From 5e993f12c1f493f3b518b651ebb3861e2a67673d Mon Sep 17 00:00:00 2001 From: root Date: Mon, 3 Nov 2008 04:05:40 +0000 Subject: [PATCH] initial import --- ...onfiguration-before-usb_claim_interf.patch | 40 + ...-do-not-reset-flash-when-probe-fails.patch | 39 + ...use-the-target-sizeof-rather-than-bu.patch | 102 + ...-syscontrol-functions-where-possible.patch | 123 + ...-strace-to-the-Blackfin-architecture.patch | 2492 +++ 1035_all_glibc-install-others.patch | 156 + 1035_all_glibc-respect-build-programs.patch | 44 + 10_all_generate-pie-scripts.patch | 14 + 600-missing_headers.patch | 11 + 80_all_binutils-2.15.96-arm-maxpagesize.patch | 16 + 950-unportability.patch | 28 + BuildToolChain-scrub.patch | 137 + MPlayer-mmap-fall-back-map-private.patch | 43 + SDL-1.2.9-6.8.patch | 52 + adsp-xml-remove-spurious.patch | 142 + alloc.c.patch | 13 + alsa-compile-scripts-set-e.patch | 20 + alsa-lib-alisp-include-less.patch | 16 + alsa-lib-build-out-of-tree.patch | 41 + alsa-lib-names-include-less.patch | 21 + alsa-lib-shared-fdpic.patch | 592 + alsa-lib-symbol-prefix-version-script.patch | 636 + apcupsd-drivers-updates.patch | 16 + apcupsd-more-phonies.patch | 14 + apcupsd-pass-recursive-errors.patch | 23 + asterisk-pic-fix.patch | 118 + audacious-plugins-useless-CXXFLAGS.patch | 66 + autoconf-2.62-fix-multiline-string.patch | 23 + baselayout-devfs.patch | 29 + bash-3.2-ulimit.patch | 13 + better-addr.patch | 83 + bfin-alsa-ad1836-cleanup.patch | 226 + bfin-alsa-lib.patch | 135 + bfin-binutils-parallel-check.patch | 16 + bfin-cleanup-reboot.patch | 602 + bfin-gc-sections.patch | 32 + bfin-libgloss-bf52x.patch | 50 + bfin-new-serial-break.patch | 41 + bfin-nommu-maps.patch | 237 + bfin-proc-mem.patch | 113 + bfin-pthreads-gcc-constraints.patch | 56 + bfin-request-exception.patch | 173 + bfin-revised-anomaly-handling.patch | 2072 ++ bfin-scrub-old-spinlock-exception.patch | 89 + bfin-traps-update.patch | 325 + bfin-uclibc-l1-fail-msg.patch | 36 + bfin_mplayer.patch | 10 + binutils-2.17-ld-dwarf-speedup.patch | 148 + binutils-bfd-no-open-dir.patch | 22 + binutils-bfd-vendor-version-tag.patch | 36 + binutils-cross-multi-libsuffix.patch | 23 + binutils-for-build.patch | 25 + binutils-freebsd-sparc64-support.patch | 160 + binutils-gas-obj-fdpicelf-2.patch | 161 + binutils-hppa32-bfd-bed.patch | 34 + binutils-i386-CONST_STRNEQ.patch | 20 + binutils-ld-default-linux-uclibc.patch | 23 + binutils-ld-discard-debuglink.patch | 21 + binutils-ld-selective-pick-CXX.patch | 61 + binutils-ld-test-defined-set.patch | 15 + binutils-libtool-generic-linux.patch | 36 + binutils-no-NBPG.patch | 17 + bitpim-search-path-for-helpers.patch | 20 + ...fin-dont-save-restore-retx-retn-rete.patch | 68 + blackfin-old-serial-sysrq.patch | 61 + blackfin-retn-or-rete.patch | 99 + blackfin-serial-cts-rts-sep-ports.patch | 181 + blackfin-set-ex-handler.patch | 71 + blackfin-simpler-gcc-lib-install.patch | 244 + blackfin-use-defines-not-constants.patch | 76 + built_with_use.patch | 23 + busybox-devmem.patch | 128 + busybox-elf2flt.patch | 33 + busybox-symlinks.patch | 111 + busybox-xioctl.patch | 62 + catalyst-cbuild.patch | 530 + catalyst-export-bools.patch | 26 + catalyst-relative-paths.patch | 200 + catalyst-s390x.patch | 32 + catalyst-sparc-setarch.patch | 20 + catalyst-use-subarch.patch | 24 + catalyst-verbose.patch | 111 + check-cross-compile-mkimage.patch | 24 + cmake-utils.eclass.patch | 27 + coreutils-dircolors-cons25.patch | 14 + coreutils-dircolors-gnome-256color.patch | 16 + coreutils-more-dircolors.patch | 89 + coreutils-xattr.diff | 303 + coreutils-xattr.patch | 313 + cracklib-libintl.patch | 11 + cryptsetup-1.0.6-svn-udev.patch | 328 + darcs-add-missing-php-tag.patch | 11 + darcs-check-preg-match.patch | 33 + darcs-world-read-email.patch | 13 + dcron-3.2-makefile.patch | 27 + dcron-3.2-pidfile.patch | 20 + dokuwiki-allow-svg-by-default.patch | 11 + dokuwiki-customizable-subjects.patch | 60 + dropbear-multi-dbscp.patch | 19 + dropbear-uclinux.patch | 46 + e2fsprogs-AC_MSG.patch | 458 + echangelog.patch | 11 + ed-0.5-build.patch | 57 + eject-2.1.5-handle-spaces.patch | 60 + eject-typos.patch | 21 + elf2flt-flat-stdint.patch | 15 + elf2flt-libintl_dgettext.patch | 50 + elf2flt-remove-unused.patch | 15 + elf2flt-stack-hex.patch | 21 + elf2flt-use-AC_MSG_ERROR.patch | 57 + elf2flt-user-label-prefix.patch | 185 + emerge-svn.diff | 2276 ++ eselect-opengl-non-multilib.patch | 37 + eterm-atom-typo.patch | 16 + eterm-init-vars-libscream.patch | 25 + f.patch | 407 + fadvise.patch | 51 + ffmpeg-bfin-dir.patch | 12 + ffmpeg-mmap-fallback.patch | 18 + file-4.19-init-file.patch | 21 + fillets-ng-autogen-makefile.patch | 13 + fillets-ng-check-for-X.patch | 56 + fillets-ng-custom-datadir.patch | 24 + fillets-ng-no-local-paths.patch | 12 + fillets-ng-use-lua-pkg-config.patch | 43 + fish-fillets-X.patch | 56 + gaim-2.0.0_beta3-always-idle.patch | 40 + gcc-ca-translation-typo.patch | 15 + gcc-cris-uclibc-subtarget.patch | 20 + gcc-default-cross-headers.patch | 16 + gcc-invert-Wattributes-doc.patch | 34 + gcc-libtool-generic-linux.patch | 36 + gcc-uclinux-not-uclibc.patch | 15 + gdb-clarify-load.patch | 24 + gdb-dont-load-world-writable-gdbinit.patch | 22 + gdb-gdbtk-no-sys-ioctl.patch | 51 + gdb-gdbtk-pull-in-windows.patch | 24 + gdb-hppa-dollar-lookups.patch | 28 + gdb-locale.patch | 58 + gdb-lookup-internal-first-2.patch | 97 + gdb-lookup-internal-first-3.patch | 124 + gdb-lookup-internal-first.patch | 96 + gdb-sim-superh-targets.patch | 22 + gdbserver-check-initial-startup.patch | 28 + gdbserver-use-execvp.patch | 15 + genext2fs-chmod-srcdir.patch | 14 + genext2fs-integrate-tests.patch | 26 + genext2fs-root-test-check.patch | 45 + genkernel-manpage-touchups.patch | 50 + ...o-handbook-integrate-ia64-bootloader.patch | 134 + glibc-2.3.6-i686.patch | 62 + glibc-2.5-linuxthreads-gai-headers.patch | 14 + glibc-alpha-no-asm-page.patch | 26 + glibc-awk-in-C-locale.patch | 17 + glibc-bash-2.patch | 31 + glibc-bash-prog-search.patch | 19 + glibc-error-header-updates.patch | 57 + glibc-fdatasync-lockf-cancellation.patch | 129 + glibc-fix-generic-strchr-signed-warning.patch | 17 + glibc-getcwd-param-MAX.patch | 14 + glibc-handle-long-kernel-versions.patch | 16 + glibc-hppa-tighter-atomic-constraints.patch | 21 + glibc-inet-network-0x.patch | 39 + glibc-libc-symbols-set-support.patch | 44 + glibc-linux-ptrace-updates.patch | 78 + glibc-locale-gen-src-install.patch | 25 + glibc-no-elf-header.patch | 178 + glibc-sh-broken-nptl-lock-macros.patch | 73 + glibc-sh-no-sys-io-header.patch | 18 + glibc-tst-network.patch | 19 + glibc-undefine-__i686.patch | 59 + gnuconfig-no-function.patch | 32 + gnulib-acl-optional.patch | 65 + hal-use-libpci.patch | 549 + hwtracebuffer.patch | 47 + imlib2-gnu99.patch | 23 + inotify.patch | 43 + iproute2-2.6.16.20060323-build.patch | 41 + iproute2-check-make-exit-status.patch | 14 + iproute2-genl-linking-order.patch | 22 + iptables-log-prefix-no-empty-strings.patch | 45 + iputils-ipg-tweaks.patch | 46 + iputils-makefile.patch | 44 + iputils-socklen.patch | 188 + iputils-use-proper-loops.patch | 137 + kbd-1.12-cz-qwerty-map.patch | 101 + kbd-1.12-jp-escape.patch | 16 + kbd-1.12-unimap.patch | 12 + kbd-1.14.1-missing-configure.patch | 15 + ldr-utils-prompt.patch | 148 + ldr.patch | 33 + ldrviewer-retry.patch | 79 + ldso-safe-runpath.patch | 14 + less.patch | 272 + libc-string-x86_64-head.diff.patch | 47 + libdv-0.104-pic-fix-pax.patch | 2007 ++ libdv-0.104-pic-fix.patch | 1995 ++ libdv-1.0.0-pic.patch | 1630 ++ libdv-cvs-pic-fix.patch | 1958 ++ libezv24.patch | 272 + libipod-build-cleanup.patch | 52 + libnfsidmap-optional-ldap.patch | 71 + libpcap-cross-linux.patch | 26 + libperl.patch | 409 + libsdl-fbcon-no-mmu-mmap.patch | 42 + libsdl-remove-joystick-limits-hack.patch | 12 + libsdl-uclinux-support.patch | 23 + libstdf-init-header-state.patch | 13 + libtool-1.5.23-tagdemo-c++.patch | 35 + libtool-blackfin-linux.patch | 63 + libtool-more-gcc-profile-linker-flags.patch | 26 + libtool-use-AC_MSG_RESULT.patch | 20 + linux-alpha-epoll-sysnums.patch | 22 + linux-blackfin-checkstack.patch | 14 + linux-check-headers-for-asm.patch | 21 + linux-clean-external-Module.symvers.patch | 15 + linux-cpufreq-kconfig-updates.patch | 193 + linux-dirent-types.patch | 13 + linux-docbook-trees.patch | 19 + linux-dont-export-asm-page.patch | 9 + linux-dont-force-enable-rts.patch | 13 + linux-export-ufs-fs-header.patch | 52 + linux-gen-init-cpio-stdin.patch | 15 + linux-get-unaligned-__val.patch | 35 + linux-headers-check-all.patch | 19 + linux-headersinst-translate-dash.patch | 15 + linux-i2c-smbus-doc-typo.patch | 17 + linux-ia64-asm-volatile-gcc-intrin.patch | 667 + linux-ia64-hide-intrin-headers.patch | 38 + linux-include-types-header.patch | 599 + linux-isdn-divertif.patch | 40 + linux-kallsyms-no-memmove.patch | 51 + linux-kconfig-libintl.patch | 21 + linux-kconfig-project-customize.patch | 160 + linux-log_buf_read.patch | 91 + linux-lxdialog-curses-search.patch | 35 + linux-lxdialog-dont-use-index-func.patch | 24 + linux-lxdialog-posix-eq.patch | 13 + linux-m68k-remove-page-from-user-header.patch | 20 + linux-move-cond-syscall-to-kernel.patch | 38 + linux-netfilter-dont-use-type-names.patch | 22 + linux-powerpc-use-__attribute__.patch | 29 + linux-ppc-defconfig.patch | 16 + linux-quota-header-spinlock.patch | 22 + linux-rename-val-in-get_unaligned.patch | 35 + linux-rtc-doc-update.patch | 146 + linux-rtc-sysfs-no-devinit-add.patch | 17 + linux-s390-use-asm-ptrace.patch | 13 + linux-scrub-GLIBC-ifdefs.patch | 24 + linux-sh-delete-PTRACE_O_TRACESYSGOOD.patch | 25 + linux-sh-ioctls.patch | 55 + linux-squash-initramfs-owners.patch | 31 + linux-sumversion-limits.patch | 12 + linux-uclinux-dont-force-root-dev.patch | 23 + linux-uinput-header.patch | 13 + linux-use-__-types-in-hdreg-header.patch | 25 + linux-use-__-types-in-i2o-header.patch | 30 + linux-use-__-types-in-parisc-statfs.patch | 23 + ...-use-__-types-in-usbdevice-fs-header.patch | 18 + linux-use-__-types-in-x86-64-msr.patch | 25 + linux-use-__asm__.patch | 84 + linux-use-posix-sed-in-headersinst.patch | 25 + linux-x86_64-msr-asm-volatile.patch | 43 + linuxthreads-ia64-tcb-typo.patch | 16 + lirc-0.8.2-out-of-tree-build-drivers.patch | 14 + lirc-0.8.2-out-of-tree-build.patch | 22 + lirc-0.8.2-out-of-tree-build3.patch | 22 + lirc-cvs-control-daemonize.patch | 167 + man-1.6d-headers.patch | 57 + man-1.6e-readonly-whatis.patch | 56 + man-1.6e-readonly-whatis2.patch | 47 + man-dont-kill-shebangs.patch | 23 + man-pages-fopen-e-flag.patch | 16 + mbuffer-makefile-cleanup.patch | 17 + mdev.patch | 130 + metalog-0.7beta-ext2attr.patch | 200 + minised-build.patch | 37 + mit-krb5-no-static-USE-flag.patch | 25 + ...-tools-3.2.2-handle-dupliate-aliases.patch | 68 + ...le-init-tools-3.2.2-try-more-tmpdirs.patch | 18 + ...e-init-tools-generate-modprobe-abort.patch | 40 + msh-pipes.patch | 16 + nano-python-string-hilite.patch | 16 + nano-trailing-space.patch | 39 + nasm-elf-visibility.patch | 221 + nasm-underquoted-AC_PROG_MAKE_VPATHOK.patch | 16 + nbd-configure-cross-compile.patch | 25 + nbd-configure-no-linux-types.patch | 18 + nbd-gznbd-makefile-cleanup.patch | 14 + nbd-needs-linux-types.patch | 18 + nbd-no-page-header.patch | 10 + netflash-cleanup.patch | 411 + netstress.patch | 155 + newlib-ebuild-cleanup.patch | 122 + nfs-utils-1.1.2-rpcgen-ioctl.patch | 12 + nfs-utils-autotools.patch | 42 + nfsd-man-see-also-exports.patch | 10 + nommu-map-list-debug.patch | 94 + nommu-map-list.patch | 165 + nommu-process-vm.patch | 176 + ode-autogen-sanity.patch | 22 + ode-configure-touchups.patch | 48 + ode-empty-x-flags.patch | 17 + openobex-check-for-EOF.patch | 16 + openobex-test-usage.patch | 50 + openocd-9999.ebuild.diff | 16 + openssh-4.4p1pkcs11-0.17.patch | 17956 ++++++++++++++++ openssh-5.0p1-blacklist.patch | 565 + openssh-opensc-libs.patch | 16 + openssl-sha-sys-types.patch | 18 + pciutils-build-touchup.patch | 22 + portage-debug-build-backend.patch | 28 + portage-debug-build.patch | 81 + portage-ecompress.patch | 386 + portage-ignore-kernel-modules.patch | 23 + portage-only-ldconfig-when-needed.patch | 58 + portage-qa-ignores.patch | 82 + portmap-build-cleanup.patch | 144 + portmap-destdir-strip.patch | 25 + portmap-help.patch | 15 + portmap-no-tcpd-header.patch | 14 + posixtestsuite-flags.patch | 95 + ppmtompeg-handle-gop.patch | 13 + ppmtompeg-no-shadow.patch | 12 + pread_write_sh.patch | 21 + ...-the-log-buffer-dont-use-ring-buffer.patch | 31 + psmisc-dont-need-c++.patch | 15 + qemu-friendlier-syscall.patch | 327 + qemu-socklen-t.patch | 30 + redland-bindings-mkdir.patch | 26 + redland-configure-threads.patch | 13 + reiserfsprogs-3.6.20-swab-non-portable.patch | 59 + rrdtool-bindings-build-cleanup.patch | 41 + sdl-check-reversed.patch | 98 + sdl-fbcon-page-header.patch | 108 + ...nline-BlitRGBtoRGBPixelAlphaMMX3DNOW.patch | 11 + sdl-sound-1.0.2-headers.patch | 12 + sdl-yasm-sections.patch | 83 + sed-help2man-locales.patch | 16 + sed-manpage-quit.patch | 23 + shadow-4.0.13-nonis.patch | 53 + shadow-4.0.14-su-fix-environment.patch | 26 + shadow-4.0.16-fix-useradd-usergroups.patch | 95 + shadow-abort-when-man-support-fails.patch | 25 + shadow-document-USERGROUPS_ENAB.patch | 32 + shadow-fix-useradd-usergroups.patch | 127 + shadow-friendly-selinux.patch | 41 + shadow-no-innetgr-simpler.patch | 65 + shadow-no-innetgr.patch | 88 + shadow-su-logging.patch | 14 + shadow-user-friendly-man-error.patch | 23 + shadow-useradd-no-gid-option.patch | 19 + shadow-userdel-grammar-touchup.patch | 11 + sqlite-cross-compile.patch | 223 + sqlite-readline.patch | 132 + sysklogd-1.4.1-accept.patch | 13 + syslinux-3.36-nopie.patch | 27 + telnetd-ptmx.patch | 44 + tftp-hpa-0.45-parallel.patch | 13 + thread_stack.patch | 26 + trylinkbug.diff | 90 + u-boot-MAKEALL-size.patch | 13 + u-boot-cpp-linker-script.patch | 268 + u-boot-envcrc-export.patch | 74 + u-boot-init-rts.patch | 39 + u-boot-jump-cmd.patch | 58 + u-boot-nand-warning.patch | 15 + u-boot-nand.patch | 12 + u-boot-nicer-version-handling.patch | 41 + u-boot-no-TEXT_BASE.patch | 29 + u-boot-no-host-ppc-check.patch | 26 + uCam.patch | 96 + uClibc-0.9.28.3-endian.patch | 30 + uClibc-0.9.29-libc_string_tester_memcmp.diff | 42 + uClibc-mutex-cancel.patch | 8631 ++++++++ uclibc-cleanup-whitespaces.patch | 77 + uclibc-misc1.diff | 157 + uclibc-pt-manager.patch | 20 + uclibc-tempname3.patch | 36 + uclinux-config-help-source.patch | 40 + uclinux-dosfstools-headers.patch | 31 + uclinux-flashw-cleanup.patch | 49 + uclinux-libpcap-config.patch | 14 + uclinux-libpcap-host.patch | 13 + uclinux-makefile-cksum.patch | 12 + uclinux-makefile-makearch.patch | 11 + uclinux-no-autoconf-included-define.patch | 43 + uclinux-ntp-makefile.patch | 45 + uclinux-picocom.patch | 5202 +++++ uclinux-sash-cleanup.patch | 50 + uclinux-search-LINUXDIR-for-defconfig.patch | 37 + uclinux-sysutils-cleanup.patch | 163 + uclinux-user-makefile-customize.patch | 21 + uclinux-vendors-eat-dos-gremlins.patch | 340 + uclinux-vplay-mixer.patch | 29 + udev-ccw-renaming.patch | 10 + udev-restart.patch | 61 + udev-state.patch | 64 + util-linux-autogen-set.patch | 12 + util-linux-fdisk-check-change-return.patch | 121 + util-linux-mount-bg-fstab.patch | 97 + util-linux-no-error-on-fake-mount.patch | 13 + util-linux-readprofile-stext.patch | 14 + util-linux-swapon-cleanup.patch | 85 + util-linux-swapon-headers.patch | 16 + util-linux-tests-source.patch | 514 + vfb-module-kconfig-docs.patch | 16 + visibility_hidden.m4-AC_DEFINE.patch | 30 + watchdog-headers.patch | 98 + wine-debug-checks.patch | 62 + xiptech-sdl-1.2.9.patch | 286 + xiptech-xmame-0.105.patch | 807 + xmame-0.104-6.8.patch | 25 + zziplib-doc-typo.patch | 16 + zziplib-read-void.patch | 49 + 415 files changed, 75920 insertions(+) create mode 100644 0001-call-usb_set_configuration-before-usb_claim_interf.patch create mode 100644 0001-cfi_flash-do-not-reset-flash-when-probe-fails.patch create mode 100644 0001-tools-envcrc.c-use-the-target-sizeof-rather-than-bu.patch create mode 100644 0001-use-syscontrol-functions-where-possible.patch create mode 100644 0002-Port-strace-to-the-Blackfin-architecture.patch create mode 100644 1035_all_glibc-install-others.patch create mode 100644 1035_all_glibc-respect-build-programs.patch create mode 100644 10_all_generate-pie-scripts.patch create mode 100644 600-missing_headers.patch create mode 100644 80_all_binutils-2.15.96-arm-maxpagesize.patch create mode 100644 950-unportability.patch create mode 100644 BuildToolChain-scrub.patch create mode 100644 MPlayer-mmap-fall-back-map-private.patch create mode 100644 SDL-1.2.9-6.8.patch create mode 100644 adsp-xml-remove-spurious.patch create mode 100644 alloc.c.patch create mode 100644 alsa-compile-scripts-set-e.patch create mode 100644 alsa-lib-alisp-include-less.patch create mode 100644 alsa-lib-build-out-of-tree.patch create mode 100644 alsa-lib-names-include-less.patch create mode 100644 alsa-lib-shared-fdpic.patch create mode 100644 alsa-lib-symbol-prefix-version-script.patch create mode 100644 apcupsd-drivers-updates.patch create mode 100644 apcupsd-more-phonies.patch create mode 100644 apcupsd-pass-recursive-errors.patch create mode 100644 asterisk-pic-fix.patch create mode 100644 audacious-plugins-useless-CXXFLAGS.patch create mode 100644 autoconf-2.62-fix-multiline-string.patch create mode 100644 baselayout-devfs.patch create mode 100644 bash-3.2-ulimit.patch create mode 100644 better-addr.patch create mode 100644 bfin-alsa-ad1836-cleanup.patch create mode 100644 bfin-alsa-lib.patch create mode 100644 bfin-binutils-parallel-check.patch create mode 100644 bfin-cleanup-reboot.patch create mode 100644 bfin-gc-sections.patch create mode 100644 bfin-libgloss-bf52x.patch create mode 100644 bfin-new-serial-break.patch create mode 100644 bfin-nommu-maps.patch create mode 100644 bfin-proc-mem.patch create mode 100644 bfin-pthreads-gcc-constraints.patch create mode 100644 bfin-request-exception.patch create mode 100644 bfin-revised-anomaly-handling.patch create mode 100644 bfin-scrub-old-spinlock-exception.patch create mode 100644 bfin-traps-update.patch create mode 100644 bfin-uclibc-l1-fail-msg.patch create mode 100644 bfin_mplayer.patch create mode 100644 binutils-2.17-ld-dwarf-speedup.patch create mode 100644 binutils-bfd-no-open-dir.patch create mode 100644 binutils-bfd-vendor-version-tag.patch create mode 100644 binutils-cross-multi-libsuffix.patch create mode 100644 binutils-for-build.patch create mode 100644 binutils-freebsd-sparc64-support.patch create mode 100644 binutils-gas-obj-fdpicelf-2.patch create mode 100644 binutils-hppa32-bfd-bed.patch create mode 100644 binutils-i386-CONST_STRNEQ.patch create mode 100644 binutils-ld-default-linux-uclibc.patch create mode 100644 binutils-ld-discard-debuglink.patch create mode 100644 binutils-ld-selective-pick-CXX.patch create mode 100644 binutils-ld-test-defined-set.patch create mode 100644 binutils-libtool-generic-linux.patch create mode 100644 binutils-no-NBPG.patch create mode 100644 bitpim-search-path-for-helpers.patch create mode 100644 blackfin-dont-save-restore-retx-retn-rete.patch create mode 100644 blackfin-old-serial-sysrq.patch create mode 100644 blackfin-retn-or-rete.patch create mode 100644 blackfin-serial-cts-rts-sep-ports.patch create mode 100644 blackfin-set-ex-handler.patch create mode 100644 blackfin-simpler-gcc-lib-install.patch create mode 100644 blackfin-use-defines-not-constants.patch create mode 100644 built_with_use.patch create mode 100644 busybox-devmem.patch create mode 100644 busybox-elf2flt.patch create mode 100644 busybox-symlinks.patch create mode 100644 busybox-xioctl.patch create mode 100644 catalyst-cbuild.patch create mode 100644 catalyst-export-bools.patch create mode 100644 catalyst-relative-paths.patch create mode 100644 catalyst-s390x.patch create mode 100644 catalyst-sparc-setarch.patch create mode 100644 catalyst-use-subarch.patch create mode 100644 catalyst-verbose.patch create mode 100644 check-cross-compile-mkimage.patch create mode 100644 cmake-utils.eclass.patch create mode 100644 coreutils-dircolors-cons25.patch create mode 100644 coreutils-dircolors-gnome-256color.patch create mode 100644 coreutils-more-dircolors.patch create mode 100644 coreutils-xattr.diff create mode 100644 coreutils-xattr.patch create mode 100644 cracklib-libintl.patch create mode 100644 cryptsetup-1.0.6-svn-udev.patch create mode 100644 darcs-add-missing-php-tag.patch create mode 100644 darcs-check-preg-match.patch create mode 100644 darcs-world-read-email.patch create mode 100644 dcron-3.2-makefile.patch create mode 100644 dcron-3.2-pidfile.patch create mode 100644 dokuwiki-allow-svg-by-default.patch create mode 100644 dokuwiki-customizable-subjects.patch create mode 100644 dropbear-multi-dbscp.patch create mode 100644 dropbear-uclinux.patch create mode 100644 e2fsprogs-AC_MSG.patch create mode 100644 echangelog.patch create mode 100644 ed-0.5-build.patch create mode 100644 eject-2.1.5-handle-spaces.patch create mode 100644 eject-typos.patch create mode 100644 elf2flt-flat-stdint.patch create mode 100644 elf2flt-libintl_dgettext.patch create mode 100644 elf2flt-remove-unused.patch create mode 100644 elf2flt-stack-hex.patch create mode 100644 elf2flt-use-AC_MSG_ERROR.patch create mode 100644 elf2flt-user-label-prefix.patch create mode 100644 emerge-svn.diff create mode 100644 eselect-opengl-non-multilib.patch create mode 100644 eterm-atom-typo.patch create mode 100644 eterm-init-vars-libscream.patch create mode 100644 f.patch create mode 100644 fadvise.patch create mode 100644 ffmpeg-bfin-dir.patch create mode 100644 ffmpeg-mmap-fallback.patch create mode 100644 file-4.19-init-file.patch create mode 100644 fillets-ng-autogen-makefile.patch create mode 100644 fillets-ng-check-for-X.patch create mode 100644 fillets-ng-custom-datadir.patch create mode 100644 fillets-ng-no-local-paths.patch create mode 100644 fillets-ng-use-lua-pkg-config.patch create mode 100644 fish-fillets-X.patch create mode 100644 gaim-2.0.0_beta3-always-idle.patch create mode 100644 gcc-ca-translation-typo.patch create mode 100644 gcc-cris-uclibc-subtarget.patch create mode 100644 gcc-default-cross-headers.patch create mode 100644 gcc-invert-Wattributes-doc.patch create mode 100644 gcc-libtool-generic-linux.patch create mode 100644 gcc-uclinux-not-uclibc.patch create mode 100644 gdb-clarify-load.patch create mode 100644 gdb-dont-load-world-writable-gdbinit.patch create mode 100644 gdb-gdbtk-no-sys-ioctl.patch create mode 100644 gdb-gdbtk-pull-in-windows.patch create mode 100644 gdb-hppa-dollar-lookups.patch create mode 100644 gdb-locale.patch create mode 100644 gdb-lookup-internal-first-2.patch create mode 100644 gdb-lookup-internal-first-3.patch create mode 100644 gdb-lookup-internal-first.patch create mode 100644 gdb-sim-superh-targets.patch create mode 100644 gdbserver-check-initial-startup.patch create mode 100644 gdbserver-use-execvp.patch create mode 100644 genext2fs-chmod-srcdir.patch create mode 100644 genext2fs-integrate-tests.patch create mode 100644 genext2fs-root-test-check.patch create mode 100644 genkernel-manpage-touchups.patch create mode 100644 gentoo-handbook-integrate-ia64-bootloader.patch create mode 100644 glibc-2.3.6-i686.patch create mode 100644 glibc-2.5-linuxthreads-gai-headers.patch create mode 100644 glibc-alpha-no-asm-page.patch create mode 100644 glibc-awk-in-C-locale.patch create mode 100644 glibc-bash-2.patch create mode 100644 glibc-bash-prog-search.patch create mode 100644 glibc-error-header-updates.patch create mode 100644 glibc-fdatasync-lockf-cancellation.patch create mode 100644 glibc-fix-generic-strchr-signed-warning.patch create mode 100644 glibc-getcwd-param-MAX.patch create mode 100644 glibc-handle-long-kernel-versions.patch create mode 100644 glibc-hppa-tighter-atomic-constraints.patch create mode 100644 glibc-inet-network-0x.patch create mode 100644 glibc-libc-symbols-set-support.patch create mode 100644 glibc-linux-ptrace-updates.patch create mode 100644 glibc-locale-gen-src-install.patch create mode 100644 glibc-no-elf-header.patch create mode 100644 glibc-sh-broken-nptl-lock-macros.patch create mode 100644 glibc-sh-no-sys-io-header.patch create mode 100644 glibc-tst-network.patch create mode 100644 glibc-undefine-__i686.patch create mode 100644 gnuconfig-no-function.patch create mode 100644 gnulib-acl-optional.patch create mode 100644 hal-use-libpci.patch create mode 100644 hwtracebuffer.patch create mode 100644 imlib2-gnu99.patch create mode 100644 inotify.patch create mode 100644 iproute2-2.6.16.20060323-build.patch create mode 100644 iproute2-check-make-exit-status.patch create mode 100644 iproute2-genl-linking-order.patch create mode 100644 iptables-log-prefix-no-empty-strings.patch create mode 100644 iputils-ipg-tweaks.patch create mode 100644 iputils-makefile.patch create mode 100644 iputils-socklen.patch create mode 100644 iputils-use-proper-loops.patch create mode 100644 kbd-1.12-cz-qwerty-map.patch create mode 100644 kbd-1.12-jp-escape.patch create mode 100644 kbd-1.12-unimap.patch create mode 100644 kbd-1.14.1-missing-configure.patch create mode 100644 ldr-utils-prompt.patch create mode 100644 ldr.patch create mode 100644 ldrviewer-retry.patch create mode 100644 ldso-safe-runpath.patch create mode 100644 less.patch create mode 100644 libc-string-x86_64-head.diff.patch create mode 100644 libdv-0.104-pic-fix-pax.patch create mode 100644 libdv-0.104-pic-fix.patch create mode 100644 libdv-1.0.0-pic.patch create mode 100644 libdv-cvs-pic-fix.patch create mode 100644 libezv24.patch create mode 100644 libipod-build-cleanup.patch create mode 100644 libnfsidmap-optional-ldap.patch create mode 100644 libpcap-cross-linux.patch create mode 100644 libperl.patch create mode 100644 libsdl-fbcon-no-mmu-mmap.patch create mode 100644 libsdl-remove-joystick-limits-hack.patch create mode 100644 libsdl-uclinux-support.patch create mode 100644 libstdf-init-header-state.patch create mode 100644 libtool-1.5.23-tagdemo-c++.patch create mode 100644 libtool-blackfin-linux.patch create mode 100644 libtool-more-gcc-profile-linker-flags.patch create mode 100644 libtool-use-AC_MSG_RESULT.patch create mode 100644 linux-alpha-epoll-sysnums.patch create mode 100644 linux-blackfin-checkstack.patch create mode 100644 linux-check-headers-for-asm.patch create mode 100644 linux-clean-external-Module.symvers.patch create mode 100644 linux-cpufreq-kconfig-updates.patch create mode 100644 linux-dirent-types.patch create mode 100644 linux-docbook-trees.patch create mode 100644 linux-dont-export-asm-page.patch create mode 100644 linux-dont-force-enable-rts.patch create mode 100644 linux-export-ufs-fs-header.patch create mode 100644 linux-gen-init-cpio-stdin.patch create mode 100644 linux-get-unaligned-__val.patch create mode 100644 linux-headers-check-all.patch create mode 100644 linux-headersinst-translate-dash.patch create mode 100644 linux-i2c-smbus-doc-typo.patch create mode 100644 linux-ia64-asm-volatile-gcc-intrin.patch create mode 100644 linux-ia64-hide-intrin-headers.patch create mode 100644 linux-include-types-header.patch create mode 100644 linux-isdn-divertif.patch create mode 100644 linux-kallsyms-no-memmove.patch create mode 100644 linux-kconfig-libintl.patch create mode 100644 linux-kconfig-project-customize.patch create mode 100644 linux-log_buf_read.patch create mode 100644 linux-lxdialog-curses-search.patch create mode 100644 linux-lxdialog-dont-use-index-func.patch create mode 100644 linux-lxdialog-posix-eq.patch create mode 100644 linux-m68k-remove-page-from-user-header.patch create mode 100644 linux-move-cond-syscall-to-kernel.patch create mode 100644 linux-netfilter-dont-use-type-names.patch create mode 100644 linux-powerpc-use-__attribute__.patch create mode 100644 linux-ppc-defconfig.patch create mode 100644 linux-quota-header-spinlock.patch create mode 100644 linux-rename-val-in-get_unaligned.patch create mode 100644 linux-rtc-doc-update.patch create mode 100644 linux-rtc-sysfs-no-devinit-add.patch create mode 100644 linux-s390-use-asm-ptrace.patch create mode 100644 linux-scrub-GLIBC-ifdefs.patch create mode 100644 linux-sh-delete-PTRACE_O_TRACESYSGOOD.patch create mode 100644 linux-sh-ioctls.patch create mode 100644 linux-squash-initramfs-owners.patch create mode 100644 linux-sumversion-limits.patch create mode 100644 linux-uclinux-dont-force-root-dev.patch create mode 100644 linux-uinput-header.patch create mode 100644 linux-use-__-types-in-hdreg-header.patch create mode 100644 linux-use-__-types-in-i2o-header.patch create mode 100644 linux-use-__-types-in-parisc-statfs.patch create mode 100644 linux-use-__-types-in-usbdevice-fs-header.patch create mode 100644 linux-use-__-types-in-x86-64-msr.patch create mode 100644 linux-use-__asm__.patch create mode 100644 linux-use-posix-sed-in-headersinst.patch create mode 100644 linux-x86_64-msr-asm-volatile.patch create mode 100644 linuxthreads-ia64-tcb-typo.patch create mode 100644 lirc-0.8.2-out-of-tree-build-drivers.patch create mode 100644 lirc-0.8.2-out-of-tree-build.patch create mode 100644 lirc-0.8.2-out-of-tree-build3.patch create mode 100644 lirc-cvs-control-daemonize.patch create mode 100644 man-1.6d-headers.patch create mode 100644 man-1.6e-readonly-whatis.patch create mode 100644 man-1.6e-readonly-whatis2.patch create mode 100644 man-dont-kill-shebangs.patch create mode 100644 man-pages-fopen-e-flag.patch create mode 100644 mbuffer-makefile-cleanup.patch create mode 100644 mdev.patch create mode 100644 metalog-0.7beta-ext2attr.patch create mode 100644 minised-build.patch create mode 100644 mit-krb5-no-static-USE-flag.patch create mode 100644 module-init-tools-3.2.2-handle-dupliate-aliases.patch create mode 100644 module-init-tools-3.2.2-try-more-tmpdirs.patch create mode 100644 module-init-tools-generate-modprobe-abort.patch create mode 100644 msh-pipes.patch create mode 100644 nano-python-string-hilite.patch create mode 100644 nano-trailing-space.patch create mode 100644 nasm-elf-visibility.patch create mode 100644 nasm-underquoted-AC_PROG_MAKE_VPATHOK.patch create mode 100644 nbd-configure-cross-compile.patch create mode 100644 nbd-configure-no-linux-types.patch create mode 100644 nbd-gznbd-makefile-cleanup.patch create mode 100644 nbd-needs-linux-types.patch create mode 100644 nbd-no-page-header.patch create mode 100644 netflash-cleanup.patch create mode 100644 netstress.patch create mode 100644 newlib-ebuild-cleanup.patch create mode 100644 nfs-utils-1.1.2-rpcgen-ioctl.patch create mode 100644 nfs-utils-autotools.patch create mode 100644 nfsd-man-see-also-exports.patch create mode 100644 nommu-map-list-debug.patch create mode 100644 nommu-map-list.patch create mode 100644 nommu-process-vm.patch create mode 100644 ode-autogen-sanity.patch create mode 100644 ode-configure-touchups.patch create mode 100644 ode-empty-x-flags.patch create mode 100644 openobex-check-for-EOF.patch create mode 100644 openobex-test-usage.patch create mode 100644 openocd-9999.ebuild.diff create mode 100644 openssh-4.4p1pkcs11-0.17.patch create mode 100644 openssh-5.0p1-blacklist.patch create mode 100644 openssh-opensc-libs.patch create mode 100644 openssl-sha-sys-types.patch create mode 100644 pciutils-build-touchup.patch create mode 100644 portage-debug-build-backend.patch create mode 100644 portage-debug-build.patch create mode 100644 portage-ecompress.patch create mode 100644 portage-ignore-kernel-modules.patch create mode 100644 portage-only-ldconfig-when-needed.patch create mode 100644 portage-qa-ignores.patch create mode 100644 portmap-build-cleanup.patch create mode 100644 portmap-destdir-strip.patch create mode 100644 portmap-help.patch create mode 100644 portmap-no-tcpd-header.patch create mode 100644 posixtestsuite-flags.patch create mode 100644 ppmtompeg-handle-gop.patch create mode 100644 ppmtompeg-no-shadow.patch create mode 100644 pread_write_sh.patch create mode 100644 printk-add-interfaces-for-external-access-to-the-log-buffer-dont-use-ring-buffer.patch create mode 100644 psmisc-dont-need-c++.patch create mode 100644 qemu-friendlier-syscall.patch create mode 100644 qemu-socklen-t.patch create mode 100644 redland-bindings-mkdir.patch create mode 100644 redland-configure-threads.patch create mode 100644 reiserfsprogs-3.6.20-swab-non-portable.patch create mode 100644 rrdtool-bindings-build-cleanup.patch create mode 100644 sdl-check-reversed.patch create mode 100644 sdl-fbcon-page-header.patch create mode 100644 sdl-no-inline-BlitRGBtoRGBPixelAlphaMMX3DNOW.patch create mode 100644 sdl-sound-1.0.2-headers.patch create mode 100644 sdl-yasm-sections.patch create mode 100644 sed-help2man-locales.patch create mode 100644 sed-manpage-quit.patch create mode 100644 shadow-4.0.13-nonis.patch create mode 100644 shadow-4.0.14-su-fix-environment.patch create mode 100644 shadow-4.0.16-fix-useradd-usergroups.patch create mode 100644 shadow-abort-when-man-support-fails.patch create mode 100644 shadow-document-USERGROUPS_ENAB.patch create mode 100644 shadow-fix-useradd-usergroups.patch create mode 100644 shadow-friendly-selinux.patch create mode 100644 shadow-no-innetgr-simpler.patch create mode 100644 shadow-no-innetgr.patch create mode 100644 shadow-su-logging.patch create mode 100644 shadow-user-friendly-man-error.patch create mode 100644 shadow-useradd-no-gid-option.patch create mode 100644 shadow-userdel-grammar-touchup.patch create mode 100644 sqlite-cross-compile.patch create mode 100644 sqlite-readline.patch create mode 100644 sysklogd-1.4.1-accept.patch create mode 100644 syslinux-3.36-nopie.patch create mode 100644 telnetd-ptmx.patch create mode 100644 tftp-hpa-0.45-parallel.patch create mode 100644 thread_stack.patch create mode 100644 trylinkbug.diff create mode 100644 u-boot-MAKEALL-size.patch create mode 100644 u-boot-cpp-linker-script.patch create mode 100644 u-boot-envcrc-export.patch create mode 100644 u-boot-init-rts.patch create mode 100644 u-boot-jump-cmd.patch create mode 100644 u-boot-nand-warning.patch create mode 100644 u-boot-nand.patch create mode 100644 u-boot-nicer-version-handling.patch create mode 100644 u-boot-no-TEXT_BASE.patch create mode 100644 u-boot-no-host-ppc-check.patch create mode 100644 uCam.patch create mode 100644 uClibc-0.9.28.3-endian.patch create mode 100644 uClibc-0.9.29-libc_string_tester_memcmp.diff create mode 100644 uClibc-mutex-cancel.patch create mode 100644 uclibc-cleanup-whitespaces.patch create mode 100644 uclibc-misc1.diff create mode 100644 uclibc-pt-manager.patch create mode 100644 uclibc-tempname3.patch create mode 100644 uclinux-config-help-source.patch create mode 100644 uclinux-dosfstools-headers.patch create mode 100644 uclinux-flashw-cleanup.patch create mode 100644 uclinux-libpcap-config.patch create mode 100644 uclinux-libpcap-host.patch create mode 100644 uclinux-makefile-cksum.patch create mode 100644 uclinux-makefile-makearch.patch create mode 100644 uclinux-no-autoconf-included-define.patch create mode 100644 uclinux-ntp-makefile.patch create mode 100644 uclinux-picocom.patch create mode 100644 uclinux-sash-cleanup.patch create mode 100644 uclinux-search-LINUXDIR-for-defconfig.patch create mode 100644 uclinux-sysutils-cleanup.patch create mode 100644 uclinux-user-makefile-customize.patch create mode 100644 uclinux-vendors-eat-dos-gremlins.patch create mode 100644 uclinux-vplay-mixer.patch create mode 100644 udev-ccw-renaming.patch create mode 100644 udev-restart.patch create mode 100644 udev-state.patch create mode 100644 util-linux-autogen-set.patch create mode 100644 util-linux-fdisk-check-change-return.patch create mode 100644 util-linux-mount-bg-fstab.patch create mode 100644 util-linux-no-error-on-fake-mount.patch create mode 100644 util-linux-readprofile-stext.patch create mode 100644 util-linux-swapon-cleanup.patch create mode 100644 util-linux-swapon-headers.patch create mode 100644 util-linux-tests-source.patch create mode 100644 vfb-module-kconfig-docs.patch create mode 100644 visibility_hidden.m4-AC_DEFINE.patch create mode 100644 watchdog-headers.patch create mode 100644 wine-debug-checks.patch create mode 100644 xiptech-sdl-1.2.9.patch create mode 100644 xiptech-xmame-0.105.patch create mode 100644 xmame-0.104-6.8.patch create mode 100644 zziplib-doc-typo.patch create mode 100644 zziplib-read-void.patch diff --git a/0001-call-usb_set_configuration-before-usb_claim_interf.patch b/0001-call-usb_set_configuration-before-usb_claim_interf.patch new file mode 100644 index 0000000..9eb1acf --- /dev/null +++ b/0001-call-usb_set_configuration-before-usb_claim_interf.patch @@ -0,0 +1,40 @@ +From 128f757596a32ae23fe61711883f6210e1d90bd0 Mon Sep 17 00:00:00 2001 +From: Mike Frysinger +Date: Thu, 24 Apr 2008 02:00:15 -0400 +Subject: [PATCH] call usb_set_configuration() before usb_claim_interface() + +--- + src/ftdi.c | 10 ++++++++++ + 1 files changed, 10 insertions(+), 0 deletions(-) + +diff --git a/src/ftdi.c b/src/ftdi.c +index 043d24a..56fea0c 100644 +--- a/src/ftdi.c ++++ b/src/ftdi.c +@@ -341,6 +341,7 @@ int ftdi_usb_get_strings(struct ftdi_context * ftdi, struct usb_device * dev, + \param dev libusb usb_dev to use + + \retval 0: all fine ++ \retval -3: unable to config device + \retval -4: unable to open device + \retval -5: unable to claim device + \retval -6: reset failed +@@ -359,6 +360,15 @@ int ftdi_usb_open_dev(struct ftdi_context *ftdi, struct usb_device *dev) + detach_errno = errno; + #endif + ++ if (usb_set_configuration(ftdi->usb_dev, dev->config[0].bConfigurationValue)) { ++ usb_close (ftdi->usb_dev); ++ if (detach_errno == EPERM) { ++ ftdi_error_return(-8, "inappropriate permissions on device!"); ++ } else { ++ ftdi_error_return(-3, "unable to set usb configuration. Make sure ftdi_sio is unloaded!"); ++ } ++ } ++ + if (usb_claim_interface(ftdi->usb_dev, ftdi->interface) != 0) { + usb_close (ftdi->usb_dev); + if (detach_errno == EPERM) { +-- +1.5.5 + diff --git a/0001-cfi_flash-do-not-reset-flash-when-probe-fails.patch b/0001-cfi_flash-do-not-reset-flash-when-probe-fails.patch new file mode 100644 index 0000000..e80fc85 --- /dev/null +++ b/0001-cfi_flash-do-not-reset-flash-when-probe-fails.patch @@ -0,0 +1,39 @@ +From 14c7476b1cc961931e587aecae832f0c6e3edba1 Mon Sep 17 00:00:00 2001 +From: Mike Frysinger +Date: Thu, 2 Oct 2008 01:47:55 -0400 +Subject: [PATCH] cfi_flash: do not reset flash when probe fails + +The CFI flash driver starts at flash_init() which calls down into +flash_get_size(). This starts by calling flash_detect_cfi(). If said +function fails, flash_get_size() finishes by attempting to reset the +flash. Unfortunately, it does this with an info->portwidth set to 0x10 +which filters down into flash_make_cmd() and that happily smashes the +stack by sticking info->portwidth bytes into a cfiword_t variable that +lives on the stack. On a 64bit system you probably won't notice, but +killing the last 8 bytes on a 32bit system usually leads to a corrupt +return address. Which is what happens on a Blackfin system. + +Signed-off-by: Mike Frysinger +--- + drivers/mtd/cfi_flash.c | 3 ++- + 1 files changed, 2 insertions(+), 1 deletions(-) + +diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c +index 0d1ee8a..72d063a 100644 +--- a/drivers/mtd/cfi_flash.c ++++ b/drivers/mtd/cfi_flash.c +@@ -1932,9 +1932,10 @@ ulong flash_get_size (ulong base, int banknum) + /* XXX - Need to test on x8/x16 in parallel. */ + info->portwidth >>= 1; + } ++ ++ flash_write_cmd (info, 0, 0, info->cmd_reset); + } + +- flash_write_cmd (info, 0, 0, info->cmd_reset); + return (info->size); + } + +-- +1.6.0.2 + diff --git a/0001-tools-envcrc.c-use-the-target-sizeof-rather-than-bu.patch b/0001-tools-envcrc.c-use-the-target-sizeof-rather-than-bu.patch new file mode 100644 index 0000000..4472ab8 --- /dev/null +++ b/0001-tools-envcrc.c-use-the-target-sizeof-rather-than-bu.patch @@ -0,0 +1,102 @@ +From d7603745eb4cd64397f741746afaeba230e69bc4 Mon Sep 17 00:00:00 2001 +From: Mike Frysinger +Date: Sun, 30 Mar 2008 21:36:07 -0400 +Subject: [PATCH] tools/envcrc.c: use the target sizeof rather than build + +The envcrc.c does sizeof(unsigned long) when calculating the crc, but this +is done with the build toolchain instead of the target toolchain, so if +the build is a 64bit system but the target is 32bits, the size will +obviously be wrong. This introduces a sizeof.sh script to calculate the +required sizeof() value of any type with any compiler. + +Signed-off-by: Mike Frysinger +--- + tools/Makefile | 2 +- + tools/envcrc.c | 4 ++-- + tools/sizeof.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 48 insertions(+), 3 deletions(-) + create mode 100755 tools/sizeof.sh + +diff --git a/tools/Makefile b/tools/Makefile +index 8784a6d..7351f28 100644 +--- a/tools/Makefile ++++ b/tools/Makefile +@@ -168,7 +168,7 @@ $(obj)mpc86x_clk$(SFX): $(obj)mpc86x_clk.o + $(STRIP) $@ + + $(obj)envcrc.o: $(src)envcrc.c +- $(CC) -g $(CFLAGS) -c -o $@ $< ++ $(CC) -g $(CFLAGS) -c -o $@ $< -DTARGET_SIZEOF_ULONG=$(shell $(CONFIG_SHELL) $(src)sizeof.sh unsigned long) + + $(obj)ubsha1.o: $(src)ubsha1.c + $(CC) -g $(CFLAGS) -c -o $@ $< +diff --git a/tools/envcrc.c b/tools/envcrc.c +index 7b77183..afde912 100644 +--- a/tools/envcrc.c ++++ b/tools/envcrc.c +@@ -58,9 +58,9 @@ + #endif /* CFG_ENV_IS_IN_FLASH */ + + #ifdef CFG_REDUNDAND_ENVIRONMENT +-# define ENV_HEADER_SIZE (sizeof(unsigned long) + 1) ++# define ENV_HEADER_SIZE (TARGET_SIZEOF_ULONG + 1) + #else +-# define ENV_HEADER_SIZE (sizeof(unsigned long)) ++# define ENV_HEADER_SIZE (TARGET_SIZEOF_ULONG) + #endif + + #define ENV_SIZE (CFG_ENV_SIZE - ENV_HEADER_SIZE) +diff --git a/tools/sizeof.sh b/tools/sizeof.sh +new file mode 100755 +index 0000000..4eadb3c +--- /dev/null ++++ b/tools/sizeof.sh +@@ -0,0 +1,45 @@ ++#!/bin/sh ++# Copyright (C) 2000, 2001, 2002, 2004, 2005, 2006 Free Software ++# Foundation, Inc. ++# Licensed under the GPL-2 or later. ++ ++# ++# Get the sizeof(type) for a compiler ++# ++ ++type="$*" ++CC=${CC:-gcc} ++ ++if [ -z "$type" ] ; then ++ echo "Usage: sizeof.sh " 1>&2 ++ exit 1 ++fi ++ ++test_size() { ++ cat <<-EOF > sizeof.c ++ typedef $type ac__type_sizeof_; ++ int main() { ++ static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $size)]; ++ test_array [0] = 0; ++ return 0; ++ } ++ EOF ++ ${CC} -c sizeof.c >/dev/null 2>&1 ++ ret=$? ++ rm -f sizeof.[co] ++ return $ret ++} ++ ++size=4 ++while [ ${size} -lt 512 ] ; do ++ if test_size ${size} ; then ++ ((size-=1)) ++ while test_size ${size} ; do ++ ((size-=1)) ++ done ++ echo $((size+1)) ++ exit 0 ++ fi ++ ((size+=4)) ++done ++exit 1 +-- +1.5.4.4 + diff --git a/0001-use-syscontrol-functions-where-possible.patch b/0001-use-syscontrol-functions-where-possible.patch new file mode 100644 index 0000000..8f5f121 --- /dev/null +++ b/0001-use-syscontrol-functions-where-possible.patch @@ -0,0 +1,123 @@ +From f2501ad7f47f0b912b53e3e2094e9bfe12f2a491 Mon Sep 17 00:00:00 2001 +From: Mike Frysinger +Date: Fri, 4 Jan 2008 17:05:28 -0500 +Subject: [PATCH] use syscontrol functions where possible + +this works on my bf548-ezkit 0.1 and should use the bootrom func to +program the memory which means the otp fps will be taken into account +--- + cpu/blackfin/initcode.c | 57 +++++++++++++++++++++++++++++----------------- + cpu/blackfin/reset.c | 8 +++++- + 2 files changed, 42 insertions(+), 23 deletions(-) + +diff --git a/cpu/blackfin/initcode.c b/cpu/blackfin/initcode.c +index 360caa8..1e39043 100644 +--- a/cpu/blackfin/initcode.c ++++ b/cpu/blackfin/initcode.c +@@ -299,34 +299,49 @@ void initcode(ADI_BOOT_DATA *bootstruct) + bfin_write_SIC_IWR(1); + #endif + +- serial_putc('L'); ++ /* With newer bootroms, we use the helper function to set up ++ * the memory controller. Older bootroms lacks such helpers ++ * so we do it ourselves. ++ */ ++ if (BOOTROM_CAPS_SYSCONTROL) { ++ serial_putc('S'); + +- bfin_write_PLL_LOCKCNT(CONFIG_PLL_LOCKCNT_VAL); ++ ADI_SYSCTRL_VALUES memory_settings; ++ memory_settings.uwVrCtl = CONFIG_VR_CTL_VAL; ++ memory_settings.uwPllCtl = CONFIG_PLL_CTL_VAL; ++ memory_settings.uwPllDiv = CONFIG_PLL_DIV_VAL; ++ memory_settings.uwPllLockCnt = CONFIG_PLL_LOCKCNT_VAL; ++ syscontrol(SYSCTRL_WRITE | SYSCTRL_PLLCTL | SYSCTRL_PLLDIV | SYSCTRL_VRCTL | SYSCTRL_INTVOLTAGE, &memory_settings, NULL); ++ } else { ++ serial_putc('L'); + +- serial_putc('A'); ++ bfin_write_PLL_LOCKCNT(CONFIG_PLL_LOCKCNT_VAL); + +- /* Only reprogram when needed to avoid triggering unnecessary +- * PLL relock sequences. +- */ +- if (bfin_read_VR_CTL() != CONFIG_VR_CTL_VAL) { +- serial_putc('!'); +- bfin_write_VR_CTL(CONFIG_VR_CTL_VAL); +- asm("idle;"); +- } ++ serial_putc('A'); + +- serial_putc('C'); ++ /* Only reprogram when needed to avoid triggering unnecessary ++ * PLL relock sequences. ++ */ ++ if (bfin_read_VR_CTL() != CONFIG_VR_CTL_VAL) { ++ serial_putc('!'); ++ bfin_write_VR_CTL(CONFIG_VR_CTL_VAL); ++ asm("idle;"); ++ } + +- bfin_write_PLL_DIV(CONFIG_PLL_DIV_VAL); ++ serial_putc('C'); + +- serial_putc('K'); ++ bfin_write_PLL_DIV(CONFIG_PLL_DIV_VAL); + +- /* Only reprogram when needed to avoid triggering unnecessary +- * PLL relock sequences. +- */ +- if (bfin_read_PLL_CTL() != CONFIG_PLL_CTL_VAL) { +- serial_putc('!'); +- bfin_write_PLL_CTL(CONFIG_PLL_CTL_VAL); +- asm("idle;"); ++ serial_putc('K'); ++ ++ /* Only reprogram when needed to avoid triggering unnecessary ++ * PLL relock sequences. ++ */ ++ if (bfin_read_PLL_CTL() != CONFIG_PLL_CTL_VAL) { ++ serial_putc('!'); ++ bfin_write_PLL_CTL(CONFIG_PLL_CTL_VAL); ++ asm("idle;"); ++ } + } + + /* Since we've changed the SCLK above, we may need to update +diff --git a/cpu/blackfin/reset.c b/cpu/blackfin/reset.c +index b796740..be08d80 100644 +--- a/cpu/blackfin/reset.c ++++ b/cpu/blackfin/reset.c +@@ -8,6 +8,7 @@ + #include + #include + #include ++#include + #include "cpu.h" + + /* A system soft reset makes external memory unusable so force +@@ -19,7 +20,7 @@ + * the core reset. + */ + __attribute__ ((__l1_text__, __noreturn__)) +-void bfin_reset(void) ++static void bfin_reset(void) + { + /* Wait for completion of "system" events such as cache line + * line fills so that we avoid infinite stalls later on as +@@ -75,7 +76,10 @@ static inline void bfin_reset_trampoline(void) + if (board_reset) + board_reset(); + while (1) +- asm("jump (%0);" : : "a" (bfin_reset)); ++ if (0 /*BOOTROM_CAPS_SYSCONTROL -- current silicon is broken*/) ++ syscontrol(SYSCTRL_SOFTRESET, NULL, NULL); ++ else ++ asm("jump (%0);" : : "a" (bfin_reset)); + } + + __attribute__ ((__noreturn__)) +-- +1.5.5.3 + diff --git a/0002-Port-strace-to-the-Blackfin-architecture.patch b/0002-Port-strace-to-the-Blackfin-architecture.patch new file mode 100644 index 0000000..3b80f0c --- /dev/null +++ b/0002-Port-strace-to-the-Blackfin-architecture.patch @@ -0,0 +1,2492 @@ +From 8a5cbbf0cda1076b300e27a6108a0dcabd807858 Mon Sep 17 00:00:00 2001 +From: Mike Frysinger +Date: Thu, 18 Sep 2008 17:05:40 -0400 +Subject: [PATCH] Port strace to the Blackfin architecture + +2008-10-23 Mike Frysinger + + * configure.ac: Add bfin to supported architectures. + * process.c: Skip u_fpvalid/u_fpstate for Blackfin architecture. + (change_syscall): Support Blackfin architecture. + * syscall.c: Declare r0 for Blackfin architecture. + (get_scno): Decode Blackfin syscall number. + (syscall_fixup): Extract Blackfin return value. + (get_error): Decode Blackfin return value. + (force_result): Poke Blackfin return value. + (syscall_enter): Extract Blackfin syscall arguments. + * defs.h: Define TCB_WAITEXECVE for Blackfin architecture. + * linux/syscall.h (sys_sram_alloc): Declare for Blackfin architecture. + * system.c (sys_sram_alloc): Decode Blackfin sram_alloc() syscall. + * util.c (getpc): Handle PC on Blackfin architecture. + (printcall): Likewise. + * linux/bfin/ioctlent.h, linux/bfin/syscallent.h: New Blackfin headers. + * Makefile.am (EXTRA_DIST): Add linux/bfin/ioctlent.h and + linux/bfin/syscallent.h. + +Signed-off-by: Mike Frysinger +--- + Makefile.am | 1 + + configure.ac | 4 + + defs.h | 2 +- + linux/bfin/ioctlent.h | 1792 +++++++++++++++++++++++++++++++++++++++++++++++ + linux/bfin/syscallent.h | 391 +++++++++++ + linux/syscall.h | 4 + + process.c | 8 +- + syscall.c | 41 ++ + system.c | 27 + + util.c | 11 + + 10 files changed, 2278 insertions(+), 3 deletions(-) + create mode 100644 linux/bfin/ioctlent.h + create mode 100644 linux/bfin/syscallent.h + +diff --git a/Makefile.am b/Makefile.am +index 54492cf..7fdc7fd 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -34,6 +34,7 @@ EXTRA_DIST = $(man_MANS) errnoent.sh signalent.sh syscallent.sh ioctlsort.c \ + linux/arm/syscallent.h linux/arm/syscallent1.h \ + linux/arm/signalent1.h linux/arm/ioctlent1.h \ + linux/arm/errnoent1.h \ ++ linux/bfin/ioctlent.h linux/bfin/syscallent.h \ + linux/hppa/errnoent.h linux/hppa/ioctlent.h \ + linux/hppa/signalent.h linux/hppa/syscallent.h \ + linux/ia64/syscallent.h linux/ia64/errnoent.h \ +diff --git a/configure.ac b/configure.ac +index 9852e20..3554ab6 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -43,6 +43,10 @@ AC_MSG_RESULT($opsys) + + AC_MSG_CHECKING([for supported architecture]) + case "$host_cpu" in ++bfin) ++ arch=bfin ++ AC_DEFINE([BFIN], 1, [Define for the Blackfin architecture.]) ++ ;; + i[[3456]]86|pentium) + arch=i386 + AC_DEFINE([I386], 1, [Define for the i386 architecture.]) +diff --git a/defs.h b/defs.h +index 2a44ae7..4b051d0 100644 +--- a/defs.h ++++ b/defs.h +@@ -356,7 +356,7 @@ struct tcb { + #define TCB_FOLLOWFORK 00400 /* Process should have forks followed */ + #define TCB_REPRINT 01000 /* We should reprint this syscall on exit */ + #ifdef LINUX +-# if defined(ALPHA) || defined(SPARC) || defined(SPARC64) || defined(POWERPC) || defined(IA64) || defined(HPPA) || defined(SH) || defined(SH64) || defined(S390) || defined(S390X) || defined(ARM) || defined(MIPS) ++# if defined(ALPHA) || defined(SPARC) || defined(SPARC64) || defined(POWERPC) || defined(IA64) || defined(HPPA) || defined(SH) || defined(SH64) || defined(S390) || defined(S390X) || defined(ARM) || defined(MIPS) || defined(BFIN) + # define TCB_WAITEXECVE 02000 /* ignore SIGTRAP after exceve */ + # endif + # define TCB_CLONE_DETACHED 04000 /* CLONE_DETACHED set in creating syscall */ +diff --git a/linux/bfin/ioctlent.h b/linux/bfin/ioctlent.h +new file mode 100644 +index 0000000..63b0417 +--- /dev/null ++++ b/linux/bfin/ioctlent.h +@@ -0,0 +1,1792 @@ ++ /* Generated by ioctlsort */ ++ {"linux/fs.h", "FIBMAP", 0x1}, ++ {"linux/fs.h", "FIGETBSZ", 0x2}, ++ {"linux/fd.h", "FDGETPRM", 0x204}, ++ {"linux/fd.h", "FDGETMAXERRS", 0x20e}, ++ {"linux/fd.h", "FDGETDRVTYP", 0x20f}, ++ {"linux/fd.h", "FDGETDRVPRM", 0x211}, ++ {"linux/fd.h", "FDGETDRVSTAT", 0x212}, ++ {"linux/fd.h", "FDPOLLDRVSTAT", 0x213}, ++ {"linux/fd.h", "FDGETFDCSTAT", 0x215}, ++ {"linux/fd.h", "FDWERRORGET", 0x217}, ++ {"linux/fd.h", "FDCLRPRM", 0x241}, ++ {"linux/fd.h", "FDSETPRM", 0x242}, ++ {"linux/fd.h", "FDDEFPRM", 0x243}, ++ {"linux/fd.h", "FDMSGON", 0x245}, ++ {"linux/fd.h", "FDMSGOFF", 0x246}, ++ {"linux/fd.h", "FDFMTBEG", 0x247}, ++ {"linux/fd.h", "FDFMTTRK", 0x248}, ++ {"linux/fd.h", "FDFMTEND", 0x249}, ++ {"linux/fd.h", "FDSETEMSGTRESH", 0x24a}, ++ {"linux/fd.h", "FDFLUSH", 0x24b}, ++ {"linux/fd.h", "FDSETMAXERRS", 0x24c}, ++ {"linux/fd.h", "FDRESET", 0x254}, ++ {"linux/fd.h", "FDWERRORCLR", 0x256}, ++ {"linux/fd.h", "FDRAWCMD", 0x258}, ++ {"linux/fd.h", "FDTWADDLE", 0x259}, ++ {"linux/fd.h", "FDEJECT", 0x25a}, ++ {"linux/fd.h", "FDSETDRVPRM", 0x290}, ++ {"linux/raid/md_u.h", "RAID_VERSION", 0x910}, ++ {"linux/raid/md_u.h", "GET_ARRAY_INFO", 0x911}, ++ {"linux/raid/md_u.h", "GET_DISK_INFO", 0x912}, ++ {"linux/raid/md_u.h", "PRINT_RAID_DEBUG", 0x913}, ++ {"linux/raid/md_u.h", "RAID_AUTORUN", 0x914}, ++ {"linux/raid/md_u.h", "GET_BITMAP_FILE", 0x915}, ++ {"linux/raid/md_u.h", "CLEAR_ARRAY", 0x920}, ++ {"linux/raid/md_u.h", "ADD_NEW_DISK", 0x921}, ++ {"linux/raid/md_u.h", "HOT_REMOVE_DISK", 0x922}, ++ {"linux/raid/md_u.h", "SET_ARRAY_INFO", 0x923}, ++ {"linux/raid/md_u.h", "SET_DISK_INFO", 0x924}, ++ {"linux/raid/md_u.h", "WRITE_RAID_INFO", 0x925}, ++ {"linux/raid/md_u.h", "UNPROTECT_ARRAY", 0x926}, ++ {"linux/raid/md_u.h", "PROTECT_ARRAY", 0x927}, ++ {"linux/raid/md_u.h", "HOT_ADD_DISK", 0x928}, ++ {"linux/raid/md_u.h", "SET_DISK_FAULTY", 0x929}, ++ {"linux/raid/md_u.h", "HOT_GENERATE_ERROR", 0x92a}, ++ {"linux/raid/md_u.h", "SET_BITMAP_FILE", 0x92b}, ++ {"linux/raid/md_u.h", "RUN_ARRAY", 0x930}, ++ {"linux/raid/md_u.h", "STOP_ARRAY", 0x932}, ++ {"linux/raid/md_u.h", "STOP_ARRAY_RO", 0x933}, ++ {"linux/raid/md_u.h", "RESTART_ARRAY_RW", 0x934}, ++ {"linux/fs.h", "BLKROSET", 0x125d}, ++ {"linux/fs.h", "BLKROGET", 0x125e}, ++ {"linux/fs.h", "BLKRRPART", 0x125f}, ++ {"linux/fs.h", "BLKGETSIZE", 0x1260}, ++ {"linux/fs.h", "BLKFLSBUF", 0x1261}, ++ {"linux/fs.h", "BLKRASET", 0x1262}, ++ {"linux/fs.h", "BLKRAGET", 0x1263}, ++ {"linux/fs.h", "BLKFRASET", 0x1264}, ++ {"linux/fs.h", "BLKFRAGET", 0x1265}, ++ {"linux/fs.h", "BLKSECTSET", 0x1266}, ++ {"linux/fs.h", "BLKSECTGET", 0x1267}, ++ {"linux/fs.h", "BLKSSZGET", 0x1268}, ++ {"linux/blkpg.h", "BLKPG", 0x1269}, ++ {"linux/fs.h", "BLKELVGET", 0x126a}, ++ {"linux/fs.h", "BLKELVSET", 0x126b}, ++ {"linux/fs.h", "BLKBSZGET", 0x1270}, ++ {"linux/fs.h", "BLKBSZSET", 0x1271}, ++ {"linux/fs.h", "BLKGETSIZE64", 0x1272}, ++ {"linux/fs.h", "BLKTRACESETUP", 0x1273}, ++ {"linux/fs.h", "BLKTRACESTART", 0x1274}, ++ {"linux/fs.h", "BLKTRACESTOP", 0x1275}, ++ {"linux/fs.h", "BLKTRACETEARDOWN", 0x1276}, ++ {"rdma/ib_user_mad.h", "IB_USER_MAD_REGISTER_AGENT", 0x1b01}, ++ {"rdma/ib_user_mad.h", "IB_USER_MAD_UNREGISTER_AGENT", 0x1b02}, ++ {"rdma/ib_user_mad.h", "IB_USER_MAD_ENABLE_PKEY", 0x1b03}, ++ {"scsi/sg.h", "SG_SET_TIMEOUT", 0x2201}, ++ {"scsi/sg.h", "SG_GET_TIMEOUT", 0x2202}, ++ {"scsi/sg.h", "SG_EMULATED_HOST", 0x2203}, ++ {"scsi/sg.h", "SG_SET_TRANSFORM", 0x2204}, ++ {"scsi/sg.h", "SG_GET_TRANSFORM", 0x2205}, ++ {"scsi/sg.h", "SG_GET_COMMAND_Q", 0x2270}, ++ {"scsi/sg.h", "SG_SET_COMMAND_Q", 0x2271}, ++ {"scsi/sg.h", "SG_GET_RESERVED_SIZE", 0x2272}, ++ {"scsi/sg.h", "SG_SET_RESERVED_SIZE", 0x2275}, ++ {"scsi/sg.h", "SG_GET_SCSI_ID", 0x2276}, ++ {"scsi/sg.h", "SG_SET_FORCE_LOW_DMA", 0x2279}, ++ {"scsi/sg.h", "SG_GET_LOW_DMA", 0x227a}, ++ {"scsi/sg.h", "SG_SET_FORCE_PACK_ID", 0x227b}, ++ {"scsi/sg.h", "SG_GET_PACK_ID", 0x227c}, ++ {"scsi/sg.h", "SG_GET_NUM_WAITING", 0x227d}, ++ {"scsi/sg.h", "SG_SET_DEBUG", 0x227e}, ++ {"scsi/sg.h", "SG_GET_SG_TABLESIZE", 0x227f}, ++ {"scsi/sg.h", "SG_GET_VERSION_NUM", 0x2282}, ++ {"scsi/sg.h", "SG_NEXT_CMD_LEN", 0x2283}, ++ {"scsi/sg.h", "SG_SCSI_RESET", 0x2284}, ++ {"scsi/sg.h", "SG_IO", 0x2285}, ++ {"scsi/sg.h", "SG_GET_REQUEST_TABLE", 0x2286}, ++ {"scsi/sg.h", "SG_SET_KEEP_ORPHAN", 0x2287}, ++ {"scsi/sg.h", "SG_GET_KEEP_ORPHAN", 0x2288}, ++ {"scsi/sg.h", "SG_GET_ACCESS_COUNT", 0x2289}, ++ {"linux/firewire-cdev.h", "FW_CDEV_IOC_GET_INFO", 0x2300}, ++ {"linux/firewire-cdev.h", "FW_CDEV_IOC_SEND_REQUEST", 0x2301}, ++ {"linux/firewire-cdev.h", "FW_CDEV_IOC_ALLOCATE", 0x2302}, ++ {"linux/firewire-cdev.h", "FW_CDEV_IOC_DEALLOCATE", 0x2303}, ++ {"linux/firewire-cdev.h", "FW_CDEV_IOC_SEND_RESPONSE", 0x2304}, ++ {"linux/firewire-cdev.h", "FW_CDEV_IOC_INITIATE_BUS_RESET", 0x2305}, ++ {"linux/firewire-cdev.h", "FW_CDEV_IOC_ADD_DESCRIPTOR", 0x2306}, ++ {"linux/firewire-cdev.h", "FW_CDEV_IOC_REMOVE_DESCRIPTOR", 0x2307}, ++ {"linux/firewire-cdev.h", "FW_CDEV_IOC_CREATE_ISO_CONTEXT", 0x2308}, ++ {"linux/firewire-cdev.h", "FW_CDEV_IOC_QUEUE_ISO", 0x2309}, ++ {"linux/firewire-cdev.h", "FW_CDEV_IOC_START_ISO", 0x230a}, ++ {"linux/firewire-cdev.h", "FW_CDEV_IOC_STOP_ISO", 0x230b}, ++ {"linux/firewire-cdev.h", "FW_CDEV_IOC_GET_CYCLE_TIMER", 0x230c}, ++ {"linux/i2o.h", "BLKI2OGRSTRAT", 0x3201}, ++ {"linux/i2o.h", "BLKI2OGWSTRAT", 0x3202}, ++ {"linux/i2o.h", "BLKI2OSRSTRAT", 0x3203}, ++ {"linux/i2o.h", "BLKI2OSWSTRAT", 0x3204}, ++ {"linux/suspend_ioctls.h", "SNAPSHOT_FREEZE", 0x3301}, ++ {"linux/suspend_ioctls.h", "SNAPSHOT_UNFREEZE", 0x3302}, ++ {"linux/suspend_ioctls.h", "SNAPSHOT_ATOMIC_RESTORE", 0x3304}, ++ {"linux/suspend_ioctls.h", "SNAPSHOT_FREE", 0x3305}, ++ {"linux/suspend_ioctls.h", "SNAPSHOT_FREE_SWAP_PAGES", 0x3309}, ++ {"linux/suspend_ioctls.h", "SNAPSHOT_S2RAM", 0x330b}, ++ {"linux/suspend_ioctls.h", "SNAPSHOT_SET_SWAP_AREA", 0x330d}, ++ {"linux/suspend_ioctls.h", "SNAPSHOT_GET_IMAGE_SIZE", 0x330e}, ++ {"linux/suspend_ioctls.h", "SNAPSHOT_PLATFORM_SUPPORT", 0x330f}, ++ {"linux/suspend_ioctls.h", "SNAPSHOT_POWER_OFF", 0x3310}, ++ {"linux/suspend_ioctls.h", "SNAPSHOT_CREATE_IMAGE", 0x3311}, ++ {"linux/suspend_ioctls.h", "SNAPSHOT_PREF_IMAGE_SIZE", 0x3312}, ++ {"linux/suspend_ioctls.h", "SNAPSHOT_AVAIL_SWAP_SIZE", 0x3313}, ++ {"linux/suspend_ioctls.h", "SNAPSHOT_ALLOC_SWAP_PAGE", 0x3314}, ++ {"linux/radeonfb.h", "FBIO_RADEON_GET_MIRROR", 0x4003}, ++ {"linux/radeonfb.h", "FBIO_RADEON_SET_MIRROR", 0x4004}, ++ {"linux/agpgart.h", "AGPIOC_INFO", 0x4100}, ++ {"linux/agpgart.h", "AGPIOC_ACQUIRE", 0x4101}, ++ {"linux/apm_bios.h", "APM_IOC_STANDBY", 0x4101}, ++ {"linux/agpgart.h", "AGPIOC_RELEASE", 0x4102}, ++ {"linux/apm_bios.h", "APM_IOC_SUSPEND", 0x4102}, ++ {"linux/agpgart.h", "AGPIOC_SETUP", 0x4103}, ++ {"linux/agpgart.h", "AGPIOC_RESERVE", 0x4104}, ++ {"linux/agpgart.h", "AGPIOC_PROTECT", 0x4105}, ++ {"linux/agpgart.h", "AGPIOC_ALLOCATE", 0x4106}, ++ {"linux/agpgart.h", "AGPIOC_DEALLOCATE", 0x4107}, ++ {"linux/agpgart.h", "AGPIOC_BIND", 0x4108}, ++ {"linux/agpgart.h", "AGPIOC_UNBIND", 0x4109}, ++ {"linux/agpgart.h", "AGPIOC_CHIPSET_FLUSH", 0x410a}, ++ {"linux/pmu.h", "PMU_IOC_SLEEP", 0x4200}, ++ {"linux/cciss_ioctl.h", "CCISS_GETPCIINFO", 0x4201}, ++ {"linux/pmu.h", "PMU_IOC_GET_BACKLIGHT", 0x4201}, ++ {"linux/cciss_ioctl.h", "CCISS_GETINTINFO", 0x4202}, ++ {"linux/pmu.h", "PMU_IOC_SET_BACKLIGHT", 0x4202}, ++ {"linux/cciss_ioctl.h", "CCISS_SETINTINFO", 0x4203}, ++ {"linux/pmu.h", "PMU_IOC_GET_MODEL", 0x4203}, ++ {"linux/cciss_ioctl.h", "CCISS_GETNODENAME", 0x4204}, ++ {"linux/pmu.h", "PMU_IOC_HAS_ADB", 0x4204}, ++ {"linux/cciss_ioctl.h", "CCISS_SETNODENAME", 0x4205}, ++ {"linux/pmu.h", "PMU_IOC_CAN_SLEEP", 0x4205}, ++ {"linux/cciss_ioctl.h", "CCISS_GETHEARTBEAT", 0x4206}, ++ {"linux/pmu.h", "PMU_IOC_GRAB_BACKLIGHT", 0x4206}, ++ {"linux/cciss_ioctl.h", "CCISS_GETBUSTYPES", 0x4207}, ++ {"linux/cciss_ioctl.h", "CCISS_GETFIRMVER", 0x4208}, ++ {"linux/cciss_ioctl.h", "CCISS_GETDRIVVER", 0x4209}, ++ {"linux/cciss_ioctl.h", "CCISS_REVALIDVOLS", 0x420a}, ++ {"linux/cciss_ioctl.h", "CCISS_PASSTHRU", 0x420b}, ++ {"linux/cciss_ioctl.h", "CCISS_PASSTHRU32", 0x420b}, ++ {"linux/cciss_ioctl.h", "CCISS_DEREGDISK", 0x420c}, ++ {"linux/cciss_ioctl.h", "CCISS_REGNEWDISK", 0x420d}, ++ {"linux/cciss_ioctl.h", "CCISS_REGNEWD", 0x420e}, ++ {"linux/cciss_ioctl.h", "CCISS_RESCANDISK", 0x4210}, ++ {"linux/cciss_ioctl.h", "CCISS_GETLUNINFO", 0x4211}, ++ {"linux/cciss_ioctl.h", "CCISS_BIG_PASSTHRU", 0x4212}, ++ {"linux/cciss_ioctl.h", "CCISS_BIG_PASSTHRU32", 0x4212}, ++ {"linux/soundcard.h", "SNDCTL_COPR_RESET", 0x4300}, ++ {"linux/capi.h", "CAPI_REGISTER", 0x4301}, ++ {"linux/soundcard.h", "SNDCTL_COPR_LOAD", 0x4301}, ++ {"linux/soundcard.h", "SNDCTL_COPR_RDATA", 0x4302}, ++ {"linux/soundcard.h", "SNDCTL_COPR_RCODE", 0x4303}, ++ {"linux/soundcard.h", "SNDCTL_COPR_WDATA", 0x4304}, ++ {"linux/soundcard.h", "SNDCTL_COPR_WCODE", 0x4305}, ++ {"linux/capi.h", "CAPI_GET_MANUFACTURER", 0x4306}, ++ {"linux/soundcard.h", "SNDCTL_COPR_RUN", 0x4306}, ++ {"linux/capi.h", "CAPI_GET_VERSION", 0x4307}, ++ {"linux/soundcard.h", "SNDCTL_COPR_HALT", 0x4307}, ++ {"linux/capi.h", "CAPI_GET_SERIAL", 0x4308}, ++ {"linux/soundcard.h", "SNDCTL_COPR_SENDMSG", 0x4308}, ++ {"linux/capi.h", "CAPI_GET_PROFILE", 0x4309}, ++ {"linux/soundcard.h", "SNDCTL_COPR_RCVMSG", 0x4309}, ++ {"linux/capi.h", "CAPI_MANUFACTURER_CMD", 0x4320}, ++ {"linux/capi.h", "CAPI_GET_ERRCODE", 0x4321}, ++ {"linux/capi.h", "CAPI_INSTALLED", 0x4322}, ++ {"linux/capi.h", "CAPI_GET_FLAGS", 0x4323}, ++ {"linux/capi.h", "CAPI_SET_FLAGS", 0x4324}, ++ {"linux/capi.h", "CAPI_CLR_FLAGS", 0x4325}, ++ {"linux/capi.h", "CAPI_NCCI_OPENCOUNT", 0x4326}, ++ {"linux/capi.h", "CAPI_NCCI_GETUNIT", 0x4327}, ++ {"linux/input.h", "EVIOCGVERSION", 0x4501}, ++ {"linux/input.h", "EVIOCGID", 0x4502}, ++ {"linux/input.h", "EVIOCGREP", 0x4503}, ++ {"linux/input.h", "EVIOCSREP", 0x4503}, ++ {"linux/input.h", "EVIOCGKEYCODE", 0x4504}, ++ {"linux/input.h", "EVIOCSKEYCODE", 0x4504}, ++ {"linux/input.h", "EVIOCRMFF", 0x4581}, ++ {"linux/input.h", "EVIOCGEFFECTS", 0x4584}, ++ {"linux/input.h", "EVIOCGRAB", 0x4590}, ++ {"linux/fb.h", "FBIOGET_VSCREENINFO", 0x4600}, ++ {"linux/fb.h", "FBIOPUT_VSCREENINFO", 0x4601}, ++ {"linux/fb.h", "FBIOGET_FSCREENINFO", 0x4602}, ++ {"linux/fb.h", "FBIOGETCMAP", 0x4604}, ++ {"linux/fb.h", "FBIOPUTCMAP", 0x4605}, ++ {"linux/fb.h", "FBIOPAN_DISPLAY", 0x4606}, ++ {"linux/fb.h", "FBIO_CURSOR", 0x4608}, ++ {"linux/fb.h", "FBIOGET_CON2FBMAP", 0x460f}, ++ {"linux/fb.h", "FBIOPUT_CON2FBMAP", 0x4610}, ++ {"linux/fb.h", "FBIOBLANK", 0x4611}, ++ {"linux/fb.h", "FBIOGET_VBLANK", 0x4612}, ++ {"linux/fb.h", "FBIO_ALLOC", 0x4613}, ++ {"linux/fb.h", "FBIO_FREE", 0x4614}, ++ {"linux/fb.h", "FBIOGET_GLYPH", 0x4615}, ++ {"linux/fb.h", "FBIOGET_HWCINFO", 0x4616}, ++ {"linux/fb.h", "FBIOPUT_MODEINFO", 0x4617}, ++ {"linux/fb.h", "FBIOGET_DISPINFO", 0x4618}, ++ {"linux/ivtvfb.h", "FBIO_WAITFORVSYNC", 0x4620}, ++ {"linux/matroxfb.h", "FBIO_WAITFORVSYNC", 0x4620}, ++ {"linux/arcfb.h", "FBIO_WAITEVENT", 0x4688}, ++ {"linux/arcfb.h", "FBIO_GETCONTROL2", 0x4689}, ++ {"video/sstfb.h", "SSTFB_GET_VGAPASS", 0x46dd}, ++ {"video/sstfb.h", "SSTFB_SET_VGAPASS", 0x46dd}, ++ {"linux/gigaset_dev.h", "GIGASET_REDIR", 0x4700}, ++ {"linux/gigaset_dev.h", "GIGASET_CONFIG", 0x4701}, ++ {"linux/gigaset_dev.h", "GIGASET_BRKCHARS", 0x4702}, ++ {"linux/gigaset_dev.h", "GIGASET_VERSION", 0x4703}, ++ {"linux/hidraw.h", "HIDIOCGRDESCSIZE", 0x4801}, ++ {"linux/hiddev.h", "HIDIOCGVERSION", 0x4801}, ++ {"linux/hiddev.h", "HIDIOCAPPLICATION", 0x4802}, ++ {"linux/hidraw.h", "HIDIOCGRDESC", 0x4802}, ++ {"linux/hiddev.h", "HIDIOCGDEVINFO", 0x4803}, ++ {"linux/hidraw.h", "HIDIOCGRAWINFO", 0x4803}, ++ {"linux/hiddev.h", "HIDIOCGSTRING", 0x4804}, ++ {"linux/hiddev.h", "HIDIOCINITREPORT", 0x4805}, ++ {"linux/hiddev.h", "HIDIOCGREPORT", 0x4807}, ++ {"linux/hiddev.h", "HIDIOCSREPORT", 0x4808}, ++ {"linux/hiddev.h", "HIDIOCGREPORTINFO", 0x4809}, ++ {"linux/hiddev.h", "HIDIOCGFIELDINFO", 0x480a}, ++ {"linux/hiddev.h", "HIDIOCGUSAGE", 0x480b}, ++ {"linux/hiddev.h", "HIDIOCSUSAGE", 0x480c}, ++ {"linux/hiddev.h", "HIDIOCGUCODE", 0x480d}, ++ {"linux/hiddev.h", "HIDIOCGFLAG", 0x480e}, ++ {"linux/hiddev.h", "HIDIOCSFLAG", 0x480f}, ++ {"sound/hda_hwdep.h", "HDA_IOCTL_PVERSION", 0x4810}, ++ {"linux/hiddev.h", "HIDIOCGCOLLECTIONINDEX", 0x4810}, ++ {"sound/emu10k1.h", "SNDRV_EMU10K1_IOCTL_INFO", 0x4810}, ++ {"sound/sb16_csp.h", "SNDRV_SB_CSP_IOCTL_INFO", 0x4810}, ++ {"sound/hda_hwdep.h", "HDA_IOCTL_VERB_WRITE", 0x4811}, ++ {"linux/hiddev.h", "HIDIOCGCOLLECTIONINFO", 0x4811}, ++ {"sound/emu10k1.h", "SNDRV_EMU10K1_IOCTL_CODE_POKE", 0x4811}, ++ {"sound/sb16_csp.h", "SNDRV_SB_CSP_IOCTL_LOAD_CODE", 0x4811}, ++ {"sound/hda_hwdep.h", "HDA_IOCTL_GET_WCAP", 0x4812}, ++ {"sound/emu10k1.h", "SNDRV_EMU10K1_IOCTL_CODE_PEEK", 0x4812}, ++ {"sound/sb16_csp.h", "SNDRV_SB_CSP_IOCTL_UNLOAD_CODE", 0x4812}, ++ {"linux/hiddev.h", "HIDIOCGUSAGES", 0x4813}, ++ {"sound/sb16_csp.h", "SNDRV_SB_CSP_IOCTL_START", 0x4813}, ++ {"linux/hiddev.h", "HIDIOCSUSAGES", 0x4814}, ++ {"sound/sb16_csp.h", "SNDRV_SB_CSP_IOCTL_STOP", 0x4814}, ++ {"sound/sb16_csp.h", "SNDRV_SB_CSP_IOCTL_PAUSE", 0x4815}, ++ {"sound/sb16_csp.h", "SNDRV_SB_CSP_IOCTL_RESTART", 0x4816}, ++ {"sound/asound_fm.h", "SNDRV_DM_FM_IOCTL_INFO", 0x4820}, ++ {"sound/emu10k1.h", "SNDRV_EMU10K1_IOCTL_TRAM_SETUP", 0x4820}, ++ {"sound/asound_fm.h", "SNDRV_DM_FM_IOCTL_RESET", 0x4821}, ++ {"sound/emu10k1.h", "SNDRV_EMU10K1_IOCTL_TRAM_POKE", 0x4821}, ++ {"sound/asound_fm.h", "SNDRV_DM_FM_IOCTL_PLAY_NOTE", 0x4822}, ++ {"sound/emu10k1.h", "SNDRV_EMU10K1_IOCTL_TRAM_PEEK", 0x4822}, ++ {"sound/asound_fm.h", "SNDRV_DM_FM_IOCTL_SET_VOICE", 0x4823}, ++ {"sound/asound_fm.h", "SNDRV_DM_FM_IOCTL_SET_PARAMS", 0x4824}, ++ {"sound/asound_fm.h", "SNDRV_DM_FM_IOCTL_SET_MODE", 0x4825}, ++ {"sound/asound_fm.h", "SNDRV_DM_FM_IOCTL_SET_CONNECTION", 0x4826}, ++ {"sound/emu10k1.h", "SNDRV_EMU10K1_IOCTL_PCM_POKE", 0x4830}, ++ {"sound/emu10k1.h", "SNDRV_EMU10K1_IOCTL_PCM_PEEK", 0x4831}, ++ {"sound/asound_fm.h", "SNDRV_DM_FM_IOCTL_CLEAR_PATCHES", 0x4840}, ++ {"sound/emu10k1.h", "SNDRV_EMU10K1_IOCTL_PVERSION", 0x4840}, ++ {"sound/hdsp.h", "SNDRV_HDSP_IOCTL_GET_PEAK_RMS", 0x4840}, ++ {"sound/hdsp.h", "SNDRV_HDSP_IOCTL_GET_CONFIG_INFO", 0x4841}, ++ {"sound/hdsp.h", "SNDRV_HDSP_IOCTL_UPLOAD_FIRMWARE", 0x4842}, ++ {"sound/hdspm.h", "SNDRV_HDSPM_IOCTL_GET_VERSION", 0x4843}, ++ {"sound/hdsp.h", "SNDRV_HDSP_IOCTL_GET_VERSION", 0x4843}, ++ {"sound/hdspm.h", "SNDRV_HDSPM_IOCTL_GET_MIXER", 0x4844}, ++ {"sound/hdsp.h", "SNDRV_HDSP_IOCTL_GET_MIXER", 0x4844}, ++ {"sound/hdsp.h", "SNDRV_HDSP_IOCTL_GET_9632_AEB", 0x4845}, ++ {"sound/emu10k1.h", "SNDRV_EMU10K1_IOCTL_STOP", 0x4880}, ++ {"sound/emu10k1.h", "SNDRV_EMU10K1_IOCTL_CONTINUE", 0x4881}, ++ {"sound/emu10k1.h", "SNDRV_EMU10K1_IOCTL_ZERO_TRAM_COUNTER", 0x4882}, ++ {"sound/emu10k1.h", "SNDRV_EMU10K1_IOCTL_SINGLE_STEP", 0x4883}, ++ {"sound/emu10k1.h", "SNDRV_EMU10K1_IOCTL_DBG_READ", 0x4884}, ++ {"net/bluetooth/hci.h", "HCIDEVUP", 0x48c9}, ++ {"net/bluetooth/hci.h", "HCIDEVDOWN", 0x48ca}, ++ {"net/bluetooth/hci.h", "HCIDEVRESET", 0x48cb}, ++ {"net/bluetooth/hci.h", "HCIDEVRESTAT", 0x48cc}, ++ {"net/bluetooth/hci.h", "HCIGETDEVLIST", 0x48d2}, ++ {"net/bluetooth/hci.h", "HCIGETDEVINFO", 0x48d3}, ++ {"net/bluetooth/hci.h", "HCIGETCONNLIST", 0x48d4}, ++ {"net/bluetooth/hci.h", "HCIGETCONNINFO", 0x48d5}, ++ {"net/bluetooth/hci.h", "HCISETRAW", 0x48dc}, ++ {"net/bluetooth/hci.h", "HCISETSCAN", 0x48dd}, ++ {"net/bluetooth/hci.h", "HCISETAUTH", 0x48de}, ++ {"net/bluetooth/hci.h", "HCISETENCRYPT", 0x48df}, ++ {"net/bluetooth/hci.h", "HCISETPTYPE", 0x48e0}, ++ {"net/bluetooth/hci.h", "HCISETLINKPOL", 0x48e1}, ++ {"net/bluetooth/hci.h", "HCISETLINKMODE", 0x48e2}, ++ {"net/bluetooth/hci.h", "HCISETACLMTU", 0x48e3}, ++ {"net/bluetooth/hci.h", "HCISETSCOMTU", 0x48e4}, ++ {"net/bluetooth/hci.h", "HCISETSECMGR", 0x48e6}, ++ {"net/bluetooth/hci.h", "HCIINQUIRY", 0x48f0}, ++ {"linux/isdn.h", "IIOCNETAIF", 0x4901}, ++ {"linux/isdn.h", "IIOCNETDIF", 0x4902}, ++ {"linux/isdn.h", "IIOCNETSCF", 0x4903}, ++ {"linux/isdn.h", "IIOCNETGCF", 0x4904}, ++ {"linux/isdn.h", "IIOCNETANM", 0x4905}, ++ {"linux/isdn.h", "IIOCNETDNM", 0x4906}, ++ {"linux/isdn.h", "IIOCNETGNM", 0x4907}, ++ {"linux/isdn.h", "IIOCGETSET", 0x4908}, ++ {"linux/isdn.h", "IIOCSETSET", 0x4909}, ++ {"linux/isdn.h", "IIOCSETVER", 0x490a}, ++ {"linux/isdn.h", "IIOCNETHUP", 0x490b}, ++ {"linux/isdn.h", "IIOCSETGST", 0x490c}, ++ {"linux/isdn.h", "IIOCSETBRJ", 0x490d}, ++ {"linux/isdn.h", "IIOCSIGPRF", 0x490e}, ++ {"linux/isdn.h", "IIOCGETPRF", 0x490f}, ++ {"linux/isdn.h", "IIOCSETPRF", 0x4910}, ++ {"linux/isdn.h", "IIOCGETMAP", 0x4911}, ++ {"linux/isdn.h", "IIOCSETMAP", 0x4912}, ++ {"linux/isdn.h", "IIOCNETASL", 0x4913}, ++ {"linux/isdn.h", "IIOCNETDIL", 0x4914}, ++ {"linux/isdn.h", "IIOCGETCPS", 0x4915}, ++ {"linux/isdn.h", "IIOCGETDVR", 0x4916}, ++ {"linux/isdn.h", "IIOCNETLCR", 0x4917}, ++ {"linux/isdn.h", "IIOCNETDWRSET", 0x4918}, ++ {"linux/isdn.h", "IIOCNETALN", 0x4920}, ++ {"linux/isdn.h", "IIOCNETDLN", 0x4921}, ++ {"linux/isdn.h", "IIOCNETGPN", 0x4922}, ++ {"linux/isdn.h", "IIOCDBGVAR", 0x497f}, ++ {"linux/isdn.h", "IIOCDRVCTL", 0x4980}, ++ {"linux/kd.h", "KIOCSOUND", 0x4b2f}, ++ {"linux/kd.h", "KDMKTONE", 0x4b30}, ++ {"linux/kd.h", "KDGETLED", 0x4b31}, ++ {"linux/kd.h", "KDSETLED", 0x4b32}, ++ {"linux/kd.h", "KDGKBTYPE", 0x4b33}, ++ {"linux/kd.h", "KDADDIO", 0x4b34}, ++ {"linux/kd.h", "KDDELIO", 0x4b35}, ++ {"linux/kd.h", "KDENABIO", 0x4b36}, ++ {"linux/kd.h", "KDDISABIO", 0x4b37}, ++ {"linux/kd.h", "KDSETMODE", 0x4b3a}, ++ {"linux/kd.h", "KDGETMODE", 0x4b3b}, ++ {"linux/kd.h", "KDMAPDISP", 0x4b3c}, ++ {"linux/kd.h", "KDUNMAPDISP", 0x4b3d}, ++ {"linux/kd.h", "GIO_SCRNMAP", 0x4b40}, ++ {"linux/kd.h", "PIO_SCRNMAP", 0x4b41}, ++ {"linux/kd.h", "KDGKBMODE", 0x4b44}, ++ {"linux/kd.h", "KDSKBMODE", 0x4b45}, ++ {"linux/kd.h", "KDGKBENT", 0x4b46}, ++ {"linux/kd.h", "KDSKBENT", 0x4b47}, ++ {"linux/kd.h", "KDGKBSENT", 0x4b48}, ++ {"linux/kd.h", "KDSKBSENT", 0x4b49}, ++ {"linux/kd.h", "KDGKBDIACR", 0x4b4a}, ++ {"linux/kd.h", "KDSKBDIACR", 0x4b4b}, ++ {"linux/kd.h", "KDGETKEYCODE", 0x4b4c}, ++ {"linux/kd.h", "KDSETKEYCODE", 0x4b4d}, ++ {"linux/kd.h", "KDSIGACCEPT", 0x4b4e}, ++ {"linux/kd.h", "KDKBDREP", 0x4b52}, ++ {"linux/kd.h", "GIO_FONT", 0x4b60}, ++ {"linux/kd.h", "PIO_FONT", 0x4b61}, ++ {"linux/kd.h", "KDGKBMETA", 0x4b62}, ++ {"linux/kd.h", "KDSKBMETA", 0x4b63}, ++ {"linux/kd.h", "KDGKBLED", 0x4b64}, ++ {"linux/kd.h", "KDSKBLED", 0x4b65}, ++ {"linux/kd.h", "GIO_UNIMAP", 0x4b66}, ++ {"linux/kd.h", "PIO_UNIMAP", 0x4b67}, ++ {"linux/kd.h", "PIO_UNIMAPCLR", 0x4b68}, ++ {"linux/kd.h", "GIO_UNISCRNMAP", 0x4b69}, ++ {"linux/kd.h", "PIO_UNISCRNMAP", 0x4b6a}, ++ {"linux/kd.h", "GIO_FONTX", 0x4b6b}, ++ {"linux/kd.h", "PIO_FONTX", 0x4b6c}, ++ {"linux/kd.h", "PIO_FONTRESET", 0x4b6d}, ++ {"linux/kd.h", "GIO_CMAP", 0x4b70}, ++ {"linux/kd.h", "PIO_CMAP", 0x4b71}, ++ {"linux/kd.h", "KDFONTOP", 0x4b72}, ++ {"linux/kd.h", "KDGKBDIACRUC", 0x4bfa}, ++ {"linux/kd.h", "KDSKBDIACRUC", 0x4bfb}, ++ {"mtd/mtd-abi.h", "MEMGETINFO", 0x4d01}, ++ {"mtd/mtd-abi.h", "MEMERASE", 0x4d02}, ++ {"mtd/mtd-abi.h", "MEMWRITEOOB", 0x4d03}, ++ {"mtd/mtd-abi.h", "MEMREADOOB", 0x4d04}, ++ {"mtd/mtd-abi.h", "MEMLOCK", 0x4d05}, ++ {"mtd/mtd-abi.h", "MEMUNLOCK", 0x4d06}, ++ {"mtd/mtd-abi.h", "MEMGETREGIONCOUNT", 0x4d07}, ++ {"mtd/mtd-abi.h", "MEMGETREGIONINFO", 0x4d08}, ++ {"mtd/mtd-abi.h", "MEMSETOOBSEL", 0x4d09}, ++ {"mtd/mtd-abi.h", "MEMGETOOBSEL", 0x4d0a}, ++ {"mtd/mtd-abi.h", "MEMGETBADBLOCK", 0x4d0b}, ++ {"mtd/mtd-abi.h", "MEMSETBADBLOCK", 0x4d0c}, ++ {"mtd/mtd-abi.h", "OTPSELECT", 0x4d0d}, ++ {"mtd/mtd-abi.h", "OTPGETREGIONCOUNT", 0x4d0e}, ++ {"mtd/mtd-abi.h", "OTPGETREGIONINFO", 0x4d0f}, ++ {"mtd/mtd-abi.h", "OTPLOCK", 0x4d10}, ++ {"mtd/mtd-abi.h", "ECCGETLAYOUT", 0x4d11}, ++ {"mtd/mtd-abi.h", "ECCGETSTATS", 0x4d12}, ++ {"mtd/mtd-abi.h", "MTDFILEMODE", 0x4d13}, ++ {"linux/soundcard.h", "SOUND_MIXER_INFO", 0x4d65}, ++ {"linux/soundcard.h", "SOUND_OLD_MIXER_INFO", 0x4d65}, ++ {"linux/soundcard.h", "SOUND_MIXER_ACCESS", 0x4d66}, ++ {"linux/soundcard.h", "SOUND_MIXER_AGC", 0x4d67}, ++ {"linux/soundcard.h", "SOUND_MIXER_3DSE", 0x4d68}, ++ {"linux/soundcard.h", "SOUND_MIXER_PRIVATE1", 0x4d6f}, ++ {"linux/soundcard.h", "SOUND_MIXER_PRIVATE2", 0x4d70}, ++ {"linux/soundcard.h", "SOUND_MIXER_PRIVATE3", 0x4d71}, ++ {"linux/soundcard.h", "SOUND_MIXER_PRIVATE4", 0x4d72}, ++ {"linux/soundcard.h", "SOUND_MIXER_PRIVATE5", 0x4d73}, ++ {"linux/soundcard.h", "SOUND_MIXER_GETLEVELS", 0x4d74}, ++ {"linux/soundcard.h", "SOUND_MIXER_SETLEVELS", 0x4d75}, ++ {"linux/soundcard.h", "OSS_GETVERSION", 0x4d76}, ++ {"linux/ticable.h", "IOCTL_TIUSB_TIMEOUT", 0x4e20}, ++ {"linux/ticable.h", "IOCTL_TIUSB_RESET_DEVICE", 0x4e21}, ++ {"linux/ticable.h", "IOCTL_TIUSB_RESET_PIPES", 0x4e22}, ++ {"linux/ticable.h", "IOCTL_TIUSB_GET_MAXPS", 0x4e23}, ++ {"linux/ticable.h", "IOCTL_TIUSB_GET_DEVID", 0x4e24}, ++ {"mtd/ubi-user.h", "UBI_IOCVOLUP", 0x4f00}, ++ {"mtd/ubi-user.h", "UBI_IOCEBER", 0x4f01}, ++ {"mtd/ubi-user.h", "UBI_IOCEBCH", 0x4f02}, ++ {"linux/soundcard.h", "SNDCTL_DSP_RESET", 0x5000}, ++ {"linux/soundcard.h", "SNDCTL_DSP_SYNC", 0x5001}, ++ {"asm/bfin_sport.h", "SPORT_IOC_CONFIG", 0x5001}, ++ {"asm/bfin_sport.h", "ENABLE_AD73311", 0x5002}, ++ {"linux/soundcard.h", "SNDCTL_DSP_SPEED", 0x5002}, ++ {"linux/soundcard.h", "SOUND_PCM_READ_RATE", 0x5002}, ++ {"linux/soundcard.h", "SNDCTL_DSP_STEREO", 0x5003}, ++ {"linux/soundcard.h", "SNDCTL_DSP_GETBLKSIZE", 0x5004}, ++ {"linux/soundcard.h", "SNDCTL_DSP_SETFMT", 0x5005}, ++ {"linux/soundcard.h", "SOUND_PCM_READ_BITS", 0x5005}, ++ {"linux/soundcard.h", "SNDCTL_DSP_CHANNELS", 0x5006}, ++ {"linux/soundcard.h", "SOUND_PCM_READ_CHANNELS", 0x5006}, ++ {"linux/soundcard.h", "SOUND_PCM_READ_FILTER", 0x5007}, ++ {"linux/soundcard.h", "SOUND_PCM_WRITE_FILTER", 0x5007}, ++ {"linux/soundcard.h", "SNDCTL_DSP_POST", 0x5008}, ++ {"linux/soundcard.h", "SNDCTL_DSP_SUBDIVIDE", 0x5009}, ++ {"linux/soundcard.h", "SNDCTL_DSP_SETFRAGMENT", 0x500a}, ++ {"linux/soundcard.h", "SNDCTL_DSP_GETFMTS", 0x500b}, ++ {"linux/soundcard.h", "SNDCTL_DSP_GETOSPACE", 0x500c}, ++ {"linux/soundcard.h", "SNDCTL_DSP_GETISPACE", 0x500d}, ++ {"linux/soundcard.h", "SNDCTL_DSP_NONBLOCK", 0x500e}, ++ {"linux/soundcard.h", "SNDCTL_DSP_GETCAPS", 0x500f}, ++ {"linux/soundcard.h", "SNDCTL_DSP_GETTRIGGER", 0x5010}, ++ {"linux/soundcard.h", "SNDCTL_DSP_SETTRIGGER", 0x5010}, ++ {"linux/soundcard.h", "SNDCTL_DSP_GETIPTR", 0x5011}, ++ {"linux/soundcard.h", "SNDCTL_DSP_GETOPTR", 0x5012}, ++ {"linux/soundcard.h", "SNDCTL_DSP_MAPINBUF", 0x5013}, ++ {"linux/soundcard.h", "SNDCTL_DSP_MAPOUTBUF", 0x5014}, ++ {"linux/soundcard.h", "SNDCTL_DSP_SETSYNCRO", 0x5015}, ++ {"linux/soundcard.h", "SNDCTL_DSP_SETDUPLEX", 0x5016}, ++ {"linux/soundcard.h", "SNDCTL_DSP_GETODELAY", 0x5017}, ++ {"linux/soundcard.h", "SNDCTL_DSP_PROFILE", 0x5017}, ++ {"linux/soundcard.h", "SNDCTL_DSP_GETCHANNELMASK", 0x5040}, ++ {"linux/soundcard.h", "SNDCTL_DSP_BIND_CHANNEL", 0x5041}, ++ {"linux/soundcard.h", "SNDCTL_DSP_SETSPDIF", 0x5042}, ++ {"linux/soundcard.h", "SNDCTL_DSP_GETSPDIF", 0x5043}, ++ {"sound/sscape_ioctl.h", "SND_SSCAPE_LOAD_BOOTB", 0x5064}, ++ {"sound/sscape_ioctl.h", "SND_SSCAPE_LOAD_MCODE", 0x5065}, ++ {"linux/soundcard.h", "SNDCTL_SEQ_RESET", 0x5100}, ++ {"linux/soundcard.h", "SNDCTL_SEQ_SYNC", 0x5101}, ++ {"linux/soundcard.h", "SNDCTL_SYNTH_INFO", 0x5102}, ++ {"linux/soundcard.h", "SNDCTL_SEQ_CTRLRATE", 0x5103}, ++ {"linux/soundcard.h", "SNDCTL_SEQ_GETOUTCOUNT", 0x5104}, ++ {"linux/soundcard.h", "SNDCTL_SEQ_GETINCOUNT", 0x5105}, ++ {"linux/soundcard.h", "SNDCTL_SEQ_PERCMODE", 0x5106}, ++ {"linux/soundcard.h", "SNDCTL_FM_LOAD_INSTR", 0x5107}, ++ {"linux/soundcard.h", "SNDCTL_SEQ_TESTMIDI", 0x5108}, ++ {"linux/soundcard.h", "SNDCTL_SEQ_RESETSAMPLES", 0x5109}, ++ {"linux/soundcard.h", "SNDCTL_SEQ_NRSYNTHS", 0x510a}, ++ {"linux/soundcard.h", "SNDCTL_SEQ_NRMIDIS", 0x510b}, ++ {"linux/soundcard.h", "SNDCTL_MIDI_INFO", 0x510c}, ++ {"linux/soundcard.h", "SNDCTL_SEQ_THRESHOLD", 0x510d}, ++ {"linux/soundcard.h", "SNDCTL_SYNTH_MEMAVL", 0x510e}, ++ {"linux/soundcard.h", "SNDCTL_FM_4OP_ENABLE", 0x510f}, ++ {"linux/soundcard.h", "SNDCTL_SEQ_PANIC", 0x5111}, ++ {"linux/soundcard.h", "SNDCTL_SEQ_OUTOFBAND", 0x5112}, ++ {"linux/soundcard.h", "SNDCTL_SEQ_GETTIME", 0x5113}, ++ {"linux/soundcard.h", "SNDCTL_SYNTH_ID", 0x5114}, ++ {"linux/soundcard.h", "SNDCTL_SYNTH_CONTROL", 0x5115}, ++ {"linux/soundcard.h", "SNDCTL_SYNTH_REMOVESAMPLE", 0x5116}, ++ {"linux/random.h", "RNDGETENTCNT", 0x5200}, ++ {"media/rds.h", "RDS_CMD_OPEN", 0x5201}, ++ {"linux/random.h", "RNDADDTOENTCNT", 0x5201}, ++ {"media/rds.h", "RDS_CMD_CLOSE", 0x5202}, ++ {"linux/random.h", "RNDGETPOOL", 0x5202}, ++ {"media/rds.h", "RDS_CMD_READ", 0x5203}, ++ {"linux/random.h", "RNDADDENTROPY", 0x5203}, ++ {"media/rds.h", "RDS_CMD_POLL", 0x5204}, ++ {"linux/random.h", "RNDZAPENTCNT", 0x5204}, ++ {"linux/random.h", "RNDCLEARPOOL", 0x5206}, ++ {"net/bluetooth/rfcomm.h", "RFCOMMCREATEDEV", 0x52c8}, ++ {"net/bluetooth/rfcomm.h", "RFCOMMRELEASEDEV", 0x52c9}, ++ {"net/bluetooth/rfcomm.h", "RFCOMMGETDEVLIST", 0x52d2}, ++ {"net/bluetooth/rfcomm.h", "RFCOMMGETDEVINFO", 0x52d3}, ++ {"net/bluetooth/rfcomm.h", "RFCOMMSTEALDLC", 0x52dc}, ++ {"sound/asequencer.h", "SNDRV_SEQ_IOCTL_PVERSION", 0x5300}, ++ {"linux/cdrom.h", "CDROMPAUSE", 0x5301}, ++ {"sound/asequencer.h", "SNDRV_SEQ_IOCTL_CLIENT_ID", 0x5301}, ++ {"linux/cdrom.h", "CDROMRESUME", 0x5302}, ++ {"sound/asequencer.h", "SNDRV_SEQ_IOCTL_SYSTEM_INFO", 0x5302}, ++ {"linux/cdrom.h", "CDROMPLAYMSF", 0x5303}, ++ {"sound/asequencer.h", "SNDRV_SEQ_IOCTL_RUNNING_MODE", 0x5303}, ++ {"linux/cdrom.h", "CDROMPLAYTRKIND", 0x5304}, ++ {"linux/cdrom.h", "CDROMREADTOCHDR", 0x5305}, ++ {"linux/cdrom.h", "CDROMREADTOCENTRY", 0x5306}, ++ {"linux/cdrom.h", "CDROMSTOP", 0x5307}, ++ {"linux/cdrom.h", "CDROMSTART", 0x5308}, ++ {"linux/cdrom.h", "CDROMEJECT", 0x5309}, ++ {"linux/cdrom.h", "CDROMVOLCTRL", 0x530a}, ++ {"linux/cdrom.h", "CDROMSUBCHNL", 0x530b}, ++ {"linux/cdrom.h", "CDROMREADMODE2", 0x530c}, ++ {"linux/cdrom.h", "CDROMREADMODE1", 0x530d}, ++ {"linux/cdrom.h", "CDROMREADAUDIO", 0x530e}, ++ {"linux/cdrom.h", "CDROMEJECT_SW", 0x530f}, ++ {"linux/cdrom.h", "CDROMMULTISESSION", 0x5310}, ++ {"sound/asequencer.h", "SNDRV_SEQ_IOCTL_GET_CLIENT_INFO", 0x5310}, ++ {"linux/cdrom.h", "CDROM_GET_MCN", 0x5311}, ++ {"sound/asequencer.h", "SNDRV_SEQ_IOCTL_SET_CLIENT_INFO", 0x5311}, ++ {"linux/cdrom.h", "CDROMRESET", 0x5312}, ++ {"linux/cdrom.h", "CDROMVOLREAD", 0x5313}, ++ {"linux/cdrom.h", "CDROMREADRAW", 0x5314}, ++ {"linux/cdrom.h", "CDROMREADCOOKED", 0x5315}, ++ {"linux/cdrom.h", "CDROMSEEK", 0x5316}, ++ {"linux/cdrom.h", "CDROMPLAYBLK", 0x5317}, ++ {"linux/cdrom.h", "CDROMREADALL", 0x5318}, ++ {"linux/cdrom.h", "CDROMCLOSETRAY", 0x5319}, ++ {"linux/cdrom.h", "CDROMGETSPINDOWN", 0x531d}, ++ {"linux/cdrom.h", "CDROMSETSPINDOWN", 0x531e}, ++ {"linux/cdrom.h", "CDROM_SET_OPTIONS", 0x5320}, ++ {"sound/asequencer.h", "SNDRV_SEQ_IOCTL_CREATE_PORT", 0x5320}, ++ {"linux/cdrom.h", "CDROM_CLEAR_OPTIONS", 0x5321}, ++ {"sound/asequencer.h", "SNDRV_SEQ_IOCTL_DELETE_PORT", 0x5321}, ++ {"linux/cdrom.h", "CDROM_SELECT_SPEED", 0x5322}, ++ {"sound/asequencer.h", "SNDRV_SEQ_IOCTL_GET_PORT_INFO", 0x5322}, ++ {"linux/cdrom.h", "CDROM_SELECT_DISC", 0x5323}, ++ {"sound/asequencer.h", "SNDRV_SEQ_IOCTL_SET_PORT_INFO", 0x5323}, ++ {"linux/cdrom.h", "CDROM_MEDIA_CHANGED", 0x5325}, ++ {"linux/cdrom.h", "CDROM_DRIVE_STATUS", 0x5326}, ++ {"linux/cdrom.h", "CDROM_DISC_STATUS", 0x5327}, ++ {"linux/cdrom.h", "CDROM_CHANGER_NSLOTS", 0x5328}, ++ {"linux/cdrom.h", "CDROM_LOCKDOOR", 0x5329}, ++ {"linux/cdrom.h", "CDROM_DEBUG", 0x5330}, ++ {"sound/asequencer.h", "SNDRV_SEQ_IOCTL_SUBSCRIBE_PORT", 0x5330}, ++ {"linux/cdrom.h", "CDROM_GET_CAPABILITY", 0x5331}, ++ {"sound/asequencer.h", "SNDRV_SEQ_IOCTL_UNSUBSCRIBE_PORT", 0x5331}, ++ {"sound/asequencer.h", "SNDRV_SEQ_IOCTL_CREATE_QUEUE", 0x5332}, ++ {"sound/asequencer.h", "SNDRV_SEQ_IOCTL_DELETE_QUEUE", 0x5333}, ++ {"sound/asequencer.h", "SNDRV_SEQ_IOCTL_GET_QUEUE_INFO", 0x5334}, ++ {"sound/asequencer.h", "SNDRV_SEQ_IOCTL_SET_QUEUE_INFO", 0x5335}, ++ {"sound/asequencer.h", "SNDRV_SEQ_IOCTL_GET_NAMED_QUEUE", 0x5336}, ++ {"sound/asequencer.h", "SNDRV_SEQ_IOCTL_GET_QUEUE_STATUS", 0x5340}, ++ {"sound/asequencer.h", "SNDRV_SEQ_IOCTL_GET_QUEUE_TEMPO", 0x5341}, ++ {"sound/asequencer.h", "SNDRV_SEQ_IOCTL_SET_QUEUE_TEMPO", 0x5342}, ++ {"sound/asequencer.h", "SNDRV_SEQ_IOCTL_GET_QUEUE_OWNER", 0x5343}, ++ {"sound/asequencer.h", "SNDRV_SEQ_IOCTL_SET_QUEUE_OWNER", 0x5344}, ++ {"sound/asequencer.h", "SNDRV_SEQ_IOCTL_GET_QUEUE_TIMER", 0x5345}, ++ {"sound/asequencer.h", "SNDRV_SEQ_IOCTL_SET_QUEUE_TIMER", 0x5346}, ++ {"sound/asequencer.h", "SNDRV_SEQ_IOCTL_GET_QUEUE_CLIENT", 0x5349}, ++ {"sound/asequencer.h", "SNDRV_SEQ_IOCTL_SET_QUEUE_CLIENT", 0x534a}, ++ {"sound/asequencer.h", "SNDRV_SEQ_IOCTL_GET_CLIENT_POOL", 0x534b}, ++ {"sound/asequencer.h", "SNDRV_SEQ_IOCTL_SET_CLIENT_POOL", 0x534c}, ++ {"sound/asequencer.h", "SNDRV_SEQ_IOCTL_REMOVE_EVENTS", 0x534e}, ++ {"sound/asequencer.h", "SNDRV_SEQ_IOCTL_QUERY_SUBS", 0x534f}, ++ {"sound/asequencer.h", "SNDRV_SEQ_IOCTL_GET_SUBSCRIPTION", 0x5350}, ++ {"sound/asequencer.h", "SNDRV_SEQ_IOCTL_QUERY_NEXT_CLIENT", 0x5351}, ++ {"sound/asequencer.h", "SNDRV_SEQ_IOCTL_QUERY_NEXT_PORT", 0x5352}, ++ {"sound/asequencer.h", "SNDRV_SEQ_IOCTL_GET_QUEUE_SYNC", 0x5353}, ++ {"sound/asequencer.h", "SNDRV_SEQ_IOCTL_SET_QUEUE_SYNC", 0x5354}, ++ {"scsi/scsi_ioctl.h", "SCSI_IOCTL_DOORLOCK", 0x5380}, ++ {"scsi/scsi_ioctl.h", "SCSI_IOCTL_DOORUNLOCK", 0x5381}, ++ {"linux/cdrom.h", "CDROMAUDIOBUFSIZ", 0x5382}, ++ {"scsi/scsi.h", "SCSI_IOCTL_GET_IDLUN", 0x5382}, ++ {"scsi/scsi.h", "SCSI_IOCTL_PROBE_HOST", 0x5385}, ++ {"scsi/scsi.h", "SCSI_IOCTL_GET_BUS_NUMBER", 0x5386}, ++ {"scsi/scsi.h", "SCSI_IOCTL_GET_PCI", 0x5387}, ++ {"linux/cdrom.h", "DVD_READ_STRUCT", 0x5390}, ++ {"linux/cdrom.h", "DVD_WRITE_STRUCT", 0x5391}, ++ {"linux/cdrom.h", "DVD_AUTH", 0x5392}, ++ {"linux/cdrom.h", "CDROM_SEND_PACKET", 0x5393}, ++ {"linux/cdrom.h", "CDROM_NEXT_WRITABLE", 0x5394}, ++ {"linux/cdrom.h", "CDROM_LAST_WRITTEN", 0x5395}, ++ {"linux/soundcard.h", "SNDCTL_TMR_TIMEBASE", 0x5401}, ++ {"asm/ioctls.h", "TCGETS", 0x5401}, ++ {"linux/soundcard.h", "SNDCTL_TMR_START", 0x5402}, ++ {"asm/ioctls.h", "TCSETS", 0x5402}, ++ {"linux/soundcard.h", "SNDCTL_TMR_STOP", 0x5403}, ++ {"asm/ioctls.h", "TCSETSW", 0x5403}, ++ {"linux/soundcard.h", "SNDCTL_TMR_CONTINUE", 0x5404}, ++ {"asm/ioctls.h", "TCSETSF", 0x5404}, ++ {"linux/soundcard.h", "SNDCTL_TMR_TEMPO", 0x5405}, ++ {"asm/ioctls.h", "TCGETA", 0x5405}, ++ {"linux/soundcard.h", "SNDCTL_TMR_SOURCE", 0x5406}, ++ {"asm/ioctls.h", "TCSETA", 0x5406}, ++ {"linux/soundcard.h", "SNDCTL_TMR_METRONOME", 0x5407}, ++ {"asm/ioctls.h", "TCSETAW", 0x5407}, ++ {"linux/soundcard.h", "SNDCTL_TMR_SELECT", 0x5408}, ++ {"asm/ioctls.h", "TCSETAF", 0x5408}, ++ {"asm/ioctls.h", "TCSBRK", 0x5409}, ++ {"asm/ioctls.h", "TCXONC", 0x540a}, ++ {"asm/ioctls.h", "TCFLSH", 0x540b}, ++ {"asm/ioctls.h", "TIOCEXCL", 0x540c}, ++ {"asm/ioctls.h", "TIOCNXCL", 0x540d}, ++ {"asm/ioctls.h", "TIOCSCTTY", 0x540e}, ++ {"asm/ioctls.h", "TIOCGPGRP", 0x540f}, ++ {"asm/ioctls.h", "TIOCSPGRP", 0x5410}, ++ {"asm/ioctls.h", "TIOCOUTQ", 0x5411}, ++ {"asm/ioctls.h", "TIOCSTI", 0x5412}, ++ {"asm/ioctls.h", "TIOCGWINSZ", 0x5413}, ++ {"asm/ioctls.h", "TIOCSWINSZ", 0x5414}, ++ {"asm/ioctls.h", "TIOCMGET", 0x5415}, ++ {"asm/ioctls.h", "TIOCMBIS", 0x5416}, ++ {"asm/ioctls.h", "TIOCMBIC", 0x5417}, ++ {"asm/ioctls.h", "TIOCMSET", 0x5418}, ++ {"asm/ioctls.h", "TIOCGSOFTCAR", 0x5419}, ++ {"asm/ioctls.h", "TIOCSSOFTCAR", 0x541a}, ++ {"asm/ioctls.h", "FIONREAD", 0x541b}, ++ {"asm/ioctls.h", "TIOCLINUX", 0x541c}, ++ {"asm/ioctls.h", "TIOCCONS", 0x541d}, ++ {"asm/ioctls.h", "TIOCGSERIAL", 0x541e}, ++ {"asm/ioctls.h", "TIOCSSERIAL", 0x541f}, ++ {"asm/ioctls.h", "TIOCPKT", 0x5420}, ++ {"asm/ioctls.h", "FIONBIO", 0x5421}, ++ {"asm/ioctls.h", "TIOCNOTTY", 0x5422}, ++ {"asm/ioctls.h", "TIOCSETD", 0x5423}, ++ {"asm/ioctls.h", "TIOCGETD", 0x5424}, ++ {"asm/ioctls.h", "TCSBRKP", 0x5425}, ++ {"asm/ioctls.h", "TIOCTTYGSTRUCT", 0x5426}, ++ {"asm/ioctls.h", "TIOCSBRK", 0x5427}, ++ {"asm/ioctls.h", "TIOCCBRK", 0x5428}, ++ {"asm/ioctls.h", "TIOCGSID", 0x5429}, ++ {"asm/ioctls.h", "TCGETS2", 0x542a}, ++ {"asm/ioctls.h", "TCSETS2", 0x542b}, ++ {"asm/ioctls.h", "TCSETSW2", 0x542c}, ++ {"asm/ioctls.h", "TCSETSF2", 0x542d}, ++ {"asm/ioctls.h", "TIOCGPTN", 0x5430}, ++ {"asm/ioctls.h", "TIOCSPTLCK", 0x5431}, ++ {"asm/ioctls.h", "FIONCLEX", 0x5450}, ++ {"asm/ioctls.h", "FIOCLEX", 0x5451}, ++ {"asm/ioctls.h", "FIOASYNC", 0x5452}, ++ {"asm/ioctls.h", "TIOCSERCONFIG", 0x5453}, ++ {"asm/ioctls.h", "TIOCSERGWILD", 0x5454}, ++ {"asm/ioctls.h", "TIOCSERSWILD", 0x5455}, ++ {"asm/ioctls.h", "TIOCGLCKTRMIOS", 0x5456}, ++ {"asm/ioctls.h", "TIOCSLCKTRMIOS", 0x5457}, ++ {"asm/ioctls.h", "TIOCSERGSTRUCT", 0x5458}, ++ {"asm/ioctls.h", "TIOCSERGETLSR", 0x5459}, ++ {"asm/ioctls.h", "TIOCSERGETMULTI", 0x545a}, ++ {"asm/ioctls.h", "TIOCSERSETMULTI", 0x545b}, ++ {"asm/ioctls.h", "TIOCMIWAIT", 0x545c}, ++ {"asm/ioctls.h", "TIOCGICOUNT", 0x545d}, ++ {"asm/ioctls.h", "FIOQSIZE", 0x545e}, ++ {"linux/if_tun.h", "TUNSETNOCSUM", 0x54c8}, ++ {"linux/if_tun.h", "TUNSETDEBUG", 0x54c9}, ++ {"linux/if_tun.h", "TUNSETIFF", 0x54ca}, ++ {"linux/if_tun.h", "TUNSETPERSIST", 0x54cb}, ++ {"linux/if_tun.h", "TUNSETOWNER", 0x54cc}, ++ {"linux/if_tun.h", "TUNSETLINK", 0x54cd}, ++ {"linux/if_tun.h", "TUNSETGROUP", 0x54ce}, ++ {"linux/usbdevice_fs.h", "USBDEVFS_CONTROL", 0x5500}, ++ {"linux/uinput.h", "UI_DEV_CREATE", 0x5501}, ++ {"linux/uinput.h", "UI_DEV_DESTROY", 0x5502}, ++ {"linux/usbdevice_fs.h", "USBDEVFS_BULK", 0x5502}, ++ {"linux/usbdevice_fs.h", "USBDEVFS_RESETEP", 0x5503}, ++ {"linux/usbdevice_fs.h", "USBDEVFS_SETINTERFACE", 0x5504}, ++ {"linux/usbdevice_fs.h", "USBDEVFS_SETCONFIGURATION", 0x5505}, ++ {"linux/usbdevice_fs.h", "USBDEVFS_GETDRIVER", 0x5508}, ++ {"linux/usbdevice_fs.h", "USBDEVFS_SUBMITURB", 0x550a}, ++ {"linux/usbdevice_fs.h", "USBDEVFS_SUBMITURB32", 0x550a}, ++ {"linux/usbdevice_fs.h", "USBDEVFS_DISCARDURB", 0x550b}, ++ {"linux/usbdevice_fs.h", "USBDEVFS_REAPURB", 0x550c}, ++ {"linux/usbdevice_fs.h", "USBDEVFS_REAPURB32", 0x550c}, ++ {"linux/usbdevice_fs.h", "USBDEVFS_REAPURBNDELAY", 0x550d}, ++ {"linux/usbdevice_fs.h", "USBDEVFS_REAPURBNDELAY32", 0x550d}, ++ {"linux/usbdevice_fs.h", "USBDEVFS_DISCSIGNAL", 0x550e}, ++ {"linux/usbdevice_fs.h", "USBDEVFS_CLAIMINTERFACE", 0x550f}, ++ {"linux/usbdevice_fs.h", "USBDEVFS_RELEASEINTERFACE", 0x5510}, ++ {"linux/usbdevice_fs.h", "USBDEVFS_CONNECTINFO", 0x5511}, ++ {"linux/usbdevice_fs.h", "USBDEVFS_IOCTL", 0x5512}, ++ {"linux/usbdevice_fs.h", "USBDEVFS_IOCTL32", 0x5512}, ++ {"linux/usbdevice_fs.h", "USBDEVFS_HUB_PORTINFO", 0x5513}, ++ {"linux/usbdevice_fs.h", "USBDEVFS_RESET", 0x5514}, ++ {"linux/usbdevice_fs.h", "USBDEVFS_CLEAR_HALT", 0x5515}, ++ {"linux/usbdevice_fs.h", "USBDEVFS_DISCONNECT", 0x5516}, ++ {"linux/usbdevice_fs.h", "USBDEVFS_CONNECT", 0x5517}, ++ {"linux/uinput.h", "UI_SET_EVBIT", 0x5564}, ++ {"linux/uinput.h", "UI_SET_KEYBIT", 0x5565}, ++ {"linux/uinput.h", "UI_SET_RELBIT", 0x5566}, ++ {"linux/uinput.h", "UI_SET_ABSBIT", 0x5567}, ++ {"linux/uinput.h", "UI_SET_MSCBIT", 0x5568}, ++ {"linux/uinput.h", "UI_SET_LEDBIT", 0x5569}, ++ {"linux/uinput.h", "UI_SET_SNDBIT", 0x556a}, ++ {"linux/uinput.h", "UI_SET_FFBIT", 0x556b}, ++ {"linux/uinput.h", "UI_SET_PHYS", 0x556c}, ++ {"linux/uinput.h", "UI_SET_SWBIT", 0x556d}, ++ {"linux/uinput.h", "UI_BEGIN_FF_UPLOAD", 0x55c8}, ++ {"linux/uinput.h", "UI_END_FF_UPLOAD", 0x55c9}, ++ {"linux/uinput.h", "UI_BEGIN_FF_ERASE", 0x55ca}, ++ {"linux/uinput.h", "UI_END_FF_ERASE", 0x55cb}, ++ {"linux/videodev2.h", "VIDIOC_QUERYCAP", 0x5600}, ++ {"linux/vt.h", "VT_OPENQRY", 0x5600}, ++ {"linux/videodev2.h", "VIDIOC_RESERVED", 0x5601}, ++ {"linux/vt.h", "VT_GETMODE", 0x5601}, ++ {"linux/videodev2.h", "VIDIOC_ENUM_FMT", 0x5602}, ++ {"linux/vt.h", "VT_SETMODE", 0x5602}, ++ {"linux/vt.h", "VT_GETSTATE", 0x5603}, ++ {"linux/videodev2.h", "VIDIOC_G_FMT", 0x5604}, ++ {"linux/vt.h", "VT_SENDSIG", 0x5604}, ++ {"linux/videodev2.h", "VIDIOC_S_FMT", 0x5605}, ++ {"linux/vt.h", "VT_RELDISP", 0x5605}, ++ {"linux/vt.h", "VT_ACTIVATE", 0x5606}, ++ {"linux/vt.h", "VT_WAITACTIVE", 0x5607}, ++ {"linux/videodev2.h", "VIDIOC_REQBUFS", 0x5608}, ++ {"linux/vt.h", "VT_DISALLOCATE", 0x5608}, ++ {"linux/videodev2.h", "VIDIOC_QUERYBUF", 0x5609}, ++ {"linux/vt.h", "VT_RESIZE", 0x5609}, ++ {"linux/videodev2.h", "VIDIOC_G_FBUF", 0x560a}, ++ {"linux/vt.h", "VT_RESIZEX", 0x560a}, ++ {"linux/videodev2.h", "VIDIOC_S_FBUF", 0x560b}, ++ {"linux/vt.h", "VT_LOCKSWITCH", 0x560b}, ++ {"linux/vt.h", "VT_UNLOCKSWITCH", 0x560c}, ++ {"linux/vt.h", "VT_GETHIFONTMASK", 0x560d}, ++ {"linux/videodev2.h", "VIDIOC_OVERLAY", 0x560e}, ++ {"linux/videodev2.h", "VIDIOC_OVERLAY_OLD", 0x560e}, ++ {"linux/videodev2.h", "VIDIOC_QBUF", 0x560f}, ++ {"linux/videodev2.h", "VIDIOC_DQBUF", 0x5611}, ++ {"linux/videodev2.h", "VIDIOC_STREAMON", 0x5612}, ++ {"linux/videodev2.h", "VIDIOC_STREAMOFF", 0x5613}, ++ {"linux/videodev2.h", "VIDIOC_G_PARM", 0x5615}, ++ {"linux/videodev2.h", "VIDIOC_S_PARM", 0x5616}, ++ {"linux/videodev2.h", "VIDIOC_S_PARM_OLD", 0x5616}, ++ {"linux/videodev2.h", "VIDIOC_G_STD", 0x5617}, ++ {"linux/videodev2.h", "VIDIOC_S_STD", 0x5618}, ++ {"linux/videodev2.h", "VIDIOC_ENUMSTD", 0x5619}, ++ {"linux/videodev2.h", "VIDIOC_ENUMINPUT", 0x561a}, ++ {"linux/videodev2.h", "VIDIOC_G_CTRL", 0x561b}, ++ {"linux/videodev2.h", "VIDIOC_S_CTRL", 0x561c}, ++ {"linux/videodev2.h", "VIDIOC_S_CTRL_OLD", 0x561c}, ++ {"linux/videodev2.h", "VIDIOC_G_TUNER", 0x561d}, ++ {"linux/videodev2.h", "VIDIOC_S_TUNER", 0x561e}, ++ {"linux/videodev2.h", "VIDIOC_G_AUDIO", 0x5621}, ++ {"linux/videodev2.h", "VIDIOC_G_AUDIO_OLD", 0x5621}, ++ {"linux/videodev2.h", "VIDIOC_S_AUDIO", 0x5622}, ++ {"linux/videodev2.h", "VIDIOC_QUERYCTRL", 0x5624}, ++ {"linux/videodev2.h", "VIDIOC_QUERYMENU", 0x5625}, ++ {"linux/videodev2.h", "VIDIOC_G_INPUT", 0x5626}, ++ {"linux/videodev2.h", "VIDIOC_S_INPUT", 0x5627}, ++ {"linux/videodev2.h", "VIDIOC_G_OUTPUT", 0x562e}, ++ {"linux/videodev2.h", "VIDIOC_S_OUTPUT", 0x562f}, ++ {"linux/videodev2.h", "VIDIOC_ENUMOUTPUT", 0x5630}, ++ {"linux/videodev2.h", "VIDIOC_G_AUDOUT", 0x5631}, ++ {"linux/videodev2.h", "VIDIOC_G_AUDOUT_OLD", 0x5631}, ++ {"linux/videodev2.h", "VIDIOC_S_AUDOUT", 0x5632}, ++ {"linux/videodev2.h", "VIDIOC_G_MODULATOR", 0x5636}, ++ {"linux/videodev2.h", "VIDIOC_S_MODULATOR", 0x5637}, ++ {"linux/videodev2.h", "VIDIOC_G_FREQUENCY", 0x5638}, ++ {"linux/videodev2.h", "VIDIOC_S_FREQUENCY", 0x5639}, ++ {"linux/videodev2.h", "VIDIOC_CROPCAP", 0x563a}, ++ {"linux/videodev2.h", "VIDIOC_CROPCAP_OLD", 0x563a}, ++ {"linux/videodev2.h", "VIDIOC_G_CROP", 0x563b}, ++ {"linux/videodev2.h", "VIDIOC_S_CROP", 0x563c}, ++ {"linux/videodev2.h", "VIDIOC_G_JPEGCOMP", 0x563d}, ++ {"linux/videodev2.h", "VIDIOC_S_JPEGCOMP", 0x563e}, ++ {"linux/videodev2.h", "VIDIOC_QUERYSTD", 0x563f}, ++ {"linux/videodev2.h", "VIDIOC_TRY_FMT", 0x5640}, ++ {"linux/videodev2.h", "VIDIOC_ENUMAUDIO", 0x5641}, ++ {"linux/videodev2.h", "VIDIOC_ENUMAUDOUT", 0x5642}, ++ {"linux/videodev2.h", "VIDIOC_G_PRIORITY", 0x5643}, ++ {"linux/videodev2.h", "VIDIOC_S_PRIORITY", 0x5644}, ++ {"linux/videodev2.h", "VIDIOC_G_SLICED_VBI_CAP", 0x5645}, ++ {"linux/videodev2.h", "VIDIOC_LOG_STATUS", 0x5646}, ++ {"linux/videodev2.h", "VIDIOC_G_EXT_CTRLS", 0x5647}, ++ {"linux/videodev2.h", "VIDIOC_S_EXT_CTRLS", 0x5648}, ++ {"linux/videodev2.h", "VIDIOC_TRY_EXT_CTRLS", 0x5649}, ++ {"linux/videodev2.h", "VIDIOC_ENUM_FRAMESIZES", 0x564a}, ++ {"linux/videodev2.h", "VIDIOC_ENUM_FRAMEINTERVALS", 0x564b}, ++ {"linux/videodev2.h", "VIDIOC_G_ENC_INDEX", 0x564c}, ++ {"linux/videodev2.h", "VIDIOC_ENCODER_CMD", 0x564d}, ++ {"linux/videodev2.h", "VIDIOC_TRY_ENCODER_CMD", 0x564e}, ++ {"linux/videodev2.h", "VIDIOC_DBG_S_REGISTER", 0x564f}, ++ {"linux/videodev2.h", "VIDIOC_DBG_G_REGISTER", 0x5650}, ++ {"linux/videodev2.h", "VIDIOC_G_CHIP_IDENT", 0x5651}, ++ {"linux/ivtvfb.h", "IVTVFB_IOC_DMA_FRAME", 0x56c0}, ++ {"linux/ivtv.h", "IVTV_IOC_DMA_FRAME", 0x56c0}, ++ {"linux/watchdog.h", "WDIOC_GETSUPPORT", 0x5700}, ++ {"linux/watchdog.h", "WDIOC_GETSTATUS", 0x5701}, ++ {"linux/watchdog.h", "WDIOC_GETBOOTSTATUS", 0x5702}, ++ {"linux/watchdog.h", "WDIOC_GETTEMP", 0x5703}, ++ {"linux/watchdog.h", "WDIOC_SETOPTIONS", 0x5704}, ++ {"linux/watchdog.h", "WDIOC_KEEPALIVE", 0x5705}, ++ {"linux/watchdog.h", "WDIOC_SETTIMEOUT", 0x5706}, ++ {"linux/watchdog.h", "WDIOC_GETTIMEOUT", 0x5707}, ++ {"linux/watchdog.h", "WDIOC_SETPRETIMEOUT", 0x5708}, ++ {"linux/watchdog.h", "WDIOC_GETPRETIMEOUT", 0x5709}, ++ {"linux/watchdog.h", "WDIOC_GETTIMELEFT", 0x570a}, ++ {"linux/pktcdvd.h", "PACKET_CTRL_CMD", 0x5801}, ++ {"linux/sonet.h", "SONET_GETSTAT", 0x6110}, ++ {"linux/sonet.h", "SONET_GETSTATZ", 0x6111}, ++ {"linux/sonet.h", "SONET_SETDIAG", 0x6112}, ++ {"linux/sonet.h", "SONET_CLRDIAG", 0x6113}, ++ {"linux/sonet.h", "SONET_GETDIAG", 0x6114}, ++ {"linux/sonet.h", "SONET_SETFRAMING", 0x6115}, ++ {"linux/sonet.h", "SONET_GETFRAMING", 0x6116}, ++ {"linux/sonet.h", "SONET_GETFRSENSE", 0x6117}, ++ {"linux/atm_idt77105.h", "IDT77105_GETSTAT", 0x6132}, ++ {"linux/atm_idt77105.h", "IDT77105_GETSTATZ", 0x6133}, ++ {"linux/atmdev.h", "ATM_GETSTAT", 0x6150}, ++ {"linux/atmdev.h", "ATM_GETSTATZ", 0x6151}, ++ {"linux/atmdev.h", "ATM_GETLOOP", 0x6152}, ++ {"linux/atmdev.h", "ATM_SETLOOP", 0x6153}, ++ {"linux/atmdev.h", "ATM_QUERYLOOP", 0x6154}, ++ {"linux/atm_eni.h", "ENI_MEMDUMP", 0x6160}, ++ {"linux/atm_he.h", "HE_GET_REG", 0x6160}, ++ {"linux/atm_nicstar.h", "NS_GETPSTAT", 0x6161}, ++ {"linux/atm_zatm.h", "ZATM_GETPOOL", 0x6161}, ++ {"linux/atm_nicstar.h", "NS_SETBUFLEV", 0x6162}, ++ {"linux/atm_zatm.h", "ZATM_GETPOOLZ", 0x6162}, ++ {"linux/atm_nicstar.h", "NS_ADJBUFLEV", 0x6163}, ++ {"linux/atm_zatm.h", "ZATM_SETPOOL", 0x6163}, ++ {"linux/atm_eni.h", "ENI_SETMULT", 0x6167}, ++ {"linux/atm_tcp.h", "SIOCSIFATMTCP", 0x6180}, ++ {"linux/atmdev.h", "ATM_GETLINKRATE", 0x6181}, ++ {"linux/atmdev.h", "ATM_GETNAMES", 0x6183}, ++ {"linux/atmdev.h", "ATM_GETTYPE", 0x6184}, ++ {"linux/atmdev.h", "ATM_GETESI", 0x6185}, ++ {"linux/atmdev.h", "ATM_GETADDR", 0x6186}, ++ {"linux/atmdev.h", "ATM_RSTADDR", 0x6187}, ++ {"linux/atmdev.h", "ATM_ADDADDR", 0x6188}, ++ {"linux/atmdev.h", "ATM_DELADDR", 0x6189}, ++ {"linux/atmdev.h", "ATM_GETCIRANGE", 0x618a}, ++ {"linux/atmdev.h", "ATM_SETCIRANGE", 0x618b}, ++ {"linux/atmdev.h", "ATM_SETESI", 0x618c}, ++ {"linux/atmdev.h", "ATM_SETESIF", 0x618d}, ++ {"linux/atm_tcp.h", "ATMTCP_CREATE", 0x618e}, ++ {"linux/atmdev.h", "ATM_ADDLECSADDR", 0x618e}, ++ {"linux/atm_tcp.h", "ATMTCP_REMOVE", 0x618f}, ++ {"linux/atmdev.h", "ATM_DELLECSADDR", 0x618f}, ++ {"linux/atmdev.h", "ATM_GETLECSADDR", 0x6190}, ++ {"linux/atmbr2684.h", "BR2684_SETFILT", 0x6190}, ++ {"linux/atmlec.h", "ATMLEC_CTRL", 0x61d0}, ++ {"linux/atmlec.h", "ATMLEC_DATA", 0x61d1}, ++ {"linux/atmlec.h", "ATMLEC_MCAST", 0x61d2}, ++ {"linux/atmmpc.h", "ATMMPC_CTRL", 0x61d8}, ++ {"linux/atmmpc.h", "ATMMPC_DATA", 0x61d9}, ++ {"linux/atmclip.h", "SIOCMKCLIP", 0x61e0}, ++ {"linux/atmarp.h", "ATMARPD_CTRL", 0x61e1}, ++ {"linux/atmarp.h", "ATMARP_MKIP", 0x61e2}, ++ {"linux/atmarp.h", "ATMARP_SETENTRY", 0x61e3}, ++ {"linux/atmarp.h", "ATMARP_ENCAP", 0x61e5}, ++ {"linux/atmsvc.h", "ATMSIGD_CTRL", 0x61f0}, ++ {"linux/atmdev.h", "ATM_SETSC", 0x61f1}, ++ {"linux/atmdev.h", "ATM_SETBACKEND", 0x61f2}, ++ {"linux/atmdev.h", "ATM_NEWBACKENDIF", 0x61f3}, ++ {"linux/atmdev.h", "ATM_ADDPARTY", 0x61f4}, ++ {"linux/atmdev.h", "ATM_DROPPARTY", 0x61f5}, ++ {"linux/cm4000_cs.h", "CM_IOCGSTATUS", 0x6300}, ++ {"linux/chio.h", "CHIOMOVE", 0x6301}, ++ {"linux/cm4000_cs.h", "CM_IOCGATR", 0x6301}, ++ {"linux/chio.h", "CHIOEXCHANGE", 0x6302}, ++ {"linux/cm4000_cs.h", "CM_IOCSPTS", 0x6302}, ++ {"linux/chio.h", "CHIOPOSITION", 0x6303}, ++ {"linux/cm4000_cs.h", "CM_IOCSRDR", 0x6303}, ++ {"linux/chio.h", "CHIOGPICKER", 0x6304}, ++ {"linux/cm4000_cs.h", "CM_IOCARDOFF", 0x6304}, ++ {"linux/chio.h", "CHIOSPICKER", 0x6305}, ++ {"linux/chio.h", "CHIOGPARAMS", 0x6306}, ++ {"linux/chio.h", "CHIOGSTATUS", 0x6308}, ++ {"linux/coda.h", "CIOC_KERNEL_VERSION", 0x630a}, ++ {"linux/chio.h", "CHIOGELEM", 0x6310}, ++ {"linux/chio.h", "CHIOINITELEM", 0x6311}, ++ {"linux/chio.h", "CHIOSVOLTAG", 0x6312}, ++ {"linux/chio.h", "CHIOGVPARAMS", 0x6313}, ++ {"linux/comstats.h", "COM_GETPORTSTATS", 0x631e}, ++ {"linux/comstats.h", "COM_CLRPORTSTATS", 0x631f}, ++ {"linux/comstats.h", "COM_GETBRDSTATS", 0x6320}, ++ {"linux/comstats.h", "COM_READPORT", 0x6328}, ++ {"linux/comstats.h", "COM_READBOARD", 0x6329}, ++ {"linux/comstats.h", "COM_READPANEL", 0x632a}, ++ {"linux/cm4000_cs.h", "CM_IOSDBGLVL", 0x63fa}, ++ {"linux/video_decoder.h", "DECODER_GET_CAPABILITIES", 0x6401}, ++ {"linux/video_decoder.h", "DECODER_GET_STATUS", 0x6402}, ++ {"pcmcia/ds.h", "DS_ADJUST_RESOURCE_INFO", 0x6402}, ++ {"linux/video_decoder.h", "DECODER_SET_NORM", 0x6403}, ++ {"pcmcia/ds.h", "DS_GET_CONFIGURATION_INFO", 0x6403}, ++ {"linux/video_decoder.h", "DECODER_SET_INPUT", 0x6404}, ++ {"pcmcia/ds.h", "DS_GET_FIRST_TUPLE", 0x6404}, ++ {"linux/video_decoder.h", "DECODER_SET_OUTPUT", 0x6405}, ++ {"pcmcia/ds.h", "DS_GET_NEXT_TUPLE", 0x6405}, ++ {"linux/video_decoder.h", "DECODER_ENABLE_OUTPUT", 0x6406}, ++ {"pcmcia/ds.h", "DS_GET_TUPLE_DATA", 0x6406}, ++ {"linux/video_decoder.h", "DECODER_SET_PICTURE", 0x6407}, ++ {"pcmcia/ds.h", "DS_PARSE_TUPLE", 0x6407}, ++ {"linux/video_decoder.h", "DECODER_SET_GPIO", 0x6408}, ++ {"pcmcia/ds.h", "DS_RESET_CARD", 0x6408}, ++ {"linux/video_decoder.h", "DECODER_INIT", 0x6409}, ++ {"pcmcia/ds.h", "DS_GET_STATUS", 0x6409}, ++ {"linux/video_decoder.h", "DECODER_SET_VBI_BYPASS", 0x640a}, ++ {"pcmcia/ds.h", "DS_ACCESS_CONFIGURATION_REGISTER", 0x640a}, ++ {"pcmcia/ds.h", "DS_VALIDATE_CIS", 0x640b}, ++ {"pcmcia/ds.h", "DS_SUSPEND_CARD", 0x640c}, ++ {"pcmcia/ds.h", "DS_RESUME_CARD", 0x640d}, ++ {"pcmcia/ds.h", "DS_EJECT_CARD", 0x640e}, ++ {"pcmcia/ds.h", "DS_INSERT_CARD", 0x640f}, ++ {"pcmcia/ds.h", "DS_GET_FIRST_REGION", 0x6410}, ++ {"pcmcia/ds.h", "DS_GET_NEXT_REGION", 0x6411}, ++ {"pcmcia/ds.h", "DS_REPLACE_CIS", 0x6412}, ++ {"pcmcia/ds.h", "DS_GET_FIRST_WINDOW", 0x6413}, ++ {"pcmcia/ds.h", "DS_GET_NEXT_WINDOW", 0x6414}, ++ {"pcmcia/ds.h", "DS_GET_MEM_PAGE", 0x6415}, ++ {"pcmcia/ds.h", "DS_BIND_REQUEST", 0x643c}, ++ {"pcmcia/ds.h", "DS_GET_DEVICE_INFO", 0x643d}, ++ {"pcmcia/ds.h", "DS_GET_NEXT_DEVICE", 0x643e}, ++ {"pcmcia/ds.h", "DS_UNBIND_REQUEST", 0x643f}, ++ {"pcmcia/ds.h", "DS_BIND_MTD", 0x6440}, ++ {"media/v4l2-common.h", "AUDC_SET_RADIO", 0x6458}, ++ {"media/v4l2-common.h", "TUNER_SET_TYPE_ADDR", 0x645a}, ++ {"media/v4l2-common.h", "TUNER_SET_STANDBY", 0x645b}, ++ {"media/v4l2-common.h", "TUNER_SET_CONFIG", 0x645c}, ++ {"media/v4l2-common.h", "VIDIOC_INT_S_TUNER_MODE", 0x645d}, ++ {"media/v4l2-common.h", "VIDIOC_INT_S_STANDBY", 0x645e}, ++ {"media/v4l2-common.h", "VIDIOC_INT_RESET", 0x6466}, ++ {"media/v4l2-common.h", "VIDIOC_INT_AUDIO_CLOCK_FREQ", 0x6467}, ++ {"media/v4l2-common.h", "VIDIOC_INT_DECODE_VBI_LINE", 0x6468}, ++ {"media/v4l2-common.h", "VIDIOC_INT_S_VBI_DATA", 0x6469}, ++ {"media/v4l2-common.h", "VIDIOC_INT_G_VBI_DATA", 0x646a}, ++ {"media/v4l2-common.h", "VIDIOC_INT_I2S_CLOCK_FREQ", 0x646c}, ++ {"media/v4l2-common.h", "VIDIOC_INT_S_AUDIO_ROUTING", 0x646d}, ++ {"media/v4l2-common.h", "VIDIOC_INT_G_AUDIO_ROUTING", 0x646e}, ++ {"media/v4l2-common.h", "VIDIOC_INT_S_VIDEO_ROUTING", 0x646f}, ++ {"media/v4l2-common.h", "VIDIOC_INT_G_VIDEO_ROUTING", 0x6470}, ++ {"media/v4l2-common.h", "VIDIOC_INT_S_CRYSTAL_FREQ", 0x6471}, ++ {"media/v4l2-common.h", "VIDIOC_INT_INIT", 0x6472}, ++ {"media/v4l2-common.h", "VIDIOC_INT_S_STD_OUTPUT", 0x6473}, ++ {"media/v4l2-common.h", "VIDIOC_INT_G_STD_OUTPUT", 0x6474}, ++ {"linux/video_decoder.h", "DECODER_DUMP", 0x64c0}, ++ {"linux/video_encoder.h", "ENCODER_GET_CAPABILITIES", 0x6501}, ++ {"linux/video_encoder.h", "ENCODER_SET_NORM", 0x6502}, ++ {"linux/video_encoder.h", "ENCODER_SET_INPUT", 0x6503}, ++ {"linux/video_encoder.h", "ENCODER_SET_OUTPUT", 0x6504}, ++ {"linux/video_encoder.h", "ENCODER_ENABLE_OUTPUT", 0x6505}, ++ {"linux/fs.h", "FS_IOC32_GETFLAGS", 0x6601}, ++ {"linux/fs.h", "FS_IOC_GETFLAGS", 0x6601}, ++ {"linux/fs.h", "FS_IOC32_SETFLAGS", 0x6602}, ++ {"linux/fs.h", "FS_IOC_SETFLAGS", 0x6602}, ++ {"linux/ext3_fs.h", "EXT3_IOC32_GETVERSION", 0x6603}, ++ {"linux/ext3_fs.h", "EXT3_IOC_GETVERSION", 0x6603}, ++ {"linux/ext3_fs.h", "EXT3_IOC32_SETVERSION", 0x6604}, ++ {"linux/ext3_fs.h", "EXT3_IOC_SETVERSION", 0x6604}, ++ {"linux/ext2_fs.h", "EXT2_IOC_GETRSVSZ", 0x6605}, ++ {"linux/ext3_fs.h", "EXT3_IOC32_GETRSVSZ", 0x6605}, ++ {"linux/ext3_fs.h", "EXT3_IOC_GETRSVSZ", 0x6605}, ++ {"linux/ext2_fs.h", "EXT2_IOC_SETRSVSZ", 0x6606}, ++ {"linux/ext3_fs.h", "EXT3_IOC32_SETRSVSZ", 0x6606}, ++ {"linux/ext3_fs.h", "EXT3_IOC_SETRSVSZ", 0x6606}, ++ {"linux/ext3_fs.h", "EXT3_IOC32_GROUP_EXTEND", 0x6607}, ++ {"linux/ext3_fs.h", "EXT3_IOC_GROUP_EXTEND", 0x6607}, ++ {"linux/ext3_fs.h", "EXT3_IOC_GROUP_ADD", 0x6608}, ++ {"linux/ext3_fs.h", "EXT3_IOC32_WAIT_FOR_READONLY", 0x6663}, ++ {"linux/ext3_fs.h", "EXT3_IOC_WAIT_FOR_READONLY", 0x6663}, ++ {"linux/usb/gadgetfs.h", "GADGETFS_FIFO_STATUS", 0x6701}, ++ {"linux/usb/gadgetfs.h", "GADGETFS_FIFO_FLUSH", 0x6702}, ++ {"linux/usb/gadgetfs.h", "GADGETFS_CLEAR_HALT", 0x6703}, ++ {"linux/usb/g_printer.h", "GADGET_GET_PRINTER_STATUS", 0x6721}, ++ {"linux/usb/g_printer.h", "GADGET_SET_PRINTER_STATUS", 0x6722}, ++ {"linux/hpet.h", "HPET_IE_ON", 0x6801}, ++ {"linux/hpet.h", "HPET_IE_OFF", 0x6802}, ++ {"linux/hpet.h", "HPET_INFO", 0x6803}, ++ {"linux/hpet.h", "HPET_EPI", 0x6804}, ++ {"linux/hpet.h", "HPET_DPI", 0x6805}, ++ {"linux/hpet.h", "HPET_IRQFREQ", 0x6806}, ++ {"linux/i2o-dev.h", "I2OGETIOPS", 0x6900}, ++ {"linux/i2o-dev.h", "I2OHRTGET", 0x6901}, ++ {"linux/i2o-dev.h", "I2OLCTGET", 0x6902}, ++ {"linux/i2o-dev.h", "I2OPARMSET", 0x6903}, ++ {"linux/i2o-dev.h", "I2OPARMGET", 0x6904}, ++ {"linux/i2o-dev.h", "I2OSWDL", 0x6905}, ++ {"linux/i2o-dev.h", "I2OSWUL", 0x6906}, ++ {"linux/i2o-dev.h", "I2OSWDEL", 0x6907}, ++ {"linux/i2o-dev.h", "I2OVALIDATE", 0x6908}, ++ {"linux/i2o-dev.h", "I2OHTML", 0x6909}, ++ {"linux/i2o-dev.h", "I2OEVTREG", 0x690a}, ++ {"linux/i2o-dev.h", "I2OEVTGET", 0x690b}, ++ {"linux/ipmi.h", "IPMICTL_RECEIVE_MSG_TRUNC", 0x690b}, ++ {"linux/i2o-dev.h", "I2OPASSTHRU", 0x690c}, ++ {"linux/i2o-dev.h", "I2OPASSTHRU32", 0x690c}, ++ {"linux/ipmi.h", "IPMICTL_RECEIVE_MSG", 0x690c}, ++ {"linux/ipmi.h", "IPMICTL_SEND_COMMAND", 0x690d}, ++ {"linux/ipmi.h", "IPMICTL_REGISTER_FOR_CMD", 0x690e}, ++ {"linux/ipmi.h", "IPMICTL_UNREGISTER_FOR_CMD", 0x690f}, ++ {"linux/ipmi.h", "IPMICTL_SET_GETS_EVENTS_CMD", 0x6910}, ++ {"linux/ipmi.h", "IPMICTL_SET_MY_ADDRESS_CMD", 0x6911}, ++ {"linux/ipmi.h", "IPMICTL_GET_MY_ADDRESS_CMD", 0x6912}, ++ {"linux/ipmi.h", "IPMICTL_SET_MY_LUN_CMD", 0x6913}, ++ {"linux/ipmi.h", "IPMICTL_GET_MY_LUN_CMD", 0x6914}, ++ {"linux/ipmi.h", "IPMICTL_SEND_COMMAND_SETTIME", 0x6915}, ++ {"linux/ipmi.h", "IPMICTL_SET_TIMING_PARMS_CMD", 0x6916}, ++ {"linux/ipmi.h", "IPMICTL_GET_TIMING_PARMS_CMD", 0x6917}, ++ {"linux/ipmi.h", "IPMICTL_SET_MY_CHANNEL_ADDRESS_CMD", 0x6918}, ++ {"linux/ipmi.h", "IPMICTL_GET_MY_CHANNEL_ADDRESS_CMD", 0x6919}, ++ {"linux/ipmi.h", "IPMICTL_SET_MY_CHANNEL_LUN_CMD", 0x691a}, ++ {"linux/ipmi.h", "IPMICTL_GET_MY_CHANNEL_LUN_CMD", 0x691b}, ++ {"linux/ipmi.h", "IPMICTL_REGISTER_FOR_CMD_CHANS", 0x691c}, ++ {"linux/ipmi.h", "IPMICTL_UNREGISTER_FOR_CMD_CHANS", 0x691d}, ++ {"linux/ipmi.h", "IPMICTL_GET_MAINTENANCE_MODE_CMD", 0x691e}, ++ {"linux/ipmi.h", "IPMICTL_SET_MAINTENANCE_MODE_CMD", 0x691f}, ++ {"linux/i8k.h", "I8K_BIOS_VERSION", 0x6980}, ++ {"linux/i8k.h", "I8K_MACHINE_ID", 0x6981}, ++ {"linux/i8k.h", "I8K_POWER_STATUS", 0x6982}, ++ {"linux/i8k.h", "I8K_FN_STATUS", 0x6983}, ++ {"linux/i8k.h", "I8K_GET_TEMP", 0x6984}, ++ {"linux/i8k.h", "I8K_GET_SPEED", 0x6985}, ++ {"linux/i8k.h", "I8K_GET_FAN", 0x6986}, ++ {"linux/i8k.h", "I8K_SET_FAN", 0x6987}, ++ {"linux/joystick.h", "JSIOCGVERSION", 0x6a01}, ++ {"linux/joystick.h", "JSIOCGAXES", 0x6a11}, ++ {"linux/joystick.h", "JSIOCGBUTTONS", 0x6a12}, ++ {"linux/joystick.h", "JSIOCSCORR", 0x6a21}, ++ {"linux/joystick.h", "JSIOCGCORR", 0x6a22}, ++ {"linux/joystick.h", "JSIOCSAXMAP", 0x6a31}, ++ {"linux/joystick.h", "JSIOCGAXMAP", 0x6a32}, ++ {"linux/joystick.h", "JSIOCSBTNMAP", 0x6a33}, ++ {"linux/joystick.h", "JSIOCGBTNMAP", 0x6a34}, ++ {"video/kyro.h", "KYRO_IOCTL_OVERLAY_CREATE", 0x6b00}, ++ {"video/kyro.h", "KYRO_IOCTL_OVERLAY_VIEWPORT_SET", 0x6b01}, ++ {"linux/spi/spidev.h", "SPI_IOC_RD_MODE", 0x6b01}, ++ {"linux/spi/spidev.h", "SPI_IOC_WR_MODE", 0x6b01}, ++ {"video/kyro.h", "KYRO_IOCTL_SET_VIDEO_MODE", 0x6b02}, ++ {"linux/spi/spidev.h", "SPI_IOC_RD_LSB_FIRST", 0x6b02}, ++ {"linux/spi/spidev.h", "SPI_IOC_WR_LSB_FIRST", 0x6b02}, ++ {"video/kyro.h", "KYRO_IOCTL_UVSTRIDE", 0x6b03}, ++ {"linux/spi/spidev.h", "SPI_IOC_RD_BITS_PER_WORD", 0x6b03}, ++ {"linux/spi/spidev.h", "SPI_IOC_WR_BITS_PER_WORD", 0x6b03}, ++ {"video/kyro.h", "KYRO_IOCTL_OVERLAY_OFFSET", 0x6b04}, ++ {"linux/spi/spidev.h", "SPI_IOC_RD_MAX_SPEED_HZ", 0x6b04}, ++ {"linux/spi/spidev.h", "SPI_IOC_WR_MAX_SPEED_HZ", 0x6b04}, ++ {"video/kyro.h", "KYRO_IOCTL_STRIDE", 0x6b05}, ++ {"linux/udf_fs_i.h", "UDF_GETEASIZE", 0x6c40}, ++ {"linux/udf_fs_i.h", "UDF_GETEABLOCK", 0x6c41}, ++ {"linux/udf_fs_i.h", "UDF_GETVOLIDENT", 0x6c42}, ++ {"linux/udf_fs_i.h", "UDF_RELOCATE_BLOCKS", 0x6c43}, ++ {"linux/synclink.h", "MGSL_IOCSPARAMS", 0x6d00}, ++ {"linux/synclink.h", "MGSL_IOCSPARAMS32", 0x6d00}, ++ {"linux/mmtimer.h", "MMTIMER_GETOFFSET", 0x6d00}, ++ {"linux/soundcard.h", "SNDCTL_MIDI_PRETIME", 0x6d00}, ++ {"linux/synclink.h", "MGSL_IOCGPARAMS", 0x6d01}, ++ {"linux/synclink.h", "MGSL_IOCGPARAMS32", 0x6d01}, ++ {"linux/mmtimer.h", "MMTIMER_GETRES", 0x6d01}, ++ {"linux/mtio.h", "MTIOCTOP", 0x6d01}, ++ {"linux/soundcard.h", "SNDCTL_MIDI_MPUMODE", 0x6d01}, ++ {"linux/synclink.h", "MGSL_IOCSTXIDLE", 0x6d02}, ++ {"linux/mmtimer.h", "MMTIMER_GETFREQ", 0x6d02}, ++ {"linux/mtio.h", "MTIOCGET", 0x6d02}, ++ {"linux/soundcard.h", "SNDCTL_MIDI_MPUCMD", 0x6d02}, ++ {"linux/synclink.h", "MGSL_IOCGTXIDLE", 0x6d03}, ++ {"linux/mtio.h", "MTIOCPOS", 0x6d03}, ++ {"linux/synclink.h", "MGSL_IOCTXENABLE", 0x6d04}, ++ {"linux/mmtimer.h", "MMTIMER_GETBITS", 0x6d04}, ++ {"linux/mtio.h", "MTIOCGETCONFIG", 0x6d04}, ++ {"linux/synclink.h", "MGSL_IOCRXENABLE", 0x6d05}, ++ {"linux/mtio.h", "MTIOCSETCONFIG", 0x6d05}, ++ {"linux/synclink.h", "MGSL_IOCTXABORT", 0x6d06}, ++ {"linux/mmtimer.h", "MMTIMER_MMAPAVAIL", 0x6d06}, ++ {"linux/mtio.h", "MTIOCRDFTSEG", 0x6d06}, ++ {"linux/synclink.h", "MGSL_IOCGSTATS", 0x6d07}, ++ {"linux/mtio.h", "MTIOCWRFTSEG", 0x6d07}, ++ {"linux/synclink.h", "MGSL_IOCWAITEVENT", 0x6d08}, ++ {"linux/mtio.h", "MTIOCVOLINFO", 0x6d08}, ++ {"linux/synclink.h", "MGSL_IOCLOOPTXDONE", 0x6d09}, ++ {"linux/mmtimer.h", "MMTIMER_GETCOUNTER", 0x6d09}, ++ {"linux/mtio.h", "MTIOCGETSIZE", 0x6d09}, ++ {"linux/synclink.h", "MGSL_IOCSIF", 0x6d0a}, ++ {"linux/mtio.h", "MTIOCFTFORMAT", 0x6d0a}, ++ {"linux/synclink.h", "MGSL_IOCGIF", 0x6d0b}, ++ {"linux/mtio.h", "MTIOCFTCMD", 0x6d0b}, ++ {"linux/synclink.h", "MGSL_IOCCLRMODCOUNT", 0x6d0f}, ++ {"linux/synclink.h", "MGSL_IOCSGPIO", 0x6d10}, ++ {"linux/synclink.h", "MGSL_IOCGGPIO", 0x6d11}, ++ {"linux/synclink.h", "MGSL_IOCWAITGPIO", 0x6d12}, ++ {"linux/zftape.h", "MTIOC_ZFTAPE_GETBLKSZ", 0x6d68}, ++ {"linux/ncp_fs.h", "NCP_IOC_NCPREQUEST", 0x6e01}, ++ {"linux/ncp_fs.h", "NCP_IOC_GETMOUNTUID", 0x6e02}, ++ {"linux/ncp_fs.h", "NCP_IOC_GETMOUNTUID2", 0x6e02}, ++ {"linux/ncp_fs.h", "NCP_IOC_CONN_LOGGED_IN", 0x6e03}, ++ {"linux/ncp_fs.h", "NCP_IOC_GET_FS_INFO", 0x6e04}, ++ {"linux/ncp_fs.h", "NCP_IOC_GET_FS_INFO_V2", 0x6e04}, ++ {"linux/ncp_fs.h", "NCP_IOC_SIGN_INIT", 0x6e05}, ++ {"linux/ncp_fs.h", "NCP_IOC_SET_SIGN_WANTED", 0x6e06}, ++ {"linux/ncp_fs.h", "NCP_IOC_SIGN_WANTED", 0x6e06}, ++ {"linux/ncp_fs.h", "NCP_IOC_LOCKUNLOCK", 0x6e07}, ++ {"linux/ncp_fs.h", "NCP_IOC_GETROOT", 0x6e08}, ++ {"linux/ncp_fs.h", "NCP_IOC_SETROOT", 0x6e08}, ++ {"linux/ncp_fs.h", "NCP_IOC_GETOBJECTNAME", 0x6e09}, ++ {"linux/ncp_fs.h", "NCP_IOC_SETOBJECTNAME", 0x6e09}, ++ {"linux/ncp_fs.h", "NCP_IOC_GETPRIVATEDATA", 0x6e0a}, ++ {"linux/ncp_fs.h", "NCP_IOC_SETPRIVATEDATA", 0x6e0a}, ++ {"linux/ncp_fs.h", "NCP_IOC_GETCHARSETS", 0x6e0b}, ++ {"linux/ncp_fs.h", "NCP_IOC_SETCHARSETS", 0x6e0b}, ++ {"linux/ncp_fs.h", "NCP_IOC_GETDENTRYTTL", 0x6e0c}, ++ {"linux/ncp_fs.h", "NCP_IOC_SETDENTRYTTL", 0x6e0c}, ++ {"linux/matroxfb.h", "MATROXFB_GET_OUTPUT_CONNECTION", 0x6ef8}, ++ {"linux/matroxfb.h", "MATROXFB_SET_OUTPUT_CONNECTION", 0x6ef8}, ++ {"video/sisfb.h", "SISFB_GET_INFO_OLD", 0x6ef8}, ++ {"linux/matroxfb.h", "MATROXFB_GET_AVAILABLE_OUTPUTS", 0x6ef9}, ++ {"video/sisfb.h", "SISFB_GET_VBRSTATUS_OLD", 0x6ef9}, ++ {"linux/matroxfb.h", "MATROXFB_GET_OUTPUT_MODE", 0x6efa}, ++ {"linux/matroxfb.h", "MATROXFB_SET_OUTPUT_MODE", 0x6efa}, ++ {"video/sisfb.h", "SISFB_GET_AUTOMAXIMIZE_OLD", 0x6efa}, ++ {"video/sisfb.h", "SISFB_SET_AUTOMAXIMIZE_OLD", 0x6efa}, ++ {"linux/matroxfb.h", "MATROXFB_GET_ALL_OUTPUTS", 0x6efb}, ++ {"mtd/ubi-user.h", "UBI_IOCMKVOL", 0x6f00}, ++ {"linux/dvb/audio.h", "AUDIO_STOP", 0x6f01}, ++ {"mtd/ubi-user.h", "UBI_IOCRMVOL", 0x6f01}, ++ {"linux/dvb/audio.h", "AUDIO_PLAY", 0x6f02}, ++ {"mtd/ubi-user.h", "UBI_IOCRSVOL", 0x6f02}, ++ {"linux/dvb/audio.h", "AUDIO_PAUSE", 0x6f03}, ++ {"linux/dvb/audio.h", "AUDIO_CONTINUE", 0x6f04}, ++ {"linux/dvb/audio.h", "AUDIO_SELECT_SOURCE", 0x6f05}, ++ {"linux/dvb/audio.h", "AUDIO_SET_MUTE", 0x6f06}, ++ {"linux/dvb/audio.h", "AUDIO_SET_AV_SYNC", 0x6f07}, ++ {"linux/dvb/audio.h", "AUDIO_SET_BYPASS_MODE", 0x6f08}, ++ {"linux/dvb/audio.h", "AUDIO_CHANNEL_SELECT", 0x6f09}, ++ {"linux/dvb/audio.h", "AUDIO_GET_STATUS", 0x6f0a}, ++ {"linux/dvb/audio.h", "AUDIO_GET_CAPABILITIES", 0x6f0b}, ++ {"linux/dvb/audio.h", "AUDIO_CLEAR_BUFFER", 0x6f0c}, ++ {"linux/dvb/audio.h", "AUDIO_SET_ID", 0x6f0d}, ++ {"linux/dvb/audio.h", "AUDIO_SET_MIXER", 0x6f0e}, ++ {"linux/dvb/audio.h", "AUDIO_SET_STREAMTYPE", 0x6f0f}, ++ {"linux/dvb/audio.h", "AUDIO_SET_EXT_ID", 0x6f10}, ++ {"linux/dvb/audio.h", "AUDIO_SET_ATTRIBUTES", 0x6f11}, ++ {"linux/dvb/audio.h", "AUDIO_SET_KARAOKE", 0x6f12}, ++ {"linux/dvb/audio.h", "AUDIO_GET_PTS", 0x6f13}, ++ {"linux/dvb/audio.h", "AUDIO_BILINGUAL_CHANNEL_SELECT", 0x6f14}, ++ {"linux/dvb/video.h", "VIDEO_STOP", 0x6f15}, ++ {"linux/dvb/video.h", "VIDEO_PLAY", 0x6f16}, ++ {"linux/dvb/video.h", "VIDEO_FREEZE", 0x6f17}, ++ {"linux/dvb/video.h", "VIDEO_CONTINUE", 0x6f18}, ++ {"linux/dvb/video.h", "VIDEO_SELECT_SOURCE", 0x6f19}, ++ {"linux/dvb/video.h", "VIDEO_SET_BLANK", 0x6f1a}, ++ {"linux/dvb/video.h", "VIDEO_GET_STATUS", 0x6f1b}, ++ {"linux/dvb/video.h", "VIDEO_GET_EVENT", 0x6f1c}, ++ {"linux/dvb/video.h", "VIDEO_SET_DISPLAY_FORMAT", 0x6f1d}, ++ {"linux/dvb/video.h", "VIDEO_STILLPICTURE", 0x6f1e}, ++ {"linux/dvb/video.h", "VIDEO_FAST_FORWARD", 0x6f1f}, ++ {"linux/dvb/video.h", "VIDEO_SLOWMOTION", 0x6f20}, ++ {"linux/dvb/video.h", "VIDEO_GET_CAPABILITIES", 0x6f21}, ++ {"linux/dvb/video.h", "VIDEO_CLEAR_BUFFER", 0x6f22}, ++ {"linux/dvb/video.h", "VIDEO_SET_ID", 0x6f23}, ++ {"linux/dvb/video.h", "VIDEO_SET_STREAMTYPE", 0x6f24}, ++ {"linux/dvb/video.h", "VIDEO_SET_FORMAT", 0x6f25}, ++ {"linux/dvb/video.h", "VIDEO_SET_SYSTEM", 0x6f26}, ++ {"linux/dvb/video.h", "VIDEO_SET_HIGHLIGHT", 0x6f27}, ++ {"linux/dvb/dmx.h", "DMX_START", 0x6f29}, ++ {"linux/dvb/dmx.h", "DMX_STOP", 0x6f2a}, ++ {"linux/dvb/dmx.h", "DMX_SET_FILTER", 0x6f2b}, ++ {"linux/dvb/dmx.h", "DMX_SET_PES_FILTER", 0x6f2c}, ++ {"linux/dvb/dmx.h", "DMX_SET_BUFFER_SIZE", 0x6f2d}, ++ {"linux/dvb/dmx.h", "DMX_GET_PES_PIDS", 0x6f2f}, ++ {"linux/dvb/dmx.h", "DMX_GET_CAPS", 0x6f30}, ++ {"linux/dvb/dmx.h", "DMX_SET_SOURCE", 0x6f31}, ++ {"linux/dvb/dmx.h", "DMX_GET_STC", 0x6f32}, ++ {"linux/dvb/video.h", "VIDEO_SET_SPU", 0x6f32}, ++ {"linux/dvb/video.h", "VIDEO_SET_SPU_PALETTE", 0x6f33}, ++ {"linux/dvb/net.h", "NET_ADD_IF", 0x6f34}, ++ {"linux/dvb/video.h", "VIDEO_GET_NAVI", 0x6f34}, ++ {"linux/dvb/net.h", "NET_REMOVE_IF", 0x6f35}, ++ {"linux/dvb/video.h", "VIDEO_SET_ATTRIBUTES", 0x6f35}, ++ {"linux/dvb/net.h", "NET_GET_IF", 0x6f36}, ++ {"linux/dvb/video.h", "VIDEO_GET_SIZE", 0x6f37}, ++ {"linux/dvb/video.h", "VIDEO_GET_FRAME_RATE", 0x6f38}, ++ {"linux/dvb/video.h", "VIDEO_GET_PTS", 0x6f39}, ++ {"linux/dvb/video.h", "VIDEO_GET_FRAME_COUNT", 0x6f3a}, ++ {"linux/dvb/video.h", "VIDEO_COMMAND", 0x6f3b}, ++ {"linux/dvb/video.h", "VIDEO_TRY_COMMAND", 0x6f3c}, ++ {"linux/dvb/frontend.h", "FE_GET_INFO", 0x6f3d}, ++ {"linux/dvb/frontend.h", "FE_DISEQC_RESET_OVERLOAD", 0x6f3e}, ++ {"linux/dvb/frontend.h", "FE_DISEQC_SEND_MASTER_CMD", 0x6f3f}, ++ {"linux/dvb/frontend.h", "FE_DISEQC_RECV_SLAVE_REPLY", 0x6f40}, ++ {"mtd/ubi-user.h", "UBI_IOCATT", 0x6f40}, ++ {"linux/dvb/frontend.h", "FE_DISEQC_SEND_BURST", 0x6f41}, ++ {"mtd/ubi-user.h", "UBI_IOCDET", 0x6f41}, ++ {"linux/dvb/frontend.h", "FE_SET_TONE", 0x6f42}, ++ {"linux/dvb/frontend.h", "FE_SET_VOLTAGE", 0x6f43}, ++ {"linux/dvb/frontend.h", "FE_ENABLE_HIGH_LNB_VOLTAGE", 0x6f44}, ++ {"linux/dvb/frontend.h", "FE_READ_STATUS", 0x6f45}, ++ {"linux/dvb/frontend.h", "FE_READ_BER", 0x6f46}, ++ {"linux/dvb/frontend.h", "FE_READ_SIGNAL_STRENGTH", 0x6f47}, ++ {"linux/dvb/frontend.h", "FE_READ_SNR", 0x6f48}, ++ {"linux/dvb/frontend.h", "FE_READ_UNCORRECTED_BLOCKS", 0x6f49}, ++ {"linux/dvb/frontend.h", "FE_SET_FRONTEND", 0x6f4c}, ++ {"linux/dvb/frontend.h", "FE_GET_FRONTEND", 0x6f4d}, ++ {"linux/dvb/frontend.h", "FE_GET_EVENT", 0x6f4e}, ++ {"linux/dvb/frontend.h", "FE_DISHNETWORK_SEND_LEGACY_CMD", 0x6f50}, ++ {"linux/dvb/frontend.h", "FE_SET_FRONTEND_TUNE_MODE", 0x6f51}, ++ {"linux/dvb/ca.h", "CA_RESET", 0x6f80}, ++ {"linux/dvb/ca.h", "CA_GET_CAP", 0x6f81}, ++ {"linux/dvb/ca.h", "CA_GET_SLOT_INFO", 0x6f82}, ++ {"linux/dvb/ca.h", "CA_GET_DESCR_INFO", 0x6f83}, ++ {"linux/dvb/ca.h", "CA_GET_MSG", 0x6f84}, ++ {"linux/dvb/ca.h", "CA_SEND_MSG", 0x6f85}, ++ {"linux/dvb/ca.h", "CA_SET_DESCR", 0x6f86}, ++ {"linux/dvb/ca.h", "CA_SET_PID", 0x6f87}, ++ {"linux/dvb/osd.h", "OSD_SEND_CMD", 0x6fa0}, ++ {"linux/dvb/osd.h", "OSD_GET_CAPABILITY", 0x6fa1}, ++ {"linux/phantom.h", "PHN_GET_REG", 0x7000}, ++ {"linux/phantom.h", "PHN_SET_REG", 0x7001}, ++ {"linux/rtc.h", "RTC_AIE_ON", 0x7001}, ++ {"linux/phantom.h", "PHN_GET_REGS", 0x7002}, ++ {"linux/rtc.h", "RTC_AIE_OFF", 0x7002}, ++ {"linux/phantom.h", "PHN_SET_REGS", 0x7003}, ++ {"linux/rtc.h", "RTC_UIE_ON", 0x7003}, ++ {"linux/phantom.h", "PHN_NOT_OH", 0x7004}, ++ {"linux/rtc.h", "RTC_UIE_OFF", 0x7004}, ++ {"linux/phantom.h", "PHN_GETREG", 0x7005}, ++ {"linux/rtc.h", "RTC_PIE_ON", 0x7005}, ++ {"linux/phantom.h", "PHN_SETREG", 0x7006}, ++ {"linux/rtc.h", "RTC_PIE_OFF", 0x7006}, ++ {"linux/phantom.h", "PHN_GETREGS", 0x7007}, ++ {"linux/rtc.h", "RTC_ALM_SET", 0x7007}, ++ {"linux/phantom.h", "PHN_SETREGS", 0x7008}, ++ {"linux/rtc.h", "RTC_ALM_READ", 0x7008}, ++ {"linux/rtc.h", "RTC_RD_TIME", 0x7009}, ++ {"linux/rtc.h", "RTC_SET_TIME", 0x700a}, ++ {"linux/rtc.h", "RTC_IRQP_READ", 0x700b}, ++ {"linux/rtc.h", "RTC_IRQP_SET", 0x700c}, ++ {"linux/rtc.h", "RTC_EPOCH_READ", 0x700d}, ++ {"linux/rtc.h", "RTC_EPOCH_SET", 0x700e}, ++ {"linux/rtc.h", "RTC_WIE_ON", 0x700f}, ++ {"linux/rtc.h", "RTC_WKALM_SET", 0x700f}, ++ {"linux/rtc.h", "RTC_WIE_OFF", 0x7010}, ++ {"linux/rtc.h", "RTC_WKALM_RD", 0x7010}, ++ {"linux/rtc.h", "RTC_PLL_GET", 0x7011}, ++ {"linux/rtc.h", "RTC_PLL_SET", 0x7012}, ++ {"linux/nvram.h", "NVRAM_INIT", 0x7040}, ++ {"linux/nvram.h", "NVRAM_SETCKS", 0x7041}, ++ {"linux/ppdev.h", "PPSETMODE", 0x7080}, ++ {"linux/ppdev.h", "PPRSTATUS", 0x7081}, ++ {"linux/ppdev.h", "PPRCONTROL", 0x7083}, ++ {"linux/ppdev.h", "PPWCONTROL", 0x7084}, ++ {"linux/ppdev.h", "PPRDATA", 0x7085}, ++ {"linux/ppdev.h", "PPWDATA", 0x7086}, ++ {"linux/ppdev.h", "PPCLAIM", 0x708b}, ++ {"linux/ppdev.h", "PPRELEASE", 0x708c}, ++ {"linux/ppdev.h", "PPYIELD", 0x708d}, ++ {"linux/ppdev.h", "PPFCONTROL", 0x708e}, ++ {"linux/ppdev.h", "PPEXCL", 0x708f}, ++ {"linux/ppdev.h", "PPDATADIR", 0x7090}, ++ {"linux/ppdev.h", "PPNEGOT", 0x7091}, ++ {"linux/ppdev.h", "PPWCTLONIRQ", 0x7092}, ++ {"linux/ppdev.h", "PPCLRIRQ", 0x7093}, ++ {"linux/ppdev.h", "PPSETPHASE", 0x7094}, ++ {"linux/ppdev.h", "PPGETTIME", 0x7095}, ++ {"linux/ppdev.h", "PPSETTIME", 0x7096}, ++ {"linux/ppdev.h", "PPGETMODES", 0x7097}, ++ {"linux/ppdev.h", "PPGETMODE", 0x7098}, ++ {"linux/ppdev.h", "PPGETPHASE", 0x7099}, ++ {"linux/ppdev.h", "PPGETFLAGS", 0x709a}, ++ {"linux/ppdev.h", "PPSETFLAGS", 0x709b}, ++ {"linux/ticable.h", "IOCTL_TISER_DELAY", 0x70a0}, ++ {"linux/ticable.h", "IOCTL_TISER_TIMEOUT", 0x70a1}, ++ {"linux/ticable.h", "IOCTL_TIPAR_DELAY", 0x70a8}, ++ {"linux/ticable.h", "IOCTL_TIPAR_TIMEOUT", 0x70a9}, ++ {"linux/serio.h", "SPIOCSTYPE", 0x7101}, ++ {"linux/videotext.h", "VTXIOCGETINFO_OLD", 0x7101}, ++ {"linux/videotext.h", "VTXIOCCLRPAGE_OLD", 0x7102}, ++ {"linux/videotext.h", "VTXIOCCLRFOUND_OLD", 0x7103}, ++ {"linux/videotext.h", "VTXIOCPAGEREQ_OLD", 0x7104}, ++ {"linux/videotext.h", "VTXIOCGETSTAT_OLD", 0x7105}, ++ {"linux/videotext.h", "VTXIOCGETPAGE_OLD", 0x7106}, ++ {"linux/videotext.h", "VTXIOCSTOPDAU_OLD", 0x7107}, ++ {"linux/videotext.h", "VTXIOCPUTPAGE_OLD", 0x7108}, ++ {"linux/videotext.h", "VTXIOCSETDISP_OLD", 0x7109}, ++ {"linux/videotext.h", "VTXIOCPUTSTAT_OLD", 0x710a}, ++ {"linux/videotext.h", "VTXIOCCLRCACHE_OLD", 0x710b}, ++ {"linux/videotext.h", "VTXIOCSETVIRT_OLD", 0x710c}, ++ {"linux/telephony.h", "PHONE_CAPABILITIES", 0x7180}, ++ {"linux/telephony.h", "PHONE_CAPABILITIES_LIST", 0x7181}, ++ {"linux/telephony.h", "PHONE_CAPABILITIES_CHECK", 0x7182}, ++ {"linux/telephony.h", "PHONE_RING", 0x7183}, ++ {"linux/telephony.h", "PHONE_HOOKSTATE", 0x7184}, ++ {"linux/telephony.h", "PHONE_MAXRINGS", 0x7185}, ++ {"linux/telephony.h", "PHONE_RING_CADENCE", 0x7186}, ++ {"linux/telephony.h", "OLD_PHONE_RING_START", 0x7187}, ++ {"linux/telephony.h", "PHONE_RING_START", 0x7187}, ++ {"linux/telephony.h", "PHONE_RING_STOP", 0x7188}, ++ {"linux/telephony.h", "PHONE_REC_CODEC", 0x7189}, ++ {"linux/telephony.h", "PHONE_REC_START", 0x718a}, ++ {"linux/telephony.h", "PHONE_REC_STOP", 0x718b}, ++ {"linux/telephony.h", "PHONE_REC_DEPTH", 0x718c}, ++ {"linux/telephony.h", "PHONE_FRAME", 0x718d}, ++ {"linux/telephony.h", "PHONE_REC_VOLUME", 0x718e}, ++ {"linux/telephony.h", "PHONE_REC_LEVEL", 0x718f}, ++ {"linux/telephony.h", "PHONE_PLAY_CODEC", 0x7190}, ++ {"linux/telephony.h", "PHONE_PLAY_START", 0x7191}, ++ {"linux/telephony.h", "PHONE_PLAY_STOP", 0x7192}, ++ {"linux/telephony.h", "PHONE_PLAY_DEPTH", 0x7193}, ++ {"linux/telephony.h", "PHONE_PLAY_VOLUME", 0x7194}, ++ {"linux/telephony.h", "PHONE_PLAY_LEVEL", 0x7195}, ++ {"linux/telephony.h", "PHONE_DTMF_READY", 0x7196}, ++ {"linux/telephony.h", "PHONE_GET_DTMF", 0x7197}, ++ {"linux/telephony.h", "PHONE_GET_DTMF_ASCII", 0x7198}, ++ {"linux/telephony.h", "PHONE_DTMF_OOB", 0x7199}, ++ {"linux/telephony.h", "PHONE_EXCEPTION", 0x719a}, ++ {"linux/telephony.h", "PHONE_PLAY_TONE", 0x719b}, ++ {"linux/telephony.h", "PHONE_SET_TONE_ON_TIME", 0x719c}, ++ {"linux/telephony.h", "PHONE_SET_TONE_OFF_TIME", 0x719d}, ++ {"linux/telephony.h", "PHONE_GET_TONE_ON_TIME", 0x719e}, ++ {"linux/telephony.h", "PHONE_GET_TONE_OFF_TIME", 0x719f}, ++ {"linux/telephony.h", "PHONE_GET_TONE_STATE", 0x71a0}, ++ {"linux/telephony.h", "PHONE_BUSY", 0x71a1}, ++ {"linux/telephony.h", "PHONE_RINGBACK", 0x71a2}, ++ {"linux/telephony.h", "PHONE_DIALTONE", 0x71a3}, ++ {"linux/telephony.h", "PHONE_CPT_STOP", 0x71a4}, ++ {"linux/telephony.h", "PHONE_PSTN_SET_STATE", 0x71a4}, ++ {"linux/telephony.h", "PHONE_PSTN_GET_STATE", 0x71a5}, ++ {"linux/telephony.h", "PHONE_WINK_DURATION", 0x71a6}, ++ {"linux/telephony.h", "PHONE_QUERY_CODEC", 0x71a7}, ++ {"linux/telephony.h", "PHONE_PSTN_LINETEST", 0x71a8}, ++ {"linux/telephony.h", "PHONE_VAD", 0x71a9}, ++ {"linux/telephony.h", "PHONE_WINK", 0x71aa}, ++ {"linux/ixjuser.h", "IXJCTL_DSP_RESET", 0x71c0}, ++ {"linux/ixjuser.h", "IXJCTL_CARDTYPE", 0x71c1}, ++ {"linux/ixjuser.h", "IXJCTL_SERIAL", 0x71c2}, ++ {"linux/ixjuser.h", "IXJCTL_DSP_TYPE", 0x71c3}, ++ {"linux/ixjuser.h", "IXJCTL_DSP_VERSION", 0x71c4}, ++ {"linux/ixjuser.h", "IXJCTL_DSP_IDLE", 0x71c5}, ++ {"linux/ixjuser.h", "IXJCTL_TESTRAM", 0x71c6}, ++ {"linux/ixjuser.h", "IXJCTL_SET_FILTER", 0x71c7}, ++ {"linux/ixjuser.h", "IXJCTL_GET_FILTER_HIST", 0x71c8}, ++ {"linux/ixjuser.h", "IXJCTL_INIT_TONE", 0x71c9}, ++ {"linux/ixjuser.h", "IXJCTL_TONE_CADENCE", 0x71ca}, ++ {"linux/ixjuser.h", "IXJCTL_AEC_START", 0x71cb}, ++ {"linux/ixjuser.h", "IXJCTL_AEC_STOP", 0x71cc}, ++ {"linux/ixjuser.h", "IXJCTL_AEC_GET_LEVEL", 0x71cd}, ++ {"linux/ixjuser.h", "IXJCTL_SET_LED", 0x71ce}, ++ {"linux/ixjuser.h", "IXJCTL_MIXER", 0x71cf}, ++ {"linux/ixjuser.h", "IXJCTL_DAA_COEFF_SET", 0x71d0}, ++ {"linux/ixjuser.h", "IXJCTL_PORT", 0x71d1}, ++ {"linux/ixjuser.h", "IXJCTL_DAA_AGAIN", 0x71d2}, ++ {"linux/ixjuser.h", "IXJCTL_PSTN_LINETEST", 0x71d3}, ++ {"linux/ixjuser.h", "IXJCTL_CID", 0x71d4}, ++ {"linux/ixjuser.h", "IXJCTL_POTS_PSTN", 0x71d5}, ++ {"linux/ixjuser.h", "IXJCTL_FILTER_CADENCE", 0x71d6}, ++ {"linux/ixjuser.h", "IXJCTL_PLAY_CID", 0x71d7}, ++ {"linux/ixjuser.h", "IXJCTL_VMWI", 0x71d8}, ++ {"linux/ixjuser.h", "IXJCTL_CIDCW", 0x71d9}, ++ {"linux/ixjuser.h", "IXJCTL_VERSION", 0x71da}, ++ {"linux/telephony.h", "PHONE_REC_VOLUME_LINEAR", 0x71db}, ++ {"linux/telephony.h", "PHONE_PLAY_VOLUME_LINEAR", 0x71dc}, ++ {"linux/ixjuser.h", "IXJCTL_SET_FILTER_RAW", 0x71dd}, ++ {"linux/ixjuser.h", "IXJCTL_HZ", 0x71e0}, ++ {"linux/ixjuser.h", "IXJCTL_RATE", 0x71e1}, ++ {"linux/ixjuser.h", "IXJCTL_FRAMES_READ", 0x71e2}, ++ {"linux/ixjuser.h", "IXJCTL_FRAMES_WRITTEN", 0x71e3}, ++ {"linux/ixjuser.h", "IXJCTL_READ_WAIT", 0x71e4}, ++ {"linux/ixjuser.h", "IXJCTL_WRITE_WAIT", 0x71e5}, ++ {"linux/ixjuser.h", "IXJCTL_DRYBUFFER_READ", 0x71e6}, ++ {"linux/ixjuser.h", "IXJCTL_DRYBUFFER_CLEAR", 0x71e7}, ++ {"linux/ixjuser.h", "IXJCTL_DTMF_PRESCALE", 0x71e8}, ++ {"linux/ixjuser.h", "IXJCTL_SIGCTL", 0x71e9}, ++ {"linux/ixjuser.h", "IXJCTL_SC_RXG", 0x71ea}, ++ {"linux/ixjuser.h", "IXJCTL_SC_TXG", 0x71eb}, ++ {"linux/ixjuser.h", "IXJCTL_INTERCOM_START", 0x71fd}, ++ {"linux/ixjuser.h", "IXJCTL_INTERCOM_STOP", 0x71fe}, ++ {"linux/msdos_fs.h", "VFAT_IOCTL_READDIR_BOTH", 0x7201}, ++ {"linux/msdos_fs.h", "VFAT_IOCTL_READDIR_SHORT", 0x7202}, ++ {"linux/msdos_fs.h", "FAT_IOCTL_GET_ATTRIBUTES", 0x7210}, ++ {"linux/msdos_fs.h", "FAT_IOCTL_SET_ATTRIBUTES", 0x7211}, ++ {"linux/cdk.h", "STL_BINTR", 0x7314}, ++ {"linux/cdk.h", "STL_BSTART", 0x7315}, ++ {"linux/cdk.h", "STL_BSTOP", 0x7316}, ++ {"linux/cdk.h", "STL_BRESET", 0x7317}, ++ {"linux/cdk.h", "STL_GETPFLAG", 0x7350}, ++ {"linux/cdk.h", "STL_SETPFLAG", 0x7351}, ++ {"asm/bfin_simple_timer.h", "BFIN_SIMPLE_TIMER_SET_PERIOD", 0x7402}, ++ {"asm/bfin_simple_timer.h", "BFIN_SIMPLE_TIMER_START", 0x7406}, ++ {"asm/bfin_simple_timer.h", "BFIN_SIMPLE_TIMER_STOP", 0x7408}, ++ {"asm/bfin_simple_timer.h", "BFIN_SIMPLE_TIMER_READ", 0x740a}, ++ {"linux/if_ppp.h", "PPPIOCGL2TPSTATS", 0x7436}, ++ {"linux/if_ppp.h", "PPPIOCGCHAN", 0x7437}, ++ {"linux/if_ppp.h", "PPPIOCATTCHAN", 0x7438}, ++ {"linux/if_ppp.h", "PPPIOCDISCONN", 0x7439}, ++ {"linux/if_ppp.h", "PPPIOCCONNECT", 0x743a}, ++ {"linux/if_ppp.h", "PPPIOCSMRRU", 0x743b}, ++ {"linux/if_ppp.h", "PPPIOCDETACH", 0x743c}, ++ {"linux/if_ppp.h", "PPPIOCATTACH", 0x743d}, ++ {"linux/if_ppp.h", "PPPIOCNEWUNIT", 0x743e}, ++ {"linux/if_ppp.h", "PPPIOCGIDLE", 0x743f}, ++ {"linux/if_ppp.h", "PPPIOCSDEBUG", 0x7440}, ++ {"linux/if_ppp.h", "PPPIOCGDEBUG", 0x7441}, ++ {"linux/if_ppp.h", "PPPIOCSACTIVE", 0x7446}, ++ {"linux/if_ppp.h", "PPPIOCSPASS", 0x7447}, ++ {"linux/if_ppp.h", "PPPIOCSNPMODE", 0x744b}, ++ {"linux/if_ppp.h", "PPPIOCGNPMODE", 0x744c}, ++ {"linux/if_ppp.h", "PPPIOCSCOMPRESS", 0x744d}, ++ {"linux/if_ppp.h", "PPPIOCXFERUNIT", 0x744e}, ++ {"linux/if_ppp.h", "PPPIOCSXASYNCMAP", 0x744f}, ++ {"linux/if_ppp.h", "PPPIOCGXASYNCMAP", 0x7450}, ++ {"linux/if_ppp.h", "PPPIOCSMAXCID", 0x7451}, ++ {"linux/if_ppp.h", "PPPIOCSMRU", 0x7452}, ++ {"linux/if_ppp.h", "PPPIOCGMRU", 0x7453}, ++ {"linux/if_ppp.h", "PPPIOCSRASYNCMAP", 0x7454}, ++ {"linux/if_ppp.h", "PPPIOCGRASYNCMAP", 0x7455}, ++ {"linux/if_ppp.h", "PPPIOCGUNIT", 0x7456}, ++ {"linux/if_ppp.h", "PPPIOCSASYNCMAP", 0x7457}, ++ {"linux/if_ppp.h", "PPPIOCGASYNCMAP", 0x7458}, ++ {"linux/if_ppp.h", "PPPIOCSFLAGS", 0x7459}, ++ {"linux/if_ppp.h", "PPPIOCGFLAGS", 0x745a}, ++ {"linux/isdn_ppp.h", "PPPIOCGCALLINFO", 0x7480}, ++ {"linux/isdn_ppp.h", "PPPIOCBUNDLE", 0x7481}, ++ {"linux/isdn_ppp.h", "PPPIOCGMPFLAGS", 0x7482}, ++ {"linux/isdn_ppp.h", "PPPIOCSMPFLAGS", 0x7483}, ++ {"linux/isdn_ppp.h", "PPPIOCSMPMTU", 0x7484}, ++ {"linux/isdn_ppp.h", "PPPIOCSMPMRU", 0x7485}, ++ {"linux/isdn_ppp.h", "PPPIOCGCOMPRESSORS", 0x7486}, ++ {"linux/isdn_ppp.h", "PPPIOCSCOMPRESSOR", 0x7487}, ++ {"linux/isdn_ppp.h", "PPPIOCGIFNAME", 0x7488}, ++ {"linux/toshiba.h", "TOSH_SMM", 0x7490}, ++ {"linux/smb_fs.h", "SMB_IOC_GETMOUNTUID", 0x7501}, ++ {"linux/smb_fs.h", "SMB_IOC_NEWCONN", 0x7502}, ++ {"linux/smb_fs.h", "SMB_IOC_GETMOUNTUID32", 0x7503}, ++ {"linux/sonypi.h", "SONYPI_IOCGBRT", 0x7600}, ++ {"linux/sonypi.h", "SONYPI_IOCSBRT", 0x7600}, ++ {"linux/fs.h", "FS_IOC32_GETVERSION", 0x7601}, ++ {"linux/fs.h", "FS_IOC_GETVERSION", 0x7601}, ++ {"linux/videodev.h", "VIDIOCGCAP", 0x7601}, ++ {"linux/fs.h", "FS_IOC32_SETVERSION", 0x7602}, ++ {"linux/fs.h", "FS_IOC_SETVERSION", 0x7602}, ++ {"linux/sonypi.h", "SONYPI_IOCGBAT1CAP", 0x7602}, ++ {"linux/videodev.h", "VIDIOCGCHAN", 0x7602}, ++ {"linux/sonypi.h", "SONYPI_IOCGBAT1REM", 0x7603}, ++ {"linux/videodev.h", "VIDIOCSCHAN", 0x7603}, ++ {"linux/sonypi.h", "SONYPI_IOCGBAT2CAP", 0x7604}, ++ {"linux/videodev.h", "VIDIOCGTUNER", 0x7604}, ++ {"linux/sonypi.h", "SONYPI_IOCGBAT2REM", 0x7605}, ++ {"linux/videodev.h", "VIDIOCSTUNER", 0x7605}, ++ {"linux/videodev.h", "VIDIOCGPICT", 0x7606}, ++ {"linux/sonypi.h", "SONYPI_IOCGBATFLAGS", 0x7607}, ++ {"linux/videodev.h", "VIDIOCSPICT", 0x7607}, ++ {"linux/sonypi.h", "SONYPI_IOCGBLUE", 0x7608}, ++ {"linux/videodev.h", "VIDIOCCAPTURE", 0x7608}, ++ {"linux/sonypi.h", "SONYPI_IOCSBLUE", 0x7609}, ++ {"linux/videodev.h", "VIDIOCGWIN", 0x7609}, ++ {"linux/sonypi.h", "SONYPI_IOCGFAN", 0x760a}, ++ {"linux/videodev.h", "VIDIOCSWIN", 0x760a}, ++ {"linux/sonypi.h", "SONYPI_IOCSFAN", 0x760b}, ++ {"linux/videodev.h", "VIDIOCGFBUF", 0x760b}, ++ {"linux/sonypi.h", "SONYPI_IOCGTEMP", 0x760c}, ++ {"linux/videodev.h", "VIDIOCSFBUF", 0x760c}, ++ {"linux/videodev.h", "VIDIOCKEY", 0x760d}, ++ {"linux/videodev.h", "VIDIOCGFREQ", 0x760e}, ++ {"linux/videodev.h", "VIDIOCSFREQ", 0x760f}, ++ {"linux/videodev.h", "VIDIOCGAUDIO", 0x7610}, ++ {"linux/videodev.h", "VIDIOCSAUDIO", 0x7611}, ++ {"linux/videodev.h", "VIDIOCSYNC", 0x7612}, ++ {"linux/videodev.h", "VIDIOCMCAPTURE", 0x7613}, ++ {"linux/videodev.h", "VIDIOCGMBUF", 0x7614}, ++ {"linux/videodev.h", "VIDIOCGUNIT", 0x7615}, ++ {"linux/videodev.h", "VIDIOCGCAPTURE", 0x7616}, ++ {"linux/videodev.h", "VIDIOCSCAPTURE", 0x7617}, ++ {"linux/videodev.h", "VIDIOCSPLAYMODE", 0x7618}, ++ {"linux/videodev.h", "VIDIOCSWRITEMODE", 0x7619}, ++ {"linux/videodev.h", "VIDIOCGPLAYINFO", 0x761a}, ++ {"linux/videodev.h", "VIDIOCSMICROCODE", 0x761b}, ++ {"linux/videodev.h", "VIDIOCGVBIFMT", 0x761c}, ++ {"linux/videodev.h", "VIDIOCSVBIFMT", 0x761d}, ++ {"linux/meye.h", "MEYEIOC_G_PARAMS", 0x76c0}, ++ {"media/pwc-ioctl.h", "VIDIOCPWCRUSER", 0x76c0}, ++ {"linux/meye.h", "MEYEIOC_S_PARAMS", 0x76c1}, ++ {"media/pwc-ioctl.h", "VIDIOCPWCSUSER", 0x76c1}, ++ {"linux/meye.h", "MEYEIOC_QBUF_CAPT", 0x76c2}, ++ {"media/pwc-ioctl.h", "VIDIOCPWCFACTORY", 0x76c2}, ++ {"linux/meye.h", "MEYEIOC_SYNC", 0x76c3}, ++ {"media/pwc-ioctl.h", "VIDIOCPWCGCQUAL", 0x76c3}, ++ {"media/pwc-ioctl.h", "VIDIOCPWCSCQUAL", 0x76c3}, ++ {"linux/meye.h", "MEYEIOC_STILLCAPT", 0x76c4}, ++ {"linux/meye.h", "MEYEIOC_STILLJCAPT", 0x76c5}, ++ {"media/pwc-ioctl.h", "VIDIOCPWCGSERIAL", 0x76c6}, ++ {"media/pwc-ioctl.h", "VIDIOCPWCPROBE", 0x76c7}, ++ {"media/pwc-ioctl.h", "VIDIOCPWCGAGC", 0x76c8}, ++ {"media/pwc-ioctl.h", "VIDIOCPWCSAGC", 0x76c8}, ++ {"media/pwc-ioctl.h", "VIDIOCPWCSSHUTTER", 0x76c9}, ++ {"media/pwc-ioctl.h", "VIDIOCPWCGAWB", 0x76ca}, ++ {"media/pwc-ioctl.h", "VIDIOCPWCSAWB", 0x76ca}, ++ {"media/pwc-ioctl.h", "VIDIOCPWCGAWBSPEED", 0x76cb}, ++ {"media/pwc-ioctl.h", "VIDIOCPWCSAWBSPEED", 0x76cb}, ++ {"media/pwc-ioctl.h", "VIDIOCPWCGLED", 0x76cd}, ++ {"media/pwc-ioctl.h", "VIDIOCPWCSLED", 0x76cd}, ++ {"media/pwc-ioctl.h", "VIDIOCPWCGCONTOUR", 0x76ce}, ++ {"media/pwc-ioctl.h", "VIDIOCPWCSCONTOUR", 0x76ce}, ++ {"media/pwc-ioctl.h", "VIDIOCPWCGBACKLIGHT", 0x76cf}, ++ {"media/pwc-ioctl.h", "VIDIOCPWCSBACKLIGHT", 0x76cf}, ++ {"media/pwc-ioctl.h", "VIDIOCPWCGFLICKER", 0x76d0}, ++ {"media/pwc-ioctl.h", "VIDIOCPWCSFLICKER", 0x76d0}, ++ {"media/pwc-ioctl.h", "VIDIOCPWCGDYNNOISE", 0x76d1}, ++ {"media/pwc-ioctl.h", "VIDIOCPWCSDYNNOISE", 0x76d1}, ++ {"media/pwc-ioctl.h", "VIDIOCPWCGREALSIZE", 0x76d2}, ++ {"media/pwc-ioctl.h", "VIDIOCPWCMPTGRANGE", 0x76d3}, ++ {"media/pwc-ioctl.h", "VIDIOCPWCMPTRESET", 0x76d3}, ++ {"media/pwc-ioctl.h", "VIDIOCPWCMPTGANGLE", 0x76d4}, ++ {"media/pwc-ioctl.h", "VIDIOCPWCMPTSANGLE", 0x76d4}, ++ {"linux/videodev.h", "VIDIOSFPS", 0x76d4}, ++ {"media/pwc-ioctl.h", "VIDIOCPWCMPTSTATUS", 0x76d5}, ++ {"media/pwc-ioctl.h", "VIDIOCPWCGVIDCMD", 0x76d7}, ++ {"media/pwc-ioctl.h", "VIDIOCPWCGVIDTABLE", 0x76d8}, ++ {"linux/videotext.h", "VTXIOCGETINFO", 0x8101}, ++ {"linux/videotext.h", "VTXIOCCLRPAGE", 0x8102}, ++ {"linux/videotext.h", "VTXIOCCLRFOUND", 0x8103}, ++ {"linux/videotext.h", "VTXIOCPAGEREQ", 0x8104}, ++ {"linux/videotext.h", "VTXIOCGETSTAT", 0x8105}, ++ {"linux/videotext.h", "VTXIOCGETPAGE", 0x8106}, ++ {"linux/videotext.h", "VTXIOCSTOPDAU", 0x8107}, ++ {"linux/videotext.h", "VTXIOCPUTPAGE", 0x8108}, ++ {"linux/videotext.h", "VTXIOCSETDISP", 0x8109}, ++ {"linux/videotext.h", "VTXIOCPUTSTAT", 0x810a}, ++ {"linux/videotext.h", "VTXIOCCLRCACHE", 0x810b}, ++ {"linux/videotext.h", "VTXIOCSETVIRT", 0x810c}, ++ {"media/ovcamchip.h", "OVCAMCHIP_CMD_Q_SUBTYPE", 0x8800}, ++ {"media/ovcamchip.h", "OVCAMCHIP_CMD_INITIALIZE", 0x8801}, ++ {"media/ovcamchip.h", "OVCAMCHIP_CMD_S_CTRL", 0x8802}, ++ {"media/ovcamchip.h", "OVCAMCHIP_CMD_G_CTRL", 0x8803}, ++ {"media/ovcamchip.h", "OVCAMCHIP_CMD_S_MODE", 0x8804}, ++ {"media/ovcamchip.h", "OVCAMCHIP_MAX_CMD", 0x883f}, ++ {"asm/sockios.h", "FIOSETOWN", 0x8901}, ++ {"asm/sockios.h", "SIOCSPGRP", 0x8902}, ++ {"asm/sockios.h", "FIOGETOWN", 0x8903}, ++ {"asm/sockios.h", "SIOCGPGRP", 0x8904}, ++ {"asm/sockios.h", "SIOCATMARK", 0x8905}, ++ {"asm/sockios.h", "SIOCGSTAMP", 0x8906}, ++ {"asm/sockios.h", "SIOCGSTAMPNS", 0x8907}, ++ {"linux/sockios.h", "SIOCADDRT", 0x890b}, ++ {"linux/sockios.h", "SIOCDELRT", 0x890c}, ++ {"linux/sockios.h", "SIOCRTMSG", 0x890d}, ++ {"linux/sockios.h", "SIOCGIFNAME", 0x8910}, ++ {"linux/sockios.h", "SIOCSIFLINK", 0x8911}, ++ {"linux/sockios.h", "SIOCGIFCONF", 0x8912}, ++ {"linux/sockios.h", "SIOCGIFFLAGS", 0x8913}, ++ {"linux/sockios.h", "SIOCSIFFLAGS", 0x8914}, ++ {"linux/sockios.h", "SIOCGIFADDR", 0x8915}, ++ {"linux/sockios.h", "SIOCSIFADDR", 0x8916}, ++ {"linux/sockios.h", "SIOCGIFDSTADDR", 0x8917}, ++ {"linux/sockios.h", "SIOCSIFDSTADDR", 0x8918}, ++ {"linux/sockios.h", "SIOCGIFBRDADDR", 0x8919}, ++ {"linux/sockios.h", "SIOCSIFBRDADDR", 0x891a}, ++ {"linux/sockios.h", "SIOCGIFNETMASK", 0x891b}, ++ {"linux/sockios.h", "SIOCSIFNETMASK", 0x891c}, ++ {"linux/sockios.h", "SIOCGIFMETRIC", 0x891d}, ++ {"linux/sockios.h", "SIOCSIFMETRIC", 0x891e}, ++ {"linux/sockios.h", "SIOCGIFMEM", 0x891f}, ++ {"linux/sockios.h", "SIOCSIFMEM", 0x8920}, ++ {"linux/sockios.h", "SIOCGIFMTU", 0x8921}, ++ {"linux/sockios.h", "SIOCSIFMTU", 0x8922}, ++ {"linux/sockios.h", "SIOCSIFNAME", 0x8923}, ++ {"linux/sockios.h", "SIOCSIFHWADDR", 0x8924}, ++ {"linux/sockios.h", "SIOCGIFENCAP", 0x8925}, ++ {"linux/sockios.h", "SIOCSIFENCAP", 0x8926}, ++ {"linux/sockios.h", "SIOCGIFHWADDR", 0x8927}, ++ {"linux/sockios.h", "SIOCGIFSLAVE", 0x8929}, ++ {"linux/sockios.h", "SIOCSIFSLAVE", 0x8930}, ++ {"linux/sockios.h", "SIOCADDMULTI", 0x8931}, ++ {"linux/sockios.h", "SIOCDELMULTI", 0x8932}, ++ {"linux/sockios.h", "SIOCGIFINDEX", 0x8933}, ++ {"linux/sockios.h", "SIOCSIFPFLAGS", 0x8934}, ++ {"linux/sockios.h", "SIOCGIFPFLAGS", 0x8935}, ++ {"linux/sockios.h", "SIOCDIFADDR", 0x8936}, ++ {"linux/sockios.h", "SIOCSIFHWBROADCAST", 0x8937}, ++ {"linux/sockios.h", "SIOCGIFCOUNT", 0x8938}, ++ {"linux/sockios.h", "SIOCGIFBR", 0x8940}, ++ {"linux/sockios.h", "SIOCSIFBR", 0x8941}, ++ {"linux/sockios.h", "SIOCGIFTXQLEN", 0x8942}, ++ {"linux/sockios.h", "SIOCSIFTXQLEN", 0x8943}, ++ {"linux/sockios.h", "SIOCGIFDIVERT", 0x8944}, ++ {"linux/sockios.h", "SIOCSIFDIVERT", 0x8945}, ++ {"linux/sockios.h", "SIOCETHTOOL", 0x8946}, ++ {"linux/sockios.h", "SIOCGMIIPHY", 0x8947}, ++ {"linux/sockios.h", "SIOCGMIIREG", 0x8948}, ++ {"linux/sockios.h", "SIOCSMIIREG", 0x8949}, ++ {"linux/sockios.h", "SIOCWANDEV", 0x894a}, ++ {"linux/sockios.h", "SIOCDARP", 0x8953}, ++ {"linux/sockios.h", "SIOCGARP", 0x8954}, ++ {"linux/sockios.h", "SIOCSARP", 0x8955}, ++ {"linux/sockios.h", "SIOCDRARP", 0x8960}, ++ {"linux/sockios.h", "SIOCGRARP", 0x8961}, ++ {"linux/sockios.h", "SIOCSRARP", 0x8962}, ++ {"linux/sockios.h", "SIOCGIFMAP", 0x8970}, ++ {"linux/sockios.h", "SIOCSIFMAP", 0x8971}, ++ {"linux/sockios.h", "SIOCADDDLCI", 0x8980}, ++ {"linux/sockios.h", "SIOCDELDLCI", 0x8981}, ++ {"linux/sockios.h", "SIOCGIFVLAN", 0x8982}, ++ {"linux/sockios.h", "SIOCSIFVLAN", 0x8983}, ++ {"linux/sockios.h", "SIOCBONDENSLAVE", 0x8990}, ++ {"linux/sockios.h", "SIOCBONDRELEASE", 0x8991}, ++ {"linux/sockios.h", "SIOCBONDSETHWADDR", 0x8992}, ++ {"linux/sockios.h", "SIOCBONDSLAVEINFOQUERY", 0x8993}, ++ {"linux/sockios.h", "SIOCBONDINFOQUERY", 0x8994}, ++ {"linux/sockios.h", "SIOCBONDCHANGEACTIVE", 0x8995}, ++ {"linux/sockios.h", "SIOCBRADDBR", 0x89a0}, ++ {"linux/sockios.h", "SIOCBRDELBR", 0x89a1}, ++ {"linux/sockios.h", "SIOCBRADDIF", 0x89a2}, ++ {"linux/sockios.h", "SIOCBRDELIF", 0x89a3}, ++ {"linux/dn.h", "OSIOCSNETADDR", 0x89e0}, ++ {"linux/sockios.h", "SIOCPROTOPRIVATE", 0x89e0}, ++ {"linux/dn.h", "SIOCSNETADDR", 0x89e0}, ++ {"linux/dn.h", "OSIOCGNETADDR", 0x89e1}, ++ {"linux/dn.h", "SIOCGNETADDR", 0x89e1}, ++ {"linux/sockios.h", "SIOCDEVPRIVATE", 0x89f0}, ++ {"linux/wireless.h", "SIOCIWFIRST", 0x8b00}, ++ {"linux/wireless.h", "SIOCSIWCOMMIT", 0x8b00}, ++ {"linux/wireless.h", "SIOCGIWNAME", 0x8b01}, ++ {"linux/wireless.h", "SIOCSIWNWID", 0x8b02}, ++ {"linux/wireless.h", "SIOCGIWNWID", 0x8b03}, ++ {"linux/wireless.h", "SIOCSIWFREQ", 0x8b04}, ++ {"linux/wireless.h", "SIOCGIWFREQ", 0x8b05}, ++ {"linux/wireless.h", "SIOCSIWMODE", 0x8b06}, ++ {"linux/wireless.h", "SIOCGIWMODE", 0x8b07}, ++ {"linux/wireless.h", "SIOCSIWSENS", 0x8b08}, ++ {"linux/wireless.h", "SIOCGIWSENS", 0x8b09}, ++ {"linux/wireless.h", "SIOCSIWRANGE", 0x8b0a}, ++ {"linux/wireless.h", "SIOCGIWRANGE", 0x8b0b}, ++ {"linux/wireless.h", "SIOCSIWPRIV", 0x8b0c}, ++ {"linux/wireless.h", "SIOCGIWPRIV", 0x8b0d}, ++ {"linux/wireless.h", "SIOCSIWSTATS", 0x8b0e}, ++ {"linux/wireless.h", "SIOCGIWSTATS", 0x8b0f}, ++ {"linux/wireless.h", "SIOCSIWSPY", 0x8b10}, ++ {"linux/wireless.h", "SIOCGIWSPY", 0x8b11}, ++ {"linux/wireless.h", "SIOCSIWTHRSPY", 0x8b12}, ++ {"linux/wireless.h", "SIOCGIWTHRSPY", 0x8b13}, ++ {"linux/wireless.h", "SIOCSIWAP", 0x8b14}, ++ {"linux/wireless.h", "SIOCGIWAP", 0x8b15}, ++ {"linux/wireless.h", "SIOCSIWMLME", 0x8b16}, ++ {"linux/wireless.h", "SIOCGIWAPLIST", 0x8b17}, ++ {"linux/wireless.h", "SIOCSIWSCAN", 0x8b18}, ++ {"linux/wireless.h", "SIOCGIWSCAN", 0x8b19}, ++ {"linux/wireless.h", "SIOCSIWESSID", 0x8b1a}, ++ {"linux/wireless.h", "SIOCGIWESSID", 0x8b1b}, ++ {"linux/wireless.h", "SIOCSIWNICKN", 0x8b1c}, ++ {"linux/wireless.h", "SIOCGIWNICKN", 0x8b1d}, ++ {"linux/wireless.h", "SIOCSIWRATE", 0x8b20}, ++ {"linux/wireless.h", "SIOCGIWRATE", 0x8b21}, ++ {"linux/wireless.h", "SIOCSIWRTS", 0x8b22}, ++ {"linux/wireless.h", "SIOCGIWRTS", 0x8b23}, ++ {"linux/wireless.h", "SIOCSIWFRAG", 0x8b24}, ++ {"linux/wireless.h", "SIOCGIWFRAG", 0x8b25}, ++ {"linux/wireless.h", "SIOCSIWTXPOW", 0x8b26}, ++ {"linux/wireless.h", "SIOCGIWTXPOW", 0x8b27}, ++ {"linux/wireless.h", "SIOCSIWRETRY", 0x8b28}, ++ {"linux/wireless.h", "SIOCGIWRETRY", 0x8b29}, ++ {"linux/wireless.h", "SIOCSIWENCODE", 0x8b2a}, ++ {"linux/wireless.h", "SIOCGIWENCODE", 0x8b2b}, ++ {"linux/wireless.h", "SIOCSIWPOWER", 0x8b2c}, ++ {"linux/wireless.h", "SIOCGIWPOWER", 0x8b2d}, ++ {"linux/wireless.h", "SIOCSIWGENIE", 0x8b30}, ++ {"linux/wireless.h", "SIOCGIWGENIE", 0x8b31}, ++ {"linux/wireless.h", "SIOCSIWAUTH", 0x8b32}, ++ {"linux/wireless.h", "SIOCGIWAUTH", 0x8b33}, ++ {"linux/wireless.h", "SIOCSIWENCODEEXT", 0x8b34}, ++ {"linux/wireless.h", "SIOCGIWENCODEEXT", 0x8b35}, ++ {"linux/wireless.h", "SIOCSIWPMKSA", 0x8b36}, ++ {"linux/wireless.h", "SIOCIWFIRSTPRIV", 0x8be0}, ++ {"linux/wireless.h", "SIOCIWLASTPRIV", 0x8bff}, ++ {"linux/auto_fs.h", "AUTOFS_IOC_READY", 0x9360}, ++ {"linux/auto_fs.h", "AUTOFS_IOC_FAIL", 0x9361}, ++ {"linux/auto_fs.h", "AUTOFS_IOC_CATATONIC", 0x9362}, ++ {"linux/auto_fs.h", "AUTOFS_IOC_PROTOVER", 0x9363}, ++ {"linux/auto_fs.h", "AUTOFS_IOC_SETTIMEOUT", 0x9364}, ++ {"linux/auto_fs.h", "AUTOFS_IOC_EXPIRE", 0x9365}, ++ {"linux/auto_fs4.h", "AUTOFS_IOC_EXPIRE_MULTI", 0x9366}, ++ {"linux/auto_fs4.h", "AUTOFS_IOC_PROTOSUBVER", 0x9367}, ++ {"linux/auto_fs4.h", "AUTOFS_IOC_ASKREGHOST", 0x9368}, ++ {"linux/auto_fs4.h", "AUTOFS_IOC_TOGGLEREGHOST", 0x9369}, ++ {"linux/auto_fs4.h", "AUTOFS_IOC_ASKUMOUNT", 0x9370}, ++ {"linux/nbd.h", "NBD_SET_SOCK", 0xab00}, ++ {"linux/nbd.h", "NBD_SET_BLKSIZE", 0xab01}, ++ {"linux/nbd.h", "NBD_SET_SIZE", 0xab02}, ++ {"linux/nbd.h", "NBD_DO_IT", 0xab03}, ++ {"linux/nbd.h", "NBD_CLEAR_SOCK", 0xab04}, ++ {"linux/nbd.h", "NBD_CLEAR_QUE", 0xab05}, ++ {"linux/nbd.h", "NBD_PRINT_DEBUG", 0xab06}, ++ {"linux/nbd.h", "NBD_SET_SIZE_BLOCKS", 0xab07}, ++ {"linux/nbd.h", "NBD_DISCONNECT", 0xab08}, ++ {"linux/nbd.h", "NBD_SET_TIMEOUT", 0xab09}, ++ {"linux/raw.h", "RAW_SETBIND", 0xac00}, ++ {"linux/raw.h", "RAW_GETBIND", 0xac01}, ++ {"linux/kvm.h", "KVM_GET_API_VERSION", 0xae00}, ++ {"linux/kvm.h", "KVM_CREATE_VM", 0xae01}, ++ {"linux/kvm.h", "KVM_GET_MSR_INDEX_LIST", 0xae02}, ++ {"linux/kvm.h", "KVM_CHECK_EXTENSION", 0xae03}, ++ {"linux/kvm.h", "KVM_GET_VCPU_MMAP_SIZE", 0xae04}, ++ {"linux/kvm.h", "KVM_GET_SUPPORTED_CPUID", 0xae05}, ++ {"linux/kvm.h", "KVM_S390_ENABLE_SIE", 0xae06}, ++ {"linux/kvm.h", "KVM_TRACE_ENABLE", 0xae06}, ++ {"linux/kvm.h", "KVM_TRACE_PAUSE", 0xae07}, ++ {"linux/kvm.h", "KVM_TRACE_DISABLE", 0xae08}, ++ {"linux/kvm.h", "KVM_SET_MEMORY_REGION", 0xae40}, ++ {"linux/kvm.h", "KVM_CREATE_VCPU", 0xae41}, ++ {"linux/kvm.h", "KVM_GET_DIRTY_LOG", 0xae42}, ++ {"linux/kvm.h", "KVM_SET_MEMORY_ALIAS", 0xae43}, ++ {"linux/kvm.h", "KVM_SET_NR_MMU_PAGES", 0xae44}, ++ {"linux/kvm.h", "KVM_GET_NR_MMU_PAGES", 0xae45}, ++ {"linux/kvm.h", "KVM_SET_USER_MEMORY_REGION", 0xae46}, ++ {"linux/kvm.h", "KVM_SET_TSS_ADDR", 0xae47}, ++ {"linux/kvm.h", "KVM_CREATE_IRQCHIP", 0xae60}, ++ {"linux/kvm.h", "KVM_IRQ_LINE", 0xae61}, ++ {"linux/kvm.h", "KVM_GET_IRQCHIP", 0xae62}, ++ {"linux/kvm.h", "KVM_SET_IRQCHIP", 0xae63}, ++ {"linux/kvm.h", "KVM_CREATE_PIT", 0xae64}, ++ {"linux/kvm.h", "KVM_GET_PIT", 0xae65}, ++ {"linux/kvm.h", "KVM_SET_PIT", 0xae66}, ++ {"linux/kvm.h", "KVM_RUN", 0xae80}, ++ {"linux/kvm.h", "KVM_GET_REGS", 0xae81}, ++ {"linux/kvm.h", "KVM_SET_REGS", 0xae82}, ++ {"linux/kvm.h", "KVM_GET_SREGS", 0xae83}, ++ {"linux/kvm.h", "KVM_SET_SREGS", 0xae84}, ++ {"linux/kvm.h", "KVM_TRANSLATE", 0xae85}, ++ {"linux/kvm.h", "KVM_INTERRUPT", 0xae86}, ++ {"linux/kvm.h", "KVM_DEBUG_GUEST", 0xae87}, ++ {"linux/kvm.h", "KVM_GET_MSRS", 0xae88}, ++ {"linux/kvm.h", "KVM_SET_MSRS", 0xae89}, ++ {"linux/kvm.h", "KVM_SET_CPUID", 0xae8a}, ++ {"linux/kvm.h", "KVM_SET_SIGNAL_MASK", 0xae8b}, ++ {"linux/kvm.h", "KVM_GET_FPU", 0xae8c}, ++ {"linux/kvm.h", "KVM_SET_FPU", 0xae8d}, ++ {"linux/kvm.h", "KVM_GET_LAPIC", 0xae8e}, ++ {"linux/kvm.h", "KVM_SET_LAPIC", 0xae8f}, ++ {"linux/kvm.h", "KVM_SET_CPUID2", 0xae90}, ++ {"linux/kvm.h", "KVM_GET_CPUID2", 0xae91}, ++ {"linux/kvm.h", "KVM_TPR_ACCESS_REPORTING", 0xae92}, ++ {"linux/kvm.h", "KVM_SET_VAPIC_ADDR", 0xae93}, ++ {"linux/kvm.h", "KVM_S390_INTERRUPT", 0xae94}, ++ {"linux/kvm.h", "KVM_S390_STORE_STATUS", 0xae95}, ++ {"linux/kvm.h", "KVM_S390_SET_INITIAL_PSW", 0xae96}, ++ {"linux/kvm.h", "KVM_S390_INITIAL_RESET", 0xae97}, ++ {"linux/kvm.h", "KVM_GET_MP_STATE", 0xae98}, ++ {"linux/kvm.h", "KVM_SET_MP_STATE", 0xae99}, ++ {"linux/if_pppox.h", "PPPOEIOCSFWD", 0xb100}, ++ {"linux/if_pppox.h", "PPPOEIOCDFWD", 0xb101}, ++ {"linux/usb/iowarrior.h", "IOW_WRITE", 0xc001}, ++ {"linux/usb/iowarrior.h", "IOW_READ", 0xc002}, ++ {"linux/usb/iowarrior.h", "IOW_GETINFO", 0xc003}, ++ {"linux/reiserfs_fs.h", "REISERFS_IOC32_UNPACK", 0xcd01}, ++ {"linux/reiserfs_fs.h", "REISERFS_IOC_UNPACK", 0xcd01}, ++ {"video/sisfb.h", "SISFB_GET_INFO_SIZE", 0xf300}, ++ {"video/sisfb.h", "SISFB_GET_INFO", 0xf301}, ++ {"video/sisfb.h", "SISFB_GET_VBRSTATUS", 0xf302}, ++ {"video/sisfb.h", "SISFB_GET_AUTOMAXIMIZE", 0xf303}, ++ {"video/sisfb.h", "SISFB_SET_AUTOMAXIMIZE", 0xf303}, ++ {"video/sisfb.h", "SISFB_GET_TVPOSOFFSET", 0xf304}, ++ {"video/sisfb.h", "SISFB_SET_TVPOSOFFSET", 0xf304}, ++ {"video/sisfb.h", "SISFB_COMMAND", 0xf305}, ++ {"video/sisfb.h", "SISFB_SET_LOCK", 0xf306}, ++ {"video/mbxfb.h", "MBXFB_IOCX_OVERLAY", 0xf400}, ++ {"video/mbxfb.h", "MBXFB_IOCG_ALPHA", 0xf401}, ++ {"video/mbxfb.h", "MBXFB_IOCS_ALPHA", 0xf402}, ++ {"video/mbxfb.h", "MBXFB_IOCS_PLANEORDER", 0xf403}, ++ {"video/mbxfb.h", "MBXFB_IOCS_REG", 0xf404}, ++ {"video/mbxfb.h", "MBXFB_IOCX_REG", 0xf405}, ++ {"linux/dm-ioctl.h", "DM_VERSION", 0xfd00}, ++ {"linux/dm-ioctl.h", "DM_VERSION_32", 0xfd00}, ++ {"linux/dm-ioctl.h", "DM_REMOVE_ALL", 0xfd01}, ++ {"linux/dm-ioctl.h", "DM_REMOVE_ALL_32", 0xfd01}, ++ {"linux/dm-ioctl.h", "DM_LIST_DEVICES", 0xfd02}, ++ {"linux/dm-ioctl.h", "DM_LIST_DEVICES_32", 0xfd02}, ++ {"linux/dm-ioctl.h", "DM_DEV_CREATE", 0xfd03}, ++ {"linux/dm-ioctl.h", "DM_DEV_CREATE_32", 0xfd03}, ++ {"linux/dm-ioctl.h", "DM_DEV_REMOVE", 0xfd04}, ++ {"linux/dm-ioctl.h", "DM_DEV_REMOVE_32", 0xfd04}, ++ {"linux/dm-ioctl.h", "DM_DEV_RENAME", 0xfd05}, ++ {"linux/dm-ioctl.h", "DM_DEV_RENAME_32", 0xfd05}, ++ {"linux/dm-ioctl.h", "DM_DEV_SUSPEND", 0xfd06}, ++ {"linux/dm-ioctl.h", "DM_DEV_SUSPEND_32", 0xfd06}, ++ {"linux/dm-ioctl.h", "DM_DEV_STATUS", 0xfd07}, ++ {"linux/dm-ioctl.h", "DM_DEV_STATUS_32", 0xfd07}, ++ {"linux/dm-ioctl.h", "DM_DEV_WAIT", 0xfd08}, ++ {"linux/dm-ioctl.h", "DM_DEV_WAIT_32", 0xfd08}, ++ {"linux/dm-ioctl.h", "DM_TABLE_LOAD", 0xfd09}, ++ {"linux/dm-ioctl.h", "DM_TABLE_LOAD_32", 0xfd09}, ++ {"linux/dm-ioctl.h", "DM_TABLE_CLEAR", 0xfd0a}, ++ {"linux/dm-ioctl.h", "DM_TABLE_CLEAR_32", 0xfd0a}, ++ {"linux/dm-ioctl.h", "DM_TABLE_DEPS", 0xfd0b}, ++ {"linux/dm-ioctl.h", "DM_TABLE_DEPS_32", 0xfd0b}, ++ {"linux/dm-ioctl.h", "DM_TABLE_STATUS", 0xfd0c}, ++ {"linux/dm-ioctl.h", "DM_TABLE_STATUS_32", 0xfd0c}, ++ {"linux/dm-ioctl.h", "DM_LIST_VERSIONS", 0xfd0d}, ++ {"linux/dm-ioctl.h", "DM_LIST_VERSIONS_32", 0xfd0d}, ++ {"linux/dm-ioctl.h", "DM_TARGET_MSG", 0xfd0e}, ++ {"linux/dm-ioctl.h", "DM_TARGET_MSG_32", 0xfd0e}, ++ {"linux/dm-ioctl.h", "DM_DEV_SET_GEOMETRY", 0xfd0f}, ++ {"linux/dm-ioctl.h", "DM_DEV_SET_GEOMETRY_32", 0xfd0f}, +diff --git a/linux/bfin/syscallent.h b/linux/bfin/syscallent.h +new file mode 100644 +index 0000000..ba84b2c +--- /dev/null ++++ b/linux/bfin/syscallent.h +@@ -0,0 +1,391 @@ ++/* ++ * Copyright (c) 1993 Branko Lankester ++ * Copyright (c) 1993, 1994, 1995 Rick Sladkey ++ * 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. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * 3. The name of the author may not be used to endorse or promote products ++ * derived from this software without specific prior written permission. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. ++ * ++ * $Id: syscallent.h 6985 2008-08-09 01:13:40Z vapier $ ++ */ ++ ++ { 0, 0, sys_restart_syscall, "restart_syscall" }, /* 0 */ ++ { 1, TP, sys_exit, "_exit", SYS_exit }, /* 1 */ ++ { 0, TP, sys_fork, "fork", SYS_fork }, /* 2 */ ++ { 3, TD, sys_read, "read", SYS_read }, /* 3 */ ++ { 3, TD, sys_write, "write", SYS_write }, /* 4 */ ++ { 3, TD|TF, sys_open, "open" }, /* 5 */ ++ { 1, TD, sys_close, "close" }, /* 6 */ ++ { 3, TP, sys_waitpid, "waitpid", SYS_wait4 }, /* 7 */ ++ { 2, TD|TF, sys_creat, "creat" }, /* 8 */ ++ { 2, TF, sys_link, "link" }, /* 9 */ ++ { 1, TF, sys_unlink, "unlink" }, /* 10 */ ++ { 3, TF|TP, sys_execve, "execve", SYS_execve }, /* 11 */ ++ { 1, TF, sys_chdir, "chdir" }, /* 12 */ ++ { 1, 0, sys_time, "time" }, /* 13 */ ++ { 3, TF, sys_mknod, "mknod" }, /* 14 */ ++ { 2, TF, sys_chmod, "chmod" }, /* 15 */ ++ { 3, TF, sys_chown, "chown" }, /* 16 */ ++ { 0, 0, sys_break, "break" }, /* 17 */ ++ { 2, TF, sys_oldstat, "oldstat" }, /* 18 */ ++ { 3, TD, sys_lseek, "lseek" }, /* 19 */ ++ { 0, 0, sys_getpid, "getpid" }, /* 20 */ ++ { 5, TF, sys_mount, "mount" }, /* 21 */ ++ { 1, TF, sys_umount, "oldumount" }, /* 22 */ ++ { 1, 0, sys_setuid, "setuid" }, /* 23 */ ++ { 0, 0, sys_getuid, "getuid" }, /* 24 */ ++ { 1, 0, sys_stime, "stime" }, /* 25 */ ++ { 4, 0, sys_ptrace, "ptrace" }, /* 26 */ ++ { 1, 0, sys_alarm, "alarm" }, /* 27 */ ++ { 2, TD, sys_oldfstat, "oldfstat" }, /* 28 */ ++ { 0, TS, sys_pause, "pause" }, /* 29 */ ++ { 2, TF, sys_utime, "utime" }, /* 30 */ ++ { 2, 0, sys_stty, "stty" }, /* 31 */ ++ { 2, 0, sys_gtty, "gtty" }, /* 32 */ ++ { 2, TF, sys_access, "access" }, /* 33 */ ++ { 1, 0, sys_nice, "nice" }, /* 34 */ ++ { 0, 0, sys_ftime, "ftime" }, /* 35 */ ++ { 0, 0, sys_sync, "sync" }, /* 36 */ ++ { 2, TS, sys_kill, "kill" }, /* 37 */ ++ { 2, TF, sys_rename, "rename" }, /* 38 */ ++ { 2, TF, sys_mkdir, "mkdir" }, /* 39 */ ++ { 1, TF, sys_rmdir, "rmdir" }, /* 40 */ ++ { 1, TD, sys_dup, "dup" }, /* 41 */ ++ { 1, TD, sys_pipe, "pipe" }, /* 42 */ ++ { 1, 0, sys_times, "times" }, /* 43 */ ++ { 0, 0, sys_prof, "prof" }, /* 44 */ ++ { 1, 0, sys_brk, "brk" }, /* 45 */ ++ { 1, 0, sys_setgid, "setgid" }, /* 46 */ ++ { 0, 0, sys_getgid, "getgid" }, /* 47 */ ++ { 3, TS, sys_signal, "signal" }, /* 48 */ ++ { 0, 0, sys_geteuid, "geteuid" }, /* 49 */ ++ { 0, 0, sys_getegid, "getegid" }, /* 50 */ ++ { 1, TF, sys_acct, "acct" }, /* 51 */ ++ { 2, TF, sys_umount2, "umount" }, /* 52 */ ++ { 0, 0, sys_lock, "lock" }, /* 53 */ ++ { 3, TD, sys_ioctl, "ioctl" }, /* 54 */ ++ { 3, TD, sys_fcntl, "fcntl" }, /* 55 */ ++ { 0, 0, sys_mpx, "mpx" }, /* 56 */ ++ { 2, 0, sys_setpgid, "setpgid" }, /* 57 */ ++ { 2, 0, sys_ulimit, "ulimit" }, /* 58 */ ++ { 1, 0, sys_oldolduname, "oldolduname" }, /* 59 */ ++ { 1, 0, sys_umask, "umask" }, /* 60 */ ++ { 1, TF, sys_chroot, "chroot" }, /* 61 */ ++ { 2, 0, sys_ustat, "ustat" }, /* 62 */ ++ { 2, TD, sys_dup2, "dup2" }, /* 63 */ ++ { 0, 0, sys_getppid, "getppid" }, /* 64 */ ++ { 0, 0, sys_getpgrp, "getpgrp" }, /* 65 */ ++ { 0, 0, sys_setsid, "setsid" }, /* 66 */ ++ { 3, TS, sys_sigaction, "sigaction" }, /* 67 */ ++ { 0, TS, sys_siggetmask, "siggetmask" }, /* 68 */ ++ { 1, TS, sys_sigsetmask, "sigsetmask" }, /* 69 */ ++ { 2, 0, sys_setreuid, "setreuid" }, /* 70 */ ++ { 2, 0, sys_setregid, "setregid" }, /* 71 */ ++ { 3, TS, sys_sigsuspend, "sigsuspend" }, /* 72 */ ++ { 1, TS, sys_sigpending, "sigpending" }, /* 73 */ ++ { 2, 0, sys_sethostname, "sethostname" }, /* 74 */ ++ { 2, 0, sys_setrlimit, "setrlimit" }, /* 75 */ ++ { 2, 0, sys_getrlimit, "old_getrlimit" }, /* 76 */ ++ { 2, 0, sys_getrusage, "getrusage" }, /* 77 */ ++ { 2, 0, sys_gettimeofday, "gettimeofday" }, /* 78 */ ++ { 2, 0, sys_settimeofday, "settimeofday" }, /* 79 */ ++ { 2, 0, sys_getgroups, "getgroups" }, /* 80 */ ++ { 2, 0, sys_setgroups, "setgroups" }, /* 81 */ ++ { 1, TD, sys_oldselect, "oldselect" }, /* 82 */ ++ { 2, TF, sys_symlink, "symlink" }, /* 83 */ ++ { 2, TF, sys_oldlstat, "oldlstat" }, /* 84 */ ++ { 3, TF, sys_readlink, "readlink" }, /* 85 */ ++ { 1, TF, sys_uselib, "uselib" }, /* 86 */ ++ { 1, TF, sys_swapon, "swapon" }, /* 87 */ ++ { 3, 0, sys_reboot, "reboot" }, /* 88 */ ++ { 3, TD, sys_readdir, "readdir" }, /* 89 */ ++ { 6, TD, sys_old_mmap, "old_mmap" }, /* 90 */ ++ { 2, 0, sys_munmap, "munmap" }, /* 91 */ ++ { 2, TF, sys_truncate, "truncate" }, /* 92 */ ++ { 2, TD, sys_ftruncate, "ftruncate" }, /* 93 */ ++ { 2, TD, sys_fchmod, "fchmod" }, /* 94 */ ++ { 3, TD, sys_fchown, "fchown" }, /* 95 */ ++ { 2, 0, sys_getpriority, "getpriority" }, /* 96 */ ++ { 3, 0, sys_setpriority, "setpriority" }, /* 97 */ ++ { 4, 0, sys_profil, "profil" }, /* 98 */ ++ { 2, TF, sys_statfs, "statfs" }, /* 99 */ ++ { 2, TD, sys_fstatfs, "fstatfs" }, /* 100 */ ++ { 3, 0, sys_ioperm, "ioperm" }, /* 101 */ ++ { 2, TD, sys_socketcall, "socketcall", SYS_socketcall }, /* 102 */ ++ { 3, 0, sys_syslog, "syslog" }, /* 103 */ ++ { 3, 0, sys_setitimer, "setitimer" }, /* 104 */ ++ { 2, 0, sys_getitimer, "getitimer" }, /* 105 */ ++ { 2, TF, sys_stat, "stat" }, /* 106 */ ++ { 2, TF, sys_lstat, "lstat" }, /* 107 */ ++ { 2, TD, sys_fstat, "fstat" }, /* 108 */ ++ { 1, 0, sys_olduname, "olduname" }, /* 109 */ ++ { 1, 0, sys_iopl, "iopl" }, /* 110 */ ++ { 0, 0, sys_vhangup, "vhangup" }, /* 111 */ ++ { 0, 0, sys_idle, "idle" }, /* 112 */ ++ { 1, 0, sys_vm86old, "vm86old" }, /* 113 */ ++ { 4, TP, sys_wait4, "wait4", SYS_wait4 }, /* 114 */ ++ { 1, 0, sys_swapoff, "swapoff" }, /* 115 */ ++ { 1, 0, sys_sysinfo, "sysinfo" }, /* 116 */ ++ { 6, 0, sys_ipc, "ipc", SYS_ipc }, /* 117 */ ++ { 1, TD, sys_fsync, "fsync" }, /* 118 */ ++ { 1, TS, sys_sigreturn, "sigreturn" }, /* 119 */ ++ { 5, TP, sys_clone, "clone", SYS_clone }, /* 120 */ ++ { 2, 0, sys_setdomainname, "setdomainname" }, /* 121 */ ++ { 1, 0, sys_uname, "uname" }, /* 122 */ ++ { 3, 0, sys_modify_ldt, "modify_ldt" }, /* 123 */ ++ { 1, 0, sys_adjtimex, "adjtimex" }, /* 124 */ ++ { 3, 0, sys_mprotect, "mprotect" }, /* 125 */ ++ { 3, TS, sys_sigprocmask, "sigprocmask" }, /* 126 */ ++ { 2, 0, sys_create_module, "create_module" }, /* 127 */ ++ { 3, 0, sys_init_module, "init_module" }, /* 128 */ ++ { 1, 0, sys_delete_module, "delete_module" }, /* 129 */ ++ { 1, 0, sys_get_kernel_syms, "get_kernel_syms" }, /* 130 */ ++ { 4, 0, sys_quotactl, "quotactl" }, /* 131 */ ++ { 1, 0, sys_getpgid, "getpgid" }, /* 132 */ ++ { 1, TD, sys_fchdir, "fchdir" }, /* 133 */ ++ { 0, 0, sys_bdflush, "bdflush" }, /* 134 */ ++ { 3, 0, printargs, "sysfs" }, /* 135 */ ++ { 1, 0, sys_personality, "personality" }, /* 136 */ ++ { 5, 0, sys_afs_syscall, "afs_syscall" }, /* 137 */ ++ { 1, 0, sys_setfsuid, "setfsuid" }, /* 138 */ ++ { 1, 0, sys_setfsgid, "setfsgid" }, /* 139 */ ++ { 5, TD, sys_llseek, "_llseek" }, /* 140 */ ++ { 3, TD, sys_getdents, "getdents" }, /* 141 */ ++ { 5, TD, sys_select, "select" }, /* 142 */ ++ { 2, TD, sys_flock, "flock" }, /* 143 */ ++ { 3, 0, sys_msync, "msync" }, /* 144 */ ++ { 3, TD, sys_readv, "readv", SYS_readv }, /* 145 */ ++ { 3, TD, sys_writev, "writev", SYS_writev }, /* 146 */ ++ { 1, 0, sys_getsid, "getsid" }, /* 147 */ ++ { 1, TD, sys_fdatasync, "fdatasync" }, /* 148 */ ++ { 1, 0, sys_sysctl, "_sysctl" }, /* 149 */ ++ { 2, 0, sys_mlock, "mlock" }, /* 150 */ ++ { 2, 0, sys_munlock, "munlock" }, /* 151 */ ++ { 2, 0, sys_mlockall, "mlockall" }, /* 152 */ ++ { 0, 0, sys_munlockall, "munlockall" }, /* 153 */ ++ { 0, 0, sys_sched_setparam, "sched_setparam" }, /* 154 */ ++ { 2, 0, sys_sched_getparam, "sched_getparam" }, /* 155 */ ++ { 3, 0, sys_sched_setscheduler, "sched_setscheduler" }, /* 156 */ ++ { 1, 0, sys_sched_getscheduler, "sched_getscheduler" }, /* 157 */ ++ { 0, 0, sys_sched_yield, "sched_yield" }, /* 158 */ ++ { 1, 0, sys_sched_get_priority_max, "sched_get_priority_max" }, /* 159 */ ++ { 1, 0, sys_sched_get_priority_min, "sched_get_priority_min" }, /* 160 */ ++ { 2, 0, sys_sched_rr_get_interval, "sched_rr_get_interval" }, /* 161 */ ++ { 2, 0, sys_nanosleep, "nanosleep" }, /* 162 */ ++ { 4, 0, sys_mremap, "mremap" }, /* 163 */ ++ { 3, 0, sys_setresuid, "setresuid" }, /* 164 */ ++ { 3, 0, sys_getresuid, "getresuid" }, /* 165 */ ++ { 5, 0, printargs, "vm86" }, /* 166 */ ++ { 5, 0, sys_query_module, "query_module" }, /* 167 */ ++ { 3, TD, sys_poll, "poll" }, /* 168 */ ++ { 3, 0, printargs, "nfsservctl" }, /* 169 */ ++ { 3, 0, sys_setresgid, "setresgid" }, /* 170 */ ++ { 3, 0, sys_getresgid, "getresgid" }, /* 171 */ ++ { 5, 0, printargs, "prctl" }, /* 172 */ ++ { 1, TS, printargs, "rt_sigreturn" }, /* 173 */ ++ { 4, TS, sys_rt_sigaction, "rt_sigaction" }, /* 174 */ ++ { 4, TS, sys_rt_sigprocmask, "rt_sigprocmask" }, /* 175 */ ++ { 2, TS, sys_rt_sigpending, "rt_sigpending" }, /* 176 */ ++ { 4, TS, sys_rt_sigtimedwait, "rt_sigtimedwait" }, /* 177 */ ++ { 3, TS, sys_rt_sigqueueinfo, "rt_sigqueueinfo" }, /* 178 */ ++ { 2, TS, sys_rt_sigsuspend, "rt_sigsuspend" }, /* 179 */ ++ { 5, TD, sys_pread, "pread", SYS_read }, /* 180 */ ++ { 5, TD, sys_pwrite, "pwrite", SYS_write }, /* 181 */ ++ { 3, TF, sys_chown, "lchown" }, /* 182 */ ++ { 2, TF, sys_getcwd, "getcwd" }, /* 183 */ ++ { 2, 0, sys_capget, "capget" }, /* 184 */ ++ { 2, 0, sys_capset, "capset" }, /* 185 */ ++ { 2, TS, sys_sigaltstack, "sigaltstack" }, /* 186 */ ++ { 4, TD, sys_sendfile, "sendfile" }, /* 187 */ ++ { 5, 0, sys_getpmsg, "getpmsg" }, /* 188 */ ++ { 5, 0, sys_putpmsg, "putpmsg" }, /* 189 */ ++ { 0, TP, sys_vfork, "vfork", SYS_vfork }, /* 190 */ ++ { 2, 0, sys_getrlimit, "getrlimit" }, /* 191 */ ++ { 6, 0, sys_mmap, "mmap2" }, /* 192 */ ++ { 3, TF, sys_truncate64, "truncate64" }, /* 193 */ ++ { 3, TD, sys_ftruncate64, "ftruncate64" }, /* 194 */ ++ { 2, TF, sys_stat64, "stat64" }, /* 195 */ ++ { 2, TF, sys_lstat64, "lstat64" }, /* 196 */ ++ { 2, TD, sys_fstat64, "fstat64" }, /* 197 */ ++ { 3, TF, sys_chown, "chown32" }, /* 198 */ ++ { 0, 0, sys_getuid, "getuid32" }, /* 199 */ ++ { 0, 0, sys_getgid, "getgid32" }, /* 200 */ ++ { 0, 0, sys_geteuid, "geteuid32" }, /* 201 */ ++ { 0, 0, sys_geteuid, "getegid32" }, /* 202 */ ++ { 2, 0, sys_setreuid, "setreuid32" }, /* 203 */ ++ { 2, 0, sys_setregid, "setregid32" }, /* 204 */ ++ { 2, 0, sys_getgroups32, "getgroups32" }, /* 205 */ ++ { 2, 0, sys_setgroups32, "setgroups32" }, /* 206 */ ++ { 3, TD, sys_fchown, "fchown32" }, /* 207 */ ++ { 3, 0, sys_setresuid, "setresuid32" }, /* 208 */ ++ { 3, 0, sys_getresuid, "getresuid32" }, /* 209 */ ++ { 3, 0, sys_setresgid, "setresgid32" }, /* 210 */ ++ { 3, 0, sys_getresgid, "getresgid32" }, /* 211 */ ++ { 3, TF, sys_chown, "lchown32" }, /* 212 */ ++ { 1, 0, sys_setuid, "setuid32" }, /* 213 */ ++ { 1, 0, sys_setgid, "setgid32" }, /* 214 */ ++ { 1, 0, sys_setfsuid, "setfsuid32" }, /* 215 */ ++ { 1, 0, sys_setfsgid, "setfsgid32" }, /* 216 */ ++ { 2, TF, sys_pivotroot, "pivot_root" }, /* 217 */ ++ { 3, 0, sys_mincore, "mincore" }, /* 218 */ ++ { 3, 0, sys_madvise, "madvise" }, /* 219 */ ++ { 3, TD, sys_getdents64, "getdents64" }, /* 220 */ ++ { 3, TD, sys_fcntl, "fcntl64" }, /* 221 */ ++ { 4, 0, printargs, "SYS_222" }, /* 222 */ ++ { 5, 0, printargs, "security" }, /* 223 */ ++ { 0, 0, printargs, "gettid" }, /* 224 */ ++ { 4, TD, sys_readahead, "readahead" }, /* 225 */ ++ { 5, TF, sys_setxattr, "setxattr" }, /* 226 */ ++ { 5, TF, sys_setxattr, "lsetxattr" }, /* 227 */ ++ { 5, TD, sys_fsetxattr, "fsetxattr" }, /* 228 */ ++ { 4, TF, sys_getxattr, "getxattr" }, /* 229 */ ++ { 4, TF, sys_getxattr, "lgetxattr" }, /* 230 */ ++ { 4, 0, sys_fgetxattr, "fgetxattr" }, /* 231 */ ++ { 3, TF, sys_listxattr, "listxattr" }, /* 232 */ ++ { 3, TF, sys_listxattr, "llistxattr" }, /* 233 */ ++ { 3, 0, sys_flistxattr, "flistxattr" }, /* 234 */ ++ { 2, TF, sys_removexattr, "removexattr" }, /* 235 */ ++ { 2, TF, sys_removexattr, "lremovexattr" }, /* 236 */ ++ { 2, TD, sys_fremovexattr, "fremovexattr" }, /* 237 */ ++ { 2, TS, sys_kill, "tkill" }, /* 238 */ ++ { 4, TD, sys_sendfile64, "sendfile64" }, /* 239 */ ++ { 5, 0, sys_futex, "futex" }, /* 240 */ ++ { 3, 0, sys_sched_setaffinity, "sched_setaffinity" },/* 241 */ ++ { 3, 0, sys_sched_getaffinity, "sched_getaffinity" },/* 242 */ ++ { 1, 0, sys_set_thread_area, "set_thread_area" }, /* 243 */ ++ { 1, 0, sys_get_thread_area, "get_thread_area" }, /* 244 */ ++ { 2, 0, sys_io_setup, "io_setup" }, /* 245 */ ++ { 1, 0, sys_io_destroy, "io_destroy" }, /* 246 */ ++ { 5, 0, sys_io_getevents, "io_getevents" }, /* 247 */ ++ { 3, 0, sys_io_submit, "io_submit" }, /* 248 */ ++ { 3, 0, sys_io_cancel, "io_cancel" }, /* 249 */ ++ { 5, 0, printargs, "alloc_hugepages" }, /* 250 */ ++ { 1, 0, printargs, "free_hugepages" }, /* 251 */ ++ { 1, TP, sys_exit, "exit_group", __NR_exit_group }, /* 252 */ ++ { 4, 0, printargs, "lookup_dcookie" }, /* 253 */ ++ { 1, 0, printargs, "bfin_spinlock" }, /* 254 */ ++ { 1, 0, sys_epoll_create, "epoll_create" }, /* 255 */ ++ { 4, TD, sys_epoll_ctl, "epoll_ctl" }, /* 256 */ ++ { 4, TD, sys_epoll_wait, "epoll_wait" }, /* 257 */ ++ { 5, 0, sys_remap_file_pages, "remap_file_pages" }, /* 258 */ ++ { 1, 0, printargs, "set_tid_address" }, /* 259 */ ++ { 3, 0, sys_timer_create, "timer_create" }, /* 260 */ ++ { 4, 0, sys_timer_settime, "timer_settime" }, /* 261 */ ++ { 2, 0, sys_timer_gettime, "timer_gettime" }, /* 262 */ ++ { 1, 0, sys_timer_getoverrun, "timer_getoverrun" }, /* 263 */ ++ { 1, 0, sys_timer_delete, "timer_delete" }, /* 264 */ ++ { 2, 0, sys_clock_settime, "clock_settime" }, /* 265 */ ++ { 2, 0, sys_clock_gettime, "clock_gettime" }, /* 266 */ ++ { 2, 0, sys_clock_getres, "clock_getres" }, /* 267 */ ++ { 4, 0, sys_clock_nanosleep, "clock_nanosleep" }, /* 268 */ ++ { 3, TF, sys_statfs64, "statfs64" }, /* 269 */ ++ { 3, TD, sys_fstatfs64, "fstatfs64" }, /* 270 */ ++ { 3, TS, sys_tgkill, "tgkill" }, /* 271 */ ++ { 2, TF, sys_utimes, "utimes" }, /* 272 */ ++ { 6, 0, sys_fadvise64_64, "fadvise64_64" }, /* 273 */ ++ { 5, 0, printargs, "vserver" }, /* 274 */ ++ { 6, 0, sys_mbind, "mbind" }, /* 275 */ ++ { 5, 0, sys_get_mempolicy, "get_mempolicy" }, /* 276 */ ++ { 3, 0, sys_set_mempolicy, "set_mempolicy" }, /* 277 */ ++ { 4, 0, sys_mq_open, "mq_open" }, /* 278 */ ++ { 1, 0, sys_mq_unlink, "mq_unlink" }, /* 279 */ ++ { 5, 0, sys_mq_timedsend, "mq_timedsend" }, /* 280 */ ++ { 5, 0, sys_mq_timedreceive, "mq_timedreceive" }, /* 281 */ ++ { 2, 0, sys_mq_notify, "mq_notify" }, /* 282 */ ++ { 3, 0, sys_mq_getsetattr, "mq_getsetattr" }, /* 283 */ ++ { 5, 0, printargs, "kexec_load" }, /* 284 */ ++ { 5, TP, sys_waitid, "waitid", SYS_waitid }, /* 285 */ ++ { 5, 0, printargs, "add_key" }, /* 286 */ ++ { 4, 0, printargs, "request_key" }, /* 287 */ ++ { 5, 0, printargs, "keyctl" }, /* 288 */ ++ { 3, 0, printargs, "ioprio_set" }, /* 289 */ ++ { 2, 0, printargs, "ioprio_get" }, /* 290 */ ++ { 0, TD, printargs, "inotify_init" }, /* 291 */ ++ { 3, TD, sys_inotify_add_watch, "inotify_add_watch" }, /* 292 */ ++ { 2, TD, sys_inotify_rm_watch, "inotify_rm_watch" }, /* 293 */ ++ { 4, 0, printargs, "migrate_pages" }, /* 294 */ ++ { 4, TD|TF, sys_openat, "openat" }, /* 295 */ ++ { 3, TD|TF, sys_mkdirat, "mkdirat" }, /* 296 */ ++ { 4, TD|TF, sys_mknodat, "mknodat" }, /* 297 */ ++ { 5, TD|TF, sys_fchownat, "fchownat" }, /* 298 */ ++ { 3, TD|TF, sys_futimesat, "futimesat" }, /* 299 */ ++ { 4, TD|TD, sys_newfstatat, "fstatat64" }, /* 300 */ ++ { 3, TD|TF, sys_unlinkat, "unlinkat" }, /* 301 */ ++ { 4, TD|TF, sys_renameat, "renameat" }, /* 302 */ ++ { 5, TD|TF, sys_linkat, "linkat" }, /* 303 */ ++ { 3, TD|TF, sys_symlinkat, "symlinkat" }, /* 304 */ ++ { 4, TD|TF, sys_readlinkat, "readlinkat" }, /* 305 */ ++ { 3, TD|TF, sys_fchmodat, "fchmodat" }, /* 306 */ ++ { 3, TD|TF, sys_faccessat, "faccessat" }, /* 307 */ ++ { 6, TD, sys_pselect6, "pselect6" }, /* 308 */ ++ { 5, TD, sys_ppoll, "ppoll" }, /* 309 */ ++ { 1, TP, sys_unshare, "unshare" }, /* 310 */ ++ { 2, 0, sys_sram_alloc, "sram_alloc" }, /* 311 */ ++ { 1, 0, printargs, "sram_free" }, /* 312 */ ++ { 3, 0, printargs, "dma_memcpy" }, /* 313 */ ++ { 3, TN, sys_accept, "accept" }, /* 314 */ ++ { 3, TN, sys_bind, "bind" }, /* 315 */ ++ { 3, TN, sys_connect, "connect" }, /* 316 */ ++ { 3, TN, sys_getpeername, "getpeername" }, /* 317 */ ++ { 3, TN, sys_getsockname, "getsockname" }, /* 318 */ ++ { 5, TN, sys_getsockopt, "getsockopt" }, /* 319 */ ++ { 2, TN, sys_listen, "listen" }, /* 320 */ ++ { 4, TN, sys_recv, "recv", SYS_sub_recv }, /* 321 */ ++ { 6, TN, sys_recvfrom, "recvfrom", SYS_sub_recvfrom }, /* 322 */ ++ { 5, TN, sys_recvmsg, "recvmsg" }, /* 323 */ ++ { 4, TN, sys_send, "send", SYS_sub_send }, /* 324 */ ++ { 5, TN, sys_sendmsg, "sendmsg" }, /* 325 */ ++ { 6, TN, sys_sendto, "sendto", SYS_sub_sendto }, /* 326 */ ++ { 5, TN, sys_setsockopt, "setsockopt" }, /* 327 */ ++ { 2, TN, sys_shutdown, "shutdown" }, /* 328 */ ++ { 3, TN, sys_socket, "socket" }, /* 329 */ ++ { 4, TN, sys_socketpair, "socketpair" }, /* 330 */ ++ { 4, TI, sys_semctl, "semctl" }, /* 331 */ ++ { 4, TI, sys_semget, "semget" }, /* 332 */ ++ { 4, TI, sys_semop, "semop" }, /* 333 */ ++ { 4, TI, sys_msgctl, "msgctl" }, /* 334 */ ++ { 4, TI, sys_msgget, "msgget" }, /* 335 */ ++ { 4, TI, sys_msgrcv, "msgrcv" }, /* 336 */ ++ { 4, TI, sys_msgsnd, "msgsnd" }, /* 337 */ ++ { 4, TI, sys_shmat, "shmat" }, /* 338 */ ++ { 4, TI, sys_shmctl, "shmctl" }, /* 339 */ ++ { 4, TI, sys_shmdt, "shmdt" }, /* 340 */ ++ { 4, TI, sys_shmget, "shmget" }, /* 341 */ ++ { 6, TD, printargs, "splice" }, /* 342 */ ++ { 4, TD, printargs, "sync_file_range" }, /* 343 */ ++ { 4, TD, printargs, "tee" }, /* 344 */ ++ { 4, TD, printargs, "vmsplice" }, /* 345 */ ++ { 5, TD, sys_epoll_pwait, "epoll_pwait" }, /* 346 */ ++ { 4, TD|TF, sys_utimensat, "utimensat" }, /* 347 */ ++ { 3, TD|TS, sys_signalfd, "signalfd" }, /* 348 */ ++ { 2, TD, sys_timerfd, "timerfd_create" }, /* 349 */ ++ { 1, TD, sys_eventfd, "eventfd" }, /* 350 */ ++ { 5, 0, sys_pread, "pread64" }, /* 351 */ ++ { 5, 0, sys_pwrite, "pwrite64" }, /* 352 */ ++ { 5, 0, sys_fadvise64, "fadvise64" }, /* 353 */ ++ { 2, 0, printargs, "set_robust_list" }, /* 354 */ ++ { 3, 0, printargs, "get_robust_list" }, /* 355 */ ++ { 4, 0, printargs, "fallocate" }, /* 356 */ ++ { 5, TI, sys_semtimedop, "semtimedop" }, /* 357 */ ++ { 7, 0, printargs, "syscall" }, /* 358 */ ++ { 4, TD, printargs, "timerfd_settime" }, /* 358 */ ++ { 2, TD, printargs, "timerfd_gettime" }, /* 359 */ +diff --git a/linux/syscall.h b/linux/syscall.h +index c41bc42..a8a3fa3 100644 +--- a/linux/syscall.h ++++ b/linux/syscall.h +@@ -326,3 +326,7 @@ int sys_pread64(), sys_pwrite64(); + #ifdef POWERPC + int sys_subpage_prot(); + #endif ++ ++#ifdef BFIN ++int sys_sram_alloc(); ++#endif +diff --git a/process.c b/process.c +index a1a02b7..40ae1c4 100644 +--- a/process.c ++++ b/process.c +@@ -742,6 +742,10 @@ int new; + if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_A3), new)<0) + return -1; + return 0; ++#elif defined(BFIN) ++ if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_P0), new)<0) ++ return -1; ++ return 0; + #elif defined(IA64) + if (ia32) { + switch (new) { +@@ -3036,7 +3040,7 @@ const struct xlat struct_user_offsets[] = { + { 70, "fpeir" }, + #endif + +-#if !defined(S390) && !defined(S390X) && !defined(MIPS) && !defined(SPARC64) ++#if !defined(S390) && !defined(S390X) && !defined(MIPS) && !defined(SPARC64) && !defined(BFIN) + { uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" }, + #endif + #if defined(I386) || defined(X86_64) +@@ -3065,7 +3069,7 @@ const struct xlat struct_user_offsets[] = { + #if !defined(SPARC64) + { uoff(u_ar0), "offsetof(struct user, u_ar0)" }, + #endif +-#if !defined(ARM) && !defined(MIPS) && !defined(S390) && !defined(S390X) && !defined(SPARC64) ++#if !defined(ARM) && !defined(MIPS) && !defined(S390) && !defined(S390X) && !defined(SPARC64) && !defined(BFIN) + { uoff(u_fpstate), "offsetof(struct user, u_fpstate)" }, + #endif + { uoff(magic), "offsetof(struct user, magic)" }, +diff --git a/syscall.c b/syscall.c +index 086a793..b7fe14c 100644 +--- a/syscall.c ++++ b/syscall.c +@@ -746,6 +746,8 @@ internal_syscall(struct tcb *tcp) + static long result,flags; + #elif defined (M68K) + static int d0; ++#elif defined(BFIN) ++ static long r0; + #elif defined (ARM) + static struct pt_regs regs; + #elif defined (ALPHA) +@@ -899,6 +901,12 @@ struct tcb *tcp; + return 0; + } + } ++#elif defined(BFIN) ++ if (upeek(pid, PT_ORIG_P0, &scno)) ++ return -1; ++ /* Check if we return from execve. */ ++ if (tcp->flags & TCB_WAITEXECVE && tcp->flags & TCB_INSYSCALL) ++ tcp->flags &= ~(TCB_INSYSCALL | TCB_WAITEXECVE); + #elif defined (I386) + if (upeek(pid, 4*ORIG_EAX, &scno) < 0) + return -1; +@@ -1455,6 +1463,9 @@ struct tcb *tcp; + /* + * Nothing required + */ ++#elif defined(BFIN) ++ if (upeek(pid, PT_R0, &r0) < 0) ++ return -1; + #elif defined (HPPA) + if (upeek(pid, PT_GR28, &r28) < 0) + return -1; +@@ -1588,6 +1599,15 @@ struct tcb *tcp; + u_error = 0; + } + #else /* !ARM */ ++#ifdef BFIN ++ if (is_negated_errno(r0)) { ++ tcp->u_rval = -1; ++ u_error = -r0; ++ } else { ++ tcp->u_rval = r0; ++ u_error = 0; ++ } ++#else /* !BFIN */ + #ifdef ALPHA + if (a3) { + tcp->u_rval = -1; +@@ -1655,6 +1675,7 @@ struct tcb *tcp; + #endif /* SPARC */ + #endif /* SPARC64 */ + #endif /* ALPHA */ ++#endif /* BFIN */ + #endif /* ARM */ + #endif /* M68K */ + #endif /* POWERPC */ +@@ -1781,6 +1802,11 @@ force_result(tcp, error, rval) + return -1; + } + #else /* !IA64 */ ++#ifdef BFIN ++ r0 = error ? -error : rval; ++ if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)PT_R0, r0) < 0) ++ return -1; ++#else /* !BFIN */ + #ifdef MIPS + if (error) { + r2 = error; +@@ -1885,6 +1911,7 @@ force_result(tcp, error, rval) + #endif /* M68K */ + #endif /* POWERPC */ + #endif /* MIPS */ ++#endif /* BFIN */ + #endif /* IA64 */ + #endif /* X86_64 */ + #endif /* I386 */ +@@ -2116,6 +2143,20 @@ struct tcb *tcp; + for (i = 0; i < tcp->u_nargs; i++) + tcp->u_arg[i] = regs.uregs[i]; + } ++#elif defined(BFIN) ++ { ++ int i; ++ int argreg[] = {PT_R0, PT_R1, PT_R2, PT_R3, PT_R4, PT_R5}; ++ ++ if (tcp->scno >= 0 && tcp->scno < nsyscalls && sysent[tcp->scno].nargs != -1) ++ tcp->u_nargs = sysent[tcp->scno].nargs; ++ else ++ tcp->u_nargs = sizeof(argreg) / sizeof(argreg[0]); ++ ++ for (i = 0; i < tcp->u_nargs; ++i) ++ if (upeek(pid, argreg[i], &tcp->u_arg[i]) < 0) ++ return -1; ++ } + #elif defined(SH) + { + int i; +diff --git a/system.c b/system.c +index 306b0df..6c16baf 100644 +--- a/system.c ++++ b/system.c +@@ -293,6 +293,33 @@ struct tcb *tcp; + } + #endif /* M68K */ + ++#ifdef BFIN ++ ++#include ++ ++static const struct xlat sram_alloc_flags[] = { ++ { L1_INST_SRAM, "L1_INST_SRAM" }, ++ { L1_DATA_A_SRAM, "L1_DATA_A_SRAM" }, ++ { L1_DATA_B_SRAM, "L1_DATA_B_SRAM" }, ++ { L1_DATA_SRAM, "L1_DATA_SRAM" }, ++ { 0, NULL }, ++}; ++ ++int ++sys_sram_alloc(tcp) ++struct tcb *tcp; ++{ ++ if (entering(tcp)) { ++ /* size */ ++ tprintf("%zu, ", tcp->u_arg[0]); ++ /* flags */ ++ printxval(sram_alloc_flags, tcp->u_arg[1], "L1_???_SRAM"); ++ } ++ return 1; ++} ++ ++#endif ++ + #endif /* LINUX */ + + #ifdef SUNOS4 +diff --git a/util.c b/util.c +index 07a03ec..77a8404 100644 +--- a/util.c ++++ b/util.c +@@ -1068,6 +1068,9 @@ struct tcb *tcp; + #elif defined(ARM) + if (upeek(tcp->pid, 4*15, &pc) < 0) + return -1; ++#elif defined(BFIN) ++ if (upeek(tcp->pid, REG_PC, &pc) < 0) ++ return -1; + #elif defined(POWERPC) + if (upeek(tcp->pid, sizeof(unsigned long)*PT_NIP, &pc) < 0) + return -1; +@@ -1245,6 +1248,14 @@ struct tcb *tcp; + return; + } + tprintf("[%08lx] ", pc); ++#elif defined(BFIN) ++ long pc; ++ ++ if (upeek(tcp->pid, PT_PC, &pc) < 0) { ++ PRINTBADPC; ++ return; ++ } ++ tprintf("[%08lx] ", pc); + #endif /* !architecture */ + #endif /* LINUX */ + +-- +1.6.0.2 + diff --git a/1035_all_glibc-install-others.patch b/1035_all_glibc-install-others.patch new file mode 100644 index 0000000..4ab4f3c --- /dev/null +++ b/1035_all_glibc-install-others.patch @@ -0,0 +1,156 @@ +2007-07-24 Mike Frysinger + + * Makefile (+subdir_targets): Add extras with install- prefix. + (install-extras): Change from install-others. + (install-extras-nosubdir): Change from install-others-nosubdir. + * Makerules (install-extras-nosubdir): Define. + (install-no-libc.a-nosubdir): Add install-extras-nosubdir when + build-programs. Delete install-others-nosubdir when not. + * elf/Makefile (install-extras): Change from install-others. + * iconvdata/Makefile (install-extras): Likewise. + * intl/Makefile (install-extras): Likewise. + * localedata/Makefile (install-extras): Likewise. + * po/Makefile (install-extras): Likewise. + * stdio-common/Makefile (install-extras): Likewise. + * timezone/Makefile (install-extras): Likewise. + +--- Makefile ++++ Makefile +@@ -66,7 +66,7 @@ + subdir_echo-headers \ + subdir_install \ + subdir_objs subdir_stubs subdir_testclean \ +- $(addprefix install-, no-libc.a bin lib data headers others) ++ $(addprefix install-, no-libc.a bin lib data headers others extras) + + headers := limits.h values.h features.h gnu-versions.h bits/libc-lock.h \ + bits/xopen_lim.h gnu/libc-version.h +@@ -78,7 +78,7 @@ + vpath %.h $(subdir-dirs) + + # What to install. +-install-others = $(inst_includedir)/gnu/stubs.h ++install-extras = $(inst_includedir)/gnu/stubs.h + install-bin-script = + + ifeq (yes,$(build-shared)) +@@ -167,7 +167,7 @@ + $(make-target-directory) + $(INSTALL_DATA) $< $@ + +-install-others-nosubdir: $(installed-stubs) ++install-extras-nosubdir: $(installed-stubs) + endif + + +--- Makerules ++++ Makerules +@@ -1144,6 +1144,7 @@ + install-data-nosubdir: $(addprefix $(inst_datadir)/,$(install-data)) + install-headers-nosubdir: $(addprefix $(inst_includedir)/,$(headers)) + install-others-nosubdir: $(install-others) ++install-extras-nosubdir: $(install-extras) + + # We need all the `-nosubdir' targets so that `install' in the parent + # doesn't depend on several things which each iterate over the subdirs. +@@ -1155,11 +1156,12 @@ + ifeq ($(build-programs),yes) + install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir\ + install-bin-nosubdir install-bin-script-nosubdir \ +- install-lib-nosubdir install-others-nosubdir \ +- install-rootsbin-nosubdir install-sbin-nosubdir ++ install-lib-nosubdir install-extras-nosubdir \ ++ install-others-nosubdir install-rootsbin-nosubdir \ ++ install-sbin-nosubdir + else + install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir\ +- install-lib-nosubdir install-others-nosubdir ++ install-lib-nosubdir install-extras-nosubdir + endif + install: install-no-libc.a-nosubdir + +--- elf/Makefile ++++ elf/Makefile +@@ -116,7 +116,7 @@ + ifeq (yes,$(build-shared)) + extra-objs = $(all-rtld-routines:%=%.os) soinit.os sofini.os interp.os + generated += librtld.os dl-allobjs.os ld.so ldd +-install-others = $(inst_slibdir)/$(rtld-installed-name) ++install-extras = $(inst_slibdir)/$(rtld-installed-name) + install-bin-script = ldd + endif + +--- iconvdata/Makefile ++++ iconvdata/Makefile +@@ -210,7 +210,7 @@ + + + extra-objs += $(modules.so) +-install-others = $(addprefix $(inst_gconvdir)/, $(modules.so)) \ ++install-extras = $(addprefix $(inst_gconvdir)/, $(modules.so)) \ + $(inst_gconvdir)/gconv-modules + + # We can build the conversion tables for numerous charsets automatically. +--- intl/Makefile ++++ intl/Makefile +@@ -45,7 +45,7 @@ + + before-compile = $(objpfx)msgs.h + +-install-others = $(inst_msgcatdir)/locale.alias ++install-extras = $(inst_msgcatdir)/locale.alias + + generated = msgs.h mtrace-tst-gettext tst-gettext.mtrace + generated-dirs := domaindir localedir +--- localedata/Makefile ++++ localedata/Makefile +@@ -102,7 +102,7 @@ + endif + + # Files to install. +-install-others := $(addprefix $(inst_i18ndir)/, \ ++install-extras := $(addprefix $(inst_i18ndir)/, \ + $(addsuffix .gz, $(charmaps)) \ + $(locales)) + +--- po/Makefile ++++ po/Makefile +@@ -46,7 +46,7 @@ + mo-installed = $(inst_msgcatdir)/%/LC_MESSAGES/$(domainname).mo + + # Files to install: a $(domainname).mo file for each language. +-install-others = $(LINGUAS:%=$(mo-installed)) ++install-extras = $(LINGUAS:%=$(mo-installed)) + + # Files to distribute: all the source and compiled binary translation files. + distribute = $(ALL_LINGUAS:=.po) $(BROKEN_LINGUAS:=.po) $(ALL_LINGUAS:=.mo) \ +--- stdio-common/Makefile ++++ stdio-common/Makefile +@@ -36,7 +36,7 @@ + remove rename renameat \ + flockfile ftrylockfile funlockfile + +-install-others = $(inst_includedir)/bits/stdio_lim.h ++install-extras = $(inst_includedir)/bits/stdio_lim.h + + include ../Makeconfig + +--- timezone/Makefile ++++ timezone/Makefile +@@ -71,14 +71,14 @@ + + ifeq ($(cross-compiling),no) + # Don't try to install the zoneinfo files since we can't run zic. +-install-others = $(addprefix $(inst_zonedir)/,$(zonenames) \ ++install-extras = $(addprefix $(inst_zonedir)/,$(zonenames) \ + $(zonenames:%=posix/%) \ + $(zonenames:%=right/%)) \ + $(installed-localtime-file) $(installed-posixrules-file) + endif + + ifeq ($(have-ksh),yes) +-install-others += $(inst_zonedir)/iso3166.tab $(inst_zonedir)/zone.tab ++install-extras += $(inst_zonedir)/iso3166.tab $(inst_zonedir)/zone.tab + install-bin-script = tzselect + generated += tzselect + endif diff --git a/1035_all_glibc-respect-build-programs.patch b/1035_all_glibc-respect-build-programs.patch new file mode 100644 index 0000000..29607f3 --- /dev/null +++ b/1035_all_glibc-respect-build-programs.patch @@ -0,0 +1,44 @@ +2007-07-23 Mike Frysinger + + * iconv/Makefile (install-others): Don't define if not build-programs. + * login/Makefile (install-others): Likewise. + * posix/Makefile (install-others): Likewise. + +--- iconv/Makefile ++++ iconv/Makefile +@@ -56,8 +56,10 @@ + iconvconfig.h + + others = iconv_prog iconvconfig +-install-others = $(inst_bindir)/iconv + install-sbin = iconvconfig ++ifeq ($(build-programs),yes) ++install-others = $(inst_bindir)/iconv ++endif + + CFLAGS-gconv_cache.c += -DGCONV_DIR='"$(gconvdir)"' + CFLAGS-gconv_conf.c = -DGCONV_PATH='"$(gconvdir)"' +--- login/Makefile ++++ login/Makefile +@@ -30,7 +30,9 @@ + CFLAGS-grantpt.c = -DLIBEXECDIR='"$(libexecdir)"' + + others = utmpdump pt_chown ++ifeq ($(build-programs),yes) + install-others = $(inst_libexecdir)/pt_chown ++endif + + distribute := utmp-private.h utmp-equal.h pty-private.h + +--- posix/Makefile ++++ posix/Makefile +@@ -98,7 +98,9 @@ + endif + others := getconf + install-bin := getconf ++ifeq ($(build-programs),yes) + install-others := $(inst_libexecdir)/getconf ++endif + + before-compile := testcases.h ptestcases.h + diff --git a/10_all_generate-pie-scripts.patch b/10_all_generate-pie-scripts.patch new file mode 100644 index 0000000..935008f --- /dev/null +++ b/10_all_generate-pie-scripts.patch @@ -0,0 +1,14 @@ +2006-07-19 Mike Frysinger + + * emulparams/hppa64linux.sh (GENERATE_PIE_SCRIPT): Set to yes. + +--- ld/emulparams/hppa64linux.sh ++++ ld/emulparams/hppa64linux.sh +@@ -13,6 +13,7 @@ + ENTRY="main" + TEMPLATE_NAME=elf32 + GENERATE_SHLIB_SCRIPT=yes ++GENERATE_PIE_SCRIPT=yes + + # We really want multiple .stub sections, one for each input .text section, + # but for now this is good enough. diff --git a/600-missing_headers.patch b/600-missing_headers.patch new file mode 100644 index 0000000..afda703 --- /dev/null +++ b/600-missing_headers.patch @@ -0,0 +1,11 @@ +$FreeWRT$ +--- busybox-1.4.1/modutils/rmmod.c.orig 2007-01-24 21:34:39.000000000 +0000 ++++ busybox-1.4.1/modutils/rmmod.c 2007-03-27 11:26:31.000000000 +0000 +@@ -9,6 +9,7 @@ + + #include "busybox.h" + #include ++#include + + #ifdef CONFIG_FEATURE_2_6_MODULES + static inline void filename2modname(char *modname, const char *afterslash) diff --git a/80_all_binutils-2.15.96-arm-maxpagesize.patch b/80_all_binutils-2.15.96-arm-maxpagesize.patch new file mode 100644 index 0000000..1b31677 --- /dev/null +++ b/80_all_binutils-2.15.96-arm-maxpagesize.patch @@ -0,0 +1,16 @@ +2006-07-19 Peter S. Mazinger + + * emulparams/armelf.sh (MAXPAGESIZE): Changed to + "CONSTANT (MAXPAGESIZE)". + +--- ld/emulparams/armelf.sh ++++ ld/emulparams/armelf.sh +@@ -23,7 +23,7 @@ + + ARCH=arm + MACHINE= +-MAXPAGESIZE=256 ++MAXPAGESIZE="CONSTANT (MAXPAGESIZE)" + ENTRY=_start + EMBEDDED=yes + diff --git a/950-unportability.patch b/950-unportability.patch new file mode 100644 index 0000000..466ffc3 --- /dev/null +++ b/950-unportability.patch @@ -0,0 +1,28 @@ +$FreeWRT$ + + collect all unportability fixes for the build + system (not what ends up in the .ipk) here + +--- busybox-1.4.2/scripts/trylink.orig Sun Mar 18 16:59:02 2007 ++++ busybox-1.4.2/scripts/trylink Fri Jul 20 12:07:14 2007 +@@ -1,4 +1,4 @@ +-#!/bin/sh ++#!/usr/bin/env bash + + debug=false + +--- busybox-1.4.2/applets/Kbuild.orig Sun Mar 18 16:59:13 2007 ++++ busybox-1.4.2/applets/Kbuild Fri Jul 20 12:08:48 2007 +@@ -8,6 +8,7 @@ obj-y:= + obj-y += applets.o + obj-y += busybox.o + ++ifneq (${HOST_OS_IS_NOT_LINUX},) + # Generated file needs additional love + + applets/applets.o: include/usage_compressed.h +@@ -20,3 +21,4 @@ quiet_cmd_gen_usage_compressed = GEN + cmd_gen_usage_compressed = $(srctree)/applets/usage_compressed include/usage_compressed.h applets + include/usage_compressed.h: $(srctree)/include/usage.h applets/usage + $(call cmd,gen_usage_compressed) ++endif diff --git a/BuildToolChain-scrub.patch b/BuildToolChain-scrub.patch new file mode 100644 index 0000000..26e4a0f --- /dev/null +++ b/BuildToolChain-scrub.patch @@ -0,0 +1,137 @@ +Index: BuildToolChain +=================================================================== +--- BuildToolChain (revision 1371) ++++ BuildToolChain (working copy) +@@ -199,15 +199,9 @@ + HOST_TARGET="--host=$OPTARG" + ;; + k) +- if [ -d $OPTARG/uClibc ] ; then +- UCLINUX_ROOT=$OPTARG +- KERNEL_SOURCE=$OPTARG/linux-2.6.x +- if [ ! -d $KERNEL_SOURCE/arch/blackfin ] ; then +- echo "Can't find $KERNEL_SOURCE/arch/blackfin" +- exit 1 +- fi +- else +- echo "Invalid Kernel path : $OPTARG" ++ KERNEL_SOURCE=$OPTARG ++ if [ ! -d $KERNEL_SOURCE/arch/blackfin ] ; then ++ echo "Can't find $KERNEL_SOURCE/arch/blackfin" + exit 1 + fi + ;; +@@ -811,8 +805,7 @@ + # + build_uClibc() + { +- #ARGS="CROSS=bfin-elf- PREFIX=$2 DEVEL_PREFIX=\"/\" RUNTIME_PREFIX=/runtime/ KERNEL_SOURCE=$KERNEL_SOURCE ROOTDIR=$UCLINUX_ROOT" +- ARGS="CROSS=bfin-elf- PREFIX=$2 DEVEL_PREFIX=\"/\" RUNTIME_PREFIX=/runtime/ KERNEL_SOURCE=$DIR_KBUILD_OUTPUT/usr ROOTDIR=$UCLINUX_ROOT" ++ ARGS="CROSS=bfin-elf- PREFIX=$2 DEVEL_PREFIX=\"/\" RUNTIME_PREFIX=/runtime/ KERNEL_SOURCE=$DIR_KBUILD_OUTPUT/usr" + echo -n "*** Cleaning uClibc " ; date + RUN="$MAKE clean $ARGS" + (echo "echo -e '###\n$RUN\n' $LOGFILE" ) | sh +@@ -869,11 +862,6 @@ + echo "uClibc $1 did not install properly : Missing $RUN" + echo "Please report an error to http://blackfin.uclinux.org" + tail -10 $ACTUAL_LOGFILE +- mv saved-config-toplevel .config 2>/dev/null +- mv saved-config-linux linux-2.6.x/.config 2>/dev/null +- mv saved-config-uClibc uClibc/.config 2>/dev/null +- mv saved-config-user config/.config 2>/dev/null +- mv saved-config-arch config.arch 2>/dev/null + exit 1 + fi + done +@@ -1102,26 +1090,11 @@ + + if [ $KERNEL_SOURCE ] ; then + echo -n "*** Configuring uClinux " ; date +- cd $UCLINUX_ROOT + +- # Save the previous configuration +- cp .config saved-config-toplevel 2>/dev/null +- cp linux-2.6.x/.config saved-config-linux 2>/dev/null +- cp config/.config saved-config-user 2>/dev/null +- cp -a config.arch saved-config-arch 2>/dev/null +- +- # Make sure the kernel is in a safe state +- RUN="$MAKE AnalogDevices/BF537-STAMP_config" ++ cd $KERNEL_SOURCE ++ RUN="$MAKE -j1 CROSS_COMPILE=bfin-elf- headers_check headers_install INSTALL_HDR_PATH=$DIR_KBUILD_OUTPUT/usr KBUILD_OUTPUT=$DIR_KBUILD_OUTPUT" + (echo "echo -e '###\n$RUN\n' $LOGFILE" ) | sh +- (echo $RUN $LOGFILE ; ) | sh +- +- cd linux-2.6.x +- RUN="$MAKE CROSS_COMPILE=bfin-elf- prepare" +- (echo "echo -e '###\n$RUN\n' $LOGFILE" ) | sh + (echo $RUN $LOGFILE ; ) | sh || die_with_log +- RUN="$MAKE CROSS_COMPILE=bfin-elf- headers_install INSTALL_HDR_PATH=$DIR_KBUILD_OUTPUT/usr KBUILD_OUTPUT=$DIR_KBUILD_OUTPUT" +- (echo "echo -e '###\n$RUN\n' $LOGFILE" ) | sh +- (echo $RUN $LOGFILE ; ) | sh || die_with_log + cd .. + + ####################### Step 3 - build uClibc ################ +@@ -1144,7 +1117,7 @@ + echo '# UCLIBC_FORMAT_SHARED_FLAT is not set' >>.config + echo '# UCLIBC_FORMAT_FLAT_SEP_DATA is not set' >>.config + echo "KERNEL_HEADERS=\"$DIR_KBUILD_OUTPUT/usr/include\"" >>.config +- RUN="$MAKE oldconfig CROSS=bfin-elf- ROOTDIR=$UCLINUX_ROOT" ++ RUN="$MAKE oldconfig CROSS=bfin-elf-" + (echo "echo -e '###\n$RUN\n' $LOGFILE" ) | sh + (echo $RUN $LOGFILE ; ) | sh + +@@ -1162,7 +1135,7 @@ + echo '# UCLIBC_FORMAT_FLAT is not set' >>.config + echo 'MULTILIB="msep-data"' >>.config + +- RUN="$MAKE oldconfig CROSS=bfin-elf- ROOTDIR=$UCLINUX_ROOT" ++ RUN="$MAKE oldconfig CROSS=bfin-elf-" + (echo "echo -e '###\n$RUN\n' $LOGFILE" ) | sh + (echo $RUN $LOGFILE ; ) | sh + +@@ -1180,7 +1153,7 @@ + echo '# UCLIBC_FORMAT_FLAT_SEP_DATA is not set' >>.config + echo 'MULTILIB="mid-shared-library"' >>.config + +- RUN="$MAKE oldconfig CROSS=bfin-elf- ROOTDIR=$UCLINUX_ROOT" ++ RUN="$MAKE oldconfig CROSS=bfin-elf-" + (echo "echo -e '###\n$RUN\n' $LOGFILE" ) | sh + (echo $RUN $LOGFILE ; ) | sh + +@@ -1206,7 +1179,7 @@ + echo '# UCLIBC_FORMAT_FLAT_SEP_DATA is not set' >>.config + echo "KERNEL_HEADERS=\"$DIR_KBUILD_OUTPUT/usr/include\"" >>.config + +- RUN="$MAKE oldconfig CROSS=bfin-elf- ROOTDIR=$UCLINUX_ROOT" ++ RUN="$MAKE oldconfig CROSS=bfin-elf-" + (echo "echo -e '###\n$RUN\n' $LOGFILE" ) | sh + (echo $RUN $LOGFILE ; ) | sh + +@@ -1225,11 +1198,8 @@ + + ######################### Done with uClibc ########################### + +- echo -n "*** Cleaning uClinux " ; date +- cd $UCLINUX_ROOT +- RUN="$MAKE distclean" +- (echo "echo -e '###\n$RUN\n' $LOGFILE" ) | sh +- (echo $RUN $LOGFILE ; ) | sh ++ echo -n "*** Cleaning kernel " ; date ++ rm -rf "$DIR_KBUILD_OUTPUT" + + echo -n "*** Cleaning uClibc " ; date + cd $UCLIBC_SOURCE +@@ -1243,12 +1213,6 @@ + mkdir -p $DIR_LINUX_OUTPUT/bfin-linux-uclibc/runtime/usr/include + (cd $DIR_uC_OUTPUT/bfin-uclinux/ ; tar cf - include) | (cd $DIR_LINUX_OUTPUT/bfin-linux-uclibc/runtime/usr ; tar xf - ) + +- cd $UCLINUX_ROOT +- mv saved-config-toplevel .config 2>/dev/null +- mv saved-config-linux linux-2.6.x/.config 2>/dev/null +- mv saved-config-user config/.config 2>/dev/null +- mv saved-config-arch config.arch 2>/dev/null +- + ####################### Done Step 3 ######################### + + ####################### Step 4 - build bfin-uclinux ################ diff --git a/MPlayer-mmap-fall-back-map-private.patch b/MPlayer-mmap-fall-back-map-private.patch new file mode 100644 index 0000000..093cec7 --- /dev/null +++ b/MPlayer-mmap-fall-back-map-private.patch @@ -0,0 +1,43 @@ +Index: libvo/vo_fbdev.c +=================================================================== +--- libvo/vo_fbdev.c (revision 22100) ++++ libvo/vo_fbdev.c (working copy) +@@ -1003,10 +1003,13 @@ static int config(uint32_t width, uint32 + #endif + { + int x_offset=0,y_offset=0; +- if ((frame_buffer = (uint8_t *) mmap(0, fb_size, PROT_READ | PROT_WRITE, +- MAP_SHARED, fb_dev_fd, 0)) == (uint8_t *) -1) { +- mp_msg(MSGT_VO, MSGL_ERR, "Can't mmap %s: %s\n", fb_dev_name, strerror(errno)); +- return 1; ++ frame_buffer = mmap(0, fb_size, PROT_READ | PROT_WRITE, MAP_SHARED, fb_dev_fd, 0); ++ if (frame_buffer == MAP_FAILED) { ++ frame_buffer = mmap(0, fb_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fb_dev_fd, 0); ++ if (frame_buffer == MAP_FAILED) { ++ mp_msg(MSGT_VO, MSGL_ERR, "Can't mmap %s: %s\n", fb_dev_name, strerror(errno)); ++ return 1; ++ } + } + + center = frame_buffer + +Index: libvo/vo_fbdev2.c +=================================================================== +--- libvo/vo_fbdev2.c (revision 22088) ++++ libvo/vo_fbdev2.c (working copy) +@@ -274,9 +274,13 @@ static int config(uint32_t width, uint32 + + fb_size = fb_finfo.smem_len; + fb_line_len = fb_finfo.line_length; +- if ((frame_buffer = (uint8_t *) mmap(0, fb_size, PROT_READ | PROT_WRITE, MAP_SHARED, fb_dev_fd, 0)) == (uint8_t *) -1) { +- mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] Can't mmap %s: %s\n", fb_dev_name, strerror(errno)); +- return 1; ++ frame_buffer = mmap(0, fb_size, PROT_READ | PROT_WRITE, MAP_SHARED, fb_dev_fd, 0); ++ if (frame_buffer == MAP_FAILED) { ++ frame_buffer = mmap(0, fb_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fb_dev_fd, 0); ++ if (frame_buffer == MAP_FAILED) { ++ mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] Can't mmap %s: %s\n", fb_dev_name, strerror(errno)); ++ return 1; ++ } + } + } + diff --git a/SDL-1.2.9-6.8.patch b/SDL-1.2.9-6.8.patch new file mode 100644 index 0000000..8f5954e --- /dev/null +++ b/SDL-1.2.9-6.8.patch @@ -0,0 +1,52 @@ +diff -Naur SDL-1.2.9_pre/src/video/fbcon/SDL_fbvideo.c SDL-1.2.9/src/video/fbcon/SDL_fbvideo.c +--- SDL-1.2.9_pre/src/video/fbcon/SDL_fbvideo.c 2006-05-20 16:54:59.000000000 +0800 ++++ SDL-1.2.9/src/video/fbcon/SDL_fbvideo.c 2006-05-22 13:15:36.000000000 +0800 +@@ -752,6 +752,24 @@ + fprintf(stderr, "Printing original vinfo:\n"); + print_vinfo(&vinfo); + #endif ++#if 1 ++ vinfo.accel_flags = 0; ++ vinfo.bits_per_pixel = bpp; ++ vinfo.xres = width; ++ vinfo.xres_virtual = width; ++ vinfo.yres = height; ++ if ( flags & SDL_DOUBLEBUF ) { ++ vinfo.yres_virtual = height*2; ++ } else { ++ vinfo.yres_virtual = height; ++ } ++ vinfo.xoffset = 0; ++ vinfo.yoffset = 0; ++ vinfo.red.length = vinfo.red.offset = 0; ++ vinfo.green.length = vinfo.green.offset = 0; ++ vinfo.blue.length = vinfo.blue.offset = 0; ++ vinfo.transp.length = vinfo.transp.offset = 0; ++#else + if ( (vinfo.xres != width) || (vinfo.yres != height) || + (vinfo.bits_per_pixel != bpp) || (flags & SDL_DOUBLEBUF) ) { + vinfo.activate = FB_ACTIVATE_NOW; +@@ -800,6 +818,7 @@ + vinfo.yres_virtual = maxheight; + } + } ++#endif + cache_vinfo = vinfo; + #ifdef FBCON_DEBUG + fprintf(stderr, "Printing actual vinfo:\n"); +@@ -1119,12 +1138,12 @@ + FB_WaitBusySurfaces(this); + } + wait_vbl(this); +- #if 0 //lee 5-1 ++ + if ( ioctl(console_fd, FBIOPAN_DISPLAY, &cache_vinfo) < 0 ) { +- SDL_SetError("ioctl(FBIOPAN_DISPLAY) failed"); ++ //SDL_SetError("ioctl(FBIOPAN_DISPLAY) failed"); //lee:skip SDL error logout + return(-1); + } +- #endif ++ + flip_page = !flip_page; + + surface->pixels = flip_address[flip_page]; diff --git a/adsp-xml-remove-spurious.patch b/adsp-xml-remove-spurious.patch new file mode 100644 index 0000000..84eea05 --- /dev/null +++ b/adsp-xml-remove-spurious.patch @@ -0,0 +1,142 @@ +Index: ADSP-BF535-proc.xml +=================================================================== +RCS file: /cvs/dsptools/sc2/Common/ADspCommon/ArchDef/ADSP-BF535-proc.xml,v +retrieving revision 1.33 +diff -u -p -r1.33 ADSP-BF535-proc.xml +--- ADSP-BF535-proc.xml 19 Apr 2007 06:35:59 -0000 1.33 ++++ ADSP-BF535-proc.xml 4 Aug 2007 00:21:55 -0000 +@@ -1330,7 +1330,7 @@ + + + +-+ ++ + + + +Index: ADSP-BF542-proc.xml +=================================================================== +RCS file: /cvs/dsptools/sc2/Common/ADspCommon/ArchDef/ADSP-BF542-proc.xml,v +retrieving revision 1.14 +diff -u -p -r1.14 ADSP-BF542-proc.xml +--- ADSP-BF542-proc.xml 14 May 2007 22:24:37 -0000 1.14 ++++ ADSP-BF542-proc.xml 4 Aug 2007 00:21:58 -0000 +@@ -4796,7 +4796,7 @@ + + + +-N ++ + + + +Index: ADSP-BF548-proc.xml +=================================================================== +RCS file: /cvs/dsptools/sc2/Common/ADspCommon/ArchDef/ADSP-BF548-proc.xml,v +retrieving revision 1.20 +diff -u -p -r1.20 ADSP-BF548-proc.xml +--- ADSP-BF548-proc.xml 29 May 2007 20:51:15 -0000 1.20 ++++ ADSP-BF548-proc.xml 4 Aug 2007 00:21:58 -0000 +@@ -5206,7 +5206,7 @@ + + + +-N ++ + + + +Index: ADSP-BF6xx-extended.xml +=================================================================== +RCS file: /cvs/dsptools/sc2/Common/ADspCommon/ArchDef/ADSP-BF6xx-extended.xml,v +retrieving revision 1.3 +diff -u -p -r1.3 ADSP-BF6xx-extended.xml +--- ADSP-BF6xx-extended.xml 25 May 2007 18:14:26 -0000 1.3 ++++ ADSP-BF6xx-extended.xml 4 Aug 2007 00:21:58 -0000 +@@ -182,11 +182,11 @@ + + + +- //[11] reserved ++ + +- //[15] reserved ++ + +- //[24:31] reserved ++ + + + +@@ -227,11 +227,11 @@ + + + +- //[11] reserved ++ + +- //[15] reserved ++ + +- //[24:31] reserved ++ + + + +@@ -268,11 +268,11 @@ + + + +- //[11] reserved ++ + +- //[15] reserved ++ + +- //[24:31] reserved ++ + + + +@@ -313,11 +313,11 @@ + + + +- //[11] reserved ++ + +- //[15] reserved ++ + +- //[24:31] reserved ++ + + + +Index: ADSP-EDN-BF538-extended.xml +=================================================================== +RCS file: /cvs/dsptools/sc2/Common/ADspCommon/ArchDef/ADSP-EDN-BF538-extended.xml,v +retrieving revision 1.21 +diff -u -p -r1.21 ADSP-EDN-BF538-extended.xml +--- ADSP-EDN-BF538-extended.xml 19 Apr 2007 05:18:22 -0000 1.21 ++++ ADSP-EDN-BF538-extended.xml 4 Aug 2007 00:21:58 -0000 +@@ -425,15 +425,15 @@ + + + +- /> +- /> ++ ++ + + + + + +- /> +- /> ++ ++ + + + diff --git a/alloc.c.patch b/alloc.c.patch new file mode 100644 index 0000000..436ddd5 --- /dev/null +++ b/alloc.c.patch @@ -0,0 +1,13 @@ +--- alloc.c~ 2006-05-10 18:07:00.000000000 +0200 ++++ alloc.c 2006-05-10 18:08:54.000000000 +0200 +@@ -90,7 +90,9 @@ + + newptr = malloc(size); + if (newptr) { +- memcpy(newptr, ptr, *((size_t *) (ptr - sizeof(size_t)))); ++ size_t old_size = *((size_t *) (ptr - sizeof(size_t))); ++ if(old_size < size) size = old_size; ++ memcpy(newptr, ptr, size); + free(ptr); + } + return newptr; diff --git a/alsa-compile-scripts-set-e.patch b/alsa-compile-scripts-set-e.patch new file mode 100644 index 0000000..33bf0a5 --- /dev/null +++ b/alsa-compile-scripts-set-e.patch @@ -0,0 +1,20 @@ +diff -r 8bdd68608788 cvscompile +--- a/cvscompile Mon Sep 18 17:57:58 2006 +0200 ++++ b/cvscompile Fri Sep 22 16:58:42 2006 -0400 +@@ -1,4 +1,6 @@ + #!/bin/bash ++ ++set -e + + touch ltconfig + libtoolize --force --copy --automake +diff -r 8bdd68608788 hgcompile +--- a/hgcompile Mon Sep 18 17:57:58 2006 +0200 ++++ b/hgcompile Fri Sep 22 16:59:13 2006 -0400 +@@ -1,4 +1,6 @@ + #!/bin/bash ++ ++set -e + + touch ltconfig + libtoolize --force --copy --automake diff --git a/alsa-lib-alisp-include-less.patch b/alsa-lib-alisp-include-less.patch new file mode 100644 index 0000000..a966695 --- /dev/null +++ b/alsa-lib-alisp-include-less.patch @@ -0,0 +1,16 @@ +Signed-off-by: Mike Frysinger + + alisp.c | 1 - + 1 file changed, 1 deletion(-) + +diff -r 46221e609f45 src/alisp/alisp.c +--- a/src/alisp/alisp.c Wed Sep 06 14:39:01 2006 +0200 ++++ b/src/alisp/alisp.c Thu Sep 07 14:42:21 2006 -0400 +@@ -30,7 +30,6 @@ + #include + #include + #include +-#include + + #define alisp_seq_iterator alisp_object + diff --git a/alsa-lib-build-out-of-tree.patch b/alsa-lib-build-out-of-tree.patch new file mode 100644 index 0000000..c146d09 --- /dev/null +++ b/alsa-lib-build-out-of-tree.patch @@ -0,0 +1,41 @@ +Signed-off-by: Mike Frysinger + + configure.in | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff -r 8bdd68608788 configure.in +--- a/configure.in Mon Sep 18 17:57:58 2006 +0200 ++++ b/configure.in Fri Sep 22 17:07:13 2006 -0400 +@@ -83,7 +84,7 @@ AC_ARG_WITH(versioned, + versioned="$withval", versioned="yes") + if test "$versioned" = "yes"; then + # it seems that GNU ld versions since 2.10 are not broken +- xres=`grep '^VERSION=' $ac_aux_dir/libtool | cut -d = -f 2` ++ xres=`grep '^VERSION=' libtool | cut -d = -f 2` + major=`echo $xres | cut -d . -f 1` + minor=`echo $xres | cut -d . -f 2` + pass=0 +@@ -357,18 +368,18 @@ fi + + + dnl Create PCM plugin symbol list for static library +-rm -f src/pcm/pcm_symbols_list.c ++rm -f "$srcdir"/src/pcm/pcm_symbols_list.c + for t in $PCM_PLUGIN_LIST; do + if eval test \$build_pcm_$t = yes; then +- echo \&_snd_module_pcm_$t, >> src/pcm/pcm_symbols_list.c ++ echo \&_snd_module_pcm_$t, >> "$srcdir"/src/pcm/pcm_symbols_list.c + fi + done + + dnl Make a symlink for inclusion of alsa/xxx.h +-if test ! -L include/alsa ; then ++if test ! -L "$srcdir"/include/alsa ; then + echo "Making a symlink include/alsa" +- rm -f include/alsa +- ln -sf . include/alsa ++ rm -f "$srcdir"/include/alsa ++ ln -sf . "$srcdir"/include/alsa + fi + + AC_OUTPUT(Makefile doc/Makefile doc/pictures/Makefile include/Makefile diff --git a/alsa-lib-names-include-less.patch b/alsa-lib-names-include-less.patch new file mode 100644 index 0000000..0bf4339 --- /dev/null +++ b/alsa-lib-names-include-less.patch @@ -0,0 +1,21 @@ +Signed-off-by: Mike Frysinger + + names.c | 4 ---- + 1 file changed, 4 deletions(-) + +diff -r 46221e609f45 src/names.c +--- a/src/names.c Wed Sep 06 14:39:01 2006 +0200 ++++ b/src/names.c Thu Sep 07 14:39:43 2006 -0400 +@@ -31,12 +31,8 @@ + */ + + #include +-#include +-#include + #include + #include +-#include +-#include + #include "local.h" + + #ifndef DOC_HIDDEN diff --git a/alsa-lib-shared-fdpic.patch b/alsa-lib-shared-fdpic.patch new file mode 100644 index 0000000..8a040e9 --- /dev/null +++ b/alsa-lib-shared-fdpic.patch @@ -0,0 +1,592 @@ +Index: aclocal.m4 +=================================================================== +--- aclocal.m4 (revision 4673) ++++ aclocal.m4 (working copy) +@@ -1644,7 +1644,7 @@ linux*oldld* | linux*aout* | linux*coff* + ;; + + # This must be Linux ELF. +-linux*) ++linux*|uclinux*) + version_type=linux + need_lib_prefix=no + need_version=no +@@ -2444,7 +2444,7 @@ irix5* | irix6* | nonstopux*) + ;; + + # This must be Linux ELF. +-linux*) ++linux*|uclinux*) + lt_cv_deplibs_check_method=pass_all + ;; + +@@ -3770,6 +3770,24 @@ case $host_os in + ;; + esac + ;; ++ uclinux*) ++ case $LDFLAGS in ++ *-Wl,-elf2lft*) ++ _LT_AC_TAGVAR(ld_shlibs, $1)=no ++ ;; ++ *) ++ case $host_cpu in ++ bfin) ++ CFLAGS="$CFLAGS -mfdpic" ++ ;; ++ *) ++ _LT_AC_TAGVAR(ld_shlibs, $1)=no ++ ;; ++ esac ++ ;; ++ esac ++ ;; ++ + vxworks*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no +@@ -4949,6 +4967,23 @@ AC_MSG_CHECKING([for $compiler option to + ;; + esac + ;; ++ linux|uclinux*) ++ case $LDFLAGS in ++ *-Wl,-elf2lft*) ++ _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ++ ;; ++ *) ++ case $host_cpu in ++ bfin) ++ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-mfdpic' ++ ;; ++ *) ++ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ++ ;; ++ esac ++ ;; ++ esac ++ ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; +@@ -5232,6 +5267,23 @@ AC_MSG_CHECKING([for $compiler option to + esac + ;; + ++ linux|uclinux*) ++ case $LDFLAGS in ++ *-Wl,-elf2lft*) ++ _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ++ ;; ++ *) ++ case $host_cpu in ++ bfin) ++ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-mfdpic' ++ ;; ++ *) ++ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ++ ;; ++ esac ++ ;; ++ esac ++ ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; +Index: src/Versions +=================================================================== +--- src/Versions (revision 4673) ++++ src/Versions (working copy) +@@ -1,8 +1,8 @@ + ALSA_0.9 { + global: ++ ___snd_*; + __snd_*; + _snd_*; +- snd_*; + local: + *; + }; +@@ -10,281 +10,281 @@ ALSA_0.9 { + ALSA_0.9.0rc4 { + global: + +- snd_pcm_hw_params_get_access; +- snd_pcm_hw_params_set_access_first; +- snd_pcm_hw_params_set_access_last; +- +- snd_pcm_hw_params_get_format; +- snd_pcm_hw_params_set_format_first; +- snd_pcm_hw_params_set_format_last; +- +- snd_pcm_hw_params_get_subformat; +- snd_pcm_hw_params_set_subformat_first; +- snd_pcm_hw_params_set_subformat_last; +- +- snd_pcm_hw_params_get_channels; +- snd_pcm_hw_params_get_channels_min; +- snd_pcm_hw_params_get_channels_max; +- snd_pcm_hw_params_set_channels_near; +- snd_pcm_hw_params_set_channels_first; +- snd_pcm_hw_params_set_channels_last; +- +- snd_pcm_hw_params_get_rate; +- snd_pcm_hw_params_get_rate_min; +- snd_pcm_hw_params_get_rate_max; +- snd_pcm_hw_params_set_rate_near; +- snd_pcm_hw_params_set_rate_first; +- snd_pcm_hw_params_set_rate_last; +- +- snd_pcm_hw_params_get_period_time; +- snd_pcm_hw_params_get_period_time_min; +- snd_pcm_hw_params_get_period_time_max; +- snd_pcm_hw_params_set_period_time_near; +- snd_pcm_hw_params_set_period_time_first; +- snd_pcm_hw_params_set_period_time_last; +- +- snd_pcm_hw_params_get_period_size; +- snd_pcm_hw_params_get_period_size_min; +- snd_pcm_hw_params_get_period_size_max; +- snd_pcm_hw_params_set_period_size_near; +- snd_pcm_hw_params_set_period_size_first; +- snd_pcm_hw_params_set_period_size_last; +- +- snd_pcm_hw_params_get_periods; +- snd_pcm_hw_params_get_periods_min; +- snd_pcm_hw_params_get_periods_max; +- snd_pcm_hw_params_set_periods_near; +- snd_pcm_hw_params_set_periods_first; +- snd_pcm_hw_params_set_periods_last; +- +- snd_pcm_hw_params_get_buffer_time; +- snd_pcm_hw_params_get_buffer_time_min; +- snd_pcm_hw_params_get_buffer_time_max; +- snd_pcm_hw_params_set_buffer_time_near; +- snd_pcm_hw_params_set_buffer_time_first; +- snd_pcm_hw_params_set_buffer_time_last; +- +- snd_pcm_hw_params_get_buffer_size; +- snd_pcm_hw_params_get_buffer_size_min; +- snd_pcm_hw_params_get_buffer_size_max; +- snd_pcm_hw_params_set_buffer_size_near; +- snd_pcm_hw_params_set_buffer_size_first; +- snd_pcm_hw_params_set_buffer_size_last; +- +- snd_pcm_hw_params_get_tick_time; +- snd_pcm_hw_params_get_tick_time_min; +- snd_pcm_hw_params_get_tick_time_max; +- snd_pcm_hw_params_set_tick_time_near; +- snd_pcm_hw_params_set_tick_time_first; +- snd_pcm_hw_params_set_tick_time_last; ++ _snd_pcm_hw_params_get_access; ++ _snd_pcm_hw_params_set_access_first; ++ _snd_pcm_hw_params_set_access_last; ++ ++ _snd_pcm_hw_params_get_format; ++ _snd_pcm_hw_params_set_format_first; ++ _snd_pcm_hw_params_set_format_last; ++ ++ _snd_pcm_hw_params_get_subformat; ++ _snd_pcm_hw_params_set_subformat_first; ++ _snd_pcm_hw_params_set_subformat_last; ++ ++ _snd_pcm_hw_params_get_channels; ++ _snd_pcm_hw_params_get_channels_min; ++ _snd_pcm_hw_params_get_channels_max; ++ _snd_pcm_hw_params_set_channels_near; ++ _snd_pcm_hw_params_set_channels_first; ++ _snd_pcm_hw_params_set_channels_last; ++ ++ _snd_pcm_hw_params_get_rate; ++ _snd_pcm_hw_params_get_rate_min; ++ _snd_pcm_hw_params_get_rate_max; ++ _snd_pcm_hw_params_set_rate_near; ++ _snd_pcm_hw_params_set_rate_first; ++ _snd_pcm_hw_params_set_rate_last; ++ ++ _snd_pcm_hw_params_get_period_time; ++ _snd_pcm_hw_params_get_period_time_min; ++ _snd_pcm_hw_params_get_period_time_max; ++ _snd_pcm_hw_params_set_period_time_near; ++ _snd_pcm_hw_params_set_period_time_first; ++ _snd_pcm_hw_params_set_period_time_last; ++ ++ _snd_pcm_hw_params_get_period_size; ++ _snd_pcm_hw_params_get_period_size_min; ++ _snd_pcm_hw_params_get_period_size_max; ++ _snd_pcm_hw_params_set_period_size_near; ++ _snd_pcm_hw_params_set_period_size_first; ++ _snd_pcm_hw_params_set_period_size_last; ++ ++ _snd_pcm_hw_params_get_periods; ++ _snd_pcm_hw_params_get_periods_min; ++ _snd_pcm_hw_params_get_periods_max; ++ _snd_pcm_hw_params_set_periods_near; ++ _snd_pcm_hw_params_set_periods_first; ++ _snd_pcm_hw_params_set_periods_last; ++ ++ _snd_pcm_hw_params_get_buffer_time; ++ _snd_pcm_hw_params_get_buffer_time_min; ++ _snd_pcm_hw_params_get_buffer_time_max; ++ _snd_pcm_hw_params_set_buffer_time_near; ++ _snd_pcm_hw_params_set_buffer_time_first; ++ _snd_pcm_hw_params_set_buffer_time_last; ++ ++ _snd_pcm_hw_params_get_buffer_size; ++ _snd_pcm_hw_params_get_buffer_size_min; ++ _snd_pcm_hw_params_get_buffer_size_max; ++ _snd_pcm_hw_params_set_buffer_size_near; ++ _snd_pcm_hw_params_set_buffer_size_first; ++ _snd_pcm_hw_params_set_buffer_size_last; ++ ++ _snd_pcm_hw_params_get_tick_time; ++ _snd_pcm_hw_params_get_tick_time_min; ++ _snd_pcm_hw_params_get_tick_time_max; ++ _snd_pcm_hw_params_set_tick_time_near; ++ _snd_pcm_hw_params_set_tick_time_first; ++ _snd_pcm_hw_params_set_tick_time_last; + + } ALSA_0.9; + + ALSA_0.9.0rc8 { + global: + +- snd_pcm_forward; +- snd_pcm_status_get_trigger_htstamp; +- snd_pcm_status_get_htstamp; ++ _snd_pcm_forward; ++ _snd_pcm_status_get_trigger_htstamp; ++ _snd_pcm_status_get_htstamp; + + } ALSA_0.9.0rc4; + + ALSA_0.9.0 { + global: + +- snd_pcm_type_name; +- snd_timer_query_info; +- snd_timer_query_params; +- snd_timer_query_status; +- snd_timer_params_set_exclusive; +- snd_timer_params_get_exclusive; +- snd_timer_params_set_filter; +- snd_timer_params_get_filter; ++ _snd_pcm_type_name; ++ _snd_timer_query_info; ++ _snd_timer_query_params; ++ _snd_timer_query_status; ++ _snd_timer_params_set_exclusive; ++ _snd_timer_params_get_exclusive; ++ _snd_timer_params_set_filter; ++ _snd_timer_params_get_filter; + } ALSA_0.9.0rc8; + + ALSA_0.9.3 { + global: + +- snd_ctl_elem_info_get_dimensions; +- snd_ctl_elem_info_get_dimension; ++ _snd_ctl_elem_info_get_dimensions; ++ _snd_ctl_elem_info_get_dimension; + } ALSA_0.9.0; + + ALSA_0.9.5 { + global: + +- alsa_lisp; ++ _alsa_lisp; + } ALSA_0.9.3; + + ALSA_0.9.6 { + global: + +- snd_hctl_open_ctl; +- snd_seq_port_info_get_timestamping; +- snd_seq_port_info_get_timestamp_real; +- snd_seq_port_info_get_timestamp_queue; +- snd_seq_port_info_set_timestamping; +- snd_seq_port_info_set_timestamp_real; +- snd_seq_port_info_set_timestamp_queue; ++ _snd_hctl_open_ctl; ++ _snd_seq_port_info_get_timestamping; ++ _snd_seq_port_info_get_timestamp_real; ++ _snd_seq_port_info_get_timestamp_queue; ++ _snd_seq_port_info_set_timestamping; ++ _snd_seq_port_info_set_timestamp_real; ++ _snd_seq_port_info_set_timestamp_queue; + } ALSA_0.9.5; + + ALSA_0.9.7 { + global: + +- snd_user_file; +- snd_hctl_ctl; +- sndo_*; +- alsa_lisp_*; ++ _snd_user_file; ++ _snd_hctl_ctl; ++ _sndo_*; ++ _alsa_lisp_*; + } ALSA_0.9.6; + + ALSA_0.9.8 { + global: + +- snd_ctl_elem_add; +- snd_ctl_elem_replace; +- snd_ctl_elem_remove; +- snd_hctl_poll_descriptors_revents; ++ _snd_ctl_elem_add; ++ _snd_ctl_elem_replace; ++ _snd_ctl_elem_remove; ++ _snd_hctl_poll_descriptors_revents; + } ALSA_0.9.7; + + ALSA_1.0.4 { + global: + +- snd_spcm_init; +- snd_spcm_init_duplex; +- snd_spcm_init_get_params; ++ _snd_spcm_init; ++ _snd_spcm_init_duplex; ++ _snd_spcm_init_get_params; + } ALSA_0.9.8; + + ALSA_1.0.5 { + global: + +- snd_asoundlib_version; +- snd_timer_params_set_early_event; +- snd_timer_params_get_early_event; ++ _snd_asoundlib_version; ++ _snd_timer_params_set_early_event; ++ _snd_timer_params_get_early_event; + } ALSA_1.0.4; + + ALSA_1.0.8 { + global: + +- snd_ctl_elem_add_integer; +- snd_ctl_elem_add_integer64; +- snd_ctl_elem_add_boolean; +- snd_ctl_elem_add_iec958; +- snd_ctl_elem_remove; ++ _snd_ctl_elem_add_integer; ++ _snd_ctl_elem_add_integer64; ++ _snd_ctl_elem_add_boolean; ++ _snd_ctl_elem_add_iec958; ++ _snd_ctl_elem_remove; + } ALSA_1.0.5; + + ALSA_1.0.9 { + global: + +- snd_names_list; +- snd_names_list_free; ++ _snd_names_list; ++ _snd_names_list_free; + +- snd_pcm_hw_params_set_rate_resample; +- snd_pcm_hw_params_get_rate_resample; +- snd_pcm_hw_params_set_export_buffer; +- snd_pcm_hw_params_get_export_buffer; +- +- snd_pcm_ioplug_create; +- snd_pcm_ioplug_delete; +- snd_pcm_ioplug_reinit_status; +- snd_pcm_ioplug_params_reset; +- snd_pcm_ioplug_set_param_minmax; +- snd_pcm_ioplug_set_param_list; +- +- snd_pcm_extplug_create; +- snd_pcm_extplug_delete; +- snd_pcm_extplug_params_reset; +- snd_pcm_extplug_set_param_list; +- snd_pcm_extplug_set_param_minmax; +- snd_pcm_extplug_set_slave_param_list; +- snd_pcm_extplug_set_slave_param_minmax; +- +- snd_pcm_parse_control_id; +- +- snd_async_add_timer_handler; +- snd_async_handler_get_timer; +- +- snd_timer_ginfo_sizeof; +- snd_timer_ginfo_malloc; +- snd_timer_ginfo_free; +- snd_timer_ginfo_copy; +- snd_timer_ginfo_set_tid; +- snd_timer_ginfo_get_tid; +- snd_timer_ginfo_get_flags; +- snd_timer_ginfo_get_card; +- snd_timer_ginfo_get_id; +- snd_timer_ginfo_get_name; +- snd_timer_ginfo_get_resolution; +- snd_timer_ginfo_get_resolution_min; +- snd_timer_ginfo_get_resolution_max; +- snd_timer_ginfo_get_clients; ++ _snd_pcm_hw_params_set_rate_resample; ++ _snd_pcm_hw_params_get_rate_resample; ++ _snd_pcm_hw_params_set_export_buffer; ++ _snd_pcm_hw_params_get_export_buffer; ++ ++ _snd_pcm_ioplug_create; ++ _snd_pcm_ioplug_delete; ++ _snd_pcm_ioplug_reinit_status; ++ _snd_pcm_ioplug_params_reset; ++ _snd_pcm_ioplug_set_param_minmax; ++ _snd_pcm_ioplug_set_param_list; ++ ++ _snd_pcm_extplug_create; ++ _snd_pcm_extplug_delete; ++ _snd_pcm_extplug_params_reset; ++ _snd_pcm_extplug_set_param_list; ++ _snd_pcm_extplug_set_param_minmax; ++ _snd_pcm_extplug_set_slave_param_list; ++ _snd_pcm_extplug_set_slave_param_minmax; ++ ++ _snd_pcm_parse_control_id; ++ ++ _snd_async_add_timer_handler; ++ _snd_async_handler_get_timer; ++ ++ _snd_timer_ginfo_sizeof; ++ _snd_timer_ginfo_malloc; ++ _snd_timer_ginfo_free; ++ _snd_timer_ginfo_copy; ++ _snd_timer_ginfo_set_tid; ++ _snd_timer_ginfo_get_tid; ++ _snd_timer_ginfo_get_flags; ++ _snd_timer_ginfo_get_card; ++ _snd_timer_ginfo_get_id; ++ _snd_timer_ginfo_get_name; ++ _snd_timer_ginfo_get_resolution; ++ _snd_timer_ginfo_get_resolution_min; ++ _snd_timer_ginfo_get_resolution_max; ++ _snd_timer_ginfo_get_clients; + + } ALSA_1.0.8; + + ALSA_1.0.10 { + global: + +- snd_mixer_get_hctl; +- snd_mixer_elem_get_private; +- snd_mixer_attach_hctl; +- snd_mixer_detach_hctl; +- +- snd_mixer_class_register; +- snd_mixer_add_elem; +- snd_mixer_remove_elem; +- snd_mixer_elem_new; +- snd_mixer_elem_add; +- snd_mixer_elem_remove; +- snd_mixer_elem_free; +- snd_mixer_elem_info; +- snd_mixer_elem_value; +- snd_mixer_elem_attach; +- snd_mixer_elem_detach; +- snd_mixer_elem_empty; +- +- snd_mixer_class_malloc; +- snd_mixer_class_free; +- snd_mixer_class_copy; +- snd_mixer_class_get_mixer; +- snd_mixer_class_get_event; +- snd_mixer_class_get_private; +- snd_mixer_class_get_compare; +- snd_mixer_class_set_event; +- snd_mixer_class_set_private; +- snd_mixer_class_set_private_free; +- snd_mixer_class_set_compare; +- +- snd_mixer_selem_set_playback_dB_all; +- snd_mixer_selem_set_capture_dB_all; +- snd_mixer_selem_is_enum_playback; +- snd_mixer_selem_is_enum_capture; +- snd_mixer_selem_compare; +- snd_mixer_sbasic_info; +- snd_mixer_sbasic_get_private; +- snd_mixer_sbasic_set_private; +- snd_mixer_sbasic_set_private_free; ++ _snd_mixer_get_hctl; ++ _snd_mixer_elem_get_private; ++ _snd_mixer_attach_hctl; ++ _snd_mixer_detach_hctl; ++ ++ _snd_mixer_class_register; ++ _snd_mixer_add_elem; ++ _snd_mixer_remove_elem; ++ _snd_mixer_elem_new; ++ _snd_mixer_elem_add; ++ _snd_mixer_elem_remove; ++ _snd_mixer_elem_free; ++ _snd_mixer_elem_info; ++ _snd_mixer_elem_value; ++ _snd_mixer_elem_attach; ++ _snd_mixer_elem_detach; ++ _snd_mixer_elem_empty; ++ ++ _snd_mixer_class_malloc; ++ _snd_mixer_class_free; ++ _snd_mixer_class_copy; ++ _snd_mixer_class_get_mixer; ++ _snd_mixer_class_get_event; ++ _snd_mixer_class_get_private; ++ _snd_mixer_class_get_compare; ++ _snd_mixer_class_set_event; ++ _snd_mixer_class_set_private; ++ _snd_mixer_class_set_private_free; ++ _snd_mixer_class_set_compare; ++ ++ _snd_mixer_selem_set_playback_dB_all; ++ _snd_mixer_selem_set_capture_dB_all; ++ _snd_mixer_selem_is_enum_playback; ++ _snd_mixer_selem_is_enum_capture; ++ _snd_mixer_selem_compare; ++ _snd_mixer_sbasic_info; ++ _snd_mixer_sbasic_get_private; ++ _snd_mixer_sbasic_set_private; ++ _snd_mixer_sbasic_set_private_free; + +- snd_ctl_ext_create; +- snd_ctl_ext_delete; ++ _snd_ctl_ext_create; ++ _snd_ctl_ext_delete; + + } ALSA_1.0.9; + + ALSA_1.0.11 { + global: + +- snd_pcm_recover; +- snd_pcm_set_params; +- snd_pcm_get_params; ++ _snd_pcm_recover; ++ _snd_pcm_set_params; ++ _snd_pcm_get_params; + } ALSA_1.0.10; + + ALSA_1.0.12 { + global: + +- snd_ctl_elem_tlv_read; +- snd_ctl_elem_tlv_write; +- snd_ctl_elem_tlv_command; +- snd_ctl_elem_info_is_tlv_readable; +- snd_ctl_elem_info_is_tlv_writable; +- snd_ctl_elem_info_is_tlv_commandable; +- snd_hctl_elem_tlv_read; +- snd_hctl_elem_tlv_write; +- snd_hctl_elem_tlv_command; ++ _snd_ctl_elem_tlv_read; ++ _snd_ctl_elem_tlv_write; ++ _snd_ctl_elem_tlv_command; ++ _snd_ctl_elem_info_is_tlv_readable; ++ _snd_ctl_elem_info_is_tlv_writable; ++ _snd_ctl_elem_info_is_tlv_commandable; ++ _snd_hctl_elem_tlv_read; ++ _snd_hctl_elem_tlv_write; ++ _snd_hctl_elem_tlv_command; + } ALSA_1.0.11; diff --git a/alsa-lib-symbol-prefix-version-script.patch b/alsa-lib-symbol-prefix-version-script.patch new file mode 100644 index 0000000..35d3b6e --- /dev/null +++ b/alsa-lib-symbol-prefix-version-script.patch @@ -0,0 +1,636 @@ +diff -r 4b305d56a1f0 configure.in +--- a/configure.in Mon Jan 08 16:39:26 2007 +0100 ++++ b/configure.in Fri Jan 12 13:27:35 2007 -0500 +@@ -114,6 +114,7 @@ SYMBOL_PREFIX=` \ + | ${EGREP-grep} "^PREFIX=" \ + | ${SED-sed} "s:^PREFIX=::"` + AC_DEFINE_UNQUOTED([__SYMBOL_PREFIX], "$SYMBOL_PREFIX", [Toolchain Symbol Prefix]) ++AC_SUBST(SYMBOL_PREFIX) + AC_MSG_RESULT($SYMBOL_PREFIX) + + dnl Check for debug... +@@ -384,7 +385,7 @@ fi + fi + + AC_OUTPUT(Makefile doc/Makefile doc/pictures/Makefile include/Makefile +- include/sound/Makefile src/Makefile \ ++ include/sound/Makefile src/Versions src/Makefile \ + src/control/Makefile src/mixer/Makefile \ + src/pcm/Makefile src/pcm/scopes/Makefile \ + src/rawmidi/Makefile src/timer/Makefile \ +diff -r 4b305d56a1f0 src/Makefile.am +--- a/src/Makefile.am Mon Jan 08 16:39:26 2007 +0100 ++++ b/src/Makefile.am Fri Jan 12 13:32:11 2007 -0500 +@@ -2,7 +2,7 @@ COMPATNUM=@LIBTOOL_VERSION_INFO@ + COMPATNUM=@LIBTOOL_VERSION_INFO@ + + if VERSIONED_SYMBOLS +-VSYMS = -Wl,--version-script=$(srcdir)/Versions ++VSYMS = -Wl,--version-script=Versions + else + VSYMS = + endif +diff -r 4b305d56a1f0 src/Versions +--- a/src/Versions Mon Jan 08 16:39:26 2007 +0100 ++++ /dev/null Thu Jan 01 00:00:00 1970 +0000 +@@ -1,298 +0,0 @@ +-ALSA_0.9 { +- global: +- __snd_*; +- _snd_*; +- snd_*; +- local: +- *; +-}; +- +-ALSA_0.9.0rc4 { +- global: +- +- snd_pcm_hw_params_get_access; +- snd_pcm_hw_params_set_access_first; +- snd_pcm_hw_params_set_access_last; +- +- snd_pcm_hw_params_get_format; +- snd_pcm_hw_params_set_format_first; +- snd_pcm_hw_params_set_format_last; +- +- snd_pcm_hw_params_get_subformat; +- snd_pcm_hw_params_set_subformat_first; +- snd_pcm_hw_params_set_subformat_last; +- +- snd_pcm_hw_params_get_channels; +- snd_pcm_hw_params_get_channels_min; +- snd_pcm_hw_params_get_channels_max; +- snd_pcm_hw_params_set_channels_near; +- snd_pcm_hw_params_set_channels_first; +- snd_pcm_hw_params_set_channels_last; +- +- snd_pcm_hw_params_get_rate; +- snd_pcm_hw_params_get_rate_min; +- snd_pcm_hw_params_get_rate_max; +- snd_pcm_hw_params_set_rate_near; +- snd_pcm_hw_params_set_rate_first; +- snd_pcm_hw_params_set_rate_last; +- +- snd_pcm_hw_params_get_period_time; +- snd_pcm_hw_params_get_period_time_min; +- snd_pcm_hw_params_get_period_time_max; +- snd_pcm_hw_params_set_period_time_near; +- snd_pcm_hw_params_set_period_time_first; +- snd_pcm_hw_params_set_period_time_last; +- +- snd_pcm_hw_params_get_period_size; +- snd_pcm_hw_params_get_period_size_min; +- snd_pcm_hw_params_get_period_size_max; +- snd_pcm_hw_params_set_period_size_near; +- snd_pcm_hw_params_set_period_size_first; +- snd_pcm_hw_params_set_period_size_last; +- +- snd_pcm_hw_params_get_periods; +- snd_pcm_hw_params_get_periods_min; +- snd_pcm_hw_params_get_periods_max; +- snd_pcm_hw_params_set_periods_near; +- snd_pcm_hw_params_set_periods_first; +- snd_pcm_hw_params_set_periods_last; +- +- snd_pcm_hw_params_get_buffer_time; +- snd_pcm_hw_params_get_buffer_time_min; +- snd_pcm_hw_params_get_buffer_time_max; +- snd_pcm_hw_params_set_buffer_time_near; +- snd_pcm_hw_params_set_buffer_time_first; +- snd_pcm_hw_params_set_buffer_time_last; +- +- snd_pcm_hw_params_get_buffer_size; +- snd_pcm_hw_params_get_buffer_size_min; +- snd_pcm_hw_params_get_buffer_size_max; +- snd_pcm_hw_params_set_buffer_size_near; +- snd_pcm_hw_params_set_buffer_size_first; +- snd_pcm_hw_params_set_buffer_size_last; +- +- snd_pcm_hw_params_get_tick_time; +- snd_pcm_hw_params_get_tick_time_min; +- snd_pcm_hw_params_get_tick_time_max; +- snd_pcm_hw_params_set_tick_time_near; +- snd_pcm_hw_params_set_tick_time_first; +- snd_pcm_hw_params_set_tick_time_last; +- +-} ALSA_0.9; +- +-ALSA_0.9.0rc8 { +- global: +- +- snd_pcm_forward; +- snd_pcm_status_get_trigger_htstamp; +- snd_pcm_status_get_htstamp; +- +-} ALSA_0.9.0rc4; +- +-ALSA_0.9.0 { +- global: +- +- snd_pcm_type_name; +- snd_timer_query_info; +- snd_timer_query_params; +- snd_timer_query_status; +- snd_timer_params_set_exclusive; +- snd_timer_params_get_exclusive; +- snd_timer_params_set_filter; +- snd_timer_params_get_filter; +-} ALSA_0.9.0rc8; +- +-ALSA_0.9.3 { +- global: +- +- snd_ctl_elem_info_get_dimensions; +- snd_ctl_elem_info_get_dimension; +-} ALSA_0.9.0; +- +-ALSA_0.9.5 { +- global: +- +- alsa_lisp; +-} ALSA_0.9.3; +- +-ALSA_0.9.6 { +- global: +- +- snd_hctl_open_ctl; +- snd_seq_port_info_get_timestamping; +- snd_seq_port_info_get_timestamp_real; +- snd_seq_port_info_get_timestamp_queue; +- snd_seq_port_info_set_timestamping; +- snd_seq_port_info_set_timestamp_real; +- snd_seq_port_info_set_timestamp_queue; +-} ALSA_0.9.5; +- +-ALSA_0.9.7 { +- global: +- +- snd_user_file; +- snd_hctl_ctl; +- sndo_*; +- alsa_lisp_*; +-} ALSA_0.9.6; +- +-ALSA_0.9.8 { +- global: +- +- snd_ctl_elem_add; +- snd_ctl_elem_replace; +- snd_ctl_elem_remove; +- snd_hctl_poll_descriptors_revents; +-} ALSA_0.9.7; +- +-ALSA_1.0.4 { +- global: +- +- snd_spcm_init; +- snd_spcm_init_duplex; +- snd_spcm_init_get_params; +-} ALSA_0.9.8; +- +-ALSA_1.0.5 { +- global: +- +- snd_asoundlib_version; +- snd_timer_params_set_early_event; +- snd_timer_params_get_early_event; +-} ALSA_1.0.4; +- +-ALSA_1.0.8 { +- global: +- +- snd_ctl_elem_add_integer; +- snd_ctl_elem_add_integer64; +- snd_ctl_elem_add_boolean; +- snd_ctl_elem_add_iec958; +- snd_ctl_elem_remove; +-} ALSA_1.0.5; +- +-ALSA_1.0.9 { +- global: +- +- snd_names_list; +- snd_names_list_free; +- +- snd_pcm_hw_params_set_rate_resample; +- snd_pcm_hw_params_get_rate_resample; +- snd_pcm_hw_params_set_export_buffer; +- snd_pcm_hw_params_get_export_buffer; +- +- snd_pcm_ioplug_create; +- snd_pcm_ioplug_delete; +- snd_pcm_ioplug_reinit_status; +- snd_pcm_ioplug_params_reset; +- snd_pcm_ioplug_set_param_minmax; +- snd_pcm_ioplug_set_param_list; +- +- snd_pcm_extplug_create; +- snd_pcm_extplug_delete; +- snd_pcm_extplug_params_reset; +- snd_pcm_extplug_set_param_list; +- snd_pcm_extplug_set_param_minmax; +- snd_pcm_extplug_set_slave_param_list; +- snd_pcm_extplug_set_slave_param_minmax; +- +- snd_pcm_parse_control_id; +- +- snd_async_add_timer_handler; +- snd_async_handler_get_timer; +- +- snd_timer_ginfo_sizeof; +- snd_timer_ginfo_malloc; +- snd_timer_ginfo_free; +- snd_timer_ginfo_copy; +- snd_timer_ginfo_set_tid; +- snd_timer_ginfo_get_tid; +- snd_timer_ginfo_get_flags; +- snd_timer_ginfo_get_card; +- snd_timer_ginfo_get_id; +- snd_timer_ginfo_get_name; +- snd_timer_ginfo_get_resolution; +- snd_timer_ginfo_get_resolution_min; +- snd_timer_ginfo_get_resolution_max; +- snd_timer_ginfo_get_clients; +- +-} ALSA_1.0.8; +- +-ALSA_1.0.10 { +- global: +- +- snd_mixer_get_hctl; +- snd_mixer_elem_get_private; +- snd_mixer_attach_hctl; +- snd_mixer_detach_hctl; +- +- snd_mixer_class_register; +- snd_mixer_add_elem; +- snd_mixer_remove_elem; +- snd_mixer_elem_new; +- snd_mixer_elem_add; +- snd_mixer_elem_remove; +- snd_mixer_elem_free; +- snd_mixer_elem_info; +- snd_mixer_elem_value; +- snd_mixer_elem_attach; +- snd_mixer_elem_detach; +- snd_mixer_elem_empty; +- +- snd_mixer_class_malloc; +- snd_mixer_class_free; +- snd_mixer_class_copy; +- snd_mixer_class_get_mixer; +- snd_mixer_class_get_event; +- snd_mixer_class_get_private; +- snd_mixer_class_get_compare; +- snd_mixer_class_set_event; +- snd_mixer_class_set_private; +- snd_mixer_class_set_private_free; +- snd_mixer_class_set_compare; +- +- snd_mixer_selem_set_playback_dB_all; +- snd_mixer_selem_set_capture_dB_all; +- snd_mixer_selem_is_enum_playback; +- snd_mixer_selem_is_enum_capture; +- snd_mixer_selem_compare; +- snd_mixer_sbasic_info; +- snd_mixer_sbasic_get_private; +- snd_mixer_sbasic_set_private; +- snd_mixer_sbasic_set_private_free; +- +- snd_ctl_ext_create; +- snd_ctl_ext_delete; +- +-} ALSA_1.0.9; +- +-ALSA_1.0.11 { +- global: +- +- snd_pcm_recover; +- snd_pcm_set_params; +- snd_pcm_get_params; +-} ALSA_1.0.10; +- +-ALSA_1.0.12 { +- global: +- +- snd_ctl_elem_tlv_read; +- snd_ctl_elem_tlv_write; +- snd_ctl_elem_tlv_command; +- snd_ctl_elem_info_is_tlv_readable; +- snd_ctl_elem_info_is_tlv_writable; +- snd_ctl_elem_info_is_tlv_commandable; +- snd_hctl_elem_tlv_read; +- snd_hctl_elem_tlv_write; +- snd_hctl_elem_tlv_command; +-} ALSA_1.0.11; +- +-ALSA_1.0.14 { +- global: +- +- snd_device_name_hint; +- snd_device_name_free_hint; +- snd_device_name_get_hint; +-} ALSA_1.0.12; +diff -r 4b305d56a1f0 src/Versions.in +--- /dev/null Thu Jan 01 00:00:00 1970 +0000 ++++ b/src/Versions.in Fri Jan 12 13:27:35 2007 -0500 +@@ -0,0 +1,298 @@ ++ALSA_0.9 { ++ global: ++ @SYMBOL_PREFIX@__snd_*; ++ @SYMBOL_PREFIX@_snd_*; ++ @SYMBOL_PREFIX@snd_*; ++ local: ++ *; ++}; ++ ++ALSA_0.9.0rc4 { ++ global: ++ ++ @SYMBOL_PREFIX@snd_pcm_hw_params_get_access; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_set_access_first; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_set_access_last; ++ ++ @SYMBOL_PREFIX@snd_pcm_hw_params_get_format; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_set_format_first; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_set_format_last; ++ ++ @SYMBOL_PREFIX@snd_pcm_hw_params_get_subformat; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_set_subformat_first; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_set_subformat_last; ++ ++ @SYMBOL_PREFIX@snd_pcm_hw_params_get_channels; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_get_channels_min; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_get_channels_max; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_set_channels_near; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_set_channels_first; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_set_channels_last; ++ ++ @SYMBOL_PREFIX@snd_pcm_hw_params_get_rate; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_get_rate_min; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_get_rate_max; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_set_rate_near; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_set_rate_first; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_set_rate_last; ++ ++ @SYMBOL_PREFIX@snd_pcm_hw_params_get_period_time; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_get_period_time_min; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_get_period_time_max; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_set_period_time_near; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_set_period_time_first; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_set_period_time_last; ++ ++ @SYMBOL_PREFIX@snd_pcm_hw_params_get_period_size; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_get_period_size_min; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_get_period_size_max; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_set_period_size_near; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_set_period_size_first; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_set_period_size_last; ++ ++ @SYMBOL_PREFIX@snd_pcm_hw_params_get_periods; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_get_periods_min; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_get_periods_max; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_set_periods_near; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_set_periods_first; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_set_periods_last; ++ ++ @SYMBOL_PREFIX@snd_pcm_hw_params_get_buffer_time; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_get_buffer_time_min; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_get_buffer_time_max; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_set_buffer_time_near; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_set_buffer_time_first; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_set_buffer_time_last; ++ ++ @SYMBOL_PREFIX@snd_pcm_hw_params_get_buffer_size; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_get_buffer_size_min; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_get_buffer_size_max; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_set_buffer_size_near; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_set_buffer_size_first; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_set_buffer_size_last; ++ ++ @SYMBOL_PREFIX@snd_pcm_hw_params_get_tick_time; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_get_tick_time_min; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_get_tick_time_max; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_set_tick_time_near; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_set_tick_time_first; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_set_tick_time_last; ++ ++} ALSA_0.9; ++ ++ALSA_0.9.0rc8 { ++ global: ++ ++ @SYMBOL_PREFIX@snd_pcm_forward; ++ @SYMBOL_PREFIX@snd_pcm_status_get_trigger_htstamp; ++ @SYMBOL_PREFIX@snd_pcm_status_get_htstamp; ++ ++} ALSA_0.9.0rc4; ++ ++ALSA_0.9.0 { ++ global: ++ ++ @SYMBOL_PREFIX@snd_pcm_type_name; ++ @SYMBOL_PREFIX@snd_timer_query_info; ++ @SYMBOL_PREFIX@snd_timer_query_params; ++ @SYMBOL_PREFIX@snd_timer_query_status; ++ @SYMBOL_PREFIX@snd_timer_params_set_exclusive; ++ @SYMBOL_PREFIX@snd_timer_params_get_exclusive; ++ @SYMBOL_PREFIX@snd_timer_params_set_filter; ++ @SYMBOL_PREFIX@snd_timer_params_get_filter; ++} ALSA_0.9.0rc8; ++ ++ALSA_0.9.3 { ++ global: ++ ++ @SYMBOL_PREFIX@snd_ctl_elem_info_get_dimensions; ++ @SYMBOL_PREFIX@snd_ctl_elem_info_get_dimension; ++} ALSA_0.9.0; ++ ++ALSA_0.9.5 { ++ global: ++ ++ @SYMBOL_PREFIX@alsa_lisp; ++} ALSA_0.9.3; ++ ++ALSA_0.9.6 { ++ global: ++ ++ @SYMBOL_PREFIX@snd_hctl_open_ctl; ++ @SYMBOL_PREFIX@snd_seq_port_info_get_timestamping; ++ @SYMBOL_PREFIX@snd_seq_port_info_get_timestamp_real; ++ @SYMBOL_PREFIX@snd_seq_port_info_get_timestamp_queue; ++ @SYMBOL_PREFIX@snd_seq_port_info_set_timestamping; ++ @SYMBOL_PREFIX@snd_seq_port_info_set_timestamp_real; ++ @SYMBOL_PREFIX@snd_seq_port_info_set_timestamp_queue; ++} ALSA_0.9.5; ++ ++ALSA_0.9.7 { ++ global: ++ ++ @SYMBOL_PREFIX@snd_user_file; ++ @SYMBOL_PREFIX@snd_hctl_ctl; ++ @SYMBOL_PREFIX@sndo_*; ++ @SYMBOL_PREFIX@alsa_lisp_*; ++} ALSA_0.9.6; ++ ++ALSA_0.9.8 { ++ global: ++ ++ @SYMBOL_PREFIX@snd_ctl_elem_add; ++ @SYMBOL_PREFIX@snd_ctl_elem_replace; ++ @SYMBOL_PREFIX@snd_ctl_elem_remove; ++ @SYMBOL_PREFIX@snd_hctl_poll_descriptors_revents; ++} ALSA_0.9.7; ++ ++ALSA_1.0.4 { ++ global: ++ ++ @SYMBOL_PREFIX@snd_spcm_init; ++ @SYMBOL_PREFIX@snd_spcm_init_duplex; ++ @SYMBOL_PREFIX@snd_spcm_init_get_params; ++} ALSA_0.9.8; ++ ++ALSA_1.0.5 { ++ global: ++ ++ @SYMBOL_PREFIX@snd_asoundlib_version; ++ @SYMBOL_PREFIX@snd_timer_params_set_early_event; ++ @SYMBOL_PREFIX@snd_timer_params_get_early_event; ++} ALSA_1.0.4; ++ ++ALSA_1.0.8 { ++ global: ++ ++ @SYMBOL_PREFIX@snd_ctl_elem_add_integer; ++ @SYMBOL_PREFIX@snd_ctl_elem_add_integer64; ++ @SYMBOL_PREFIX@snd_ctl_elem_add_boolean; ++ @SYMBOL_PREFIX@snd_ctl_elem_add_iec958; ++ @SYMBOL_PREFIX@snd_ctl_elem_remove; ++} ALSA_1.0.5; ++ ++ALSA_1.0.9 { ++ global: ++ ++ @SYMBOL_PREFIX@snd_names_list; ++ @SYMBOL_PREFIX@snd_names_list_free; ++ ++ @SYMBOL_PREFIX@snd_pcm_hw_params_set_rate_resample; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_get_rate_resample; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_set_export_buffer; ++ @SYMBOL_PREFIX@snd_pcm_hw_params_get_export_buffer; ++ ++ @SYMBOL_PREFIX@snd_pcm_ioplug_create; ++ @SYMBOL_PREFIX@snd_pcm_ioplug_delete; ++ @SYMBOL_PREFIX@snd_pcm_ioplug_reinit_status; ++ @SYMBOL_PREFIX@snd_pcm_ioplug_params_reset; ++ @SYMBOL_PREFIX@snd_pcm_ioplug_set_param_minmax; ++ @SYMBOL_PREFIX@snd_pcm_ioplug_set_param_list; ++ ++ @SYMBOL_PREFIX@snd_pcm_extplug_create; ++ @SYMBOL_PREFIX@snd_pcm_extplug_delete; ++ @SYMBOL_PREFIX@snd_pcm_extplug_params_reset; ++ @SYMBOL_PREFIX@snd_pcm_extplug_set_param_list; ++ @SYMBOL_PREFIX@snd_pcm_extplug_set_param_minmax; ++ @SYMBOL_PREFIX@snd_pcm_extplug_set_slave_param_list; ++ @SYMBOL_PREFIX@snd_pcm_extplug_set_slave_param_minmax; ++ ++ @SYMBOL_PREFIX@snd_pcm_parse_control_id; ++ ++ @SYMBOL_PREFIX@snd_async_add_timer_handler; ++ @SYMBOL_PREFIX@snd_async_handler_get_timer; ++ ++ @SYMBOL_PREFIX@snd_timer_ginfo_sizeof; ++ @SYMBOL_PREFIX@snd_timer_ginfo_malloc; ++ @SYMBOL_PREFIX@snd_timer_ginfo_free; ++ @SYMBOL_PREFIX@snd_timer_ginfo_copy; ++ @SYMBOL_PREFIX@snd_timer_ginfo_set_tid; ++ @SYMBOL_PREFIX@snd_timer_ginfo_get_tid; ++ @SYMBOL_PREFIX@snd_timer_ginfo_get_flags; ++ @SYMBOL_PREFIX@snd_timer_ginfo_get_card; ++ @SYMBOL_PREFIX@snd_timer_ginfo_get_id; ++ @SYMBOL_PREFIX@snd_timer_ginfo_get_name; ++ @SYMBOL_PREFIX@snd_timer_ginfo_get_resolution; ++ @SYMBOL_PREFIX@snd_timer_ginfo_get_resolution_min; ++ @SYMBOL_PREFIX@snd_timer_ginfo_get_resolution_max; ++ @SYMBOL_PREFIX@snd_timer_ginfo_get_clients; ++ ++} ALSA_1.0.8; ++ ++ALSA_1.0.10 { ++ global: ++ ++ @SYMBOL_PREFIX@snd_mixer_get_hctl; ++ @SYMBOL_PREFIX@snd_mixer_elem_get_private; ++ @SYMBOL_PREFIX@snd_mixer_attach_hctl; ++ @SYMBOL_PREFIX@snd_mixer_detach_hctl; ++ ++ @SYMBOL_PREFIX@snd_mixer_class_register; ++ @SYMBOL_PREFIX@snd_mixer_add_elem; ++ @SYMBOL_PREFIX@snd_mixer_remove_elem; ++ @SYMBOL_PREFIX@snd_mixer_elem_new; ++ @SYMBOL_PREFIX@snd_mixer_elem_add; ++ @SYMBOL_PREFIX@snd_mixer_elem_remove; ++ @SYMBOL_PREFIX@snd_mixer_elem_free; ++ @SYMBOL_PREFIX@snd_mixer_elem_info; ++ @SYMBOL_PREFIX@snd_mixer_elem_value; ++ @SYMBOL_PREFIX@snd_mixer_elem_attach; ++ @SYMBOL_PREFIX@snd_mixer_elem_detach; ++ @SYMBOL_PREFIX@snd_mixer_elem_empty; ++ ++ @SYMBOL_PREFIX@snd_mixer_class_malloc; ++ @SYMBOL_PREFIX@snd_mixer_class_free; ++ @SYMBOL_PREFIX@snd_mixer_class_copy; ++ @SYMBOL_PREFIX@snd_mixer_class_get_mixer; ++ @SYMBOL_PREFIX@snd_mixer_class_get_event; ++ @SYMBOL_PREFIX@snd_mixer_class_get_private; ++ @SYMBOL_PREFIX@snd_mixer_class_get_compare; ++ @SYMBOL_PREFIX@snd_mixer_class_set_event; ++ @SYMBOL_PREFIX@snd_mixer_class_set_private; ++ @SYMBOL_PREFIX@snd_mixer_class_set_private_free; ++ @SYMBOL_PREFIX@snd_mixer_class_set_compare; ++ ++ @SYMBOL_PREFIX@snd_mixer_selem_set_playback_dB_all; ++ @SYMBOL_PREFIX@snd_mixer_selem_set_capture_dB_all; ++ @SYMBOL_PREFIX@snd_mixer_selem_is_enum_playback; ++ @SYMBOL_PREFIX@snd_mixer_selem_is_enum_capture; ++ @SYMBOL_PREFIX@snd_mixer_selem_compare; ++ @SYMBOL_PREFIX@snd_mixer_sbasic_info; ++ @SYMBOL_PREFIX@snd_mixer_sbasic_get_private; ++ @SYMBOL_PREFIX@snd_mixer_sbasic_set_private; ++ @SYMBOL_PREFIX@snd_mixer_sbasic_set_private_free; ++ ++ @SYMBOL_PREFIX@snd_ctl_ext_create; ++ @SYMBOL_PREFIX@snd_ctl_ext_delete; ++ ++} ALSA_1.0.9; ++ ++ALSA_1.0.11 { ++ global: ++ ++ @SYMBOL_PREFIX@snd_pcm_recover; ++ @SYMBOL_PREFIX@snd_pcm_set_params; ++ @SYMBOL_PREFIX@snd_pcm_get_params; ++} ALSA_1.0.10; ++ ++ALSA_1.0.12 { ++ global: ++ ++ @SYMBOL_PREFIX@snd_ctl_elem_tlv_read; ++ @SYMBOL_PREFIX@snd_ctl_elem_tlv_write; ++ @SYMBOL_PREFIX@snd_ctl_elem_tlv_command; ++ @SYMBOL_PREFIX@snd_ctl_elem_info_is_tlv_readable; ++ @SYMBOL_PREFIX@snd_ctl_elem_info_is_tlv_writable; ++ @SYMBOL_PREFIX@snd_ctl_elem_info_is_tlv_commandable; ++ @SYMBOL_PREFIX@snd_hctl_elem_tlv_read; ++ @SYMBOL_PREFIX@snd_hctl_elem_tlv_write; ++ @SYMBOL_PREFIX@snd_hctl_elem_tlv_command; ++} ALSA_1.0.11; ++ ++ALSA_1.0.14 { ++ global: ++ ++ @SYMBOL_PREFIX@snd_device_name_hint; ++ @SYMBOL_PREFIX@snd_device_name_free_hint; ++ @SYMBOL_PREFIX@snd_device_name_get_hint; ++} ALSA_1.0.12; diff --git a/apcupsd-drivers-updates.patch b/apcupsd-drivers-updates.patch new file mode 100644 index 0000000..aaa4a15 --- /dev/null +++ b/apcupsd-drivers-updates.patch @@ -0,0 +1,16 @@ +--- autoconf/targets.mak ++++ autoconf/targets.mak +@@ -79,9 +80,12 @@ $(topdir)/src/drivers/usb/libusb.a: $(to + $(topdir)/src/drivers/snmp/libdumb.a: $(topdir)/src/drivers/snmp/*.[ch] + @(cd $(topdir)/src/drivers/snmp && $(MAKE)) + +-$(topdir)/src/drivers/dumb/libtest.a: $(topdir)/src/drivers/test/*.[ch] ++$(topdir)/src/drivers/test/libtest.a: $(topdir)/src/drivers/test/*.[ch] + @(cd $(topdir)/src/drivers/test && $(MAKE)) + ++$(topdir)/src/drivers/pcnet/libpcnet.a: $(topdir)/src/drivers/pcnet/*.[ch] ++ @(cd $(topdir)/src/drivers/pcnet && $(MAKE)) ++ + $(topdir)/src/intl/libintl.a: $(topdir)/src/intl/*.[ch] + @(cd $(topdir)/src/intl && $(MAKE)) + diff --git a/apcupsd-more-phonies.patch b/apcupsd-more-phonies.patch new file mode 100644 index 0000000..6d92c24 --- /dev/null +++ b/apcupsd-more-phonies.patch @@ -0,0 +1,14 @@ +--- autoconf/targets.mak ++++ autoconf/targets.mak +@@ -13,8 +13,9 @@ + .NOEXPORT: + .SUFFIXES: .o .lo .c .cpp .h .po .gmo .mo .cat .msg .pox + .MAIN: all +-.PHONY: all install uninstall install- install-apcupsd install-powerflute \ +- install-cgi install-strip clean realclean distclean mostlyclean clobber ++.PHONY: all all-subdirs all-targets install uninstall install- install-apcupsd \ ++ install-powerflute install-cgi install-strip clean realclean distclean \ ++ mostlyclean clobber + + all: all-subdirs all-targets + diff --git a/apcupsd-pass-recursive-errors.patch b/apcupsd-pass-recursive-errors.patch new file mode 100644 index 0000000..043601a --- /dev/null +++ b/apcupsd-pass-recursive-errors.patch @@ -0,0 +1,23 @@ +Index: autoconf/targets.mak +=================================================================== +RCS file: /cvsroot/apcupsd/apcupsd/autoconf/targets.mak,v +retrieving revision 1.21 +diff -u -p -r1.21 targets.mak +--- autoconf/targets.mak 21 Sep 2006 00:07:35 -0000 1.21 ++++ autoconf/targets.mak 19 Dec 2006 22:38:52 -0000 +@@ -22,10 +22,11 @@ all-subdirs: + @if test ! x"$(subdirs)" = x; then \ + for file in . ${subdirs}; \ + do \ +- (cd $$file && if test "$$file" != "."; then $(MAKE) DESTDIR=$(DESTDIR) all; fi); \ +- if test "$$?" != "0"; then \ +- break; \ +- fi; \ ++ (cd $$file; \ ++ if test "$$file" != "."; then \ ++ $(MAKE) DESTDIR=$(DESTDIR) all || exit $$?; \ ++ fi; \ ++ ) || exit $$?; \ + done; \ + fi + diff --git a/asterisk-pic-fix.patch b/asterisk-pic-fix.patch new file mode 100644 index 0000000..ee6af70 --- /dev/null +++ b/asterisk-pic-fix.patch @@ -0,0 +1,118 @@ +Index: codecs/gsm/src/k6opt.s +=================================================================== +--- codecs/gsm/src/k6opt.s (revision 49815) ++++ codecs/gsm/src/k6opt.s (working copy) +@@ -1,23 +1,24 @@ + .file "k6opt.s" + .version "01.01" +-/* gcc2_compiled.: */ +-.section .rodata +- .align 4 +- .type coefs,@object +- .size coefs,24 +-coefs: +- .value -134 +- .value -374 +- .value 0 +- .value 2054 +- .value 5741 +- .value 8192 +- .value 5741 +- .value 2054 +- .value 0 +- .value -374 +- .value -134 +- .value 0 ++ ++/* load a mask into a mmx register ... use the stack to avoid TEXTRELS */ ++.macro load_immq mask reg ++ pushl $h_\mask ++ pushl $l_\mask ++ movq (%esp), \reg ++.endm ++.macro cleanup_immq num ++ addl \num * 8, %esp ++.endm ++ ++/* some coefficients for us to play with */ ++.set h_coefs1, 0xFE8AFF7A /* -134 -374 */ ++.set l_coefs1, 0x08060000 /* 0 2504 */ ++.set h_coefs2, 0x2000166D /* 5741 8192 */ ++.set l_coefs2, 0x0806166D /* 5741 2054 */ ++.set h_coefs3, 0xFE8A0000 /* 0 -374 */ ++.set l_coefs3, 0x0000FF7A /* -134 0 */ ++ + .text + .align 4 + /* void Weighting_filter (const short *e, short *x) */ +@@ -34,9 +35,10 @@ Weighting_filter: + addl $-10,%ebx + emms + movl $0x1000,%eax; movd %eax,%mm5 /* for rounding */ +- movq coefs,%mm1 +- movq coefs+8,%mm2 +- movq coefs+16,%mm3 ++ load_immq coefs1, %mm1 ++ load_immq coefs2, %mm2 ++ load_immq coefs3, %mm3 ++ cleanup_immq 3 + xorl %esi,%esi + .p2align 2 + .L21: +@@ -229,6 +231,8 @@ k6iprod: + + .align 4 + /* void k6vsraw P3((short *p, int n, int bits) */ ++.set h_ones, 0x00010001 ++.set l_ones, 0x00010001 + .globl k6vsraw + .type k6vsraw,@function + k6vsraw: +@@ -242,7 +246,8 @@ k6vsraw: + leal -16(%esi,%eax,2),%edx /* edx = top - 16 */ + emms + movd %ecx,%mm3 +- movq ones,%mm2 ++ load_immq ones, %mm2 ++ cleanup_immq 1 + psllw %mm3,%mm2; psrlw $1,%mm2 + cmpl %edx,%esi; ja .L306 + +@@ -362,22 +367,10 @@ k6vsllw: + .size k6vsllw,.Lfe5-k6vsllw + + +-.section .rodata +- .align 4 +- .type extremes,@object +- .size extremes,8 +-extremes: +- .long 0x80008000 +- .long 0x7fff7fff +- .type ones,@object +- .size ones,8 +-ones: +- .long 0x00010001 +- .long 0x00010001 +- +-.text + .align 4 + /* long k6maxmin (const short *p, int n, short *out) */ ++.set extremes_1, 0x80008000 ++.set extremes_2, 0x7fff7fff + .globl k6maxmin + .type k6maxmin,@function + k6maxmin: +@@ -391,8 +384,10 @@ k6maxmin: + + cmpl %edx,%esi + jbe .L52 +- movd extremes,%mm0 +- movd extremes+4,%mm1 ++ mov $extremes_1, %ecx ++ movd %ecx, %mm0 ++ mov $extremes_2, %ecx ++ movd %ecx, %mm1 + jmp .L58 + + .p2align 2 diff --git a/audacious-plugins-useless-CXXFLAGS.patch b/audacious-plugins-useless-CXXFLAGS.patch new file mode 100644 index 0000000..c543b20 --- /dev/null +++ b/audacious-plugins-useless-CXXFLAGS.patch @@ -0,0 +1,66 @@ +--- src.orig/cue/Makefile ++++ src/cue/Makefile +@@ -11,8 +11,6 @@ + + CFLAGS += $(PICFLAGS) $(GTK_CFLAGS) $(GLIB_CFLAGS) $(PANGO_CFLAGS) $(ARCH_DEFINES) -I../../intl -I../.. + +-CXXFLAGS = $(CFLAGS) +- + LIBADD = $(GTK_LIBS) $(GLIB_LIBS) $(PANGO_LIBS) + + include ../../mk/objective.mk +--- src.orig/m3u/Makefile ++++ src/m3u/Makefile +@@ -11,8 +11,6 @@ + + CFLAGS += $(PICFLAGS) $(GTK_CFLAGS) $(GLIB_CFLAGS) $(PANGO_CFLAGS) $(ARCH_DEFINES) -I../../intl -I../.. + +-CXXFLAGS = $(CFLAGS) +- + LIBADD = $(GTK_LIBS) $(GLIB_LIBS) $(PANGO_LIBS) + + include ../../mk/objective.mk +--- src.orig/mms/Makefile ++++ src/mms/Makefile +@@ -12,8 +12,6 @@ + + CFLAGS += $(PICFLAGS) $(GTK_CFLAGS) $(GLIB_CFLAGS) $(PANGO_CFLAGS) $(MMS_CFLAGS) $(ARCH_DEFINES) -I../../intl -I../.. + +-CXXFLAGS = $(CFLAGS) +- + LIBADD = $(GTK_LIBS) $(GLIB_LIBS) $(PANGO_LIBS) $(MMS_LIBS) + + include ../../mk/objective.mk +--- src.orig/pls/Makefile ++++ src/pls/Makefile +@@ -11,8 +11,6 @@ + + CFLAGS += $(PICFLAGS) $(GTK_CFLAGS) $(GLIB_CFLAGS) $(PANGO_CFLAGS) $(ARCH_DEFINES) -I../../intl -I../.. + +-CXXFLAGS = $(CFLAGS) +- + LIBADD = $(GTK_LIBS) $(GLIB_LIBS) $(PANGO_LIBS) + + include ../../mk/objective.mk +--- src.orig/stdio/Makefile ++++ src/stdio/Makefile +@@ -12,8 +12,6 @@ + + CFLAGS += $(PICFLAGS) $(GTK_CFLAGS) $(GLIB_CFLAGS) $(PANGO_CFLAGS) $(ARCH_DEFINES) -I../../intl -I../.. + +-CXXFLAGS = $(CFLAGS) +- + LIBADD = $(GTK_LIBS) $(GLIB_LIBS) $(PANGO_LIBS) + + include ../../mk/objective.mk +--- src.orig/xspf/Makefile ++++ src/xspf/Makefile +@@ -11,8 +11,6 @@ + + CFLAGS += $(PICFLAGS) $(GTK_CFLAGS) $(GLIB_CFLAGS) $(PANGO_CFLAGS) $(ARCH_DEFINES) $(XML_CPPFLAGS) -I../../intl -I../.. -Wall + +-CXXFLAGS = $(CFLAGS) +- + LIBADD = $(GTK_LIBS) $(GLIB_LIBS) $(PANGO_LIBS) $(XML_LIBS) + + include ../../mk/objective.mk diff --git a/autoconf-2.62-fix-multiline-string.patch b/autoconf-2.62-fix-multiline-string.patch new file mode 100644 index 0000000..e4e3363 --- /dev/null +++ b/autoconf-2.62-fix-multiline-string.patch @@ -0,0 +1,23 @@ +--- autoconf-2.62/lib/autoconf/status.m4.multiline 2008-04-06 01:04:48.000000000 +0200 ++++ autoconf-2.62/lib/autoconf/status.m4 2008-04-19 03:33:27.721188004 +0200 +@@ -1360,16 +1360,16 @@ _ACEOF + cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + # Files that config.status was made for. + m4_ifdef([_AC_SEEN_CONFIG(FILES)], +-[config_files="$ac_config_files" ++[config_files="`echo $ac_config_files`" + ])dnl + m4_ifdef([_AC_SEEN_CONFIG(HEADERS)], +-[config_headers="$ac_config_headers" ++[config_headers="`echo $ac_config_headers`" + ])dnl + m4_ifdef([_AC_SEEN_CONFIG(LINKS)], +-[config_links="$ac_config_links" ++[config_links="`echo $ac_config_links`" + ])dnl + m4_ifdef([_AC_SEEN_CONFIG(COMMANDS)], +-[config_commands="$ac_config_commands" ++[config_commands="`echo $ac_config_commands`" + ])dnl + + _ACEOF diff --git a/baselayout-devfs.patch b/baselayout-devfs.patch new file mode 100644 index 0000000..3df4f6e --- /dev/null +++ b/baselayout-devfs.patch @@ -0,0 +1,29 @@ +Index: branches/baselayout-1_12/sbin/rc +=================================================================== +--- branches/baselayout-1_12/sbin/rc (revision 2250) ++++ branches/baselayout-1_12/sbin/rc (working copy) +@@ -288,9 +288,9 @@ then + esac + + # Check udev prerequisites and kernel params +- if [ "${udev}" = "yes" ] && has_addon udev ++ if [ "${udev}" = "yes" ] + then +- if get_bootparam "noudev" || \ ++ if get_bootparam "noudev" || ! has_addon udev || \ + [ ${devfs_automounted} = "yes" ] || \ + [ "$(get_KV)" -lt "$(KV_to_int '2.6.0')" ] + then +@@ -299,9 +299,10 @@ then + fi + + # Check devfs prerequisites and kernel params +- if [ "${devfs}" = "yes" ] && has_addon devfs ++ if [ "${devfs}" = "yes" ] + then +- if get_bootparam "nodevfs" || [ "${udev}" = "yes" ] ++ if get_bootparam "nodevfs" || [ "${udev}" = "yes" ] || \ ++ ! has_addon devfs + then + devfs="no" + fi diff --git a/bash-3.2-ulimit.patch b/bash-3.2-ulimit.patch new file mode 100644 index 0000000..a0975cb --- /dev/null +++ b/bash-3.2-ulimit.patch @@ -0,0 +1,13 @@ +add missing docs for -e and -r options + +--- builtins/ulimit.def ++++ builtins/ulimit.def +@@ -24,7 +24,7 @@ + $BUILTIN ulimit + $FUNCTION ulimit_builtin + $DEPENDS_ON !_MINIX +-$SHORT_DOC ulimit [-SHacdfilmnpqstuvx] [limit] ++$SHORT_DOC ulimit [-SHacdefilmnpqrstuvx] [limit] + Ulimit provides control over the resources available to processes + started by the shell, on systems that allow such control. If an + option is given, it is interpreted as follows: diff --git a/better-addr.patch b/better-addr.patch new file mode 100644 index 0000000..8f8d0f5 --- /dev/null +++ b/better-addr.patch @@ -0,0 +1,83 @@ +--- arch/blackfin/kernel/traps.c ++++ arch/blackfin/kernel/traps.c +@@ -94,30 +99,63 @@ static int printk_address(unsigned long + char *delim = ":"; + char namebuf[128]; + +- symname = +- kallsyms_lookup(address, &symsize, &offset, &modname, namebuf); +- if (!symname) { +- if (current->mm) { +- if ((address > current->mm->start_code) && +- (address < current->mm->end_code)) { +- return printk("<%08lx>[%s+0x%lx]", +- address, +- current->comm, +- (long)(address - +- current->mm->start_code)); ++ /* look up the address and see if we are in kernel space */ ++ symname = kallsyms_lookup(address, &symsize, &offset, &modname, namebuf); ++ ++ if (symname) { ++ /* yeah! kernel space! */ ++ if (!modname) ++ modname = delim = ""; ++ return printk("<0x%p> { %s%s%s%s + 0x%lX }", ++ (void*)address, delim, modname, delim, symname, (unsigned long)offset); ++ ++ } else { ++ /* looks like we're off in user-land, so let's walk all the ++ * mappings of all our processes and see if we can't be a whee ++ * bit more specific ++ */ ++ struct vm_list_struct *vml; ++ struct task_struct *p; ++ struct mm_struct *mm; ++ ++ write_lock_irq(&tasklist_lock); ++ for_each_process (p) { ++ mm = get_task_mm(p); ++ if (!mm) ++ continue; ++ ++ vml = mm->context.vmlist; ++ while (vml) { ++ struct vm_area_struct *vma = vml->vma; ++ ++ if ((address >= vma->vm_start) && (address < vma->vm_end)) { ++ char *name = p->comm; ++ struct file *file = vma->vm_file; ++ if (file) { ++ char _tmpbuf[256]; ++ name = d_path(file->f_dentry, file->f_vfsmnt, _tmpbuf, sizeof(_tmpbuf)); ++ } ++ ++ write_unlock_irq(&tasklist_lock); ++ return printk("<0x%p> [ %s + 0x%lX ]", ++ (void*)address, ++ name, ++ (unsigned long)((address - vma->vm_start) + (vma->vm_pgoff << PAGE_SHIFT))); ++ } ++ ++ vml = vml->next; + } + } +- return printk("[<%08lx>]", address); ++ write_unlock_irq(&tasklist_lock); + } +- if (!modname) +- modname = delim = ""; +- return printk("<%08lx>{%s%s%s%s+0x%lx}", +- address, delim, modname, delim, symname, (long)offset); ++ ++ /* we were unable to find this address anywhere */ ++ return printk("[<0x%p>]", (void*)address); + } + #else + static int printk_address(unsigned long address) + { +- return printk("[<%08lx>]", address); ++ return printk("[<0x%p>]", (void*)address); + } + #endif + diff --git a/bfin-alsa-ad1836-cleanup.patch b/bfin-alsa-ad1836-cleanup.patch new file mode 100644 index 0000000..fa43811 --- /dev/null +++ b/bfin-alsa-ad1836-cleanup.patch @@ -0,0 +1,226 @@ +Index: ad1836.c +=================================================================== +RCS file: /usr/local/src/blackfin/rsync/uclinux533/uClinux-dist/linux-2.6.x/sound/blackfin/ad1836.c,v +retrieving revision 1.57 +diff -u -p -r1.57 ad1836.c +--- ad1836.c 29 Aug 2006 09:36:12 -0000 1.57 ++++ ad1836.c 8 Sep 2006 23:25:58 -0000 +@@ -917,6 +917,7 @@ static int snd_ad1836_playback_close(snd + } + } + #else ++ snd_printk_marker(); + chip->tx_substream = NULL; + #endif + +@@ -946,11 +947,13 @@ static int snd_ad1836_hw_params(snd_pcm_ + */ + #ifdef CONFIG_SND_BLACKFIN_AD1836_TDM + +-#ifdef MULTI_SUBSTREAM ++# ifdef MULTI_SUBSTREAM + substream_info_t *sub_info = NULL; + ad1836_t *chip = snd_pcm_substream_chip(substream); + int index = find_substream(chip, substream, &sub_info); + ++ snd_printk_marker(); ++ + if (chip->rx_substream == substream) { + substream->runtime->dma_area = chip->rx_dma_buf; + substream->runtime->dma_addr = (unsigned int)chip->rx_dma_buf; +@@ -961,18 +964,19 @@ static int snd_ad1836_hw_params(snd_pcm_ + substream->runtime->dma_bytes = AD1836_BUF_SZ; + } + +-#else ++# else ++ snd_printk_marker(); + if (snd_pcm_lib_malloc_pages(substream, AD1836_BUF_SZ) < 0) + return -ENOMEM; +-#endif ++# endif + + #else ++ snd_printk_marker(); + if (snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hwparams)) < 0) + return -ENOMEM; + #endif + + return 0; +- + } + + static int snd_ad1836_hw_free(snd_pcm_substream_t * substream) +@@ -1080,6 +1084,8 @@ static int snd_ad1836_playback_trigger(s + snd_assert((index >= 0 && index <= 2 && sub_info), return -EINVAL); + #endif + ++ snd_printk_marker(); ++ + spin_lock(&chip->ad1836_lock); + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: +@@ -1121,6 +1127,8 @@ static int snd_ad1836_capture_trigger(sn + { + ad1836_t *chip = snd_pcm_substream_chip(substream); + ++ snd_printk_marker(); ++ + spin_lock(&chip->ad1836_lock); + snd_assert(substream == chip->rx_substream, return -EINVAL); + switch (cmd) { +@@ -1158,6 +1166,8 @@ static snd_pcm_uframes_t snd_ad1836_play + #endif + size_t frames = diff / bytes_per_frame; + ++ snd_printk_marker(); ++ + #ifdef MULTI_SUBSTREAM + find_substream(chip, substream, &sub_info); + frames = (frames + DMA_BUFFER_FRAMES - sub_info->dma_offset) % \ +@@ -1197,8 +1207,10 @@ static snd_pcm_uframes_t snd_ad1836_capt + #endif + size_t frames = diff / bytes_per_frame; + ++ snd_printk_marker(); ++ + #ifdef CONFIG_SND_DEBUG_CURRPTR +- snd_printk(KERN_INFO " capture pos: 0x%04x / %lx\n", frames, ++ snd_printk(KERN_DEBUG "capture pos: 0x%04x / %lx\n", frames, + runtime->buffer_size); + #endif + +@@ -1399,7 +1411,7 @@ static int snd_ad1836_playback_silence(s + frames_to_bytes(substream->runtime, count)); + #endif + #ifdef CONFIG_SND_DEBUG_CURRPTR +- snd_printk(KERN_INFO "silence: pos %x, count %x\n", (uint)pos, (uint)count); ++ snd_printk(KERN_DEBUG "silence: pos %x, count %x\n", (uint)pos, (uint)count); + #endif + + return 0; +@@ -1411,7 +1423,7 @@ static int snd_ad1836_capture_silence(sn + unsigned char *buf = substream->runtime->dma_area; + + #ifdef CONFIG_SND_DEBUG +- snd_printk(KERN_INFO "silence: pos %x, count %x\n", ++ snd_printk(KERN_DEBUG "silence: pos %x, count %x\n", + (uint)pos, (uint)count); + #endif + #ifdef CONFIG_SND_BLACKFIN_AD1836_TDM +@@ -1457,6 +1469,8 @@ static snd_pcm_ops_t snd_ad1836_capture_ + *************************************************************/ + static int snd_ad1836_stop(struct snd_ad1836 *chip) + { ++ snd_printk_marker(); ++ + snd_ad1836_set_register(chip, DAC_CTRL_2, DAC_MUTE_MASK, DAC_MUTE_MASK); + snd_ad1836_set_register(chip, ADC_CTRL_2, ADC_MUTE_MASK, ADC_MUTE_MASK); + snd_ad1836_set_register(chip, DAC_CTRL_1, DAC_PWRDWN, DAC_PWRDWN); +@@ -1469,6 +1483,8 @@ static int snd_ad1836_dev_free(snd_devic + { + struct snd_ad1836 *chip = (ad1836_t *)device->device_data; + ++ snd_printk_marker(); ++ + #ifdef MULTI_SUBSTREAM + dma_free_coherent(NULL, AD1836_BUF_SZ, chip->rx_dma_buf, 0); + dma_free_coherent(NULL, AD1836_BUF_SZ, chip->tx_dma_buf, 0); +@@ -1514,7 +1530,7 @@ static int snd_bf53x_ad1836_reset(ad1836 + + bfin_write(FlashA_PortA_Dir,0x1); /* configure flag as an output pin */ + +- snd_printk(KERN_INFO "resetting ezkit 1836 using flash flag pin\n"); ++ snd_printk(KERN_INFO "resetting ezkit using flash flag pin\n"); + bfin_write(FlashA_PortA_Data,0x0); /* reset is active low */ + udelay(1); /* hold low */ + +@@ -1532,6 +1548,8 @@ static int snd_ad1836_configure(ad1836_t + int err = 0; + struct bf53x_sport *sport= chip->sport; + ++ snd_printk_marker(); ++ + snd_bf53x_ad1836_reset(chip); + + /* see if we are connected by writing (preferably something useful) +@@ -1592,6 +1610,8 @@ static int snd_ad1836_configure(ad1836_t + int err = 0; + struct bf53x_sport *sport= chip->sport; + ++ snd_printk_marker(); ++ + snd_bf53x_ad1836_reset(chip); + + /* Power up DAC and ADC */ +@@ -1672,7 +1692,7 @@ static void snd_ad1836_dma_tx(void *data + + static void snd_ad1836_sport_err(void *data) + { +- printk(KERN_ERR "%s: err happened on sport\n", __FUNCTION__); ++ printk(KERN_ERR DRIVER_NAME ":%s: err happened on sport\n", __FUNCTION__); + } + + static void snd_ad1836_proc_registers_read(snd_info_entry_t * entry, +@@ -1742,6 +1762,8 @@ static int __devinit snd_ad1836_pcm(stru + struct snd_pcm *pcm; + int err = 0; + ++ snd_printk_marker(); ++ + #ifdef MULTI_SUBSTREAM + /* 3 playback and 1 capture substream, 2 channels each */ + err = snd_pcm_new(ad1836->card, PCM_NAME, 0, 3, 1, &pcm); +@@ -1779,12 +1801,16 @@ static int __devinit snd_ad1836_probe(st + dma_addr_t addr; + #endif + ++ snd_printk_marker(); ++ + if (device != NULL) + return -ENOENT; + + card = snd_card_new(-1, NULL, THIS_MODULE, sizeof(struct snd_ad1836)); +- if (card == NULL) ++ if (card == NULL) { ++ snd_printdd(KERN_DEBUG "%s: snd_card_new() failed\n", __FUNCTION__); + return -ENOMEM; ++ } + + ad1836 = card->private_data; + ad1836->card = card; +@@ -1810,7 +1836,7 @@ static int __devinit snd_ad1836_probe(st + ad1836->rx_dma_buf = dma_alloc_coherent(NULL, AD1836_BUF_SZ, &addr, 0); + ad1836->tx_dma_buf = dma_alloc_coherent(NULL, AD1836_BUF_SZ, &addr, 0); + if (!ad1836->rx_dma_buf || !ad1836->tx_dma_buf) { +- printk(KERN_ERR"Failed to allocate DMA buffer\n"); ++ printk(KERN_ERR DRIVER_NAME ": Failed to allocate DMA buffer\n"); + return -ENOMEM; + } + #endif +@@ -1820,6 +1846,7 @@ static int __devinit snd_ad1836_probe(st + SPORT_DMA_TX, snd_ad1836_dma_tx, + SPORT_IRQ_ERR, snd_ad1836_sport_err, ad1836)) + == NULL) { ++ printk(KERN_ERR DRIVER_NAME ": Failed to find device on sport\n"); + err = -ENODEV; + goto __nodev; + } +@@ -1891,6 +1918,8 @@ static int snd_ad1836_suspend(struct pla + struct snd_card *card = platform_get_drvdata(pdev); + struct snd_ad1836 *ad1836 = card->private_data; + ++ snd_printk_marker(); ++ + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + snd_pcm_suspend_all(ad1836->pcm); + return 0; +@@ -1900,6 +1929,8 @@ static int snd_ad1836_resume(struct plat + { + struct snd_card *card = platform_get_drvdata(pdev); + ++ snd_printk_marker(); ++ + snd_power_change_state(card, SNDRV_CTL_POWER_D0); + return 0; + } diff --git a/bfin-alsa-lib.patch b/bfin-alsa-lib.patch new file mode 100644 index 0000000..d76e8a0 --- /dev/null +++ b/bfin-alsa-lib.patch @@ -0,0 +1,135 @@ +diff -r 46221e609f45 configure.in +--- a/configure.in Wed Sep 06 14:39:01 2006 +0200 ++++ b/configure.in Thu Sep 07 20:45:24 2006 -0400 +@@ -34,6 +34,7 @@ fi + + + AC_PROG_CC ++AC_PROG_CPP + AC_PROG_INSTALL + AC_PROG_LN_S + AC_DISABLE_STATIC +@@ -104,6 +105,16 @@ else + AC_MSG_RESULT(no) + fi + AM_CONDITIONAL(VERSIONED_SYMBOLS, test x$versioned = xyes) ++ ++dnl See if toolchain has a custom prefix for symbols ... ++AC_MSG_CHECKING(for custom symbol prefixes) ++SYMBOL_PREFIX=` \ ++ echo "PREFIX=__USER_LABEL_PREFIX__" \ ++ | ${CPP-${CC-gcc} -E} - 2>&1 \ ++ | ${EGREP-grep} "^PREFIX=" \ ++ | ${SED-sed} "s:^PREFIX=::"` ++AC_DEFINE_UNQUOTED([__SYMBOL_PREFIX], "$SYMBOL_PREFIX", [Toolchain Symbol Prefix]) ++AC_MSG_RESULT($SYMBOL_PREFIX) + + dnl Check for debug... + AC_MSG_CHECKING(for debug) +diff -r 46221e609f45 include/alsa-symbols.h +--- a/include/alsa-symbols.h Wed Sep 06 14:39:01 2006 +0200 ++++ b/include/alsa-symbols.h Thu Sep 07 20:45:45 2006 -0400 +@@ -22,6 +22,14 @@ + #ifndef __ALSA_SYMBOLS_H + #define __ALSA_SYMBOLS_H + ++#ifdef __USER_LABEL_PREFIX__ ++# define __SYMBOL_PREFIX __USER_LABEL_PREFIX__ ++#else ++# define __SYMBOL_PREFIX ++#endif ++ ++#include "local.h" ++ + #if defined(PIC) && defined(VERSIONED_SYMBOLS) /* might be also configurable */ + #define USE_VERSIONED_SYMBOLS + #endif +@@ -31,16 +39,16 @@ + + #ifdef __powerpc64__ + # define symbol_version(real, name, version) \ +- __asm__ (".symver " #real "," #name "@" #version); \ +- __asm__ (".symver ." #real ",." #name "@" #version) ++ __asm__ (".symver " ASM_NAME(#real) "," ASM_NAME(#name) "@" #version); \ ++ __asm__ (".symver ." ASM_NAME(#real) ",." ASM_NAME(#name) "@" #version) + # define default_symbol_version(real, name, version) \ +- __asm__ (".symver " #real "," #name "@@" #version); \ +- __asm__ (".symver ." #real ",." #name "@@" #version) ++ __asm__ (".symver " ASM_NAME(#real) "," ASM_NAME(#name) "@@" #version); \ ++ __asm__ (".symver ." ASM_NAME(#real) ",." ASM_NAME(#name) "@@" #version) + #else + # define symbol_version(real, name, version) \ +- __asm__ (".symver " #real "," #name "@" #version) ++ __asm__ (".symver " ASM_NAME(#real) "," ASM_NAME(#name) "@" #version) + # define default_symbol_version(real, name, version) \ +- __asm__ (".symver " #real "," #name "@@" #version) ++ __asm__ (".symver " ASM_NAME(#real) "," ASM_NAME(#name) "@@" #version) + #endif + + #ifdef USE_VERSIONED_SYMBOLS +@@ -52,19 +60,19 @@ + #define use_symbol_version(real, name, version) /* nothing */ + #ifdef __powerpc64__ + #define use_default_symbol_version(real, name, version) \ +- __asm__ (".weak " #name); \ +- __asm__ (".weak ." #name); \ +- __asm__ (".set " #name "," #real); \ +- __asm__ (".set ." #name ",." #real) ++ __asm__ (".weak " ASM_NAME(#name)); \ ++ __asm__ (".weak ." ASM_NAME(#name)); \ ++ __asm__ (".set " ASM_NAME(#name) "," ASM_NAME(#real)); \ ++ __asm__ (".set ." ASM_NAME(#name) ",." ASM_NAME(#real)) + #else + #if defined(__alpha__) || defined(__mips__) + #define use_default_symbol_version(real, name, version) \ +- __asm__ (".weak " #name); \ +- __asm__ (#name " = " #real) ++ __asm__ (".weak " ASM_NAME(#name)); \ ++ __asm__ (ASM_NAME(#name) " = " ASM_NAME(#real)) + #else + #define use_default_symbol_version(real, name, version) \ +- __asm__ (".weak " #name); \ +- __asm__ (".set " #name "," #real) ++ __asm__ (".weak " ASM_NAME(#name)); \ ++ __asm__ (".set " ASM_NAME(#name) "," ASM_NAME(#real)) + #endif + #endif + #endif +diff -r 46221e609f45 include/local.h +--- a/include/local.h Wed Sep 06 14:39:01 2006 +0200 ++++ b/include/local.h Thu Sep 07 20:45:45 2006 -0400 +@@ -192,6 +192,9 @@ extern snd_lib_error_handler_t snd_err_m + + /* When a reference to SYMBOL is encountered, the linker will emit a + warning message MSG. */ ++ ++#define ASM_NAME(name) __SYMBOL_PREFIX name ++ + #ifdef HAVE_GNU_LD + # ifdef HAVE_ELF + +@@ -210,19 +213,19 @@ extern snd_lib_error_handler_t snd_err_m + section attributes on what looks like a comment to the assembler. */ + # ifdef HAVE_SECTION_QUOTES + # define link_warning(symbol, msg) \ +- __make_section_unallocated (".gnu.warning." #symbol) \ ++ __make_section_unallocated (".gnu.warning." ASM_NAME(#symbol)) \ + static const char __evoke_link_warning_##symbol[] \ +- __attribute__ ((section (".gnu.warning." #symbol "\"\n\t#\""))) = msg; ++ __attribute__ ((section (".gnu.warning." ASM_NAME(#symbol) "\"\n\t#\""))) = msg; + # else + # define link_warning(symbol, msg) \ +- __make_section_unallocated (".gnu.warning." #symbol) \ ++ __make_section_unallocated (".gnu.warning." ASM_NAME(#symbol)) \ + static const char __evoke_link_warning_##symbol[] \ +- __attribute__ ((section (".gnu.warning." #symbol "\n\t#"))) = msg; ++ __attribute__ ((section (".gnu.warning." ASM_NAME(#symbol) "\n\t#"))) = msg; + # endif + # else + # define link_warning(symbol, msg) \ + asm (".stabs \"" msg "\",30,0,0,0\n\t" \ +- ".stabs \"" __SYMBOL_PREFIX #symbol "\",1,0,0,0\n"); ++ ".stabs \"" ASM_NAME(#symbol) "\",1,0,0,0\n"); + # endif + #else + /* We will never be heard; they will all die horribly. */ diff --git a/bfin-binutils-parallel-check.patch b/bfin-binutils-parallel-check.patch new file mode 100644 index 0000000..8348420 --- /dev/null +++ b/bfin-binutils-parallel-check.patch @@ -0,0 +1,16 @@ +--- gas/testsuite/gas/bfin/expected_errors.l ++++ gas/testsuite/gas/bfin/expected_errors.l +@@ -8,3 +8,4 @@ + .*:10: Error: Bad constant value. + .*:11: Error: Bad constant value. + .*:13: Error: Dregs expected. Input text was R3.L. ++.*:16: Error: Source multiplication register mismatch. Input text was ). +--- gas/testsuite/gas/bfin/expected_errors.s ++++ gas/testsuite/gas/bfin/expected_errors.s +@@ -11,3 +11,6 @@ + CC = R3 <= 8; + + A1 -= M2.h * R3.L, A0 -= M2.l * R3.L; ++ ++ /* http://blackfin.uclinux.org/tracker/?func=detail&atid=145&aid=1321&group_id=18 */ ++ R1.H = (A1=R7.L*R5.L) , A0 += R1.L*R0.L (IS); diff --git a/bfin-cleanup-reboot.patch b/bfin-cleanup-reboot.patch new file mode 100644 index 0000000..1f8da90 --- /dev/null +++ b/bfin-cleanup-reboot.patch @@ -0,0 +1,602 @@ +Index: include/asm-blackfin/reboot.h +=================================================================== +--- include/asm-blackfin/reboot.h (revision 0) ++++ include/asm-blackfin/reboot.h (revision 0) +@@ -0,0 +1,20 @@ ++/* ++ * include/asm-blackfin/reboot.h - shutdown/reboot header ++ * ++ * Copyright 2004-2007 Analog Devices Inc. ++ * ++ * Licensed under the GPL-2 or later. ++ */ ++ ++#ifndef __ASM_REBOOT_H__ ++#define __ASM_REBOOT_H__ ++ ++/* optional board specific hooks */ ++extern void native_machine_restart(char *cmd); ++extern void native_machine_halt(void); ++extern void native_machine_power_off(void); ++ ++/* common reboot workarounds */ ++extern void bfin_gpio_reset_spi0_ssel1(void); ++ ++#endif +Index: arch/blackfin/kernel/process.c +=================================================================== +--- arch/blackfin/kernel/process.c (revision 3549) ++++ arch/blackfin/kernel/process.c (working copy) +@@ -132,31 +132,6 @@ + } + } + +-void machine_restart(char *__unused) +-{ +-#if defined(CONFIG_BFIN_ICACHE) +- bfin_write_IMEM_CONTROL(0x01); +- SSYNC(); +-#endif +- bfin_reset(); +- /* Dont do anything till the reset occurs */ +- while (1) { +- SSYNC(); +- } +-} +- +-void machine_halt(void) +-{ +- for (;;) +- asm volatile ("idle"); +-} +- +-void machine_power_off(void) +-{ +- for (;;) +- asm volatile ("idle"); +-} +- + void show_regs(struct pt_regs *regs) + { + printk(KERN_NOTICE "\n"); +Index: arch/blackfin/kernel/reboot.c +=================================================================== +--- arch/blackfin/kernel/reboot.c (revision 0) ++++ arch/blackfin/kernel/reboot.c (revision 0) +@@ -0,0 +1,73 @@ ++/* ++ * arch/blackfin/kernel/reboot.c - handle shutdown/reboot ++ * ++ * Copyright 2004-2007 Analog Devices Inc. ++ * ++ * Licensed under the GPL-2 or later. ++ */ ++ ++#include ++#include ++#include ++ ++static void bfin_spin_forever(void) ++{ ++ while (1) ++ asm volatile ("idle"); ++} ++ ++/* A system soft reset makes external memory unusable ++ * so force this function into L1. ++ */ ++__attribute__((l1_text)) ++void bfin_reset(void) ++{ ++ /* force BMODE and disable Core B (as needed) */ ++ bfin_write_SYSCR(0x20); ++ while (1) { ++ /* initiate system soft reset with magic 0x7 */ ++ bfin_write_SWRST(0x7); ++ SSYNC(); ++ /* clear system soft reset */ ++ bfin_write_SWRST(0); ++ SSYNC(); ++ /* issue core reset */ ++ asm("raise 1"); ++ } ++} ++ ++__attribute__((weak)) ++void native_machine_restart(char *cmd) ++{ ++} ++ ++void machine_restart(char *cmd) ++{ ++ native_machine_restart(cmd); ++ local_irq_disable(); ++ bfin_reset(); ++} ++ ++__attribute__((weak)) ++void native_machine_halt(void) ++{ ++ local_irq_disable(); ++ bfin_spin_forever(); ++} ++ ++void machine_halt(void) ++{ ++ native_machine_halt(); ++} ++ ++__attribute__((weak)) ++void native_machine_power_off(void) ++{ ++ local_irq_disable(); ++ bfin_spin_forever(); ++} ++ ++void machine_power_off(void) ++{ ++ native_machine_power_off(); ++} +Index: arch/blackfin/kernel/bfin_gpio.c +=================================================================== +--- arch/blackfin/kernel/bfin_gpio.c (revision 3549) ++++ arch/blackfin/kernel/bfin_gpio.c (working copy) +@@ -80,6 +80,7 @@ + * GPIO_47 PH15 PF47 + */ + ++#include + #include + #include + #include +@@ -888,3 +889,20 @@ + local_irq_restore(flags); + } + EXPORT_SYMBOL(gpio_direction_output); ++ ++/* If we are booting from SPI and our board lacks a strong enough pull up, ++ * the core can reset and execute the bootrom faster than the resistor can ++ * pull the signal logically high. To work around this (common) error in ++ * board design, we explicitly set the pin back to GPIO mode, force /CS ++ * high, and wait for the electrons to do their thing. ++ * ++ * This function only makes sense to be called from reset code, but it ++ * lives here as we need to force all the GPIO states w/out going through ++ * BUG() checks and such. ++ */ ++void bfin_gpio_reset_spi0_ssel1(void) ++{ ++ port_setup(P_SPI0_SSEL1, GPIO_USAGE); ++ gpio_bankb[gpio_bank(P_SPI0_SSEL1)]->data_set = gpio_bit(P_SPI0_SSEL1); ++ udelay(1); ++} +Index: arch/blackfin/kernel/Makefile +=================================================================== +--- arch/blackfin/kernel/Makefile (revision 3549) ++++ arch/blackfin/kernel/Makefile (working copy) +@@ -7,7 +7,7 @@ + obj-y := \ + entry.o process.o bfin_ksyms.o ptrace.o setup.o signal.o \ + sys_bfin.o time.o traps.o irqchip.o dma-mapping.o flat.o \ +- fixed_code.o cplbinit.o cacheinit.o ++ fixed_code.o cplbinit.o cacheinit.o reboot.o + + obj-$(CONFIG_BF53x) += bfin_gpio.o + obj-$(CONFIG_BF561) += bfin_gpio.o +Index: arch/blackfin/mach-bf533/head.S +=================================================================== +--- arch/blackfin/mach-bf533/head.S (revision 3549) ++++ arch/blackfin/mach-bf533/head.S (working copy) +@@ -459,66 +459,6 @@ + ENDPROC(_start_dma_code) + #endif /* CONFIG_BFIN_KERNEL_CLOCK */ + +-ENTRY(_bfin_reset) +- /* No more interrupts to be handled*/ +- CLI R6; +- SSYNC; +- +-#if defined(CONFIG_BFIN_SHARED_FLASH_ENET) +- p0.h = hi(FIO_INEN); +- p0.l = lo(FIO_INEN); +- r0.l = ~(1 << CONFIG_ENET_FLASH_PIN); +- w[p0] = r0.l; +- +- p0.h = hi(FIO_DIR); +- p0.l = lo(FIO_DIR); +- r0.l = (1 << CONFIG_ENET_FLASH_PIN); +- w[p0] = r0.l; +- +- p0.h = hi(FIO_FLAG_C); +- p0.l = lo(FIO_FLAG_C); +- r0.l = (1 << CONFIG_ENET_FLASH_PIN); +- w[p0] = r0.l; +-#endif +- +- /* Clear the IMASK register */ +- p0.h = hi(IMASK); +- p0.l = lo(IMASK); +- r0 = 0x0; +- [p0] = r0; +- +- /* Clear the ILAT register */ +- p0.h = hi(ILAT); +- p0.l = lo(ILAT); +- r0 = [p0]; +- [p0] = r0; +- SSYNC; +- +- /* make sure SYSCR is set to use BMODE */ +- P0.h = hi(SYSCR); +- P0.l = lo(SYSCR); +- R0.l = 0x0; +- W[P0] = R0.l; +- SSYNC; +- +- /* issue a system soft reset */ +- P1.h = hi(SWRST); +- P1.l = lo(SWRST); +- R1.l = 0x0007; +- W[P1] = R1; +- SSYNC; +- +- /* clear system soft reset */ +- R0.l = 0x0000; +- W[P0] = R0; +- SSYNC; +- +- /* issue core reset */ +- raise 1; +- +- RTS; +-ENDPROC(_bfin_reset) +- + #if CONFIG_DEBUG_KERNEL_START + debug_kernel_start_trap: + /* Set up a temp stack in L1 - SDRAM might not be working */ +Index: arch/blackfin/mach-bf533/boards/stamp.c +=================================================================== +--- arch/blackfin/mach-bf533/boards/stamp.c (revision 3549) ++++ arch/blackfin/mach-bf533/boards/stamp.c (working copy) +@@ -41,6 +41,7 @@ + #include + #include + #include ++#include + + /* + * Name the Board for the /proc/cpuinfo +@@ -424,3 +425,13 @@ + } + + arch_initcall(stamp_init); ++ ++void native_machine_restart(char *cmd) ++{ ++#if defined(CONFIG_BFIN_SHARED_FLASH_ENET) ++# define BIT_TO_SET (1 << CONFIG_ENET_FLASH_PIN) ++ bfin_write_FIO_INEN(~BIT_TO_SET); ++ bfin_write_FIO_DIR(BIT_TO_SET); ++ bfin_write_FIO_FLAG_C(BIT_TO_SET); ++#endif ++} +Index: arch/blackfin/mach-bf561/head.S +=================================================================== +--- arch/blackfin/mach-bf561/head.S (revision 3549) ++++ arch/blackfin/mach-bf561/head.S (working copy) +@@ -406,66 +406,6 @@ + ENDPROC(_start_dma_code) + #endif /* CONFIG_BFIN_KERNEL_CLOCK */ + +-ENTRY(_bfin_reset) +- /* No more interrupts to be handled*/ +- CLI R6; +- SSYNC; +- +-#if defined(CONFIG_BFIN_SHARED_FLASH_ENET) +- p0.h = hi(FIO_INEN); +- p0.l = lo(FIO_INEN); +- r0.l = ~(PF1 | PF0); +- w[p0] = r0.l; +- +- p0.h = hi(FIO_DIR); +- p0.l = lo(FIO_DIR); +- r0.l = (PF1 | PF0); +- w[p0] = r0.l; +- +- p0.h = hi(FIO_FLAG_C); +- p0.l = lo(FIO_FLAG_C); +- r0.l = (PF1 | PF0); +- w[p0] = r0.l; +-#endif +- +- /* Clear the IMASK register */ +- p0.h = hi(IMASK); +- p0.l = lo(IMASK); +- r0 = 0x0; +- [p0] = r0; +- +- /* Clear the ILAT register */ +- p0.h = hi(ILAT); +- p0.l = lo(ILAT); +- r0 = [p0]; +- [p0] = r0; +- SSYNC; +- +- /* make sure SYSCR is set to use BMODE */ +- P0.h = hi(SYSCR); +- P0.l = lo(SYSCR); +- R0.l = 0x20; /* on BF561, disable core b */ +- W[P0] = R0.l; +- SSYNC; +- +- /* issue a system soft reset */ +- P1.h = hi(SWRST); +- P1.l = lo(SWRST); +- R1.l = 0x0007; +- W[P1] = R1; +- SSYNC; +- +- /* clear system soft reset */ +- R0.l = 0x0000; +- W[P0] = R0; +- SSYNC; +- +- /* issue core reset */ +- raise 1; +- +- RTS; +-ENDPROC(_bfin_reset) +- + .data + + /* +Index: arch/blackfin/mach-bf537/head.S +=================================================================== +--- arch/blackfin/mach-bf537/head.S (revision 3549) ++++ arch/blackfin/mach-bf537/head.S (working copy) +@@ -478,85 +478,6 @@ + ENDPROC(_start_dma_code) + #endif /* CONFIG_BFIN_KERNEL_CLOCK */ + +-ENTRY(_bfin_reset) +- /* No more interrupts to be handled*/ +- CLI R6; +- SSYNC; +- +-#if defined(CONFIG_MTD_M25P80) +- /* +- * The following code fix the SPI flash reboot issue, +- * /CS signal of the chip which is using PF10 return to GPIO mode +- */ +- p0.h = hi(PORTF_FER); +- p0.l = lo(PORTF_FER); +- r0.l = 0x0000; +- w[p0] = r0.l; +- SSYNC; +- +- /* /CS return to high */ +- p0.h = hi(PORTFIO); +- p0.l = lo(PORTFIO); +- r0.l = 0xFFFF; +- w[p0] = r0.l; +- SSYNC; +- +- /* Delay some time, This is necessary */ +- r1.h = 0; +- r1.l = 0x400; +- p1 = r1; +- lsetup (.L_delay_lab1, .L_delay_lab1_end) lc1 = p1; +-.L_delay_lab1: +- r0.h = 0; +- r0.l = 0x8000; +- p0 = r0; +- lsetup (.L_delay_lab0, .L_delay_lab0_end) lc0 = p0; +-.L_delay_lab0: +- nop; +-.L_delay_lab0_end: +- nop; +-.L_delay_lab1_end: +- nop; +-#endif +- +- /* Clear the IMASK register */ +- p0.h = hi(IMASK); +- p0.l = lo(IMASK); +- r0 = 0x0; +- [p0] = r0; +- +- /* Clear the ILAT register */ +- p0.h = hi(ILAT); +- p0.l = lo(ILAT); +- r0 = [p0]; +- [p0] = r0; +- SSYNC; +- +- /* make sure SYSCR is set to use BMODE */ +- P0.h = hi(SYSCR); +- P0.l = lo(SYSCR); +- R0.l = 0x0; +- W[P0] = R0.l; +- SSYNC; +- +- /* issue a system soft reset */ +- P1.h = hi(SWRST); +- P1.l = lo(SWRST); +- R1.l = 0x0007; +- W[P1] = R1; +- SSYNC; +- +- /* clear system soft reset */ +- R0.l = 0x0000; +- W[P0] = R0; +- SSYNC; +- +- /* issue core reset */ +- raise 1; +- +- RTS; +-ENDPROC(_bfin_reset) +- + .data + + /* +Index: arch/blackfin/mach-bf537/boards/stamp.c +=================================================================== +--- arch/blackfin/mach-bf537/boards/stamp.c (revision 3549) ++++ arch/blackfin/mach-bf537/boards/stamp.c (working copy) +@@ -43,6 +43,7 @@ + #include + #include + #include ++#include + #include + + /* +@@ -714,3 +715,10 @@ + } + + arch_initcall(stamp_init); ++ ++void native_machine_restart(char *cmd) ++{ ++ /* workaround reboot hang when booting from SPI */ ++ if ((bfin_read_SYSCR() & 0x7) == 0x3) ++ bfin_gpio_reset_spi0_ssel1(); ++} +Index: arch/blackfin/mach-bf548/head.S +=================================================================== +--- arch/blackfin/mach-bf548/head.S (revision 3549) ++++ arch/blackfin/mach-bf548/head.S (working copy) +@@ -378,131 +378,6 @@ + RTS; + #endif /* CONFIG_BFIN_KERNEL_CLOCK */ + +-ENTRY(_bfin_reset) +- /* No more interrupts to be handled*/ +- CLI R6; +- SSYNC; +- +-#if 0 /* Need to determine later if this is here necessary for BF54x */ +-#if defined(CONFIG_MTD_M25P80) +-/* +- * The following code fix the SPI flash reboot issue, +- * /CS signal of the chip which is using PF10 return to GPIO mode +- */ +- p0.h = hi(PORTF_FER); +- p0.l = lo(PORTF_FER); +- r0.l = 0x0000; +- w[p0] = r0.l; +- SSYNC; +- +-/* /CS return to high */ +- p0.h = hi(PORTFIO); +- p0.l = lo(PORTFIO); +- r0.l = 0xFFFF; +- w[p0] = r0.l; +- SSYNC; +- +-/* Delay some time, This is necessary */ +- r1.h = 0; +- r1.l = 0x400; +- p1 = r1; +- lsetup (_delay_lab1,_delay_lab1_end ) lc1 = p1; +-_delay_lab1: +- r0.h = 0; +- r0.l = 0x8000; +- p0 = r0; +- lsetup (_delay_lab0,_delay_lab0_end ) lc0 = p0; +-_delay_lab0: +- nop; +-_delay_lab0_end: +- nop; +-_delay_lab1_end: +- nop; +-#endif +-#endif +- +- /* Clear the bits 13-15 in SWRST if they werent cleared */ +- p0.h = hi(SWRST); +- p0.l = lo(SWRST); +- csync; +- r0.l = w[p0]; +- +- /* Clear the IMASK register */ +- p0.h = hi(IMASK); +- p0.l = lo(IMASK); +- r0 = 0x0; +- [p0] = r0; +- +- /* Clear the ILAT register */ +- p0.h = hi(ILAT); +- p0.l = lo(ILAT); +- r0 = [p0]; +- [p0] = r0; +- SSYNC; +- +- /* Disable the WDOG TIMER */ +- p0.h = hi(WDOG_CTL); +- p0.l = lo(WDOG_CTL); +- r0.l = 0xAD6; +- w[p0] = r0.l; +- SSYNC; +- +- /* Clear the sticky bit incase it is already set */ +- p0.h = hi(WDOG_CTL); +- p0.l = lo(WDOG_CTL); +- r0.l = 0x8AD6; +- w[p0] = r0.l; +- SSYNC; +- +- /* Program the count value */ +- R0.l = 0x100; +- R0.h = 0x0; +- P0.h = hi(WDOG_CNT); +- P0.l = lo(WDOG_CNT); +- [P0] = R0; +- SSYNC; +- +- /* Program WDOG_STAT if necessary */ +- P0.h = hi(WDOG_CTL); +- P0.l = lo(WDOG_CTL); +- R0 = W[P0](Z); +- CC = BITTST(R0,1); +- if !CC JUMP .LWRITESTAT; +- CC = BITTST(R0,2); +- if !CC JUMP .LWRITESTAT; +- JUMP .LSKIP_WRITE; +- +-.LWRITESTAT: +- /* When watch dog timer is enabled, +- * a write to STAT will load the contents of CNT to STAT +- */ +- R0 = 0x0000(z); +- P0.h = hi(WDOG_STAT); +- P0.l = lo(WDOG_STAT) +- [P0] = R0; +- SSYNC; +- +-.LSKIP_WRITE: +- /* Enable the reset event */ +- P0.h = hi(WDOG_CTL); +- P0.l = lo(WDOG_CTL); +- R0 = W[P0](Z); +- BITCLR(R0,1); +- BITCLR(R0,2); +- W[P0] = R0.L; +- SSYNC; +- NOP; +- +- /* Enable the wdog counter */ +- R0 = W[P0](Z); +- BITCLR(R0,4); +- W[P0] = R0.L; +- SSYNC; +- +- IDLE; +- +- RTS; +- + .data + + /* diff --git a/bfin-gc-sections.patch b/bfin-gc-sections.patch new file mode 100644 index 0000000..14bb78a --- /dev/null +++ b/bfin-gc-sections.patch @@ -0,0 +1,32 @@ +--- arch/blackfin/Kconfig ++++ arch/blackfin/Kconfig +@@ -398,6 +398,14 @@ config I_ENTRY_L1 + If enabled interrupt entry code (STORE/RESTORE CONTEXT) is linked + into L1 instruction memory.(less latency) + ++config GC_SECTIONS ++ bool "Garbage collect unused functions and data" ++ default n ++ help ++ Tell the compiler to place all functions and variables in their own ++ sections and then tell the linker to discard any section that aren't ++ referred to. ++ + endmenu + + +--- arch/blackfin/Makefile ++++ arch/blackfin/Makefile +@@ -18,6 +18,12 @@ CFLAGS_MODULE += -mlong-calls + KALLSYMS += --symbol-prefix=_ + + ++ifdef CONFIG_GC_SECTIONS ++CFLAGS += -ffunction-sections -fdata-sections ++LINKFLAGS += --gc-sections ++endif ++ ++ + # setup the machine name and the machine dependent settings + machine-$(CONFIG_BF531) := bf533 + machine-$(CONFIG_BF532) := bf533 diff --git a/bfin-libgloss-bf52x.patch b/bfin-libgloss-bf52x.patch new file mode 100644 index 0000000..1879805 --- /dev/null +++ b/bfin-libgloss-bf52x.patch @@ -0,0 +1,50 @@ +Index: ChangeLog.bfin +=================================================================== +--- ChangeLog.bfin (revision 1828) ++++ ChangeLog.bfin (working copy) +@@ -1,3 +1,9 @@ ++2007-10-02 Michael Frysinger ++ ++ * bfin/bf522.ld (MEM_L1_CODE): Define region 0xFFA00000 of size 0x8000. ++ * bfin/bf525.ld (MEM_L1_CODE): Likewise. ++ * bfin/bf527.ld (MEM_L1_CODE): Likewise. ++ + 2007-09-20 Jie Zhang + + * bfin/include/*, bfin/include/sys/*: Remove trailing blank +Index: bfin/bf525.ld +=================================================================== +--- bfin/bf525.ld (revision 1828) ++++ bfin/bf525.ld (working copy) +@@ -17,6 +17,7 @@ + + MEMORY + { ++ MEM_L1_CODE : ORIGIN = 0xFFA00000, LENGTH = 0x8000 + MEM_L1_CODE_CACHE : ORIGIN = 0xFFA10000, LENGTH = 0x4000 + MEM_L1_SCRATCH : ORIGIN = 0xFFB00000, LENGTH = 0x1000 + MEM_L1_DATA_B : ORIGIN = 0xFF900000, LENGTH = 0x8000 +Index: bfin/bf527.ld +=================================================================== +--- bfin/bf527.ld (revision 1828) ++++ bfin/bf527.ld (working copy) +@@ -17,6 +17,7 @@ + + MEMORY + { ++ MEM_L1_CODE : ORIGIN = 0xFFA00000, LENGTH = 0x8000 + MEM_L1_CODE_CACHE : ORIGIN = 0xFFA10000, LENGTH = 0x4000 + MEM_L1_SCRATCH : ORIGIN = 0xFFB00000, LENGTH = 0x1000 + MEM_L1_DATA_B : ORIGIN = 0xFF900000, LENGTH = 0x8000 +Index: bfin/bf522.ld +=================================================================== +--- bfin/bf522.ld (revision 1828) ++++ bfin/bf522.ld (working copy) +@@ -17,6 +17,7 @@ + + MEMORY + { ++ MEM_L1_CODE : ORIGIN = 0xFFA00000, LENGTH = 0x8000 + MEM_L1_CODE_CACHE : ORIGIN = 0xFFA10000, LENGTH = 0x4000 + MEM_L1_SCRATCH : ORIGIN = 0xFFB00000, LENGTH = 0x1000 + MEM_L1_DATA_B : ORIGIN = 0xFF900000, LENGTH = 0x8000 diff --git a/bfin-new-serial-break.patch b/bfin-new-serial-break.patch new file mode 100644 index 0000000..cf06512 --- /dev/null +++ b/bfin-new-serial-break.patch @@ -0,0 +1,41 @@ +Index: bfin_5xx.c +=================================================================== +RCS file: /usr/local/src/blackfin/rsync/uclinux533/uClinux-dist/linux-2.6.x/drivers/serial/bfin_5xx.c,v +retrieving revision 1.20 +diff -u -p -r1.20 bfin_5xx.c +--- bfin_5xx.c 14 Oct 2006 04:28:21 -0000 1.20 ++++ bfin_5xx.c 14 Oct 2006 22:03:11 -0000 +@@ -163,11 +163,29 @@ static void + bfin_serial_rx_chars(struct bfin_serial_port *uart, struct pt_regs *regs) + { + struct tty_struct *tty = uart->port.info->tty; +- unsigned int status=0, ch, flg; ++ unsigned int status, ch, flg; ++ ++ status = UART_GET_LSR(uart); ++ ch = UART_GET_CHAR(uart); ++ uart->port.icount.rx++; ++ ++ if (status & BI) { ++ if (uart_handle_break(&uart->port)) ++ goto ignore_char; ++ flg = TTY_BREAK; ++ uart->port.icount.brk++; ++ } else if (status & PE) { ++ flg = TTY_PARITY; ++ uart->port.icount.parity++; ++ } else if (status & OE) { ++ flg = TTY_OVERRUN; ++ uart->port.icount.overrun++; ++ } else if (status & FE) { ++ flg = TTY_FRAME; ++ uart->port.icount.frame++; ++ } else ++ flg = TTY_NORMAL; + +- ch = UART_GET_CHAR(uart); +- uart->port.icount.rx++; +- flg = TTY_NORMAL; + if (uart_handle_sysrq_char(&uart->port, ch, regs)) + goto ignore_char; + uart_insert_char(&uart->port, status, 1, ch, flg); diff --git a/bfin-nommu-maps.patch b/bfin-nommu-maps.patch new file mode 100644 index 0000000..66b05bf --- /dev/null +++ b/bfin-nommu-maps.patch @@ -0,0 +1,237 @@ +Index: fs/proc/task_nommu.c +=================================================================== +RCS file: /usr/local/src/blackfin/rsync/uclinux533/uClinux-dist/linux-2.6.x/fs/proc/task_nommu.c,v +retrieving revision 1.4 +diff -u -p -r1.4 task_nommu.c +--- fs/proc/task_nommu.c 12 Aug 2005 04:12:03 -0000 1.4 ++++ fs/proc/task_nommu.c 25 Aug 2006 23:03:47 -0000 +@@ -141,20 +141,227 @@ out: + * Albert D. Cahalan suggested to fake entries for the traditional + * sections here. This might be worth investigating. + */ ++static void pad_len_spaces(struct seq_file *m, int len) ++{ ++ len = 25 + sizeof(void*) * 6 - len; ++ if (len < 1) ++ len = 1; ++ seq_printf(m, "%*c", len, ' '); ++} ++ + static int show_map(struct seq_file *m, void *v) + { ++ struct task_struct *task = m->private; ++ struct vm_area_struct *vma = v; ++ struct mm_struct *mm = vma->vm_mm; ++ struct file *file = vma->vm_file; ++ int flags = vma->vm_flags; ++ unsigned long ino = 0; ++ dev_t dev = 0; ++ int len; ++ ++printk("!!! BOOYA %s\n", __FUNCTION__); ++ ++ if (file) { ++ struct inode *inode = vma->vm_file->f_dentry->d_inode; ++ dev = inode->i_sb->s_dev; ++ ino = inode->i_ino; ++ } ++ ++ seq_printf(m, "%08lx-%08lx %c%c%c%c %08lx %02x:%02x %lu %n", ++ vma->vm_start, ++ vma->vm_end, ++ flags & VM_READ ? 'r' : '-', ++ flags & VM_WRITE ? 'w' : '-', ++ flags & VM_EXEC ? 'x' : '-', ++ flags & VM_MAYSHARE ? 's' : 'p', ++ vma->vm_pgoff << PAGE_SHIFT, ++ MAJOR(dev), MINOR(dev), ino, &len); ++ ++ /* ++ * Print the dentry name for named mappings, and a ++ * special [heap] marker for the heap: ++ */ ++ if (file) { ++ pad_len_spaces(m, len); ++ seq_path(m, file->f_vfsmnt, file->f_dentry, "\n"); ++ } else { ++ if (mm) { ++ if (vma->vm_start <= mm->start_brk && ++ vma->vm_end >= mm->brk) { ++ pad_len_spaces(m, len); ++ seq_puts(m, "[heap]"); ++ } else { ++ if (vma->vm_start <= mm->start_stack && ++ vma->vm_end >= mm->start_stack) { ++ ++ pad_len_spaces(m, len); ++ seq_puts(m, "[stack]"); ++ } ++ } ++ } else { ++ pad_len_spaces(m, len); ++ seq_puts(m, "[vdso]"); ++ } ++ } ++ seq_putc(m, '\n'); ++ ++/* ++ if (mss) ++ seq_printf(m, ++ "Size: %8lu kB\n" ++ "Rss: %8lu kB\n" ++ "Shared_Clean: %8lu kB\n" ++ "Shared_Dirty: %8lu kB\n" ++ "Private_Clean: %8lu kB\n" ++ "Private_Dirty: %8lu kB\n", ++ (vma->vm_end - vma->vm_start) >> 10, ++ mss->resident >> 10, ++ mss->shared_clean >> 10, ++ mss->shared_dirty >> 10, ++ mss->private_clean >> 10, ++ mss->private_dirty >> 10); ++*/ ++#define get_gate_vma(x) NULL ++ if (m->count < m->size) /* vma is copied successfully */ ++ m->version = (vma != get_gate_vma(task))? vma->vm_start: 0; + return 0; + } + static void *m_start(struct seq_file *m, loff_t *pos) + { +- return NULL; ++ struct task_struct *task = m->private; ++ unsigned long last_addr = m->version; ++ struct mm_struct *mm; ++ struct vm_area_struct *vma, *tail_vma; ++ struct vm_list_struct *vml; ++ loff_t l = *pos; ++printk("!!! BOOYA %s\n", __FUNCTION__); ++printk("%s:%i: %p %lu \n", __FUNCTION__, __LINE__, task, last_addr); ++ /* ++ * We remember last_addr rather than next_addr to hit with ++ * mmap_cache most of the time. We have zero last_addr at ++ * the beginning and also after lseek. We will have -1 last_addr ++ * after the end of the vmas. ++ */ ++ ++ if (last_addr == -1UL) ++ return NULL; ++printk("%s:%i: \n", __FUNCTION__, __LINE__); ++ ++ mm = get_task_mm(task); ++ if (!mm) ++ return NULL; ++printk("%s:%i: mm=%p \n", __FUNCTION__, __LINE__, mm); ++ ++ for (vml = mm->context.vmlist; vml; vml = vml->next) { ++ vma = vml->vma; ++char _tmpbuf[1024]; ++ char *p; ++ unsigned long ino = 0; ++ dev_t dev = 0; ++int flags = vma->vm_flags; ++ struct file *file = vma->vm_file; ++ if (file) { ++ struct inode *inode = vma->vm_file->f_dentry->d_inode; ++ dev = inode->i_sb->s_dev; ++ ino = inode->i_ino; ++ } ++// printk("%s:%i: %p: %lu -> %lu\n", __FUNCTION__, __LINE__, vml->vma, ++// vml->vma->vm_start, vml->vma->vm_end); ++printk("MAPS: %08lx-%08lx %c%c%c%c %08lx %02x:%02x %lu %n ", ++ vma->vm_start, ++ vma->vm_end, ++ flags & VM_READ ? 'r' : '-', ++ flags & VM_WRITE ? 'w' : '-', ++ flags & VM_EXEC ? 'x' : '-', ++ flags & VM_MAYSHARE ? 's' : 'p', ++ vma->vm_pgoff << PAGE_SHIFT, ++ MAJOR(dev), MINOR(dev), ino); ++if (file) { ++p = d_path(file->f_dentry, file->f_vfsmnt, _tmpbuf, sizeof(_tmpbuf)); ++printk(" %s ", p); ++ ++} else { ++ if (mm) { ++ if (vma->vm_start <= mm->start_brk && ++ vma->vm_end >= mm->brk) { ++ printk(" [heap]"); ++ } else { ++ if (vma->vm_start <= mm->start_stack && ++ vma->vm_end >= mm->start_stack) { ++ ++ printk(" [stack]"); ++ } ++ } ++ } ++} ++printk("\n"); ++ ++// if (addr >= vml->vma->vm_start && addr < vml->vma->vm_end) ++// break; ++ } ++ ++ tail_vma = get_gate_vma(task); ++ down_read(&mm->mmap_sem); ++ ++ /* Start with last addr hint */ ++ if (last_addr && (vma = find_vma(mm, last_addr))) { ++ vma = vma->vm_next; ++ goto out; ++ } ++printk("%s:%i: \n", __FUNCTION__, __LINE__); ++ ++ /* ++ * Check the vma index is within the range and do ++ * sequential scan until m_index. ++ */ ++ vma = NULL; ++ if ((unsigned long)l < mm->map_count) { ++ vma = mm->mmap; ++ while (l-- && vma) ++ vma = vma->vm_next; ++ goto out; ++ } ++printk("%s:%i: \n", __FUNCTION__, __LINE__); ++ ++ if (l != mm->map_count) ++ tail_vma = NULL; /* After gate vma */ ++printk("%s:%i: \n", __FUNCTION__, __LINE__); ++ ++out: ++ if (vma) ++ return vma; ++printk("%s:%i: %p\n", __FUNCTION__, __LINE__, tail_vma); ++ ++ /* End of vmas has been reached */ ++ m->version = (tail_vma != NULL)? 0: -1UL; ++ up_read(&mm->mmap_sem); ++ mmput(mm); ++ return tail_vma; + } + static void m_stop(struct seq_file *m, void *v) + { ++ struct task_struct *task = m->private; ++ struct vm_area_struct *vma = v; ++printk("!!! BOOYA %s\n", __FUNCTION__); ++ if (vma && vma != get_gate_vma(task)) { ++ struct mm_struct *mm = vma->vm_mm; ++ up_read(&mm->mmap_sem); ++ mmput(mm); ++ } + } + static void *m_next(struct seq_file *m, void *v, loff_t *pos) + { +- return NULL; ++ struct task_struct *task = m->private; ++ struct vm_area_struct *vma = v; ++ struct vm_area_struct *tail_vma = get_gate_vma(task); ++printk("!!! BOOYA %s\n", __FUNCTION__); ++ ++ (*pos)++; ++ if (vma && (vma != tail_vma) && vma->vm_next) ++ return vma->vm_next; ++ m_stop(m, v); ++ return (vma != tail_vma)? tail_vma: NULL; + } + struct seq_operations proc_pid_maps_op = { + .start = m_start, diff --git a/bfin-proc-mem.patch b/bfin-proc-mem.patch new file mode 100644 index 0000000..adf8b6b --- /dev/null +++ b/bfin-proc-mem.patch @@ -0,0 +1,113 @@ +--- a/mm/memory.c ++++ b/mm/memory.c +@@ -2505,3 +2505,56 @@ #endif + } + + #endif /* __HAVE_ARCH_GATE_AREA */ ++ ++/* ++ * Access another process' address space. ++ * Source/target buffer must be kernel space, ++ * Do not walk the page table directly, use get_user_pages ++ */ ++int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write) ++{ ++ struct mm_struct *mm; ++ struct vm_area_struct *vma; ++ struct page *page; ++ void *old_buf = buf; ++ ++ mm = get_task_mm(tsk); ++ if (!mm) ++ return 0; ++ ++ down_read(&mm->mmap_sem); ++ /* ignore errors, just check how much was sucessfully transfered */ ++ while (len) { ++ int bytes, ret, offset; ++ void *maddr; ++ ++ ret = get_user_pages(tsk, mm, addr, 1, ++ write, 1, &page, &vma); ++ if (ret <= 0) ++ break; ++ ++ bytes = len; ++ offset = addr & (PAGE_SIZE-1); ++ if (bytes > PAGE_SIZE-offset) ++ bytes = PAGE_SIZE-offset; ++ ++ maddr = kmap(page); ++ if (write) { ++ copy_to_user_page(vma, page, addr, ++ maddr + offset, buf, bytes); ++ set_page_dirty_lock(page); ++ } else { ++ copy_from_user_page(vma, page, addr, ++ buf, maddr + offset, bytes); ++ } ++ kunmap(page); ++ page_cache_release(page); ++ len -= bytes; ++ buf += bytes; ++ addr += bytes; ++ } ++ up_read(&mm->mmap_sem); ++ mmput(mm); ++ ++ return buf - old_buf; ++} +--- a/mm/nommu.c ++++ b/mm/nommu.c +@@ -1206,3 +1206,51 @@ struct page *filemap_nopage(struct vm_ar + BUG(); + return NULL; + } ++ ++/* ++ * Access another process' address space. ++ * - source/target buffer must be kernel space ++ */ ++int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write) ++{ ++ struct vm_list_struct *vml; ++ struct vm_area_struct *vma; ++ struct mm_struct *mm; ++printk("!!! OH YEAH\n"); ++ if (addr + len < addr) ++ return 0; ++ ++ mm = get_task_mm(tsk); ++ if (!mm) ++ return 0; ++ ++ down_read(&mm->mmap_sem); ++ ++ /* the access must start within one of the target process's mappings */ ++ for (vml = mm->context.vmlist; vml; vml = vml->next) { ++ if (addr >= vml->vma->vm_start && addr < vml->vma->vm_end) ++ break; ++ } ++ ++ if (vml) { ++ vma = vml->vma; ++ ++ /* don't overrun this mapping */ ++ if (addr + len >= vma->vm_end) ++ len = vma->vm_end - addr; ++ ++ /* only read or write mappings where it is permitted */ ++ if (write && vma->vm_flags & VM_WRITE) ++ len -= copy_to_user((void *) addr, buf, len); ++ else if (!write && vma->vm_flags & VM_READ) ++ len -= copy_from_user(buf, (void *) addr, len); ++ else ++ len = 0; ++ } else { ++ len = 0; ++ } ++ ++ up_read(&mm->mmap_sem); ++ mmput(mm); ++ return len; ++} diff --git a/bfin-pthreads-gcc-constraints.patch b/bfin-pthreads-gcc-constraints.patch new file mode 100644 index 0000000..2096866 --- /dev/null +++ b/bfin-pthreads-gcc-constraints.patch @@ -0,0 +1,56 @@ +Index: uClibc/libpthread/linuxthreads.old/sysdeps/bfin/pt-machine.h +=================================================================== +--- uClibc/libpthread/linuxthreads.old/sysdeps/bfin/pt-machine.h (revision 1807) ++++ uClibc/libpthread/linuxthreads.old/sysdeps/bfin/pt-machine.h (working copy) +@@ -22,7 +22,7 @@ + #define _PT_MACHINE_H 1 + + #ifndef PT_EI +-# define PT_EI extern inline ++# define PT_EI extern inline __attribute__((always_inline)) + #endif + + extern long int testandset (int *spinlock); +@@ -41,11 +41,11 @@ testandset (int *spinlock) + { + long int res; + +- asm volatile ("R1 = 1; P0 = %2; CALL (%4); %0 = R0;" +- : "=d" (res), "=m" (*spinlock) +- : "da" (spinlock), "m" (*spinlock), +- "a" (ATOMIC_XCHG32) +- :"R0", "R1", "P0", "RETS", "cc", "memory"); ++ __asm__ __volatile__ ( ++ "CALL (%4);" ++ : "=q0" (res), "=m" (*spinlock) ++ : "qA" (spinlock), "m" (*spinlock), "a" (ATOMIC_XCHG32), "q1" (1) ++ : "RETS", "cc", "memory"); + + return res; + } +@@ -55,18 +55,15 @@ PT_EI int + __compare_and_swap (long int *p, long int oldval, long int newval) + { + long int readval; +- asm volatile ("P0 = %2;\n\t" +- "R1 = %3;\n\t" +- "R2 = %4;\n\t" +- "CALL (%5);\n\t" +- "%0 = R0;\n\t" +- : "=da" (readval), "=m" (*p) +- : "da" (p), +- "da" (oldval), +- "da" (newval), ++ __asm__ __volatile__ ( ++ "CALL (%5);" ++ : "=q0" (readval), "=m" (*p) ++ : "qA" (p), ++ "q1" (oldval), ++ "q2" (newval), + "a" (ATOMIC_CAS32), + "m" (*p) +- : "P0", "R0", "R1", "R2", "RETS", "memory", "cc"); ++ : "RETS", "memory", "cc"); + return readval == oldval; + } + diff --git a/bfin-request-exception.patch b/bfin-request-exception.patch new file mode 100644 index 0000000..be1ddfd --- /dev/null +++ b/bfin-request-exception.patch @@ -0,0 +1,173 @@ +Index: include/asm-blackfin/irq_handler.h +=================================================================== +--- include/asm-blackfin/irq_handler.h (revision 3496) ++++ include/asm-blackfin/irq_handler.h (working copy) +@@ -18,5 +21,13 @@ + asmlinkage void evt_soft_int1(void); + asmlinkage void evt_system_call(void); + asmlinkage void init_exception_buff(void); ++asmlinkage void trap_c(struct pt_regs *fp); ++asmlinkage void ex_replaceable(void); + ++extern void *ex_table[]; ++extern void return_from_exception(void); ++ ++extern int bfin_request_exception(unsigned int exception, void (*handler)(void)); ++extern int bfin_free_exception(unsigned int exception, void (*handler)(void)); ++ + #endif +Index: arch/blackfin/kernel/traps.c +=================================================================== +--- arch/blackfin/kernel/traps.c (revision 3496) ++++ arch/blackfin/kernel/traps.c (working copy) +@@ -50,8 +50,6 @@ + CSYNC(); + } + +-asmlinkage void trap_c(struct pt_regs *fp); +- + int kstack_depth_to_print = 48; + + #ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON +@@ -673,9 +671,8 @@ + } + + #ifdef CONFIG_SYS_BFIN_SPINLOCK_L1 +-asmlinkage int sys_bfin_spinlock(int *spinlock)__attribute__((l1_text)); ++__attribute__((l1_text)) + #endif +- + asmlinkage int sys_bfin_spinlock(int *spinlock) + { + int ret = 0; +@@ -693,6 +690,42 @@ + return ret; + } + ++int bfin_request_exception(unsigned int exception, void (*handler)(void)) ++{ ++ void (*curr_handler)(void); ++ ++ if (exception > 0x3F) ++ return -EINVAL; ++ ++ curr_handler = ex_table[exception]; ++ ++ if (curr_handler != ex_replaceable) ++ return -EBUSY; ++ ++ ex_table[exception] = handler; ++ ++ return 0; ++} ++EXPORT_SYMBOL(bfin_request_exception); ++ ++int bfin_free_exception(unsigned int exception, void (*handler)(void)) ++{ ++ void (*curr_handler)(void); ++ ++ if (exception > 0x3F) ++ return -EINVAL; ++ ++ curr_handler = ex_table[exception]; ++ ++ if (curr_handler != handler) ++ return -EBUSY; ++ ++ ex_table[exception] = ex_replaceable; ++ ++ return 0; ++} ++EXPORT_SYMBOL(bfin_free_exception); ++ + void panic_cplb_error(int cplb_panic, struct pt_regs *fp) + { + switch (cplb_panic) { +Index: arch/blackfin/mach-common/entry.S +=================================================================== +--- arch/blackfin/mach-common/entry.S (revision 3496) ++++ arch/blackfin/mach-common/entry.S (working copy) +@@ -135,7 +135,7 @@ + cc = r6 == r7; + if !cc jump _ex_trap_c; + +-_return_from_exception: ++ENTRY(_return_from_exception) + DEBUG_START_HWTRACE(p5, r7) + #if ANOMALY_05000257 + R7=LC0; +@@ -163,6 +163,9 @@ + [--sp] = ASTAT; + [--sp] = (R7:6, P5:4); + ++ENTRY(_ex_replaceable) ++ nop; ++ + ENTRY(_ex_trap_c) + /* Call C code (trap_c) to handle the exception, which most + * likely involves sending a signal to the current process. +@@ -290,8 +293,8 @@ + r6.l = lo(SEQSTAT_EXCAUSE); + r6.h = hi(SEQSTAT_EXCAUSE); + r7 = r7 & r6; +- p5.h = _extable; +- p5.l = _extable; ++ p5.h = _ex_table; ++ p5.l = _ex_table; + p4 = r7; + p5 = p5 + (p4 << 2); + p4 = [p5]; +@@ -810,28 +813,27 @@ + #else + .data + #endif +-ALIGN +-_extable: ++ENTRY(_ex_table) + /* entry for each EXCAUSE[5:0] + * This table must be in sync with the table in ./kernel/traps.c + * EXCPT instruction can provide 4 bits of EXCAUSE, allowing 16 to be user defined + */ +- .long _ex_syscall; /* 0x00 - User Defined - Linux Syscall */ ++ .long _ex_syscall /* 0x00 - User Defined - Linux Syscall */ + .long _ex_soft_bp /* 0x01 - User Defined - Software breakpoint */ +- .long _ex_trap_c /* 0x02 - User Defined */ ++ .long _ex_replaceable /* 0x02 - User Defined */ + .long _ex_trap_c /* 0x03 - User Defined - userspace stack overflow */ +- .long _ex_trap_c /* 0x04 - User Defined */ +- .long _ex_trap_c /* 0x05 - User Defined */ +- .long _ex_trap_c /* 0x06 - User Defined */ +- .long _ex_trap_c /* 0x07 - User Defined */ +- .long _ex_trap_c /* 0x08 - User Defined */ +- .long _ex_trap_c /* 0x09 - User Defined */ +- .long _ex_trap_c /* 0x0A - User Defined */ +- .long _ex_trap_c /* 0x0B - User Defined */ +- .long _ex_trap_c /* 0x0C - User Defined */ +- .long _ex_trap_c /* 0x0D - User Defined */ +- .long _ex_trap_c /* 0x0E - User Defined */ +- .long _ex_trap_c /* 0x0F - User Defined */ ++ .long _ex_replaceable /* 0x04 - User Defined */ ++ .long _ex_replaceable /* 0x05 - User Defined */ ++ .long _ex_replaceable /* 0x06 - User Defined */ ++ .long _ex_replaceable /* 0x07 - User Defined */ ++ .long _ex_replaceable /* 0x08 - User Defined */ ++ .long _ex_replaceable /* 0x09 - User Defined */ ++ .long _ex_replaceable /* 0x0A - User Defined */ ++ .long _ex_replaceable /* 0x0B - User Defined */ ++ .long _ex_replaceable /* 0x0C - User Defined */ ++ .long _ex_replaceable /* 0x0D - User Defined */ ++ .long _ex_replaceable /* 0x0E - User Defined */ ++ .long _ex_replaceable /* 0x0F - User Defined */ + .long _ex_single_step /* 0x10 - HW Single step */ + #ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND + .long _ex_trace_buff_full /* 0x11 - Trace Buffer Full */ +@@ -885,8 +887,8 @@ + .long _ex_trap_c /* 0x3D - Reserved */ + .long _ex_trap_c /* 0x3E - Reserved */ + .long _ex_trap_c /* 0x3F - Reserved */ ++END(_ex_table) + +-ALIGN + ENTRY(_sys_call_table) + .long _sys_ni_syscall /* 0 - old "setup()" system call*/ + .long _sys_exit diff --git a/bfin-revised-anomaly-handling.patch b/bfin-revised-anomaly-handling.patch new file mode 100644 index 0000000..b9b7c7c --- /dev/null +++ b/bfin-revised-anomaly-handling.patch @@ -0,0 +1,2072 @@ +Index: include/asm-blackfin/mach-bf548/anomaly.h +=================================================================== +--- include/asm-blackfin/mach-bf548/anomaly.h (revision 3448) ++++ include/asm-blackfin/mach-bf548/anomaly.h (working copy) +@@ -6,46 +6,62 @@ + * Licensed under the GPL-2 or later. + */ + ++/* This file shoule be up to date with: ++ * - Revision B, April 6, 2007; ADSP-BF549 Silicon Anomaly List ++ */ ++ + #ifndef _MACH_ANOMALY_H_ + #define _MACH_ANOMALY_H_ + +-#define ANOMALY_05000074 /* A multi issue instruction with dsp32shiftimm in +- * slot1 and store of a P register in slot 2 is not +- * supported */ +-#define ANOMALY_05000119 /* DMA_RUN bit is not valid after a Peripheral Receive +- * Channel DMA stops */ +-#define ANOMALY_05000122 /* Rx.H can not be used to access 16-bit System MMR +- * registers. */ +-#define ANOMALY_05000245 /* Spurious Hardware Error from an Access in the +- * Shadow of a Conditional Branch */ +-#define ANOMALY_05000255 /* Entering Hibernate Mode with RTC Seconds event +- * interrupt not functional */ +-#define ANOMALY_05000265 /* Sensitivity to noise with slow input edge rates on +- * SPORT external receive and transmit clocks. */ +-#define ANOMALY_05000272 /* Certain data cache write through modes fail for +- * VDDint <=0.9V */ +-#define ANOMALY_05000281 /* False Hardware Error Exception when ISR context is +- * not restored */ +-#define ANOMALY_05000310 /* False Hardware Errors Caused by Fetches at the +- * Boundary of Reserved Memory */ +-#define ANOMALY_05000312 /* Errors When SSYNC, CSYNC, or Loads to LT, LB and +- * LC Registers Are Interrupted */ +-#define ANOMALY_05000324 /* TWI Slave Boot Mode Is Not Functional */ +-#define ANOMALY_05000325 /* External FIFO Boot Mode Is Not Functional */ +-#define ANOMALY_05000327 /* Data Lost When Core and DMA Accesses Are Made to +- * the USB FIFO Simultaneously */ +-#define ANOMALY_05000328 /* Incorrect Access of OTP_STATUS During otp_write() +- * function */ +-#define ANOMALY_05000329 /* Synchronous Burst Flash Boot Mode Is Not Functional +- * */ +-#define ANOMALY_05000330 /* Host DMA Boot Mode Is Not Functional */ +-#define ANOMALY_05000334 /* Inadequate Timing Margins on DDR DQS to DQ and DQM +- * Skew */ +-#define ANOMALY_05000335 /* Inadequate Rotary Debounce Logic Duration */ +-#define ANOMALY_05000336 /* Phantom Interrupt Occurs After First Configuration +- * of Host DMA Port */ +-#define ANOMALY_05000337 /* Disallowed Configuration Prevents Subsequent +- * Allowed Configuration on Host DMA Port */ +-#define ANOMALY_05000338 /* Slave-Mode SPI0 MISO Failure With CPHA = 0 */ ++/* Multi-Issue Instruction with dsp32shiftimm in slot1 and P-reg Store in slot 2 Not Supported */ ++#define ANOMALY_05000074 (1) ++/* DMA_RUN Bit Is Not Valid after a Peripheral Receive Channel DMA Stops */ ++#define ANOMALY_05000119 (1) ++/* Rx.H Cannot Be Used to Access 16-bit System MMR Registers */ ++#define ANOMALY_05000122 (1) ++/* Spurious Hardware Error from an Access in the Shadow of a Conditional Branch */ ++#define ANOMALY_05000245 (1) ++/* Entering Hibernate State with RTC Seconds Interrupt Not Functional */ ++#define ANOMALY_05000255 (1) ++/* Sensitivity To Noise with Slow Input Edge Rates on External SPORT TX and RX Clocks */ ++#define ANOMALY_05000265 (1) ++/* Certain Data Cache Writethrough Modes Fail for Vddint <= 0.9V */ ++#define ANOMALY_05000272 (1) ++/* False Hardware Errors Caused by Fetches at the Boundary of Reserved Memory */ ++#define ANOMALY_05000310 (1) ++/* Errors When SSYNC, CSYNC, or Loads to LT, LB and LC Registers Are Interrupted */ ++#define ANOMALY_05000312 (1) ++/* TWI Slave Boot Mode Is Not Functional */ ++#define ANOMALY_05000324 (1) ++/* External FIFO Boot Mode Is Not Functional */ ++#define ANOMALY_05000325 (1) ++/* Data Lost When Core and DMA Accesses Are Made to the USB FIFO Simultaneously */ ++#define ANOMALY_05000327 (1) ++/* Incorrect Access of OTP_STATUS During otp_write() Function */ ++#define ANOMALY_05000328 (1) ++/* Synchronous Burst Flash Boot Mode Is Not Functional */ ++#define ANOMALY_05000329 (1) ++/* Host DMA Boot Mode Is Not Functional */ ++#define ANOMALY_05000330 (1) ++/* Inadequate Timing Margins on DDR DQS to DQ and DQM Skew */ ++#define ANOMALY_05000334 (1) ++/* Inadequate Rotary Debounce Logic Duration */ ++#define ANOMALY_05000335 (1) ++/* Phantom Interrupt Occurs After First Configuration of Host DMA Port */ ++#define ANOMALY_05000336 (1) ++/* Disallowed Configuration Prevents Subsequent Allowed Configuration on Host DMA Port */ ++#define ANOMALY_05000337 (1) ++/* Slave-Mode SPI0 MISO Failure With CPHA = 0 */ ++#define ANOMALY_05000338 (1) + +-#endif /* _MACH_ANOMALY_H_ */ ++/* Anomalies that don't exist on this proc */ ++#define ANOMALY_05000125 (0) ++#define ANOMALY_05000183 (0) ++#define ANOMALY_05000198 (0) ++#define ANOMALY_05000244 (0) ++#define ANOMALY_05000263 (0) ++#define ANOMALY_05000266 (0) ++#define ANOMALY_05000273 (0) ++#define ANOMALY_05000311 (0) ++ ++#endif +Index: include/asm-blackfin/blackfin.h +=================================================================== +--- include/asm-blackfin/blackfin.h (revision 3448) ++++ include/asm-blackfin/blackfin.h (working copy) +@@ -17,72 +17,64 @@ + #ifndef __ASSEMBLY__ + + /* SSYNC implementation for C file */ +-#if defined(ANOMALY_05000312) && defined(ANOMALY_05000244) +-static inline void SSYNC (void) ++static inline void SSYNC(void) + { + int _tmp; +- __asm__ __volatile__ ("cli %0;\n\t" +- "nop;nop;\n\t" +- "ssync;\n\t" +- "sti %0;\n\t" +- :"=d"(_tmp):); ++ if (ANOMALY_05000312 && ANOMALY_05000244) ++ __asm__ __volatile__ ( ++ "cli %0;" ++ "nop;nop;" ++ "ssync;" ++ "sti %0;" ++ : "=d" (_tmp) ++ ); ++ else if (ANOMALY_05000312 && !ANOMALY_05000244) ++ __asm__ __volatile__ ( ++ "cli %0;" ++ "ssync;" ++ "sti %0;" ++ : "=d" (_tmp) ++ ); ++ else if (!ANOMALY_05000312 && ANOMALY_05000244) ++ __asm__ __volatile__ ( ++ "nop;" ++ "nop;" ++ "nop;" ++ "ssync;" ++ ); ++ else ++ __asm__ __volatile__ ("ssync;"); + } +-#elif defined(ANOMALY_05000312) && !defined(ANOMALY_05000244) +-static inline void SSYNC (void) +-{ +- int _tmp; +- __asm__ __volatile__ ("cli %0;\n\t" +- "ssync;\n\t" +- "sti %0;\n\t" +- :"=d"(_tmp):); +-} +-#elif !defined(ANOMALY_05000312) && defined(ANOMALY_05000244) +-static inline void SSYNC (void) +-{ +- __asm__ __volatile__ ("nop; nop; nop;\n\t" +- "ssync;\n\t" +- ::); +-} +-#elif !defined(ANOMALY_05000312) && !defined(ANOMALY_05000244) +-static inline void SSYNC (void) +-{ +- __asm__ __volatile__ ("ssync;\n\t"); +-} +-#endif + + /* CSYNC implementation for C file */ +-#if defined(ANOMALY_05000312) && defined(ANOMALY_05000244) +-static inline void CSYNC (void) ++static inline void CSYNC(void) + { + int _tmp; +- __asm__ __volatile__ ("cli %0;\n\t" +- "nop;nop;\n\t" +- "csync;\n\t" +- "sti %0;\n\t" +- :"=d"(_tmp):); ++ if (ANOMALY_05000312 && ANOMALY_05000244) ++ __asm__ __volatile__ ( ++ "cli %0;" ++ "nop;nop;" ++ "csync;" ++ "sti %0;" ++ : "=d" (_tmp) ++ ); ++ else if (ANOMALY_05000312 && !ANOMALY_05000244) ++ __asm__ __volatile__ ( ++ "cli %0;" ++ "csync;" ++ "sti %0;" ++ : "=d" (_tmp) ++ ); ++ else if (!ANOMALY_05000312 && ANOMALY_05000244) ++ __asm__ __volatile__ ( ++ "nop;" ++ "nop;" ++ "nop;" ++ "ssync;" ++ ); ++ else ++ __asm__ __volatile__ ("csync;"); + } +-#elif defined(ANOMALY_05000312) && !defined(ANOMALY_05000244) +-static inline void CSYNC (void) +-{ +- int _tmp; +- __asm__ __volatile__ ("cli %0;\n\t" +- "csync;\n\t" +- "sti %0;\n\t" +- :"=d"(_tmp):); +-} +-#elif !defined(ANOMALY_05000312) && defined(ANOMALY_05000244) +-static inline void CSYNC (void) +-{ +- __asm__ __volatile__ ("nop; nop; nop;\n\t" +- "ssync;\n\t" +- ::); +-} +-#elif !defined(ANOMALY_05000312) && !defined(ANOMALY_05000244) +-static inline void CSYNC (void) +-{ +- __asm__ __volatile__ ("csync;\n\t"); +-} +-#endif + + #else /* __ASSEMBLY__ */ + +@@ -91,19 +83,19 @@ + #define ssync(x) SSYNC(x) + #define csync(x) CSYNC(x) + +-#if defined(ANOMALY_05000312) && defined(ANOMALY_05000244) ++#if ANOMALY_05000312 && ANOMALY_05000244 + #define SSYNC(scratch) cli scratch; nop; nop; SSYNC; sti scratch; + #define CSYNC(scratch) cli scratch; nop; nop; CSYNC; sti scratch; + +-#elif defined(ANOMALY_05000312) && !defined(ANOMALY_05000244) ++#elif ANOMALY_05000312 && !ANOMALY_05000244 + #define SSYNC(scratch) cli scratch; nop; nop; SSYNC; sti scratch; + #define CSYNC(scratch) cli scratch; nop; nop; CSYNC; sti scratch; + +-#elif !defined(ANOMALY_05000312) && defined(ANOMALY_05000244) ++#elif !ANOMALY_05000312 && ANOMALY_05000244 + #define SSYNC(scratch) nop; nop; nop; SSYNC; + #define CSYNC(scratch) nop; nop; nop; CSYNC; + +-#elif !defined(ANOMALY_05000312) && !defined(ANOMALY_05000244) ++#elif !ANOMALY_05000312 && !ANOMALY_05000244 + #define SSYNC(scratch) SSYNC; + #define CSYNC(scratch) CSYNC; + +Index: include/asm-blackfin/mach-bf561/anomaly.h +=================================================================== +--- include/asm-blackfin/mach-bf561/anomaly.h (revision 3448) ++++ include/asm-blackfin/mach-bf561/anomaly.h (working copy) +@@ -7,155 +7,249 @@ + */ + + /* This file shoule be up to date with: +- * - Revision L, Aug 10, 2006; ADSP-BF561 Silicon Anomaly List ++ * - Revision N, March 28, 2007; ADSP-BF561 Silicon Anomaly List + */ + + #ifndef _MACH_ANOMALY_H_ + #define _MACH_ANOMALY_H_ + +-/* We do not support 0.1 or 0.4 silicon - sorry */ +-#if (defined(CONFIG_BF_REV_0_1) || defined(CONFIG_BF_REV_0_2) || defined(CONFIG_BF_REV_0_4)) +-#error Kernel will not work on BF561 Version 0.1, 0.2, or 0.4 ++/* We do not support 0.1, 0.2, or 0.4 silicon - sorry */ ++#if __SILICON_REVISION__ < 3 || __SILICON_REVISION__ == 4 ++# error Kernel will not work on BF561 silicon version 0.0, 0.1, 0.2, or 0.4 + #endif + +-/* Issues that are common to 0.5 and 0.3 silicon */ +-#if (defined(CONFIG_BF_REV_0_5) || defined(CONFIG_BF_REV_0_3)) +-#define ANOMALY_05000074 /* A multi issue instruction with dsp32shiftimm in +- * slot1 and store of a P register in slot 2 is not +- * supported */ +-#define ANOMALY_05000099 /* UART Line Status Register (UART_LSR) bits are not +- * updated at the same time. */ +-#define ANOMALY_05000120 /* Testset instructions restricted to 32-bit aligned +- * memory locations */ +-#define ANOMALY_05000122 /* Rx.H cannot be used to access 16-bit System MMR +- * registers */ +-#define ANOMALY_05000127 /* Signbits instruction not functional under certain +- * conditions */ +-#define ANOMALY_05000149 /* IMDMA S1/D1 channel may stall */ +-#define ANOMALY_05000166 /* PPI Data Lengths Between 8 and 16 do not zero out +- * upper bits */ +-#define ANOMALY_05000167 /* Turning Serial Ports on With External Frame Syncs */ +-#define ANOMALY_05000180 /* PPI_DELAY not functional in PPI modes with 0 frame +- * syncs */ +-#define ANOMALY_05000182 /* IMDMA does not operate to full speed for 600MHz +- * and higher devices */ +-#define ANOMALY_05000187 /* IMDMA Corrupted Data after a Halt */ +-#define ANOMALY_05000190 /* PPI not functional at core voltage < 1Volt */ +-#define ANOMALY_05000208 /* VSTAT status bit in PLL_STAT register is not +- * functional */ +-#define ANOMALY_05000245 /* Spurious Hardware Error from an access in the +- * shadow of a conditional branch */ +-#define ANOMALY_05000257 /* Interrupt/Exception during short hardware loop +- * may cause bad instruction fetches */ +-#define ANOMALY_05000265 /* Sensitivity to noise with slow input edge rates on +- * external SPORT TX and RX clocks */ +-#define ANOMALY_05000267 /* IMDMA may corrupt data under certain conditions */ +-#define ANOMALY_05000269 /* High I/O activity causes output voltage of internal +- * voltage regulator (VDDint) to increase */ +-#define ANOMALY_05000270 /* High I/O activity causes output voltage of internal +- * voltage regulator (VDDint) to decrease */ +-#define ANOMALY_05000272 /* Certain data cache write through modes fail for +- * VDDint <=0.9V */ +-#define ANOMALY_05000274 /* Data cache write back to external synchronous memory +- * may be lost */ +-#define ANOMALY_05000275 /* PPI Timing and sampling informaton updates */ +-#define ANOMALY_05000312 /* Errors when SSYNC, CSYNC, or loads to LT, LB and LC +- * registers are interrupted */ ++/* Multi-Issue Instruction with dsp32shiftimm in slot1 and P-reg Store in slot 2 Not Supported */ ++#define ANOMALY_05000074 (1) ++/* UART Line Status Register (UART_LSR) Bits Are Not Updated at the Same Time */ ++#define ANOMALY_05000099 (__SILICON_REVISION__ < 5) ++/* Trace Buffers may contain errors in emulation mode and/or exception, NMI, reset handlers */ ++#define ANOMALY_05000116 (__SILICON_REVISION__ < 3) ++/* Testset instructions restricted to 32-bit aligned memory locations */ ++#define ANOMALY_05000120 (1) ++/* Rx.H Cannot Be Used to Access 16-bit System MMR Registers */ ++#define ANOMALY_05000122 (1) ++/* Erroneous exception when enabling cache */ ++#define ANOMALY_05000125 (__SILICON_REVISION__ < 3) ++/* Signbits instruction not functional under certain conditions */ ++#define ANOMALY_05000127 (1) ++/* Two bits in the Watchpoint Status Register (WPSTAT) are swapped */ ++#define ANOMALY_05000134 (__SILICON_REVISION__ < 3) ++/* Enable wires from the Data Watchpoint Address Control Register (WPDACTL) are swapped */ ++#define ANOMALY_05000135 (__SILICON_REVISION__ < 3) ++/* Stall in multi-unit DMA operations */ ++#define ANOMALY_05000136 (__SILICON_REVISION__ < 3) ++/* Allowing the SPORT RX FIFO to fill will cause an overflow */ ++#define ANOMALY_05000140 (__SILICON_REVISION__ < 3) ++/* Infinite Stall may occur with a particular sequence of consecutive dual dag events */ ++#define ANOMALY_05000141 (__SILICON_REVISION__ < 3) ++/* Interrupts may be lost when a programmable input flag is configured to be edge sensitive */ ++#define ANOMALY_05000142 (__SILICON_REVISION__ < 3) ++/* DMA and TESTSET conflict when both are accessing external memory */ ++#define ANOMALY_05000144 (__SILICON_REVISION__ < 3) ++/* In PWM_OUT mode, you must enable the PPI block to generate a waveform from PPI_CLK */ ++#define ANOMALY_05000145 (__SILICON_REVISION__ < 3) ++/* MDMA may lose the first few words of a descriptor chain */ ++#define ANOMALY_05000146 (__SILICON_REVISION__ < 3) ++/* Source MDMA descriptor may stop with a DMA Error near beginning of descriptor fetch */ ++#define ANOMALY_05000147 (__SILICON_REVISION__ < 3) ++/* IMDMA S1/D1 channel may stall */ ++#define ANOMALY_05000149 (1) ++/* DMA engine may lose data due to incorrect handshaking */ ++#define ANOMALY_05000150 (__SILICON_REVISION__ < 3) ++/* DMA stalls when all three controllers read data from the same source */ ++#define ANOMALY_05000151 (__SILICON_REVISION__ < 3) ++/* Execution stall when executing in L2 and doing external accesses */ ++#define ANOMALY_05000152 (__SILICON_REVISION__ < 3) ++/* Frame Delay in SPORT Multichannel Mode */ ++#define ANOMALY_05000153 (__SILICON_REVISION__ < 3) ++/* SPORT TFS signal stays active in multichannel mode outside of valid channels */ ++#define ANOMALY_05000154 (__SILICON_REVISION__ < 3) ++/* Timers in PWM-Out Mode with PPI GP Receive (Input) Mode with 0 Frame Syncs */ ++#define ANOMALY_05000156 (__SILICON_REVISION__ < 4) ++/* Killed 32-bit MMR write leads to next system MMR access thinking it should be 32-bit */ ++#define ANOMALY_05000157 (__SILICON_REVISION__ < 3) ++/* DMA Lock-up at CCLK to SCLK ratios of 4:1, 2:1, or 1:1 */ ++#define ANOMALY_05000159 (__SILICON_REVISION__ < 3) ++/* A read from external memory may return a wrong value with data cache enabled */ ++#define ANOMALY_05000160 (__SILICON_REVISION__ < 3) ++/* Data Cache Fill data can be corrupted after/during Instruction DMA if certain core stalls exist */ ++#define ANOMALY_05000161 (__SILICON_REVISION__ < 3) ++/* DMEM_CONTROL<12> is not set on Reset */ ++#define ANOMALY_05000162 (__SILICON_REVISION__ < 3) ++/* SPORT transmit data is not gated by external frame sync in certain conditions */ ++#define ANOMALY_05000163 (__SILICON_REVISION__ < 3) ++/* PPI Data Lengths Between 8 and 16 Do Not Zero Out Upper Bits */ ++#define ANOMALY_05000166 (1) ++/* Turning Serial Ports on with External Frame Syncs */ ++#define ANOMALY_05000167 (1) ++/* SDRAM auto-refresh and subsequent Power Ups */ ++#define ANOMALY_05000168 (__SILICON_REVISION__ < 5) ++/* DATA CPLB page miss can result in lost write-through cache data writes */ ++#define ANOMALY_05000169 (__SILICON_REVISION__ < 5) ++/* Boot-ROM code modifies SICA_IWRx wakeup registers */ ++#define ANOMALY_05000171 (__SILICON_REVISION__ < 5) ++/* DSPID register values incorrect */ ++#define ANOMALY_05000172 (__SILICON_REVISION__ < 3) ++/* DMA vs Core accesses to external memory */ ++#define ANOMALY_05000173 (__SILICON_REVISION__ < 3) ++/* Cache Fill Buffer Data lost */ ++#define ANOMALY_05000174 (__SILICON_REVISION__ < 5) ++/* Overlapping Sequencer and Memory Stalls */ ++#define ANOMALY_05000175 (__SILICON_REVISION__ < 5) ++/* Multiplication of (-1) by (-1) followed by an accumulator saturation */ ++#define ANOMALY_05000176 (__SILICON_REVISION__ < 5) ++/* PPI_COUNT Cannot Be Programmed to 0 in General Purpose TX or RX Modes */ ++#define ANOMALY_05000179 (__SILICON_REVISION__ < 5) ++/* PPI_DELAY Not Functional in PPI Modes with 0 Frame Syncs */ ++#define ANOMALY_05000180 (1) ++/* Disabling the PPI resets the PPI configuration registers */ ++#define ANOMALY_05000181 (__SILICON_REVISION__ < 5) ++/* IMDMA does not operate to full speed for 600MHz and higher devices */ ++#define ANOMALY_05000182 (1) ++/* Timer Pin limitations for PPI TX Modes with External Frame Syncs */ ++#define ANOMALY_05000184 (__SILICON_REVISION__ < 5) ++/* PPI TX Mode with 2 External Frame Syncs */ ++#define ANOMALY_05000185 (__SILICON_REVISION__ < 5) ++/* PPI packing with Data Length greater than 8 bits (not a meaningful mode) */ ++#define ANOMALY_05000186 (__SILICON_REVISION__ < 5) ++/* IMDMA Corrupted Data after a Halt */ ++#define ANOMALY_05000187 (1) ++/* IMDMA Restrictions on Descriptor and Buffer Placement in Memory */ ++#define ANOMALY_05000188 (__SILICON_REVISION__ < 5) ++/* False Protection Exceptions */ ++#define ANOMALY_05000189 (__SILICON_REVISION__ < 5) ++/* PPI not functional at core voltage < 1Volt */ ++#define ANOMALY_05000190 (1) ++/* PPI does not invert the Driving PPICLK edge in Transmit Modes */ ++#define ANOMALY_05000191 (__SILICON_REVISION__ < 3) ++/* False I/O Pin Interrupts on Edge-Sensitive Inputs When Polarity Setting Is Changed */ ++#define ANOMALY_05000193 (__SILICON_REVISION__ < 5) ++/* Restarting SPORT in Specific Modes May Cause Data Corruption */ ++#define ANOMALY_05000194 (__SILICON_REVISION__ < 5) ++/* Failing MMR Accesses When Stalled by Preceding Memory Read */ ++#define ANOMALY_05000198 (__SILICON_REVISION__ < 5) ++/* Current DMA Address Shows Wrong Value During Carry Fix */ ++#define ANOMALY_05000199 (__SILICON_REVISION__ < 5) ++/* SPORT TFS and DT Are Incorrectly Driven During Inactive Channels in Certain Conditions */ ++#define ANOMALY_05000200 (__SILICON_REVISION__ < 5) ++/* Possible Infinite Stall with Specific Dual-DAG Situation */ ++#define ANOMALY_05000202 (__SILICON_REVISION__ < 5) ++/* Incorrect data read with write-through cache and allocate cache lines on reads only mode */ ++#define ANOMALY_05000204 (__SILICON_REVISION__ < 5) ++/* Specific sequence that can cause DMA error or DMA stopping */ ++#define ANOMALY_05000205 (__SILICON_REVISION__ < 5) ++/* Recovery from "Brown-Out" Condition */ ++#define ANOMALY_05000207 (__SILICON_REVISION__ < 5) ++/* VSTAT Status Bit in PLL_STAT Register Is Not Functional */ ++#define ANOMALY_05000208 (1) ++/* Speed Path in Computational Unit Affects Certain Instructions */ ++#define ANOMALY_05000209 (__SILICON_REVISION__ < 5) ++/* UART TX Interrupt Masked Erroneously */ ++#define ANOMALY_05000215 (__SILICON_REVISION__ < 5) ++/* NMI Event at Boot Time Results in Unpredictable State */ ++#define ANOMALY_05000219 (__SILICON_REVISION__ < 5) ++/* Data Corruption with Cached External Memory and Non-Cached On-Chip L2 Memory */ ++#define ANOMALY_05000220 (__SILICON_REVISION__ < 5) ++/* Incorrect Pulse-Width of UART Start Bit */ ++#define ANOMALY_05000225 (__SILICON_REVISION__ < 5) ++/* Scratchpad Memory Bank Reads May Return Incorrect Data */ ++#define ANOMALY_05000227 (__SILICON_REVISION__ < 5) ++/* UART Receiver is Less Robust Against Baudrate Differences in Certain Conditions */ ++#define ANOMALY_05000230 (__SILICON_REVISION__ < 5) ++/* UART STB Bit Incorrectly Affects Receiver Setting */ ++#define ANOMALY_05000231 (__SILICON_REVISION__ < 5) ++/* SPORT data transmit lines are incorrectly driven in multichannel mode */ ++#define ANOMALY_05000232 (__SILICON_REVISION__ < 5) ++/* DF Bit in PLL_CTL Register Does Not Respond to Hardware Reset */ ++#define ANOMALY_05000242 (__SILICON_REVISION__ < 5) ++/* If I-Cache Is On, CSYNC/SSYNC/IDLE Around Change of Control Causes Failures */ ++#define ANOMALY_05000244 (__SILICON_REVISION__ < 5) ++/* Spurious Hardware Error from an Access in the Shadow of a Conditional Branch */ ++#define ANOMALY_05000245 (__SILICON_REVISION__ < 5) ++/* TESTSET operation forces stall on the other core */ ++#define ANOMALY_05000248 (__SILICON_REVISION__ < 5) ++/* Incorrect Bit Shift of Data Word in Multichannel (TDM) Mode in Certain Conditions */ ++#define ANOMALY_05000250 (__SILICON_REVISION__ > 2 && __SILICON_REVISION__ < 5) ++/* Exception Not Generated for MMR Accesses in Reserved Region */ ++#define ANOMALY_05000251 (__SILICON_REVISION__ < 5) ++/* Maximum External Clock Speed for Timers */ ++#define ANOMALY_05000253 (__SILICON_REVISION__ < 5) ++/* Incorrect Timer Pulse Width in Single-Shot PWM_OUT Mode with External Clock */ ++#define ANOMALY_05000254 (__SILICON_REVISION__ > 3) ++/* Interrupt/Exception During Short Hardware Loop May Cause Bad Instruction Fetches */ ++#define ANOMALY_05000257 (__SILICON_REVISION__ < 5) ++/* Instruction Cache Is Corrupted When Bits 9 and 12 of the ICPLB Data Registers Differ */ ++#define ANOMALY_05000258 (__SILICON_REVISION__ < 5) ++/* ICPLB_STATUS MMR Register May Be Corrupted */ ++#define ANOMALY_05000260 (__SILICON_REVISION__ < 5) ++/* DCPLB_FAULT_ADDR MMR Register May Be Corrupted */ ++#define ANOMALY_05000261 (__SILICON_REVISION__ < 5) ++/* Stores To Data Cache May Be Lost */ ++#define ANOMALY_05000262 (__SILICON_REVISION__ < 5) ++/* Hardware Loop Corrupted When Taking an ICPLB Exception */ ++#define ANOMALY_05000263 (__SILICON_REVISION__ < 5) ++/* CSYNC/SSYNC/IDLE Causes Infinite Stall in Penultimate Instruction in Hardware Loop */ ++#define ANOMALY_05000264 (__SILICON_REVISION__ < 5) ++/* Sensitivity To Noise with Slow Input Edge Rates on External SPORT TX and RX Clocks */ ++#define ANOMALY_05000265 (__SILICON_REVISION__ < 5) ++/* IMDMA destination IRQ status must be read prior to using IMDMA */ ++#define ANOMALY_05000266 (__SILICON_REVISION__ > 3) ++/* IMDMA may corrupt data under certain conditions */ ++#define ANOMALY_05000267 (1) ++/* High I/O Activity Causes Output Voltage of Internal Voltage Regulator (Vddint) to Increase */ ++#define ANOMALY_05000269 (1) ++/* High I/O Activity Causes Output Voltage of Internal Voltage Regulator (Vddint) to Decrease */ ++#define ANOMALY_05000270 (1) ++/* Certain Data Cache Writethrough Modes Fail for Vddint <= 0.9V */ ++#define ANOMALY_05000272 (1) ++/* Data cache write back to external synchronous memory may be lost */ ++#define ANOMALY_05000274 (1) ++/* PPI Timing and Sampling Information Updates */ ++#define ANOMALY_05000275 (__SILICON_REVISION__ > 2) ++/* Timing Requirements Change for External Frame Sync PPI Modes with Non-Zero PPI_DELAY */ ++#define ANOMALY_05000276 (__SILICON_REVISION__ < 5) ++/* Disabling Peripherals with DMA Running May Cause DMA System Instability */ ++#define ANOMALY_05000278 (__SILICON_REVISION__ < 5) ++/* False Hardware Error Exception When ISR Context Is Not Restored */ ++#define ANOMALY_05000281 (__SILICON_REVISION__ < 5) ++/* System MMR Write Is Stalled Indefinitely When Killed in a Particular Stage */ ++#define ANOMALY_05000283 (1) ++/* A read will receive incorrect data under certain conditions */ ++#define ANOMALY_05000287 (__SILICON_REVISION__ < 5) ++/* SPORTs May Receive Bad Data If FIFOs Fill Up */ ++#define ANOMALY_05000288 (__SILICON_REVISION__ < 5) ++/* Memory-To-Memory DMA Source/Destination Descriptors Must Be in Same Memory Space */ ++#define ANOMALY_05000301 (1) ++/* SSYNCs After Writes To DMA MMR Registers May Not Be Handled Correctly */ ++#define ANOMALY_05000302 (1) ++/* New Feature: Additional Hysteresis on SPORT Input Pins (Not Available On Older Silicon) */ ++#define ANOMALY_05000305 (__SILICON_REVISION__ < 5) ++/* SCKELOW Bit Does Not Maintain State Through Hibernate */ ++#define ANOMALY_05000307 (__SILICON_REVISION__ < 5) ++/* False Hardware Errors Caused by Fetches at the Boundary of Reserved Memory */ ++#define ANOMALY_05000310 (1) ++/* Errors When SSYNC, CSYNC, or Loads to LT, LB and LC Registers Are Interrupted */ ++#define ANOMALY_05000312 (1) ++/* PPI Is Level-Sensitive on First Transfer */ ++#define ANOMALY_05000313 (1) ++/* Killed System MMR Write Completes Erroneously On Next System MMR Access */ ++#define ANOMALY_05000315 (1) ++/* PF2 Output Remains Asserted After SPI Master Boot */ ++#define ANOMALY_05000320 (__SILICON_REVISION__ > 3) ++/* Erroneous GPIO Flag Pin Operations Under Specific Sequences */ ++#define ANOMALY_05000323 (1) ++/* SPORT Secondary Receive Channel Not Functional When Word Length Exceeds 16 Bits */ ++#define ANOMALY_05000326 (__SILICON_REVISION__ > 3) ++/* New Feature: 24-Bit SPI Boot Mode Support (Not Available On Older Silicon) */ ++#define ANOMALY_05000331 (__SILICON_REVISION__ < 5) ++/* New Feature: Slave SPI Boot Mode Supported (Not Available On Older Silicon) */ ++#define ANOMALY_05000332 (__SILICON_REVISION__ < 5) ++/* Flag Data Register Writes One SCLK Cycle After Edge Is Detected May Clear Interrupt Status */ ++#define ANOMALY_05000333 (__SILICON_REVISION__ < 5) + +-#endif /* (defined(CONFIG_BF_REV_0_5) || defined(CONFIG_BF_REV_0_3)) */ ++/* Anomalies that don't exist on this proc */ ++#define ANOMALY_05000183 (0) ++#define ANOMALY_05000273 (0) ++#define ANOMALY_05000311 (0) + +-#if (defined(CONFIG_BF_REV_0_5)) +-#define ANOMALY_05000254 /* Incorrect Timer Pulse Width in Single-Shot PWM_OUT +- * mode with external clock */ +-#define ANOMALY_05000266 /* IMDMA destination IRQ status must be read prior to +- * using IMDMA */ + #endif +- +-#if (defined(CONFIG_BF_REV_0_3)) +-#define ANOMALY_05000156 /* Timers in PWM-Out Mode with PPI GP Receive (Input) +- * Mode with 0 Frame Syncs */ +-#define ANOMALY_05000168 /* SDRAM auto-refresh and subsequent Power Ups */ +-#define ANOMALY_05000169 /* DATA CPLB page miss can result in lost write-through +- * cache data writes */ +-#define ANOMALY_05000171 /* Boot-ROM code modifies SICA_IWRx wakeup registers */ +-#define ANOMALY_05000174 /* Cache Fill Buffer Data lost */ +-#define ANOMALY_05000175 /* Overlapping Sequencer and Memory Stalls */ +-#define ANOMALY_05000176 /* Multiplication of (-1) by (-1) followed by an +- * accumulator saturation */ +-#define ANOMALY_05000179 /* PPI_COUNT cannot be programmed to 0 in General +- * Purpose TX or RX modes */ +-#define ANOMALY_05000181 /* Disabling the PPI resets the PPI configuration +- * registers */ +-#define ANOMALY_05000184 /* Timer Pin limitations for PPI TX Modes with +- * External Frame Syncs */ +-#define ANOMALY_05000185 /* PPI TX Mode with 2 External Frame Syncs */ +-#define ANOMALY_05000186 /* PPI packing with Data Length greater than 8 bits +- * (not a meaningful mode) */ +-#define ANOMALY_05000188 /* IMDMA Restrictions on Descriptor and Buffer +- * Placement in Memory */ +-#define ANOMALY_05000189 /* False Protection Exception */ +-#define ANOMALY_05000193 /* False Flag Pin Interrupts on Edge Sensitive Inputs +- * when polarity setting is changed */ +-#define ANOMALY_05000194 /* Restarting SPORT in specific modes may cause data +- * corruption */ +-#define ANOMALY_05000198 /* Failing MMR accesses when stalled by preceding +- * memory read */ +-#define ANOMALY_05000199 /* DMA current address shows wrong value during carry +- * fix */ +-#define ANOMALY_05000200 /* SPORT TFS and DT are incorrectly driven during +- * inactive channels in certain conditions */ +-#define ANOMALY_05000202 /* Possible infinite stall with specific dual-DAG +- * situation */ +-#define ANOMALY_05000204 /* Incorrect data read with write-through cache and +- * allocate cache lines on reads only mode */ +-#define ANOMALY_05000205 /* Specific sequence that can cause DMA error or DMA +- * stopping */ +-#define ANOMALY_05000207 /* Recovery from "brown-out" condition */ +-#define ANOMALY_05000209 /* Speed-Path in computational unit affects certain +- * instructions */ +-#define ANOMALY_05000215 /* UART TX Interrupt masked erroneously */ +-#define ANOMALY_05000219 /* NMI event at boot time results in unpredictable +- * state */ +-#define ANOMALY_05000220 /* Data Corruption with Cached External Memory and +- * Non-Cached On-Chip L2 Memory */ +-#define ANOMALY_05000225 /* Incorrect pulse-width of UART start-bit */ +-#define ANOMALY_05000227 /* Scratchpad memory bank reads may return incorrect +- * data */ +-#define ANOMALY_05000230 /* UART Receiver is less robust against Baudrate +- * Differences in certain Conditions */ +-#define ANOMALY_05000231 /* UART STB bit incorrectly affects receiver setting */ +-#define ANOMALY_05000232 /* SPORT data transmit lines are incorrectly driven in +- * multichannel mode */ +-#define ANOMALY_05000242 /* DF bit in PLL_CTL register does not respond to +- * hardware reset */ +-#define ANOMALY_05000244 /* If i-cache is on, CSYNC/SSYNC/IDLE around Change of +- * Control causes failures */ +-#define ANOMALY_05000248 /* TESTSET operation forces stall on the other core */ +-#define ANOMALY_05000250 /* Incorrect Bit-Shift of Data Word in Multichannel +- * (TDM) mode in certain conditions */ +-#define ANOMALY_05000251 /* Exception not generated for MMR accesses in +- * reserved region */ +-#define ANOMALY_05000253 /* Maximum external clock speed for Timers */ +-#define ANOMALY_05000258 /* Instruction Cache is corrupted when bits 9 and 12 +- * of the ICPLB Data registers differ */ +-#define ANOMALY_05000260 /* ICPLB_STATUS MMR register may be corrupted */ +-#define ANOMALY_05000261 /* DCPLB_FAULT_ADDR MMR register may be corrupted */ +-#define ANOMALY_05000262 /* Stores to data cache may be lost */ +-#define ANOMALY_05000263 /* Hardware loop corrupted when taking an ICPLB +- * exception */ +-#define ANOMALY_05000264 /* CSYNC/SSYNC/IDLE causes infinite stall in second +- * to last instruction in hardware loop */ +-#define ANOMALY_05000276 /* Timing requirements change for External Frame +- * Sync PPI Modes with non-zero PPI_DELAY */ +-#define ANOMALY_05000278 /* Disabling Peripherals with DMA running may cause +- * DMA system instability */ +-#define ANOMALY_05000281 /* False Hardware Error Exception when ISR context is +- * not restored */ +-#define ANOMALY_05000283 /* An MMR write is stalled indefinitely when killed +- * in a particular stage */ +-#define ANOMALY_05000287 /* A read will receive incorrect data under certain +- * conditions */ +-#define ANOMALY_05000288 /* SPORTs may receive bad data if FIFOs fill up */ +-#endif +- +-#endif /* _MACH_ANOMALY_H_ */ +Index: include/asm-blackfin/mach-bf561/bf561.h +=================================================================== +--- include/asm-blackfin/mach-bf561/bf561.h (revision 3448) ++++ include/asm-blackfin/mach-bf561/bf561.h (working copy) +@@ -311,7 +311,7 @@ + #define CONFIG_CCLK_ACT_DIV CONFIG_CCLK_DIV_not_defined_properly + #endif + +-#if defined(ANOMALY_05000273) && (CONFIG_CCLK_DIV == 1) ++#if ANOMALY_05000273 && (CONFIG_CCLK_DIV == 1) + #error ANOMALY 05000273, please make sure CCLK is at least 2x SCLK + #endif + +Index: include/asm-blackfin/mach-common/def_LPBlackfin.h +=================================================================== +--- include/asm-blackfin/mach-common/def_LPBlackfin.h (revision 3448) ++++ include/asm-blackfin/mach-common/def_LPBlackfin.h (working copy) +@@ -33,80 +33,76 @@ + + #include + +-/*#if !defined(__ADSPLPBLACKFIN__) +-#warning def_LPBlackfin.h should only be included for 532 compatible chips. +-#endif +-*/ +- + #define MK_BMSK_(x) (1< + +-#define bfin_read16(addr) ({ unsigned __v; \ +- __asm__ __volatile__ ("NOP;\n\t"\ +- "%0 = w[%1] (z);\n\t"\ +- : "=d"(__v) : "a"(addr)); (unsigned short)__v; }) +- +-#define bfin_read32(addr) ({ unsigned __v; \ +- __asm__ __volatile__ ("NOP;\n\t"\ +- "%0 = [%1];\n\t"\ +- : "=d"(__v) : "a"(addr)); __v; }) +- +-#define bfin_write8(addr, val) ({ \ +- __asm__ __volatile__ ("NOP;\n\t" \ +- "b[%0] = %1;\n\t" \ +- : : "a"(addr), "d"(val) : "memory");}) +- +-#define bfin_write16(addr,val) ({\ +- __asm__ __volatile__ ("NOP;\n\t"\ +- "w[%0] = %1;\n\t"\ +- : : "a"(addr) , "d"(val) : "memory");}) +- +-#define bfin_write32(addr,val) ({\ +- __asm__ __volatile__ ("NOP;\n\t"\ +- "[%0] = %1;\n\t"\ +- : : "a"(addr) , "d"(val) : "memory");}) +- ++#if ANOMALY_05000198 ++# define NOP_PAD_ANOMALY_05000198 "nop;" + #else ++# define NOP_PAD_ANOMALY_05000198 ++#endif + +-#define bfin_read8(addr) ({ unsigned char __v; \ +- __asm__ __volatile__ ( \ +- "%0 = b[%1] (z);\n\t" \ +- :"=d"(__v) : "a"(addr)); \ +- __v; }) ++#define bfin_read8(addr) ({ \ ++ uint8_t __v; \ ++ __asm__ __volatile__ ( \ ++ NOP_PAD_ANOMALY_05000198 \ ++ "%0 = b[%1] (z);" \ ++ : "=d" (__v) \ ++ : "a" (addr) \ ++ ); \ ++ __v; }) + +-#define bfin_read16(addr) ({ unsigned __v; \ +- __asm__ __volatile__ (\ +- "%0 = w[%1] (z);\n\t"\ +- : "=d"(__v) : "a"(addr)); (unsigned short)__v; }) ++#define bfin_read16(addr) ({ \ ++ uint16_t __v; \ ++ __asm__ __volatile__ ( \ ++ NOP_PAD_ANOMALY_05000198 \ ++ "%0 = w[%1] (z);" \ ++ : "=d" (__v) \ ++ : "a" (addr) \ ++ ); \ ++ __v; }) + +-#define bfin_read32(addr) ({ unsigned __v; \ +- __asm__ __volatile__ (\ +- "%0 = [%1];\n\t"\ +- : "=d"(__v) : "a"(addr)); __v; }) ++#define bfin_read32(addr) ({ \ ++ uint32_t __v; \ ++ __asm__ __volatile__ ( \ ++ NOP_PAD_ANOMALY_05000198 \ ++ "%0 = [%1];" \ ++ : "=d" (__v) \ ++ : "a" (addr) \ ++ ); \ ++ __v; }) + + #define bfin_write8(addr, val) ({ \ +- __asm__ __volatile__ ( \ +- "b[%0] = %1; \n\t" \ +- ::"a"(addr), "d"(val) : "memory");}) ++ __asm__ __volatile__ ( \ ++ NOP_PAD_ANOMALY_05000198 \ ++ "b[%0] = %1;" \ ++ : \ ++ : "a" (addr), "d" (val) \ ++ : "memory" \ ++ ); }) + +-#define bfin_write16(addr,val) ({\ +- __asm__ __volatile__ (\ +- "w[%0] = %1;\n\t"\ +- : : "a"(addr) , "d"(val) : "memory");}) ++#define bfin_write16(addr, val) ({ \ ++ __asm__ __volatile__ ( \ ++ NOP_PAD_ANOMALY_05000198 \ ++ "w[%0] = %1;" \ ++ : \ ++ : "a" (addr), "d" (val) \ ++ : "memory" \ ++ ); }) + +-#define bfin_write32(addr,val) ({\ +- __asm__ __volatile__ (\ +- "[%0] = %1;\n\t"\ +- : : "a"(addr) , "d"(val) : "memory");}) ++#define bfin_write32(addr, val) ({ \ ++ __asm__ __volatile__ ( \ ++ NOP_PAD_ANOMALY_05000198 \ ++ "[%0] = %1;" \ ++ : \ ++ : "a" (addr), "d" (val) \ ++ : "memory" \ ++ ); }) + +-#endif ++#endif /* __ASSEMBLY__ */ + + /************************************************** + * System Register Bits +Index: include/asm-blackfin/mach-common/cdef_LPBlackfin.h +=================================================================== +--- include/asm-blackfin/mach-common/cdef_LPBlackfin.h (revision 3448) ++++ include/asm-blackfin/mach-common/cdef_LPBlackfin.h (working copy) +@@ -39,7 +39,7 @@ + #define bfin_read_SRAM_BASE_ADDRESS() bfin_read32(SRAM_BASE_ADDRESS) + #define bfin_write_SRAM_BASE_ADDRESS(val) bfin_write32(SRAM_BASE_ADDRESS,val) + #define bfin_read_DMEM_CONTROL() bfin_read32(DMEM_CONTROL) +-#ifdef ANOMALY_05000125 ++#if ANOMALY_05000125 + extern void bfin_write_DMEM_CONTROL(unsigned int val); + #else + #define bfin_write_DMEM_CONTROL(val) bfin_write32(DMEM_CONTROL,val) +@@ -129,7 +129,7 @@ + #define DTEST_DATA3 0xFFE0040C + */ + #define bfin_read_IMEM_CONTROL() bfin_read32(IMEM_CONTROL) +-#ifdef ANOMALY_05000125 ++#if ANOMALY_05000125 + extern void bfin_write_IMEM_CONTROL(unsigned int val); + #else + #define bfin_write_IMEM_CONTROL(val) bfin_write32(IMEM_CONTROL,val) +Index: include/asm-blackfin/system.h +=================================================================== +--- include/asm-blackfin/system.h (revision 3448) ++++ include/asm-blackfin/system.h (working copy) +@@ -36,6 +36,7 @@ + + #include + #include ++#include + + /* + * Interrupt configuring macros. +@@ -56,23 +57,22 @@ + :"=d" (_tmp_dummy):); \ + } while (0) + +-#if defined(ANOMALY_05000244) && defined (CONFIG_BLKFIN_CACHE) +-#define idle_with_irq_disabled() do { \ +- __asm__ __volatile__ ( \ +- "nop; nop;\n" \ +- ".align 8;\n" \ +- "sti %0; idle;\n" \ +- ::"d" (irq_flags)); \ +-} while (0) ++#if ANOMALY_05000244 && defined(CONFIG_BLKFIN_CACHE) ++# define NOP_PAD_ANOMALY_05000244 "nop; nop;" + #else +-#define idle_with_irq_disabled() do { \ +- __asm__ __volatile__ ( \ +- ".align 8;\n" \ +- "sti %0; idle;\n" \ +- ::"d" (irq_flags)); \ +-} while (0) ++# define NOP_PAD_ANOMALY_05000244 + #endif + ++#define idle_with_irq_disabled() \ ++ __asm__ __volatile__ ( \ ++ NOP_PAD_ANOMALY_05000244 \ ++ ".align 8;" \ ++ "sti %0;" \ ++ "idle;" \ ++ : \ ++ : "d" (irq_flags) \ ++ ); ++ + #ifdef CONFIG_DEBUG_HWERR + #define __save_and_cli(x) do { \ + __asm__ __volatile__ ( \ +Index: include/asm-blackfin/mach-bf533/anomaly.h +=================================================================== +--- include/asm-blackfin/mach-bf533/anomaly.h (revision 3448) ++++ include/asm-blackfin/mach-bf533/anomaly.h (working copy) +@@ -7,219 +7,252 @@ + */ + + /* This file shoule be up to date with: +- * - Revision U, May 17, 2006; ADSP-BF533 Blackfin Processor Anomaly List +- * - Revision Y, May 17, 2006; ADSP-BF532 Blackfin Processor Anomaly List +- * - Revision T, May 17, 2006; ADSP-BF531 Blackfin Processor Anomaly List ++ * - Revision X, March 23, 2007; ADSP-BF533 Blackfin Processor Anomaly List ++ * - Revision AB, March 23, 2007; ADSP-BF532 Blackfin Processor Anomaly List ++ * - Revision W, March 23, 2007; ADSP-BF531 Blackfin Processor Anomaly List + */ + + #ifndef _MACH_ANOMALY_H_ + #define _MACH_ANOMALY_H_ + + /* We do not support 0.1 or 0.2 silicon - sorry */ +-#if (defined(CONFIG_BF_REV_0_1) || defined(CONFIG_BF_REV_0_2)) +-#error Kernel will not work on BF533 Version 0.1 or 0.2 ++#if __SILICON_REVISION__ < 3 ++# error Kernel will not work on BF533 silicon version 0.0, 0.1, or 0.2 + #endif + +-/* Issues that are common to 0.5, 0.4, and 0.3 silicon */ +-#if (defined(CONFIG_BF_REV_0_5) || defined(CONFIG_BF_REV_0_4) \ +- || defined(CONFIG_BF_REV_0_3)) +-#define ANOMALY_05000074 /* A multi issue instruction with dsp32shiftimm in +- * slot1 and store of a P register in slot 2 is not +- * supported */ +-#define ANOMALY_05000105 /* Watchpoint Status Register (WPSTAT) bits are set on +- * every corresponding match */ +-#define ANOMALY_05000119 /* DMA_RUN bit is not valid after a Peripheral Receive +- * Channel DMA stops */ +-#define ANOMALY_05000122 /* Rx.H can not be used to access 16-bit System MMR +- * registers. */ +-#define ANOMALY_05000166 /* PPI Data Lengths Between 8 and 16 do not zero out +- * upper bits*/ +-#define ANOMALY_05000167 /* Turning Serial Ports on With External Frame Syncs */ +-#define ANOMALY_05000180 /* PPI_DELAY not functional in PPI modes with 0 frame +- * syncs */ +-#define ANOMALY_05000208 /* VSTAT status bit in PLL_STAT register is not +- * functional */ +-#define ANOMALY_05000219 /* NMI event at boot time results in unpredictable +- * state */ +-#define ANOMALY_05000229 /* SPI Slave Boot Mode modifies registers */ +-#define ANOMALY_05000272 /* Certain data cache write through modes fail for +- * VDDint <=0.9V */ +-#define ANOMALY_05000273 /* Writes to Synchronous SDRAM memory may be lost */ +-#define ANOMALY_05000277 /* Writes to a flag data register one SCLK cycle after +- * an edge is detected may clear interrupt */ +-#define ANOMALY_05000278 /* Disabling Peripherals with DMA running may cause +- * DMA system instability */ +-#define ANOMALY_05000281 /* False Hardware Error Exception when ISR context is +- * not restored */ +-#define ANOMALY_05000282 /* Memory DMA corruption with 32-bit data and traffic +- * control */ +-#define ANOMALY_05000283 /* A system MMR write is stalled indefinitely when +- * killed in a particular stage*/ +-#define ANOMALY_05000311 /* Erroneous flag pin operations under specific +- * sequences */ +-#define ANOMALY_05000312 /* Errors when SSYNC, CSYNC, or loads to LT, LB and LC +- * registers are interrupted */ +-#define ANOMALY_05000313 /* PPI Is Level-Sensitive on First Transfer */ +-#define ANOMALY_05000315 /* Killed System MMR Write Completes Erroneously On +- * Next System MMR Access */ +-#define ANOMALY_05000319 /* Internal Voltage Regulator Values of 1.05V, 1.10V +- * and 1.15V Not Allowed for LQFP Packages */ +-#endif /* Issues that are common to 0.5, 0.4, and 0.3 silicon */ ++#if defined(__ADSPBF531__) ++# define ANOMALY_BF531 1 ++#else ++# define ANOMALY_BF531 0 ++#endif ++#if defined(__ADSPBF532__) ++# define ANOMALY_BF532 1 ++#else ++# define ANOMALY_BF532 0 ++#endif ++#if defined(__ADSPBF533__) ++# define ANOMALY_BF533 1 ++#else ++# define ANOMALY_BF533 0 ++#endif + +-/* These issues only occur on 0.3 or 0.4 BF533 */ +-#if (defined(CONFIG_BF_REV_0_4) || defined(CONFIG_BF_REV_0_3)) +-#define ANOMALY_05000099 /* UART Line Status Register (UART_LSR) bits are not +- * updated at the same time. */ +-#define ANOMALY_05000158 /* Boot fails when data cache enabled: Data from a Data +- * Cache Fill can be corrupted after or during +- * Instruction DMA if certain core stalls exist */ +-#define ANOMALY_05000179 /* PPI_COUNT cannot be programmed to 0 in General +- * Purpose TX or RX modes */ +-#define ANOMALY_05000198 /* Failing SYSTEM MMR accesses when stalled by +- * preceding memory read */ +-#define ANOMALY_05000200 /* SPORT TFS and DT are incorrectly driven during +- * inactive channels in certain conditions */ +-#define ANOMALY_05000202 /* Possible infinite stall with specific dual dag +- * situation */ +-#define ANOMALY_05000215 /* UART TX Interrupt masked erroneously */ +-#define ANOMALY_05000225 /* Incorrect pulse-width of UART start-bit */ +-#define ANOMALY_05000227 /* Scratchpad memory bank reads may return incorrect +- * data*/ +-#define ANOMALY_05000230 /* UART Receiver is less robust against Baudrate +- * Differences in certain Conditions */ +-#define ANOMALY_05000231 /* UART STB bit incorrectly affects receiver setting */ +-#define ANOMALY_05000242 /* DF bit in PLL_CTL register does not respond to +- * hardware reset */ +-#define ANOMALY_05000244 /* With instruction cache enabled, a CSYNC or SSYNC or +- * IDLE around a Change of Control causes +- * unpredictable results */ +-#define ANOMALY_05000245 /* Spurious Hardware Error from an access in the +- * shadow of a conditional branch */ +-#define ANOMALY_05000246 /* Data CPLB's should prevent spurious hardware +- * errors */ +-#define ANOMALY_05000253 /* Maximum external clock speed for Timers */ +-#define ANOMALY_05000255 /* Entering Hibernate Mode with RTC Seconds event +- * interrupt not functional */ +-#define ANOMALY_05000257 /* An interrupt or exception during short Hardware +- * loops may cause the instruction fetch unit to +- * malfunction */ +-#define ANOMALY_05000258 /* Instruction Cache is corrupted when bit 9 and 12 of +- * the ICPLB Data registers differ */ +-#define ANOMALY_05000260 /* ICPLB_STATUS MMR register may be corrupted */ +-#define ANOMALY_05000261 /* DCPLB_FAULT_ADDR MMR register may be corrupted */ +-#define ANOMALY_05000262 /* Stores to data cache may be lost */ +-#define ANOMALY_05000263 /* Hardware loop corrupted when taking an ICPLB exception */ +-#define ANOMALY_05000264 /* A Sync instruction (CSYNC, SSYNC) or an IDLE +- * instruction will cause an infinite stall in the +- * second to last instruction in a hardware loop */ +-#define ANOMALY_05000265 /* Sensitivity to noise with slow input edge rates on +- * SPORT external receive and transmit clocks. */ +-#define ANOMALY_05000269 /* High I/O activity causes the output voltage of the +- * internal voltage regulator (VDDint) to increase. */ +-#define ANOMALY_05000270 /* High I/O activity causes the output voltage of the +- * internal voltage regulator (VDDint) to decrease */ +-#endif /* issues only occur on 0.3 or 0.4 BF533 */ ++/* Multi-Issue Instruction with dsp32shiftimm in slot1 and P-reg Store in slot 2 Not Supported */ ++#define ANOMALY_05000074 (1) ++/* UART Line Status Register (UART_LSR) Bits Are Not Updated at the Same Time */ ++#define ANOMALY_05000099 (__SILICON_REVISION__ < 5) ++/* Watchpoint Status Register (WPSTAT) Bits Are Set on Every Corresponding Match */ ++#define ANOMALY_05000105 (1) ++/* DMA_RUN Bit Is Not Valid after a Peripheral Receive Channel DMA Stops */ ++#define ANOMALY_05000119 (1) ++/* Rx.H Cannot Be Used to Access 16-bit System MMR Registers */ ++#define ANOMALY_05000122 (1) ++/* Instruction DMA Can Cause Data Cache Fills to Fail (Boot Implications) */ ++#define ANOMALY_05000158 (__SILICON_REVISION__ < 5) ++/* PPI Data Lengths Between 8 and 16 Do Not Zero Out Upper Bits */ ++#define ANOMALY_05000166 (1) ++/* Turning Serial Ports on with External Frame Syncs */ ++#define ANOMALY_05000167 (1) ++/* PPI_COUNT Cannot Be Programmed to 0 in General Purpose TX or RX Modes */ ++#define ANOMALY_05000179 (__SILICON_REVISION__ < 5) ++/* PPI_DELAY Not Functional in PPI Modes with 0 Frame Syncs */ ++#define ANOMALY_05000180 (1) ++/* Timer Pin Limitations for PPI TX Modes with External Frame Syncs */ ++#define ANOMALY_05000183 (__SILICON_REVISION__ < 4) ++/* False Protection Exceptions */ ++#define ANOMALY_05000189 (__SILICON_REVISION__ < 4) ++/* False I/O Pin Interrupts on Edge-Sensitive Inputs When Polarity Setting Is Changed */ ++#define ANOMALY_05000193 (__SILICON_REVISION__ < 4) ++/* Restarting SPORT in Specific Modes May Cause Data Corruption */ ++#define ANOMALY_05000194 (__SILICON_REVISION__ < 4) ++/* Failing MMR Accesses When Stalled by Preceding Memory Read */ ++#define ANOMALY_05000198 (__SILICON_REVISION__ < 5) ++/* Current DMA Address Shows Wrong Value During Carry Fix */ ++#define ANOMALY_05000199 (__SILICON_REVISION__ < 4) ++/* SPORT TFS and DT Are Incorrectly Driven During Inactive Channels in Certain Conditions */ ++#define ANOMALY_05000200 (__SILICON_REVISION__ < 5) ++/* Receive Frame Sync Not Ignored During Active Frames in SPORT Multi-Channel Mode */ ++#define ANOMALY_05000201 (__SILICON_REVISION__ < 4) ++/* Possible Infinite Stall with Specific Dual-DAG Situation */ ++#define ANOMALY_05000202 (__SILICON_REVISION__ < 5) ++/* Specific Sequence That Can Cause DMA Error or DMA Stopping */ ++#define ANOMALY_05000203 (__SILICON_REVISION__ < 4) ++/* Incorrect data read with write-through cache and allocate cache lines on reads only mode */ ++#define ANOMALY_05000204 (__SILICON_REVISION__ < 4 && ANOMALY_BF533) ++/* Recovery from "Brown-Out" Condition */ ++#define ANOMALY_05000207 (__SILICON_REVISION__ < 4) ++/* VSTAT Status Bit in PLL_STAT Register Is Not Functional */ ++#define ANOMALY_05000208 (1) ++/* Speed Path in Computational Unit Affects Certain Instructions */ ++#define ANOMALY_05000209 (__SILICON_REVISION__ < 4) ++/* UART TX Interrupt Masked Erroneously */ ++#define ANOMALY_05000215 (__SILICON_REVISION__ < 5) ++/* NMI Event at Boot Time Results in Unpredictable State */ ++#define ANOMALY_05000219 (1) ++/* Incorrect Pulse-Width of UART Start Bit */ ++#define ANOMALY_05000225 (__SILICON_REVISION__ < 5) ++/* Scratchpad Memory Bank Reads May Return Incorrect Data */ ++#define ANOMALY_05000227 (__SILICON_REVISION__ < 5) ++/* SPI Slave Boot Mode Modifies Registers from Reset Value */ ++#define ANOMALY_05000229 (1) ++/* UART Receiver is Less Robust Against Baudrate Differences in Certain Conditions */ ++#define ANOMALY_05000230 (__SILICON_REVISION__ < 5) ++/* UART STB Bit Incorrectly Affects Receiver Setting */ ++#define ANOMALY_05000231 (__SILICON_REVISION__ < 5) ++/* PPI_FS3 Is Not Driven in 2 or 3 Internal Frame Sync Transmit Modes */ ++#define ANOMALY_05000233 (__SILICON_REVISION__ < 4) ++/* Incorrect Revision Number in DSPID Register */ ++#define ANOMALY_05000234 (__SILICON_REVISION__ == 4) ++/* DF Bit in PLL_CTL Register Does Not Respond to Hardware Reset */ ++#define ANOMALY_05000242 (__SILICON_REVISION__ < 4) ++/* If I-Cache Is On, CSYNC/SSYNC/IDLE Around Change of Control Causes Failures */ ++#define ANOMALY_05000244 (__SILICON_REVISION__ < 5) ++/* Spurious Hardware Error from an Access in the Shadow of a Conditional Branch */ ++#define ANOMALY_05000245 (1) ++/* Data CPLBs Should Prevent Spurious Hardware Errors */ ++#define ANOMALY_05000246 (__SILICON_REVISION__ < 5) ++/* Incorrect Bit Shift of Data Word in Multichannel (TDM) Mode in Certain Conditions */ ++#define ANOMALY_05000250 (__SILICON_REVISION__ == 4) ++/* Maximum External Clock Speed for Timers */ ++#define ANOMALY_05000253 (__SILICON_REVISION__ < 5) ++/* Incorrect Timer Pulse Width in Single-Shot PWM_OUT Mode with External Clock */ ++#define ANOMALY_05000254 (__SILICON_REVISION__ > 4) ++/* Entering Hibernate State with RTC Seconds Interrupt Not Functional */ ++#define ANOMALY_05000255 (__SILICON_REVISION__ < 5) ++/* Interrupt/Exception During Short Hardware Loop May Cause Bad Instruction Fetches */ ++#define ANOMALY_05000257 (__SILICON_REVISION__ < 5) ++/* Instruction Cache Is Corrupted When Bits 9 and 12 of the ICPLB Data Registers Differ */ ++#define ANOMALY_05000258 (__SILICON_REVISION__ < 5) ++/* ICPLB_STATUS MMR Register May Be Corrupted */ ++#define ANOMALY_05000260 (__SILICON_REVISION__ < 5) ++/* DCPLB_FAULT_ADDR MMR Register May Be Corrupted */ ++#define ANOMALY_05000261 (__SILICON_REVISION__ < 5) ++/* Stores To Data Cache May Be Lost */ ++#define ANOMALY_05000262 (__SILICON_REVISION__ < 5) ++/* Hardware Loop Corrupted When Taking an ICPLB Exception */ ++#define ANOMALY_05000263 (__SILICON_REVISION__ < 5) ++/* CSYNC/SSYNC/IDLE Causes Infinite Stall in Penultimate Instruction in Hardware Loop */ ++#define ANOMALY_05000264 (__SILICON_REVISION__ < 5) ++/* Sensitivity To Noise with Slow Input Edge Rates on External SPORT TX and RX Clocks */ ++#define ANOMALY_05000265 (__SILICON_REVISION__ < 5) ++/* High I/O Activity Causes Output Voltage of Internal Voltage Regulator (Vddint) to Increase */ ++#define ANOMALY_05000269 (__SILICON_REVISION__ < 5) ++/* High I/O Activity Causes Output Voltage of Internal Voltage Regulator (Vddint) to Decrease */ ++#define ANOMALY_05000270 (__SILICON_REVISION__ < 5) ++/* Spontaneous Reset of Internal Voltage Regulator */ ++#define ANOMALY_05000271 (__SILICON_REVISION__ < 4) ++/* Certain Data Cache Writethrough Modes Fail for Vddint <= 0.9V */ ++#define ANOMALY_05000272 (1) ++/* Writes to Synchronous SDRAM Memory May Be Lost */ ++#define ANOMALY_05000273 (1) ++/* Timing Requirements Change for External Frame Sync PPI Modes with Non-Zero PPI_DELAY */ ++#define ANOMALY_05000276 (1) ++/* Writes to an I/O Data Register One SCLK Cycle after an Edge Is Detected May Clear Interrupt */ ++#define ANOMALY_05000277 (1) ++/* Disabling Peripherals with DMA Running May Cause DMA System Instability */ ++#define ANOMALY_05000278 (1) ++/* False Hardware Error Exception When ISR Context Is Not Restored */ ++#define ANOMALY_05000281 (1) ++/* Memory DMA Corruption with 32-Bit Data and Traffic Control */ ++#define ANOMALY_05000282 (1) ++/* System MMR Write Is Stalled Indefinitely When Killed in a Particular Stage */ ++#define ANOMALY_05000283 (1) ++/* SPORTs May Receive Bad Data If FIFOs Fill Up */ ++#define ANOMALY_05000288 (1) ++/* Memory-To-Memory DMA Source/Destination Descriptors Must Be in Same Memory Space */ ++#define ANOMALY_05000301 (1) ++/* SSYNCs After Writes To DMA MMR Registers May Not Be Handled Correctly */ ++#define ANOMALY_05000302 (__SILICON_REVISION__ < 5) ++/* New Feature: Additional Hysteresis on SPORT Input Pins (Not Available On Older Silicon) */ ++#define ANOMALY_05000305 (__SILICON_REVISION__ < 5) ++/* New Feature: Additional PPI Frame Sync Sampling Options (Not Available On Older Silicon) */ ++#define ANOMALY_05000306 (__SILICON_REVISION__ < 5) ++/* False Hardware Errors Caused by Fetches at the Boundary of Reserved Memory */ ++#define ANOMALY_05000310 (1) ++/* Erroneous Flag (GPIO) Pin Operations under Specific Sequences */ ++#define ANOMALY_05000311 (1) ++/* Errors When SSYNC, CSYNC, or Loads to LT, LB and LC Registers Are Interrupted */ ++#define ANOMALY_05000312 (1) ++/* PPI Is Level-Sensitive on First Transfer */ ++#define ANOMALY_05000313 (1) ++/* Killed System MMR Write Completes Erroneously On Next System MMR Access */ ++#define ANOMALY_05000315 (1) ++/* Internal Voltage Regulator Values of 1.05V, 1.10V and 1.15V Not Allowed for LQFP Packages */ ++#define ANOMALY_05000319 (ANOMALY_BF531 || ANOMALY_BF532) + +-/* These issues are only on 0.4 silicon */ +-#if (defined(CONFIG_BF_REV_0_4)) +-#define ANOMALY_05000234 /* Incorrect Revision Number in DSPID Register */ +-#define ANOMALY_05000250 /* Incorrect Bit-Shift of Data Word in Multichannel +- * (TDM) */ +-#endif /* issues are only on 0.4 silicon */ ++/* These anomalies have been "phased" out of analog.com anomaly sheets and are ++ * here to show running on older silicon just isn't feasible. ++ */ + +-/* These issues are only on 0.3 silicon */ +-#if defined(CONFIG_BF_REV_0_3) +-#define ANOMALY_05000183 /* Timer Pin limitations for PPI TX Modes with +- * External Frame Syncs */ +-#define ANOMALY_05000189 /* False Protection Exceptions caused by Speculative +- * Instruction or Data Fetches, or by Fetches at the +- * boundary of reserved memory space */ +-#define ANOMALY_05000193 /* False Flag Pin Interrupts on Edge Sensitive Inputs +- * when polarity setting is changed */ +-#define ANOMALY_05000194 /* Sport Restarting in specific modes may cause data +- * corruption */ +-#define ANOMALY_05000199 /* DMA current address shows wrong value during carry +- * fix */ +-#define ANOMALY_05000201 /* Receive frame sync not ignored during active +- * frames in sport MCM */ +-#define ANOMALY_05000203 /* Specific sequence that can cause DMA error or DMA +- * stopping */ +-#if defined(CONFIG_BF533) +-#define ANOMALY_05000204 /* Incorrect data read with write-through cache and +- * allocate cache lines on reads only mode */ +-#endif /* CONFIG_BF533 */ +-#define ANOMALY_05000207 /* Recovery from "brown-out" condition */ +-#define ANOMALY_05000209 /* Speed-Path in computational unit affects certain +- * instructions */ +-#define ANOMALY_05000233 /* PPI_FS3 is not driven in 2 or 3 internal Frame +- * Sync Transmit Mode */ +-#define ANOMALY_05000271 /* Spontaneous reset of Internal Voltage Regulator */ +-#endif /* only on 0.3 silicon */ ++/* Watchpoints (Hardware Breakpoints) are not supported */ ++#define ANOMALY_05000067 (__SILICON_REVISION__ < 3) ++/* Reserved bits in SYSCFG register not set at power on */ ++#define ANOMALY_05000109 (__SILICON_REVISION__ < 3) ++/* Trace Buffers may record discontinuities into emulation mode and/or exception, NMI, reset handlers */ ++#define ANOMALY_05000116 (__SILICON_REVISION__ < 3) ++/* DTEST_COMMAND initiated memory access may be incorrect if data cache or DMA is active */ ++#define ANOMALY_05000123 (__SILICON_REVISION__ < 3) ++/* DMA Lock-up at CCLK to SCLK ratios of 4:1, 2:1, or 1:1 */ ++#define ANOMALY_05000124 (__SILICON_REVISION__ < 3) ++/* Erroneous exception when enabling cache */ ++#define ANOMALY_05000125 (__SILICON_REVISION__ < 3) ++/* SPI clock polarity and phase bits incorrect during booting */ ++#define ANOMALY_05000126 (__SILICON_REVISION__ < 3) ++/* DMEM_CONTROL is not set on Reset */ ++#define ANOMALY_05000137 (__SILICON_REVISION__ < 3) ++/* SPI boot will not complete if there is a zero fill block in the loader file */ ++#define ANOMALY_05000138 (__SILICON_REVISION__ < 3) ++/* Allowing the SPORT RX FIFO to fill will cause an overflow */ ++#define ANOMALY_05000140 (__SILICON_REVISION__ < 3) ++/* An Infinite Stall occurs with a particular sequence of consecutive dual dag events */ ++#define ANOMALY_05000141 (__SILICON_REVISION__ < 3) ++/* Interrupts may be lost when a programmable input flag is configured to be edge sensitive */ ++#define ANOMALY_05000142 (__SILICON_REVISION__ < 3) ++/* A read from external memory may return a wrong value with data cache enabled */ ++#define ANOMALY_05000143 (__SILICON_REVISION__ < 3) ++/* DMA and TESTSET conflict when both are accessing external memory */ ++#define ANOMALY_05000144 (__SILICON_REVISION__ < 3) ++/* In PWM_OUT mode, you must enable the PPI block to generate a waveform from PPI_CLK */ ++#define ANOMALY_05000145 (__SILICON_REVISION__ < 3) ++/* MDMA may lose the first few words of a descriptor chain */ ++#define ANOMALY_05000146 (__SILICON_REVISION__ < 3) ++/* The source MDMA descriptor may stop with a DMA Error */ ++#define ANOMALY_05000147 (__SILICON_REVISION__ < 3) ++/* When booting from a 16-bit asynchronous memory device, the upper 8-bits of each word must be 0x00 */ ++#define ANOMALY_05000148 (__SILICON_REVISION__ < 3) ++/* Frame Delay in SPORT Multichannel Mode */ ++#define ANOMALY_05000153 (__SILICON_REVISION__ < 3) ++/* SPORT TFS signal is active in Multi-channel mode outside of valid channels */ ++#define ANOMALY_05000154 (__SILICON_REVISION__ < 3) ++/* Timer1 can not be used for PWMOUT mode when a certain PPI mode is in use */ ++#define ANOMALY_05000155 (__SILICON_REVISION__ < 3) ++/* A killed 32-bit System MMR write will lead to the next system MMR access thinking it should be 32-bit. */ ++#define ANOMALY_05000157 (__SILICON_REVISION__ < 3) ++/* SPORT transmit data is not gated by external frame sync in certain conditions */ ++#define ANOMALY_05000163 (__SILICON_REVISION__ < 3) ++/* SDRAM auto-refresh and subsequent Power Ups */ ++#define ANOMALY_05000168 (__SILICON_REVISION__ < 3) ++/* DATA CPLB page miss can result in lost write-through cache data writes */ ++#define ANOMALY_05000169 (__SILICON_REVISION__ < 3) ++/* DMA vs Core accesses to external memory */ ++#define ANOMALY_05000173 (__SILICON_REVISION__ < 3) ++/* Cache Fill Buffer Data lost */ ++#define ANOMALY_05000174 (__SILICON_REVISION__ < 3) ++/* Overlapping Sequencer and Memory Stalls */ ++#define ANOMALY_05000175 (__SILICON_REVISION__ < 3) ++/* Multiplication of (-1) by (-1) followed by an accumulator saturation */ ++#define ANOMALY_05000176 (__SILICON_REVISION__ < 3) ++/* Disabling the PPI resets the PPI configuration registers */ ++#define ANOMALY_05000181 (__SILICON_REVISION__ < 3) ++/* PPI TX Mode with 2 External Frame Syncs */ ++#define ANOMALY_05000185 (__SILICON_REVISION__ < 3) ++/* PPI does not invert the Driving PPICLK edge in Transmit Modes */ ++#define ANOMALY_05000191 (__SILICON_REVISION__ < 3) ++/* In PPI Transmit Modes with External Frame Syncs POLC */ ++#define ANOMALY_05000192 (__SILICON_REVISION__ < 3) ++/* Internal Voltage Regulator may not start up */ ++#define ANOMALY_05000206 (__SILICON_REVISION__ < 3) + +-#if defined(CONFIG_BF_REV_0_2) +-#define ANOMALY_05000067 /* Watchpoints (Hardware Breakpoints) are not +- * supported */ +-#define ANOMALY_05000109 /* Reserved bits in SYSCFG register not set at +- * power on */ +-#define ANOMALY_05000116 /* Trace Buffers may record discontinuities into +- * emulation mode and/or exception, NMI, reset +- * handlers */ +-#define ANOMALY_05000123 /* DTEST_COMMAND initiated memory access may be +- * incorrect if data cache or DMA is active */ +-#define ANOMALY_05000124 /* DMA Lock-up at CCLK to SCLK ratios of 4:1, 2:1, +- * or 1:1 */ +-#define ANOMALY_05000125 /* Erroneous exception when enabling cache */ +-#define ANOMALY_05000126 /* SPI clock polarity and phase bits incorrect +- * during booting */ +-#define ANOMALY_05000137 /* DMEM_CONTROL is not set on Reset */ +-#define ANOMALY_05000138 /* SPI boot will not complete if there is a zero fill +- * block in the loader file */ +-#define ANOMALY_05000140 /* Allowing the SPORT RX FIFO to fill will cause an +- * overflow */ +-#define ANOMALY_05000141 /* An Infinite Stall occurs with a particular sequence +- * of consecutive dual dag events */ +-#define ANOMALY_05000142 /* Interrupts may be lost when a programmable input +- * flag is configured to be edge sensitive */ +-#define ANOMALY_05000143 /* A read from external memory may return a wrong +- * value with data cache enabled */ +-#define ANOMALY_05000144 /* DMA and TESTSET conflict when both are accessing +- * external memory */ +-#define ANOMALY_05000145 /* In PWM_OUT mode, you must enable the PPI block to +- * generate a waveform from PPI_CLK */ +-#define ANOMALY_05000146 /* MDMA may lose the first few words of a descriptor +- * chain */ +-#define ANOMALY_05000147 /* The source MDMA descriptor may stop with a DMA +- * Error */ +-#define ANOMALY_05000148 /* When booting from a 16-bit asynchronous memory +- * device, the upper 8-bits of each word must be +- * 0x00 */ +-#define ANOMALY_05000153 /* Frame Delay in SPORT Multichannel Mode */ +-#define ANOMALY_05000154 /* SPORT TFS signal is active in Multi-channel mode +- * outside of valid channels */ +-#define ANOMALY_05000155 /* Timer1 can not be used for PWMOUT mode when a +- * certain PPI mode is in use */ +-#define ANOMALY_05000157 /* A killed 32-bit System MMR write will lead to +- * the next system MMR access thinking it should be +- * 32-bit. */ +-#define ANOMALY_05000163 /* SPORT transmit data is not gated by external frame +- * sync in certain conditions */ +-#define ANOMALY_05000168 /* SDRAM auto-refresh and subsequent Power Ups */ +-#define ANOMALY_05000169 /* DATA CPLB page miss can result in lost +- * write-through cache data writes */ +-#define ANOMALY_05000173 /* DMA vs Core accesses to external memory */ +-#define ANOMALY_05000174 /* Cache Fill Buffer Data lost */ +-#define ANOMALY_05000175 /* Overlapping Sequencer and Memory Stalls */ +-#define ANOMALY_05000176 /* Multiplication of (-1) by (-1) followed by an +- * accumulator saturation */ +-#define ANOMALY_05000181 /* Disabling the PPI resets the PPI configuration +- * registers */ +-#define ANOMALY_05000185 /* PPI TX Mode with 2 External Frame Syncs */ +-#define ANOMALY_05000191 /* PPI does not invert the Driving PPICLK edge in +- * Transmit Modes */ +-#define ANOMALY_05000192 /* In PPI Transmit Modes with External Frame Syncs +- * POLC */ +-#define ANOMALY_05000206 /* Internal Voltage Regulator may not start up */ ++/* Anomalies that don't exist on this proc */ ++#define ANOMALY_05000266 (0) + + #endif +- +-#endif /* _MACH_ANOMALY_H_ */ +Index: include/asm-blackfin/mach-bf533/bf533.h +=================================================================== +--- include/asm-blackfin/mach-bf533/bf533.h (revision 3448) ++++ include/asm-blackfin/mach-bf533/bf533.h (working copy) +@@ -226,7 +226,7 @@ + #define CONFIG_CCLK_ACT_DIV CONFIG_CCLK_DIV_not_defined_properly + #endif + +-#if defined(ANOMALY_05000273) && (CONFIG_CCLK_DIV == 1) ++#if ANOMALY_05000273 && (CONFIG_CCLK_DIV == 1) + #error ANOMALY 05000273, please make sure CCLK is at least 2x SCLK + #endif + +Index: include/asm-blackfin/mach-bf537/anomaly.h +=================================================================== +--- include/asm-blackfin/mach-bf537/anomaly.h (revision 3448) ++++ include/asm-blackfin/mach-bf537/anomaly.h (working copy) +@@ -7,109 +7,137 @@ + */ + + /* This file shoule be up to date with: +- * - Revision J, June 1, 2006; ADSP-BF537 Blackfin Processor Anomaly List +- * - Revision I, June 1, 2006; ADSP-BF536 Blackfin Processor Anomaly List +- * - Revision J, June 1, 2006; ADSP-BF534 Blackfin Processor Anomaly List ++ * - Revision M, March 13, 2007; ADSP-BF537 Blackfin Processor Anomaly List ++ * - Revision L, March 13, 2007; ADSP-BF536 Blackfin Processor Anomaly List ++ * - Revision M, March 13, 2007; ADSP-BF534 Blackfin Processor Anomaly List + */ + + #ifndef _MACH_ANOMALY_H_ + #define _MACH_ANOMALY_H_ + + /* We do not support 0.1 silicon - sorry */ +-#if (defined(CONFIG_BF_REV_0_1)) +-#error Kernel will not work on BF537/6/4 Version 0.1 ++#if __SILICON_REVISION__ < 2 ++# error Kernel will not work on BF537 silicon version 0.0 or 0.1 + #endif + +-#if (defined(CONFIG_BF_REV_0_3) || defined(CONFIG_BF_REV_0_2)) +-#define ANOMALY_05000074 /* A multi issue instruction with dsp32shiftimm in +- * slot1 and store of a P register in slot 2 is not +- * supported */ +-#define ANOMALY_05000119 /* DMA_RUN bit is not valid after a Peripheral Receive +- * Channel DMA stops */ +-#define ANOMALY_05000122 /* Rx.H can not be used to access 16-bit System MMR +- * registers. */ +-#define ANOMALY_05000166 /* PPI Data Lengths Between 8 and 16 do not zero out +- * upper bits*/ +-#define ANOMALY_05000180 /* PPI_DELAY not functional in PPI modes with 0 frame +- * syncs */ +-#if (defined(CONFIG_BF537) || defined(CONFIG_BF536)) +-#define ANOMALY_05000247 /* CLKIN Buffer Output Enable Reset Behavior Is +- * Changed */ ++#if defined(__ADSPBF534__) ++# define ANOMALY_BF534 1 ++#else ++# define ANOMALY_BF534 0 + #endif +-#define ANOMALY_05000265 /* Sensitivity to noise with slow input edge rates on +- * SPORT external receive and transmit clocks. */ +-#define ANOMALY_05000272 /* Certain data cache write through modes fail for +- * VDDint <=0.9V */ +-#define ANOMALY_05000273 /* Writes to Synchronous SDRAM memory may be lost */ +-#define ANOMALY_05000277 /* Writes to a flag data register one SCLK cycle after +- * an edge is detected may clear interrupt */ +-#define ANOMALY_05000281 /* False Hardware Error Exception when ISR context is +- * not restored */ +-#define ANOMALY_05000282 /* Memory DMA corruption with 32-bit data and traffic +- * control */ +-#define ANOMALY_05000283 /* A system MMR write is stalled indefinitely when +- * killed in a particular stage*/ +-#define ANOMALY_05000310 /* False hardware errors caused by fetches at the +- * boundary of reserved memory */ +-#define ANOMALY_05000312 /* Errors when SSYNC, CSYNC, or loads to LT, LB and LC +- * registers are interrupted */ +-#define ANOMALY_05000313 /* PPI is level sensitive on first transfer */ +-#define ANOMALY_05000322 /* EMAC RMII mode at 10-Base-T speed: RX frames not +- * received properly */ ++#if defined(__ADSPBF536__) ++# define ANOMALY_BF536 1 ++#else ++# define ANOMALY_BF536 0 + #endif ++#if defined(__ADSPBF537__) ++# define ANOMALY_BF537 1 ++#else ++# define ANOMALY_BF537 0 ++#endif + +-#if defined(CONFIG_BF_REV_0_2) +-#define ANOMALY_05000244 /* With instruction cache enabled, a CSYNC or SSYNC or +- * IDLE around a Change of Control causes +- * unpredictable results */ +-#define ANOMALY_05000250 /* Incorrect Bit-Shift of Data Word in Multichannel +- * (TDM) */ +-#if (defined(CONFIG_BF537) || defined(CONFIG_BF536)) +-#define ANOMALY_05000252 /* EMAC Tx DMA error after an early frame abort */ ++/* Multi-issue instruction with dsp32shiftimm in slot1 and P-reg store in slot 2 not supported */ ++#define ANOMALY_05000074 (1) ++/* DMA_RUN bit is not valid after a Peripheral Receive Channel DMA stops */ ++#define ANOMALY_05000119 (1) ++/* Rx.H cannot be used to access 16-bit System MMR registers */ ++#define ANOMALY_05000122 (1) ++/* Killed 32-bit MMR write leads to next system MMR access thinking it should be 32-bit */ ++#define ANOMALY_05000157 (__SILICON_REVISION__ < 2) ++/* PPI Data Lengths Between 8 and 16 do not zero out upper bits*/ ++#define ANOMALY_05000166 (1) /* XXX: deleted from BF537 sheet ? */ ++/* PPI_DELAY not functional in PPI modes with 0 frame syncs */ ++#define ANOMALY_05000180 (1) ++/* Instruction Cache Is Not Functional */ ++#define ANOMALY_05000237 (__SILICON_REVISION__ < 2) ++/* If i-cache is on, CSYNC/SSYNC/IDLE around Change of Control causes failures */ ++#define ANOMALY_05000244 (__SILICON_REVISION__ < 3) ++/* Spurious Hardware Error from an access in the shadow of a conditional branch */ ++#define ANOMALY_05000245 (1) ++/* CLKIN Buffer Output Enable Reset Behavior Is Changed */ ++#define ANOMALY_05000247 (1) ++/* Incorrect Bit-Shift of Data Word in Multichannel (TDM) mode in certain conditions */ ++#define ANOMALY_05000250 (__SILICON_REVISION__ < 3) ++/* EMAC Tx DMA error after an early frame abort */ ++#define ANOMALY_05000252 (__SILICON_REVISION__ < 3) ++/* Maximum external clock speed for Timers */ ++#define ANOMALY_05000253 (__SILICON_REVISION__ < 3) ++/* Incorrect Timer Pulse Width in Single-Shot PWM_OUT mode with external clock */ ++#define ANOMALY_05000254 (__SILICON_REVISION__ > 2) ++/* Entering Hibernate Mode with RTC Seconds event interrupt not functional */ ++#define ANOMALY_05000255 (__SILICON_REVISION__ < 3) ++/* EMAC MDIO input latched on wrong MDC edge */ ++#define ANOMALY_05000256 (__SILICON_REVISION__ < 3) ++/* Interrupt/Exception during short hardware loop may cause bad instruction fetches */ ++#define ANOMALY_05000257 (__SILICON_REVISION__ < 3) ++/* Instruction Cache is corrupted when bits 9 and 12 of the ICPLB Data registers differ */ ++#define ANOMALY_05000258 (((ANOMALY_BF536 || ANOMALY_BF537) && __SILICON_REVISION__ == 1) || __SILICON_REVISION__ == 2) ++/* ICPLB_STATUS MMR register may be corrupted */ ++#define ANOMALY_05000260 (__SILICON_REVISION__ == 2) ++/* DCPLB_FAULT_ADDR MMR register may be corrupted */ ++#define ANOMALY_05000261 (__SILICON_REVISION__ < 3) ++/* Stores to data cache may be lost */ ++#define ANOMALY_05000262 (__SILICON_REVISION__ < 3) ++/* Hardware loop corrupted when taking an ICPLB exception */ ++#define ANOMALY_05000263 (__SILICON_REVISION__ == 2) ++/* CSYNC/SSYNC/IDLE causes infinite stall in second to last instruction in hardware loop */ ++#define ANOMALY_05000264 (__SILICON_REVISION__ < 3) ++/* Sensitivity to noise with slow input edge rates on external SPORT TX and RX clocks */ ++#define ANOMALY_05000265 (1) ++/* Memory DMA error when peripheral DMA is running with non-zero DEB_TRAFFIC_PERIOD */ ++#define ANOMALY_05000268 (__SILICON_REVISION__ < 3) ++/* High I/O activity causes output voltage of internal voltage regulator (VDDint) to decrease */ ++#define ANOMALY_05000270 (__SILICON_REVISION__ < 3) ++/* Certain data cache write through modes fail for VDDint <=0.9V */ ++#define ANOMALY_05000272 (1) ++/* Writes to Synchronous SDRAM memory may be lost */ ++#define ANOMALY_05000273 (__SILICON_REVISION__ < 3) ++/* Writes to an I/O data register one SCLK cycle after an edge is detected may clear interrupt */ ++#define ANOMALY_05000277 (__SILICON_REVISION__ < 3) ++/* Disabling Peripherals with DMA running may cause DMA system instability */ ++#define ANOMALY_05000278 (((ANOMALY_BF536 || ANOMALY_BF537) && __SILICON_REVISION__ < 3) || (ANOMALY_BF534 && __SILICON_REVISION__ < 2)) ++/* SPI Master boot mode does not work well with Atmel Data flash devices */ ++#define ANOMALY_05000280 (1) ++/* False Hardware Error Exception when ISR context is not restored */ ++#define ANOMALY_05000281 (__SILICON_REVISION__ < 3) ++/* Memory DMA corruption with 32-bit data and traffic control */ ++#define ANOMALY_05000282 (__SILICON_REVISION__ < 3) ++/* System MMR Write Is Stalled Indefinitely When Killed in a Particular Stage */ ++#define ANOMALY_05000283 (__SILICON_REVISION__ < 3) ++/* New Feature: EMAC TX DMA Word Alignment (Not Available On Older Silicon) */ ++#define ANOMALY_05000285 (__SILICON_REVISION__ < 3) ++/* SPORTs may receive bad data if FIFOs fill up */ ++#define ANOMALY_05000288 (__SILICON_REVISION__ < 3) ++/* Memory to memory DMA source/destination descriptors must be in same memory space */ ++#define ANOMALY_05000301 (1) ++/* SSYNCs After Writes To CAN/DMA MMR Registers Are Not Always Handled Correctly */ ++#define ANOMALY_05000304 (__SILICON_REVISION__ < 3) ++/* New Feature: Additional Hysteresis on SPORT Input Pins (Not Available On Older Silicon) */ ++#define ANOMALY_05000305 (__SILICON_REVISION__ < 3) ++/* SCKELOW Bit Does Not Maintain State Through Hibernate */ ++#define ANOMALY_05000307 (__SILICON_REVISION__ < 3) ++/* Writing UART_THR while UART clock is disabled sends erroneous start bit */ ++#define ANOMALY_05000309 (__SILICON_REVISION__ < 3) ++/* False hardware errors caused by fetches at the boundary of reserved memory */ ++#define ANOMALY_05000310 (1) ++/* Errors when SSYNC, CSYNC, or loads to LT, LB and LC registers are interrupted */ ++#define ANOMALY_05000312 (1) ++/* PPI is level sensitive on first transfer */ ++#define ANOMALY_05000313 (1) ++/* Killed System MMR Write Completes Erroneously On Next System MMR Access */ ++#define ANOMALY_05000315 (__SILICON_REVISION__ < 3) ++/* EMAC RMII mode: collisions occur in Full Duplex mode */ ++#define ANOMALY_05000316 (__SILICON_REVISION__ < 3) ++/* EMAC RMII mode: TX frames in half duplex fail with status No Carrier */ ++#define ANOMALY_05000321 (__SILICON_REVISION__ < 3) ++/* EMAC RMII mode at 10-Base-T speed: RX frames not received properly */ ++#define ANOMALY_05000322 (1) ++ ++/* Anomalies that don't exist on this proc */ ++#define ANOMALY_05000125 (0) ++#define ANOMALY_05000183 (0) ++#define ANOMALY_05000198 (0) ++#define ANOMALY_05000266 (0) ++#define ANOMALY_05000311 (0) ++ + #endif +-#define ANOMALY_05000253 /* Maximum external clock speed for Timers */ +-#define ANOMALY_05000255 /* Entering Hibernate Mode with RTC Seconds event +- * interrupt not functional */ +-#if (defined(CONFIG_BF537) || defined(CONFIG_BF536)) +-#define ANOMALY_05000256 /* EMAC MDIO input latched on wrong MDC edge */ +-#endif +-#define ANOMALY_05000257 /* An interrupt or exception during short Hardware +- * loops may cause the instruction fetch unit to +- * malfunction */ +-#define ANOMALY_05000258 /* Instruction Cache is corrupted when bit 9 and 12 of +- * the ICPLB Data registers differ */ +-#define ANOMALY_05000260 /* ICPLB_STATUS MMR register may be corrupted */ +-#define ANOMALY_05000261 /* DCPLB_FAULT_ADDR MMR register may be corrupted */ +-#define ANOMALY_05000262 /* Stores to data cache may be lost */ +-#define ANOMALY_05000263 /* Hardware loop corrupted when taking an ICPLB exception */ +-#define ANOMALY_05000264 /* A Sync instruction (CSYNC, SSYNC) or an IDLE +- * instruction will cause an infinite stall in the +- * second to last instruction in a hardware loop */ +-#define ANOMALY_05000268 /* Memory DMA error when peripheral DMA is running +- * and non-zero DEB_TRAFFIC_PERIOD value */ +-#define ANOMALY_05000270 /* High I/O activity causes the output voltage of the +- * internal voltage regulator (VDDint) to decrease */ +-#define ANOMALY_05000277 /* Writes to a flag data register one SCLK cycle after +- * an edge is detected may clear interrupt */ +-#define ANOMALY_05000278 /* Disabling Peripherals with DMA running may cause +- * DMA system instability */ +-#define ANOMALY_05000280 /* SPI Master boot mode does not work well with +- * Atmel Dataflash devices */ +-#define ANOMALY_05000281 /* False Hardware Error Exception when ISR context +- * is not restored */ +-#define ANOMALY_05000282 /* Memory DMA corruption with 32-bit data and traffic +- * control */ +-#define ANOMALY_05000283 /* System MMR Write Is Stalled Indefinitely When +- * Killed in a Particular Stage */ +-#define ANOMALY_05000285 /* New Feature: EMAC TX DMA Word Alignment +- * (Not Available On Older Silicon) */ +-#define ANOMALY_05000288 /* SPORTs may receive bad data if FIFOs fill up */ +-#define ANOMALY_05000315 /* Killed System MMR Write Completes Erroneously +- * On Next System MMR Access */ +-#define ANOMALY_05000316 /* EMAC RMII mode: collisions occur in Full Duplex +- * mode */ +-#define ANOMALY_05000321 /* EMAC RMII mode: TX frames in half duplex fail with +- * status No Carrier */ +-#endif /* CONFIG_BF_REV_0_2 */ +- +-#endif /* _MACH_ANOMALY_H_ */ +Index: include/asm-blackfin/mach-bf537/bf537.h +=================================================================== +--- include/asm-blackfin/mach-bf537/bf537.h (revision 3448) ++++ include/asm-blackfin/mach-bf537/bf537.h (working copy) +@@ -206,7 +206,7 @@ + #define CONFIG_CCLK_ACT_DIV CONFIG_CCLK_DIV_not_defined_properly + #endif + +-#if defined(ANOMALY_05000273) && (CONFIG_CCLK_DIV == 1) ++#if ANOMALY_05000273 && (CONFIG_CCLK_DIV == 1) + #error ANOMALY 05000273, please make sure CCLK is at least 2x SCLK + #endif + +Index: arch/blackfin/kernel/setup.c +=================================================================== +--- arch/blackfin/kernel/setup.c (revision 3448) ++++ arch/blackfin/kernel/setup.c (working copy) +@@ -179,14 +179,16 @@ + cclk = get_cclk(); + sclk = get_sclk(); + +-#if !defined(CONFIG_BFIN_KERNEL_CLOCK) && defined(ANOMALY_05000273) +- if (cclk == sclk) ++#if !defined(CONFIG_BFIN_KERNEL_CLOCK) ++ if (ANOMALY_05000273 && cclk == sclk) + panic("ANOMALY 05000273, SCLK can not be same as CCLK"); + #endif + +-#if defined(ANOMALY_05000266) +- bfin_read_IMDMA_D0_IRQ_STATUS(); +- bfin_read_IMDMA_D1_IRQ_STATUS(); ++#ifdef BF561_FAMILY ++ if (ANOMALY_05000266) { ++ bfin_read_IMDMA_D0_IRQ_STATUS(); ++ bfin_read_IMDMA_D1_IRQ_STATUS(); ++ } + #endif + + #ifdef DEBUG_SERIAL_EARLY_INIT +@@ -260,7 +262,7 @@ + && ((unsigned long *)mtd_phys)[1] == ROMSB_WORD1) + mtd_size = + PAGE_ALIGN(be32_to_cpu(((unsigned long *)mtd_phys)[2])); +-# if (defined(CONFIG_BLKFIN_CACHE) && defined(ANOMALY_05000263)) ++# if (defined(CONFIG_BLKFIN_CACHE) && ANOMALY_05000263) + /* Due to a Hardware Anomaly we need to limit the size of usable + * instruction memory to max 60MB, 56 if HUNT_FOR_ZERO is on + * 05000263 - Hardware loop corrupted when taking an ICPLB exception +@@ -289,7 +291,7 @@ + _ebss = memory_mtd_start; /* define _ebss for compatible */ + #endif /* CONFIG_MTD_UCLINUX */ + +-#if (defined(CONFIG_BLKFIN_CACHE) && defined(ANOMALY_05000263)) ++#if (defined(CONFIG_BLKFIN_CACHE) && ANOMALY_05000263) + /* Due to a Hardware Anomaly we need to limit the size of usable + * instruction memory to max 60MB, 56 if HUNT_FOR_ZERO is on + * 05000263 - Hardware loop corrupted when taking an ICPLB exception +@@ -337,10 +339,8 @@ + printk(KERN_INFO "Processor Speed: %lu MHz core clock and %lu Mhz System Clock\n", + cclk / 1000000, sclk / 1000000); + +-#if defined(ANOMALY_05000273) +- if ((cclk >> 1) <= sclk) ++ if (ANOMALY_05000273 && (cclk >> 1) <= sclk) + printk("\n\n\nANOMALY_05000273: CCLK must be >= 2*SCLK !!!\n\n\n"); +-#endif + + printk(KERN_INFO "Board Memory: %ldMB\n", physical_mem_end >> 20); + printk(KERN_INFO "Kernel Managed Memory: %ldMB\n", _ramend >> 20); +Index: arch/blackfin/kernel/cplbinit.c +=================================================================== +--- arch/blackfin/kernel/cplbinit.c (revision 3448) ++++ arch/blackfin/kernel/cplbinit.c (working copy) +@@ -230,8 +230,8 @@ + cplb_data[i].psize, + cplb_data[i].i_conf); + } else { +-#if (defined(CONFIG_BLKFIN_CACHE) && defined(ANOMALY_05000263)) +- if (i == SDRAM_KERN) { ++#if defined(CONFIG_BLKFIN_CACHE) ++ if (ANOMALY_05000263 && i == SDRAM_KERN) { + fill_cplbtab(t, + cplb_data[i].start, + cplb_data[i].end, +Index: arch/blackfin/kernel/bfin_gpio.c +=================================================================== +--- arch/blackfin/kernel/bfin_gpio.c (revision 3448) ++++ arch/blackfin/kernel/bfin_gpio.c (working copy) +@@ -330,7 +330,7 @@ + SET_GPIO_SC(maska) + SET_GPIO_SC(maskb) + +-#if defined(ANOMALY_05000311) ++#if ANOMALY_05000311 + void set_gpio_data(unsigned short gpio, unsigned short arg) + { + unsigned long flags; +@@ -349,7 +349,7 @@ + #endif + + +-#if defined(ANOMALY_05000311) ++#if ANOMALY_05000311 + void set_gpio_toggle(unsigned short gpio) + { + unsigned long flags; +@@ -387,7 +387,7 @@ + SET_GPIO_P(maskb) + + +-#if defined(ANOMALY_05000311) ++#if ANOMALY_05000311 + void set_gpiop_data(unsigned short gpio, unsigned short arg) + { + unsigned long flags; +@@ -421,7 +421,7 @@ + GET_GPIO(maskb) + + +-#if defined(ANOMALY_05000311) ++#if ANOMALY_05000311 + unsigned short get_gpio_data(unsigned short gpio) + { + unsigned long flags; +@@ -455,7 +455,7 @@ + GET_GPIO_P(maska) + GET_GPIO_P(maskb) + +-#if defined(ANOMALY_05000311) ++#if ANOMALY_05000311 + unsigned short get_gpiop_data(unsigned short gpio) + { + unsigned long flags; +Index: arch/blackfin/lib/memcmp.S +=================================================================== +--- arch/blackfin/lib/memcmp.S (revision 3448) ++++ arch/blackfin/lib/memcmp.S (working copy) +@@ -61,7 +61,7 @@ + + LSETUP (.Lquad_loop_s, .Lquad_loop_e) LC0=P1; + .Lquad_loop_s: +-#ifdef ANOMALY_05000202 ++#if ANOMALY_05000202 + R0 = [P0++]; + R1 = [I0++]; + #else +Index: arch/blackfin/lib/memcpy.S +=================================================================== +--- arch/blackfin/lib/memcpy.S (revision 3448) ++++ arch/blackfin/lib/memcpy.S (working copy) +@@ -98,7 +98,7 @@ + R0 = R1; + I1 = P1; + R3 = [I1++]; +-#ifdef ANOMALY_05000202 ++#if ANOMALY_05000202 + .Lword_loops: + [P0++] = R3; + .Lword_loope: +Index: arch/blackfin/lib/memmove.S +=================================================================== +--- arch/blackfin/lib/memmove.S (revision 3448) ++++ arch/blackfin/lib/memmove.S (working copy) +@@ -70,7 +70,7 @@ + R1 = [I0++]; + + LSETUP (.Lquad_loops, .Lquad_loope) LC0=P1; +-#ifdef ANOMALY_05000202 ++#if ANOMALY_05000202 + .Lquad_loops: + [P0++] = R1; + .Lquad_loope: +@@ -102,7 +102,7 @@ + R1 = B[P3--] (Z); + CC = P2 == 0; + IF CC JUMP .Lno_loop; +-#ifdef ANOMALY_05000245 ++#if ANOMALY_05000245 + NOP; + NOP; + #endif +Index: arch/blackfin/mach-bf533/head.S +=================================================================== +--- arch/blackfin/mach-bf533/head.S (revision 3448) ++++ arch/blackfin/mach-bf533/head.S (working copy) +@@ -151,13 +151,13 @@ + R0 = R0 & R1; + + /* Anomaly 05000125 */ +-#ifdef ANOMALY_05000125 ++#if ANOMALY_05000125 + CLI R2; + SSYNC; + #endif + [p0] = R0; + SSYNC; +-#ifdef ANOMALY_05000125 ++#if ANOMALY_05000125 + STI R2; + #endif + +@@ -169,13 +169,13 @@ + R0 = R0 & R1; + + /* Anomaly 05000125 */ +-#ifdef ANOMALY_05000125 ++#if ANOMALY_05000125 + CLI R2; + SSYNC; + #endif + [p0] = R0; + SSYNC; +-#ifdef ANOMALY_05000125 ++#if ANOMALY_05000125 + STI R2; + #endif + +@@ -264,7 +264,7 @@ + p0.l = .LWAIT_HERE; + p0.h = .LWAIT_HERE; + reti = p0; +-#if defined(ANOMALY_05000281) ++#if ANOMALY_05000281 + nop; nop; nop; + #endif + rti; +Index: arch/blackfin/mach-bf561/head.S +=================================================================== +--- arch/blackfin/mach-bf561/head.S (revision 3448) ++++ arch/blackfin/mach-bf561/head.S (working copy) +@@ -106,14 +106,13 @@ + R0 = ~ENICPLB; + R0 = R0 & R1; + +- /* Anomaly 05000125 */ +-#ifdef ANOMALY_05000125 ++#if ANOMALY_05000125 + CLI R2; + SSYNC; + #endif + [p0] = R0; + SSYNC; +-#ifdef ANOMALY_05000125 ++#if ANOMALY_05000125 + STI R2; + #endif + +@@ -125,13 +124,13 @@ + R0 = R0 & R1; + + /* Anomaly 05000125 */ +-#ifdef ANOMALY_05000125 ++#if ANOMALY_05000125 + CLI R2; + SSYNC; + #endif + [p0] = R0; + SSYNC; +-#ifdef ANOMALY_05000125 ++#if ANOMALY_05000125 + STI R2; + #endif + +@@ -220,7 +219,7 @@ + p0.l = .LWAIT_HERE; + p0.h = .LWAIT_HERE; + reti = p0; +-#if defined(ANOMALY_05000281) ++#if ANOMALY_05000281 + nop; nop; nop; + #endif + rti; +Index: arch/blackfin/mach-bf537/head.S +=================================================================== +--- arch/blackfin/mach-bf537/head.S (revision 3448) ++++ arch/blackfin/mach-bf537/head.S (working copy) +@@ -107,13 +107,13 @@ + R0 = R0 & R1; + + /* Anomaly 05000125 */ +-#ifdef ANOMALY_05000125 ++#if ANOMALY_05000125 + CLI R2; + SSYNC; + #endif + [p0] = R0; + SSYNC; +-#ifdef ANOMALY_05000125 ++#if ANOMALY_05000125 + STI R2; + #endif + +@@ -125,13 +125,13 @@ + R0 = R0 & R1; + + /* Anomaly 05000125 */ +-#ifdef ANOMALY_05000125 ++#if ANOMALY_05000125 + CLI R2; + SSYNC; + #endif + [p0] = R0; + SSYNC; +-#ifdef ANOMALY_05000125 ++#if ANOMALY_05000125 + STI R2; + #endif + +@@ -141,12 +141,12 @@ + */ + p0.h = hi(BFIN_PORT_MUX); + p0.l = lo(BFIN_PORT_MUX); +-#ifdef ANOMALY_05000212 ++#if ANOMALY_05000212 + R0.L = W[P0]; /* Read */ + SSYNC; + #endif + R0 = (PGDE_UART | PFTE_UART)(Z); +-#ifdef ANOMALY_05000212 ++#if ANOMALY_05000212 + W[P0] = R0.L; /* Write */ + SSYNC; + #endif +@@ -155,12 +155,12 @@ + + p0.h = hi(PORTF_FER); + p0.l = lo(PORTF_FER); +-#ifdef ANOMALY_05000212 ++#if ANOMALY_05000212 + R0.L = W[P0]; /* Read */ + SSYNC; + #endif + R0 = 0x000F(Z); +-#ifdef ANOMALY_05000212 ++#if ANOMALY_05000212 + W[P0] = R0.L; /* Write */ + SSYNC; + #endif +@@ -274,7 +274,7 @@ + p0.l = .LWAIT_HERE; + p0.h = .LWAIT_HERE; + reti = p0; +-#if defined(ANOMALY_05000281) ++#if ANOMALY_05000281 + nop; nop; nop; + #endif + rti; +Index: arch/blackfin/mach-bf548/head.S +=================================================================== +--- arch/blackfin/mach-bf548/head.S (revision 3448) ++++ arch/blackfin/mach-bf548/head.S (working copy) +@@ -172,7 +172,7 @@ + p0.l = .LWAIT_HERE; + p0.h = .LWAIT_HERE; + reti = p0; +-#if defined (ANOMALY_05000281) ++#if ANOMALY_05000281 + nop; + nop; + nop; +Index: arch/blackfin/mach-common/entry.S +=================================================================== +--- arch/blackfin/mach-common/entry.S (revision 3448) ++++ arch/blackfin/mach-common/entry.S (working copy) +@@ -69,7 +69,7 @@ + * patch up CPLB misses on the kernel stack. + */ + ENTRY(_ex_dcplb) +-#if defined(ANOMALY_05000261) ++#if ANOMALY_05000261 + /* + * Work around an anomaly: if we see a new DCPLB fault, return + * without doing anything. Then, if we get the same fault again, +@@ -137,7 +137,7 @@ + + _return_from_exception: + DEBUG_START_HWTRACE(p5, r7) +-#ifdef ANOMALY_05000257 ++#if ANOMALY_05000257 + R7=LC0; + LC0=R7; + R7=LC1; +@@ -634,7 +634,7 @@ + p1.h = _schedule_and_signal_from_int; + [p0] = p1; + csync; +-#if defined(ANOMALY_05000281) ++#if ANOMALY_05000281 + r0.l = lo(CONFIG_BOOT_LOAD); + r0.h = hi(CONFIG_BOOT_LOAD); + reti = r0; +@@ -648,7 +648,7 @@ + ENDPROC(_return_from_int) + + ENTRY(_lower_to_irq14) +-#if defined(ANOMALY_05000281) ++#if ANOMALY_05000281 + r0.l = lo(CONFIG_BOOT_LOAD); + r0.h = hi(CONFIG_BOOT_LOAD); + reti = r0; +@@ -1242,7 +1242,7 @@ + .endr + _exception_stack_top: + +-#if defined(ANOMALY_05000261) ++#if ANOMALY_05000261 + /* Used by the assembly entry point to work around an anomaly. */ + _last_cplb_fault_retx: + .long 0; +Index: arch/blackfin/mach-common/cplbmgr.S +=================================================================== +--- arch/blackfin/mach-common/cplbmgr.S (revision 3448) ++++ arch/blackfin/mach-common/cplbmgr.S (working copy) +@@ -405,7 +405,7 @@ + P3.L = _page_size_table; /* retrieve end address */ + P3.H = _page_size_table; /* retrieve end address */ + R3 = 0x1002; /* 16th - position, 2 bits -length */ +-#ifdef ANOMALY_05000209 ++#if ANOMALY_05000209 + nop; /* Anomaly 05000209 */ + #endif + R7 = EXTRACT(R1,R3.l); +Index: arch/blackfin/mach-common/cacheinit.S +=================================================================== +--- arch/blackfin/mach-common/cacheinit.S (revision 3448) ++++ arch/blackfin/mach-common/cacheinit.S (working copy) +@@ -38,7 +38,7 @@ + + .text + +-#ifdef ANOMALY_05000125 ++#if ANOMALY_05000125 + #if defined(CONFIG_BLKFIN_CACHE) + ENTRY(_bfin_write_IMEM_CONTROL) + +Index: arch/blackfin/mach-common/interrupt.S +=================================================================== +--- arch/blackfin/mach-common/interrupt.S (revision 3448) ++++ arch/blackfin/mach-common/interrupt.S (working copy) +@@ -140,7 +140,7 @@ + fp = 0; + #endif + +-#if defined (ANOMALY_05000283) || defined (ANOMALY_05000315) ++#if ANOMALY_05000283 || ANOMALY_05000315 + cc = r7 == r7; + p5.h = 0xffc0; + p5.l = 0x0014; +@@ -163,7 +163,7 @@ + #ifdef CONFIG_FRAME_POINTER + fp = 0; + #endif +-#ifdef ANOMALY_05000283 ++#if ANOMALY_05000283 + cc = r7 == r7; + p5.h = 0xffc0; + p5.l = 0x0014; +@@ -207,7 +207,7 @@ + #ifdef CONFIG_FRAME_POINTER + fp = 0; + #endif +-#ifdef ANOMALY_05000283 ++#if ANOMALY_05000283 + cc = r7 == r7; + p5.h = 0xffc0; + p5.l = 0x0014; +Index: drivers/video/bfin_adv7393fb.c +=================================================================== +--- drivers/video/bfin_adv7393fb.c (revision 3448) ++++ drivers/video/bfin_adv7393fb.c (working copy) +@@ -288,10 +288,10 @@ + #endif + + +-#if defined(ANOMALY_05000183) +- bfin_write_TIMER2_CONFIG(WDTH_CAP); +- bfin_write_TIMER_ENABLE(TIMEN2); +-#endif ++ if (ANOMALY_05000183) { ++ bfin_write_TIMER2_CONFIG(WDTH_CAP); ++ bfin_write_TIMER_ENABLE(TIMEN2); ++ } + + bfin_write_PPI_CONTROL(0x381E); + bfin_write_PPI_FRAME(fbdev->modes[mode].tot_lines); diff --git a/bfin-scrub-old-spinlock-exception.patch b/bfin-scrub-old-spinlock-exception.patch new file mode 100644 index 0000000..c566bfd --- /dev/null +++ b/bfin-scrub-old-spinlock-exception.patch @@ -0,0 +1,89 @@ +Index: arch/blackfin/kernel/traps.c +=================================================================== +--- arch/blackfin/kernel/traps.c (revision 3345) ++++ arch/blackfin/kernel/traps.c (working copy) +@@ -186,15 +186,14 @@ asmlinkage void trap_c(struct pt_regs *f + #else + /* 0x02 - User Defined, Caught by default */ + #endif +- /* 0x03 - Atomic test and set */ ++ /* 0x03 - User Defined, userspace stack overflow */ + case VEC_EXCPT03: + info.si_code = SEGV_STACKFLOW; + sig = SIGSEGV; + printk(KERN_EMERG EXC_0x03); + CHK_DEBUGGER_TRAP(); + break; +- /* 0x04 - spinlock - handled by _ex_spinlock, +- getting here is an error */ ++ /* 0x04 - User Defined, Caught by default */ + /* 0x05 - User Defined, Caught by default */ + /* 0x06 - User Defined, Caught by default */ + /* 0x07 - User Defined, Caught by default */ +Index: arch/blackfin/mach-common/entry.S +=================================================================== +--- arch/blackfin/mach-common/entry.S (revision 3345) ++++ arch/blackfin/mach-common/entry.S (working copy) +@@ -97,17 +97,6 @@ ENTRY(_ex_icplb) + rtx; + ENDPROC(_ex_icplb) + +-ENTRY(_ex_spinlock) +- /* Transform this into a syscall - twiddle the syscall vector. */ +- p5.l = lo(EVT15); +- p5.h = hi(EVT15); +- r7.l = _spinlock_bh; +- r7.h = _spinlock_bh; +- [p5] = r7; +- csync; +- /* Fall through. */ +-ENDPROC(_ex_spinlock) +- + ENTRY(_ex_syscall) + DEBUG_START_HWTRACE(p5, r7) + (R7:6,P5:4) = [sp++]; +@@ -117,26 +106,6 @@ ENTRY(_ex_syscall) + rtx + ENDPROC(_ex_syscall) + +-ENTRY(_spinlock_bh) +- SAVE_ALL_SYS +- /* To end up here, vector 15 was changed - so we have to change it +- * back. +- */ +- p0.l = lo(EVT15); +- p0.h = hi(EVT15); +- p1.l = _evt_system_call; +- p1.h = _evt_system_call; +- [p0] = p1; +- csync; +- r0 = [sp + PT_R0]; +- sp += -12; +- call _sys_bfin_spinlock; +- sp += 12; +- [SP + PT_R0] = R0; +- RESTORE_ALL_SYS +- rti; +-ENDPROC(_spinlock_bh) +- + ENTRY(_ex_soft_bp) + r7 = retx; + r7 += -2; +@@ -775,14 +744,14 @@ ENDPROC(_init_exception_buff) + ALIGN + _extable: + /* entry for each EXCAUSE[5:0] +- * This table bmust be in sync with the table in ./kernel/traps.c ++ * This table must be in sync with the table in ./kernel/traps.c + * EXCPT instruction can provide 4 bits of EXCAUSE, allowing 16 to be user defined + */ + .long _ex_syscall; /* 0x00 - User Defined - Linux Syscall */ + .long _ex_soft_bp /* 0x01 - User Defined - Software breakpoint */ + .long _ex_trap_c /* 0x02 - User Defined */ +- .long _ex_trap_c /* 0x03 - User Defined - Atomic test and set service */ +- .long _ex_spinlock /* 0x04 - User Defined */ ++ .long _ex_trap_c /* 0x03 - User Defined - userspace stack overflow */ ++ .long _ex_trap_c /* 0x04 - User Defined */ + .long _ex_trap_c /* 0x05 - User Defined */ + .long _ex_trap_c /* 0x06 - User Defined */ + .long _ex_trap_c /* 0x07 - User Defined */ diff --git a/bfin-traps-update.patch b/bfin-traps-update.patch new file mode 100644 index 0000000..3ba36fb --- /dev/null +++ b/bfin-traps-update.patch @@ -0,0 +1,325 @@ +Index: arch/blackfin/kernel/traps.c +=================================================================== +RCS file: /usr/local/src/blackfin/rsync/uclinux533/uClinux-dist/linux-2.6.x/arch/blackfin/kernel/traps.c,v +retrieving revision 1.60 +diff -u -p -r1.60 traps.c +--- arch/blackfin/kernel/traps.c 21 Aug 2006 10:31:28 -0000 1.60 ++++ arch/blackfin/kernel/traps.c 29 Aug 2006 22:48:11 -0000 +@@ -45,24 +45,26 @@ + * >2 for various levels of hopefully increasingly useless information + */ + +-#define TRAPS_DEBUG 1 /* Must be defined here or in in Makefile */ ++#ifndef TRAPS_DEBUG ++# define TRAPS_DEBUG 0 ++#endif + + #if (TRAPS_DEBUG > 2 ) +-#define DPRINTK3(args...) printk(args) ++# define DPRINTK3(args...) printk(KERN_DEBUG args) + #else +-#define DPRINTK3(args...) ++# define DPRINTK3(args...) + #endif + +-#if TRAPS_DEBUG > 1 +-#define DPRINTK2(args...) printk(args) ++#if (TRAPS_DEBUG > 1) ++# define DPRINTK2(args...) printk(KERN_DEBUG args) + #else +-#define DPRINTK2(args...) ++# define DPRINTK2(args...) + #endif + + #ifdef TRAPS_DEBUG +-#define DPRINTK(args...) printk(args) ++# define DPRINTK1(args...) printk(KERN_DEBUG args) + #else +-#define DPRINTK(args...) ++# define DPRINTK1(args...) + #endif + + /* assembler routines */ +@@ -145,12 +147,12 @@ asmlinkage void trap_c(struct pt_regs *f + fp->orig_pc = fp->retx; + + /* send the appropriate signal to the user program */ +- switch (fp->seqstat & 0x3f) { ++ switch (fp->seqstat & SEQSTAT_EXCAUSE) { + case VEC_STEP: + info.si_code = TRAP_STEP; + sig = SIGTRAP; + /* Check if this is a single step in kernel space */ +- if(fp->ipend & 0xffc0) ++ if (fp->ipend & 0xffc0) + return; + else + break; +@@ -158,14 +160,14 @@ asmlinkage void trap_c(struct pt_regs *f + info.si_code = TRAP_ILLTRAP; + sig = SIGTRAP; + /* Check if this is a breakpoint in kernel space */ +- if(fp->ipend & 0xffc0) ++ if (fp->ipend & 0xffc0) + return; + else + break; + case VEC_EXCPT03: /* Atomic test and set service */ + info.si_code = SEGV_STACKFLOW; + sig = SIGSEGV; +- DPRINTK(EXC_0x03); ++ printk(KERN_EMERG EXC_0x03); + break; + case VEC_EXCPT04: /* Atomic test and set service */ + panic("Exception 4"); +@@ -173,52 +175,53 @@ asmlinkage void trap_c(struct pt_regs *f + case VEC_UNDEF_I: + info.si_code = ILL_ILLOPC; + sig = SIGILL; +- DPRINTK(EXC_0x21); ++ printk(KERN_EMERG EXC_0x21); + break; + case VEC_OVFLOW: + info.si_code = TRAP_TRACEFLOW; + sig = SIGTRAP; +- DPRINTK(EXC_0x11); ++ printk(KERN_EMERG EXC_0x11); + break; + case VEC_ILGAL_I: + info.si_code = ILL_ILLPARAOP; + sig = SIGILL; +- DPRINTK(EXC_0x22); ++ printk(KERN_EMERG EXC_0x22); + break; + case VEC_ILL_RES: + info.si_code = ILL_PRVOPC; + sig = SIGILL; +- DPRINTK(EXC_0x2E); ++ printk(KERN_EMERG EXC_0x2E); + break; + case VEC_MISALI_D: + info.si_code = BUS_ADRALN; + sig = SIGBUS; +- DPRINTK(EXC_0x24); +- DPRINTK("DCPLB_FAULT_ADDR=%p\n", (void*)bfin_read_DCPLB_FAULT_ADDR()); ++ printk(KERN_EMERG EXC_0x24); ++ printk(KERN_EMERG "DCPLB_FAULT_ADDR=%p\n", (void*)bfin_read_DCPLB_FAULT_ADDR()); + break; + case VEC_MISALI_I: + info.si_code = BUS_ADRALN; + sig = SIGBUS; +- DPRINTK(EXC_0x2A); +- DPRINTK("ICPLB_FAULT_ADDR=%p\n", (void*)bfin_read_ICPLB_FAULT_ADDR()); ++ printk(KERN_EMERG EXC_0x2A); ++ printk(KERN_EMERG "ICPLB_FAULT_ADDR=%p\n", (void*)bfin_read_ICPLB_FAULT_ADDR()); + break; + case VEC_UNCOV: + info.si_code = ILL_ILLEXCPT; + sig = SIGILL; +- DPRINTK(EXC_0x25); ++ printk(KERN_EMERG EXC_0x25); + break; + case VEC_WATCH: + info.si_code = TRAP_WATCHPT; + sig = SIGTRAP; + DPRINTK3(EXC_0x28); + /* Check if this is a watchpoint in kernel space */ +- if(fp->ipend & 0xffc0) ++ if (fp->ipend & 0xffc0) + return; + else + break; + case VEC_ISTRU_VL: /* ADSP-BF535 only (MH) */ + info.si_code = BUS_OPFETCH; + sig = SIGBUS; ++ printk(KERN_EMERG "BF535: VEC_ISTRU_VL\n"); + break; + case VEC_CPLB_I_VL: + DPRINTK2(EXC_0x2B); +@@ -229,8 +232,6 @@ asmlinkage void trap_c(struct pt_regs *f + DPRINTK3("DCPLB_FAULT_ADDR=%p\n", (void*)bfin_read_DCPLB_FAULT_ADDR()); + _cplb_hdr(); + goto nsig; +- sig = SIGILL; +- break; + case VEC_CPLB_I_M: + DPRINTK3(EXC_0x2C); + DPRINTK3("ICPLB_FAULT_ADDR=%p\n", (void*)bfin_read_ICPLB_FAULT_ADDR()); +@@ -244,18 +245,19 @@ asmlinkage void trap_c(struct pt_regs *f + case VEC_CPLB_I_MHIT: + info.si_code = ILL_CPLB_MULHIT; + sig = SIGILL; +- DPRINTK3(EXC_0x2D); +- DPRINTK3("ICPLB_FAULT_ADDR=%p\n", (void*)bfin_read_ICPLB_FAULT_ADDR()); ++ printk(KERN_EMERG EXC_0x2D); ++ printk(KERN_EMERG "ICPLB_FAULT_ADDR=%p\n", (void*)bfin_read_ICPLB_FAULT_ADDR()); + break; + case VEC_CPLB_MHIT: + info.si_code = ILL_CPLB_MULHIT; + #ifdef CONFIG_DEBUG_HUNT_FOR_ZERO + sig = SIGSEGV; ++ printk(KERN_EMERG "\n\nNULL pointer access (probably)\n"); + #else + sig = SIGILL; ++ printk(KERN_EMERG EXC_0x27); + #endif +- DPRINTK3(EXC_0x27); +- DPRINTK3("DCPLB_FAULT_ADDR=%p\n", (void*)bfin_read_DCPLB_FAULT_ADDR()); ++ printk(KERN_EMERG "DCPLB_FAULT_ADDR=%p\n", (void*)bfin_read_DCPLB_FAULT_ADDR()); + break; + default: + info.si_code = TRAP_ILLTRAP; +@@ -270,6 +272,8 @@ asmlinkage void trap_c(struct pt_regs *f + unsigned long stack; + dump_bfin_regs(fp, (void *)fp->retx); + show_stack(current, &stack); ++ if (current == NULL) ++ panic("Kernel exception"); + } + nsig: + trace_buffer_restore(j); +Index: arch/blackfin/mach-common/irqpanic.c +=================================================================== +RCS file: /usr/local/src/blackfin/rsync/uclinux533/uClinux-dist/linux-2.6.x/arch/blackfin/mach-common/irqpanic.c,v +retrieving revision 1.17 +diff -u -p -r1.17 irqpanic.c +--- arch/blackfin/mach-common/irqpanic.c 3 Aug 2006 17:37:12 -0000 1.17 ++++ arch/blackfin/mach-common/irqpanic.c 29 Aug 2006 20:35:23 -0000 +@@ -36,15 +36,15 @@ + + #include "../oprofile/op_blackfin.h" + +-/********* +- * irq_panic - calls panic with string setup +- *********/ + #ifdef CONFIG_DEBUG_ICACHE_CHECK + #define L1_ICACHE_START 0xffa10000 + #define L1_ICACHE_END 0xffa13fff + void irq_panic(int reason, struct pt_regs *regs) __attribute__ ((section (".text.l1"))); + #endif + ++/* ++ * irq_panic - calls panic with string setup ++ */ + asmlinkage void irq_panic(int reason, struct pt_regs *regs) + { + int sig = 0; +@@ -135,31 +135,30 @@ asmlinkage void irq_panic(int reason, st + printk(" stack frame=0x%04x, ", (unsigned int)(unsigned long)regs); + printk(" bad PC=0x%04x\n", (unsigned int)regs->pc); + if (reason == 0x5) { +- + printk("\n----------- HARDWARE ERROR -----------\n\n"); + + /* There is only need to check for Hardware Errors, since other + * EXCEPTIONS are handled in TRAPS.c (MH) + */ +- switch (((unsigned int)regs->seqstat) >> 14) { +- case (0x2): /* System MMR Error */ ++ switch (regs->seqstat & SEQSTAT_HWERRCAUSE) { ++ case (SEQSTAT_HWERRCAUSE_SYSTEM_MMR): /* System MMR Error */ + info.si_code = BUS_ADRALN; + sig = SIGBUS; + printk(HWC_x2); + break; +- case (0x3): /* External Memory Addressing Error */ ++ case (SEQSTAT_HWERRCAUSE_EXTERN_ADDR): /* External Memory Addressing Error */ + info.si_code = BUS_ADRERR; + sig = SIGBUS; +- printk(HWC_x3); ++ printk(KERN_EMERG HWC_x3); + break; +- case (0x12): /* Performance Monitor Overflow */ +- printk(HWC_x12); ++ case (SEQSTAT_HWERRCAUSE_PERF_FLOW): /* Performance Monitor Overflow */ ++ printk(KERN_EMERG HWC_x12); + break; +- case (0x18): /* RAISE 5 instruction */ +- printk(HWC_x18); ++ case (SEQSTAT_HWERRCAUSE_RAISE_5): /* RAISE 5 instruction */ ++ printk(KERN_EMERG HWC_x18); + break; + default: /* Reserved */ +- printk(HWC_default); ++ printk(KERN_EMERG HWC_default); + break; + } + } +@@ -176,11 +175,11 @@ asmlinkage void irq_panic(int reason, st + } + + #ifdef CONFIG_HARDWARE_PM +-/**** +- * +- * call the handler of Performance overflow +- ****/ +-asmlinkage void pm_overflow(int irq, struct pt_regs *regs){ +- pm_overflow_handler(irq , regs); ++/* ++ * call the handler of Performance overflow ++ */ ++asmlinkage void pm_overflow(int irq, struct pt_regs *regs) ++{ ++ pm_overflow_handler(irq, regs); + } + #endif +Index: include/asm-blackfin/mach-common/def_LPBlackfin.h +=================================================================== +RCS file: /usr/local/src/blackfin/rsync/uclinux533/uClinux-dist/linux-2.6.x/include/asm-blackfin/mach-common/def_LPBlackfin.h,v +retrieving revision 1.11 +diff -u -p -r1.11 def_LPBlackfin.h +--- include/asm-blackfin/mach-common/def_LPBlackfin.h 3 Aug 2006 14:36:27 -0000 1.11 ++++ include/asm-blackfin/mach-common/def_LPBlackfin.h 29 Aug 2006 21:18:13 -0000 +@@ -182,29 +182,35 @@ + #define SEQSTAT_HWERRCAUSE2_P 0x00000010 /* Last hw error cause bit 2 */ + #define SEQSTAT_HWERRCAUSE3_P 0x00000011 /* Last hw error cause bit 3 */ + #define SEQSTAT_HWERRCAUSE4_P 0x00000012 /* Last hw error cause bit 4 */ +-#define SEQSTAT_HWERRCAUSE5_P 0x00000013 /* Last hw error cause bit 5 */ +-#define SEQSTAT_HWERRCAUSE6_P 0x00000014 /* Last hw error cause bit 6 */ +-#define SEQSTAT_HWERRCAUSE7_P 0x00000015 /* Last hw error cause bit 7 */ + /* Masks */ + /* Exception cause */ +-#define SEQSTAT_EXCAUSE MK_BMSK_(SEQSTAT_EXCAUSE0_P ) | \ +- MK_BMSK_(SEQSTAT_EXCAUSE1_P ) | \ +- MK_BMSK_(SEQSTAT_EXCAUSE2_P ) | \ +- MK_BMSK_(SEQSTAT_EXCAUSE3_P ) | \ +- MK_BMSK_(SEQSTAT_EXCAUSE4_P ) | \ +- MK_BMSK_(SEQSTAT_EXCAUSE5_P ) | \ +- 0 ++#define SEQSTAT_EXCAUSE (MK_BMSK_(SEQSTAT_EXCAUSE0_P) | \ ++ MK_BMSK_(SEQSTAT_EXCAUSE1_P) | \ ++ MK_BMSK_(SEQSTAT_EXCAUSE2_P) | \ ++ MK_BMSK_(SEQSTAT_EXCAUSE3_P) | \ ++ MK_BMSK_(SEQSTAT_EXCAUSE4_P) | \ ++ MK_BMSK_(SEQSTAT_EXCAUSE5_P) | \ ++ 0) + + /* Indicates whether the last reset was a software reset (=1) */ +-#define SEQSTAT_SFTRESET MK_BMSK_(SEQSTAT_SFTRESET_P ) ++#define SEQSTAT_SFTRESET (MK_BMSK_(SEQSTAT_SFTRESET_P)) + + /* Last hw error cause */ +-#define SEQSTAT_HWERRCAUSE MK_BMSK_(SEQSTAT_HWERRCAUSE0_P ) | \ +- MK_BMSK_(SEQSTAT_HWERRCAUSE1_P ) | \ +- MK_BMSK_(SEQSTAT_HWERRCAUSE2_P ) | \ +- MK_BMSK_(SEQSTAT_HWERRCAUSE3_P ) | \ +- MK_BMSK_(SEQSTAT_HWERRCAUSE4_P ) | \ +- 0 ++#define SEQSTAT_HWERRCAUSE (MK_BMSK_(SEQSTAT_HWERRCAUSE0_P) | \ ++ MK_BMSK_(SEQSTAT_HWERRCAUSE1_P) | \ ++ MK_BMSK_(SEQSTAT_HWERRCAUSE2_P) | \ ++ MK_BMSK_(SEQSTAT_HWERRCAUSE3_P) | \ ++ MK_BMSK_(SEQSTAT_HWERRCAUSE4_P) | \ ++ 0) ++ ++/* Translate bits to something useful */ ++ ++/* Last hw error cause */ ++#define SEQSTAT_HWERRCAUSE_SHIFT (14) ++#define SEQSTAT_HWERRCAUSE_SYSTEM_MMR (0x02 << SEQSTAT_HWERRCAUSE_SHIFT) ++#define SEQSTAT_HWERRCAUSE_EXTERN_ADDR (0x03 << SEQSTAT_HWERRCAUSE_SHIFT) ++#define SEQSTAT_HWERRCAUSE_PERF_FLOW (0x12 << SEQSTAT_HWERRCAUSE_SHIFT) ++#define SEQSTAT_HWERRCAUSE_RAISE_5 (0x18 << SEQSTAT_HWERRCAUSE_SHIFT) + + /************************************************** + * SYSCFG register diff --git a/bfin-uclibc-l1-fail-msg.patch b/bfin-uclibc-l1-fail-msg.patch new file mode 100644 index 0000000..ff80ad6 --- /dev/null +++ b/bfin-uclibc-l1-fail-msg.patch @@ -0,0 +1,36 @@ +Index: ldso/ldso/bfin/dl-inlines.h +=================================================================== +--- ldso/ldso/bfin/dl-inlines.h (revision 1816) ++++ ldso/ldso/bfin/dl-inlines.h (revision 1817) +@@ -541,7 +541,7 @@ + _dl_dma_memcpy (l1addr, status + (ppnt->p_vaddr & ADDR_ALIGN), ppnt->p_filesz); + _dl_munmap (status, size); + if (l1addr == NULL) +- return NULL; ++ _dl_dprintf(2, "%s:%i: L1 allocation failed\n", _dl_progname, __LINE__); + return l1addr; + } + +@@ -557,12 +557,16 @@ + l1addr = (char *) _dl_sram_alloc (ppnt->p_memsz, L1_DATA_B_SRAM); + else + l1addr = (char *) _dl_sram_alloc (ppnt->p_memsz, L1_DATA_SRAM); +- if (l1addr == NULL +- || (_DL_PREAD (infile, l1addr, ppnt->p_filesz, ppnt->p_offset) +- != ppnt->p_filesz)) +- return NULL; +- if (ppnt->p_filesz < ppnt->p_memsz) +- _dl_memset (l1addr + ppnt->p_filesz, 0, ppnt->p_memsz - ppnt->p_filesz); ++ if (l1addr == NULL) { ++ _dl_dprintf(2, "%s:%i: L1 allocation failed\n", _dl_progname, __LINE__); ++ } else { ++ if (_DL_PREAD (infile, l1addr, ppnt->p_filesz, ppnt->p_offset) != ppnt->p_filesz) { ++ _dl_sram_free (l1addr); ++ return NULL; ++ } ++ if (ppnt->p_filesz < ppnt->p_memsz) ++ _dl_memset (l1addr + ppnt->p_filesz, 0, ppnt->p_memsz - ppnt->p_filesz); ++ } + return l1addr; + } + diff --git a/bfin_mplayer.patch b/bfin_mplayer.patch new file mode 100644 index 0000000..c68a84e --- /dev/null +++ b/bfin_mplayer.patch @@ -0,0 +1,10 @@ +--- MPlayer-1.0rc1/libvo/vo_yuv4mpeg.c ++++ MPlayer-1.0rc1/libvo/vo_yuv4mpeg.c +@@ -40,6 +40,7 @@ + + #include "fastmemcpy.h" + #include "libswscale/swscale.h" ++#include "libswscale/rgb2rgb.h" + #include "libmpcodecs/vf_scale.h" + + static vo_info_t info = diff --git a/binutils-2.17-ld-dwarf-speedup.patch b/binutils-2.17-ld-dwarf-speedup.patch new file mode 100644 index 0000000..bd7642a --- /dev/null +++ b/binutils-2.17-ld-dwarf-speedup.patch @@ -0,0 +1,148 @@ +Index: bfd/elflink.c +=================================================================== +RCS file: /cvs/src/src/bfd/elflink.c,v +retrieving revision 1.237 +retrieving revision 1.238 +diff -u -p -r1.237 -r1.238 +--- bfd/elflink.c 30 Oct 2006 23:25:49 -0000 1.237 ++++ bfd/elflink.c 17 Nov 2006 13:55:41 -0000 1.238 +@@ -7287,8 +7287,8 @@ match_group_member (asection *sec, asect + } + + /* Check if the kept section of a discarded section SEC can be used +- to replace it. Return the replacement if it is OK. Otherwise return +- NULL. */ ++ to replace it. Return the replacement if it is OK. Otherwise return ++ NULL. */ + + asection * + _bfd_elf_check_kept_section (asection *sec, struct bfd_link_info *info) +@@ -7298,10 +7298,11 @@ _bfd_elf_check_kept_section (asection *s + kept = sec->kept_section; + if (kept != NULL) + { +- if (elf_sec_group (sec) != NULL) ++ if ((kept->flags & SEC_GROUP) != 0) + kept = match_group_member (sec, kept, info); + if (kept != NULL && sec->size != kept->size) + kept = NULL; ++ sec->kept_section = kept; + } + return kept; + } +@@ -10316,33 +10317,21 @@ _bfd_elf_section_already_linked (bfd *ab + const char *name, *p; + struct bfd_section_already_linked *l; + struct bfd_section_already_linked_hash_entry *already_linked_list; +- asection *group; + +- /* A single member comdat group section may be discarded by a +- linkonce section. See below. */ + if (sec->output_section == bfd_abs_section_ptr) + return; + + flags = sec->flags; + +- /* Check if it belongs to a section group. */ +- group = elf_sec_group (sec); +- +- /* Return if it isn't a linkonce section nor a member of a group. A +- comdat group section also has SEC_LINK_ONCE set. */ +- if ((flags & SEC_LINK_ONCE) == 0 && group == NULL) ++ /* Return if it isn't a linkonce section. A comdat group section ++ also has SEC_LINK_ONCE set. */ ++ if ((flags & SEC_LINK_ONCE) == 0) + return; + +- if (group) +- { +- /* If this is the member of a single member comdat group, check if +- the group should be discarded. */ +- if (elf_next_in_group (sec) == sec +- && (group->flags & SEC_LINK_ONCE) != 0) +- sec = group; +- else +- return; +- } ++ /* Don't put group member sections on our list of already linked ++ sections. They are handled as a group via their group section. */ ++ if (elf_sec_group (sec) != NULL) ++ return; + + /* FIXME: When doing a relocatable link, we may have trouble + copying relocations in other sections that refer to local symbols +@@ -10373,11 +10362,8 @@ _bfd_elf_section_already_linked (bfd *ab + + for (l = already_linked_list->entry; l != NULL; l = l->next) + { +- /* We may have 3 different sections on the list: group section, +- comdat section and linkonce section. SEC may be a linkonce or +- group section. We match a group section with a group section, +- a linkonce section with a linkonce section, and ignore comdat +- section. */ ++ /* We may have 2 different types of sections on the list: group ++ sections and linkonce sections. Match like sections. */ + if ((flags & SEC_GROUP) == (l->sec->flags & SEC_GROUP) + && strcmp (name, l->sec->name) == 0 + && bfd_coff_get_comdat_section (l->sec->owner, l->sec) == NULL) +@@ -10465,32 +10451,28 @@ _bfd_elf_section_already_linked (bfd *ab + } + } + +- if (group) ++ /* A single member comdat group section may be discarded by a ++ linkonce section and vice versa. */ ++ ++ if ((flags & SEC_GROUP) != 0) + { +- /* If this is the member of a single member comdat group and the +- group hasn't be discarded, we check if it matches a linkonce +- section. We only record the discarded comdat group. Otherwise +- the undiscarded group will be discarded incorrectly later since +- itself has been recorded. */ +- for (l = already_linked_list->entry; l != NULL; l = l->next) +- if ((l->sec->flags & SEC_GROUP) == 0 +- && bfd_coff_get_comdat_section (l->sec->owner, l->sec) == NULL +- && bfd_elf_match_symbols_in_sections (l->sec, +- elf_next_in_group (sec), +- info)) +- { +- elf_next_in_group (sec)->output_section = bfd_abs_section_ptr; +- elf_next_in_group (sec)->kept_section = l->sec; +- group->output_section = bfd_abs_section_ptr; +- break; +- } +- if (l == NULL) +- return; ++ asection *first = elf_next_in_group (sec); ++ ++ if (first != NULL && elf_next_in_group (first) == first) ++ /* Check this single member group against linkonce sections. */ ++ for (l = already_linked_list->entry; l != NULL; l = l->next) ++ if ((l->sec->flags & SEC_GROUP) == 0 ++ && bfd_coff_get_comdat_section (l->sec->owner, l->sec) == NULL ++ && bfd_elf_match_symbols_in_sections (l->sec, first, info)) ++ { ++ first->output_section = bfd_abs_section_ptr; ++ first->kept_section = l->sec; ++ sec->output_section = bfd_abs_section_ptr; ++ break; ++ } + } + else +- /* There is no direct match. But for linkonce section, we should +- check if there is a match with comdat group member. We always +- record the linkonce section, discarded or not. */ ++ /* Check this linkonce section against single member groups. */ + for (l = already_linked_list->entry; l != NULL; l = l->next) + if (l->sec->flags & SEC_GROUP) + { +@@ -10501,7 +10483,7 @@ _bfd_elf_section_already_linked (bfd *ab + && bfd_elf_match_symbols_in_sections (first, sec, info)) + { + sec->output_section = bfd_abs_section_ptr; +- sec->kept_section = l->sec; ++ sec->kept_section = first; + break; + } + } diff --git a/binutils-bfd-no-open-dir.patch b/binutils-bfd-no-open-dir.patch new file mode 100644 index 0000000..89a6c82 --- /dev/null +++ b/binutils-bfd-no-open-dir.patch @@ -0,0 +1,22 @@ +2006-10-21 David Kimdon + + * opncls.c (bfd_fopen): Return failure if filename is a directory. + +--- bfd/opncls.c ++++ bfd/opncls.c +@@ -182,6 +182,15 @@ bfd_fopen (const char *filename, const c + { + bfd *nbfd; + const bfd_target *target_vec; ++ struct stat s; ++ ++ if ((fd != -1 && fstat (fd, &s) == 0) || ++ (fd == -1 && 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/binutils-bfd-vendor-version-tag.patch b/binutils-bfd-vendor-version-tag.patch new file mode 100644 index 0000000..5f476ad --- /dev/null +++ b/binutils-bfd-vendor-version-tag.patch @@ -0,0 +1,36 @@ +--- bfd/configure.in ++++ bfd/configure.in +@@ -63,6 +63,12 @@ if test $use_secureplt = true; then + [Define if we should default to creating read-only plt entries]) + fi + ++AC_ARG_WITH(vendor-tag, ++[ --with-vendor-tag=TAG Include TAG in version output], ++[VENDOR_TAG="${withval}"],[VENDOR_TAG=""])dnl ++AC_SUBST(VENDOR_TAG) ++ ++ + AM_BINUTILS_WARNINGS + + AM_CONFIG_HEADER(config.h:config.in) +--- bfd/Makefile.am ++++ bfd/Makefile.am +@@ -954,10 +954,16 @@ DISTCLEANFILES = $(BUILD_CFILES) $(BUILD + bfdver.h: $(srcdir)/version.h $(srcdir)/Makefile.in + @echo "creating $@" + @bfd_version=`echo "$(VERSION)" | sed -e 's/\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\).*/\1.00\2.00\3.00\4.00\5/' -e 's/\([^\.]*\)\..*\(..\)\..*\(..\)\..*\(..\)\..*\(..\)$$/\1\2\3\4\5/'` ;\ +- bfd_version_string="\"$(VERSION)\"" ;\ ++ if test "x$(VENDOR_TAG)" != x ; then \ ++ vendor_tag=" $(VENDOR_TAG)" ;\ ++ else \ ++ vendor_tag="" ;\ ++ fi ;\ + if test "x$(RELEASE)" = x ; then \ + bfd_version_date=`sed -n -e 's/.*DATE //p' < $(srcdir)/version.h` ;\ +- bfd_version_string="\"$(VERSION) $${bfd_version_date}\"" ;\ ++ bfd_version_string="\"$(VERSION) $${bfd_version_date}$${vendor_tag}\"" ;\ ++ else \ ++ bfd_version_string="\"$(VERSION)$${vendor_tag}\"" ;\ + fi ;\ + sed -e "s/@bfd_version@/$$bfd_version/" -e "s/@bfd_version_string@/$$bfd_version_string/" < $(srcdir)/version.h > $@ + diff --git a/binutils-cross-multi-libsuffix.patch b/binutils-cross-multi-libsuffix.patch new file mode 100644 index 0000000..c5ca553 --- /dev/null +++ b/binutils-cross-multi-libsuffix.patch @@ -0,0 +1,23 @@ +http://sources.redhat.com/bugzilla/show_bug.cgi?id=2755 + +2006-09-24 Mike Frysinger + + * genscripts.sh: Respect LIBPATH_SUFFIX when not using sysroot. + +--- binutils/ld/genscripts.sh ++++ binutils/ld/genscripts.sh +@@ -186,6 +186,14 @@ + ::) LIB_PATH=${tool_lib} ;; + *) LIB_PATH=${tool_lib}:${LIB_PATH} ;; + esac ++ # For multilib targets, search both $tool_lib dirs ++ if [ "x${LIBPATH_SUFFIX}" != "x" ] ; then ++ case :${LIB_PATH}: in ++ ::: | *:${tool_lib}${LIBPATH_SUFFIX}:*) ;; ++ ::) LIB_PATH=${tool_lib}${LIBPATH_SUFFIX} ;; ++ *) LIB_PATH=${tool_lib}${LIBPATH_SUFFIX}:${LIB_PATH} ;; ++ esac ++ fi + fi + + LIB_SEARCH_DIRS=`echo ${LIB_PATH} | sed -e 's/:/ /g' -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\\"\1\\");/g'` diff --git a/binutils-for-build.patch b/binutils-for-build.patch new file mode 100644 index 0000000..e4bd3ff --- /dev/null +++ b/binutils-for-build.patch @@ -0,0 +1,25 @@ +2007-10-06 Mike Frysinger + + * configure.ac (CFLAGS_FOR_BUILD, CXXFLAGS_FOR_BUILD, + LDFLAGS_FOR_BUILD): Default them to host flags only for $host = $build. + Set default CXXFLAGS_FOR_BUILD to CXXFLAGS, not CFLAGS. Set default + LDFLAGS_FOR_BUILD to LDFLAGS, not CFLAGS. + * configure: Regenerate. + +--- configure.ac 1 Oct 2007 07:55:47 -0000 1.30 ++++ configure.ac 6 Oct 2007 23:06:00 -0000 +@@ -2387,9 +2387,11 @@ esac + + # Allow the user to override the flags for + # our build compiler if desired. +-CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD-${CFLAGS}} +-CXXFLAGS_FOR_BUILD=${CXXFLAGS_FOR_BUILD-${CFLAGS}} +-LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-${CFLAGS}} ++if test x"${build}" = x"${host}" ; then ++ CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD-${CFLAGS}} ++ CXXFLAGS_FOR_BUILD=${CXXFLAGS_FOR_BUILD-${CXXFLAGS}} ++ LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-${LDFLAGS}} ++fi + + # On Canadian crosses, we'll be searching the right directories for + # the previously-installed cross compiler, so don't bother to add diff --git a/binutils-freebsd-sparc64-support.patch b/binutils-freebsd-sparc64-support.patch new file mode 100644 index 0000000..400018a --- /dev/null +++ b/binutils-freebsd-sparc64-support.patch @@ -0,0 +1,160 @@ +2006-10-17 Roy Marples + + * bfd/elf64-sparc.c: Add FreeBSD support. + (elf64_sparc_fbsd_post_process_headers): New function. + * bfd/targets.c (_bfd_target_vector): Add bfd_elf64_sparc_freebsd_vec. + * bfd/config.bfd (sparc64-*-freebsd*): Set targ_defvec to bfd_elf64_sparc_freebsd_vec. + * bfd/configure.in: Add entry for bfd_elf64_sparc_freebsd_vec. + * bfd/configure: Regenerate. + * gas/config/tc-sparc.c (md_parse_option): Treat any target starting with elf32-sparc + as a viable target for the -32 switch and any target starting with elf64-sparc as a + viable target for the -64 switch. + (sparc_target_format): For 64-bit ELF flavoured output use ELF_TARGET_FORMAT64 + while for 32-bit ELF flavoured output use ELF_TARGET_FORMAT. + * gas/config/tc-sparc.h (ELF_TARGET_FORMAT, ELF_TARGET_FORMAT64): Define. + * ld/emulparams/elf64_sparc_fbsd.sh (OUTPUT_FORMAT): Define as elf64-sparc-freebsd. + +--- bfd/elf64-sparc.c ++++ bfd/elf64-sparc.c +@@ -902,3 +902,33 @@ const struct elf_size_info elf64_sparc_s + #define elf_backend_plt_alignment 8 + + #include "elf64-target.h" ++ ++/* FreeBSD support */ ++#undef TARGET_BIG_SYM ++#define TARGET_BIG_SYM bfd_elf64_sparc_freebsd_vec ++#undef TARGET_BIG_NAME ++#define TARGET_BIG_NAME "elf64-sparc-freebsd" ++ ++/* The kernel recognizes executables as valid only if they carry a ++ "FreeBSD" label in the ELF header. So we put this label on all ++ executables and (for simplicity) also all other object files. */ ++ ++static void ++elf64_sparc_fbsd_post_process_headers (bfd *abfd, ++ struct bfd_link_info *info ATTRIBUTE_UNUSED) ++{ ++ Elf_Internal_Ehdr *i_ehdrp; /* ELF file header, internal form. */ ++ ++ i_ehdrp = elf_elfheader (abfd); ++ ++ /* Put an ABI label supported by FreeBSD >= 4.1 */ ++ i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_FREEBSD; ++} ++ ++#undef elf_backend_post_process_headers ++#define elf_backend_post_process_headers elf64_sparc_fbsd_post_process_headers ++#undef elf64_bed ++#define elf64_bed elf64_sparc_fbsd_bed ++ ++#include "elf64-target.h" ++ +--- bfd/targets.c ++++ bfd/targets.c +@@ -674,6 +674,7 @@ extern const bfd_target bfd_elf64_sh64bl + extern const bfd_target bfd_elf64_sh64lnbsd_vec; + extern const bfd_target bfd_elf64_sh64nbsd_vec; + extern const bfd_target bfd_elf64_sparc_vec; ++extern const bfd_target bfd_elf64_sparc_freebsd_vec; + extern const bfd_target bfd_elf64_tradbigmips_vec; + extern const bfd_target bfd_elf64_tradlittlemips_vec; + extern const bfd_target bfd_elf64_x86_64_freebsd_vec; +@@ -1002,6 +1003,7 @@ static const bfd_target * const _bfd_tar + &bfd_elf64_sh64lin_vec, + &bfd_elf64_sh64blin_vec, + &bfd_elf64_sparc_vec, ++ &bfd_elf64_sparc_freebsd_vec, + &bfd_elf64_tradbigmips_vec, + &bfd_elf64_tradlittlemips_vec, + &bfd_elf64_x86_64_freebsd_vec, +--- bfd/config.bfd ++++ bfd/config.bfd +@@ -182,7 +182,11 @@ case "${targ}" in + targ_selvecs="bfd_elf64_ia64_hpux_big_vec" + want64=true + ;; +- sparc64-*-freebsd* | sparc64-*-netbsd* | sparc64-*-openbsd* | sparc64-*-kfreebsd*-gnu) ++ sparc64-*-freebsd* | sparc64-*-kfreebsd*-gnu) ++ targ_defvec=bfd_elf64_sparc_freebsd_vec ++ targ_selvecs="bfd_elf32_sparc_vec sunos_big_vec" ++ ;; ++ sparc64-*-netbsd* | sparc64-*-openbsd*) + targ_defvec=bfd_elf64_sparc_vec + targ_selvecs="bfd_elf32_sparc_vec sunos_big_vec" + want64=true +--- bfd/configure.in ++++ bfd/configure.in +@@ -716,6 +716,7 @@ do + bfd_elf64_sh64lnbsd_vec) tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;; + bfd_elf64_sh64nbsd_vec) tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;; + bfd_elf64_sparc_vec) tb="$tb elf64-sparc.lo elfxx-sparc.lo elf-vxworks.lo elf64.lo $elf"; target_size=64 ;; ++ bfd_elf64_sparc_freebsd_vec) tb="$tb elf64-sparc.lo elfxx-sparc.lo elf-vxworks.lo elf64.lo $elf"; target_size=64 ;; + bfd_elf64_tradbigmips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; + bfd_elf64_tradlittlemips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; + bfd_elf64_x86_64_freebsd_vec) tb="$tb elf64-x86-64.lo elf64.lo $elf"; target_size=64 ;; +--- bfd/configure ++++ bfd/configure +@@ -716,6 +716,7 @@ do + bfd_elf64_sh64lnbsd_vec) tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;; + bfd_elf64_sh64nbsd_vec) tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;; + bfd_elf64_sparc_vec) tb="$tb elf64-sparc.lo elfxx-sparc.lo elf-vxworks.lo elf64.lo $elf"; target_size=64 ;; ++ bfd_elf64_sparc_freebsd_vec) tb="$tb elf64-sparc.lo elfxx-sparc.lo elf-vxworks.lo elf64.lo $elf"; target_size=64 ;; + bfd_elf64_tradbigmips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; + bfd_elf64_tradlittlemips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; + bfd_elf64_x86_64_freebsd_vec) tb="$tb elf64-x86-64.lo elf64.lo $elf"; target_size=64 ;; +--- gas/config/tc-sparc.c ++++ gas/config/tc-sparc.c +@@ -337,7 +337,7 @@ sparc_target_format () + #endif + + #ifdef OBJ_ELF +- return sparc_arch_size == 64 ? "elf64-sparc" : "elf32-sparc"; ++ return sparc_arch_size == 64 ? ELF64_TARGET_FORMAT : ELF_TARGET_FORMAT; + #endif + + abort (); +@@ -545,12 +545,12 @@ md_parse_option (c, arg) + { + if (sparc_arch_size == 32) + { +- if (strcmp (*l, "elf32-sparc") == 0) ++ if (CONST_STRNEQ (*l, "elf32-sparc")) + break; + } + else + { +- if (strcmp (*l, "elf64-sparc") == 0) ++ if (CONST_STRNEQ (*l, "elf64-sparc")) + break; + } + } +--- gas/config/tc-sparc.h ++++ gas/config/tc-sparc.h +@@ -31,6 +31,19 @@ struct frag; + + #define TARGET_ARCH bfd_arch_sparc + ++#ifdef TE_FreeBSD ++#define ELF_TARGET_FORMAT "elf32-sparc-freebsd" ++#define ELF64_TARGET_FORMAT "elf64-sparc-freebsd" ++#endif ++ ++#ifndef ELF_TARGET_FORMAT ++#define ELF_TARGET_FORMAT "elf32-sparc" ++#endif ++ ++#ifndef ELF64_TARGET_FORMAT ++#define ELF64_TARGET_FORMAT "elf64-sparc" ++#endif ++ + extern const char *sparc_target_format PARAMS ((void)); + #define TARGET_FORMAT sparc_target_format () + +--- ld/emulparams/elf64_sparc_fbsd.sh ++++ ld/emulparams/elf64_sparc_fbsd.sh +@@ -1,2 +1,4 @@ + . ${srcdir}/emulparams/elf64_sparc.sh + . ${srcdir}/emulparams/elf_fbsd.sh ++ ++OUTPUT_FORMAT="elf64-sparc-freebsd" diff --git a/binutils-gas-obj-fdpicelf-2.patch b/binutils-gas-obj-fdpicelf-2.patch new file mode 100644 index 0000000..6a23d00 --- /dev/null +++ b/binutils-gas-obj-fdpicelf-2.patch @@ -0,0 +1,161 @@ +Index: Makefile.am +=================================================================== +RCS file: /cvs/src/src/gas/Makefile.am,v +retrieving revision 1.156 +diff -u -p -r1.156 Makefile.am +--- Makefile.am 13 Mar 2008 02:05:20 -0000 1.156 ++++ Makefile.am 22 Apr 2008 20:47:23 -0000 +@@ -364,6 +364,7 @@ OBJ_FORMAT_CFILES = \ + config/obj-ecoff.c \ + config/obj-elf.c \ + config/obj-evax.c \ ++ config/obj-fdpicelf.c \ + config/obj-som.c + + OBJ_FORMAT_HFILES = \ +@@ -372,6 +373,7 @@ OBJ_FORMAT_HFILES = \ + config/obj-ecoff.h \ + config/obj-elf.h \ + config/obj-evax.h \ ++ config/obj-fdpicelf.h \ + config/obj-som.h + + # Emulation header files in config +@@ -586,6 +588,8 @@ obj-elf.o : $(srcdir)/config/obj-elf.c $ + $(COMPILE) -c $(srcdir)/config/obj-elf.c + obj-evax.o : $(srcdir)/config/obj-evax.c + $(COMPILE) -c $(srcdir)/config/obj-evax.c ++obj-fdpicelf.o : $(srcdir)/config/obj-fdpicelf.c ++ $(COMPILE) -c $(srcdir)/config/obj-fdpicelf.c + obj-multi.o : $(srcdir)/config/obj-multi.c + $(COMPILE) -c $(srcdir)/config/obj-multi.c + obj-som.o : $(srcdir)/config/obj-som.c +Index: Makefile.in +=================================================================== +RCS file: /cvs/src/src/gas/Makefile.in,v +retrieving revision 1.173 +diff -u -p -r1.173 Makefile.in +--- Makefile.in 17 Mar 2008 22:17:29 -0000 1.173 ++++ Makefile.in 22 Apr 2008 20:47:27 -0000 +@@ -608,6 +608,7 @@ OBJ_FORMAT_CFILES = \ + config/obj-ecoff.c \ + config/obj-elf.c \ + config/obj-evax.c \ ++ config/obj-fdpicelf.c \ + config/obj-som.c + + OBJ_FORMAT_HFILES = \ +@@ -616,6 +617,7 @@ OBJ_FORMAT_HFILES = \ + config/obj-ecoff.h \ + config/obj-elf.h \ + config/obj-evax.h \ ++ config/obj-fdpicelf.h \ + config/obj-som.h + + +@@ -2586,6 +2588,8 @@ obj-elf.o : $(srcdir)/config/obj-elf.c $ + $(COMPILE) -c $(srcdir)/config/obj-elf.c + obj-evax.o : $(srcdir)/config/obj-evax.c + $(COMPILE) -c $(srcdir)/config/obj-evax.c ++obj-fdpicelf.o : $(srcdir)/config/obj-fdpicelf.c ++ $(COMPILE) -c $(srcdir)/config/obj-fdpicelf.c + obj-multi.o : $(srcdir)/config/obj-multi.c + $(COMPILE) -c $(srcdir)/config/obj-multi.c + obj-som.o : $(srcdir)/config/obj-som.c +Index: configure.tgt +=================================================================== +RCS file: /cvs/src/src/gas/configure.tgt,v +retrieving revision 1.39 +diff -u -p -r1.39 configure.tgt +--- configure.tgt 1 Feb 2008 17:58:47 -0000 1.39 ++++ configure.tgt 22 Apr 2008 20:47:27 -0000 +@@ -125,8 +125,11 @@ case ${generic_target} in + arm-*-riscix*) fmt=aout em=riscix ;; + + avr-*-*) fmt=elf bfd_gas=yes ;; +- bfin-*-*) fmt=elf bfd_gas=yes ;; ++ ++ bfin-*-linux-uclibc) fmt=fdpicelf em=linux ;; ++ bfin-*-uclinux*) fmt=elf em=linux ;; + bfin-*elf) fmt=elf ;; ++ + cr16-*-elf*) fmt=elf ;; + + cris-*-linux-* | crisv32-*-linux-*) +@@ -416,7 +419,7 @@ case ${cpu_type} in + ;; + esac + case ${fmt} in +- elf | ecoff | multi | som) ++ elf | ecoff | fdpicelf | multi | som) + bfd_gas=yes + ;; + esac +Index: config/obj-fdpicelf.c +=================================================================== +RCS file: config/obj-fdpicelf.c +diff -N config/obj-fdpicelf.c +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ config/obj-fdpicelf.c 22 Apr 2008 20:47:27 -0000 +@@ -0,0 +1 @@ ++#include "obj-elf.c" +Index: config/obj-fdpicelf.h +=================================================================== +RCS file: config/obj-fdpicelf.h +diff -N config/obj-fdpicelf.h +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ config/obj-fdpicelf.h 22 Apr 2008 20:47:27 -0000 +@@ -0,0 +1,2 @@ ++#define OBJ_FDPIC_ELF 1 ++#include "obj-elf.h" +Index: config/tc-bfin.c +=================================================================== +RCS file: /cvs/src/src/gas/config/tc-bfin.c,v +retrieving revision 1.15 +diff -u -p -r1.15 tc-bfin.c +--- config/tc-bfin.c 26 Mar 2008 16:33:33 -0000 1.15 ++++ config/tc-bfin.c 22 Apr 2008 20:47:28 -0000 +@@ -50,8 +50,14 @@ FILE *errorf; + /* Flags to set in the elf header */ + #define DEFAULT_FLAGS 0 + +-static flagword bfin_flags = DEFAULT_FLAGS; +-static const char *bfin_pic_flag = (const char *)0; ++#ifdef OBJ_FDPIC_ELF ++# define DEFAULT_FDPIC EF_BFIN_FDPIC ++#else ++# define DEFAULT_FDPIC 0 ++#endif ++ ++static flagword bfin_flags = DEFAULT_FLAGS | DEFAULT_FDPIC; ++static const char *bfin_pic_flag = DEFAULT_FDPIC ? "-mfdpic" : (const char *)0; + + /* Registers list. */ + struct bfin_reg_entry +@@ -305,10 +311,13 @@ const char FLT_CHARS[] = "fFdDxX"; + const char *md_shortopts = ""; + + #define OPTION_FDPIC (OPTION_MD_BASE) ++#define OPTION_NOPIC (OPTION_MD_BASE + 1) + + struct option md_longopts[] = + { +- { "mfdpic", no_argument, NULL, OPTION_FDPIC }, ++ { "mfdpic", no_argument, NULL, OPTION_FDPIC }, ++ { "mnopic", no_argument, NULL, OPTION_NOPIC }, ++ { "mno-fdpic", no_argument, NULL, OPTION_NOPIC }, + { NULL, no_argument, NULL, 0 }, + }; + +@@ -327,6 +336,11 @@ md_parse_option (int c ATTRIBUTE_UNUSED, + bfin_flags |= EF_BFIN_FDPIC; + bfin_pic_flag = "-mfdpic"; + break; ++ ++ case OPTION_NOPIC: ++ bfin_flags &= ~(EF_BFIN_FDPIC); ++ bfin_pic_flag = 0; ++ break; + } + + return 1; diff --git a/binutils-hppa32-bfd-bed.patch b/binutils-hppa32-bfd-bed.patch new file mode 100644 index 0000000..b0c29d6 --- /dev/null +++ b/binutils-hppa32-bfd-bed.patch @@ -0,0 +1,34 @@ +2007-01-27 Mike Frysinger + + * elf32-hppa.c [elf32_bed]: Define for hpux, linux, and netbsd. + [INCLUDED_TARGET_FILE]: Remove. + +--- binutils-2.17.50.0.10/bfd/elf32-hppa.c ++++ binutils-2.17.50.0.10/bfd/elf32-hppa.c +@@ -4656,6 +4656,7 @@ + #define ELF_MACHINE_CODE EM_PARISC + #define ELF_MAXPAGESIZE 0x1000 + #define ELF_OSABI ELFOSABI_HPUX ++#define elf32_bed elf32_hppa_hpux_bed + + #include "elf32-target.h" + +@@ -4665,8 +4666,9 @@ + #define TARGET_BIG_NAME "elf32-hppa-linux" + #undef ELF_OSABI + #define ELF_OSABI ELFOSABI_LINUX ++#undef elf32_bed ++#define elf32_bed elf32_hppa_linux_bed + +-#define INCLUDED_TARGET_FILE 1 + #include "elf32-target.h" + + #undef TARGET_BIG_SYM +@@ -4675,5 +4677,7 @@ + #define TARGET_BIG_NAME "elf32-hppa-netbsd" + #undef ELF_OSABI + #define ELF_OSABI ELFOSABI_NETBSD ++#undef elf32_bed ++#define elf32_bed elf32_hppa_netbsd_bed + + #include "elf32-target.h" diff --git a/binutils-i386-CONST_STRNEQ.patch b/binutils-i386-CONST_STRNEQ.patch new file mode 100644 index 0000000..3018b7a --- /dev/null +++ b/binutils-i386-CONST_STRNEQ.patch @@ -0,0 +1,20 @@ +--- gas/config/tc-i386.c ++++ gas/config/tc-i386.c +@@ -5882,7 +5882,7 @@ md_parse_option (int c, char *arg) + + list = bfd_target_list (); + for (l = list; *l != NULL; l++) +- if ( strncmp (*l, "elf64-x86-64", 12) == 0 ++ if (CONST_STRNEQ (*l, "elf64-x86-64") + || strcmp (*l, "coff-x86-64") == 0 + || strcmp (*l, "pe-x86-64") == 0 + || strcmp (*l, "pei-x86-64") == 0) +@@ -7785,7 +7785,7 @@ x86_64_section_letter (int letter, char + int + x86_64_section_word (char *str, size_t len) + { +- if (len == 5 && flag_code == CODE_64BIT && strncmp (str, "large", 5) == 0) ++ if (len == 5 && flag_code == CODE_64BIT && CONST_STRNEQ (str, "large") == 0) + return SHF_X86_64_LARGE; + + return -1; diff --git a/binutils-ld-default-linux-uclibc.patch b/binutils-ld-default-linux-uclibc.patch new file mode 100644 index 0000000..9662076 --- /dev/null +++ b/binutils-ld-default-linux-uclibc.patch @@ -0,0 +1,23 @@ +2008-04-25 Michael Frysinger + + * configure.tgt (bfin-*-linux-uclibc*): Set targ_emul to elf32bfinfd + and targ_extra_emuls to elf32bfin. + +Index: configure.tgt +=================================================================== +RCS file: /cvs/src/src/ld/configure.tgt,v +retrieving revision 1.217 +diff -u -p -r1.217 configure.tgt +--- configure.tgt 1 Feb 2008 17:58:48 -0000 1.217 ++++ configure.tgt 26 Apr 2008 01:08:45 -0000 +@@ -121,8 +121,8 @@ bfin-*-uclinux*) targ_emul=elf32bfin; + targ_extra_emuls="elf32bfinfd" + targ_extra_libpath=$targ_extra_emuls + ;; +-bfin-*-linux-uclibc*) targ_emul=elf32bfin; +- targ_extra_emuls="elf32bfinfd" ++bfin-*-linux-uclibc*) targ_emul=elf32bfinfd; ++ targ_extra_emuls="elf32bfin" + targ_extra_libpath=$targ_extra_emuls + ;; + cr16-*-elf*) targ_emul=elf32cr16 ;; diff --git a/binutils-ld-discard-debuglink.patch b/binutils-ld-discard-debuglink.patch new file mode 100644 index 0000000..775bcb8 --- /dev/null +++ b/binutils-ld-discard-debuglink.patch @@ -0,0 +1,21 @@ +2007-07-07 Mike Frysinger + + * scripttempl/elf.sc: Discard .gnu_debuglink. + +--- ld/scripttempl/elf.sc ++++ ld/scripttempl/elf.sc +@@ -125,6 +125,7 @@ + RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }" + DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }" + STACKNOTE="/DISCARD/ : { *(.note.GNU-stack) }" ++DEBUGLINK="/DISCARD/ : { *(.gnu_debuglink) }" + if test -z "${NO_SMALL_DATA}"; then + SBSS=".sbss ${RELOCATING-0} : + { +@@ -519,5 +520,6 @@ + ${OTHER_SECTIONS} + ${RELOCATING+${OTHER_SYMBOLS}} + ${RELOCATING+${STACKNOTE}} ++ ${RELOCATING+${DEBUGLINK}} + } + EOF diff --git a/binutils-ld-selective-pick-CXX.patch b/binutils-ld-selective-pick-CXX.patch new file mode 100644 index 0000000..ba52337 --- /dev/null +++ b/binutils-ld-selective-pick-CXX.patch @@ -0,0 +1,61 @@ +2007-09-29 Mike Frysinger + + * ld-selective/selective.exp: Set $compiler based on $testtype and + use that instead of $CC. + +Index: ld-selective/selective.exp +=================================================================== +RCS file: /cvs/src/src/ld/testsuite/ld-selective/selective.exp,v +retrieving revision 1.38 +diff -u -p -r1.38 selective.exp +--- ld-selective/selective.exp 28 Aug 2007 13:21:58 -0000 1.38 ++++ ld-selective/selective.exp 30 Sep 2007 01:45:19 -0000 +@@ -100,6 +100,7 @@ foreach testitem $seltests { + # It's either C or C++ at the moment. + if { $testtype == "C++" } { + set testflags "$cflags $cxxflags" ++ set compiler "$CXX" + if [string match "*gcc*" [lindex $CC 0]] { + # Starting with 3.4.0, -fvtable-gc is no longer supported and thus + # the functionality we try to test for cannot be expected to work. +@@ -111,19 +112,20 @@ foreach testitem $seltests { + } + } { + set testflags "$cflags" ++ set compiler "$CC" + } + + # Note that we do not actually *use* CXX; we just add cxxflags for C++ + # tests. It might have been a buglet originally; now I think better + # leave as is. +- if { ![ld_compile "$CC $testflags" $srcdir/$subdir/$testfile $objfile] } { ++ if { ![ld_compile "$compiler $testflags" $srcdir/$subdir/$testfile $objfile] } { + unresolved $testname + continue + } + + # V850 targets need libgcc.a + if [istarget v850*-*-elf] { +- set libgcc [remote_exec host "$CC -print-libgcc-file-name"] ++ set libgcc [remote_exec host "$compiler -print-libgcc-file-name"] + set libgcc [lindex $libgcc 1] + regsub -all "\[\r\n\]" $libgcc "" libgcc + set objfile "$objfile $libgcc" +@@ -131,7 +133,7 @@ foreach testitem $seltests { + + # ARM targets need libgcc.a in THUMB mode so that __call_via_r3 is provided + if {[istarget arm-*-*] || [istarget xscale-*-*]} { +- set libgcc [remote_exec host "$CC -print-libgcc-file-name"] ++ set libgcc [remote_exec host "$compiler -print-libgcc-file-name"] + set libgcc [lindex $libgcc 1] + regsub -all "\[\r\n\]" $libgcc "" libgcc + set objfile "$objfile $libgcc" +@@ -139,7 +141,7 @@ foreach testitem $seltests { + + # HPPA linux targets need libgcc.a for millicode routines ($$dyncall). + if [istarget hppa*-*-linux*] { +- set libgcc [remote_exec host "$CC -print-libgcc-file-name"] ++ set libgcc [remote_exec host "$compiler -print-libgcc-file-name"] + set libgcc [lindex $libgcc 1] + regsub -all "\[\r\n\]" $libgcc "" libgcc + set objfile "$objfile $libgcc" diff --git a/binutils-ld-test-defined-set.patch b/binutils-ld-test-defined-set.patch new file mode 100644 index 0000000..f5924bd --- /dev/null +++ b/binutils-ld-test-defined-set.patch @@ -0,0 +1,15 @@ +2008-04-25 Mike Frysinger + + * ld-scripts/defined.s: Use .set syntax rather than =. + +Index: testsuite/ld-scripts/defined.s +=================================================================== +RCS file: /cvs/src/src/ld/testsuite/ld-scripts/defined.s,v +retrieving revision 1.1.1.1 +diff -u -p -r1.1.1.1 defined.s +--- testsuite/ld-scripts/defined.s 3 May 1999 07:29:09 -0000 1.1.1.1 ++++ testsuite/ld-scripts/defined.s 26 Apr 2008 00:13:04 -0000 +@@ -1,2 +1,2 @@ + .globl defined +- defined = 1 ++ .set defined, 1 diff --git a/binutils-libtool-generic-linux.patch b/binutils-libtool-generic-linux.patch new file mode 100644 index 0000000..ccec890 --- /dev/null +++ b/binutils-libtool-generic-linux.patch @@ -0,0 +1,36 @@ +2006-04-10 Mike Frysinger + + * libtool.m4: Accept linux* instead of just linux-gnu*. + * ltconfig: Likewise. Also accept linux-uclibc* as well as linux-gnu*. + +--- libtool.m4 ++++ libtool.m4 +@@ -739,7 +739,7 @@ + ;; + + # This must be Linux ELF. +-linux-gnu*) ++linux*) + lt_cv_deplibs_check_method=pass_all + ;; + +--- ltconfig ++++ 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 + +@@ -1247,7 +1247,7 @@ + ;; + + # This must be Linux ELF. +-linux-gnu*) ++linux*) + version_type=linux + need_lib_prefix=no + need_version=no diff --git a/binutils-no-NBPG.patch b/binutils-no-NBPG.patch new file mode 100644 index 0000000..4cd75c9 --- /dev/null +++ b/binutils-no-NBPG.patch @@ -0,0 +1,17 @@ +2007-03-16 Mike Frysinger + + * trad-core.c (NBPG): If not defined, set to getpagesize(). + +--- bfd/trad-core.c ++++ bfd/trad-core.c +@@ -47,6 +47,10 @@ Foundation, Inc., 51 Franklin Street - F + #include TRAD_HEADER + #endif + ++#ifndef NBPG ++# define NBPG getpagesize() ++#endif ++ + struct trad_core_struct + { + asection *data_section; diff --git a/bitpim-search-path-for-helpers.patch b/bitpim-search-path-for-helpers.patch new file mode 100644 index 0000000..3fd67de --- /dev/null +++ b/bitpim-search-path-for-helpers.patch @@ -0,0 +1,20 @@ +Index: src/conversions.py +=================================================================== +--- src/conversions.py (revision 2853) ++++ src/conversions.py (working copy) +@@ -49,7 +49,14 @@ + f=shortfilename(f) + except: + # this craps out if the helper does not exist! +- raise common.HelperBinaryNotFound(basename, basename+osext, [helperdir]) ++ # see if we can't find it in the system path instead ... ++ try: ++ for path in os.getenv("PATH", "").split(":"): ++ f = path+"/"+basename+osext ++ if os.access(f, os.X_OK) and os.path.isfile(f): ++ return f ++ except: ++ raise common.HelperBinaryNotFound(basename, basename+osext, [helperdir]) + if not os.path.isfile(f): + raise common.HelperBinaryNotFound(basename, basename+osext, [helperdir]) + return f diff --git a/blackfin-dont-save-restore-retx-retn-rete.patch b/blackfin-dont-save-restore-retx-retn-rete.patch new file mode 100644 index 0000000..2605b5c --- /dev/null +++ b/blackfin-dont-save-restore-retx-retn-rete.patch @@ -0,0 +1,68 @@ +Index: include/asm-blackfin/mach-common/context.S +=================================================================== +--- include/asm-blackfin/mach-common/context.S (revision 3496) ++++ include/asm-blackfin/mach-common/context.S (working copy) +@@ -79,9 +79,6 @@ + [--sp] = RETS; + r0 = RETI; + [--sp] = r0; +- [--sp] = RETX; +- [--sp] = RETN; +- [--sp] = RETE; + [--sp] = SEQSTAT; + [--sp] = r0; /* Skip IPEND as well. */ + /* Switch to other method of keeping interrupts disabled. */ +@@ -146,9 +143,6 @@ + [--sp] = RETS; + r0 = RETI; + [--sp] = r0; +- [--sp] = RETX; +- [--sp] = RETN; +- [--sp] = RETE; + [--sp] = SEQSTAT; + [--sp] = r0; /* Skip IPEND as well. */ + [--sp] = RETI; /*orig_pc*/ +@@ -214,9 +208,6 @@ + [--sp] = RETS; + r0 = RETI; + [--sp] = r0; +- [--sp] = RETX; +- [--sp] = RETN; +- [--sp] = RETE; + [--sp] = SEQSTAT; + #ifdef CONFIG_KGDB + r1.l = lo(IPEND); +@@ -238,9 +229,6 @@ + sp += 4; /* Skip orig_pc */ + sp += 4; /* Skip IPEND */ + SEQSTAT = [sp++]; +- RETE = [sp++]; +- RETN = [sp++]; +- RETX = [sp++]; + r0 = [sp++]; + RETI = r0; /* Restore RETI indirectly when in exception */ + RETS = [sp++]; +@@ -292,9 +280,6 @@ + sp += 4; /* Skip orig_pc */ + sp += 4; /* Skip IPEND */ + SEQSTAT = [sp++]; +- RETE = [sp++]; +- RETN = [sp++]; +- RETX = [sp++]; + RETI = [sp++]; + RETS = [sp++]; + +Index: arch/blackfin/mach-common/interrupt.S +=================================================================== +--- arch/blackfin/mach-common/interrupt.S (revision 3499) ++++ arch/blackfin/mach-common/interrupt.S (working copy) +@@ -92,9 +92,6 @@ __common_int_entry: + [--sp] = RETS; + r2 = RETI; + [--sp] = r2; +- [--sp] = RETX; +- [--sp] = RETN; +- [--sp] = RETE; + [--sp] = SEQSTAT; + [--sp] = r1; /* IPEND - R1 may or may not be set up before jumping here. */ + diff --git a/blackfin-old-serial-sysrq.patch b/blackfin-old-serial-sysrq.patch new file mode 100644 index 0000000..6154c21 --- /dev/null +++ b/blackfin-old-serial-sysrq.patch @@ -0,0 +1,61 @@ +--- bfin_serial_5xx.c ++++ bfin_serial_5xx.c +@@ -17,6 +17,7 @@ + * $Id: bfin_serial_5xx.c,v 1.80 2006/10/12 03:16:38 sonicz Exp $ + */ + ++#include + #include + #include + #include +@@ -650,9 +651,10 @@ static void receive_chars(struct bfin_se + struct tty_struct *tty = info->tty; + unsigned char ch = 0, flag = 0; + unsigned short status = 0; +-#if defined(CONFIG_BF531) || defined(CONFIG_BF532) || defined(CONFIG_BF533) +- static int in_break=0; ++#ifdef CONFIG_MAGIC_SYSRQ ++ static int in_break = 0; + #endif ++ + FUNC_ENTER(); + + #ifdef CONFIG_BFIN_UART_CTSRTS +@@ -665,16 +667,13 @@ static void receive_chars(struct bfin_se + ACCESS_PORT_IER(uart_regs); + ch = (unsigned char)bfin_read16(uart_regs->rpUART_RBR); + +- if (!tty) { ++ if (!tty) + goto clear_and_exit; +- } + +-#if defined(CONFIG_BF531) || defined(CONFIG_BF532) || defined(CONFIG_BF533) ++#ifdef CONFIG_MAGIC_SYSRQ + if (in_break) { +- if(ch!=0) { +- ch = (unsigned char)bfin_read16(uart_regs->rpUART_RBR); +- in_break = 0; +- } ++ handle_sysrq(ch, regs, NULL); ++ in_break = 0; + goto clear_and_exit; + } + #endif +@@ -683,7 +682,7 @@ static void receive_chars(struct bfin_se + if (status & BI) { + flag = TTY_BREAK; + status_handle(info, status); +-#if defined(CONFIG_BF531) || defined(CONFIG_BF532) || defined(CONFIG_BF533) ++#ifdef CONFIG_MAGIC_SYSRQ + in_break = 1; + #endif + } else if (status & PE) { +@@ -696,6 +695,7 @@ static void receive_chars(struct bfin_se + flag = TTY_FRAME; + status_handle(info, status); + } ++ + tty_insert_flip_char(tty, ch, flag); + } + tty_flip_buffer_push(tty); diff --git a/blackfin-retn-or-rete.patch b/blackfin-retn-or-rete.patch new file mode 100644 index 0000000..fcf1ee3 --- /dev/null +++ b/blackfin-retn-or-rete.patch @@ -0,0 +1,99 @@ +Index: arch/blackfin/mach-common/entry.S +=================================================================== +--- arch/blackfin/mach-common/entry.S (revision 3496) ++++ arch/blackfin/mach-common/entry.S (working copy) +@@ -58,6 +58,12 @@ + + #include + ++#ifdef CONFIG_BFIN_SCRATCH_REG_RETN ++# define EX_SCRATCH_REG RETN ++#else ++# define EX_SCRATCH_REG RETE ++#endif ++ + #ifdef CONFIG_EXCPT_IRQ_SYSC_L1 + .section .l1.text + #else +@@ -93,7 +99,7 @@ ENTRY(_ex_icplb) + call __cplb_hdr; + DEBUG_START_HWTRACE(p5, r7) + RESTORE_ALL_SYS +- SP = RETN; ++ SP = EX_SCRATCH_REG; + rtx; + ENDPROC(_ex_icplb) + +@@ -102,7 +108,7 @@ ENTRY(_ex_syscall) + (R7:6,P5:4) = [sp++]; + ASTAT = [sp++]; + raise 15; /* invoked by TRAP #0, for sys call */ +- sp = retn; ++ sp = EX_SCRATCH_REG; + rtx + ENDPROC(_ex_syscall) + +@@ -145,7 +151,7 @@ _return_from_exception: + #endif + (R7:6,P5:4) = [sp++]; + ASTAT = [sp++]; +- sp = retn; ++ sp = EX_SCRATCH_REG; + rtx; + ENDPROC(_ex_soft_bp) + +@@ -204,7 +210,7 @@ ENTRY(_ex_trap_c) + DEBUG_START_HWTRACE(p5, r7) + (R7:6,P5:4) = [sp++]; + ASTAT = [sp++]; +- SP = RETN; ++ SP = EX_SCRATCH_REG; + raise 5; + rtx; + ENDPROC(_ex_trap_c) +@@ -279,7 +285,7 @@ ENTRY(_trap) /* Exception: 4th entry int + * covered by a CPLB. Switch to an exception stack; use RETN as a + * scratch register (for want of a better option). + */ +- retn = sp; ++ EX_SCRATCH_REG = sp; + sp.l = _exception_stack_top; + sp.h = _exception_stack_top; + /* Try to deal with syscalls quickly. */ +Index: arch/blackfin/Kconfig +=================================================================== +--- arch/blackfin/Kconfig (revision 3496) ++++ arch/blackfin/Kconfig (working copy) +@@ -520,6 +520,32 @@ config BFIN_IDLE_LED_NUM + help + Select the LED (marked on the board) for you to blink. + ++choice ++ prompt "Blackfin Exception Scratch Register" ++ default BFIN_SCRATCH_REG_RETN ++ ++config BFIN_SCRATCH_REG_RETN ++ bool "RETN" ++ help ++ Use the RETN register in the Blackfin exception handler ++ as a stack scratch register. This means you cannot ++ safely use NMI on the Blackfin while running Linux, but ++ you can debug the system with a JTAG ICE. ++ ++ If you are unsure, please select "RETN". ++ ++config BFIN_SCRATCH_REG_RETE ++ bool "RETE" ++ help ++ Use the RETE register in the Blackfin exception handler ++ as a stack scratch register. This means you cannot ++ safely use a JTAG ICE while debugging a Blackfin board, ++ but you can safely use the NMI. ++ ++ If you are unsure, please select "RETN". ++ ++endchoice ++ + # + # Sorry - but you need to put the hex address here - + # diff --git a/blackfin-serial-cts-rts-sep-ports.patch b/blackfin-serial-cts-rts-sep-ports.patch new file mode 100644 index 0000000..817ace4 --- /dev/null +++ b/blackfin-serial-cts-rts-sep-ports.patch @@ -0,0 +1,181 @@ +--- uClinux-dist/linux-2.6.x/drivers/serial/Kconfig ++++ uClinux-dist/linux-2.6.x/drivers/serial/Kconfig +@@ -1003,8 +1003,8 @@ config BFIN_UART0_CTSRTS + bool "CTS and RTS setting for UART0" + depends on BFIN_UART_CTSRTS + +-config BFIN_UART0_CTSRTS_PORT +- string "UART0 GPIO port for CTS and RTS" ++config BFIN_UART0_CTS_PORT ++ string "UART0 GPIO port for CTS" + default 'G' if (BF534||BF536||BF537) + default 'F' if (BF531||BF532||BF533) + depends on BFIN_UART0_CTSRTS +@@ -1020,6 +1020,16 @@ config BFIN_UART0_CTS + help + This is the UART0 CTS bit number in the select GPIO port. + ++config BFIN_UART0_RTS_PORT ++ string "UART0 GPIO port for RTS" ++ default 'G' if (BF534||BF536||BF537) ++ default 'F' if (BF531||BF532||BF533) ++ depends on BFIN_UART0_CTSRTS ++ help ++ This is GPIO port used by CTS and RTS of UART0. ++ On BF531,532,533, only 'F' is supported. ++ On BF534,536,537, 'F', 'G' and 'H' are supported. ++ + config BFIN_UART0_RTS + int "UART0 RTS control bit in GPIO port" + depends on BFIN_UART0_CTSRTS +--- uClinux-dist/linux-2.6.x/drivers/serial/bfin_serial_5xx.c ++++ uClinux-dist/linux-2.6.x/drivers/serial/bfin_serial_5xx.c +@@ -272,33 +272,53 @@ static inline void bfin_uart_write_PORTI + # endif + } + +-static inline void bfin_uart_portio_ctsrts_init(char *port, unsigned short cts, unsigned short rts) ++static inline void bfin_uart_portio_cts_init(const char *port, const unsigned short gpio) + { + # if defined(CONFIG_BF534) || defined(CONFIG_BF536) || defined(CONFIG_BF537) + switch(port[0]) { + case 'F': +- bfin_write_PORTFIO_DIR(bfin_read_PORTFIO_DIR() & ~(1 << cts)); +- bfin_write_PORTFIO_INEN(bfin_read_PORTFIO_INEN() | (1 << cts)); +- bfin_write_PORTFIO_MASKA_SET(bfin_read_PORTFIO_MASKA_SET() & ~(1 << cts)); +- bfin_write_PORTFIO_MASKB_SET(bfin_read_PORTFIO_MASKB_SET() & ~(1 << cts)); +- bfin_write_PORTFIO_DIR(bfin_read_PORTFIO_DIR() | (1 << rts)); +- bfin_write_PORTF_FER(bfin_read_PORTF_FER() & ~((1 << rts)|(1 << cts)|0x3)); ++ bfin_write_PORTFIO_DIR(bfin_read_PORTFIO_DIR() & ~(1 << gpio)); ++ bfin_write_PORTFIO_INEN(bfin_read_PORTFIO_INEN() | (1 << gpio)); ++ bfin_write_PORTFIO_MASKA_SET(bfin_read_PORTFIO_MASKA_SET() & ~(1 << gpio)); ++ bfin_write_PORTFIO_MASKB_SET(bfin_read_PORTFIO_MASKB_SET() & ~(1 << gpio)); ++ bfin_write_PORTF_FER(bfin_read_PORTF_FER() & ~((1 << gpio)|0x3)); + break; + case 'G': +- bfin_write_PORTGIO_DIR(bfin_read_PORTGIO_DIR() & ~(1 << cts)); +- bfin_write_PORTGIO_INEN(bfin_read_PORTGIO_INEN() | (1 << cts)); +- bfin_write_PORTGIO_MASKA_SET(bfin_read_PORTGIO_MASKA_SET() & ~(1 << cts)); +- bfin_write_PORTGIO_MASKB_SET(bfin_read_PORTGIO_MASKB_SET() & ~(1 << cts)); +- bfin_write_PORTGIO_DIR(bfin_read_PORTGIO_DIR() | (1 << rts)); +- bfin_write_PORTG_FER(bfin_read_PORTG_FER() & ~((1 << rts)|(1 << cts)|0x3)); ++ bfin_write_PORTGIO_DIR(bfin_read_PORTGIO_DIR() & ~(1 << gpio)); ++ bfin_write_PORTGIO_INEN(bfin_read_PORTGIO_INEN() | (1 << gpio)); ++ bfin_write_PORTGIO_MASKA_SET(bfin_read_PORTGIO_MASKA_SET() & ~(1 << gpio)); ++ bfin_write_PORTGIO_MASKB_SET(bfin_read_PORTGIO_MASKB_SET() & ~(1 << gpio)); ++ bfin_write_PORTG_FER(bfin_read_PORTG_FER() & ~((1 << gpio)|0x3)); + break; + case 'H': +- bfin_write_PORTHIO_DIR(bfin_read_PORTHIO_DIR() & ~(1 << cts)); +- bfin_write_PORTHIO_INEN(bfin_read_PORTHIO_INEN() | (1 << cts)); +- bfin_write_PORTHIO_MASKA_SET(bfin_read_PORTHIO_MASKA_SET() & ~(1 << cts)); +- bfin_write_PORTHIO_MASKB_SET(bfin_read_PORTHIO_MASKB_SET() & ~(1 << cts)); +- bfin_write_PORTHIO_DIR(bfin_read_PORTHIO_DIR() | (1 << rts)); +- bfin_write_PORTH_FER(bfin_read_PORTH_FER() & ~((1 << rts)|(1 << cts)|0x3)); ++ bfin_write_PORTHIO_DIR(bfin_read_PORTHIO_DIR() & ~(1 << gpio)); ++ bfin_write_PORTHIO_INEN(bfin_read_PORTHIO_INEN() | (1 << gpio)); ++ bfin_write_PORTHIO_MASKA_SET(bfin_read_PORTHIO_MASKA_SET() & ~(1 << gpio)); ++ bfin_write_PORTHIO_MASKB_SET(bfin_read_PORTHIO_MASKB_SET() & ~(1 << gpio)); ++ bfin_write_PORTH_FER(bfin_read_PORTH_FER() & ~((1 << gpio)|0x3)); ++ break; ++ default: ++ break; ++ } ++ SSYNC; ++# endif ++} ++ ++static inline void bfin_uart_portio_rts_init(const char *port, const unsigned short gpio) ++{ ++# if defined(CONFIG_BF534) || defined(CONFIG_BF536) || defined(CONFIG_BF537) ++ switch(port[0]) { ++ case 'F': ++ bfin_write_PORTFIO_DIR(bfin_read_PORTFIO_DIR() | (1 << gpio)); ++ bfin_write_PORTF_FER(bfin_read_PORTF_FER() & ~((1 << gpio)|0x3)); ++ break; ++ case 'G': ++ bfin_write_PORTGIO_DIR(bfin_read_PORTGIO_DIR() | (1 << gpio)); ++ bfin_write_PORTG_FER(bfin_read_PORTG_FER() & ~((1 << gpio)|0x3)); ++ break; ++ case 'H': ++ bfin_write_PORTHIO_DIR(bfin_read_PORTHIO_DIR() | (1 << gpio)); ++ bfin_write_PORTH_FER(bfin_read_PORTH_FER() & ~((1 << gpio)|0x3)); + break; + default: + break; +@@ -320,13 +340,13 @@ static inline void bfin_setsignal(struct + switch(info->line) { + # ifdef CONFIG_BFIN_UART0_CTSRTS + case 0: +- port = CONFIG_BFIN_UART0_CTSRTS_PORT; ++ port = CONFIG_BFIN_UART0_RTS_PORT; + rts_mask = (1 << CONFIG_BFIN_UART0_RTS); + break; + # endif + # ifdef CONFIG_BFIN_UART1_CTSRTS + case 1: +- port = CONFIG_BFIN_UART1_CTSRTS_PORT; ++ port = CONFIG_BFIN_UART1_RTS_PORT; + rts_mask = (1 << CONFIG_BFIN_UART1_RTS); + break; + # endif +@@ -359,13 +379,13 @@ static inline int bfin_getsignal(struct + switch(info->line) { + # ifdef CONFIG_BFIN_UART0_CTSRTS + case 0: +- port = CONFIG_BFIN_UART0_CTSRTS_PORT; ++ port = CONFIG_BFIN_UART0_CTS_PORT; + cts_mask = (1 << CONFIG_BFIN_UART0_CTS); + break; + # endif + # ifdef CONFIG_BFIN_UART1_CTSRTS + case 1: +- port = CONFIG_BFIN_UART1_CTSRTS_PORT; ++ port = CONFIG_BFIN_UART1_CTS_PORT; + cts_mask = (1 << CONFIG_BFIN_UART1_CTS); + break; + # endif +@@ -2005,8 +2025,8 @@ int rs_open(struct tty_struct *tty, stru + } + } + #if defined(CONFIG_BFIN_UART0_CTSRTS) +- bfin_uart_portio_ctsrts_init(CONFIG_BFIN_UART0_CTSRTS_PORT, +- CONFIG_BFIN_UART0_CTS, CONFIG_BFIN_UART0_RTS); ++ bfin_uart_portio_cts_init(CONFIG_BFIN_UART0_CTS_PORT, CONFIG_BFIN_UART0_CTS); ++ bfin_uart_portio_rts_init(CONFIG_BFIN_UART0_RTS_PORT, CONFIG_BFIN_UART0_RTS); + #endif + } + #if defined(CONFIG_BF534) || defined(CONFIG_BF536) || defined(CONFIG_BF537) +@@ -2025,8 +2045,8 @@ int rs_open(struct tty_struct *tty, stru + bfin_write_PORTF_FER(bfin_read_PORTF_FER() | 0xc); + SSYNC; + # if defined(CONFIG_BFIN_UART1_CTSRTS) +- bfin_uart_portio_ctsrts_init(CONFIG_BFIN_UART1_CTSRTS_PORT, +- CONFIG_BFIN_UART1_CTS, CONFIG_BFIN_UART1_RTS); ++ bfin_uart_portio_cts_init(CONFIG_BFIN_UART1_CTS_PORT, CONFIG_BFIN_UART1_CTS); ++ bfin_uart_portio_rts_init(CONFIG_BFIN_UART1_RTS_PORT, CONFIG_BFIN_UART1_RTS); + # endif + } + #endif +@@ -2311,8 +2331,8 @@ int bfin_console_setup(struct console *c + #endif + SSYNC; + #ifdef CONFIG_BFIN_UART0_CTSRTS +- bfin_uart_portio_ctsrts_init(CONFIG_BFIN_UART0_CTSRTS_PORT, +- CONFIG_BFIN_UART0_CTS, CONFIG_BFIN_UART0_RTS); ++ bfin_uart_portio_cts_init(CONFIG_BFIN_UART0_CTS_PORT, CONFIG_BFIN_UART0_CTS); ++ bfin_uart_portio_rts_init(CONFIG_BFIN_UART0_RTS_PORT, CONFIG_BFIN_UART0_RTS); + #endif + } + #if defined(CONFIG_BF534) || defined(CONFIG_BF536) || defined(CONFIG_BF537) +@@ -2321,8 +2341,8 @@ int bfin_console_setup(struct console *c + bfin_write_PORTF_FER(bfin_read_PORTF_FER() | 0xc); + SSYNC; + # ifdef CONFIG_BFIN_UART1_CTSRTS +- bfin_uart_portio_ctsrts_init(CONFIG_BFIN_UART1_CTSRTS_PORT, +- CONFIG_BFIN_UART1_CTS, CONFIG_BFIN_UART1_RTS); ++ bfin_uart_portio_cts_init(CONFIG_BFIN_UART1_CTS_PORT, CONFIG_BFIN_UART1_CTS); ++ bfin_uart_portio_rts_init(CONFIG_BFIN_UART1_RTS_PORT, CONFIG_BFIN_UART1_RTS); + # endif + } + #endif diff --git a/blackfin-set-ex-handler.patch b/blackfin-set-ex-handler.patch new file mode 100644 index 0000000..0165468 --- /dev/null +++ b/blackfin-set-ex-handler.patch @@ -0,0 +1,71 @@ +Index: include/asm-blackfin/irq_handler.h +=================================================================== +--- include/asm-blackfin/irq_handler.h (revision 3481) ++++ include/asm-blackfin/irq_handler.h (working copy) +@@ -18,5 +18,8 @@ asmlinkage void evt_evt13(void); + asmlinkage void evt_soft_int1(void); + asmlinkage void evt_system_call(void); + asmlinkage void init_exception_buff(void); ++asmlinkage void return_from_exception(void); ++ ++asmlinkage void *(*bfin_replace_exception_vector)(int exception, void (*handler)(void)); + + #endif +Index: arch/blackfin/mach-common/entry.S +=================================================================== +--- arch/blackfin/mach-common/entry.S (revision 3481) ++++ arch/blackfin/mach-common/entry.S (working copy) +@@ -135,7 +135,7 @@ ENTRY(_ex_single_step) + cc = r6 == r7; + if !cc jump _ex_trap_c; + +-_return_from_exception: ++ENTRY(_return_from_exception) + DEBUG_START_HWTRACE(p5, r7) + #if ANOMALY_05000257 + R7=LC0; +@@ -717,6 +717,33 @@ _schedule_and_signal: + rti; + ENDPROC(_lower_to_irq14) + ++/* void *bfin_replace_exception_vector(int exception, void *handler) */ ++ENTRY(_bfin_replace_exception_vector) ++ [--sp] = (P5:4); ++ [--sp] = ASTAT; ++ ++ /* make sure exception # is valid */ ++ P4 = R0; ++ P5 = 0x3F; ++ CC = P4 <= P5; ++ IF CC jump .Lpass (bp); ++ R0 = -ERANGE; ++ jump .Lfail; ++ ++ /* set new handler and return old one */ ++.Lpass: ++ P5.L = _extable; ++ P5.H = _extable; ++ P5 = P5 + (P4 << 2); ++ R0 = [P5]; ++ [P5] = R1; ++ ++.Lfail: ++ ASTAT = [sp++]; ++ (P5:4) = [sp++]; ++ rts; ++ENDPROC(_bfin_replace_exception_vector) ++ + /* Make sure when we start, that the circular buffer is initialized properly + * R0 and P0 are call clobbered, so we can use them here. + */ +Index: arch/blackfin/kernel/bfin_ksyms.c +=================================================================== +--- arch/blackfin/kernel/bfin_ksyms.c (revision 3481) ++++ arch/blackfin/kernel/bfin_ksyms.c (working copy) +@@ -118,3 +118,6 @@ EXPORT_SYMBOL(_etext_l1); + EXPORT_SYMBOL(_sdata_l1); + EXPORT_SYMBOL(_ebss_b_l1); + EXPORT_SYMBOL(_sdata_b_l1); ++ ++EXPORT_SYMBOL(bfin_replace_exception_vector); ++EXPORT_SYMBOL(return_from_exception); diff --git a/blackfin-simpler-gcc-lib-install.patch b/blackfin-simpler-gcc-lib-install.patch new file mode 100644 index 0000000..7b9107c --- /dev/null +++ b/blackfin-simpler-gcc-lib-install.patch @@ -0,0 +1,244 @@ +Index: BuildToolChain +=================================================================== +--- BuildToolChain (revision 1707) ++++ BuildToolChain (working copy) +@@ -792,205 +792,41 @@ + rm -f $3/bin/tclsh* $3/bin/wish* + } + +-# If $1 is newer than $2, return 1. Otherwise, return 0. +- +-is_newer () +-{ +- MAJOR1=`echo $1 | sed 's/\([0-9]*\).*/\1/'` +- MINOR1=`echo $1 | sed 's/[0-9]*.\([0-9]*\).*/\1/'` +- PATCH1=`echo $1 | sed 's/[0-9]*.[0-9]*.\([0-9]*\).*/\1/'` +- MAJOR2=`echo $2 | sed 's/\([0-9]*\).*/\1/'` +- MINOR2=`echo $2 | sed 's/[0-9]*.\([0-9]*\).*/\1/'` +- PATCH2=`echo $2 | sed 's/[0-9]*.[0-9]*.\([0-9]*\).*/\1/'` +- +- if [ -z "$MAJOR1" -o -z "$MINOR1" -o -z "$PATCH1" -o -z "$MAJOR2" -o -z "$MINOR2" -o -z "$PATCH2" ]; then +- return 0; +- fi +- +- if [ "$MAJOR1" -lt "$MAJOR2" ]; then +- return 0; +- elif [ "$MAJOR1" -gt "$MAJOR2" ]; then +- return 1; +- elif [ "$MINOR1" -lt "$MINOR2" ]; then +- return 0; +- elif [ "$MINOR1" -gt "$MINOR2" ]; then +- return 1; +- elif [ "$PATCH1" -lt "$PATCH2" ]; then +- return 0; +- elif [ "$PATCH1" -gt "$PATCH2" ]; then +- return 1; +- else +- return 0; +- fi +-} +- +-# If $1 is compatible with $2, return 1. Otherwise, return 0. +- +-is_compat () +-{ +- MAJOR1=`echo $1 | sed 's/\([0-9]*\).*/\1/'` +- MINOR1=`echo $1 | sed 's/[0-9]*.\([0-9]*\).*/\1/'` +- PATCH1=`echo $1 | sed 's/[0-9]*.[0-9]*.\([0-9]*\).*/\1/'` +- MAJOR2=`echo $2 | sed 's/\([0-9]*\).*/\1/'` +- MINOR2=`echo $2 | sed 's/[0-9]*.\([0-9]*\).*/\1/'` +- PATCH2=`echo $2 | sed 's/[0-9]*.[0-9]*.\([0-9]*\).*/\1/'` +- +- if [ -z "$MAJOR1" -o -z "$MINOR1" -o -z "$PATCH1" -o -z "$MAJOR2" -o -z "$MINOR2" -o -z "$PATCH2" ]; then +- return 0; +- fi +- +- if [ "$MAJOR1" -eq "$MAJOR2" -a "$MINOR1" -eq "$MINOR2" ]; then +- return 1; +- else +- return 0; +- fi +-} +- +-# Install shared libstdc++ libraries into sysroot direcotory ++# Install shared libraries into sysroot direcotory + # 1st argument is the toolchain install directory + # 2nd argument is the toolchain name + +-install_libstdcpps () ++install_gcc_libs () + { +- GCCS=`find $1 -name bfin-linux-uclibc-gcc-* | tr '\n' ' '` ++ pushd $1/lib/gcc/$2 > /dev/null + +- while [ -n "$GCCS" ]; do +- GCCS2="" +- COMPAT_GCCS="" +- NEWEST_VERSION="" +- NEWEST_GCC="" ++ # install the libraries from the latest version of the toolchain ++ GCC_VER=$(echo * | tr ' ' '\n' | LC_ALL=C sort | tail -n 1) ++ cd "${GCC_VER}" + +- for GCC in $GCCS; do +- LIBSTDCPP=`$GCC --print-file-name=libstdc++.so` +- LIBSTDCPP=`readlink -f $LIBSTDCPP` +- LIBSTDCPP_DIR=`dirname $LIBSTDCPP` +- LIBSTDCPP_NAME=`basename $LIBSTDCPP` +- LIBSTDCPP_VERSION=`echo $LIBSTDCPP_NAME | sed 's/libstdc++.so.\([0-9]*.[0-9]*.[0-9]*\).*/\1/'` +- +- if [ -z "$NEWEST_VERSION" ]; then +- NEWEST_VERSION=$LIBSTDCPP_VERSION +- NEWEST_GCC=$GCC +- COMPAT_GCCS=$GCC +- continue +- fi ++ # walk each multilib version ++ for l in $(find -name 'lib*.so') ; do ++ echo "Installing shared ${l} from gcc dir into runtime sysroot" + +- is_compat $LIBSTDCPP_VERSION $NEWEST_VERSION +- if [ $? -eq 1 ]; then +- COMPAT_GCCS="$COMPAT_GCCS $GCC" ++ DIRNAME=$(dirname ${l}) ++ SONAME=$(readelf -d ${l} | sed -n '/SONAME/s:.*\[\(.*\)\]:\1:p') ++ FULLNAME=$(basename $(readlink ${l})) ++ DESTDIR="../../../../$2/runtime/${DIRNAME}/lib" + +- is_newer $LIBSTDCPP_VERSION $NEWEST_VERSION +- if [ $? -eq 1 ]; then +- NEWEST_VERSION=$LIBSTDCPP_VERSION +- NEWEST_GCC=$GCC +- fi +- else +- GCCS2="$GCCS2 $GCC" +- fi +- done ++ # move the soname and the full versioned one (if it exists) ++ # aka libstdc.so.x and libstdc.so.x.y.z ++ mv ${DIRNAME}/${FULLNAME} ${DESTDIR}/${FULLNAME} ++ if [ "${FULLNAME}" != "${SONAME}" ] ; then ++ ln -s ${FULLNAME} ${DESTDIR}/${SONAME} ++ fi + +- echo "Installing shared libstdc++ from $NEWEST_GCC" +- +- MULTILIBS=`$NEWEST_GCC --print-multi-lib` +- +- for ml in $MULTILIBS; do +- +- dir=`echo ${ml} | sed -e 's/;.*$//'` +- flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'` +- if [ "$dir" = "." ]; then +- dir2= +- else +- dir2=`echo ${dir} | sed -e 's|[^/]*|..|g'`/ +- fi +- +- LIBSTDCPP=`$NEWEST_GCC $flags --print-file-name=libstdc++.so` +- LIBSTDCPP=`readlink -f $LIBSTDCPP` +- LIBSTDCPP_DIR=`dirname $LIBSTDCPP` +- LIBSTDCPP_NAME=`basename $LIBSTDCPP` +- LIBSTDCPP_VERSION=`echo $LIBSTDCPP_NAME | sed 's/libstdc++.so.\([0-9]*.[0-9]*.[0-9]*\).*/\1/'` +- MAJOR_NUM=`echo $LIBSTDCPP_VERSION | sed 's/\([0-9]*\).*/\1/'` +- +- cp $LIBSTDCPP $1/$2/runtime/$dir/lib +- ln -s $LIBSTDCPP_NAME $1/$2/runtime/$dir/lib/libstdc++.so.$MAJOR_NUM +- +- for G in $COMPAT_GCCS; do +- L=`$G $flags --print-file-name=libstdc++.so` +- rm -f `dirname $L`/libstdc++.so* +- ln -s ../../../../$dir2$2/runtime/$dir/lib/$LIBSTDCPP_NAME `dirname $L`/libstdc++.so +- done +- +- done +- +- GCCS=$GCCS2 ++ # create a symlink here from the linkable lib to ++ # the full versioned one so gcc can still find it ++ rm -f ${l} ${DIRNAME}/${SONAME} ++ ln -s ${DESTDIR}/${FULLNAME} ${l} + done +-} + +-# Install shared libgcc libraries into sysroot direcotory +-# 1st argument is the toolchain install directory +-# 2nd argument is the toolchain name +-# FIXME: Only libgcc_s.so.1 is handled +- +-install_libgccs () +-{ +- GCCS=`find $1 -name bfin-linux-uclibc-gcc-* | tr '\n' ' '` +- +- NEWEST_VERSION="" +- NEWEST_GCC="" +- for GCC in $GCCS; do +- LIBGCC=`$GCC --print-file-name=libgcc_s.so` +- LIBGCC_DIR=`dirname $LIBGCC` +- GCC_VERSION=`basename $LIBGCC_DIR` +- +- if [ -z "$NEWEST_VERSION" ]; then +- NEWEST_VERSION=$GCC_VERSION +- NEWEST_GCC=$GCC +- continue +- fi +- +- is_newer $GCC_VERSION $NEWEST_VERSION +- if [ $? -eq 1 ]; then +- NEWEST_VERSION=$GCC_VERSION +- NEWEST_GCC=$GCC +- fi +- done +- +- echo "Installing libgcc_s from $NEWEST_GCC" +- +- MULTILIBS=`$NEWEST_GCC --print-multi-lib` +- +- for ml in $MULTILIBS; do +- +- dir=`echo ${ml} | sed -e 's/;.*$//'` +- flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'` +- +- LIBGCC=`$NEWEST_GCC $flags --print-file-name=libgcc_s_$dir.so` +- if [ ! -e $LIBGCC ]; then +- LIBGCC=`$NEWEST_GCC $flags --print-file-name=libgcc_s.so` +- fi +- if [ ! -e $LIBGCC ]; then +- echo "No libgcc_s.so for $NEWEST_GCC - report an error" +- tail -10 $ACTUAL_LOGFILE +- exit 1 +- fi +- +- LIBGCC=`readlink -f $LIBGCC` +- LIBGCC_DIR=`dirname $LIBGCC` +- LIBGCC_NAME=`basename $LIBGCC` +- +- cp $LIBGCC $1/$2/runtime/$dir/lib +- +- for G in $GCCS; do +- L=`$G $flags --print-file-name=libgcc_s_$dir.so` +- dir2= +- if [ ! -e $L ]; then +- L=`$G $flags --print-file-name=libgcc_s.so` +- if [ "$dir" != "." ]; then +- dir2=`echo ${dir} | sed -e 's|[^/]*|..|g'`/ +- fi +- fi +- rm -f $L* +- ln -s ../../../../$dir2$2/runtime/$dir/lib/$LIBGCC_NAME $L +- done +- done ++ popd > /dev/null + } + + run_tests () +@@ -1667,8 +1503,7 @@ + done + rm -f $DIR_LINUX_OUTPUT/bfin-linux-uclibc/sys-include + +- install_libstdcpps $DIR_LINUX_OUTPUT bfin-linux-uclibc +- install_libgccs $DIR_LINUX_OUTPUT bfin-linux-uclibc ++ install_gcc_libs $DIR_LINUX_OUTPUT bfin-linux-uclibc + + ##################### Test bfin-linux-uclibc ##################### + diff --git a/blackfin-use-defines-not-constants.patch b/blackfin-use-defines-not-constants.patch new file mode 100644 index 0000000..2470a66 --- /dev/null +++ b/blackfin-use-defines-not-constants.patch @@ -0,0 +1,76 @@ +Index: arch/blackfin/kernel/vmlinux.lds.S +=================================================================== +--- arch/blackfin/kernel/vmlinux.lds.S (revision 3447) ++++ arch/blackfin/kernel/vmlinux.lds.S (working copy) +@@ -31,6 +31,8 @@ + + #include + #include ++#include ++#include + + OUTPUT_FORMAT("elf32-bfin") + ENTRY(__start) +@@ -64,7 +66,7 @@ + .data : + { + __sdata = .; +- . = ALIGN(0x2000); ++ . = ALIGN(THREAD_SIZE); + *(.data.init_task) + *(.data) + CONSTRUCTORS +@@ -72,14 +74,14 @@ + . = ALIGN(32); + *(.data.cacheline_aligned) + +- . = ALIGN(0x2000); ++ . = ALIGN(THREAD_SIZE); + __edata = .; + } + + ___init_begin = .; + .init : + { +- . = ALIGN(4096); ++ . = ALIGN(PAGE_SIZE); + __sinittext = .; + *(.init.text) + __einittext = .; +Index: include/asm-blackfin/thread_info.h +=================================================================== +--- include/asm-blackfin/thread_info.h (revision 3447) ++++ include/asm-blackfin/thread_info.h (working copy) +@@ -39,6 +39,11 @@ + */ + #define ALIGN_PAGE_MASK 0xffffe000 + ++/* ++ * Size of kernel stack for each process. This must be a power of 2... ++ */ ++#define THREAD_SIZE 8192 /* 2 pages */ ++ + #ifndef __ASSEMBLY__ + + typedef unsigned long mm_segment_t; +@@ -76,11 +81,6 @@ + #define init_thread_info (init_thread_union.thread_info) + #define init_stack (init_thread_union.stack) + +-/* +- * Size of kernel stack for each process. This must be a power of 2... +- */ +-#define THREAD_SIZE 8192 /* 2 pages */ +- + /* How to get the thread information struct from C */ + + static inline struct thread_info *current_thread_info(void) +@@ -94,7 +94,7 @@ + struct thread_info *ti; + __asm__("%0 = sp;": "=&d"(ti): + ); +- return (struct thread_info *)((long)ti & ~8191UL); ++ return (struct thread_info *)((long)ti & ~((long)THREAD_SIZE-1)); + } + + /* thread information allocation */ diff --git a/built_with_use.patch b/built_with_use.patch new file mode 100644 index 0000000..2f1bfe5 --- /dev/null +++ b/built_with_use.patch @@ -0,0 +1,23 @@ +Index: eutils.eclass +=================================================================== +RCS file: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v +retrieving revision 1.248 +diff -u -p -r1.248 eutils.eclass +--- eutils.eclass 19 Aug 2006 13:52:02 -0000 1.248 ++++ eutils.eclass 10 Sep 2006 08:09:57 -0000 +@@ -1595,11 +1595,15 @@ built_with_use() { + shift + + local USEFILE=${ROOT}/var/db/pkg/${PKG}/USE ++ local IUSEFILE=${ROOT}/var/db/pkg/${PKG}/IUSE + + # if the USE file doesnt exist, assume the $PKG is either + # injected or package.provided + [[ ! -e ${USEFILE} ]] && die "Unable to determine what USE flags $PKG was built with" + ++ local IUSE_BUILT=$(<${IUSEFILE}) ++ has $1 ${IUSE_BUILT} || die "$PKG does not actually support the $1 USE flag!" ++ + local USE_BUILT=$(<${USEFILE}) + while [[ $# -gt 0 ]] ; do + if [[ ${opt} = "-o" ]] ; then diff --git a/busybox-devmem.patch b/busybox-devmem.patch new file mode 100644 index 0000000..3932119 --- /dev/null +++ b/busybox-devmem.patch @@ -0,0 +1,128 @@ +diff -Nrup include/applets.h include/applets.h +--- include/applets.h 2008-04-26 18:22:37.000000000 +0000 ++++ include/applets.h 2008-04-26 18:19:53.000000000 +0000 +@@ -121,6 +121,7 @@ USE_DEALLOCVT(APPLET(deallocvt, _BB_DIR_ + USE_DELGROUP(APPLET_ODDNAME(delgroup, deluser, _BB_DIR_BIN, _BB_SUID_NEVER, delgroup)) + USE_DELUSER(APPLET(deluser, _BB_DIR_BIN, _BB_SUID_NEVER)) + USE_DEVFSD(APPLET(devfsd, _BB_DIR_SBIN, _BB_SUID_NEVER)) ++USE_DEVMEM(APPLET(devmem, _BB_DIR_SBIN, _BB_SUID_NEVER)) + USE_DF(APPLET(df, _BB_DIR_BIN, _BB_SUID_NEVER)) + USE_APP_DHCPRELAY(APPLET(dhcprelay, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)) + USE_DIFF(APPLET(diff, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) +diff -Nrup include/usage.h include/usage.h +--- include/usage.h 2007-12-21 22:00:31.000000000 +0000 ++++ include/usage.h 2008-04-26 18:21:59.000000000 +0000 +@@ -630,6 +630,16 @@ + "\n and processing synthetic REGISTER events," \ + "\n do not poll for events") + ++#define devmem_trivial_usage \ ++ "{ address } [ type [ data ] ]" ++ ++#define devmem_full_usage \ ++ "Read/Write from physical addresses" \ ++ "\n\nUsage: devmem { address } [ type [ data ] ]" \ ++ "\n address : memory address to act upon" \ ++ "\n type : access operation type : [b]yte, [h]alfword, [w]ord" \ ++ "\n data : data to be written" ++ + /* -k is accepted but ignored for !HUMAN_READABLE, + * but we won't mention this (unimportant) */ + #if ENABLE_FEATURE_HUMAN_READABLE || ENABLE_FEATURE_DF_INODE +diff -Nrup miscutils/Config.in miscutils/Config.in +--- miscutils/Config.in 2007-12-21 22:00:31.000000000 +0000 ++++ miscutils/Config.in 2008-04-26 17:54:51.000000000 +0000 +@@ -120,6 +120,13 @@ config FEATURE_DEVFS + /dev/loop0. If your /dev directory has normal names instead of + devfs names, you don't want this. + ++config DEVMEM ++ bool "devmem" ++ default y ++ help ++ devmem is a small program that reads and writes from physical ++ memory using /dev/mem. ++ + config EJECT + bool "eject" + default n +diff -Nrup miscutils/Kbuild miscutils/Kbuild +--- miscutils/Kbuild 2007-12-21 22:00:31.000000000 +0000 ++++ miscutils/Kbuild 2008-04-26 17:56:36.000000000 +0000 +@@ -12,6 +12,7 @@ lib-$(CONFIG_CROND) += crond.o + lib-$(CONFIG_CRONTAB) += crontab.o + lib-$(CONFIG_DC) += dc.o + lib-$(CONFIG_DEVFSD) += devfsd.o ++lib-$(CONFIG_DEVMEM) += devmem.o + lib-$(CONFIG_EJECT) += eject.o + lib-$(CONFIG_HDPARM) += hdparm.o + lib-$(CONFIG_LAST) += last.o +diff -Nrup miscutils/devmem.c miscutils/devmem.c +--- miscutils/devmem.c 1970-01-01 00:00:00.000000000 +0000 ++++ miscutils/devmem.c 2008-04-26 18:18:30.000000000 +0000 +@@ -0,0 +1,65 @@ ++/* ++ * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. ++ * Copyright (C) 2000, Jan-Derk Bakker (J.D.Bakker@its.tudelft.nl) ++ * Copyright (C) 2008, BusyBox Team. -solar 4/26/08 ++ */ ++ ++#include "libbb.h" ++ ++#define DEVMEM_MAP_SIZE 4096UL ++#define DEVMEM_MAP_MASK (DEVMEM_MAP_SIZE - 1) ++ ++int devmem_main(int argc, char **argv) { ++ void *map_base, *virt_addr; ++ unsigned long read_result, writeval; ++ off_t target; ++ int fd, access_type = 'w'; ++ ++ if (argc < 2) ++ bb_show_usage(); ++ ++ target = bb_strtoul(argv[1], 0, 0); ++ ++ if (argc > 2) ++ access_type = tolower(argv[2][0]); ++ ++ fd = xopen("/dev/mem", O_RDWR | O_SYNC); ++ ++ if ((map_base = mmap(0, DEVMEM_MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, target & ~DEVMEM_MAP_MASK)) == MAP_FAILED) ++ bb_perror_msg_and_die("mmap"); ++ ++ printf("Memory mapped at address %p.\n", map_base); ++ ++ virt_addr = map_base + (target & DEVMEM_MAP_MASK); ++ if (access_type == 'b') ++ read_result = *((unsigned char *) virt_addr); ++ else if (access_type == 'h') ++ read_result = *((unsigned short *) virt_addr); ++ else if (access_type == 'w') ++ read_result = *((unsigned long *) virt_addr); ++ else { ++ fprintf(stderr, "Illegal data type '%c'\n", access_type); ++ exit(EXIT_FAILURE); ++ } ++ printf("Value at address 0x%X (%p): 0x%X\n", target, virt_addr, read_result); ++ ++ if (argc > 3) { ++ writeval = bb_strtoul(argv[3], 0, 0); ++ if (access_type == 'b') { ++ *((unsigned char *) virt_addr) = writeval; ++ read_result = *((unsigned char *) virt_addr); ++ } else if (access_type == 'h') { ++ *((unsigned short *) virt_addr) = writeval; ++ read_result = *((unsigned short *) virt_addr); ++ } else if (access_type == 'w') { ++ *((unsigned long *) virt_addr) = writeval; ++ read_result = *((unsigned long *) virt_addr); ++ } ++ printf("Written 0x%X; readback 0x%X\n", writeval, read_result); ++ } ++ ++ if (munmap(map_base, DEVMEM_MAP_SIZE) == -1) ++ bb_perror_msg_and_die("munmap"); ++ close(fd); ++ fflush_stdout_and_exit(EXIT_SUCCESS); ++} diff --git a/busybox-elf2flt.patch b/busybox-elf2flt.patch new file mode 100644 index 0000000..b2c4c3c --- /dev/null +++ b/busybox-elf2flt.patch @@ -0,0 +1,33 @@ +Index: Makefile +=================================================================== +--- Makefile (revision 18843) ++++ Makefile (working copy) +@@ -676,9 +676,14 @@ busybox_unstripped: $(busybox-all) FORCE + $(call if_changed_rule,busybox__) + $(Q)rm -f .old_version + ++LDFLAGS_ELF2FLT = -Wl,-elf2flt + busybox: busybox_unstripped ++ifneq (,$(findstring $(LDFLAGS_ELF2FLT),$(LDFLAGS))) ++ $(Q)cp $< $@ ++else + $(Q)$(STRIP) -s --remove-section=.note --remove-section=.comment \ + busybox_unstripped -o $@ ++endif + + # The actual objects are generated when descending, + # make sure no implicit rule kicks in +Index: Makefile.custom +=================================================================== +--- Makefile.custom (revision 18843) ++++ Makefile.custom (working copy) +@@ -2,9 +2,6 @@ + # Build system + # ========================================================================== + +-%.bflt: %_unstripped +- $(CROSS_COMPILE)elf2flt $(ELF2FLTFLAGS) $< -o $@ +- + busybox.links: $(srctree)/applets/busybox.mkll $(objtree)/include/autoconf.h $(srctree)/include/applets.h + $(Q)-$(SHELL) $^ >$@ + diff --git a/busybox-symlinks.patch b/busybox-symlinks.patch new file mode 100644 index 0000000..b8afdc3 --- /dev/null +++ b/busybox-symlinks.patch @@ -0,0 +1,111 @@ +Index: busybox-1.2.1.ebuild +=================================================================== +RCS file: /var/cvsroot/gentoo-x86/sys-apps/busybox/busybox-1.2.1.ebuild,v +retrieving revision 1.7 +diff -u -p -r1.7 busybox-1.2.1.ebuild +--- busybox-1.2.1.ebuild 9 Aug 2006 18:18:00 -0000 1.7 ++++ busybox-1.2.1.ebuild 28 Aug 2006 05:54:07 -0000 +@@ -169,8 +169,11 @@ src_unpack() { + + src_compile() { + busybox_set_env ++ ++ # work around broken ass powerpc compilers + use ppc64 && append-flags -mminimal-toc $(test-flags-CC -fno-stack-protector) + use ppc && append-flags $(test-flags-CC -fno-stack-protector) ++ + emake CROSS="${CROSS}" busybox || die "build failed" + if ! use static ; then + mv busybox_unstripped{,.bak} +@@ -203,27 +206,12 @@ src_install() { + && dosym busybox /bin/bb \ + || dobin bb + +- if use make-symlinks ; then +- if [[ ! ${VERY_BRAVE_OR_VERY_DUMB} == "yes" ]] && [[ ${ROOT} == "/" ]] ; then +- ewarn "setting USE=make-symlinks and emerging to / is very dangerous." +- ewarn "it WILL overwrite lots of system programs like: ls bash awk grep (bug 60805 for full list)." +- ewarn "If you are creating a binary only and not merging this is probably ok." +- ewarn "set env VERY_BRAVE_OR_VERY_DUMB=yes if this is realy what you want." +- die "silly options will destroy your system" +- fi +- make CROSS="${CROSS}" install || die +- cp -pPR _install/${x}/* "${D}"/ || die "copying links for ${x} failed" +- cd "${D}" +- # XXX: should really move this to pkg_preinst() ... +- local symlink +- for symlink in {,usr/}{bin,sbin}/* linuxrc ; do +- [[ -L ${symlink} ]] || continue +- [[ -e ${ROOT}/${symlink} ]] \ +- && eerror "Deleting symlink ${symlink} because it exists in ${ROOT}" \ +- && rm ${symlink} +- done +- cd "${S}" +- fi ++ # bundle up the symlink files for use later ++ make CROSS="${CROSS}" install || die ++ rm _install/bin/busybox ++ tar cf busybox-links.tar -C _install . || die ++ insinto /usr/share/${PN} ++ doins busybox-links.tar || die + + dodoc AUTHORS README TODO + +@@ -234,9 +222,6 @@ src_install() { + dodoc *.pod + dohtml *.html *.sgml + +- # no man files? +- # cd ../man && doman *.1 +- + cd ../examples || die + docinto examples + dodoc inittab depmod.pl *.conf *.script undeb unrpm +@@ -244,23 +229,28 @@ src_install() { + cd bootfloppy || die + docinto bootfloppy + dodoc * etc/* etc/init.d/* 2>/dev/null ++} + +- cd ../../ || die +- if has buildpkg ${FEATURES} && has keepwork ${FEATURES} ; then +- cd "${S}" +- # this should install to the ./_install/ dir by default. +- # we make a micro pkg of busybox that can be used for +- # embedded systems -solar +- if ! use make-symlinks ; then +- make CROSS="${CROSS}" install || die +- fi +- cd ./_install/ \ +- && tar --no-same-owner -jcvf ${WORKDIR}/${MY_P}-${ARCH}.bz2 . \ +- && cd .. ++pkg_preinst() { ++ if use make-symlinks && [[ ! ${VERY_BRAVE_OR_VERY_DUMB} == "yes" ]] && [[ ${ROOT} == "/" ]] ; then ++ ewarn "setting USE=make-symlinks and emerging to / is very dangerous." ++ ewarn "it WILL overwrite lots of system programs like: ls bash awk grep (bug 60805 for full list)." ++ ewarn "If you are creating a binary only and not merging this is probably ok." ++ ewarn "set env VERY_BRAVE_OR_VERY_DUMB=yes if this is realy what you want." ++ die "silly options will destroy your system" + fi ++ ++ mv "${D}"/usr/share/${PN}/busybox-links.tar "${T}"/ || die + } + + pkg_postinst() { ++ if use make-symlinks ; then ++ cd "${T}" || die ++ mkdir _install ++ tar xf busybox-links.tar -C _install || die ++ cp -vpPR _install/* "${ROOT}"/ || die "copying links for ${x} failed" ++ fi ++ + if use savedconfig ; then + local config_dir="${PORTAGE_CONFIGROOT:-${ROOT}}/etc/portage/savedconfig" + einfo "Saving this build config to ${config_dir}/${PF}.config" +@@ -275,6 +265,3 @@ pkg_postinst() { + einfo "if you want to add or remove functionality for ${PN}" + echo + } +- +- +- diff --git a/busybox-xioctl.patch b/busybox-xioctl.patch new file mode 100644 index 0000000..32c7c4f --- /dev/null +++ b/busybox-xioctl.patch @@ -0,0 +1,62 @@ +Index: console-tools/deallocvt.c +=================================================================== +--- console-tools/deallocvt.c (revision 18902) ++++ console-tools/deallocvt.c (working copy) +@@ -31,8 +31,7 @@ int deallocvt_main(int argc, char **argv + bb_show_usage(); + } + +- if (-1 == ioctl(get_console_fd(), VT_DISALLOCATE, num)) { +- bb_perror_msg_and_die("VT_DISALLOCATE"); +- } ++ xioctl(get_console_fd(), VT_DISALLOCATE, num); ++ + return EXIT_SUCCESS; + } +Index: libbb/xfuncs.c +=================================================================== +--- libbb/xfuncs.c (revision 18902) ++++ libbb/xfuncs.c (working copy) +@@ -639,3 +639,13 @@ int get_terminal_width_height(const int + + return ret; + } ++ ++/* Die if the ioctl() call failed. Only support the 3 arg form. */ ++#undef xioctl ++int xioctl(int fd, int request, unsigned long arg) ++{ ++ int ret = ioctl(fd, request, arg); ++ if (ret != 0) ++ bb_perror_msg_and_die("ioctl"); ++ return ret; ++} +Index: miscutils/raidautorun.c +=================================================================== +--- miscutils/raidautorun.c (revision 18902) ++++ miscutils/raidautorun.c (working copy) +@@ -19,9 +19,7 @@ int raidautorun_main(int argc, char **ar + if (argc != 2) + bb_show_usage(); + +- if (ioctl(xopen(argv[1], O_RDONLY), RAID_AUTORUN, NULL) != 0) { +- bb_perror_msg_and_die("ioctl"); +- } ++ xioctl(xopen(argv[1], O_RDONLY), RAID_AUTORUN, NULL); + + return EXIT_SUCCESS; + } +Index: include/libbb.h +=================================================================== +--- include/libbb.h (revision 18902) ++++ include/libbb.h (working copy) +@@ -249,7 +249,8 @@ DIR *warn_opendir(const char *path); + char *xrealloc_getcwd_or_warn(char *cwd); + char *xmalloc_readlink_or_warn(const char *path); + char *xmalloc_realpath(const char *path); +- ++int xioctl(int fd, int request, unsigned long arg); ++#define xioctl(fd,request,arg) xioctl(fd,request,(unsigned long)arg) + + //TODO: signal(sid, f) is the same? then why? + extern void sig_catch(int,void (*)(int)); diff --git a/catalyst-cbuild.patch b/catalyst-cbuild.patch new file mode 100644 index 0000000..abbf5af --- /dev/null +++ b/catalyst-cbuild.patch @@ -0,0 +1,530 @@ +Index: modules/generic_stage_target.py +=================================================================== +--- modules/generic_stage_target.py (revision 1203) ++++ modules/generic_stage_target.py (working copy) +@@ -18,40 +18,21 @@ + + self.valid_values.extend(["version_stamp","target","subarch",\ + "rel_type","profile","snapshot","source_subpath","portage_confdir",\ +- "cflags","cxxflags","ldflags","chost","hostuse","portage_overlay",\ ++ "cflags","cxxflags","ldflags","cbuild","chost","hostuse","portage_overlay",\ + "distcc_hosts","makeopts","pkgcache_path","kerncache_path"]) + + self.set_valid_build_kernel_vars(addlargs) + generic_target.__init__(self,myspec,addlargs) +- # map the mainarch we are running under to the mainarches we support for +- # building stages and LiveCDs. (for example, on amd64, we can build +- # stages for x86 or amd64. +- targetmap={ +- "x86" : ["x86"], +- "amd64" : ["x86","amd64"], +- "sparc64" : ["sparc","sparc64"], +- "ia64" : ["ia64"], +- "alpha" : ["alpha"], +- "sparc" : ["sparc"], +- "sh" : ["sh"], +- "s390" : ["s390"], +- "ppc" : ["ppc"], +- "ppc64" : ["ppc","ppc64"], +- "hppa" : ["hppa"], +- "mips" : ["mips"], +- "arm" : ["arm"] +- } +- +- machinemap={ ++ machinemap={ + "i386" : "x86", + "i486" : "x86", + "i586" : "x86", + "i686" : "x86", + "x86_64" : "amd64", ++ "sparc" : "sparc", + "sparc64" : "sparc64", + "ia64" : "ia64", + "alpha" : "alpha", +- "sparc" : "sparc", + "sh2" : "sh", + "sh3" : "sh", + "sh4" : "sh", +@@ -61,8 +42,12 @@ + "s390" : "s390", + "ppc" : "ppc", + "ppc64" : "ppc64", +- "parisc" : "hppa", +- "parisc64" : "hppa", ++ "powerpc" : "powerpc", ++ "powerpc64" : "powerpc64", ++ "parisc" : "parisc", ++ "parisc64" : "parisc", ++ "hppa" : "hppa", ++ "hppa64" : "hppa", + "mips" : "mips", + "mips64" : "mips", + "arm" : "arm", +@@ -71,31 +56,38 @@ + "armv5b" : "arm" + } + +- mymachine=os.uname()[4] +- if not machinemap.has_key(mymachine): +- raise CatalystError, "Unknown machine type "+mymachine +- +- self.settings["hostarch"]=machinemap[mymachine] +- self.archmap={} +- self.subarchmap={} ++ if self.settings.has_key("chost"): ++ hostmachine = self.settings["chost"].split("-")[0] ++ else: ++ hostmachine = os.uname()[4] ++ if not machinemap.has_key(hostmachine): ++ raise CatalystError, "Unknown host machine type "+hostmachine ++ self.settings["hostarch"] = machinemap[hostmachine] ++ if self.settings.has_key("cbuild"): ++ buildmachine = self.settings["cbuild"].split("-")[0] ++ else: ++ buildmachine = os.uname()[4] ++ if not machinemap.has_key(buildmachine): ++ raise CatalystError, "Unknown build machine type "+buildmachine ++ self.settings["buildarch"] = machinemap[buildmachine] ++ self.settings["crosscompile"] = (self.settings["hostarch"] != self.settings["buildarch"]) ++ self.archmap = {} ++ self.subarchmap = {} + +- for x in targetmap[self.settings["hostarch"]]: +- try: +- fh=open(self.settings["sharedir"]+"/arch/"+x+".py") +- # This next line loads the plugin as a module and assigns it to +- # archmap[x] +- self.archmap[x]=imp.load_module(x,fh,"arch/"+x+".py",(".py","r",imp.PY_SOURCE)) +- # This next line registers all the subarches supported in the +- # plugin +- self.archmap[x].register(self.subarchmap) +- fh.close() +- +- except IOError: +- msg("Can't find "+x+".py plugin in "+self.settings["sharedir"]+"/arch/") ++ x = self.settings["hostarch"] ++ try: ++ fh = open(self.settings["sharedir"]+"/arch/"+x+".py") ++ # this next line loads the plugin as a module and assigns it to archmap[x] ++ self.archmap[x] = imp.load_module(x,fh,"arch/"+x+".py",(".py","r",imp.PY_SOURCE)) ++ # this next line registers all the subarches supported in the plugin ++ self.archmap[x].register(self.subarchmap) ++ fh.close() ++ except IOError: ++ msg("Can't find "+x+".py plugin in "+self.settings["sharedir"]+"/arch/") + # Call arch constructor, pass our settings + try: + self.arch=self.subarchmap[self.settings["subarch"]](self.settings) +- except: ++ except: + print "Invalid subarch: "+self.settings["subarch"] + print "Choose one of the following:", + for x in self.subarchmap: +@@ -104,14 +96,16 @@ + sys.exit(2) + + print "Using target:",self.settings["target"] +- # self.settings["mainarch"] should now be set by our arch constructor, +- # so we print a nice informational message: +- if self.settings["mainarch"]==self.settings["hostarch"]: ++ # print a nice informational message: ++ if self.settings["buildarch"]==self.settings["hostarch"]: + print "Building natively for",self.settings["hostarch"] +- ++ elif self.settings["crosscompile"]: ++ print "Cross-compiling on",self.settings["buildarch"],"for different machine type",\ ++ self.settings["hostarch"] + else: +- print "Building on",self.settings["hostarch"],"for alternate machine type",\ +- self.settings["mainarch"] ++ print "Building on",self.settings["buildarch"],"for alternate personality type",\ ++ self.settings["hostarch"] ++ + # This should be first to be set as other set_ options depend on this + self.set_spec_prefix() + +@@ -205,6 +199,10 @@ + # for the chroot: + self.env["CCACHE_DIR"]="/var/tmp/ccache" + ++ def override_cbuild(self): ++ if self.makeconf.has_key("CBUILD"): ++ self.settings["CBUILD"]=self.makeconf["CBUILD"] ++ + def override_chost(self): + if self.makeconf.has_key("CHOST"): + self.settings["CHOST"]=self.makeconf["CHOST"] +@@ -832,7 +830,8 @@ + + def chroot_setup(self): + self.makeconf=read_makeconf(self.settings["chroot_path"]+"/etc/make.conf") +- self.override_chost() ++ self.override_cbuild() ++ self.override_chost() + self.override_cflags() + self.override_cxxflags() + self.override_ldflags() +@@ -869,7 +868,8 @@ + cmd("mv "+self.settings["chroot_path"]+"/etc/hosts "+self.settings["chroot_path"]+\ + "/etc/hosts.bck", "Could not backup /etc/hosts",env=self.env) + cmd("cp /etc/hosts "+self.settings["chroot_path"]+"/etc/hosts", "Could not copy /etc/hosts",env=self.env) +- #self.override_chost() ++ #self.override_cbuild() ++ #self.override_chost() + #self.override_cflags() + #self.override_cxxflags() + #self.override_ldflags() +@@ -888,6 +888,8 @@ + if self.settings.has_key("LDFLAGS"): + myf.write('LDFLAGS="'+self.settings["LDFLAGS"]+'"\n') + myf.write("# This should not be changed unless you know exactly what you are doing. You\n# should probably be using a different stage, instead.\n") ++ if self.settings.has_key("CBUILD"): ++ myf.write('CBUILD="'+self.settings["CBUILD"]+'"\n') + myf.write('CHOST="'+self.settings["CHOST"]+'"\n') + + # Figure out what our USE vars are for building +@@ -1078,7 +1080,7 @@ + self.purge() + + for x in self.settings["action_sequence"]: +- print "Running action sequence: "+x ++ print "--- Running action sequence: "+x + sys.stdout.flush() + try: + apply(getattr(self,x)) +Index: targets/netboot/netboot-combine.sh +=================================================================== +--- targets/netboot/netboot-combine.sh (revision 1203) ++++ targets/netboot/netboot-combine.sh (working copy) +@@ -15,7 +15,7 @@ + + # First install the boot package that we need + booter="" +-case ${clst_mainarch} in ++case ${clst_hostarch} in + alpha) + booter="" + ;; +@@ -51,7 +51,7 @@ + create_normal_loop ${clst_chroot_path}/tmp/staging/initrd-${kname} ${clst_target_path} initrd-${kname}.igz + rm -r ${clst_chroot_path}/tmp/staging/initrd-${kname} + +- case ${clst_mainarch} in ++ case ${clst_hostarch} in + alpha) + # Until aboot is patched this is broken currently. + # please use catalyst 1.1.5 or older +@@ -93,10 +93,10 @@ + ;; + sparc*) + #TEST TEST TEST TEST +- #elftoaout -o /netboot-${kname}.${clst_mainarch} /usr/src/linux/vmlinux +- #elftoaout -o /netboot-${kname}.${clst_mainarch} /${kname} +- #piggy=${clst_mainarch/sparc/piggyback} +- #${piggy} /netboot-${kname}.${clst_mainarch} /usr/src/linux/System.map /initrd-${kname}.igz ++ #elftoaout -o /netboot-${kname}.${clst_hostarch} /usr/src/linux/vmlinux ++ #elftoaout -o /netboot-${kname}.${clst_hostarch} /${kname} ++ #piggy=${clst_hostarch/sparc/piggyback} ++ #${piggy} /netboot-${kname}.${clst_hostarch} /usr/src/linux/System.map /initrd-${kname}.igz + ;; + x86) + mknbi-linux \ +Index: targets/support/functions.sh +=================================================================== +--- targets/support/functions.sh (revision 1203) ++++ targets/support/functions.sh (working copy) +@@ -211,3 +211,7 @@ + ;; + esac + } ++ ++run_crossdev() { ++ crossdev ${clst_CHOST} ++} +Index: targets/support/netboot2-final.sh +=================================================================== +--- targets/support/netboot2-final.sh (revision 1203) ++++ targets/support/netboot2-final.sh (working copy) +@@ -21,7 +21,7 @@ + + # Any post-processing necessary for each architecture can be done here. This + # may include things like sparc's elftoaout, x86's PXE boot, etc. +-case ${clst_mainarch} in ++case ${clst_hostarch} in + alpha) + sleep 0 + ;; +Index: targets/support/bootloader-setup.sh +=================================================================== +--- targets/support/bootloader-setup.sh (revision 1203) ++++ targets/support/bootloader-setup.sh (working copy) +@@ -13,7 +13,7 @@ + + default_append_line="root=/dev/ram0 init=/linuxrc ${cmdline_opts} ${custom_kopts} cdroot" + +-case ${clst_mainarch} in ++case ${clst_hostarch} in + alpha) + # NO SOFTLEVEL SUPPORT YET + acfg=$1/etc/aboot.conf +Index: targets/support/create-iso.sh +=================================================================== +--- targets/support/create-iso.sh (revision 1203) ++++ targets/support/create-iso.sh (working copy) +@@ -7,7 +7,7 @@ + ## START RUNSCRIPT + + # Check for our CD ISO creation tools +-case ${clst_mainarch} in ++case ${clst_hostarch} in + mips) + cdmaker="sgibootcd" + cdmakerpkg="sys-boot/sgibootcd" +@@ -28,7 +28,7 @@ + then + case ${clst_livecd_type} in + gentoo-*) +- case ${clst_mainarch} in ++ case ${clst_hostarch} in + alpha) + clst_iso_volume_id="Gentoo Linux - Alpha" + ;; +@@ -76,7 +76,7 @@ + fi + + # Here we actually create the ISO images for each architecture +-case ${clst_mainarch} in ++case ${clst_hostarch} in + alpha) + case ${clst_fstype} in + zisofs) +Index: targets/support/pre-kmerge.sh +=================================================================== +--- targets/support/pre-kmerge.sh (revision 1203) ++++ targets/support/pre-kmerge.sh (working copy) +@@ -13,7 +13,7 @@ + # Setup case structure for livecd_type + case ${clst_livecd_type} in + gentoo-release-minimal | gentoo-release-universal) +- case ${clst_mainarch} in ++ case ${clst_hostarch} in + amd64|x86) + sed -i 's/initramfs_data.cpio.gz /initramfs_data.cpio.gz -r 1024x768 /' /usr/share/genkernel/genkernel + ;; +@@ -32,14 +32,14 @@ + sed -e "s/@@MYDATE@@/${clst_netboot2_builddate}/g" \ + -e "s/@@RELVER@@/${clst_version_stamp}/g" \ + ${clst_root_path}usr/share/genkernel/netboot/linuxrc.x \ +- > ${clst_root_path}usr/share/genkernel/${clst_mainarch}/linuxrc ++ > ${clst_root_path}usr/share/genkernel/${clst_hostarch}/linuxrc + + echo ">>> Copying support files to ${clst_root_path} ..." + cp -pPRf ${clst_root_path}usr/share/genkernel/netboot/misc/* \ + ${clst_merge_path} + + echo ">>> Copying busybox config ..." +- cp -f ${clst_root_path}usr/share/genkernel/${clst_mainarch}/nb-busybox.cf \ +- ${clst_root_path}usr/share/genkernel/${clst_mainarch}/busy-config ++ cp -f ${clst_root_path}usr/share/genkernel/${clst_hostarch}/nb-busybox.cf \ ++ ${clst_root_path}usr/share/genkernel/${clst_hostarch}/busy-config + ;; + esac +Index: arch/hppa.py +=================================================================== +--- arch/hppa.py (revision 1203) ++++ arch/hppa.py (working copy) +@@ -7,7 +7,6 @@ + "Abstract base class for all hppa builders" + def __init__(self,myspec): + builder.generic.__init__(self,myspec) +- self.settings["mainarch"]="hppa" + self.settings["CHROOT"]="chroot" + self.settings["CFLAGS"]="-O2 -pipe" + self.settings["CXXFLAGS"]="-O2 -pipe" +Index: arch/mips.py +=================================================================== +--- arch/mips.py (revision 1203) ++++ arch/mips.py (working copy) +@@ -7,7 +7,6 @@ + "Abstract base class for all mips builders [Big-endian]" + def __init__(self,myspec): + builder.generic.__init__(self,myspec) +- self.settings["mainarch"]="mips" + self.settings["CHROOT"]="chroot" + self.settings["CHOST"]="mips-unknown-linux-gnu" + +@@ -15,7 +14,6 @@ + "Abstract base class for all mipsel builders [Little-endian]" + def __init__(self,myspec): + builder.generic.__init__(self,myspec) +- self.settings["mainarch"]="mips" + self.settings["CHROOT"]="chroot" + self.settings["CHOST"]="mipsel-unknown-linux-gnu" + +Index: arch/sparc.py +=================================================================== +--- arch/sparc.py (revision 1203) ++++ arch/sparc.py (working copy) +@@ -7,11 +7,11 @@ + "abstract base class for all sparc builders" + def __init__(self,myspec): + builder.generic.__init__(self,myspec) +- self.settings["mainarch"]="sparc" +- if self.settings["hostarch"]=="sparc64": ++ if self.settings["buildarch"]=="sparc64": + if not os.path.exists("/bin/linux32"): + raise CatalystError,"required /bin/linux32 executable not found (\"emerge setarch\" to fix.)" + self.settings["CHROOT"]="linux32 chroot" ++ self.settings["crosscompile"] = False; + else: + self.settings["CHROOT"]="chroot" + +Index: arch/sh.py +=================================================================== +--- arch/sh.py (revision 1203) ++++ arch/sh.py (working copy) +@@ -7,14 +7,12 @@ + "Abstract base class for all sh builders [Little-endian]" + def __init__(self,myspec): + builder.generic.__init__(self,myspec) +- self.settings["mainarch"]="sh" + self.settings["CHROOT"]="chroot" + + class generic_sheb(builder.generic): + "Abstract base class for all sheb builders [Big-endian]" + def __init__(self,myspec): + builder.generic.__init__(self,myspec) +- self.settings["mainarch"]="sh" + self.settings["CHROOT"]="chroot" + + class arch_sh(generic_sh): +Index: arch/amd64.py +=================================================================== +--- arch/amd64.py (revision 1203) ++++ arch/amd64.py (working copy) +@@ -6,7 +6,6 @@ + "abstract base class for all amd64 builders" + def __init__(self,myspec): + builder.generic.__init__(self,myspec) +- self.settings["mainarch"]="amd64" + self.settings["CHROOT"]="chroot" + + class arch_amd64(generic_amd64): +Index: arch/ppc64.py +=================================================================== +--- arch/ppc64.py (revision 1203) ++++ arch/ppc64.py (working copy) +@@ -6,7 +6,6 @@ + "abstract base class for all ppc64 builders" + def __init__(self,myspec): + builder.generic.__init__(self,myspec) +- self.settings["mainarch"]="ppc64" + self.settings["CHROOT"]="chroot" + + class arch_ppc64(generic_ppc64): +Index: arch/s390.py +=================================================================== +--- arch/s390.py (revision 1203) ++++ arch/s390.py (working copy) +@@ -7,7 +7,6 @@ + "abstract base class for all s390 builders" + def __init__(self,myspec): + builder.generic.__init__(self,myspec) +- self.settings["mainarch"]="s390" + self.settings["CHROOT"]="chroot" + + class arch_s390(generic_s390): +Index: arch/arm.py +=================================================================== +--- arch/arm.py (revision 1203) ++++ arch/arm.py (working copy) +@@ -7,7 +7,6 @@ + "Abstract base class for all arm (little endian) builders" + def __init__(self,myspec): + builder.generic.__init__(self,myspec) +- self.settings["mainarch"]="arm" + self.settings["CHROOT"]="chroot" + self.settings["CFLAGS"]="-O2 -pipe" + self.settings["CXXFLAGS"]="-O1 -pipe" +@@ -16,7 +15,6 @@ + "Abstract base class for all arm (big endian) builders" + def __init__(self,myspec): + builder.generic.__init__(self,myspec) +- self.settings["mainarch"]="arm" + self.settings["CHROOT"]="chroot" + self.settings["CFLAGS"]="-O2 -pipe" + self.settings["CXXFLAGS"]="-O1 -pipe" +Index: arch/ppc.py +=================================================================== +--- arch/ppc.py (revision 1203) ++++ arch/ppc.py (working copy) +@@ -12,12 +12,12 @@ + "abstract base class for all ppc builders" + def __init__(self,myspec): + builder.generic.__init__(self,myspec) +- self.settings["mainarch"]="ppc" + self.settings["CHOST"]="powerpc-unknown-linux-gnu" +- if self.settings["hostarch"]=="ppc64": ++ if self.settings["buildarch"]=="ppc64": + if not os.path.exists("/bin/linux32"): + raise CatalystError,"required /bin/linux32 executable not found (\"emerge setarch\" to fix." + self.settings["CHROOT"]="linux32 chroot" ++ self.settings["crosscompile"] = False; + else: + self.settings["CHROOT"]="chroot" + +Index: arch/sparc64.py +=================================================================== +--- arch/sparc64.py (revision 1203) ++++ arch/sparc64.py (working copy) +@@ -7,7 +7,6 @@ + "abstract base class for all sparc64 builders" + def __init__(self,myspec): + builder.generic.__init__(self,myspec) +- self.settings["mainarch"]="sparc64" + self.settings["CHROOT"]="chroot" + + class arch_sparc64(generic_sparc64): +Index: arch/ia64.py +=================================================================== +--- arch/ia64.py (revision 1203) ++++ arch/ia64.py (working copy) +@@ -7,7 +7,6 @@ + "builder class for ia64" + def __init__(self,myspec): + builder.generic.__init__(self,myspec) +- self.settings["mainarch"]="ia64" + self.settings["CHROOT"]="chroot" + self.settings["CFLAGS"]="-O2 -pipe" + self.settings["CFLAGS"]="-O2 -pipe" +Index: arch/alpha.py +=================================================================== +--- arch/alpha.py (revision 1203) ++++ arch/alpha.py (working copy) +@@ -7,7 +7,6 @@ + "abstract base class for all alpha builders" + def __init__(self,myspec): + builder.generic.__init__(self,myspec) +- self.settings["mainarch"]="alpha" + self.settings["CHROOT"]="chroot" + self.settings["CFLAGS"]="-mieee -pipe" + +Index: arch/x86.py +=================================================================== +--- arch/x86.py (revision 1203) ++++ arch/x86.py (working copy) +@@ -7,11 +7,11 @@ + "abstract base class for all x86 builders" + def __init__(self,myspec): + builder.generic.__init__(self,myspec) +- self.settings["mainarch"]="x86" +- if self.settings["hostarch"]=="amd64": ++ if self.settings["buildarch"]=="amd64": + if not os.path.exists("/bin/linux32"): + raise CatalystError,"required /bin/linux32 executable not found (\"emerge setarch\" to fix.)" + self.settings["CHROOT"]="linux32 chroot" ++ self.settings["crosscompile"] = False; + else: + self.settings["CHROOT"]="chroot" + diff --git a/catalyst-export-bools.patch b/catalyst-export-bools.patch new file mode 100644 index 0000000..820e632 --- /dev/null +++ b/catalyst-export-bools.patch @@ -0,0 +1,26 @@ +Index: modules/generic_stage_target.py +=================================================================== +--- modules/generic_stage_target.py (revision 1224) ++++ modules/generic_stage_target.py (working copy) +@@ -1056,8 +1066,7 @@ + # fixed. We need this to use the os.system() call since we can't + # specify our own environ: + for x in self.settings.keys(): +- # "/" is replaced with "_", "-" is replaced with "_", and "." is +- # replaced with "_" ++ # sanitize var names by doing "s|/-.|_|g" + varname="clst_"+string.replace(x,"/","_") + varname=string.replace(varname,"-","_") + varname=string.replace(varname,".","_") +@@ -1068,6 +1077,11 @@ + elif type(self.settings[x])==types.ListType: + #os.environ[varname]=string.join(self.settings[x]) + self.env[varname]=string.join(self.settings[x]) ++ elif type(self.settings[x])==types.BooleanType: ++ if self.settings[x]: ++ self.env[varname]="true" ++ else: ++ self.env[varname]="false" + if self.settings.has_key("makeopts"): + self.env["MAKEOPTS"]=self.settings["makeopts"] + diff --git a/catalyst-relative-paths.patch b/catalyst-relative-paths.patch new file mode 100644 index 0000000..6eac95b --- /dev/null +++ b/catalyst-relative-paths.patch @@ -0,0 +1,200 @@ +Index: catalyst +=================================================================== +--- catalyst (revision 1234) ++++ catalyst (working copy) +@@ -91,6 +91,10 @@ + print "Setting",x,"to default value \""+confdefaults[x]+"\"" + conf_values[x]=confdefaults[x] + ++ # use local stuff if we're running out of a svn dir ++ if os.path.isdir(os.path.join(os.path.dirname(sys.argv[0]), ".svn")): ++ conf_values["sharedir"] = os.path.dirname(sys.argv[0]); ++ + # parse out the rest of the options from the config file + if "autoresume" in string.split(conf_values["options"]): + print "Autoresuming support enabled." +Index: targets/stage1/stage1-preclean-chroot.sh +=================================================================== +--- targets/stage1/stage1-preclean-chroot.sh (revision 1234) ++++ targets/stage1/stage1-preclean-chroot.sh (working copy) +@@ -1,6 +1,6 @@ + #!/bin/bash + +-. /tmp/chroot-functions.sh ++. ./tmp/chroot-functions.sh + + # Now, some finishing touches to initialize gcc-config.... + unset ROOT +@@ -9,12 +9,12 @@ + setup_binutils + + # Stage1 is not going to have anything in zoneinfo, so save our Factory timezone +-if [ -d /usr/share/zoneinfo ] ++if [ -d ./usr/share/zoneinfo ] + then +- rm -f /etc/localtime +- cp /usr/share/zoneinfo/Factory /etc/localtime ++ rm -f ./etc/localtime ++ cp ./usr/share/zoneinfo/Factory ./etc/localtime + else +- echo UTC > /etc/TZ ++ echo UTC > ./etc/TZ + fi + + #if [ -n "${clst_CCACHE}" ] +Index: targets/stage1/stage1-chroot.sh +=================================================================== +--- targets/stage1/stage1-chroot.sh (revision 1234) ++++ targets/stage1/stage1-chroot.sh (working copy) +@@ -1,13 +1,15 @@ + #!/bin/bash + +-. /tmp/chroot-functions.sh ++. ./tmp/chroot-functions.sh + ++set -x ++ + update_env_settings + + setup_myfeatures + + # Setup our environment +-export clst_buildpkgs="$(/tmp/build.py)" ++export clst_buildpkgs="$(./tmp/build.py)" + export STAGE1_USE="$(portageq envvar STAGE1_USE)" + export USE="-* build ${STAGE1_USE}" + export FEATURES="${clst_myfeatures} nodoc noman noinfo" +@@ -25,7 +27,7 @@ + clst_root_path=/ setup_portage + + run_emerge "--noreplace --oneshot ${clst_buildpkgs}" +-rm -f /var/lib/portage/world +-touch /var/lib/portage/world ++rm -f ./var/lib/portage/world ++touch ./var/lib/portage/world + +-rm -f /var/log/emerge.log ++rm -f ./var/log/emerge.log +Index: targets/support/functions.sh +=================================================================== +--- targets/support/functions.sh (revision 1234) ++++ targets/support/functions.sh (working copy) +@@ -9,7 +9,7 @@ + chmod 755 ${dest_dir}/${file_name} + else + echo "copying ${file_name} to ${clst_chroot_path}/tmp" +- mkdir -p ${chroot_path}/tmp ++ mkdir -p ${clst_chroot_path}/tmp + cp -pPR ${1} ${clst_chroot_path}/tmp + chmod 755 ${clst_chroot_path}/tmp/${file_name} + fi +@@ -36,15 +36,31 @@ + chroot_path=${clst_chroot_path}${subdir} + copy_to_chroot ${clst_sharedir}/targets/support/chroot-functions.sh \ + ${subdir}/tmp/ +- echo "Running ${file_name} in chroot ${chroot_path}" +- ${clst_CHROOT} ${chroot_path} /tmp/${file_name} || exit 1 ++ echo "Running ${file_name} in chroot ${chroot_path}" ++ if ${clst_crosscompile} ; then ++ pushd ${chroot_path} > /dev/null || exit 1 ++ export CFLAGS="$(portageq envvar CFLAGS) --sysroot=${chroot_path}" ++ export CPPFLAGS="$(portageq envvar CPPFLAGS) --sysroot=${chroot_path}" ++ ROOT=${chroot_path} ./tmp/${file_name} || exit 1 ++ popd > /dev/null ++ else ++ ${clst_CHROOT} ${chroot_path} /tmp/${file_name} || exit 1 ++ fi + else + copy_to_chroot ${1} tmp/ + chroot_path=${clst_chroot_path} + copy_to_chroot ${clst_sharedir}/targets/support/chroot-functions.sh \ + tmp/ + echo "Running ${file_name} in chroot ${chroot_path}" +- ${clst_CHROOT} ${chroot_path}/ /tmp/${file_name} || exit 1 ++ if ${clst_crosscompile} ; then ++ pushd ${chroot_path} > /dev/null || exit 1 ++ export CFLAGS="$(portageq envvar CFLAGS) --sysroot=${chroot_path}" ++ export CPPFLAGS="$(portageq envvar CPPFLAGS) --sysroot=${chroot_path}" ++ ROOT=${chroot_path} ./tmp/${file_name} || exit 1 ++ popd > /dev/null ++ else ++ ${clst_CHROOT} ${chroot_path}/ /tmp/${file_name} || exit 1 ++ fi + fi + + rm -f ${chroot_path}/tmp/${file_name} +@@ -217,6 +233,4 @@ + esac + } + +-run_crossdev() { +- crossdev ${clst_CHOST} +-} ++. ${clst_sharedir}/targets/support/cross-functions.sh +Index: targets/support/chroot-functions.sh +=================================================================== +--- targets/support/chroot-functions.sh (revision 1234) ++++ targets/support/chroot-functions.sh (working copy) +@@ -96,9 +96,9 @@ + } + + setup_gcc(){ +- if [ -x /usr/bin/gcc-config ] ++ if [ -x ./usr/bin/gcc-config ] + then +- mythang=$( cd /etc/env.d/gcc; ls ${clst_CHOST}-* | head -n 1 ) ++ mythang=$( cd ./etc/env.d/gcc; ls ${clst_CHOST}-* | head -n 1 ) + if [ -z "${mythang}" ] + then + mythang=1 +@@ -108,9 +108,9 @@ + } + + setup_binutils(){ +- if [ -x /usr/bin/binutils-config ] ++ if [ -x ./usr/bin/binutils-config ] + then +- mythang=$( cd /etc/env.d/binutils; ls ${clst_CHOST}-* | head -n 1 ) ++ mythang=$( cd ./etc/env.d/binutils; ls ${clst_CHOST}-* | head -n 1 ) + if [ -z "${mythang}" ] + then + mythang=1 +@@ -120,31 +120,24 @@ + } + + cleanup_distcc() { +- rm -rf /etc/distcc/hosts ++ rm -rf ./etc/distcc/hosts + } + + update_env_settings(){ + /usr/sbin/env-update +- source /etc/profile +- [ -f /tmp/envscript ] && source /tmp/envscript ++ ${clst_crosscompile} || source /etc/profile ++ [ -f ./tmp/envscript ] && source ./tmp/envscript + } + + die() { +- echo "$1" ++ echo "$*" + exit 1 + } + + make_destpath() { +- if [ "${1}" = "" ] +- then +- export ROOT=/ +- else +- export ROOT=${1} +- if [ ! -d ${ROOT} ] +- then +- install -d ${ROOT} +- fi +- fi ++ export ROOT=${1:-/} ++ ${clst_crosscompile} && export ROOT=${clst_chroot_path}${ROOT} ++ [ ! -d ${ROOT} ] && install -d ${ROOT} + } + + run_emerge() { diff --git a/catalyst-s390x.patch b/catalyst-s390x.patch new file mode 100644 index 0000000..b8dcfa3 --- /dev/null +++ b/catalyst-s390x.patch @@ -0,0 +1,32 @@ +Index: arch/s390.py +=================================================================== +--- arch/s390.py (revision 1224) ++++ arch/s390.py (working copy) +@@ -8,6 +8,12 @@ class generic_s390(builder.generic): + builder.generic.__init__(self,myspec) + self.settings["CHROOT"]="chroot" + ++class generic_s390x(builder.generic): ++ "abstract base class for all s390x builders" ++ def __init__(self,myspec): ++ builder.generic.__init__(self,myspec) ++ self.settings["CHROOT"]="chroot" ++ + class arch_s390(generic_s390): + "builder class for generic s390" + def __init__(self,myspec): +@@ -15,6 +21,13 @@ class arch_s390(generic_s390): + self.settings["CFLAGS"]="-O2 -pipe" + self.settings["CHOST"]="s390-ibm-linux-gnu" + ++class arch_s390x(generic_s390x): ++ "builder class for generic s390x" ++ def __init__(self,myspec): ++ generic_s390.__init__(self,myspec) ++ self.settings["CFLAGS"]="-O2 -pipe" ++ self.settings["CHOST"]="s390x-ibm-linux-gnu" ++ + def register(): + "Inform main catalyst program of the contents of this plugin." +- return ({"s390":arch_s390}, ("s390", )) ++ return ({"s390":arch_s390,"s390x":arch_s390x}, ("s390", "s390x")) diff --git a/catalyst-sparc-setarch.patch b/catalyst-sparc-setarch.patch new file mode 100644 index 0000000..dbd22a9 --- /dev/null +++ b/catalyst-sparc-setarch.patch @@ -0,0 +1,20 @@ +Index: arch/sparc.py +=================================================================== +RCS file: /var/cvsroot/gentoo/src/catalyst/arch/sparc.py,v +retrieving revision 1.9 +diff -u -p -r1.9 sparc.py +--- arch/sparc.py 2 Oct 2006 20:41:53 -0000 1.9 ++++ arch/sparc.py 24 Dec 2006 11:30:39 -0000 +@@ -9,9 +9,9 @@ class generic_sparc(builder.generic): + builder.generic.__init__(self,myspec) + self.settings["mainarch"]="sparc" + if self.settings["hostarch"]=="sparc64": +- if not os.path.exists("/bin/sparc32"): +- raise CatalystError,"required /bin/sparc32 executable not found (\"emerge sparc-utils\" to fix.)" +- self.settings["CHROOT"]="/bin/sparc32 chroot" ++ if not os.path.exists("/bin/linux32"): ++ raise CatalystError,"required /bin/linux32 executable not found (\"emerge setarch\" to fix.)" ++ self.settings["CHROOT"]="linux32 chroot" + else: + self.settings["CHROOT"]="chroot" + diff --git a/catalyst-use-subarch.patch b/catalyst-use-subarch.patch new file mode 100644 index 0000000..00bb58b --- /dev/null +++ b/catalyst-use-subarch.patch @@ -0,0 +1,24 @@ +Index: modules/generic_stage_target.py +=================================================================== +--- modules/generic_stage_target.py (revision 1206) ++++ modules/generic_stage_target.py (working copy) +@@ -57,11 +57,14 @@ class generic_stage_target(generic_targe + + if self.settings.has_key("chost"): + hostmachine = self.settings["chost"].split("-")[0] +- else: +- hostmachine = os.uname()[4] +- if not machinemap.has_key(hostmachine): +- raise CatalystError, "Unknown host machine type "+hostmachine +- self.settings["hostarch"] = machinemap[hostmachine] ++ if not machinemap.has_key(hostmachine): ++ raise CatalystError, "Unknown host machine type "+hostmachine ++ self.settings["hostarch"] = machinemap[hostmachine] ++ else: ++ hostmachine = self.settings["subarch"] ++ if machinemap.has_key(hostmachine): ++ hostmachine = machinemap[hostmachine] ++ self.settings["hostarch"] = hostmachine + if self.settings.has_key("cbuild"): + buildmachine = self.settings["cbuild"].split("-")[0] + else: diff --git a/catalyst-verbose.patch b/catalyst-verbose.patch new file mode 100644 index 0000000..9fa814b --- /dev/null +++ b/catalyst-verbose.patch @@ -0,0 +1,111 @@ +Index: catalyst +=================================================================== +RCS file: /var/cvsroot/gentoo/src/catalyst/catalyst,v +retrieving revision 1.162 +diff -u -p -r1.162 catalyst +--- catalyst 2 Oct 2006 20:41:53 -0000 1.162 ++++ catalyst 24 Dec 2006 11:19:10 -0000 +@@ -86,51 +86,65 @@ def parse_config(myconfig): + # now, load up the values into conf_values so that we can use them + for x in confdefaults.keys(): + if myconf.has_key(x): +- print "Setting",x,"to config file value \""+myconf[x]+"\"" ++ if verbose: ++ print "Setting",x,"to config file value \""+myconf[x]+"\"" + conf_values[x]=myconf[x] + else: +- print "Setting",x,"to default value \""+confdefaults[x]+"\"" ++ if verbose: ++ print "Setting",x,"to default value \""+confdefaults[x]+"\"" + conf_values[x]=confdefaults[x] + ++ conf_values["sharedir"] = "/usr/local/gentoo/src/catalyst" ++ + # parse out the rest of the options from the config file + if "ccache" in string.split(conf_values["options"]): +- print "Compiler cache support enabled." ++ if verbose: ++ print "Compiler cache support enabled." + conf_values["CCACHE"]="1" + + if "pkgcache" in string.split(conf_values["options"]): +- print "Package cache support enabled." ++ if verbose: ++ print "Package cache support enabled." + conf_values["PKGCACHE"]="1" + + if "snapcache" in string.split(conf_values["options"]): +- print "Snapshot cache support enabled." ++ if verbose: ++ print "Snapshot cache support enabled." + conf_values["SNAPCACHE"]="1" + + if "seedcache" in string.split(conf_values["options"]): +- print "Seed cache support enabled." ++ if verbose: ++ print "Seed cache support enabled." + conf_values["SEEDCACHE"]="1" + + if "kerncache" in string.split(conf_values["options"]): +- print "Kernel cache support enabled." ++ if verbose: ++ print "Kernel cache support enabled." + conf_values["KERNCACHE"]="1" + + if "distcc" in string.split(conf_values["options"]): +- print "Distcc support enabled." ++ if verbose: ++ print "Distcc support enabled." + conf_values["DISTCC"]="1" + + if "autoresume" in string.split(conf_values["options"]): +- print "Autoresuming support enabled." ++ if verbose: ++ print "Autoresuming support enabled." + conf_values["AUTORESUME"]="1" + + if "purge" in string.split(conf_values["options"]): +- print "Purge support enabled." ++ if verbose: ++ print "Purge support enabled." + conf_values["PURGE"]="1" + + if "clear-autoresume" in string.split(conf_values["options"]): +- print "Cleaning autoresume flags support enabled." ++ if verbose: ++ print "Cleaning autoresume flags support enabled." + conf_values["CLEAR_AUTORESUME"]="1" + + if myconf.has_key("envscript"): +- print "Envscript support enabled." ++ if verbose: ++ print "Envscript support enabled." + conf_values["ENVSCRIPT"]=myconf["envscript"] + + if myconf.has_key("digests"): +@@ -200,7 +214,6 @@ def build_target(addlargs, targetmap): + if __name__ == "__main__": + targetmap={} + +- version() + if os.getuid() != 0: + # catalyst cannot be run as a normal user due to chroots, mounts, etc + print "!!! catalyst: This script requires root privileges to operate" +@@ -280,6 +293,7 @@ if __name__ == "__main__": + conf_values["FETCH"]="1" + + if o in ("-v", "--verbose"): ++ verbose = True + if len(sys.argv) < 3: + print "!!! catalyst: please specify one of either -f or -C\n" + usage() +@@ -316,6 +330,9 @@ if __name__ == "__main__": + usage() + sys.exit(2) + ++ if verbose: ++ version() ++ + # import configuration file and import our main module using those settings + parse_config(myconfig) + sys.path.append(conf_values["sharedir"]+"/modules") diff --git a/check-cross-compile-mkimage.patch b/check-cross-compile-mkimage.patch new file mode 100644 index 0000000..17101db --- /dev/null +++ b/check-cross-compile-mkimage.patch @@ -0,0 +1,24 @@ +diff --git a/scripts/mkuboot.sh b/scripts/mkuboot.sh +index 52a17ab..4b06c5e 100755 +--- a/scripts/mkuboot.sh ++++ b/scripts/mkuboot.sh +@@ -4,12 +4,15 @@ + # Build U-Boot image when `mkimage' tool is available. + # + +-MKIMAGE=$(type -path mkimage) ++MKIMAGE=$(type -path ${CROSS_COMPILE}mkimage) + + if [ -z "${MKIMAGE}" ]; then +- # Doesn't exist +- echo '"mkimage" command not found - U-Boot images will not be built' >&2 +- exit 0; ++ MKIMAGE=$(type -path mkimage) ++ if [ -z "${MKIMAGE}" ]; then ++ # Doesn't exist ++ echo '"mkimage" command not found - U-Boot images will not be built' >&2 ++ exit 0; ++ fi + fi + + # Call "mkimage" to create U-Boot image diff --git a/cmake-utils.eclass.patch b/cmake-utils.eclass.patch new file mode 100644 index 0000000..131e8d2 --- /dev/null +++ b/cmake-utils.eclass.patch @@ -0,0 +1,27 @@ +--- cmake-utils.eclass 28 Sep 2008 18:52:16 -0000 1.10 ++++ cmake-utils.eclass 27 Oct 2008 05:36:02 -0000 1.12 +@@ -85,6 +85,10 @@ cmake-utils_has() { _use_me_now HAVE "$@ + cmake-utils_src_configure() { + debug-print-function $FUNCNAME $* + ++ if ! has debug ${IUSE//+} || ! use debug ; then ++ append-cppflags -DNDEBUG ++ fi ++ + if [[ -n "${CMAKE_IN_SOURCE_BUILD}" ]]; then + cmake-utils_src_configurein + else +@@ -141,11 +145,8 @@ cmake-utils_src_configureout() { + # Internal use only. Common configuration options for all types of builds. + _common_configure_code() { + local tmp_libdir=$(get_libdir) +- if has debug ${IUSE//+} && use debug; then +- echo -DCMAKE_BUILD_TYPE=Debug +- else +- echo -DCMAKE_BUILD_TYPE=Release +- fi ++ # CMAKE_BUILD_TYPE only modifies compiler flags, so set to None ++ echo -DCMAKE_BUILD_TYPE=None + echo -DCMAKE_C_COMPILER=$(type -P $(tc-getCC)) + echo -DCMAKE_CXX_COMPILER=$(type -P $(tc-getCXX)) + echo -DCMAKE_INSTALL_PREFIX=${PREFIX:-/usr} diff --git a/coreutils-dircolors-cons25.patch b/coreutils-dircolors-cons25.patch new file mode 100644 index 0000000..11d4827 --- /dev/null +++ b/coreutils-dircolors-cons25.patch @@ -0,0 +1,14 @@ +2007-01-04 Mike Frysinger + + * src/dircolors.hin: Add a TERM directive for cons25. + +--- src/dircolors.hin 27 Nov 2006 10:57:18 -0000 1.25 ++++ src/dircolors.hin 4 Jan 2007 22:04:06 -0000 +@@ -23,6 +23,7 @@ TERM con80x30 + TERM con80x43 + TERM con80x50 + TERM con80x60 ++TERM cons25 + TERM console + TERM cygwin + TERM dtterm diff --git a/coreutils-dircolors-gnome-256color.patch b/coreutils-dircolors-gnome-256color.patch new file mode 100644 index 0000000..56de789 --- /dev/null +++ b/coreutils-dircolors-gnome-256color.patch @@ -0,0 +1,16 @@ +2007-02-04 Mike Frysinger + + * src/dircolors.hin: Add a TERM directive for gnome-256color. + +diff --git a/src/dircolors.hin b/src/dircolors.hin +index 8d550d1..395076e 100644 +--- a/src/dircolors.hin ++++ b/src/dircolors.hin +@@ -28,6 +28,7 @@ TERM console + TERM cygwin + TERM dtterm + TERM gnome ++TERM gnome-256color + TERM konsole + TERM kterm + TERM linux diff --git a/coreutils-more-dircolors.patch b/coreutils-more-dircolors.patch new file mode 100644 index 0000000..3c288bd --- /dev/null +++ b/coreutils-more-dircolors.patch @@ -0,0 +1,89 @@ +2006-11-26 Mike Frysinger + + * src/dircolors.hin: Add comments for common .sh and .csh scripts. + Add .bz2, .tbz2, .tz, .rar, .ace, .zoo, .cpio, .7z, .rz as archive + suffixes. Add .mng, .pcx, .m2v, .mkv, .ogm, .mp4, .m4v, .mp4v, .vob, + .qt, .nuv, .wmv, .asf, .rm, .rmvb, .flc, .yuv as image formats. + Add .aac, .au, .mid, .midi, .mka, .ra as audio suffixes. Change + audio color to 00;36 to differentiate from image/video color. + +--- src/dircolors.hin ++++ src/dircolors.hin +@@ -86,6 +86,10 @@ EXEC 01;32 + #.com 01;32 + #.btm 01;32 + #.bat 01;32 ++# Or if you want to colorize scripts even if they do not have the ++# executable bit actually set. ++#.sh 01;32 ++#.csh 01;32 + + .tar 01;31 # archives or compressed (bright red) + .tgz 01;31 +@@ -97,9 +101,18 @@ EXEC 01;32 + .Z 01;31 + .gz 01;31 + .bz2 01;31 ++.bz 01;31 ++.tbz2 01;31 ++.tz 01;31 + .deb 01;31 + .rpm 01;31 + .jar 01;31 ++.rar 01;31 ++.ace 01;31 ++.zoo 01;31 ++.cpio 01;31 ++.7z 01;31 ++.rz 01;31 + + # image formats + .jpg 01;35 +@@ -115,19 +128,42 @@ EXEC 01;32 + .tif 01;35 + .tiff 01;35 + .png 01;35 ++.mng 01;35 ++.pcx 01;35 + .mov 01;35 + .mpg 01;35 + .mpeg 01;35 ++.m2v 01;35 ++.mkv 01;35 ++.ogm 01;35 ++.mp4 01;35 ++.m4v 01;35 ++.mp4v 01;35 ++.vob 01;35 ++.qt 01;35 ++.nuv 01;35 ++.wmv 01;35 ++.asf 01;35 ++.rm 01;35 ++.rmvb 01;35 ++.flc 01;35 + .avi 01;35 + .fli 01;35 + .gl 01;35 + .dl 01;35 + .xcf 01;35 + .xwd 01;35 ++.yuv 01;35 + + # audio formats +-.flac 01;35 +-.mp3 01;35 +-.mpc 01;35 +-.ogg 01;35 +-.wav 01;35 ++.aac 00;36 ++.au 00;36 ++.flac 00;36 ++.mid 00;36 ++.midi 00;36 ++.mka 00;36 ++.mp3 00;36 ++.mpc 00;36 ++.ogg 00;36 ++.ra 00;36 ++.wav 00;36 diff --git a/coreutils-xattr.diff b/coreutils-xattr.diff new file mode 100644 index 0000000..1a9ac9f --- /dev/null +++ b/coreutils-xattr.diff @@ -0,0 +1,303 @@ +--- coreutils-6.2.orig/configure.ac ++++ coreutils-6.2/configure.ac +@@ -246,6 +246,9 @@ AC_CHECK_DECLS([strtoimax, strtoumax]) + + cu_LIB_CHECK + ++# Extended attribute copying. ++AC_FUNC_XATTR ++ + AM_GNU_GETTEXT([external], [need-formatstring-macros]) + AM_GNU_GETTEXT_VERSION([0.15]) + +--- /dev/null ++++ coreutils-6.2/m4/xattr.m4 +@@ -0,0 +1,38 @@ ++# xattr.m4 - check for Extended Attributes (Linux) ++ ++# Copyright (C) 2003 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ ++ ++# Written by Andreas Gruenbacher. ++ ++AC_DEFUN([AC_FUNC_XATTR], ++[ ++ AC_CHECK_HEADERS(attr/error_context.h attr/libattr.h) ++ if test "$ac_cv_header_attr_libattr_h" = yes \ ++ && test "$ac_cv_header_attr_error_context_h" = yes; then ++ use_xattr=1 ++ else ++ use_xattr=0 ++ fi ++ AC_DEFINE_UNQUOTED(USE_XATTR, $use_xattr, ++ [Define if you want extended attribute support.]) ++ xattr_saved_LIBS=$LIBS ++ AC_SEARCH_LIBS(attr_copy_file, attr, ++ [test "$ac_cv_search_attr_copy_file" = "none required" || LIB_XATTR=$ac_cv_search_attr_copy_file]) ++ AC_SUBST(LIB_XATTR) ++ AC_CHECK_FUNCS(attr_copy_file) ++ LIBS=$xattr_saved_LIBS ++]) +--- coreutils-6.2.orig/src/Makefile.am ++++ coreutils-6.2/src/Makefile.am +@@ -112,6 +112,10 @@ cp_LDADD += $(LIB_ACL) + mv_LDADD += $(LIB_ACL) + ginstall_LDADD += $(LIB_ACL) + ++cp_LDADD += $(LIB_XATTR) ++mv_LDADD += $(LIB_XATTR) ++ginstall_LDADD += $(LIB_XATTR) ++ + $(PROGRAMS): ../lib/libcoreutils.a + + SUFFIXES = .sh +--- coreutils-6.2.orig/src/copy.c ++++ coreutils-6.2/src/copy.c +@@ -53,6 +53,12 @@ + #include "xreadlink.h" + #include "yesno.h" + ++#if USE_XATTR ++# include ++# include ++# include ++#endif ++ + #ifndef HAVE_FCHOWN + # define HAVE_FCHOWN false + # define fchown(fd, uid, gid) (-1) +@@ -118,6 +124,98 @@ is_ancestor (const struct stat *sb, cons + return false; + } + ++#if USE_XATTR ++static void ++copy_xattr_error (struct error_context *ctx, const char *fmt, ...) ++{ ++ int err = errno; ++ va_list ap; ++ int len; ++ char *buffer; ++ ++ /* There is no error function that takes a va_list argument, ++ so we print the message in a buffer first. */ ++ ++ va_start (ap, fmt); ++ len = vsnprintf (NULL, 0, fmt, ap); ++ va_end (ap); ++ if (len > 0) ++ { ++ buffer = xmalloc (len + 1); ++ va_start (ap, fmt); ++ vsnprintf (buffer, len + 1, fmt, ap); ++ va_end (ap); ++ error (0, err, "%s", buffer); ++ free (buffer); ++ } ++} ++ ++static const char * ++copy_xattr_quote (struct error_context *ctx, const char *str) ++{ ++ return xstrdup (quote (str)); ++} ++ ++static void ++copy_xattr_free (struct error_context *ctx, const char *str) ++{ ++ free ((void *) str); ++} ++ ++struct copy_xattr_context { ++ struct error_context ctx; ++ struct cp_options *x; ++}; ++ ++static int ++copy_xattr_filter (const char *name, struct error_context *ctx) ++{ ++ struct copy_xattr_context *copy_ctx = (struct copy_xattr_context *) ctx; ++ int action; ++ ++ /* We handle POSIX ACLs separately. */ ++ if (!strcmp(name, "system.posix_acl_access") ++ || !strcmp(name, "system.posix_acl_default")) ++ return 0; ++ ++ action = attr_copy_action(name, ctx); ++ return (action != ATTR_ACTION_SKIP && ++ (!copy_ctx->x->preserve_mode ++ || action != ATTR_ACTION_PERMISSIONS)); ++} ++#endif /* USE_XATTR */ ++ ++static bool ++copy_xattrs (const char *src_path, int source_desc, const char *dst_path, ++ int dest_desc, const struct cp_options *x) ++{ ++ struct copy_xattr_context copy_xattr_ctx = { ++ { copy_xattr_error, ++ copy_xattr_quote, ++ copy_xattr_free }, ++ x ++ }; ++ ++#if USE_XATTR ++ if (x->preserve_xattrs) ++ { ++ int ret; ++ ++ if (source_desc != -1 && dest_desc != -1) ++ ret = attr_copy_fd(src_path, source_desc, dst_path, dest_desc, ++ copy_xattr_filter, ©_xattr_ctx.ctx); ++ else ++ ret = attr_copy_file (src_path, dst_path, ++ copy_xattr_filter, ©_xattr_ctx.ctx); ++ return ret == 0 || !x->require_preserve; ++ } ++ else ++ return true; ++#else /* USE_XATTR */ ++ return true; ++#endif /* USE_XATTR */ ++} ++ + /* Read the contents of the directory SRC_NAME_IN, and recursively + copy the contents to DST_NAME_IN. NEW_DST is true if + DST_NAME_IN is a directory that was created previously in the +@@ -509,6 +607,9 @@ copy_reg (char const *src_name, char con + } + } + ++ if (!copy_xattrs (src_name, source_desc, dst_name, dest_desc, x)) ++ return_val = false; ++ + set_author (dst_name, dest_desc, src_sb); + + if (x->preserve_mode || x->move_mode) +@@ -1755,6 +1856,9 @@ copy_internal (char const *src_name, cha + return false; + } + ++ if (!copy_xattrs (src_name, -1, dst_name, -1, x)) ++ delayed_ok = false; ++ + set_author (dst_name, -1, &src_sb); + + if (x->preserve_mode || x->move_mode) +--- coreutils-6.2.orig/src/copy.h ++++ coreutils-6.2/src/copy.h +@@ -128,6 +128,9 @@ struct cp_options + bool preserve_mode; + bool preserve_timestamps; + ++ /* If true, attempt to copy extended attributes. */ ++ bool preserve_xattrs; ++ + /* Enabled for mv, and for cp by the --preserve=links option. + If true, attempt to preserve in the destination files any + logical hard links between the source files. If used with cp's +--- coreutils-6.2.orig/src/cp.c ++++ coreutils-6.2/src/cp.c +@@ -191,7 +191,7 @@ Mandatory arguments to long options are + -p same as --preserve=mode,ownership,timestamps\n\ + --preserve[=ATTR_LIST] preserve the specified attributes (default:\n\ + mode,ownership,timestamps), if possible\n\ +- additional attributes: links, all\n\ ++ additional attributes: links, xattrs, all\n\ + "), stdout); + fputs (_("\ + --no-preserve=ATTR_LIST don't preserve the specified attributes\n\ +@@ -724,6 +724,7 @@ cp_option_init (struct cp_options *x) + x->preserve_links = false; + x->preserve_mode = false; + x->preserve_timestamps = false; ++ x->preserve_xattrs = false; + + x->require_preserve = false; + x->recursive = false; +@@ -752,18 +753,21 @@ decode_preserve_arg (char const *arg, st + PRESERVE_TIMESTAMPS, + PRESERVE_OWNERSHIP, + PRESERVE_LINK, ++ PRESERVE_XATTRS, + PRESERVE_ALL + }; + static enum File_attribute const preserve_vals[] = + { + PRESERVE_MODE, PRESERVE_TIMESTAMPS, +- PRESERVE_OWNERSHIP, PRESERVE_LINK, PRESERVE_ALL ++ PRESERVE_OWNERSHIP, PRESERVE_LINK, ++ PRESERVE_XATTRS, PRESERVE_ALL + }; + /* Valid arguments to the `--preserve' option. */ + static char const* const preserve_args[] = + { + "mode", "timestamps", +- "ownership", "links", "all", NULL ++ "ownership", "links", ++ "xattrs", "all", NULL + }; + ARGMATCH_VERIFY (preserve_args, preserve_vals); + +@@ -799,11 +803,16 @@ decode_preserve_arg (char const *arg, st + x->preserve_links = on_off; + break; + ++ case PRESERVE_XATTRS: ++ x->preserve_xattrs = on_off; ++ break; ++ + case PRESERVE_ALL: + x->preserve_mode = on_off; + x->preserve_timestamps = on_off; + x->preserve_ownership = on_off; + x->preserve_links = on_off; ++ x->preserve_xattrs = on_off; + break; + + default: +--- coreutils-6.2.orig/src/install.c ++++ coreutils-6.2/src/install.c +@@ -154,6 +154,7 @@ cp_option_init (struct cp_options *x) + x->preserve_links = false; + x->preserve_mode = false; + x->preserve_timestamps = false; ++ x->preserve_xattrs = false; + x->require_preserve = false; + x->recursive = false; + x->sparse_mode = SPARSE_AUTO; +--- coreutils-6.2.orig/src/mv.c ++++ coreutils-6.2/src/mv.c +@@ -125,6 +125,7 @@ cp_option_init (struct cp_options *x) + x->preserve_links = true; + x->preserve_mode = true; + x->preserve_timestamps = true; ++ x->preserve_xattrs = true; + x->require_preserve = false; /* FIXME: maybe make this an option */ + x->recursive = true; + x->sparse_mode = SPARSE_AUTO; /* FIXME: maybe make this an option */ +--- coreutils-6.2.orig/doc/coreutils.texi ++++ coreutils-6.2/doc/coreutils.texi +@@ -6948,6 +6948,8 @@ Preserve in the destination files + any links between corresponding source files. + @c Give examples illustrating how hard links are preserved. + @c Also, show how soft links map to hard links with -L and -H. ++@itemx xattrs ++Preserve extended attributes. (See /etc/xattr.conf.) + @itemx all + Preserve all file attributes. + Equivalent to specifying all of the above. diff --git a/coreutils-xattr.patch b/coreutils-xattr.patch new file mode 100644 index 0000000..c61f4eb --- /dev/null +++ b/coreutils-xattr.patch @@ -0,0 +1,313 @@ +--- coreutils-6.11/configure.ac ++++ coreutils-6.11/configure.ac +@@ -249,6 +249,9 @@ + AC_SUBST([CONFIG_STATUS_DEPENDENCIES]) + ############################################################################ + ++# Extended attribute copying. ++AC_FUNC_XATTR ++ + AM_GNU_GETTEXT([external], [need-formatstring-macros]) + AM_GNU_GETTEXT_VERSION([0.15]) + +--- coreutils-6.11/m4/xattr.m4 ++++ coreutils-6.11/m4/xattr.m4 +@@ -0,0 +1,44 @@ ++# xattr.m4 - check for Extended Attributes (Linux) ++ ++# Copyright (C) 2003 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ ++ ++# Written by Andreas Gruenbacher. ++ ++AC_DEFUN([AC_FUNC_XATTR], ++[ ++ AC_ARG_ENABLE(xattr, ++ [ --disable-xattr turn off support for extended attributes], ++ use_xattr=$enableval, use_xattr=yes) ++ ++ if test "$use_xattr" = "yes"; then ++ AC_CHECK_HEADERS(attr/error_context.h attr/libattr.h) ++ if test "$ac_cv_header_attr_libattr_h" = yes \ ++ && test "$ac_cv_header_attr_error_context_h" = yes; then ++ use_xattr=1 ++ else ++ use_xattr=0 ++ fi ++ AC_DEFINE_UNQUOTED(USE_XATTR, $use_xattr, ++ [Define if you want extended attribute support.]) ++ xattr_saved_LIBS=$LIBS ++ AC_SEARCH_LIBS(attr_copy_file, attr, ++ [test "$ac_cv_search_attr_copy_file" = "none required" || LIB_XATTR=$ac_cv_search_attr_copy_file]) ++ AC_SUBST(LIB_XATTR) ++ AC_CHECK_FUNCS(attr_copy_file) ++ LIBS=$xattr_saved_LIBS ++ fi ++]) +--- coreutils-6.11/src/copy.c ++++ coreutils-6.11/src/copy.c +@@ -53,6 +53,12 @@ + #include "areadlink.h" + #include "yesno.h" + ++#if USE_XATTR ++# include ++# include ++# include ++#endif ++ + #ifndef HAVE_FCHOWN + # define HAVE_FCHOWN false + # define fchown(fd, uid, gid) (-1) +@@ -118,6 +124,98 @@ is_ancestor (const struct stat *sb, cons + return false; + } + ++#if USE_XATTR ++static void ++copy_xattr_error (struct error_context *ctx, const char *fmt, ...) ++{ ++ int err = errno; ++ va_list ap; ++ int len; ++ char *buffer; ++ ++ /* There is no error function that takes a va_list argument, ++ so we print the message in a buffer first. */ ++ ++ va_start (ap, fmt); ++ len = vsnprintf (NULL, 0, fmt, ap); ++ va_end (ap); ++ if (len > 0) ++ { ++ buffer = xmalloc (len + 1); ++ va_start (ap, fmt); ++ vsnprintf (buffer, len + 1, fmt, ap); ++ va_end (ap); ++ error (0, err, "%s", buffer); ++ free (buffer); ++ } ++} ++ ++static const char * ++copy_xattr_quote (struct error_context *ctx, const char *str) ++{ ++ return xstrdup (quote (str)); ++} ++ ++static void ++copy_xattr_free (struct error_context *ctx, const char *str) ++{ ++ free ((void *) str); ++} ++ ++struct copy_xattr_context { ++ struct error_context ctx; ++ struct cp_options *x; ++}; ++ ++static int ++copy_xattr_filter (const char *name, struct error_context *ctx) ++{ ++ struct copy_xattr_context *copy_ctx = (struct copy_xattr_context *) ctx; ++ int action; ++ ++ /* We handle POSIX ACLs separately. */ ++ if (!strcmp(name, "system.posix_acl_access") ++ || !strcmp(name, "system.posix_acl_default")) ++ return 0; ++ ++ action = attr_copy_action(name, ctx); ++ return (action != ATTR_ACTION_SKIP && ++ (!copy_ctx->x->preserve_mode ++ || action != ATTR_ACTION_PERMISSIONS)); ++} ++#endif /* USE_XATTR */ ++ ++static bool ++copy_xattrs (const char *src_path, int source_desc, const char *dst_path, ++ int dest_desc, const struct cp_options *x) ++{ ++ struct copy_xattr_context copy_xattr_ctx = { ++ { copy_xattr_error, ++ copy_xattr_quote, ++ copy_xattr_free }, ++ x ++ }; ++ ++#if USE_XATTR ++ if (x->preserve_xattrs) ++ { ++ int ret; ++ ++ if (source_desc != -1 && dest_desc != -1) ++ ret = attr_copy_fd(src_path, source_desc, dst_path, dest_desc, ++ copy_xattr_filter, ©_xattr_ctx.ctx); ++ else ++ ret = attr_copy_file (src_path, dst_path, ++ copy_xattr_filter, ©_xattr_ctx.ctx); ++ return ret == 0 || !x->require_preserve; ++ } ++ else ++ return true; ++#else /* USE_XATTR */ ++ return true; ++#endif /* USE_XATTR */ ++} ++ + /* Read the contents of the directory SRC_NAME_IN, and recursively + copy the contents to DST_NAME_IN. NEW_DST is true if + DST_NAME_IN is a directory that was created previously in the +@@ -509,6 +607,9 @@ copy_reg (char const *src_name, char con + } + } + ++ if (!copy_xattrs (src_name, source_desc, dst_name, dest_desc, x)) ++ return_val = false; ++ + set_author (dst_name, dest_desc, src_sb); + + if (x->preserve_mode || x->move_mode) +@@ -1755,6 +1856,9 @@ copy_internal (char const *src_name, cha + } + } + ++ if (!copy_xattrs (src_name, -1, dst_name, -1, x)) ++ delayed_ok = false; ++ + set_author (dst_name, -1, &src_sb); + + if (x->preserve_mode || x->move_mode) +--- coreutils-6.11/src/copy.h ++++ coreutils-6.11/src/copy.h +@@ -128,6 +128,9 @@ struct cp_options + bool preserve_mode; + bool preserve_timestamps; + ++ /* If true, attempt to copy extended attributes. */ ++ bool preserve_xattrs; ++ + /* Enabled for mv, and for cp by the --preserve=links option. + If true, attempt to preserve in the destination files any + logical hard links between the source files. If used with cp's +--- coreutils-6.11/src/cp.c ++++ coreutils-6.11/src/cp.c +@@ -191,7 +191,7 @@ Mandatory arguments to long options are + -p same as --preserve=mode,ownership,timestamps\n\ + --preserve[=ATTR_LIST] preserve the specified attributes (default:\n\ + mode,ownership,timestamps), if possible\n\ +- additional attributes: context, links, all\n\ ++ additional attributes: context, links, xattrs, all\n\ + "), stdout); + fputs (_("\ + --no-preserve=ATTR_LIST don't preserve the specified attributes\n\ +@@ -724,6 +724,7 @@ cp_option_init (struct cp_options *x) + x->preserve_timestamps = false; + x->preserve_security_context = false; + x->require_preserve_context = false; ++ x->preserve_xattrs = false; + + x->require_preserve = false; + x->recursive = false; +@@ -752,18 +753,21 @@ decode_preserve_arg (char const *arg, st + PRESERVE_OWNERSHIP, + PRESERVE_LINK, + PRESERVE_CONTEXT, ++ PRESERVE_XATTRS, + PRESERVE_ALL + }; + static enum File_attribute const preserve_vals[] = + { + PRESERVE_MODE, PRESERVE_TIMESTAMPS, +- PRESERVE_OWNERSHIP, PRESERVE_LINK, PRESERVE_CONTEXT, PRESERVE_ALL ++ PRESERVE_OWNERSHIP, PRESERVE_LINK, PRESERVE_CONTEXT, ++ PRESERVE_XATTRS, PRESERVE_ALL + }; + /* Valid arguments to the `--preserve' option. */ + static char const* const preserve_args[] = + { + "mode", "timestamps", +- "ownership", "links", "context", "all", NULL ++ "ownership", "links", "context", ++ "xattrs", "all", NULL + }; + ARGMATCH_VERIFY (preserve_args, preserve_vals); + +@@ -799,13 +803,18 @@ decode_preserve_arg (char const *arg, st + x->require_preserve_context = on_off; + break; + ++ case PRESERVE_XATTRS: ++ x->preserve_xattrs = on_off; ++ break; ++ + case PRESERVE_ALL: + x->preserve_mode = on_off; + x->preserve_timestamps = on_off; + x->preserve_ownership = on_off; + x->preserve_links = on_off; + if (selinux_enabled) + x->preserve_security_context = on_off; ++ x->preserve_xattrs = on_off; + break; + + default: +--- coreutils-6.11/src/install.c ++++ coreutils-6.11/src/install.c +@@ -154,6 +154,7 @@ cp_option_init (struct cp_options *x) + x->preserve_links = false; + x->preserve_mode = false; + x->preserve_timestamps = false; ++ x->preserve_xattrs = false; + x->require_preserve = false; + x->require_preserve_context = false; + x->recursive = false; +--- coreutils-6.11/src/mv.c ++++ coreutils-6.11/src/mv.c +@@ -125,6 +125,7 @@ cp_option_init (struct cp_options *x) + x->preserve_mode = true; + x->preserve_timestamps = true; + x->preserve_security_context = selinux_enabled; ++ x->preserve_xattrs = true; + x->require_preserve = false; /* FIXME: maybe make this an option */ + x->require_preserve_context = false; + x->recursive = true; +--- coreutils-6.11/doc/coreutils.texi ++++ coreutils-6.11/doc/coreutils.texi +@@ -6948,6 +6948,8 @@ Preserve in the destination files + any links between corresponding source files. + @c Give examples illustrating how hard links are preserved. + @c Also, show how soft links map to hard links with -L and -H. ++@itemx xattrs ++Preserve extended attributes. (See /etc/xattr.conf.) + @itemx all + Preserve all file attributes. + Equivalent to specifying all of the above. +--- coreutils-6.11/src/Makefile.am ++++ coreutils-6.11/src/Makefile.am +@@ -107,9 +107,9 @@ + dir_LDADD += $(LIB_ACL) + ls_LDADD += $(LIB_ACL) + vdir_LDADD += $(LIB_ACL) +-cp_LDADD += $(LIB_ACL) +-mv_LDADD += $(LIB_ACL) +-ginstall_LDADD += $(LIB_ACL) ++cp_LDADD += $(LIB_ACL) $(LIB_XATTR) ++mv_LDADD += $(LIB_ACL) $(LIB_XATTR) ++ginstall_LDADD += $(LIB_ACL) $(LIB_XATTR) + + stat_LDADD = $(LDADD) $(LIB_SELINUX) + diff --git a/cracklib-libintl.patch b/cracklib-libintl.patch new file mode 100644 index 0000000..f706ff9 --- /dev/null +++ b/cracklib-libintl.patch @@ -0,0 +1,11 @@ +Index: lib/Makefile.am +=================================================================== +--- lib/Makefile.am (revision 87) ++++ lib/Makefile.am (working copy) +@@ -15,5 +15,6 @@ libcrack_la_SOURCES = fascist.c \ + # After that, follow the libtool recommended incrementing procedure + # + libcrack_la_LDFLAGS = -version-info 10:0:8 ++libcrack_la_LIBADD = $(LTLIBINTL) + + AM_CPPFLAGS = -I. -I.. -I$(top_srcdir)/lib -DIN_CRACKLIB '-DDEFAULT_CRACKLIB_DICT="$(DEFAULT_CRACKLIB_DICT)"' diff --git a/cryptsetup-1.0.6-svn-udev.patch b/cryptsetup-1.0.6-svn-udev.patch new file mode 100644 index 0000000..0b78632 --- /dev/null +++ b/cryptsetup-1.0.6-svn-udev.patch @@ -0,0 +1,328 @@ +Index: lib/setup.c +=================================================================== +--- lib/setup.c (revision 29) ++++ lib/setup.c (revision 32) +@@ -396,7 +396,7 @@ static int __crypt_remove_device(int arg + return -EBUSY; + } + +- return backend->remove(options); ++ return backend->remove(0, options); + } + + static int __crypt_luks_format(int arg, struct setup_backend *backend, struct crypt_options *options) +@@ -705,7 +705,10 @@ static int crypt_job(int (*job)(int arg, + + backend = get_setup_backend(default_backend); + +- setup_enter(backend,options->icb->log); ++ if (setup_enter(backend,options->icb->log) < 0) { ++ r = -ENOSYS; ++ goto out; ++ } + + if (!backend) { + set_error("No setup backend available"); +Index: lib/internal.h +=================================================================== +--- lib/internal.h (revision 29) ++++ lib/internal.h (revision 32) +@@ -40,7 +40,7 @@ struct setup_backend { + const char *key); + int (*status)(int details, struct crypt_options *options, + char **key); +- int (*remove)(struct crypt_options *options); ++ int (*remove)(int force, struct crypt_options *options); + + const char * (*dir)(void); + }; +Index: lib/libdevmapper.c +=================================================================== +--- lib/libdevmapper.c (revision 29) ++++ lib/libdevmapper.c (revision 32) +@@ -17,13 +17,7 @@ + #define DEVICE_DIR "/dev" + + #define CRYPT_TARGET "crypt" +- +-#define UDEVSETTLE "/sbin/udevsettle" +- +-static void run_udevsettle(void) +-{ +- system(UDEVSETTLE); +-} ++#define RETRY_COUNT 5 + + static void set_dm_error(int level, const char *file, int line, + const char *f, ...) +@@ -38,9 +32,16 @@ static void set_dm_error(int level, cons + va_end(va); + } + ++static int _dm_simple(int task, const char *name); ++ + static int dm_init(void) + { + dm_log_init(set_dm_error); ++ if (!_dm_simple(DM_DEVICE_LIST_VERSIONS, "test")) { ++ set_error("Cannot communicate with device-mapper. Is the dm_mod module loaded?"); ++ return -1; ++ } ++ + return 1; /* unsafe memory */ + } + +@@ -50,16 +51,6 @@ static void dm_exit(void) + dm_lib_release(); + } + +-static void flush_dm_workqueue(void) +-{ +- /* +- * Unfortunately this is the only way to trigger libdevmapper's +- * update_nodes function +- */ +- dm_exit(); +- dm_init(); +-} +- + static char *__lookup_dev(char *path, dev_t dev) + { + struct dirent *entry; +@@ -152,6 +143,89 @@ out: + return params; + } + ++/* DM helpers */ ++static int _dm_simple(int task, const char *name) ++{ ++ int r = 0; ++ struct dm_task *dmt; ++ ++ if (!(dmt = dm_task_create(task))) ++ return 0; ++ ++ if (!dm_task_set_name(dmt, name)) ++ goto out; ++ ++ r = dm_task_run(dmt); ++ ++ out: ++ dm_task_destroy(dmt); ++ return r; ++} ++ ++static int _error_device(struct crypt_options *options) ++{ ++ struct dm_task *dmt; ++ int r = 0; ++ ++ if (!(dmt = dm_task_create(DM_DEVICE_RELOAD))) ++ return 0; ++ ++ if (!dm_task_set_name(dmt, options->name)) ++ goto error; ++ ++ if (!dm_task_add_target(dmt, UINT64_C(0), options->size, "error", "")) ++ goto error; ++ ++ if (!dm_task_set_ro(dmt)) ++ goto error; ++ ++ if (!dm_task_no_open_count(dmt)) ++ goto error; ++ ++ if (!dm_task_run(dmt)) ++ goto error; ++ ++ if (!_dm_simple(DM_DEVICE_RESUME, options->name)) { ++ _dm_simple(DM_DEVICE_CLEAR, options->name); ++ goto error; ++ } ++ ++ r = 1; ++ ++error: ++ dm_task_destroy(dmt); ++ return r; ++} ++ ++static int _dm_remove(struct crypt_options *options, int force) ++{ ++ int r = -EINVAL; ++ int retries = force ? RETRY_COUNT : 1; ++ ++ /* If force flag is set, replace device with error, read-only target. ++ * it should stop processes from reading it and also removed underlying ++ * device from mapping, so it is usable again. ++ * Force flag should be used only for temporary devices, which are ++ * intended to work inside cryptsetup only! ++ * Anyway, if some process try to read temporary cryptsetup device, ++ * it is bug - no other process should try touch it (e.g. udev). ++ */ ++ if (force) { ++ _error_device(options); ++ retries = RETRY_COUNT; ++ } ++ ++ do { ++ r = _dm_simple(DM_DEVICE_REMOVE, options->name) ? 0 : -EINVAL; ++ if (--retries) ++ sleep(1); ++ } while (r == -EINVAL && retries); ++ ++ dm_task_update_nodes(); ++ ++ return r; ++} ++ + static int dm_create_device(int reload, struct crypt_options *options, + const char *key) + { +@@ -191,24 +265,14 @@ static int dm_create_device(int reload, + if (dmi.read_only) + options->flags |= CRYPT_FLAG_READONLY; + +- /* run udevsettle to avoid a race in libdevmapper causing busy dm devices */ +- run_udevsettle(); +- + r = 0; +- + out: + if (r < 0 && !reload) { + char *error = (char *)get_error(); + if (error) + error = strdup(error); +- if (dmt) +- dm_task_destroy(dmt); + +- if (!(dmt = dm_task_create(DM_DEVICE_REMOVE))) +- goto out_restore_error; +- if (!dm_task_set_name(dmt, options->name)) +- goto out_restore_error; +- if (!dm_task_run(dmt)) ++ if (!_dm_remove(options, 0)) + goto out_restore_error; + + out_restore_error: +@@ -224,7 +288,7 @@ out_no_removal: + dm_task_destroy(dmt); + if(dmt_query) + dm_task_destroy(dmt_query); +- flush_dm_workqueue(); ++ dm_task_update_nodes(); + return r; + } + +@@ -352,25 +416,12 @@ out: + return r; + } + +-static int dm_remove_device(struct crypt_options *options) ++static int dm_remove_device(int force, struct crypt_options *options) + { +- struct dm_task *dmt; +- int r = -EINVAL; +- +- if (!(dmt = dm_task_create(DM_DEVICE_REMOVE))) +- goto out; +- if (!dm_task_set_name(dmt, options->name)) +- goto out; +- if (!dm_task_run(dmt)) +- goto out; +- +- r = 0; ++ if (!options || !options->name) ++ return -EINVAL; + +-out: +- if (dmt) +- dm_task_destroy(dmt); +- flush_dm_workqueue(); +- return r; ++ return _dm_remove(options, force);; + } + + +Index: luks/keyencryption.c +=================================================================== +--- luks/keyencryption.c (revision 29) ++++ luks/keyencryption.c (revision 32) +@@ -45,6 +45,11 @@ static inline int round_up_modulo(int x, + return div_round_up(x, m) * m; + } + ++static struct setup_backend *cleaner_backend=NULL; ++static const char *cleaner_name=NULL; ++static uint64_t cleaner_size = 0; ++static int devfd=-1; ++ + static int setup_mapping(const char *cipher, const char *name, + const char *device, unsigned int payloadOffset, + const char *key, size_t keyLength, +@@ -52,7 +57,7 @@ static int setup_mapping(const char *cip + struct setup_backend *backend, + int mode) + { +- struct crypt_options k; ++ struct crypt_options k = {0}; + struct crypt_options *options = &k; + int device_sector_size = sector_size_for_device(device); + int r; +@@ -66,6 +71,7 @@ static int setup_mapping(const char *cip + return -EINVAL; + } + options->size = round_up_modulo(srcLength,device_sector_size)/SECTOR_SIZE; ++ cleaner_size = options->size; + + options->offset = sector; + options->cipher = cipher; +@@ -87,24 +93,21 @@ static int setup_mapping(const char *cip + return r; + } + +-static int clear_mapping(const char *name, struct setup_backend *backend) ++static int clear_mapping(const char *name, uint64_t size, struct setup_backend *backend) + { +- struct crypt_options options; ++ struct crypt_options options = {0}; + options.name=name; +- return backend->remove(&options); ++ options.size = size; ++ return backend->remove(1, &options); + } + +-/* I miss closures in C! */ +-static struct setup_backend *cleaner_backend=NULL; +-static const char *cleaner_name=NULL; +-static int devfd=0; +- + static void sigint_handler(int sig) + { +- if(devfd) ++ if(devfd >= 0) + close(devfd); ++ devfd = -1; + if(cleaner_backend && cleaner_name) +- clear_mapping(cleaner_name, cleaner_backend); ++ clear_mapping(cleaner_name, cleaner_size, cleaner_backend); + signal(SIGINT, SIG_DFL); + kill(getpid(), SIGINT); + } +@@ -160,13 +163,14 @@ static int LUKS_endec_template(char *src + r = 0; + out3: + close(devfd); +- devfd = 0; ++ devfd = -1; + out2: +- clear_mapping(name,backend); ++ clear_mapping(cleaner_name, cleaner_size, cleaner_backend); + out1: + signal(SIGINT, SIG_DFL); + cleaner_name = NULL; + cleaner_backend = NULL; ++ cleaner_size = 0; + free(dmCipherSpec); + free(fullpath); + free(name); diff --git a/darcs-add-missing-php-tag.patch b/darcs-add-missing-php-tag.patch new file mode 100644 index 0000000..c7f8941 --- /dev/null +++ b/darcs-add-missing-php-tag.patch @@ -0,0 +1,11 @@ +Fri May 25 17:40:00 EDT 2007 vapier@gentoo.org + * add-missing-php-tag-to-local.php.dist +diff -rN -u old-dokuwiki/conf/local.php.dist new-dokuwiki/conf/local.php.dist +--- old-dokuwiki/conf/local.php.dist 2007-05-25 22:32:48.000000000 -0400 ++++ new-dokuwiki/conf/local.php.dist 2007-05-25 22:32:48.000000000 -0400 +@@ -20,3 +20,4 @@ + //require_once ("mysql.conf.php"); + + ++?> + diff --git a/darcs-check-preg-match.patch b/darcs-check-preg-match.patch new file mode 100644 index 0000000..daa2baf --- /dev/null +++ b/darcs-check-preg-match.patch @@ -0,0 +1,33 @@ +--- old-dokuwiki/inc/parser/lexer.php 2007-05-25 17:39:03.000000000 -0400 ++++ new-dokuwiki/inc/parser/lexer.php 2007-05-25 17:39:03.000000000 -0400 +@@ -112,11 +112,16 @@ + return false; + } + +- if (! preg_match($this->_getCompoundedRegex(), $subject, $matches)) { ++ $match = preg_match($this->_getCompoundedRegex(), $subject, $matches); ++ if (is_bool($match) && $match == false) { ++ /* some problem occurred */ ++ return -1; ++ } else if ($match == 0) { + $split = array($subject, "", ""); + return false; + } + ++ + $idx = count($matches)-2; + + list($pre, $post) = preg_split($this->_patterns[$idx].$this->_getPerlMatchingFlags(), $subject, 2); +@@ -535,7 +540,10 @@ + if ($raw === "") { + return true; + } +- if ($action = $this->_regexes[$this->_mode->getCurrent()]->split($raw, $split)) { ++ $action = $this->_regexes[$this->_mode->getCurrent()]->split($raw, $split); ++ if (is_int($action) && $action == -1) ++ return false; ++ if ($action) { + list($unparsed, $match, $raw) = $split; + return array($unparsed, $match, $action); + } + diff --git a/darcs-world-read-email.patch b/darcs-world-read-email.patch new file mode 100644 index 0000000..f641afe --- /dev/null +++ b/darcs-world-read-email.patch @@ -0,0 +1,13 @@ +--- old-dokuwiki/inc/common.php 2006-12-24 20:18:41.000000000 -0500 ++++ new-dokuwiki/inc/common.php 2006-12-24 20:18:41.000000000 -0500 +@@ -824,6 +824,10 @@ + global $conf; + global $INFO; + ++ // Only send out notify mails if the page is world readable ++ if(auth_aclcheck($id,'','') == AUTH_NONE) ++ return; ++ + // decide if there is something to do + if($who == 'admin'){ + if(empty($conf['notify'])) return; //notify enabled? diff --git a/dcron-3.2-makefile.patch b/dcron-3.2-makefile.patch new file mode 100644 index 0000000..fcbc077 --- /dev/null +++ b/dcron-3.2-makefile.patch @@ -0,0 +1,27 @@ +--- Makefile ++++ Makefile +@@ -2,8 +2,8 @@ + # + + DESTDIR ?= /usr/local +-CC = gcc +-CFLAGS = -O2 -Wall -Wstrict-prototypes ++CC ?= gcc ++CFLAGS ?= -O2 -Wall -Wstrict-prototypes + LIB = + SRCS = main.c subs.c database.c job.c + OBJS = main.o subs.o database.o job.o +@@ -15,11 +15,11 @@ + all: ${PROTOS} crond crontab + + crond: ${OBJS} +- ${CC} ${CFLAGS} -o crond ${OBJS} ${LIB} ++ ${CC} ${CFLAGS} -o crond ${OBJS} ${LIB} ${LDFLAGS} + strip crond + + crontab: ${D_OBJS} +- ${CC} ${CFLAGS} -o crontab ${D_OBJS} ++ ${CC} ${CFLAGS} -o crontab ${D_OBJS} ${LDFLAGS} + strip crontab + + protos.h: ${SRCS} ${D_SRCS} diff --git a/dcron-3.2-pidfile.patch b/dcron-3.2-pidfile.patch new file mode 100644 index 0000000..9ef6877 --- /dev/null +++ b/dcron-3.2-pidfile.patch @@ -0,0 +1,20 @@ +write out a pidfile + +--- dcron/main.c ++++ dcron/main.c +@@ -120,8 +120,14 @@ + perror("fork"); + exit(1); + } +- if (pid > 0) ++ if (pid > 0) { ++ FILE *fp; ++ if ((fp = fopen("/var/run/cron.pid", "w")) != NULL) { ++ fprintf(fp, "%d\n", pid); ++ fclose(fp); ++ } + exit(0); ++ } + } + + /* diff --git a/dokuwiki-allow-svg-by-default.patch b/dokuwiki-allow-svg-by-default.patch new file mode 100644 index 0000000..98c6fe5 --- /dev/null +++ b/dokuwiki-allow-svg-by-default.patch @@ -0,0 +1,11 @@ +--- old-dokuwiki/conf/mime.conf 2006-12-22 06:47:18.000000000 -0500 ++++ new-dokuwiki/conf/mime.conf 2006-12-22 06:47:18.000000000 -0500 +@@ -16,6 +16,7 @@ + ppt application/mspowerpoint + rtf application/msword + xml text/xml ++svg image/svg+xml + swf application/x-shockwave-flash + + # You should enable HTML uploads only for restricted Wikis. + diff --git a/dokuwiki-customizable-subjects.patch b/dokuwiki-customizable-subjects.patch new file mode 100644 index 0000000..817c9d0 --- /dev/null +++ b/dokuwiki-customizable-subjects.patch @@ -0,0 +1,60 @@ +--- dokuwiki-2007-06-26/conf/dokuwiki.php ++++ dokuwiki-2007-06-26/conf/dokuwiki.php +@@ -86,6 +86,7 @@ + $conf['locktime'] = 15*60; //maximum age for lockfiles (defaults to 15 minutes) + $conf['fetchsize'] = 0; //maximum size (bytes) fetch.php may download from extern, disabled by default + $conf['notify'] = ''; //send change info to this email (leave blank for nobody) ++$conf['notify_subject'] = '[@TITLE@] @REASON@ @ID@'; //subject template for change emails + $conf['registernotify'] = ''; //send info about newly registered users to this email (leave blank for nobody) + $conf['mailfrom'] = ''; //use this email when sending mails + $conf['gzip_output'] = 0; //use gzip content encodeing for the output xhtml (if allowed by browser) +--- dokuwiki-2007-06-26/inc/common.php ++++ dokuwiki-2007-06-26/inc/common.php +@@ -868,7 +868,7 @@ + if($who == 'register'){ + $subject = $lang['mail_new_user'].' '.$summary; + }elseif($rev){ +- $subject = $lang['mail_changed'].' '.$id; ++ $subject = str_replace('@REASON@',$lang['mail_changed'],$conf['notify_subject']); + $text = str_replace('@OLDPAGE@',wl($id,"rev=$rev",true,'&'),$text); + require_once(DOKU_INC.'inc/DifferenceEngine.php'); + $df = new Diff(split("\n",rawWiki($id,$rev)), +@@ -876,12 +876,16 @@ + $dformat = new UnifiedDiffFormatter(); + $diff = $dformat->format($df); + }else{ +- $subject=$lang['mail_newpage'].' '.$id; ++ $subject = str_replace('@REASON@',$lang['mail_newpage'],$conf['notify_subject']); + $text = str_replace('@OLDPAGE@','none',$text); + $diff = rawWiki($id); + } + $text = str_replace('@DIFF@',$diff,$text); +- $subject = '['.$conf['title'].'] '.$subject; ++ $subject = str_replace('@DATE@',date($conf['dformat']),$subject); ++ $subject = str_replace('@PAGE@',$id,$subject); ++ $subject = str_replace('@TITLE@',$conf['title'],$subject); ++ $subject = str_replace('@SUMMARY@',$summary,$subject); ++ $subject = str_replace('@USER@',$_SERVER['REMOTE_USER'],$subject); + + $from = $conf['mailfrom']; + $from = str_replace('@USER@',$_SERVER['REMOTE_USER'],$from); +--- dokuwiki-2007-06-26/lib/plugins/config/lang/en/lang.php ++++ dokuwiki-2007-06-26/lib/plugins/config/lang/en/lang.php +@@ -112,6 +112,7 @@ + $lang['locktime'] = 'Maximum age for lock files (sec)'; + $lang['fetchsize'] = 'Maximum size (bytes) fetch.php may download from extern'; + $lang['notify'] = 'Send change notifications to this email address'; ++$lang['notify_subject'] = 'Subject to use in notification emails'; + $lang['registernotify'] = 'Send info on newly registered users to this email address'; + $lang['mailfrom'] = 'Email address to use for automatic mails'; + $lang['gzip_output'] = 'Use gzip Content-Encoding for xhtml'; +--- dokuwiki-2007-06-26/lib/plugins/config/settings/config.metadata.php ++++ dokuwiki-2007-06-26/lib/plugins/config/settings/config.metadata.php +@@ -133,6 +133,7 @@ + $meta['htmlok'] = array('onoff'); + $meta['phpok'] = array('onoff'); + $meta['notify'] = array('email'); ++$meta['notify_subject'] = array('string'); + $meta['subscribers'] = array('onoff'); + $meta['locktime'] = array('numeric'); + $meta['cachetime'] = array('numeric'); diff --git a/dropbear-multi-dbscp.patch b/dropbear-multi-dbscp.patch new file mode 100644 index 0000000..e06b305 --- /dev/null +++ b/dropbear-multi-dbscp.patch @@ -0,0 +1,19 @@ +# +# old_revision [2f31bc0e5d1c701ad8c03176bbb5722852c0c11d] +# +# patch "dbmulti.c" +# from [5c39fae15ddd3d9519de6d7d3ed54abd926905d3] +# to [98f401a3d46b4bb143290f1ad88bb26290f70bed] +# +============================================================ +--- dbmulti.c 5c39fae15ddd3d9519de6d7d3ed54abd926905d3 ++++ dbmulti.c 98f401a3d46b4bb143290f1ad88bb26290f70bed +@@ -60,7 +60,7 @@ int main(int argc, char ** argv) { + } + #endif + #ifdef DBMULTI_scp +- if (strcmp(progname, "scp") == 0) { ++ if (strcmp(progname, "scp") == 0 || strcmp(progname, "dbscp") == 0) { + return scp_main(argc, argv); + } + #endif diff --git a/dropbear-uclinux.patch b/dropbear-uclinux.patch new file mode 100644 index 0000000..447ac14 --- /dev/null +++ b/dropbear-uclinux.patch @@ -0,0 +1,46 @@ +# +# old_revision [2f31bc0e5d1c701ad8c03176bbb5722852c0c11d] +# +# patch "scp.c" +# from [a490c2773b48cbdb1ec1fa12f312bb8d98092f12] +# to [c9ced325688624015d7202aa1ef4bb2cf95cbfd9] +# +============================================================ +--- scp.c a490c2773b48cbdb1ec1fa12f312bb8d98092f12 ++++ scp.c c9ced325688624015d7202aa1ef4bb2cf95cbfd9 +@@ -130,13 +130,22 @@ do_local_cmd(arglist *a) + fprintf(stderr, " %s", a->list[i]); + fprintf(stderr, "\n"); + } +- if ((pid = fork()) == -1) ++#ifdef __uClinux__ ++ pid = vfork(); ++#else ++ pid = fork(); ++#endif /* __uClinux__ */ ++ if (pid == -1) + fatal("do_local_cmd: fork: %s", strerror(errno)); + + if (pid == 0) { + execvp(a->list[0], a->list); + perror(a->list[0]); ++#ifdef __uClinux__ ++ _exit(1); ++#else + exit(1); ++#endif /* __uClinux__ */ + } + + do_cmd_pid = pid; +@@ -225,7 +234,11 @@ do_cmd(char *host, char *remuser, char * + + execvp(ssh_program, args.list); + perror(ssh_program); ++#ifdef __uClinux__ ++ _exit(1); ++#else + exit(1); ++#endif /* __uClinux__ */ + } else if (do_cmd_pid == -1) { + fatal("fork: %s", strerror(errno)); + } diff --git a/e2fsprogs-AC_MSG.patch b/e2fsprogs-AC_MSG.patch new file mode 100644 index 0000000..3bfb192 --- /dev/null +++ b/e2fsprogs-AC_MSG.patch @@ -0,0 +1,458 @@ +diff --git a/configure.in b/configure.in +index c29f438..0eba7dc 100644 +--- a/configure.in ++++ b/configure.in +@@ -36,7 +36,7 @@ Sep) MONTH_NUM=09; E2FSPROGS_MONTH="September" ;; + Oct) MONTH_NUM=10; E2FSPROGS_MONTH="October" ;; + Nov) MONTH_NUM=11; E2FSPROGS_MONTH="November" ;; + Dec) MONTH_NUM=12; E2FSPROGS_MONTH="December" ;; +-*) echo "Unknown month $MONTH??" ;; ++*) AC_MSG_WARN([Unknown month $MONTH??]) ;; + esac + + base_ver=`echo $E2FSPROGS_VERSION | \ +@@ -54,8 +54,8 @@ case $E2FSPROGS_VERSION in + esac + + unset DATE MONTH YEAR base_ver pre_vers date_spec +-echo "Generating configuration file for e2fsprogs version $E2FSPROGS_VERSION" +-echo "Release date is ${E2FSPROGS_MONTH}, ${E2FSPROGS_YEAR}" ++AC_MSG_RESULT([Generating configuration file for e2fsprogs version $E2FSPROGS_VERSION]) ++AC_MSG_RESULT([Release date is ${E2FSPROGS_MONTH}, ${E2FSPROGS_YEAR}]) + AC_SUBST(E2FSPROGS_YEAR) + AC_SUBST(E2FSPROGS_MONTH) + AC_SUBST(E2FSPROGS_DAY) +@@ -161,14 +161,14 @@ AC_ARG_ENABLE([maintainer-mode], + if test "$enableval" = "no" + then + MAINTAINER_CMT=# +- echo "Disabling maintainer mode" ++ AC_MSG_RESULT([Disabling maintainer mode]) + else + MAINTAINER_CMT= +- echo "Enabling maintainer mode" ++ AC_MSG_RESULT([Enabling maintainer mode]) + fi + , + MAINTAINER_CMT=# +-echo "Disabling maintainer mode by default" ++AC_MSG_RESULT([Disabling maintainer mode by default]) + ) + AC_SUBST(MAINTAINER_CMT) + dnl +@@ -178,14 +178,14 @@ AC_ARG_ENABLE([compression], + [ --enable-compression enable EXPERIMENTAL compression support], + if test "$enableval" = "no" + then +- echo "Disabling compression support" ++ AC_MSG_RESULT([Disabling compression support]) + else + AC_DEFINE(ENABLE_COMPRESSION) +- echo "Enabling compression support" +- echo "WARNING: Compression support is experimental" ++ AC_MSG_RESULT([Enabling compression support]) ++ AC_MSG_WARN([Compression support is experimental]) + fi + , +-echo "Disabling compression support by default" ++AC_MSG_RESULT([Disabling compression support by default]) + ) + dnl + dnl handle --enable-htree +@@ -195,16 +195,16 @@ AC_ARG_ENABLE([htree], + if test "$enableval" = "no" + then + HTREE_CMT=# +- echo "Disabling htree directory support" ++ AC_MSG_RESULT([Disabling htree directory support]) + else + HTREE_CMT= + AC_DEFINE(ENABLE_HTREE) +- echo "Enabling htree directory support" ++ AC_MSG_RESULT([Enabling htree directory support]) + fi + , + HTREE_CMT= + AC_DEFINE(ENABLE_HTREE) +-echo "Enabling htree directory support by default" ++AC_MSG_RESULT([Enabling htree directory support by default]) + ) + AC_SUBST(HTREE_CMT) + dnl +@@ -220,7 +220,7 @@ if test "$enableval" = "no" + then + ELF_CMT=# + MAKEFILE_ELF=/dev/null +- echo "Disabling ELF shared libraries" ++ AC_MSG_RESULT([Disabling ELF shared libraries]) + else + E2_PKG_CONFIG_STATIC= + ELF_CMT= +@@ -232,12 +232,12 @@ else + esac] + BINARY_TYPE=elfbin + LIB_EXT=.so +- echo "Enabling ELF shared libraries" ++ AC_MSG_RESULT([Enabling ELF shared libraries]) + fi + , + MAKEFILE_ELF=/dev/null + ELF_CMT=# +-echo "Disabling ELF shared libraries by default" ++AC_MSG_RESULT([Disabling ELF shared libraries by default]) + ) + AC_SUBST(ELF_CMT) + AC_SUBST_FILE(MAKEFILE_ELF) +@@ -250,7 +250,7 @@ if test "$enableval" = "no" + then + BSDLIB_CMT=# + MAKEFILE_BSDLIB=/dev/null +- echo "Disabling BSD shared libraries" ++ AC_MSG_RESULT([Disabling BSD shared libraries]) + else + E2_PKG_CONFIG_STATIC= + BSDLIB_CMT= +@@ -262,12 +262,12 @@ else + LIB_EXT=.dylib + ;; + esac] +- echo "Enabling BSD shared libraries" ++ AC_MSG_RESULT([Enabling BSD shared libraries]) + fi + , + MAKEFILE_BSDLIB=/dev/null + BSDLIB_CMT=# +-echo "Disabling BSD shared libraries by default" ++AC_MSG_RESULT([Disabling BSD shared libraries by default]) + ) + AC_SUBST(BSDLIB_CMT) + AC_SUBST_FILE(MAKEFILE_BSDLIB) +@@ -280,17 +280,17 @@ if test "$enableval" = "no" + then + PROFILE_CMT=# + MAKEFILE_PROFILE=/dev/null +- echo "Disabling profiling libraries" ++ AC_MSG_RESULT([Disabling profiling libraries]) + else + PROFILE_CMT= + MAKEFILE_PROFILE=$srcdir/lib/Makefile.profile + PROFILED_LIB_EXT=_p.a +- echo "Building profiling libraries" ++ AC_MSG_RESULT([Building profiling libraries]) + fi + , + PROFILE_CMT=# + MAKEFILE_PROFILE=/dev/null +-echo "Disabling profiling libraries by default" ++AC_MSG_RESULT([Disabling profiling libraries by default]) + ) + AC_SUBST(PROFILE_CMT) + AC_SUBST_FILE(MAKEFILE_PROFILE) +@@ -303,16 +303,16 @@ if test "$enableval" = "no" + then + CHECKER_CMT=# + MAKEFILE_CHECKER=/dev/null +- echo "Disabling checker libraries" ++ AC_MSG_RESULT([Disabling checker libraries]) + else + CHECKER_CMT= + MAKEFILE_CHECKER=$srcdir/lib/Makefile.checker +- echo "Building checker libraries" ++ AC_MSG_RESULT([Building checker libraries]) + fi + , + CHECKER_CMT=# + MAKEFILE_CHECKER=/dev/null +-echo "Disabling checker libraries by default" ++AC_MSG_RESULT([Disabling checker libraries by default]) + ) + AC_SUBST(CHECKER_CMT) + AC_SUBST_FILE(MAKEFILE_CHECKER) +@@ -329,13 +329,13 @@ AC_ARG_ENABLE([jbd-debug], + [ --enable-jbd-debug enable journal debugging], + if test "$enableval" = "no" + then +- echo "Disabling journal debugging" ++ AC_MSG_RESULT([Disabling journal debugging]) + else + AC_DEFINE(CONFIG_JBD_DEBUG) +- echo "Enabling journal debugging" ++ AC_MSG_RESULT([Enabling journal debugging]) + fi + , +-echo "Disabling journal debugging by default" ++AC_MSG_RESULT([Disabling journal debugging by default]) + ) + dnl + dnl handle --enable-blkid-debug +@@ -344,13 +344,13 @@ AC_ARG_ENABLE([blkid-debug], + [ --enable-blkid-debug enable blkid debugging], + if test "$enableval" = "no" + then +- echo "Disabling blkid debugging" ++ AC_MSG_RESULT([Disabling blkid debugging]) + else + AC_DEFINE(CONFIG_BLKID_DEBUG) +- echo "Enabling blkid debugging" ++ AC_MSG_RESULT([Enabling blkid debugging]) + fi + , +-echo "Disabling blkid debugging by default" ++AC_MSG_RESULT([Disabling blkid debugging by default]) + ) + dnl + dnl handle --enable-testio-debug +@@ -359,13 +359,13 @@ AC_ARG_ENABLE([testio-debug], + [ --enable-testio-debug enable the use of the test I/O manager for debugging], + if test "$enableval" = "no" + then +- echo "Disabling testio debugging" ++ AC_MSG_RESULT([Disabling testio debugging]) + else + AC_DEFINE(CONFIG_TESTIO_DEBUG) +- echo "Enabling testio debugging" ++ AC_MSG_RESULT([Enabling testio debugging]) + fi + , +-echo "Disabling testio debugging by default" ++AC_MSG_RESULT([Disabling testio debugging by default]) + ) + dnl + dnl handle --enable-debugfs +@@ -374,14 +374,14 @@ AC_ARG_ENABLE([debugfs], + [ --disable-debugfs disable support of debugfs program], + if test "$enableval" = "no" + then +- echo "Disabling debugfs support" ++ AC_MSG_RESULT([Disabling debugfs support]) + DEBUGFS_CMT="#" + else + DEBUGFS_CMT= +- echo "Enabling debugfs support" ++ AC_MSG_RESULT([Enabling debugfs support]) + fi + , +-echo "Enabling debugfs support by default" ++AC_MSG_RESULT([Enabling debugfs support by default]) + DEBUGFS_CMT= + ) + AC_SUBST(DEBUGFS_CMT) +@@ -392,14 +392,14 @@ AC_ARG_ENABLE([imager], + [ --disable-imager disable support of e2image program], + if test "$enableval" = "no" + then +- echo "Disabling e2image support" ++ AC_MSG_RESULT([Disabling e2image support]) + IMAGER_CMT="#" + else + IMAGER_CMT= +- echo "Enabling e2image support" ++ AC_MSG_RESULT([Enabling e2image support]) + fi + , +-echo "Enabling e2image support by default" ++AC_MSG_RESULT([Enabling e2image support by default]) + IMAGER_CMT= + ) + AC_SUBST(IMAGER_CMT) +@@ -410,14 +410,14 @@ AC_ARG_ENABLE([resizer], + [ --disable-resizer disable support of e2resize program], + if test "$enableval" = "no" + then +- echo "Disabling e2resize support" ++ AC_MSG_RESULT([Disabling e2resize support]) + RESIZER_CMT="#" + else + RESIZER_CMT= +- echo "Enabling e2resize support" ++ AC_MSG_RESULT([Enabling e2resize support]) + fi + , +-echo "Enabling e2resize support by default" ++AC_MSG_RESULT([Enabling e2resize support by default]) + RESIZER_CMT= + ) + AC_SUBST(RESIZER_CMT) +@@ -429,20 +429,20 @@ AC_ARG_ENABLE([fsck], + [if test "$enableval" = "no" + then + FSCK_PROG='' FSCK_MAN='' +- echo "Not building fsck wrapper" ++ AC_MSG_RESULT([Not building fsck wrapper]) + else + FSCK_PROG=fsck FSCK_MAN=fsck.8 +- echo "Building fsck wrapper" ++ AC_MSG_RESULT([Building fsck wrapper]) + fi] + , + [case "$host_os" in + gnu*) + FSCK_PROG='' FSCK_MAN='' +- echo "Not building fsck wrapper by default" ++ AC_MSG_RESULT([Not building fsck wrapper by default]) + ;; + *) + FSCK_PROG=fsck FSCK_MAN=fsck.8 +- echo "Building fsck wrapper by default" ++ AC_MSG_RESULT([Building fsck wrapper by default]) + esac] + ) + AC_SUBST(FSCK_PROG) +@@ -455,14 +455,14 @@ AC_ARG_ENABLE([e2initrd-helper], + [if test "$enableval" = "no" + then + E2INITRD_PROG='' E2INITRD_MAN='' +- echo "Not building e2initrd helper" ++ AC_MSG_RESULT([Not building e2initrd helper]) + else + E2INITRD_PROG=e2initrd_helper E2INITRD_MAN=e2initrd_helper.8 +- echo "Building e2initrd helper" ++ AC_MSG_RESULT([Building e2initrd helper]) + fi] + , + E2INITRD_PROG=e2initrd_helper E2INITRD_MAN=e2initrd_helper.8 +-echo "Building e2initrd helper by default" ++AC_MSG_RESULT([Building e2initrd helper by default]) + ) + AC_SUBST(E2INITRD_PROG) + AC_SUBST(E2INITRD_MAN) +@@ -473,19 +473,18 @@ AC_ARG_ENABLE([blkid-devmapper], + [ --enable-blkid-devmapper build with device-mapper support], + [if test "$enableval" = "no" + then +- echo "Disabling device-mapper support" ++ AC_MSG_RESULT([Disabling device-mapper support]) + DEVMAPPER_REQ='' + DEVMAPPER_LIBS='' + STATIC_DEVMAPPER_LIBS='' + else + AC_DEFINE(HAVE_DEVMAPPER) +- echo "Enabling device-mapper support" ++ AC_MSG_RESULT([Enabling device-mapper support]) + + PKG_PROG_PKG_CONFIG() + + if test -z "$PKG_CONFIG"; then +- echo "pkg-config not installed; please install it." +- exit 1; ++ AC_MSG_ERROR([pkg-config not installed; please install it.]) + fi + + AC_CHECK_LIB(devmapper, dm_tree_create, +@@ -500,7 +499,7 @@ else + *pthread*) + ;; + *) +- echo "Working around Debian bug #390243..." ++ AC_MSG_WARN([Working around Debian bug #390243...]) + STATIC_DEVMAPPER_LIBS="-pthread $STATIC_DEVMAPPER_LIBS" + ;; + esac +@@ -510,7 +509,7 @@ else + fi + fi] + , +-echo "Disabling device-mapper support by default" ++AC_MSG_RESULT([Disabling device-mapper support by default]) + ) + AC_SUBST(DEVMAPPER_REQ) + AC_SUBST(DEVMAPPER_PC_LIBS) +@@ -525,19 +524,19 @@ AC_ARG_ENABLE([tls], + [if test "$enableval" = "no" + then + try_tls="" +- echo "Disabling thread local support" ++ AC_MSG_RESULT([Disabling thread local support]) + else + try_tls="yes" +- echo "Enabling thread local support" ++ AC_MSG_RESULT([Enabling thread local support]) + fi] + , + if test -n "$WITH_DIET_LIBC" + then + try_tls="" +- echo "Diet libc does not support thread local support" ++ AC_MSG_RESULT([Diet libc does not support thread local support]) + else + try_tls="yes" +- echo "Try using thread local support by default" ++ AC_MSG_RESULT([Try using thread local support by default]) + fi + ) + if test "$try_tls" = "yes" +@@ -551,17 +550,17 @@ AC_ARG_ENABLE([uuidd], + [ --disable-uuidd disable building the uuid daemon], + [if test "$enableval" = "no" + then +- echo "Not building uuidd" ++ AC_MSG_RESULT([Not building uuidd]) + UUIDD_CMT="#" + else + AC_DEFINE(USE_UUIDD) + UUIDD_CMT="" +- echo "Building uuidd" ++ AC_MSG_RESULT([Building uuidd]) + fi] + , + AC_DEFINE(USE_UUIDD) + UUIDD_CMT="" +-echo "Building uuidd by default" ++AC_MSG_RESULT([Building uuidd by default]) + ) + AC_SUBST(UUIDD_CMT) + dnl +@@ -812,7 +811,7 @@ case "$host_os" in + linux* | gnu* | k*bsd*-gnu) + if test "$prefix" = NONE -a "$root_prefix" = NONE ; then + root_prefix=""; +- echo "On $host_os systems, root_prefix defaults to ''" ++ AC_MSG_RESULT([On $host_os systems, root_prefix defaults to '']) + fi + ;; + esac +@@ -823,9 +822,9 @@ case "$host_os" in + linux* | gnu* | k*bsd*-gnu) + if test "$prefix" = NONE ; then + prefix="/usr"; +- echo "On $host_os systems, prefix defaults to /usr" ++ AC_MSG_RESULT([On $host_os systems, prefix defaults to /usr]) + if test "$mandir" = '${prefix}/man' ; then +- echo "...and mandir defaults to /usr/share/man" ++ AC_MSG_RESULT([...and mandir defaults to /usr/share/man]) + mandir=/usr/share/man + fi + fi +@@ -849,19 +848,19 @@ else + fi + if test "$bindir" != '${exec_prefix}/bin'; then + root_bindir=$bindir +- echo "Setting root_bindir to $root_bindir" ++ AC_MSG_RESULT([Setting root_bindir to $root_bindir]) + fi + if test "$sbindir" != '${exec_prefix}/sbin'; then + root_sbindir=$sbindir +- echo "Setting root_sbindir to $root_sbindir" ++ AC_MSG_RESULT([Setting root_sbindir to $root_sbindir]) + fi + if test "$libdir" != '${exec_prefix}/lib'; then + root_libdir=$libdir +- echo "Setting root_libdir to $root_libdir" ++ AC_MSG_RESULT([Setting root_libdir to $root_libdir]) + fi + if test "$sysconfdir" != '${prefix}/etc'; then + root_sysconfdir=$sysconfdir +- echo "Setting root_sysconfdir to $root_sysconfdir" ++ AC_MSG_RESULT([Setting root_sysconfdir to $root_sysconfdir]) + fi + AC_SUBST(root_prefix) + AC_SUBST(root_bindir) +@@ -902,7 +901,7 @@ dnl Apple hacked gcc somehow?) + dnl + case "$host_os" in + darwin*) +- echo "Using Apple Darwin / GNU libintl workaround" ++ AC_MSG_RESULT([Using Apple Darwin / GNU libintl workaround]) + AC_DEFINE(_INTL_REDIRECT_MACROS) + ;; + esac diff --git a/echangelog.patch b/echangelog.patch new file mode 100644 index 0000000..ec4cf0e --- /dev/null +++ b/echangelog.patch @@ -0,0 +1,11 @@ +--- /usr/bin/echangelog ++++ /usr/bin/echangelog +@@ -319,7 +319,7 @@ + my ($t) = @_; + (my $year = $date) =~ s/.* //; + $t =~ s/^# Copyright \d+(?= )/$&-$year/m or +- $t =~ s/^(# Copyright \d+)-(\d+)/$1-$year/m; ++ $t =~ s/^(# Copyright) \d+-(\d+)/$1 1999-$year/m; + return $t; + } + diff --git a/ed-0.5-build.patch b/ed-0.5-build.patch new file mode 100644 index 0000000..e5e145c --- /dev/null +++ b/ed-0.5-build.patch @@ -0,0 +1,57 @@ +2007-04-16 Mike Frysinger + + * Clean locale vars from environment to maintain a sane state. + * Do not set CC/CXX/CPPFLAGS/LDFLAGS to "" so that user can + override if they so choose. + * Only set CFLAGS/CXXFLAGS if user did not specify any. + +--- ed/configure ++++ ed/configure +@@ -14,6 +14,19 @@ + progversion=0.5 + srctrigger=ed.h + ++# 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 ++ unset $as_var ++ fi ++done ++ + # clear some things potentially inherited from environment. + srcdir= + prefix=/usr/local +@@ -23,12 +36,6 @@ + infodir='$(datadir)/info' + mandir='$(datadir)/man' + sysconfdir='$(prefix)/etc' +-CC= +-CXX= +-CPPFLAGS= +-CFLAGS='-Wall -W -O2' +-CXXFLAGS='-Wall -W -O2' +-LDFLAGS= + + # Loop over all args + while [ x"$1" != x ] ; do +@@ -102,6 +109,14 @@ + esac + done + ++# Defaults if the user did not select any ++if [ x"${CFLAGS}" = x ] ; then ++ CFLAGS='-Wall -W -O2' ++fi ++if [ x"${CXXFLAGS}" = x ] ; then ++ CXXFLAGS='-Wall -W -O2' ++fi ++ + # Find the source files, if location was not specified. + srcdirtext= + if [ x"${srcdir}" = x ] ; then diff --git a/eject-2.1.5-handle-spaces.patch b/eject-2.1.5-handle-spaces.patch new file mode 100644 index 0000000..2b058e7 --- /dev/null +++ b/eject-2.1.5-handle-spaces.patch @@ -0,0 +1,60 @@ +Index: eject.c +=================================================================== +RCS file: /cvsroot/eject/eject/eject/eject.c,v +retrieving revision 1.10 +diff -u -p -r1.10 eject.c +--- eject.c 15 Jul 2006 23:28:28 -0000 1.10 ++++ eject.c 14 Oct 2006 20:23:29 -0000 +@@ -370,6 +370,30 @@ static int FileExists(const char *name, + + + /* ++ * Linux mangles spaces in mount points by changing them to an octal string ++ * of '\040'. So lets scan the mount point and fix it up by replacing all ++ * occurrences off '\0##' with the ASCII value of 0##. Requires a writable ++ * string as input as we mangle in place. Some of this was taken from the ++ * util-linux package. ++ */ ++#define octalify(a) ((a) & 7) ++#define tooctal(s) (64*octalify(s[1]) + 8*octalify(s[2]) + octalify(s[3])) ++#define isoctal(a) (((a) & ~7) == '0') ++static char *DeMangleMount(char *s) ++{ ++ char *tmp = s; ++ while ((tmp = strchr(tmp, '\\')) != NULL) { ++ if (isoctal(tmp[1]) && isoctal(tmp[2]) && isoctal(tmp[3])) { ++ tmp[0] = tooctal(tmp); ++ memmove(tmp+1, tmp+4, strlen(tmp)-3); ++ } ++ ++tmp; ++ } ++ return s; ++} ++ ++ ++/* + * Given name, such as foo, see if any of the following exist: + * + * foo (if foo starts with '.' or '/') +@@ -884,8 +908,8 @@ static int MountedDevice(const char *nam + if (((strcmp(s1, name) == 0) || (strcmp(s2, name) == 0)) || + ((maj != -1) && (maj == mtabmaj) && (min == mtabmin))) { + FCLOSE(fp); +- *deviceName = strdup(s1); +- *mountName = strdup(s2); ++ *deviceName = DeMangleMount(strdup(s1)); ++ *mountName = DeMangleMount(strdup(s2)); + return 1; + } + } +@@ -928,8 +952,8 @@ static int MountableDevice(const char *n + rc = sscanf(line, "%1023s %1023s", s1, s2); + if (rc >= 2 && s1[0] != '#' && strcmp(s2, name) == 0) { + FCLOSE(fp); +- *deviceName = strdup(s1); +- *mountName = strdup(s2); ++ *deviceName = DeMangleMount(strdup(s1)); ++ *mountName = DeMangleMount(strdup(s2)); + return 1; + } + } diff --git a/eject-typos.patch b/eject-typos.patch new file mode 100644 index 0000000..f7f1d14 --- /dev/null +++ b/eject-typos.patch @@ -0,0 +1,21 @@ +--- eject.1.orig 2007-02-04 18:35:23.000000000 -0500 ++++ eject.1 2007-02-04 18:35:39.000000000 -0500 +@@ -121,8 +121,8 @@ + .B \-r + This option specifies that the drive should be ejected using a + CDROM eject command. +-.TP 0.5i + ++.TP 0.5i + .B \-s + This option specifies that the drive should be ejected using + SCSI commands. +@@ -145,7 +145,7 @@ + .TP 0.5i + .B \-m + This option allows eject to work with device drivers which automatically +-mount removable media and therefore must be always mount()ed. ++mount removable media and therefore must be always mount(1)ed. + The option tells eject to not try to unmount the given device, + even if it is mounted according to /etc/mtab or /proc/mounts. + diff --git a/elf2flt-flat-stdint.patch b/elf2flt-flat-stdint.patch new file mode 100644 index 0000000..7b51031 --- /dev/null +++ b/elf2flt-flat-stdint.patch @@ -0,0 +1,15 @@ +Index: flat.h +=================================================================== +RCS file: /var/cvs/elf2flt/flat.h,v +retrieving revision 1.6 +diff -u -p -r1.6 flat.h +--- flat.h 1 Aug 2005 00:02:33 -0000 1.6 ++++ flat.h 24 Sep 2007 05:02:17 -0000 +@@ -17,6 +17,7 @@ + #include + #include + #endif ++#include + + #define FLAT_VERSION 0x00000004L + diff --git a/elf2flt-libintl_dgettext.patch b/elf2flt-libintl_dgettext.patch new file mode 100644 index 0000000..fa31400 --- /dev/null +++ b/elf2flt-libintl_dgettext.patch @@ -0,0 +1,50 @@ +Index: configure +=================================================================== +RCS file: /var/cvs/elf2flt/configure,v +retrieving revision 1.12 +diff -u -p -r1.12 configure +--- configure 3 Jan 2007 03:53:51 -0000 1.12 ++++ configure 11 Oct 2007 03:20:29 -0000 +@@ -3667,7 +3667,7 @@ done + + + +-for ac_func in dcgettext ++for ac_func in dcgettext libintl_dgettext + do + as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` + echo "$as_me:$LINENO: checking for $ac_func" >&5 +Index: configure.in +=================================================================== +RCS file: /var/cvs/elf2flt/configure.in,v +retrieving revision 1.10 +diff -u -p -r1.10 configure.in +--- configure.in 3 Jan 2007 03:49:47 -0000 1.10 ++++ configure.in 11 Oct 2007 03:20:29 -0000 +@@ -116,7 +116,7 @@ AC_C_CONST + dnl Checks for library functions. + AC_FUNC_VPRINTF + +-AC_CHECK_FUNCS(dcgettext) ++AC_CHECK_FUNCS(dcgettext libintl_dgettext) + + dnl Subsitute values + AC_SUBST(target) +Index: stubs.c +=================================================================== +RCS file: /var/cvs/elf2flt/stubs.c,v +retrieving revision 1.1 +diff -u -p -r1.1 stubs.c +--- stubs.c 21 Sep 2003 23:19:08 -0000 1.1 ++++ stubs.c 11 Oct 2007 03:20:29 -0000 +@@ -4,3 +4,10 @@ const char *dcgettext (const char *domai + return msg; + } + #endif /* !HAVE_DCGETTEXT */ ++ ++#ifndef HAVE_LIBINTL_DGETTEXT ++const char *libintl_dgettext (const char *domain, const char *msg) ++{ ++ return msg; ++} ++#endif /* !HAVE_LIBINTL_DGETTEXT */ diff --git a/elf2flt-remove-unused.patch b/elf2flt-remove-unused.patch new file mode 100644 index 0000000..94ffaaa --- /dev/null +++ b/elf2flt-remove-unused.patch @@ -0,0 +1,15 @@ +Index: flthdr.c +=================================================================== +RCS file: /var/cvs/elf2flt/flthdr.c,v +retrieving revision 1.10 +diff -u -p -r1.10 flthdr.c +--- flthdr.c 3 Apr 2006 02:58:44 -0000 1.10 ++++ flthdr.c 22 Sep 2007 09:52:47 -0000 +@@ -41,7 +41,6 @@ char *program_name; + + static char cmd[1024]; + static int print = 0, compress = 0, ramload = 0, stacksize = 0, ktrace = 0; +-static int short_format = 0; + + /****************************************************************************/ + diff --git a/elf2flt-stack-hex.patch b/elf2flt-stack-hex.patch new file mode 100644 index 0000000..35c4b5a --- /dev/null +++ b/elf2flt-stack-hex.patch @@ -0,0 +1,21 @@ +Index: flthdr.c +=================================================================== +RCS file: /var/cvs/elf2flt/flthdr.c,v +retrieving revision 1.10 +diff -u -p -r1.10 flthdr.c +--- flthdr.c 3 Apr 2006 02:58:44 -0000 1.10 ++++ flthdr.c 22 Sep 2007 09:50:23 -0000 +@@ -351,7 +351,12 @@ main(int argc, char *argv[]) + case 'R': ramload = -1; break; + case 'k': ktrace = 1; break; + case 'K': ktrace = -1; break; +- case 's': stacksize = atoi(optarg); break; ++ case 's': ++ if (optarg[1] == 'x' || optarg[1] == 'X') ++ sscanf(optarg, "%x", &stacksize); ++ else ++ stacksize = atoi(optarg); ++ break; + case 'o': ofile = optarg; break; + default: + usage("invalid option"); diff --git a/elf2flt-use-AC_MSG_ERROR.patch b/elf2flt-use-AC_MSG_ERROR.patch new file mode 100644 index 0000000..23dbccc --- /dev/null +++ b/elf2flt-use-AC_MSG_ERROR.patch @@ -0,0 +1,57 @@ +Index: configure.in +=================================================================== +RCS file: /var/cvs/elf2flt/configure.in,v +retrieving revision 1.9 +diff -u -p -r1.9 configure.in +--- configure.in 10 Jul 2006 22:23:46 -0000 1.9 ++++ configure.in 30 Dec 2006 03:27:45 -0000 +@@ -81,29 +81,29 @@ fi + binutils_ldscript_dir="$ac_binutils_ldscript_dir" + + if test "$ac_libbfd" = "NONE" -o "$ac_libiberty" = "NONE" ; then +- echo +- echo "You need to specify the location of the libfd.a and libiberty.a" +- echo "host libraries from the binutils package." +- echo +- echo "Run configure again specifying these options:" +- echo +- echo " ./configure --target= --with-bfd-include-dir= --with-libbfd= --with-libiberty=" +- echo +- exit 1 ++ 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= --with-bfd-include-dir= --with-libbfd= --with-libiberty= ++]) + fi + + if test "$ac_bfd_include_dir" = "NONE" ; then +- echo +- echo "You need to specify the location of the bfd.h header from a" +- echo "configured/compiled version of the binutils package for your target." +- echo "Without this your elf2flt may crash as it will try to use the" +- echo "systems bfd.h which may be from a different binutils package." +- echo +- echo "Run configure again specifying these options:" +- echo +- echo " ./configure --target= --with-bfd-include-dir= --with-libbfd= --with-libiberty=" +- echo +- exit 1 ++ 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= --with-bfd-include-dir= --with-libbfd= --with-libiberty= ++]) + fi + + dnl Checks for header files. diff --git a/elf2flt-user-label-prefix.patch b/elf2flt-user-label-prefix.patch new file mode 100644 index 0000000..7474ff2 --- /dev/null +++ b/elf2flt-user-label-prefix.patch @@ -0,0 +1,185 @@ +Index: configure.in +=================================================================== +RCS file: /var/cvs/elf2flt/configure.in,v +retrieving revision 1.10 +diff -u -p -r1.10 configure.in +--- configure.in 3 Jan 2007 03:49:47 -0000 1.10 ++++ configure.in 22 Sep 2007 10:04:57 -0000 +@@ -106,6 +106,14 @@ Run configure again specifying these opt + ]) + fi + ++SYMBOL_PREFIX= ++case $target in ++ bfin*) ++ SYMBOL_PREFIX=_ ++ ;; ++esac ++ ++ + dnl Checks for header files. + AC_HEADER_STDC + AC_CHECK_HEADERS(fcntl.h unistd.h bfd.h) +@@ -129,6 +137,7 @@ AC_SUBST(binutils_include_dir) + AC_SUBST(binutils_ldscript_dir) + AC_SUBST(got_check) + AC_SUBST(emit_relocs) ++AC_SUBST(SYMBOL_PREFIX) + +-AC_OUTPUT(Makefile ld-elf2flt) ++AC_OUTPUT(Makefile ld-elf2flt elf2flt.ld) + +Index: elf2flt.ld +=================================================================== +RCS file: /var/cvs/elf2flt/elf2flt.ld,v +retrieving revision 1.15 +diff -u -p -r1.15 elf2flt.ld +--- elf2flt.ld 21 Jul 2006 13:11:04 -0000 1.15 ++++ elf2flt.ld 22 Sep 2007 10:04:58 -0000 +@@ -1,5 +1,5 @@ + +-ENTRY (_start) ++ENTRY (@SYMBOL_PREFIX@_start) + + MEMORY { + flatmem : ORIGIN = 0x0, LENGTH = 0xfffffff +@@ -10,7 +10,7 @@ SECTIONS { + .text 0x0 : { + . = . + 4; + . = ALIGN(0x4) ; +- _stext = . ; ++ @SYMBOL_PREFIX@_stext = . ; + *(.text) + *(.text.*) + *(.gnu.warning) +@@ -32,19 +32,19 @@ W_RODAT *(.gnu.linkonce.r*) + the start followed by the code pointed to by entries + in the lookup table. */ + . = ALIGN (4) ; +- PROVIDE(__ctbp = .); ++ PROVIDE(@SYMBOL_PREFIX@__ctbp = .); + *(.call_table_data) + *(.call_table_text) + + . = ALIGN(0x20) ; +- _etext = . ; ++ @SYMBOL_PREFIX@_etext = . ; + } > flatmem + + .data : { + . = ALIGN(0x4) ; +- _sdata = . ; +- __data_start = . ; +- data_start = . ; ++ @SYMBOL_PREFIX@_sdata = . ; ++ @SYMBOL_PREFIX@__data_start = . ; ++ @SYMBOL_PREFIX@data_start = . ; + *(.got.plt) + *(.got) + FILL(0) ; +@@ -65,14 +65,14 @@ R_RODAT *(.gnu.linkonce.r*) + + /* Microblaze has .sdata and .sbss (small bss). They must + be contiguous, so please don't move any of this. JW */ +- _ssrw = . ; ++ @SYMBOL_PREFIX@_ssrw = . ; + *(.sdata) + *(.sdata.*) + *(.sbss) /* Don't move this! */ +- _essrw = . ; ++ @SYMBOL_PREFIX@_essrw = . ; + +- _ssrw_size = _essrw - _ssrw; +- PROVIDE(_SDA_BASE_ = _ssrw + (_ssrw_size / 2)); ++ @SYMBOL_PREFIX@_ssrw_size = @SYMBOL_PREFIX@_essrw - @SYMBOL_PREFIX@_ssrw; ++ PROVIDE(@SYMBOL_PREFIX@_SDA_BASE_ = @SYMBOL_PREFIX@_ssrw + (@SYMBOL_PREFIX@_ssrw_size / 2)); + + *(.gnu.linkonce.s.*) + *(__libc_atexit) +@@ -82,15 +82,15 @@ R_RODAT *(.gnu.linkonce.r*) + + /* microblaze-specific read-only small data area + and associated locating symbols */ +- _ssro = . ; ++ @SYMBOL_PREFIX@_ssro = . ; + *(.sdata2) +- _essro = . ; +- _ssro_size = _essro - _ssro; +- PROVIDE(_SDA2_BASE_ = _ssro + (_ssro_size / 2)); ++ @SYMBOL_PREFIX@_essro = . ; ++ @SYMBOL_PREFIX@_ssro_size = @SYMBOL_PREFIX@_essro - @SYMBOL_PREFIX@_ssro; ++ PROVIDE(@SYMBOL_PREFIX@_SDA2_BASE_ = @SYMBOL_PREFIX@_ssro + (@SYMBOL_PREFIX@_ssro_size / 2)); + + . = ALIGN(4) ; +- __CTOR_LIST__ = .; +- LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) ++ @SYMBOL_PREFIX@__CTOR_LIST__ = .; ++ LONG((@SYMBOL_PREFIX@__CTOR_END__ - @SYMBOL_PREFIX@__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 +@@ -109,38 +109,38 @@ SINGLE_LINK: KEEP (*(EXCLUDE_FILE (*crte + SINGLE_LINK: KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + LONG(0) +- __CTOR_END__ = .; +- __DTOR_LIST__ = .; +- LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2) ++ @SYMBOL_PREFIX@__CTOR_END__ = .; ++ @SYMBOL_PREFIX@__DTOR_LIST__ = .; ++ LONG((@SYMBOL_PREFIX@__DTOR_END__ - @SYMBOL_PREFIX@__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__ = .; ++ @SYMBOL_PREFIX@__DTOR_END__ = .; + +- PROVIDE (__preinit_array_start = .); ++ PROVIDE (@SYMBOL_PREFIX@__preinit_array_start = .); + KEEP (*(.preinit_array)) +- PROVIDE (__preinit_array_end = .); ++ PROVIDE (@SYMBOL_PREFIX@__preinit_array_end = .); + +- PROVIDE (__init_array_start = .); ++ PROVIDE (@SYMBOL_PREFIX@__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) +- PROVIDE (__init_array_end = .); ++ PROVIDE (@SYMBOL_PREFIX@__init_array_end = .); + +- PROVIDE (__fini_array_start = .); ++ PROVIDE (@SYMBOL_PREFIX@__fini_array_start = .); + KEEP (*(.fini_array)) + KEEP (*(SORT(.fini_array.*))) +- PROVIDE (__fini_array_end = .); ++ PROVIDE (@SYMBOL_PREFIX@__fini_array_end = .); + + . = ALIGN(0x10) ; +- _edata = . ; ++ @SYMBOL_PREFIX@_edata = . ; + } > flatmem + + .bss : { + . = ALIGN(0x4) ; +- _sbss = ALIGN(0x4) ; +- __bss_start = . ; ++ @SYMBOL_PREFIX@_sbss = ALIGN(0x4) ; ++ @SYMBOL_PREFIX@__bss_start = . ; + *(.dynsbss) + *(.sbss) + *(.sbss.*) +@@ -152,9 +152,9 @@ SINGLE_LINK: KEEP (*(SORT(.dtors.*))) + *(.gnu.linkonce.b*) + *(COMMON) + . = ALIGN(0x10) ; +- _ebss = . ; +- _end = . ; +- end = . ; ++ @SYMBOL_PREFIX@_ebss = . ; ++ @SYMBOL_PREFIX@_end = . ; ++ @SYMBOL_PREFIX@end = . ; + } > flatmem + + .stack : { diff --git a/emerge-svn.diff b/emerge-svn.diff new file mode 100644 index 0000000..c07ecd0 --- /dev/null +++ b/emerge-svn.diff @@ -0,0 +1,2276 @@ +diff -Nru --exclude=CVS --exclude=env.sh busybox-1.00/archival/Config.in busybox/archival/Config.in +--- busybox-1.00/archival/Config.in 2004-03-15 09:28:16.000000000 +0100 ++++ busybox/archival/Config.in 2005-03-29 13:45:03.000000000 +0200 +@@ -97,6 +97,14 @@ + However it saves space as none of the extra dpkg-deb, ar or tar options are + needed, they are linked to internally. + ++config CONFIG_EMERGE ++ bool "emerge workalike for gentoo packages" ++ default n ++ depends on CONFIG_WGET && CONFIG_TBZ2PKG ++ help ++ This allows busybox to fetch and install binary packages ++ from the gentoo portage system. ++ + config CONFIG_GUNZIP + bool "gunzip" + default n +@@ -205,6 +213,13 @@ + help + Enable use of long options, increases size by about 400 Bytes + ++config CONFIG_TBZ2PKG ++ bool "tbz2pkg" ++ default n ++ depends on CONFIG_FEATURE_TAR_BZIP2 ++ help ++ Install and uninstall gentoo binary packages ++ + config CONFIG_UNCOMPRESS + bool "uncompress" + default n +diff -Nru --exclude=CVS --exclude=env.sh busybox-1.00/archival/Makefile.in busybox/archival/Makefile.in +--- busybox-1.00/archival/Makefile.in 2004-10-08 09:45:09.000000000 +0200 ++++ busybox/archival/Makefile.in 2005-04-02 18:02:27.000000000 +0200 +@@ -30,11 +30,13 @@ + ARCHIVAL-$(CONFIG_CPIO) += cpio.o + ARCHIVAL-$(CONFIG_DPKG) += dpkg.o + ARCHIVAL-$(CONFIG_DPKG_DEB) += dpkg_deb.o ++ARCHIVAL-$(CONFIG_EMERGE) += emerge.o gentoo_shared.o + ARCHIVAL-$(CONFIG_GUNZIP) += gunzip.o + ARCHIVAL-$(CONFIG_GZIP) += gzip.o + ARCHIVAL-$(CONFIG_RPM2CPIO) += rpm2cpio.o + ARCHIVAL-$(CONFIG_RPM) += rpm.o + ARCHIVAL-$(CONFIG_TAR) += tar.o ++ARCHIVAL-$(CONFIG_TBZ2PKG) += tbz2pkg.o gentoo_shared.o + ARCHIVAL-$(CONFIG_UNCOMPRESS) += uncompress.o + ARCHIVAL-$(CONFIG_UNZIP) += unzip.o + +diff -Nru --exclude=CVS --exclude=env.sh busybox-1.00/archival/emerge.c busybox/archival/emerge.c +--- busybox-1.00/archival/emerge.c 1970-01-01 01:00:00.000000000 +0100 ++++ busybox/archival/emerge.c 2005-06-08 20:17:34.000000000 +0200 +@@ -0,0 +1,768 @@ ++/* ++* Distributed under the terms of the GNU General Public License v2 ++* $Header: /home/collar_b/programs/cvs/busybox/archival/emerge.c,v 1.27 2005/06/08 18:17:34 collar_b Exp $ ++* ++* emerge: a gentoo-emerge workalike for embedded systems, integrated ++* into the busybox suite ++* ++* Written by Benjamin Collar ++* Copyright (C) 2005, Benjamin Collar ++* ++******************************************************************** ++* This program is free software; you can redistribute it and/or ++* modify it under the terms of the GNU General Public License as ++* published by the Free Software Foundation; either version 2 of the ++* License, or (at your option) any later version. ++* ++* This program is distributed in the hope that it will be useful, but ++* WITHOUT 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. ++*/ ++ ++/* note about source code organization */ ++/* this file is organized like this: ++ * structs & other declarations ++ * generally useful stuff ++ * functions that start with do_ relate directly to an "action", ie a command ++ * helper functions for the do_ start with the _ ++ * functions that start with parse_ are used for processing the index file ++ * other things should hopefully be clear :) ++ */ ++ ++#include "busybox.h" ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "tbz2pkg.h" ++ ++#define file_exists(f) (access(f, R_OK) == 0) ++#define dir_exists(f) (access(f, R_OK) == 0) ++ ++ ++typedef struct pkg_info_s { ++ llist_t *packages; ++ package_t** searchable_packages; /* sorted pointers to package names; use bsearch to find them */ ++ int num_packages; /* length of searchable_packages array */ ++} pkg_info_t; ++ ++extern int wget_main(int argc, char **argv); ++configurables_t conf; ++int (*action) (const package_t*);/* this is the action we'll take, after handling cmdline, etc */ ++static pkg_info_t pkg_info; ++ ++/* some useful functions */ ++static int ++mkalldirs(char *dir) ++{ ++ return bb_make_directory(dir, -1, FILEUTILS_RECUR); ++} ++ ++static package_t* ++find_in_index (package_t* pkg) ++{ ++ void* result; ++ result = bsearch((void*) pkg, (const void*) pkg_info.searchable_packages, ++ pkg_info.num_packages, sizeof(package_t*), bfind_compare); ++ if (result) { ++ return (*(package_t**)result); ++ } ++ return 0; ++} ++ ++static int ++fetch_package(package_t* package) ++{ ++ /* using the package in package-name (which is category/package), figure ++ * out the actual package name and URL. Then fetch it. return 0 when it works. ++ */ ++ /* append the category/package to the binhost to create the url */ ++ ++ static char fullurl[GEM_PATH_MAX]; ++ static char target[GEM_PATH_MAX]; ++ static char pkgver[GEM_NAME_LEN*2+2]; ++ sprintf(pkgver, "%s-%s.tbz2", package->name, package->version); ++ if (!conf.pretend) { ++ sprintf(msg, "Fetching package %s/%s", package->category, pkgver); ++ einfo(msg); ++ } else { ++ sprintf(msg, "Would fetch %s/%s", package->category, pkgver); ++ einfo(msg); ++ return 0; ++ } ++ sprintf(target, "%s/All/", conf.pkgdir); ++ /* make sure the package download directory exists */ ++ if ( mkalldirs(target) != 0 ) ++ edie("Failed to create package download directory"); ++ /* check if package already exists; if so, return ok */ ++ strcat(target, pkgver); ++ if ( file_exists(target) ) { ++ sprintf(msg, "Package already fetched: %s", target); ++ einfo(msg); ++ /* further processing expects msg to contain path to downloaded file */ ++ /* REFACTOR THIS */ ++ strcpy(msg, target); ++ return 0; ++ } ++ sprintf(target, "%s/All/", conf.pkgdir); ++ /* is it correct that the package file will be in http://binhost/category/abc-1.2.3.tbz2 ? */ ++ sprintf(fullurl, "%s/%s/%s", conf.binhost, package->category, pkgver); ++ { ++ char *cmdline[] = { "wget", "-c", "-P", target, fullurl, 0 }; ++ pid_t child=fork(); ++ if ( child == 0 ) { ++ execvp("/proc/self/exe", cmdline); ++ } else { ++ int status, wgrval; ++ wait(&status); ++ if (WIFEXITED(status)) { ++ wgrval = WEXITSTATUS(status); ++ if (wgrval != 0) { ++ edie("Failed to fetch package"); ++ } else { ++ strcat(target, pkgver); ++ sprintf(msg, "Package saved to %s", target); ++ einfo(msg); ++ } ++ sprintf(msg, "%s/%s/%s", conf.pkgdir, package->category, pkgver); ++ if (symlink(target, msg) != 0 && errno != EEXIST) { ++ edie("Failed to symlink package into correct subdirectory"); ++ } ++ /* save targetdir into msg; another function will use it */ ++ strcpy(msg, target); ++ return 0; ++ } ++ } ++ } ++ return 1; ++} ++ ++static int ++do_fetch(const package_t * user_pkg) ++{ ++ llist_t* list; ++ package_t *dep_pkg, *index_pkg; ++ int rval=0; ++ index_pkg = user_pkg->index_pkg; ++ if (!index_pkg) { ++ eerror("Package not found in index, cannot fetch!"); ++ return 1; ++ } ++ list = index_pkg->depends; ++ while (list) { ++ dep_pkg = decode_namespec((char*) list->data); ++ dep_pkg->index_pkg = find_in_index(dep_pkg); ++ if (!dep_pkg->index_pkg) { ++ sprintf(msg, "Dependency %s for %s not found in index", ++ dep_pkg->name, user_pkg->name); ++ eerror(msg); ++ rval = 1; ++ } else { ++ rval = rval ? rval : do_fetch(dep_pkg); ++ } ++ free(dep_pkg); ++ list = list->link; ++ } ++ if (conf.pretend) { ++ sprintf(msg, "Would fetch package %s\n", user_pkg->name); ++ einfo(msg); ++ return 0; ++ } ++ return rval ? rval : fetch_package(index_pkg); ++} ++ ++static void ++do_info(void) ++{ ++ bb_printf("PKGDIR=%s\n", (conf.pkgdir == NULL) ? "" : conf.pkgdir); ++ bb_printf("PKG_DBDIR=%s\n", (conf.pkg_dbdir == NULL) ? "" : conf.pkg_dbdir); ++ bb_printf("PORTAGE_BINHOST=%s\n", ++ (conf.binhost == NULL) ? "" : conf.binhost); ++ bb_printf("PORTAGE_TMPDIR=%s\n", ++ (conf.tmpdir == NULL) ? "" : conf.tmpdir); ++ bb_printf("ROOT=%s\n", (conf.root == NULL) ? "" : conf.root); ++ bb_printf("INDEX_FILE=%s\n", (conf.index == NULL) ? "" : conf.index); ++} ++ ++static int do_merge(const package_t* p); ++ ++static int ++merge_should_install(package_t* p) ++{ ++ static package_t tmppkg; ++ int rval=0; ++ llist_t *installed, *t; ++ memcpy(&tmppkg, p, sizeof(package_t)); ++ tmppkg.modifier[0]='>'; ++ tmppkg.modifier[1]='='; ++ installed = find_package_on_disk(&tmppkg); ++ rval = installed == 0; ++ while (installed) { ++ t = installed->link; ++ free(installed); ++ installed = t; ++ } ++ return rval; ++} ++ ++static int ++merge_deps(package_t* p) ++{ ++ llist_t* list = p->depends; ++ package_t* dep_pkg=0; ++ int rval = 0; ++ sprintf(msg, "Merging dependencies of %s", p->name); ++ einfo(msg); ++ if (conf.debug) { print_pkg(p); } ++ while (list) { ++ dep_pkg = decode_namespec((char*) list->data); ++ if (strcmp(dep_pkg->category, "virtual") == 0) { ++ rval = rval ? 1 : 0; ++ sprintf(msg, "Can't do virtual dependencies yet. Please make sure %s/%s is installed", ++ dep_pkg->category, dep_pkg->name); ++ eerror(msg); ++ } else { ++ dep_pkg->index_pkg = find_in_index(dep_pkg); ++ if (!dep_pkg->index_pkg) { ++ rval = 1; ++ } else { ++ rval = rval ? 1 : do_merge(dep_pkg); ++ } ++ } ++ free(dep_pkg); ++ list = list->link; ++ } ++ einfo("Done merging dependencies"); ++ return rval; ++} ++ ++static int ++do_merge(const package_t* user_pkg) ++{ ++ package_t* index_pkg = user_pkg->index_pkg; ++ sprintf(msg, "Merging package %s", user_pkg->name); ++ einfo(msg); ++ if (!index_pkg) { ++ eerror("Package not found in index"); ++ return 1; ++ } ++ if (!merge_should_install(index_pkg)) { ++ sprintf(msg, "Package %s already up-to-date", user_pkg->name); ++ einfo(msg); ++ return 0; ++ } ++ if (merge_deps(index_pkg) != 0) { eerror("Failed to merge dependencies"); return 1; } ++ if (fetch_package(index_pkg) != 0) { eerror("Failed to fetch package"); return 1; } ++ ++ /* fetch puts the filename into msg, so give that to tbz2 */ ++ if (conf.pretend) { ++ sprintf(msg, "Would merge %s", user_pkg->name); ++ einfo(msg); ++ return 0; ++ } ++ if (tbz2_install_file(msg, &conf) <= 0) { eerror("Failed to install package"); return 1; } ++ sprintf(msg, "Package %s merged successfully", user_pkg->name); ++ einfo(msg); ++ return 0; ++} ++ ++static int ++do_unmerge(const package_t* user_pkg) ++{ ++ package_t* index_pkg = user_pkg->index_pkg, *installed_pkg=0; ++ int rval=0, should_free=0; ++ llist_t* installed_pkgs, *l; ++ if (!index_pkg) { ++ index_pkg = xmalloc(sizeof(package_t)); ++ memcpy(index_pkg, user_pkg, sizeof(package_t)); ++ sprintf(msg, "Unable to find package %s in index, continuing...", user_pkg->name); ++ should_free=1; ++ } ++ if (conf.pretend) { ++ sprintf(msg, "Would unmerge %s", user_pkg->name); ++ einfo(msg); ++ rval = 0; ++ } ++ installed_pkgs = find_package_on_disk(index_pkg); ++ if (!installed_pkgs) { ++ einfo("Nothing to unmerge"); ++ } ++ while (installed_pkgs) { ++ installed_pkg = (package_t*) installed_pkgs->data; ++ if (conf.pretend) { ++ sprintf(msg, "Would unmerge %s-%s", installed_pkg->name, ++ installed_pkg->version); ++ einfo(msg); ++ } else { ++ if (tbz2_unmerge(installed_pkg) <= 0) rval = 1; ++ if (rval==0) { ++ einfo("Unmerge successful"); ++ } else { ++ eerror("Unmerge failed!"); ++ } ++ } ++ ++ l = installed_pkgs->link; ++ free(installed_pkgs->data); ++ installed_pkgs = l; ++ } ++ if (should_free) ++ free(index_pkg); ++ return rval; ++} ++ ++static int ++do_query(const package_t* user_pkg) ++{ ++ einfo("Package query result\nQuery--"); ++ print_pkg(user_pkg); ++ if (!user_pkg->index_pkg) { ++ sprintf(msg, "Package not found in index: %s, continuing", user_pkg->name); ++ einfo(msg); ++ } else { ++ einfo("Found package in index"); ++ print_pkg(user_pkg->index_pkg); ++ } ++ { ++ llist_t *r, *l; ++ einfo("Checking for installed version"); ++ r = find_package_on_disk(user_pkg); ++ if (!r) { einfo("Not found"); } ++ while(r) { ++ einfo("Found installed package"); ++ print_pkg((package_t*)r->data); ++ l = r->link; ++ free(r->data); ++ r = l; ++ } ++ } ++ return 0; ++} ++ ++static int ++do_sync(const package_t* user_pkg) ++{ ++ eerror("Unable to sync"); ++ return 1; ++} ++ ++static int ++do_list(const package_t* user_pkg) ++{ ++ llist_t* r = find_package_on_disk(user_pkg), *l; ++ while (r) { ++ tbz2_list((package_t*)r->data); ++ l = r->link; ++ free(r->data); ++ r = l; ++ } ++ return 0; ++} ++ ++static int ++do_update(const package_t* user_pkg) ++{ ++ eerror("Unable to update"); ++ return 1; ++} ++ ++static int ++do_clean(const package_t* user_pkg) ++{ ++ eerror("Unable to clean"); ++ return 1; ++} ++ ++ ++/* parseargs and similar ilk */ ++/* busybox has their own funny getopt structure, which depends on bits... */ ++#define EMERGE_HELP (1<<0) ++#define EMERGE_DEBUG (1<<1) ++#define EMERGE_PRETEND (1<<2) ++#define EMERGE_VERBOSE (1<<3) ++#define EMERGE_FETCH (1<<4) ++#define EMERGE_USEPKGONLY (1<<5) ++#define EMERGE_UNMERGE (1<<6) ++#define EMERGE_QUERY (1<<7) ++#define EMERGE_INFO (1<<8) ++#define EMERGE_SYNC (1<<9) ++#define EMERGE_LIST (1<<10) ++#define EMERGE_UPDATE (1<<11) ++#define EMERGE_CLEAN (1<<12) ++ ++static struct option const emerge_long_options[] = { ++ {"help", 0, 0, 'h'}, ++ {"debug", 0, 0, 'd'}, ++ {"pretend", 0, 0, 'p'}, ++ {"verbose", 0, 0, 'v'}, ++ {"fetch", 0, 0, 'f'}, ++ {"usepkgonly", 0, 0, 'K'}, ++ {"unmerge", 0, 0, 'C'}, ++ {"query", 0, 0, 'q'}, ++ {"info", 0, 0, 'i'}, ++ {"sync", 0, 0, 's'}, ++ {"list", 0, 0, 'l'}, ++ {"update", 0, 0, 'u'}, ++ {"clean", 0, 0, 'c'}, ++ {"root", 1, 0, 'R'}, ++ {"index", 1, 0, 'I'}, ++ {"pkgdir", 1, 0, 'P'}, ++ {"tmpdir", 1, 0, 'T'}, ++ {"binhost", 1, 0, 'B'}, ++ {NULL, 0, NULL, 0} ++}; ++ ++#define OPTIONS_FLAGS "hdpvfKCqislucR:I:P:T:B:" ++static void ++parseargs(int argc, char *argv[]) ++{ ++ int optend; ++ unsigned long opt; ++ char *root=0, *pkgdir=0, *tmpdir=0, *binhost=0, *cindex=0; ++ package_t* tmppkg; ++ opterr = 0; ++ /* this complementaly only works if a conflict is specified in both directions, ++ thus f~q:q~f will block f & q from being specified together. that seems ++ pretty wrong to me */ ++ bb_opt_complementaly = "f~Cqisluc:i~pfKCqsluc:q~f"; ++ bb_applet_long_options = emerge_long_options; ++ ++ /* need to allocate these flags, not let bb do it! */ ++ /* need to allocate!! also, conf.index processing seems broken */ ++ root = pkgdir = tmpdir = binhost = 0; ++ opt = bb_getopt_ulflags(argc, argv, OPTIONS_FLAGS, ++ &root, &cindex, &pkgdir, &tmpdir, &binhost); ++ if (root != NULL) { ++ conf.root = xmalloc(strnlen(root, GEM_PATH_MAX)); ++ strncpy(conf.root, root, GEM_PATH_MAX); ++ } ++ if (pkgdir != NULL) { ++ conf.pkgdir = xmalloc(strnlen(pkgdir, GEM_PATH_MAX)); ++ strncpy(conf.pkgdir, pkgdir, GEM_PATH_MAX); ++ } ++ if (tmpdir != NULL) { ++ conf.tmpdir = xmalloc(strnlen(tmpdir, GEM_PATH_MAX)); ++ strncpy(conf.tmpdir, tmpdir, GEM_PATH_MAX); ++ } ++ if (binhost != NULL) { ++ conf.binhost = xmalloc(strnlen(binhost, GEM_NAME_LEN)); ++ strncpy(conf.binhost, binhost, GEM_NAME_LEN); ++ } ++ if (cindex != NULL) { ++ conf.index = xmalloc(strnlen(cindex, GEM_PATH_MAX)); ++ strncpy(conf.index, cindex, GEM_PATH_MAX); ++ } ++ ++ /* Check one and only one context option was given */ ++ /* this doesn't work... */ ++ if (opt & 0x80000000UL) { ++ bb_printf("conflict!\n"); ++ bb_show_usage(); ++ } ++ ++ if (opt & EMERGE_HELP) ++ bb_show_usage(); ++ ++ /* runtime-configuration */ ++ if (opt & EMERGE_DEBUG) ++ conf.debug = 1; ++ if (opt & EMERGE_PRETEND) ++ conf.pretend = 1; ++ if (opt & EMERGE_VERBOSE) ++ conf.verbose = 1; ++ if (opt & EMERGE_USEPKGONLY) ++ conf.usepkgonly = 1; ++ ++ /* actions */ ++ if (opt & EMERGE_INFO ++ || (argv[optind] && strncmp(argv[optind], "info", 4) == 0)) { ++ /* info: perform info, then exit */ ++ do_info(); ++ exit(0); ++ } else { ++ if (opt & EMERGE_FETCH) ++ action = do_fetch; ++ else if (opt & EMERGE_UNMERGE) ++ action = do_unmerge; ++ else if (opt & EMERGE_QUERY) ++ action = do_query; ++ else if (opt & EMERGE_SYNC) ++ action = do_sync; ++ else if (opt & EMERGE_LIST) ++ action = do_list; ++ else if (opt & EMERGE_UPDATE) ++ action = do_update; ++ else if (opt & EMERGE_CLEAN) ++ action = do_clean; ++ else ++ action = do_merge; ++ } ++ ++ /* this adds the remainder of the arguments (i.e. the packages) reversed, so they ++ are processed in the order specified (which may be important) */ ++ optend = argc - 1; ++ ++ while (optend >= optind) { ++ if (strnlen(argv[optend], GEM_NAME_LEN) == GEM_NAME_LEN) { ++ snprintf(msg, GEM_NAME_LEN, "Name too long: %s", argv[optend]); ++ edie(msg); ++ } ++ tmppkg = decode_namespec(argv[optend]); ++ if (!tmppkg) { ++ snprintf(msg, GEM_NAME_LEN, "Unable to decode name %s", argv[optend]); ++ edie(msg); ++ } ++ tmppkg->index_pkg=0; ++ conf.packages = llist_add_to(conf.packages, (char *)tmppkg); ++ optend--; ++ ++conf.num_packages; ++ } ++} ++ ++/* all the functions that start with parse_ are for parsing the Index file */ ++static void ++parse_pkgname_version(package_t* pkg) ++{ ++ int i = 0; char *c; ++ while (msg[i] != ' ' && i < GEM_MLEN) ++i; ++ ++i; ++ if (i >= GEM_MLEN) edie("overflow!"); ++ c = &msg[i]; ++keep_looking: ++ while (msg[i] != '-' && i < GEM_MLEN) ++i; ++ ++i; ++ if (i >= GEM_MLEN) edie("overflow looking for version"); ++ if (!isdigit(msg[i])) goto keep_looking; ++ strncpy(pkg->name, c, i-5); ++ c = &msg[i]; ++ strncpy(pkg->version, c, GEM_NAME_LEN); ++ i = strnlen(c, GEM_NAME_LEN); ++ pkg->version[i-1]=0; ++} ++ ++static void ++parse_category(package_t* pkg) ++{ ++ /* CATEGORY: sys-kernel */ ++ int i = 0; char *c; ++ while (msg[i] != ' ') ++i; ++ ++i; ++ c = &msg[i]; ++ i = strnlen(c, GEM_NAME_LEN); ++ c[i-1]=0; ++ strncpy(pkg->category, c, i-1); ++} ++ ++static void ++parse_depend_line(package_t* pkg, char* m) ++{ ++ /* just strchr our way through it--> use m, not msg! */ ++ char *c, *d, *i=m; ++ do { ++ c = strchr(i, ' '); ++ if (c != NULL) { ++ d = xmalloc(c-i+1); ++ if (d == NULL) edie("failed to alloc space for depend"); ++ strncpy(d, i, c-i); ++ pkg->depends = llist_add_to(pkg->depends, d); ++ ++c; i = c; ++ } ++ } while (c != NULL); ++ /* do the last one too */ ++ d = xmalloc(strlen(i)+1); ++ strcpy(d, i); ++ pkg->depends = llist_add_to(pkg->depends, d); ++ ++} ++ ++/* this is out in static-land because both parse_depends and parse_line need to use it */ ++static FILE *index_file; ++static void ++parse_depends(package_t* pkg) ++{ ++ int saw_end_of_line = 0, len; ++ char *m, *l; ++ static char tmp[GEM_NAME_LEN]; ++ /* skip over the RDEPEND: part */ ++ if ((m = strchr(msg, ':')) == NULL) edie("No RDEPEND?"); ++ ++m; ++m; ++ while (!saw_end_of_line) { ++ len = strnlen(msg, GEM_MLEN); ++ /* it's ok to use msg here ... */ ++ if (msg[len-1] == '\n') { ++ saw_end_of_line = 1; ++ msg[len-1]=0; /* cut that end of line off */ ++ /* but parsing the line parses on m */ ++ parse_depend_line(pkg, m); ++ } else { ++ /* also ok here */ ++ l = rindex(msg, ' '); /* space before the last word */ ++ ++l; ++ strncpy(tmp, l, GEM_NAME_LEN); /* len - l ? */ ++ --l; *l=0; /* now the line parser can't see the partial word */ ++ parse_depend_line(pkg, m); ++ strncpy(msg, tmp, GEM_NAME_LEN); /* now msg has the partial word */ ++ len = strnlen(msg, GEM_NAME_LEN); ++ l = &msg[len]; ++ if (fgets(l, GEM_MLEN-len, index_file) == NULL) edie("unexpect end of file (deps"); ++ /* msg doesn't have RDEPEND anymore, so parse at beginning of msg */ ++ m = &msg[0]; ++ } ++ } ++} ++ ++static int ++parse_line(package_t* pkg) ++{ /* must return 1 when the whole package is ready, otherwise 0 (or edie()) */ ++ /* fortunately, the lines in each section have totally distinct beginnings! */ ++ if (msg[0] == '\n') return 0; ++ if (msg[0] == 'P') parse_pkgname_version(pkg); ++ else if (msg[0] == 'C' && msg[1] == 'A') parse_category(pkg); ++ else if (msg[0] == 'C' && msg[1] == 'H') return 0; /* parse_chost(pkg); */ ++ else if (msg[0] == 'L') return 0; /* parse_license(pkg); */ ++ else if (msg[0] == 'C' && msg[1] == 'F') return 0; /* parse_cflags(pkg); */ ++ else if (msg[0] == 'R') parse_depends(pkg); ++ else if (msg[0] == 'U') return 0; /* parse_use(pkg); */ ++ /* size is the very last entry, so it will return 1 */ ++ else if (msg[0] == 'S') return 1; /* parse_size(pkg); */ ++ else { edie("unexpected data in index file"); } ++ return 0; ++} ++ ++static int ++process_index(void) ++{ ++ package_t *pkg = 0; ++ ++ if ((index_file = bb_xfopen(conf.index, "r")) == 0) ++ edie("Failed to open index file"); ++ if (conf.debug) einfo("*** *** Processing index file"); ++ ++ while (feof(index_file) != 1) { ++ /* can we get a line? */ ++ if (fgets(msg, GEM_MLEN, index_file) != NULL) { ++ /* do we have a package? */ ++ if (!pkg) { ++ pkg = (package_t*) malloc(sizeof(package_t)); ++ memset(pkg, 0, sizeof(package_t)); ++ } ++ /* is the pkg already complete? */ ++ if (parse_line(pkg)==1) { ++ /* finish package! */ ++ if (conf.verbose) ++ print_pkg(pkg); ++ pkg_info.packages = llist_add_to(pkg_info.packages, (char *) pkg); ++ pkg = 0; ++ ++pkg_info.num_packages; ++ } ++ } ++ } ++ if (ferror(index_file) != 0) { ++ edie("encountered error while processing index file"); ++ } ++ if (bb_fclose_nonstdin(index_file) != 0) return 1; ++ if (conf.debug) { einfo("*** *** Done processing index file"); } ++ return 0; ++} ++ ++int ++emerge_main(int argc, char **argv) ++{ ++ char tmpp[GEM_PATH_MAX]; ++ unsigned int len; int i; ++ llist_t *tp; ++ package_t *package = 0; ++ ++ if (argc < 2) ++ bb_show_usage(); ++ ++ conf.verbose = 0; ++ conf.debug = 0; ++ conf.pretend = 0; ++ conf.usepkgonly = 0; ++ conf.packages = 0; ++ conf.num_packages = 0; ++ conf.index = 0; ++ ++ /* command line overrides env vars. */ ++ conf.pkgdir = getenv("PKGDIR"); ++ conf.binhost = getenv("PORTAGE_BINHOST"); ++ conf.tmpdir = getenv("PORTAGE_TMPDIR"); ++ conf.root = getenv("ROOT"); ++ conf.index = getenv("INDEX_FILE"); ++ conf.pkg_dbdir = getenv("PKG_DBDIR"); ++ ++ parseargs(argc, argv); ++ ++ /* now configurations may have some items, and some not. function may exit */ ++#undef FOO ++#define FOO "Try adding it to your /etc/make.conf, exporting it as an environment variable, or specifying it on the command line" ++ /* verify that environment variables exist before going on, fix them on disk if necessary */ ++ if (conf.pkgdir == 0) ++ edie("PKGDIR is not set. " FOO); ++ if (conf.binhost == 0) ++ edie("PORTAGE_BINHOST is not set. " FOO); ++ if (conf.tmpdir == 0) ++ edie("PORTAGE_TMPDIR is not set. " FOO); ++ if (conf.root == 0) ++ edie("ROOT is not set. " FOO); ++ if (conf.index == 0) ++ edie("INDEX is not set. " FOO); ++#undef FOO ++ (void) tbz2pkg_init(&conf); ++ ++ ++ /* make sure PKGDIR exists on disk */ ++ len = strnlen(conf.pkgdir, GEM_PATH_MAX); ++ memset(tmpp, 0, sizeof(tmpp)); ++ strncpy(tmpp, conf.pkgdir, len); ++ strncat(tmpp, "/All", GEM_PATH_MAX - 1 - len); ++ if (!dir_exists(tmpp)) /* dir_exists checks R_OK, not W_OK...fix that later! */ ++ if (mkalldirs(tmpp) != 0) ++ edie("FAILED to make PKGDIR/All"); ++ ++ /* that's all for configuration; let's parse out the index */ ++ pkg_info.searchable_packages=0; ++ pkg_info.num_packages=0; ++ process_index(); ++ ++ pkg_info.searchable_packages = ++ (package_t**) xmalloc(pkg_info.num_packages*sizeof(package_t*)); ++ tp = pkg_info.packages; ++ for (i = 0; i < pkg_info.num_packages; ++i) { ++ pkg_info.searchable_packages[i] = (package_t*) tp->data; ++ tp = tp->link; ++ } ++ ++ /* now we are all set up. perform the action */ ++ tp = conf.packages; ++ while (tp != 0) { ++ package = (package_t*)tp->data; ++ if (conf.debug) { ++ bb_printf("handling package:\n"); ++ print_pkg(package); ++ } ++ package->index_pkg=find_in_index(package); ++ if (action(package) != 0) { ++ sprintf(msg, "Failed on package %s", package->name); ++ edie(msg); ++ } ++ package = 0; ++ tp = tp->link; ++ } ++ ++ exit(EXIT_SUCCESS); ++} +diff -Nru --exclude=CVS --exclude=env.sh busybox-1.00/archival/gentoo_shared.c busybox/archival/gentoo_shared.c +--- busybox-1.00/archival/gentoo_shared.c 1970-01-01 01:00:00.000000000 +0100 ++++ busybox/archival/gentoo_shared.c 2005-06-08 19:46:32.000000000 +0200 +@@ -0,0 +1,297 @@ ++/* ++* Distributed under the terms of the GNU General Public License v2 ++* $Header: /home/collar_b/programs/cvs/busybox/archival/gentoo_shared.c,v 1.10 2005/06/08 17:46:32 collar_b Exp $ ++* ++* gentoo_shared: functions that are used by both emerge.c and tbz2pkg.c ++* reason: emerge.c can depend (Config.on) on tbz2pkg, but not the other ++* direction too. ++* ++* Written by Benjamin Collar & Natanael Copa ++* Copyright (C) 2005, Benjamin Collar, Natanael Copa ++* ++******************************************************************** ++* This program is free software; you can redistribute it and/or ++* modify it under the terms of the GNU General Public License as ++* published by the Free Software Foundation; either version 2 of the ++* License, or (at your option) any later version. ++* ++* This program is distributed in the hope that it will be useful, but ++* WITHOUT 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 "gentoo_shared.h" ++#include ++ ++char msg[GEM_MLEN]; /* useful for einfo, etc--just a buffer */ ++ ++void ++einfo(char *str) ++{ ++ bb_fprintf(stdout, ">>> %s\n", str); ++} ++ ++void ++eerror(char *str) ++{ ++ bb_fprintf(stderr, "!!! %s\n", str); ++} ++ ++void ++edie(char *str) ++{ ++ eerror(str); ++ bb_error_msg_and_die("Quitting..."); ++} ++ ++extern configurables_t conf; ++ ++void ++print_pkg(const package_t* pkg) ++{ ++ llist_t* d=pkg->depends; ++ bb_printf("Name: %s\n", pkg->name); ++ bb_printf("Version: %s\n", pkg->version); ++ bb_printf("Category: %s\n", pkg->category); ++ if (conf.debug) { ++ bb_printf("Modifiers: %s\n", pkg->modifier); ++ } ++ bb_printf("Depends: \n"); ++ while (d) { ++ bb_printf(" %s\n", d->data); ++ d = d->link; ++ } ++ bb_printf("\n"); ++} ++ ++int ++bfind_compare(const void* key, const void* try) ++{ ++ const package_t* query = (const package_t*) key; ++ const package_t **potential = (const package_t**) try; ++ int match=0; ++ match = strcmp(query->name, (*potential)->name); ++ if (match == 0) { ++ if (conf.debug) { bb_printf("got a name match...\n"); } ++ /* if the names match, check that we're in the same cateogry */ ++ if (query->category[0]) { ++ match = strcmp(query->category, (*potential)->category); ++ if (match != 0) { ++ /* category doesn't match -- need resolution from user*/ ++ sprintf(msg, "Found package name in multiple categories: (given) %s, (found)" ++ " %s Please resolve manually with emerge ... category/package\n", ++ query->category, (*potential)->category); ++ edie(msg); ++ } ++ if (conf.debug) { bb_printf("got a category match\n"); } ++ /* if category does match, check version */ ++ } ++ if (query->version[0]) { ++ match = strcmp(query->version, (*potential)->version); ++ if (query->modifier[0]) { ++ if (conf.debug) ++ bb_printf("modifier processing engaged!\n"); ++ if (query->modifier[1] == '=' && match == 0) goto stop; ++ if (query->modifier[0] == '=' && match == 0) goto stop; ++ if (query->modifier[0] == '>' && match == -1) { match = 0; goto stop; } ++ if (query->modifier[0] == '<' && match == 1) { match = 0; goto stop; } ++ } ++ if (conf.debug && match == 0) bb_printf("got version match\n"); ++ } ++ } ++stop: ++ if (conf.debug) { ++ bb_printf("compare result %d for\n", match); ++ print_pkg(query); ++ print_pkg(*potential); ++ } ++ return match; ++} ++ ++typedef struct pkgsearch { ++ llist_t* results; ++ const package_t* package; ++} pkgsearch_t; ++ ++int ++findPkgVerAction(const char* fileName, struct stat* statbuf, void* userData) ++{ ++ pkgsearch_t* sch = (pkgsearch_t*) userData; ++ package_t* result; ++ char *basec, *bname, *begin, *dirc, *dname; ++ int retval=0, cmp; ++ static char version[GEM_NAME_LEN]; ++ if (conf.debug) bb_printf("checking for pkg/version, got %s\n", fileName); ++ version[0]=0; ++ basec = strdup(fileName); ++ bname = basename(basec); ++ if (strstr(bname, sch->package->name) != bname) { ++ free(basec); ++ return 1; ++ } ++ /* get version from fileName */ ++ begin = bname; ++ while (*begin != 0) { ++ if (*begin == '-') { ++ ++begin; ++ if (isdigit(*begin)) { ++ strcpy(version, begin); ++ break; ++ } ++ } else { ++ ++begin; ++ } ++ } ++ cmp = strcmp(version, sch->package->version); ++ if ( ++ (sch->package->modifier[1] == '=' && cmp == 0) || ++ (sch->package->modifier[0] == '<' && cmp == -1) || ++ (sch->package->modifier[0] == '>' && cmp == 1) || ++ (sch->package->modifier[0] == '>' && cmp == 1) || ++ (!sch->package->modifier[0]) /* && cmp == 0) */ ++ ) ++ { ++ result = xmalloc(sizeof(package_t)); ++ memset(result, 0, sizeof(package_t)); ++ /* we can copy the given package, as long as we clear the modifiers */ ++ memcpy(result, sch->package, sizeof(package_t)); ++ result->modifier[0]=0; result->modifier[1]=0; ++ strcpy(result->version, version); ++ strcpy(result->disk_location, fileName); ++ if (conf.debug) { bb_printf("found disk entry %s", result->disk_location); } ++ /* get the directory name == category */ ++ dirc = strdup(fileName); ++ dname = dirname(dirc); ++ free(basec); ++ basec = strdup(dname); ++ bname = basename(basec); ++ strcpy(result->category, bname); ++ if (conf.debug) { bb_printf("found disk package \n"); print_pkg(result); } ++ free(dirc); ++ sch->results = llist_add_to(sch->results, (char*) result); ++ retval = 0; ++ } else { ++ retval = 1; ++ } ++ ++ free(basec); ++ return retval; ++ ++} ++ ++/* the result* list for this function is a (single) directory name--the one that matches! */ ++int ++findCatAction(const char* fileName, struct stat* statbuf, void* userData) ++{ ++ pkgsearch_t* sch = (pkgsearch_t*) userData; ++ char *basec, *bname; ++ int retval; ++ if (conf.debug) bb_printf("checking for category, got %s\n", fileName); ++ basec = strdup(fileName); ++ bname = basename(basec); ++ if (strcmp(bname, sch->package->category) == 0) { ++ /* this is our man */ ++ /* recur from here into pkgs directory, look for right name (only 1) */ ++ recursive_action(fileName, 1, 0, 0, 0, findPkgVerAction, userData); ++ retval=0; ++ } else { ++ retval=1; ++ } ++ free(basec); ++ return retval; ++} ++ ++llist_t* ++find_package_on_disk(const package_t* package) ++{ ++/* int recursive_action(const char *fileName, int recurse, ++ int followLinks, int depthFirst, ++ int (*fileAction) (const char *fileName, struct stat* statbuf, void* userData), ++ int (*dirAction) (const char *fileName, struct stat* statbuf, void* userData), ++ void* userData); ++*/ ++ static pkgsearch_t ps; ps.results=0; ps.package=package; ++ if (!*package->category) ++ recursive_action(conf.pkg_dbdir, 1, 0, 0, 0, findPkgVerAction, (void*) &ps); ++ else ++ recursive_action(conf.pkg_dbdir, 1, 0, 0, 0, findCatAction, (void*) &ps); ++ return ps.results; ++} ++ ++package_t* ++decode_namespec(char* namespec) ++{ ++ /* on the command line or in the Package-depends, the form of a specification is ++ * emerge abc ++ * cat/abc ++ * >=cat/abc-1.3.4.5 ++ * this function has to split all that up and return a new package_t (in char form) ++ */ ++ package_t* ret = xmalloc(sizeof(package_t)); ++ char *slash, *begin, first = namespec[0]; ++ int provided_modifiers=0, provided_category=0; ++ memset(ret, 0, sizeof(package_t)); ++ if (conf.debug) { sprintf(msg, "decoding namespec %s\n", namespec); einfo(msg); } ++ switch (first) { ++ case '>': case '<': case '=': case '!': ++ { ++ /* handle modifiers */ ++ provided_modifiers=1; ++ ret->modifier[0]=first; ++ first = namespec[1]; ++ if (first == '>' || first == '<' || first == '=' || first == '!') { ++ ret->modifier[1] = first; ++ begin = &namespec[2]; ++ } else { ++ begin = &namespec[1]; ++ } ++ break; ++ } ++ default: ++ begin = &namespec[0]; ++ } ++ /* is there a slash (and thus a category & name?) */ ++ /* process category */ ++ if ((slash = strchr(begin, '/')) != 0) { ++ /* we have a slash, so there must be a category */ ++ provided_category=1; ++ *slash = 0; ++ strcpy(ret->category, begin); ++ ++slash; ++ begin = slash; ++ } else { ++ slash = begin; ++ } ++ /* process name & version */ ++ while (*begin != 0) { ++ if (*begin == '-') { ++ ++begin; ++ if (isdigit(*begin)) { ++ strcpy(ret->version, begin); ++ --begin; ++ *begin = 0; ++ break; ++ } else { ++ continue; ++ } ++ } ++ ++begin; ++ } ++ strcpy(ret->name, slash); ++ if (conf.debug) { ++ bb_printf("Decoded namespec to \n"); ++ print_pkg(ret); ++ } ++ if (provided_modifiers && !provided_category) { ++ sprintf(msg, "If you use =!<>, you must specify category/app. error: %s", namespec); ++ edie(msg); ++ } ++ ++ return ret; ++} +diff -Nru --exclude=CVS --exclude=env.sh busybox-1.00/archival/gentoo_shared.h busybox/archival/gentoo_shared.h +--- busybox-1.00/archival/gentoo_shared.h 1970-01-01 01:00:00.000000000 +0100 ++++ busybox/archival/gentoo_shared.h 2005-06-08 20:16:26.000000000 +0200 +@@ -0,0 +1,83 @@ ++/* ++* Distributed under the terms of the GNU General Public License v2 ++* $Header: /home/collar_b/programs/cvs/busybox/archival/gentoo_shared.h,v 1.8 2005/06/08 17:46:32 collar_b Exp $ ++* ++* stuff that is shared between emerge.c and tbz2pkg.c ++* ++* Written by Benjamin Collar ++* Copyright (C) 2005, Benjamin Collar ++* ++******************************************************************** ++* This program is free software; you can redistribute it and/or ++* modify it under the terms of the GNU General Public License as ++* published by the Free Software Foundation; either version 2 of the ++* License, or (at your option) any later version. ++* ++* This program is distributed in the hope that it will be useful, but ++* WITHOUT 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 GENTOO_SHARED_H ++#define GENTOO_SHARED_H ++ ++#include "busybox.h" ++#include ++#include ++ ++#define GEM_PATH_MAX (PATH_MAX) ++#define GEM_NAME_LEN (32) ++#define GEM_MLEN (GEM_PATH_MAX+64) ++ ++typedef struct configurables_s { ++ char *root; ++ char *index; ++ char *tmpdir; ++ char *binhost; ++ char *pkgdir; ++ char *pkg_dbdir; /* used by tbz2pkg only */ ++ char *install_mask; /* used by tbz2pkg only */ ++ int verbose; ++ int debug; ++ int pretend; ++ int usepkgonly; ++ llist_t *packages; /* the package-names given on the command line */ ++ int num_packages; /* the number of package-names given */ ++} configurables_t; ++ ++ ++typedef struct package_s { ++ llist_t *depends; ++ struct package_s* index_pkg; ++ char modifier[3]; /* things like >=, =, !, ~, etc that portage uses */ ++ char version[GEM_NAME_LEN]; ++ char category[GEM_NAME_LEN]; ++ char name[GEM_NAME_LEN]; ++ char disk_location[GEM_PATH_MAX]; ++} package_t; ++ ++ ++extern char msg[GEM_MLEN]; /* useful for einfo, etc--just a buffer */ ++void einfo(char* s); /* write some info, emerge style */ ++void eerror(char* s); /* write an error, emerge style */ ++void edie(char* s); /* write the error, then exit */ ++ ++/* use this function to bsearch the pkg_info.packages array (all packages in index) ++ * or to just compare two package_t's ++ * key is a package_t* you are searching for, try is package_t** -- a possible match ++ * this function is used in bsearch, but may also be used to compare two package_t's; ++ * it returns -1,0,1 as one would expect */ ++int bfind_compare(const void* key, const void* try); ++void print_pkg(const package_t* pkg); ++package_t* decode_namespec(char* namespec); ++/* finds an installed package (or multiple, if modifiers are used) */ ++llist_t* find_package_on_disk(const package_t* package); ++ ++ ++#endif +diff -Nru --exclude=CVS --exclude=env.sh busybox-1.00/archival/tbz2pkg.c busybox/archival/tbz2pkg.c +--- busybox-1.00/archival/tbz2pkg.c 1970-01-01 01:00:00.000000000 +0100 ++++ busybox/archival/tbz2pkg.c 2005-06-08 20:17:34.000000000 +0200 +@@ -0,0 +1,945 @@ ++/* ++ * tbz2pkg, an installer for gentoo binary packages (tbz2) ++ * $Header: /home/collar_b/programs/cvs/busybox/archival/tbz2pkg.c,v 1.13 2005/06/08 18:17:34 collar_b Exp $ ++ * ++ * Written by Natanael Copa ++ * Copyright (C) 2005 by Natanael Copa ++ * Extended by Benjamin Collar ++ * Parts Copyright (C) 2005 by Benjamin Collar ++ * ++ * Distributed under the terms of the GNU General Public License v2 ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License as ++ * published by the Free Software Foundation; either version 2 of the ++ * License, or (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, but ++ * WITHOUT 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 "busybox.h" ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include ++#include ++#include ++ ++#include "tbz2pkg.h" ++ ++ ++#define BUFSIZE 32768 ++#define PREBUFSIZE 7 ++ ++/* if BUFSIZE is smaller than XPACKSIZE, strange things could happen */ ++#if (XPAKSIZE >= BUFSIZE) ++#error BUFSIZE must be bigger than XPAKSIZE ++#endif ++ ++#define INDEX_LEN_OFFSET 8 ++#define DATA_LEN_OFFSET (INDEX_LEN_OFFSET + 4) ++#define INDEX_OFFSET (DATA_LEN_OFFSET + 4) ++ ++/* if the XPAK is bigger than 8MiB, something is wrong */ ++#define FAR_TOO_BIG_XPAK (8192 * 1024) ++ ++#define CHECKSUM_ALGO HASH_SHA1 ++ ++typedef struct xpak_s { ++ char *buffer; /* the raw xpak buffer */ ++ int size; ++ int index_len; ++ int data_len; ++ int data_offset; ++} xpak_t; ++ ++static configurables_t *conf; ++static char prebuf[PREBUFSIZE]; ++static int presize=0; /* how much is in the prebuf? */ ++static char root_dbdir[256]; ++static char root_dbdir_pkg[256]; ++static char root_dbdir_pkg_contents[256]; ++ ++static struct option const tbz2pkg_long_options[] = { ++ {"debug", 0, 0, 'd'}, ++ {"help", 0, 0, 'h'}, ++ {"install", 0, 0, 'i'}, ++ {"install-mask", 1, 0, 'M'}, ++ {"list", 0, 0, 'L'}, ++ {"pretend", 0, 0, 'p'}, ++ {"purge", 0, 0, 'P'}, ++ {"root", 1, 0, 'R'}, ++ {"verbose", 0, 0, 'v'}, ++ {NULL, 0, NULL, 0} ++}; ++ ++#define TBZ2PKG_DEBUG (1<<0) ++#define TBZ2PKG_HELP (1<<1) ++#define TBZ2PKG_INSTALL (1<<2) ++#define TBZ2PKG_INSTALL_MASK (1<<3) ++#define TBZ2PKG_LIST (1<<4) ++#define TBZ2PKG_PRETEND (1<<5) ++#define TBZ2PKG_PURGE (1<<6) ++#define TBZ2PKG_ROOT (1<<7) ++#define TBZ2PKG_VERBOSE (1<<8) ++ ++ ++#define OPTIONS_FLAGS "dhiM:LpPR:v" ++ ++ ++configurables_t *tbz2pkg_init(configurables_t *myconf) { ++ snprintf(root_dbdir, sizeof(root_dbdir), "%s", myconf->pkg_dbdir); ++ return conf = myconf; ++} ++ ++char *set_dbdir_pkg_char(const char *pkg) { ++ snprintf(root_dbdir_pkg, sizeof(root_dbdir_pkg), "%s/%s", root_dbdir, pkg); ++ strncpy(root_dbdir_pkg_contents, root_dbdir_pkg, ++ sizeof(root_dbdir_pkg_contents)); ++ strncat(root_dbdir_pkg_contents, "/CONTENTS", ++ sizeof(root_dbdir_pkg_contents)); ++ return root_dbdir_pkg; ++} ++ ++char *set_dbdir_pkg(package_t *pkg) { ++ snprintf(root_dbdir_pkg, sizeof(root_dbdir_pkg), "%s", pkg->disk_location); ++ strncpy(root_dbdir_pkg_contents, root_dbdir_pkg, ++ sizeof(root_dbdir_pkg_contents)); ++ strncat(root_dbdir_pkg_contents, "/CONTENTS", ++ sizeof(root_dbdir_pkg_contents)); ++ return root_dbdir_pkg; ++} ++ ++/* ++ convert a 4 byte big endian to int ++*/ ++static int decodeint(const unsigned char *ptr) { ++ return (((int)ptr[0]) << 24) + (((int)ptr[1]) << 16) ++ + (((int)ptr[2]) << 8) + ((int)ptr[3]); ++} ++ ++ ++ ++/* ++ return a string with the absolute path. ++*/ ++char *mk_absolute_path(const char *path) { ++ static char fullpath[256]; /* maximun length of path */ ++ if (strncmp(path, "./", 2) == 0) ++ snprintf(fullpath, sizeof(fullpath), "%s%s", conf->root, path+1); ++ else ++ snprintf(fullpath, sizeof(fullpath), "%s%s%s", ++ conf->root, (path[0] != '/') ? "/" : "", path); ++ return fullpath; ++} ++ ++ ++/* Creates a full path from a dbfile in the pkgdb */ ++char *mk_dbdir_path(const char *package, const char *dbfile) { ++ static char path[256]; ++ snprintf(path, sizeof(path), "%s/%s/%s", ++ mk_absolute_path(conf->pkg_dbdir), package, dbfile); ++ return path; ++} ++ ++/* ++ finds the specified index and returns the value in a allocated buffer ++*/ ++static char *xpak_get_data(const xpak_t *xpak, const char *key) { ++ int len; ++ int offset=INDEX_OFFSET; ++ char *pathname; ++ while (offset < xpak->index_len) { ++ if (offset + 4 > xpak->size) ++ bb_error_msg_and_die("xpak_get_data: problems with XPAK"); ++ len = decodeint(xpak->buffer + offset); ++ ++ /* pathname_len + pathname + data_offset + data_len */ ++ if (offset + 4 + len + 4 + 4 > xpak->size) ++ return NULL; ++ pathname = bb_xstrndup(xpak->buffer + offset + 4, len); ++ if (strcmp(pathname, key) == 0) { ++ int data_offset = decodeint(xpak->buffer + offset + 4 + len); ++ int data_len = decodeint(xpak->buffer + offset + 8 + len); ++ char *p = xmalloc(data_len+1); ++ if (data_offset >= 0 && ((data_offset + data_len) < xpak->size)) { ++ memcpy(p, xpak->buffer + xpak->data_offset + data_offset, ++ data_len); ++ p[data_len] = '\0'; ++ free(pathname); ++ return(p); ++ } else { ++ bb_error_msg_and_die("xpak_get_data: data_offset=%i, " ++ "data_offset+data_len=%i, xpak->size=%i", ++ data_offset, data_offset + data_len, ++ xpak->size); ++ } ++ } ++ free(pathname); ++ offset += 12 + len; ++ } ++ /* not found */ ++ return NULL; ++} ++ ++/* ++ allocate space for xpak->buffer and get the rest of the data stream ++ memory is allocated and pointer is stored in global variable xpak. ++ ++ returns the size of xpak or -1 on error. ++*/ ++int get_xpak(int src_fd, xpak_t *xpak, const char *restbuf, size_t restsize) { ++ static char readbuf[BUFSIZE]; ++ int total = restsize; ++ int numread; ++ ++ xpak->buffer = xmalloc(restsize); ++ memcpy(xpak->buffer, restbuf, restsize); ++ ++ /* dump the rest of the data */ ++ while((numread = read(src_fd, readbuf, BUFSIZE))) { ++ char *p; ++ p = xrealloc(xpak->buffer, total + numread); ++ xpak->buffer = p; ++ memcpy(xpak->buffer + total, readbuf, numread); ++ total += numread; ++ /* check that the XPAK is not unreasonable big */ ++ if (total > FAR_TOO_BIG_XPAK) { ++ bb_error_msg_and_die("XPAK is unreasonable big. Giving up."); ++ } ++ } ++ xpak->size = total - 8; /* we skip the trailing [4 byte offset]STOP */ ++ if (xpak->size < (INDEX_OFFSET + 8)) { /* the +8 is for the "XPAKSTOP" */ ++ /* something is definitively wrong */ ++ free(xpak->buffer); ++ xpak->buffer = NULL; ++ return -1; ++ } ++ ++ xpak->index_len = decodeint(xpak->buffer + INDEX_LEN_OFFSET); ++ xpak->data_len = decodeint(xpak->buffer + DATA_LEN_OFFSET); ++ xpak->data_offset = INDEX_OFFSET + xpak->index_len; ++ if (xpak->data_offset + xpak->data_len + 8 > xpak->size) { ++ /* we are out of buffer */ ++ free(xpak->buffer); ++ xpak->buffer=NULL; ++ return -1; ++ } ++ return xpak->size; ++} ++ ++/* ++ flush buffer to file ++*/ ++int flush_buf(const char *buf, int size, const char *filename) { ++ FILE *outfile; ++ int written; ++ outfile = bb_xfopen(filename, "w"); ++ written = fwrite(buf, 1, size, outfile); ++ bb_fclose_nonstdin(outfile); ++ return written; ++} ++ ++/* ++ read data from src_fd until we find a "XPAKPACK" string ++ returns numbers of byte available in buffer ++*/ ++int read_to_xpak(int src_fd, char *buf, size_t size, xpak_t *xpak) { ++ int n; ++ int count, rest, avail; ++ char *p=buf; ++ char *found = NULL; ++ ++ memcpy(buf, prebuf, presize); ++ n = size - presize; /* this is what we want to read */ ++ assert(n>0); ++ if ((count = bb_xread(src_fd, buf+presize, n) + presize) == 0) { ++ /* we are done reading from file. no more data */ ++ return 0; ++ } ++ presize=0; ++ avail=count; ++ rest=count; ++ while( ((p=memchr(p, 'X', rest)) != NULL) && (found == NULL) && rest) { ++ avail = p - buf; /* data available in buffer that is guaranteed to ++ not contain "XPAKPACK" */ ++ rest = count - avail; /* the amount of data we need to examine */ ++ if ( rest < PREBUFSIZE ) { ++ /* ++ we found 'X' but we don't have enough data left to check ++ the entire string. We save the data in prebuf for next read ++ */ ++ memcpy(prebuf, p, rest); ++ presize=rest; ++ return avail; ++ } ++ ++ if (strncmp(p, "XPAKPACK", rest)==0) { ++ /* ok guy's, we found the XPAKPACK */ ++ found=p; ++ if (get_xpak(src_fd, xpak, p, rest)<0) ++ bb_error_msg_and_die("Problems with XPAK\n"); ++ if (conf->debug) flush_buf(xpak->buffer, xpak->size, "/tmp/xpak"); ++ return avail; ++ } ++ ++ /* nothing here to see folks, move on (no XPAKPACK found)*/ ++ p++; ++ rest--; ++ } ++ if (avail == 0 && found == NULL) { ++ bb_error_msg_and_die("No XPACK was found. sorry...\n"); ++ } ++ return count; ++} ++ ++ ++/* ++ Extrackt the package from xpak. (CATEGORY/PF) ++*/ ++char* xpak_get_package(xpak_t *xpak, char *package, int packagemax) { ++ char *cat, *pf, *eol; ++ ++ if ((cat = xpak_get_data(xpak, "CATEGORY")) == NULL) ++ bb_error_msg_and_die("CATEGORY not found in XPAK"); ++ ++ if ((pf = xpak_get_data(xpak, "PF")) == NULL) ++ bb_error_msg_and_die("PF not found in XPAK"); ++ ++ if ((eol = strchr(cat, '\n')) != NULL) *eol = '\0'; ++ if ((eol = strchr(pf, '\n')) != NULL) *eol = '\0'; ++ snprintf(package, packagemax, "%s/%s", cat, pf); ++ free(cat); ++ free(pf); ++ return package; ++} ++ ++/* ++ unpack the xpak to path ++*/ ++int xpak_unpack(xpak_t *xpak, char *package, int package_bufsize) { ++ int len; ++ int offset=INDEX_OFFSET; ++ char *pathname; ++ int data_offset, data_len; ++ ++ xpak_get_package(xpak, package, package_bufsize); ++ set_dbdir_pkg_char(package); ++ bb_make_directory(root_dbdir_pkg, -1, FILEUTILS_RECUR); ++ ++ while (offset < xpak->index_len) { ++ char *key; ++ if (offset + 4 > xpak->size) return -1; ++ len = decodeint(xpak->buffer + offset); ++ ++ /* pathname_len + pathname + data_offset + data_len */ ++ if (offset + 4 + len + 4 + 4 > xpak->size) return -1; ++ if ((key = xmalloc(len + 1))==NULL) return -1; ++ memcpy(key, xpak->buffer + offset + 4, len); ++ key[len] = '\0'; ++ pathname = mk_dbdir_path(package, key); ++ free(key); ++ ++ data_offset = decodeint(xpak->buffer + offset + 4 + len); ++ data_len = decodeint(xpak->buffer + offset + 8 + len); ++ ++ if ((data_offset >= 0) && ((data_offset + data_len) < xpak->size)) { ++ int i; ++ if (conf->debug) { ++ /* unpack the xpak if we are in debug mode */ ++ if (conf->pretend) ++ i = xpak->size; ++ else ++ i = flush_buf(xpak->buffer ++ + xpak->data_offset ++ + data_offset, ++ data_len, pathname); ++ if (conf->verbose) ++ bb_printf("Writing %s: %i bytes\n", pathname, i); ++ } ++ } else { ++ bb_error_msg_and_die("Invalid XPAK."); ++ } ++ offset += 12 + len; ++ } ++ return 0; ++} ++ ++/* ++ create a rejectlist for tar from install_mask ++*/ ++llist_t *create_reject_list(const char *install_mask) { ++ char *tok, *mask; ++ llist_t *list = NULL; ++ ++ mask = bb_xstrdup(install_mask); ++ /* according to man 3 strtok: "Never use these functions." ++ any alternative how this can easily be solved? */ ++ tok=strtok(mask, " "); ++ while(tok != NULL) { ++ list = llist_add_to(list, bb_xstrdup(tok)); ++ if (conf->debug) bb_printf("create_reject_list: added %s\n", tok); ++ tok = strtok(NULL, " "); ++ } ++ free(mask); ++ return list; ++} ++ ++/* ++ for debugging stuff ++*/ ++void dump_llist(llist_t *list) { ++ llist_t *item; ++ item = list; ++ while (item != NULL) { ++ bb_printf("dump_llist: %s\n", item->data); ++ item = item->link; ++ } ++} ++ ++/* ++ this func unpacks (tar -xj) whatever comes from src_fd, ++ return the filelist to ret_fd and exit. ++ the XPAK is supposed to be stripped off from src_fd ++*/ ++void tbz2_unpack_files(int src_fd, int ret_fd, const char *root_dir, ++ const char *install_mask) { ++ archive_handle_t *tar_handle = init_handle(); ++ llist_t *item; ++ ++ tar_handle->flags = ARCHIVE_CREATE_LEADING_DIRS | ARCHIVE_PRESERVE_DATE | ARCHIVE_EXTRACT_UNCONDITIONAL; ++ ++ if (install_mask != NULL) { ++ if (conf->debug) ++ bb_printf("creating reject list from '%s'\n", install_mask); ++ tar_handle->reject = create_reject_list(install_mask); ++ tar_handle->filter = filter_accept_reject_list; ++ if (conf->debug) ++ dump_llist(tar_handle->reject); ++ } ++ tar_handle->src_fd = src_fd; ++ tar_handle->seek = seek_by_char; ++ if (! conf->pretend) tar_handle->action_data = data_extract_all; ++ ++ if (root_dir != NULL) { ++ if (chdir(root_dir)) ++ bb_perror_msg_and_die("Couldnt chdir to %s", root_dir); ++ } else { ++ if (chdir("/")) ++ bb_perror_msg_and_die("Couldnt chdir to /"); ++ } ++ ++ while (get_header_tar_bz2(tar_handle) == EXIT_SUCCESS); ++ ++ /* return the filelist */ ++ for (item = tar_handle->passed; item != NULL; item = item->link) { ++ if (item->data != NULL) { ++ write(ret_fd, item->data, strlen(item->data)); ++ write(ret_fd, "\0", 1); ++ } ++ } ++} ++ ++ ++/* those funcs are copied from coreutils/md5_sha1_sum.c */ ++/* This might be useful elsewhere */ ++static unsigned char *hash_bin_to_hex(unsigned char *hash_value, ++ unsigned char hash_length) ++{ ++ int x, len, max; ++ unsigned char *hex_value; ++ ++ max = (hash_length * 2) + 2; ++ hex_value = xmalloc(max); ++ for (x = len = 0; x < hash_length; x++) { ++ len += snprintf(hex_value + len, max - len, "%02x", hash_value[x]); ++ } ++ return (hex_value); ++} ++ ++static uint8_t *hash_file(const char *filename, uint8_t hash_algo) ++{ ++ static uint8_t hash_value_bin[22]; ++ uint8_t *hash_value = NULL; ++ uint8_t hash_length; ++ int src_fd; ++ ++ src_fd = open(filename, O_RDONLY); ++ ++ if (hash_algo == HASH_MD5) { ++ hash_length = 16; ++ } else { ++ hash_length = 20; ++ } ++ ++ /* hash_value_bin = xmalloc(hash_length); */ ++ ++ if ((src_fd != -1) && (hash_fd(src_fd, -1, hash_algo, hash_value_bin) != -2)) { ++ hash_value = hash_bin_to_hex(hash_value_bin, hash_length); ++ } else { ++ bb_perror_msg("%s", filename); ++ } ++ close(src_fd); ++ return(hash_value); ++} ++ ++ ++/* ++ write a line to CONTENTS file ++ returns size of file ++*/ ++int write_line_to_contents(FILE *outf, const char *line) { ++ struct stat info; ++ char *fullpath = mk_absolute_path(line); ++ ++ /* append to CONTENTS */ ++ if (!conf->pretend) { ++ /* first we check if it is a link */ ++ if (lstat(fullpath, &info) < 0) { ++ bb_perror_msg(fullpath); ++ return 0; ++ } ++ if (S_ISLNK(info.st_mode)) { ++ static char linkbuf[256]; ++ readlink(fullpath, linkbuf, sizeof(linkbuf)); ++ bb_fprintf(outf, "sym %s -> %s %i\n", line, linkbuf, ++ (int)info.st_mtime); ++ } else if (S_ISDIR(info.st_mode)) { ++ bb_fprintf(outf, "dir %s\n", line); ++ } else if (S_ISREG(info.st_mode)) { ++#ifdef CONFIG_FEATURE_MD5_SHA1_SUM_CHECK ++ char *hash = hash_file(fullpath, CHECKSUM_ALGO); ++ bb_fprintf(outf, "obj %s %s %i\n", line, hash, (int)info.st_mtime); ++ free(hash); ++#else ++ bb_fprintf(outf, "obj %s %i %i\n", line, (int)info.st_size, ++ (int)info.st_mtime); ++#endif ++ } else { ++ bb_fprintf(outf, "??? %s - %i\n", line, ++ (int)info.st_mtime); ++ } ++ } ++ if (conf->verbose) bb_printf(">>> %s\n", line); ++ return info.st_size; ++} ++ ++/* ++ generate a CONTENTS file ++ returns numbers of lines written. ++*/ ++int create_contents(int child_fd, const char *package) { ++ static char line[1024]; /* read buf */ ++ char c; ++ int i = 0, line_count = 0, total_size = 0; ++ FILE *outf; ++ ++ set_dbdir_pkg_char(package); ++ bb_make_directory(root_dbdir_pkg, -1, FILEUTILS_RECUR); ++ ++ if (conf->root != NULL) chdir(conf->root); else chdir("/"); ++ ++ /* open the CONTENTS file */ ++ outf = bb_xfopen(root_dbdir_pkg_contents, "w"); ++ ++ /* now we can read the file list from child */ ++ /* we reuse the buffer */ ++ while (read(child_fd, &c, 1)) { ++ if (i < (sizeof(line)-1)) /* buffer size checking... */ ++ line[i++] = c; ++ else ++ line[i] = '\0'; ++ if (c == '\0') { ++ total_size += write_line_to_contents(outf, line); ++ line_count++; ++ i = 0; ++ } ++ } ++ if (!conf->pretend) fclose(outf); ++ return total_size; ++} ++ ++/* insert a string to llist, sorted by length. longest first */ ++/* this code has to be buggy.... */ ++llist_t *llist_insert_length_sorted(llist_t *list, char *data) { ++ llist_t *prev=NULL, *cur = list; ++ int data_len = strlen(data); ++ ++ /* if this is the first element, create a new list */ ++ if (list == NULL) return llist_add_to(list, data); ++ ++ while ((cur != NULL) && (strlen(cur->data) > data_len)) { ++ prev = cur; ++ cur = cur->link; ++ } ++ if (cur == NULL) { /* this was the shortest, append to the end */ ++ prev->link = llist_add_to(NULL, data); ++ } else { ++ if (prev != NULL) ++ prev->link = llist_add_to(cur, data); ++ else ++ return llist_add_to(cur, data); ++ } ++ return list; ++} ++ ++/* ++ check if path is a link that points to dest. ++ returns nonzero if the dest correspond to the link. ++*/ ++int check_link(const char *path, const char *dest) { ++ static char buf[256]; ++ if (readlink(path, buf, sizeof(buf)) < 0) return 0; ++ return (strcmp(buf, dest) == 0); ++} ++ ++/* ++ umerge a symlink. ++ modifies the passed "string". (replaces all spaces with \0 t be exact) ++*/ ++int unmerge_sym(char *string) { ++ char *type = strtok(string, " "); ++ char *path = strtok(NULL, " "); ++ char *dest; ++ time_t mtime; ++ char *fullpath = mk_absolute_path(path); ++ static struct stat info; ++ ++ strtok(NULL, " "); /* get the '->' */ ++ dest = strtok(NULL, " "); ++ mtime = atoi(strtok(NULL, " ")); ++ if (type == NULL || path == NULL) return 0; ++ ++ lstat(fullpath, &info); ++ if (check_link(fullpath, dest) && (info.st_mtime == mtime)) { ++ /* remove it */ ++ if (conf->verbose) bb_printf("<<< %s\n", path); ++ if (!conf->pretend && (unlink(fullpath) < 0)) ++ bb_perror_msg("%s", fullpath); ++ else ++ return info.st_size; ++ } else { ++ if (conf->verbose) bb_printf("--- %s\n", path); ++ } ++ ++ return 0; ++} ++ ++/* ++ unmerge a file ++ modifies line. (replaces all spaces with \0 t be exact) ++ returns size of the file removed. ++*/ ++int unmerge_obj(char *line) { ++ char *type = strtok(line, " "); ++ char *path = strtok(NULL, " "); ++ char *chksum = strtok(NULL, " "); ++ time_t mtime = atoi(strtok(NULL, " ")); ++ static char fullpath[256]; ++ static struct stat info; ++ ++ if (type == NULL || path == NULL || chksum == NULL) return 0; ++ ++ snprintf(fullpath, sizeof(fullpath), "%s%s%s", ++ conf->root, (path[0] != '/') ? "/" : "", path); ++ ++ lstat(fullpath, &info); ++ /* ++ bb_printf("%s:%s contents(%i:%i) - stat(%i,%i)\n\n", ++ type, path, atoi(chksum), (int)mtime, ++ (int)info.st_size, (int)info.st_mtime); ++ */ ++ /* currently the chksum is just the file size... */ ++ if ((mtime == info.st_mtime) && ++#ifdef CONFIG_FEATURE_MD5_SHA1_SUM_CHECK ++ (strcmp(chksum, hash_file(fullpath, CHECKSUM_ALGO)) == 0) ++ /* we should free the allocated mem from hash_file here... */ ++#else ++ (atoi(chksum) == info.st_size) ++#endif ++ ) { ++ if (conf->verbose) bb_printf("<<< %s\n", path); ++ if (!conf->pretend && unlink(fullpath) < 0) ++ bb_perror_msg("%s", fullpath); ++ else { ++ return info.st_size; ++ } ++ } else { ++ if(conf->verbose) bb_printf("--- %s\n", path); ++ } ++ return 0; ++} ++ ++/* ++ change dir where the CONTENTS are stored ++ return 0 on succes. ++*/ /* ++int ch_dbdir(const char *package) { ++ char path[256]; ++ snprintf(path, sizeof(path), "%s/%s/%s", ++ conf->root, conf->pkg_dbdir, package); ++ return (chdir(mk_as_path(package))); ++} ++*/ ++/* ++ Search unlink all files liste in list and destroy the list. ++ Data in the nodes is free'ed too. ++ returns number of destroyed items. ++*/ ++int llist_rmdir_and_destroy(llist_t *list) { ++ llist_t *item = list; ++ int count = 0; ++ while (item != NULL) { ++ llist_t *tmp; ++ if (rmdir(mk_absolute_path(item->data)) == 0) { ++ count++; ++ if (conf->verbose) bb_printf("<<< %s\n", item->data); ++ } else { ++ if (conf->verbose) bb_printf("--- %s\n", item->data); ++ } ++ free(item->data); ++ tmp = item; ++ item = item->link; ++ free(tmp); ++ } ++ return count; ++} ++ ++int tbz2_unmerge(package_t *package) { ++ FILE *inf; ++ static char line[256]; ++ llist_t *dirs=NULL; ++ int total_removed = 0; ++ ++ if (package == NULL) return -1; ++ set_dbdir_pkg(package); ++ /* check if file exist */ ++ inf = bb_xfopen(root_dbdir_pkg_contents, "r"); ++ chdir(conf->root); ++ while (fgets(line, sizeof(line), inf)) { ++ chomp(line); ++ if (strncmp(line, "dir", 3) == 0) { ++ /* we remove the dirs after files and sym's */ ++ dirs = llist_insert_length_sorted(dirs, bb_xstrdup(line+4)); ++ } else if (strncmp(line, "sym", 3) == 0) { ++ unmerge_sym(line); ++ } else { ++ unmerge_obj(line); ++ } ++ ++total_removed; ++ } ++ fclose(inf); ++ /* remove dirs */ ++ if (conf->debug) ++ bb_fprintf(stderr, "removed %i dirs", llist_rmdir_and_destroy(dirs)); ++ else ++ llist_rmdir_and_destroy(dirs); ++ ++ remove_file(root_dbdir_pkg, FILEUTILS_FORCE|FILEUTILS_RECUR); ++ return total_removed; ++} ++ ++/* list contents of package */ ++void tbz2_list(package_t *package) { ++ FILE *inf; ++ static char line[256]; ++ ++ if (package == NULL) return; ++ set_dbdir_pkg(package); ++ inf = bb_xfopen(root_dbdir_pkg_contents, "r"); ++ while (fgets(line, sizeof(line), inf)) { ++ char *path; ++ strtok(line, " "); /* the type */ ++ path = strtok(NULL, " "); ++ chomp(path); ++ bb_printf("%s\n", path); ++ } ++ fclose(inf); ++} ++ ++/* ++ reads and unpacks package from src_fd and store the ++ category/package-version information in buffer package. ++*/ ++int tbz2_install(int src_fd, char *package, int package_size, ++ configurables_t *conf_ptr) { ++ int count, total=0; ++ static char buffer[BUFSIZE]; ++ xpak_t xpak; ++ int pid; ++ int fd_to_child[2]; ++ int fd_from_child[2]; /* this is the pipe where we get the file list ++ in return */ ++ /* set the global variable conf */ ++ conf = conf_ptr; ++ ++ if ((pipe(fd_to_child) != 0) || (pipe(fd_from_child) != 0)) { ++ bb_perror_msg_and_die("Can't create pipe"); ++ } ++ ++ pid = fork(); ++ if (pid == -1) { ++ bb_perror_msg_and_die("Fork failed"); ++ } ++ ++ if (pid == 0) { ++ /* child process */ ++ close(fd_to_child[1]); ++ close(fd_from_child[0]); ++ tbz2_unpack_files(fd_to_child[0], fd_from_child[1], ++ conf->root, conf->install_mask); ++ close(fd_to_child[0]); ++ close(fd_from_child[1]); ++ exit(0); ++ } ++ ++ /* parent process */ ++ close(fd_to_child[0]); /* This is for writing to child */ ++ close(fd_from_child[1]); /* and this is for reading */ ++ ++ while ( (count = read_to_xpak(src_fd, buffer, BUFSIZE, &xpak))) { ++ if (bb_full_write(fd_to_child[1], buffer, count) < count) { ++ bb_error_msg_and_die("unpacking archive failed"); ++ } ++ total += count; ++ } ++ /* count contains the tar.bz2 size */ ++ ++ if (xpak.buffer == NULL) bb_error_msg_and_die("No XPAK found. Sorry.\n"); ++ if (xpak_get_package(&xpak, package, package_size) == NULL) ++ bb_error_msg_and_die("Cound not extract package information from XPAK.\n"); ++ ++ /* now unmerge previously installed package */ ++ /* ++ if (access(mk_dbdir_path(package, "CONTENTS"), R_OK) == 0) ++ tbz2_unmerge(package, conf); ++ */ ++ if (!conf->pretend) xpak_unpack(&xpak, package, package_size); ++ ++ count = create_contents(fd_from_child[0], package); ++ close(fd_from_child[0]);/* close the read pipe */ ++ free(xpak.buffer); ++ return(count); ++} ++ ++/* ++ Install from filename. ++ NULL or '-' means STDIN. ++*/ ++int tbz2_install_file(char *file, configurables_t *myconf) { ++ char *display_name; ++ char package[256]; /* package name found in XPAK */ ++ int src_fd, size; ++ ++ tbz2pkg_init(myconf); ++ if ((file == NULL) || (strcmp(file, "-") == 0)) { ++ display_name = "STDIN"; ++ src_fd = STDIN_FILENO; ++ } else { ++ display_name = file; ++ src_fd = bb_xopen(file, O_RDONLY); ++ } ++ ++ if (myconf->verbose) bb_printf(">>> Unpacking %s\n", display_name); ++ ++ size = tbz2_install(src_fd, package, sizeof(package), myconf); ++ if (size < 0 ) ++ bb_error_msg_and_die("Package %s was not successfully" ++ " installed. Sorry.\n", display_name); ++ else ++ if (myconf->verbose) ++ bb_printf(">>> Package %s installed. %i bytes.\n\n", ++ package, size); ++ ++ if (src_fd != STDIN_FILENO) close(src_fd); ++ return size; ++} ++ ++/* ++ Main ++*/ ++int tbz2pkg_main(int argc, char *argv[]) { ++ unsigned long opt; ++ configurables_t myconf; ++ ++ myconf.root = NULL; ++ myconf.install_mask = NULL; ++ bb_applet_long_options = tbz2pkg_long_options; ++ opterr = 0; ++ opt = bb_getopt_ulflags(argc, argv, OPTIONS_FLAGS, ++ &myconf.install_mask, ++ &myconf.root); ++ ++ bb_printf("%s\n", myconf.root); ++ ++ if (opt & TBZ2PKG_HELP) bb_show_usage(); ++ ++ myconf.debug = (opt & TBZ2PKG_DEBUG); ++ myconf.pretend = (opt & TBZ2PKG_PRETEND); ++ myconf.verbose = (opt & TBZ2PKG_VERBOSE); ++ ++ if (myconf.root == NULL) myconf.root = getenv("ROOT"); ++ if (myconf.install_mask == NULL) myconf.install_mask = getenv("INSTALL_MASK"); ++ if ((myconf.pkg_dbdir = getenv("PKG_DBDIR")) == NULL) ++ /* shouldn't this use myconf.root, not / ? */ ++ myconf.pkg_dbdir = "/var/db/pkg"; ++ ++ if (myconf.debug) ++ bb_printf("root=%s, install_mask=%s, pkg_dbdir=%s\n", ++ myconf.root, myconf.install_mask, myconf.pkg_dbdir); ++ ++ tbz2pkg_init(&myconf); ++ if (opt & TBZ2PKG_INSTALL) { ++ if (optind == argc) { ++ tbz2_install_file(NULL, &myconf); ++ } else { ++ int i, total_size=0; ++ for (i=optind; i < argc; i++) ++ total_size += tbz2_install_file(argv[i], &myconf); ++ if (myconf.verbose) ++ bb_printf(">>> Totally %i bytes installed.\n\n", total_size); ++ } ++ } else { ++ int i; ++ llist_t *results=0; ++ package_t *pkg, *tmppkg; ++ for (i=optind; i < argc; i++) { ++ pkg = decode_namespec(argv[i]); ++ results = find_package_on_disk(pkg); ++ while (results) { ++ tmppkg = (package_t*) results->data; ++ if (opt & TBZ2PKG_LIST) { ++ bb_printf(">>> Listing %s.\n", tmppkg->name); ++ tbz2_list(tmppkg); ++ } else if (opt & TBZ2PKG_PURGE) { ++ bb_printf(">>> Purging %s.\n", tmppkg->name); ++ tbz2_unmerge(tmppkg); ++ /* } else if (opt & TBZ2PKG_CHECK) { ++ bb_printf(">>> Checking %s.\n", pkg); ++ tbz2_check(pkg); ++ */ ++ } ++ free(results->data); ++ results = results->link; ++ } ++ pkg = 0; results = 0; ++ } ++ } ++ ++ return 0; ++} ++ +diff -Nru --exclude=CVS --exclude=env.sh busybox-1.00/archival/tbz2pkg.h busybox/archival/tbz2pkg.h +--- busybox-1.00/archival/tbz2pkg.h 1970-01-01 01:00:00.000000000 +0100 ++++ busybox/archival/tbz2pkg.h 2005-06-08 19:46:32.000000000 +0200 +@@ -0,0 +1,35 @@ ++/* ++* Distributed under the terms of the GNU General Public License v2 ++* $Header: /home/collar_b/programs/cvs/busybox/archival/tbz2pkg.h,v 1.9 2005/06/08 17:46:32 collar_b Exp $ ++* ++******************************************************************** ++* This program is free software; you can redistribute it and/or ++* modify it under the terms of the GNU General Public License as ++* published by the Free Software Foundation; either version 2 of the ++* License, or (at your option) any later version. ++* ++* This program is distributed in the hope that it will be useful, but ++* WITHOUT 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 TBZ2PKG_H ++#define TBZ2PKG_H ++ ++#include "gentoo_shared.h" ++/* the data & decls here are shared by tbz2pkg and emerge */ ++ ++ ++/* functions defined in tbz2pkg and used in emerge */ ++int tbz2_install_file(char *file, configurables_t *myconf); ++int tbz2_unmerge(package_t *package); ++void tbz2_list(package_t *package); ++configurables_t *tbz2pkg_init(configurables_t *myconf); ++ ++#endif /* TBZ2PKG_H */ +diff -Nru --exclude=CVS --exclude=env.sh busybox-1.00/include/applets.h busybox/include/applets.h +--- busybox-1.00/include/applets.h 2004-08-27 01:01:34.000000000 +0200 ++++ busybox/include/applets.h 2005-03-30 15:33:02.000000000 +0200 +@@ -178,6 +178,9 @@ + #if defined(CONFIG_FEATURE_GREP_EGREP_ALIAS) + APPLET_NOUSAGE("egrep", grep_main, _BB_DIR_BIN, _BB_SUID_NEVER) + #endif ++#if defined(CONFIG_EMERGE) ++ APPLET(emerge, emerge_main, _BB_DIR_BIN, _BB_SUID_NEVER) ++#endif + #ifdef CONFIG_ENV + APPLET(env, env_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER) + #endif +@@ -559,6 +562,9 @@ + #ifdef CONFIG_TAR + APPLET(tar, tar_main, _BB_DIR_BIN, _BB_SUID_NEVER) + #endif ++#ifdef CONFIG_TBZ2PKG ++ APPLET(tbz2pkg, tbz2pkg_main, _BB_DIR_BIN, _BB_SUID_NEVER) ++#endif + #ifdef CONFIG_TEE + APPLET(tee, tee_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER) + #endif +diff -Nru --exclude=CVS --exclude=env.sh busybox-1.00/include/usage.h busybox/include/usage.h +--- busybox-1.00/include/usage.h 2004-09-14 18:23:56.000000000 +0200 ++++ busybox/include/usage.h 2005-06-08 20:16:16.000000000 +0200 +@@ -531,6 +531,30 @@ + "$ echo "Erik\\nis\\ncool"\n" \ + "Erik\\nis\\ncool\n") + ++#define emerge_trivial_usage \ ++ "[-hdpvfKCqislucR:I:P:T:B:] package_name" ++#define emerge_full_usage \ ++ "emerge is a utility to install, remove and manage Gentoo packages.\n" \ ++ "Options:\n" \ ++ "\t-h|--help : This help\n" \ ++ "\t-d|--debug : set -x\n" \ ++ "\t-p|--pretend : pretend only\n" \ ++ "\t-v|--verbose : set verbose flag\n" \ ++ "\t-f|--fetch : fetch binary files\n" \ ++ "\t-K|--usepkgonly : use binary package\n" \ ++ "\t-C|--unmerge : uninstall a binary package\n" \ ++ "\t-q|--query : query a package\n" \ ++ "\t--info|info : display info\n" \ ++ "\t--sync : perform $opt operation\n" \ ++ "\t--list : update index and list packages\n" \ ++ "\t--update : update index file\n" \ ++ "\t--clean : clean up tmpfiles\n" \ ++ "\t--root= : define ROOT=\n" \ ++ "\t--index= : define INDEX_FILE=\n" \ ++ "\t--pkgdir= : define PKGDIR=\n" \ ++ "\t--tmpdir= : define PORTAGE_TMPDIR=\n" \ ++ "\t--binhost= : define PORTAGE_BINHOST=\n" ++ + #define env_trivial_usage \ + "[-iu] [-] [name=value]... [command]" + #define env_full_usage \ +@@ -2422,6 +2446,21 @@ + "$ zcat /tmp/tarball.tar.gz | tar -xf -\n" \ + "$ tar -cf /tmp/tarball.tar /usr/local\n" + ++#define tbz2pkg_trivial_usage \ ++ "[OPTION]... [FILE|PKG_NAME]..." ++#define tbz2pkg_full_usage \ ++ "Manage gentoo-created binary packages.\n\n" \ ++ "Options:\n" \ ++ "\t-d\tshow debug output\n" \ ++ "\t-h\tshow this help information\n" \ ++ "\t-i\tinstalled given binary packages (FILE)\n" \ ++ "\t-M\tDon't install files that are masked by given regexp\n" \ ++ "\t-L\tList contents of installed package(s) (PKG_NAME)\n" \ ++ "\t-p\tPretend to do action (install, purge)\n" \ ++ "\t-P\tUninstall package(s) (PKG_NAME)\n" \ ++ "\t-R\tSet root directory to ROOT\n" \ ++ "\t-v\tVerbose output\n" ++ + #define tee_trivial_usage \ + "[OPTION]... [FILE]..." + #define tee_full_usage \ diff --git a/eselect-opengl-non-multilib.patch b/eselect-opengl-non-multilib.patch new file mode 100644 index 0000000..4ba1837 --- /dev/null +++ b/eselect-opengl-non-multilib.patch @@ -0,0 +1,37 @@ +Index: modules/opengl.eselect +=================================================================== +--- modules/opengl.eselect (revision 249) ++++ modules/opengl.eselect (working copy) +@@ -1,4 +1,4 @@ +-# Copyright 1999-2004 Gentoo Foundation ++# Copyright 1999-2006 Gentoo Foundation + # Distributed under the terms of the GNU General Public License v2 + # $Id$ + # Author: Martin Schlemmer +@@ -111,15 +111,17 @@ + rm -f "${ENV_FILE}" || die -q "Failed to remove ${ENV_FILE}" + fi + +- local libdir +- for libdir in $(list_libdirs); do +- # Special case handling of lib32 because it can be a symlink to +- # emul libs +- # Kill this special case once amd64's 2004.3 crap is gone =) --eradicator +- if [[ ${libdir} = "lib32" ]] ; then +- [[ -d ${PREFIX}/${libdir}/opengl ]] || continue +- else +- [[ -d ${PREFIX}/${libdir}/opengl && ! -h ${PREFIX}/${libdir} ]] || continue ++ local libdir libdirs=$(list_libdirs) ++ for libdir in ${libdirs} ; do ++ if [[ ${#libdirs[@]} -gt 1 ]] ; then ++ # Special case handling of lib32 because it can be a symlink to ++ # emul libs ++ # Kill this special case once amd64's 2004.3 crap is gone =) --eradicator ++ if [[ ${libdir} = "lib32" ]] ; then ++ [[ -d ${PREFIX}/${libdir}/opengl ]] || continue ++ else ++ [[ -d ${PREFIX}/${libdir}/opengl && ! -h ${PREFIX}/${libdir} ]] || continue ++ fi + fi + + # Fallback on xorg-x11 if we don't have this implementation for this libdir. diff --git a/eterm-atom-typo.patch b/eterm-atom-typo.patch new file mode 100644 index 0000000..4b8ffb3 --- /dev/null +++ b/eterm-atom-typo.patch @@ -0,0 +1,16 @@ +Index: command.c +=================================================================== +RCS file: /cvs/e/eterm/Eterm/src/command.c,v +retrieving revision 1.113 +diff -u -p -r1.113 command.c +--- command.c 18 Aug 2006 17:41:19 -0000 1.113 ++++ command.c 14 Oct 2006 05:07:27 -0000 +@@ -1125,7 +1125,7 @@ x_resource_dump(int sig) + /* Create type atoms for future use. */ + pixmap_atom = XInternAtom(Xdisplay, "PIXMAP", False); + gc_atom = XInternAtom(Xdisplay, "GC", False); +- gc_atom = XInternAtom(Xdisplay, "FONT", False); ++ font_atom = XInternAtom(Xdisplay, "FONT", False); + + /* Look at what *we* think our consumption is. */ + #if DEBUG >= DEBUG_MEM diff --git a/eterm-init-vars-libscream.patch b/eterm-init-vars-libscream.patch new file mode 100644 index 0000000..8f753fb --- /dev/null +++ b/eterm-init-vars-libscream.patch @@ -0,0 +1,25 @@ +Index: libscream.c +=================================================================== +RCS file: /cvs/e/eterm/Eterm/src/libscream.c,v +retrieving revision 1.33 +diff -u -p -r1.33 libscream.c +--- libscream.c 19 Sep 2006 21:07:40 -0000 1.33 ++++ libscream.c 14 Oct 2006 05:14:36 -0000 +@@ -1084,7 +1084,7 @@ ns_attach_lcl(_ns_sess ** sp) + static int + ns_wait_for_socket(int port) + { +- int tmp_sock, ret; ++ int tmp_sock, ret = -1; + time_t start_time; + + D_ESCREEN(("Waiting for forwarder to begin listening on port %d.\n", port)); +@@ -1933,7 +1933,7 @@ int + ns_ren_disp(_ns_sess * s, int d, char *name) + { + char *i = NULL, *n; +- size_t l; ++ size_t l = 0; + int ret = NS_FAIL; + + if (!s) { diff --git a/f.patch b/f.patch new file mode 100644 index 0000000..63d64b2 --- /dev/null +++ b/f.patch @@ -0,0 +1,407 @@ +Index: target_bfin_new.c +=================================================================== +--- target_bfin_new.c (revision 2656) ++++ target_bfin_new.c (working copy) +@@ -21,6 +21,7 @@ + #include + #endif /* HAVE_CONFIG_H */ + ++#include + #include + #include + #include +@@ -30,8 +31,11 @@ + #include + #include + #include ++#include ++#include + + #include "gdbproxy.h" ++#include "rpmisc.h" + + #include "part.h" + #include "chain.h" +@@ -4672,6 +4676,177 @@ bfin_out_treg (char *in, unsigned int re + return bfin_out_treg_value (in, reg_no, value); + } + ++#define DR_OUT (cpu->chain->parts->parts[cpu->chain->active_part]->active_instruction->data_register->out) ++#define DR_IN (cpu->chain->parts->parts[cpu->chain->active_part]->active_instruction->data_register->in) ++ ++static unsigned int btc_port = 2001; ++static int btc_listen_sock = -1; ++ ++static pthread_t btc_thread; ++ ++static char *btc_read_buff = NULL; ++static size_t btc_read_len = 0; ++static inline void btc_read_maybe_queue(void) ++{ ++ if (DR_OUT->data[40 - 1 - 7] == 0) ++ return; ++ ++ size_t i; ++ uint32_t data = 0; ++ for (i = 0; i < 32; ++i) ++ data |= DR_OUT->data[i] << (32 - 1 - i); ++ ++ printf("got from Blackfin: 0x%08x\n", data); ++ ++ btc_read_buff = realloc(btc_read_buff, btc_read_len + 4); ++ memcpy(btc_read_buff + btc_read_len, &data, 4); ++ btc_read_len += 4; ++} ++ ++static inline int jtag_strdup_parse_line(char *buf) ++{ ++ int ret; ++ buf = strdup(buf); ++ ret = jtag_parse_line(cpu->chain, buf); ++ free(buf); ++ return ret; ++} ++ ++static size_t btc_write(size_t length, void *data) ++{ ++ size_t i, j, b; ++ char *buf = data; ++ char dr_cmd[] = "dr 0000000000000000000000000000000000000000"; /* need 40bits */ ++ ++ /* in full duplex, we need to look at 7th bit ++ * to see if Blackfin is sending to us ++ */ ++ for (i = 0; i < length; i += 4) { ++ dr_cmd[3 + 6] = '0'; ++ jtag_strdup_parse_line(dr_cmd); ++ while (1) { ++ jtag_strdup_parse_line("shift dr"); ++ //jtag_strdup_parse_line("dr"); ++ //printf("{ in:%s\n out:%s}\n", register_get_string(DR_IN), register_get_string(DR_OUT)); ++ ++ btc_read_maybe_queue(); ++ ++ if (DR_OUT->data[40 - 1 - 6] == 0) ++ break; ++ } ++ ++ dr_cmd[3 + 6] = '1'; ++ for (j = 0; j < 4; ++j) { ++ //printf("byte: %c (0x%02x): 0y", buf[i+j], buf[i+j]); ++ for (b = 0; b < 8; ++b) { ++ char bit = ((buf[i+j] >> b) & 0x1) + '0'; ++ dr_cmd[3 + 8 + 8*j + b] = bit; ++ //printf("%c", bit); ++ } ++ //printf("\n"); ++ } ++ //printf("dr_cmd: %s\n", dr_cmd); ++ jtag_strdup_parse_line(dr_cmd); ++ jtag_strdup_parse_line("shift dr"); ++ btc_read_maybe_queue(); ++ } ++ ++ return 0; ++} ++ ++static void *btc_thread_main(void *arg) ++{ ++ int btc_sock; ++ ssize_t io_ret; ++ char buf[1024]; ++ ++ { ++ int fd = open("/dev/null", O_WRONLY); ++ dup2(fd, STDOUT_FILENO); ++ close(fd); ++ } ++ ++ while (1) { ++ btc_sock = sock_accept(btc_listen_sock); ++ fcntl(btc_sock, F_SETFL, fcntl(btc_sock, F_GETFL) | O_NONBLOCK); ++// dup2(btc_sock, STDOUT_FILENO); ++ ++ jtag_strdup_parse_line("instruction EMUDAT_40_SCAN"); ++ jtag_strdup_parse_line("shift ir"); ++ ++ while (1) { ++#if 0 ++ memset(buf, 'a', sizeof(buf)); ++ io_ret = read(btc_sock, buf, sizeof(buf)-1); ++ if (io_ret <= 0) ++ break; ++ while (io_ret > 0) ++ if (buf[io_ret-1] == '\n' || buf[io_ret-1] == '\r') ++ --io_ret; ++ else ++ break; ++ if (io_ret <= 0) ++ continue; ++ buf[io_ret] = '\0'; ++ printf("SOCKET: '%s'\n", buf); ++ ++ if (buf[0] == '!') ++ printf("jtag_parse_line: %i\n", jtag_parse_line(cpu->chain, buf+1)); ++ else ++ btc_write(io_ret, buf); ++#else ++ char byte; ++ io_ret = read(btc_sock, &byte, 1); ++ if (io_ret == 0 || (io_ret == -1 && errno != EAGAIN)) ++ break; ++ ++ if (io_ret > 0) ++ btc_write(1, &byte); ++ else { ++ jtag_strdup_parse_line("dr 0000000000000000000000000000000000000000"); ++ jtag_strdup_parse_line("shift dr"); ++ btc_read_maybe_queue(); ++ } ++ ++ if (btc_read_len) { ++ write(btc_sock, btc_read_buff, 1); ++ btc_read_len = 0; ++ } ++#endif ++ } ++ ++ close(btc_sock); ++ } ++ ++ return NULL; ++} ++ ++#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) ++static void bfin_btc_init(void) ++{ ++ size_t i; ++ char *btc_command_init[] = { ++ /* declare a 40bit version of emudat */ ++ "register EMUDAT_40 40", ++ "instruction EMUDAT_40_SCAN 10100 EMUDAT_40", ++ ++ /* set emudat to 40bits */ ++ "instruction DBGCTL_SCAN", ++ "shift ir", ++ "shift dr", ++ "dr 0000000100000000", ++ "shift dr" ++ }; ++ ++ btc_listen_sock = listen_sock_open(&btc_port); ++ if (btc_listen_sock == -1) ++ return; ++ ++ pthread_create(&btc_thread, NULL, btc_thread_main, NULL); ++ for (i = 0; i < ARRAY_SIZE(btc_command_init); ++i) ++ jtag_strdup_parse_line(btc_command_init[i]); ++} ++ + + /* Target method */ + static void +@@ -5208,6 +5383,8 @@ bfin_open (int argc, + cpu->cores[0].name = "Core"; + } + ++ bfin_btc_init(); ++ + return RP_VAL_TARGETRET_OK; + } + +Index: rpmisc.c +=================================================================== +--- rpmisc.c (revision 2656) ++++ rpmisc.c (working copy) +@@ -98,13 +98,14 @@ + + + /* Sockets */ +-#if defined(WIN32) ++#if !defined(WIN32) ++# undef INVALID_SOCKET ++# define INVALID_SOCKET -1 ++# undef SOCKET_ERROR ++# define SOCKET_ERROR -1 ++#endif + static int dbg_sock = INVALID_SOCKET; + static int dbg_listen_sock = INVALID_SOCKET; +-#else +-static int dbg_sock = -1; +-static int dbg_listen_sock = -1; +-#endif + + /* Log functions */ + static void rp_log_local(int level, const char *fmt, ...); +@@ -140,29 +141,21 @@ void dbg_sock_cleanup(void) + } + + /* Open listen socket in a mode expected by gdb */ +-int dbg_listen_sock_open(unsigned int *port) ++int listen_sock_open(unsigned int *port) + { + struct sockaddr_in sa; + int tmp; + int ret; + unsigned int p; ++ int sock; + + assert(port == NULL || *port < 0x10000); + +-#if defined(WIN32) +- assert(dbg_sock == INVALID_SOCKET && dbg_listen_sock == INVALID_SOCKET); +- +- if ((dbg_listen_sock = socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) +- return FALSE; +-#else +- assert(dbg_sock == -1 && dbg_listen_sock == -1); +- +- if ((dbg_listen_sock = socket(PF_INET, SOCK_STREAM, 0)) < 0) +- return FALSE; +-#endif ++ if ((sock = socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) ++ return INVALID_SOCKET; + + tmp = 1; +- setsockopt(dbg_listen_sock, ++ setsockopt(sock, + SOL_SOCKET, + SO_REUSEADDR, + (char *) &tmp, +@@ -178,13 +171,8 @@ int dbg_listen_sock_open(unsigned int *p + else + sa.sin_port = htons((unsigned short int) *port); + +-#if defined(WIN32) +- if ((ret = bind(dbg_listen_sock, (struct sockaddr *) &sa, sizeof (sa))) == SOCKET_ERROR) +- return FALSE; +-#else +- if ((ret = bind(dbg_listen_sock, (struct sockaddr *) &sa, sizeof (sa))) != 0) +- return FALSE; +-#endif ++ if ((ret = bind(sock, (struct sockaddr *) &sa, sizeof (sa))) == SOCKET_ERROR) ++ return INVALID_SOCKET; + } + else + { +@@ -194,79 +182,68 @@ int dbg_listen_sock_open(unsigned int *p + { + sa.sin_port = htons(p); + +-#if defined(WIN32) +- if ((ret = bind(dbg_listen_sock, (struct sockaddr *) &sa, sizeof (sa))) != SOCKET_ERROR) ++ if ((ret = bind(sock, (struct sockaddr *) &sa, sizeof (sa))) != SOCKET_ERROR) + break; +-#else +- if ((ret = bind(dbg_listen_sock, (struct sockaddr *) &sa, sizeof (sa))) == 0) +- break; +-#endif + } + + if (p == 0x10000) + { + /* No sockets available */ +- return FALSE; ++ return INVALID_SOCKET; + } + + *port = p; + } + +-#if defined(WIN32) +- assert(dbg_listen_sock != INVALID_SOCKET); ++ assert(sock != INVALID_SOCKET); + +- if ((ret = listen(dbg_listen_sock, 1)) == SOCKET_ERROR) +- return FALSE; +-#else +- assert(dbg_listen_sock >= 0); ++ if ((ret = listen(sock, 1)) == SOCKET_ERROR) ++ return INVALID_SOCKET; + +- if ((ret = listen(dbg_listen_sock, 1)) != 0) +- return FALSE; +-#endif ++ return sock; ++} ++int dbg_listen_sock_open(unsigned int *port) ++{ ++ assert(dbg_sock == INVALID_SOCKET && dbg_listen_sock == INVALID_SOCKET); + +- return TRUE; ++ dbg_listen_sock = listen_sock_open(port); ++ ++ return (dbg_listen_sock == INVALID_SOCKET ? FALSE : TRUE); + } + + /* Accept incoming connection and set mode expected by gdb */ +-int dbg_sock_accept(void) ++int sock_accept(int listen_sock) + { + socklen_t tmp; + struct sockaddr_in sa; + struct protoent *pe; +- +-#if defined(WIN32) +- assert(dbg_sock == INVALID_SOCKET); +- assert(dbg_listen_sock != INVALID_SOCKET); ++ int sock; + + tmp = sizeof(sa); +- if ((dbg_sock = accept(dbg_listen_sock, (struct sockaddr *) &sa, &tmp)) ++ if ((sock = accept(listen_sock, (struct sockaddr *) &sa, &tmp)) + == INVALID_SOCKET) + { +- return FALSE; ++ return INVALID_SOCKET; + } + + if ((pe = getprotobyname("tcp")) == NULL) +- return FALSE; +-#else +- assert(dbg_sock < 0); +- assert(dbg_listen_sock >= 0); +- +- tmp = sizeof(sa); +- if ((dbg_sock = accept(dbg_listen_sock, (struct sockaddr *) &sa, &tmp)) < 0) +- return FALSE; +- +- if ((pe = getprotobyname("tcp")) == NULL) +- return FALSE; +-#endif ++ return INVALID_SOCKET; + + tmp = 1; +- setsockopt(dbg_sock, ++ setsockopt(sock, + pe->p_proto, + TCP_NODELAY, + (char *) &tmp, + sizeof(tmp)); + +- return TRUE; ++ return sock; ++} ++int dbg_sock_accept(void) ++{ ++ assert(dbg_sock == INVALID_SOCKET); ++ assert(dbg_listen_sock != INVALID_SOCKET); ++ dbg_sock = sock_accept(dbg_listen_sock); ++ return (dbg_sock == INVALID_SOCKET ? FALSE : TRUE); + } + + /* Close connection to debugger side */ +Index: rpmisc.h +=================================================================== +--- rpmisc.h (revision 2656) ++++ rpmisc.h (working copy) +@@ -39,6 +39,9 @@ int dbg_sock_accept(void); + int dbg_sock_readchar(int ms); + int dbg_listen_sock_open(unsigned int *port); + ++int listen_sock_open(unsigned int *port); ++int sock_accept(int listen_sock); ++ + /* Return values for readchar: either character + code or one of the following*/ + #define RP_VAL_MISCREADCHARRET_TMOUT (-2) diff --git a/fadvise.patch b/fadvise.patch new file mode 100644 index 0000000..04777c8 --- /dev/null +++ b/fadvise.patch @@ -0,0 +1,51 @@ +diff -urNp -x '*~' uClibc-0.9.29.org/libc/sysdeps/linux/arm/posix_fadvise.c uClibc-0.9.29/libc/sysdeps/linux/arm/posix_fadvise.c +--- uClibc-0.9.29.org/libc/sysdeps/linux/arm/posix_fadvise.c 2007-03-07 04:13:31.000000000 +0900 ++++ uClibc-0.9.29/libc/sysdeps/linux/arm/posix_fadvise.c 2007-05-25 12:25:48.000000000 +0900 +@@ -30,8 +30,7 @@ weak_alias(__libc_posix_fadvise, posix_f + #else + int posix_fadvise(int fd attribute_unused, off_t offset attribute_unused, off_t len attribute_unused, int advice attribute_unused) + { +- __set_errno(ENOSYS); +- return -1; ++ return ENOSYS; + } + #endif + +diff -urNp -x '*~' uClibc-0.9.29.org/libc/sysdeps/linux/arm/posix_fadvise64.c uClibc-0.9.29/libc/sysdeps/linux/arm/posix_fadvise64.c +--- uClibc-0.9.29.org/libc/sysdeps/linux/arm/posix_fadvise64.c 2007-03-07 04:13:31.000000000 +0900 ++++ uClibc-0.9.29/libc/sysdeps/linux/arm/posix_fadvise64.c 2007-05-25 12:26:02.000000000 +0900 +@@ -40,8 +40,7 @@ weak_alias(__libc_posix_fadvise64, posix + #else + int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advise) + { +- __set_errno(ENOSYS); +- return -1; ++ return ENOSYS; + } + #endif + #endif +diff -urNp -x '*~' uClibc-0.9.29.org/libc/sysdeps/linux/common/posix_fadvise.c uClibc-0.9.29/libc/sysdeps/linux/common/posix_fadvise.c +--- uClibc-0.9.29.org/libc/sysdeps/linux/common/posix_fadvise.c 2007-03-06 17:06:26.000000000 +0900 ++++ uClibc-0.9.29/libc/sysdeps/linux/common/posix_fadvise.c 2007-05-25 12:26:51.000000000 +0900 +@@ -46,7 +46,6 @@ strong_alias(posix_fadvise,posix_fadvise + #else + int posix_fadvise(int fd attribute_unused, off_t offset attribute_unused, off_t len attribute_unused, int advice attribute_unused) + { +- __set_errno(ENOSYS); +- return -1; ++ return ENOSYS; + } + #endif +diff -urNp -x '*~' uClibc-0.9.29.org/libc/sysdeps/linux/common/posix_fadvise64.c uClibc-0.9.29/libc/sysdeps/linux/common/posix_fadvise64.c +--- uClibc-0.9.29.org/libc/sysdeps/linux/common/posix_fadvise64.c 2007-03-06 17:06:26.000000000 +0900 ++++ uClibc-0.9.29/libc/sysdeps/linux/common/posix_fadvise64.c 2007-05-25 12:26:31.000000000 +0900 +@@ -74,8 +74,7 @@ int posix_fadvise64(int fd, __off64_t of + */ + int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advice) + { +- __set_errno(ENOSYS); +- return -1; ++ return ENOSYS; + } + #endif /* __NR_fadvise64_64 */ + #endif /* __UCLIBC_HAS_LFS__ */ diff --git a/ffmpeg-bfin-dir.patch b/ffmpeg-bfin-dir.patch new file mode 100644 index 0000000..791004c --- /dev/null +++ b/ffmpeg-bfin-dir.patch @@ -0,0 +1,12 @@ +Index: configure +=================================================================== +--- configure (revision 6534) ++++ configure (working copy) +@@ -2114,6 +2114,7 @@ if test "$source_path_used" = "yes" ; th + libavcodec \ + libavcodec/alpha \ + libavcodec/armv4l \ ++ libavcodec/bfin \ + libavcodec/i386 \ + libavcodec/sparc \ + libavcodec/mlib \ diff --git a/ffmpeg-mmap-fallback.patch b/ffmpeg-mmap-fallback.patch new file mode 100644 index 0000000..ab2acbf --- /dev/null +++ b/ffmpeg-mmap-fallback.patch @@ -0,0 +1,18 @@ +Index: libavformat/grab.c +=================================================================== +--- libavformat/grab.c (revision 7378) ++++ libavformat/grab.c (working copy) +@@ -219,8 +219,11 @@ static int grab_read_header(AVFormatCont + } else { + s->video_buf = mmap(0,s->gb_buffers.size,PROT_READ|PROT_WRITE,MAP_SHARED,video_fd,0); + if ((unsigned char*)-1 == s->video_buf) { +- perror("mmap"); +- goto fail; ++ s->video_buf = mmap(0,s->gb_buffers.size,PROT_READ|PROT_WRITE,MAP_PRIVATE,video_fd,0); ++ if ((unsigned char*)-1 == s->video_buf) { ++ perror("mmap"); ++ goto fail; ++ } + } + s->gb_frame = 0; + s->time_frame = av_gettime() * s->frame_rate / s->frame_rate_base; diff --git a/file-4.19-init-file.patch b/file-4.19-init-file.patch new file mode 100644 index 0000000..96c9e68 --- /dev/null +++ b/file-4.19-init-file.patch @@ -0,0 +1,21 @@ +When a new struct magic_set is created as the handle to the calling application +(in magic_open), the "file" char * is not NULLified. This causes unexplained +segfaults in other apps that don't properly have their magic.mgc file created, +i.e. in app-arch/rpm-4.4.6-r3. The file pointer is some random value, so when +file_magwarn tries to report a missing magic.mgc file, for example, it tries to +print ms->file, which is NULL, and the segfault occurs. + +Fix by Jeff Hansen. + +http://bugs.gentoo.org/163948 + +--- src/magic.c ++++ src/magic.c +@@ -110,6 +110,7 @@ magic_open(int flags) + ms->haderr = 0; + ms->error = -1; + ms->mlist = NULL; ++ ms->file = NULL; + return ms; + free3: + free(ms->o.pbuf); diff --git a/fillets-ng-autogen-makefile.patch b/fillets-ng-autogen-makefile.patch new file mode 100644 index 0000000..521b2e0 --- /dev/null +++ b/fillets-ng-autogen-makefile.patch @@ -0,0 +1,13 @@ +--- Makefile.cvs ++++ Makefile.cvs +@@ -1,8 +1,8 @@ + + all: + touch ChangeLog # cvs2cl +- -libtoolize --force >/dev/null ++ -libtoolize --copy --force >/dev/null + aclocal -I . +- automake -a ++ automake -a --copy + autoconf + @echo "Don't forget to run ./configure" diff --git a/fillets-ng-check-for-X.patch b/fillets-ng-check-for-X.patch new file mode 100644 index 0000000..741c4d8 --- /dev/null +++ b/fillets-ng-check-for-X.patch @@ -0,0 +1,56 @@ +--- configure.in ++++ configure.in +@@ -89,21 +91,31 @@ AC_CHECK_LIB([SDL_ttf], [TTF_OpenFont], + + ################################################### + # Test X11 +-OLD_CPPFLAGS="$CPPFLAGS" +-CPPFLAGS="$CPPFLAGS $SDL_CFLAGS" +-AC_TRY_COMPILE([ +- #include "SDL.h" +- #include "SDL_syswm.h" +- #include +- ], [ +- SDL_SysWMinfo info; +- info.subsystem = SDL_SYSWM_X11; +- ], [have_x11="yes"], [have_x11="no"]) +-CPPFLAGS="$OLD_CPPFLAGS" +-if test "x$have_x11" = xyes; then +- AC_DEFINE(HAVE_X11) ++X_LIBS="" ++AC_ARG_WITH(X, ++ [AC_HELP_STRING([--with-x],[enable X window manager support [default=detect]])], ++ [with_x11=$withval],[with_x11="maybe"]) ++if test "x$with_x11" != "xno" ; then ++ AC_CHECK_LIB([X11], [Xutf8TextListToTextProperty], [with_x11="yes"], [with_x11="no"]) ++ if test "x$with_x11" != "xno" ; then ++ OLD_CPPFLAGS="$CPPFLAGS" ++ CPPFLAGS="$CPPFLAGS $SDL_CFLAGS" ++ AC_TRY_COMPILE([ ++ #include "SDL.h" ++ #include "SDL_syswm.h" ++ #include ++ ], [ ++ SDL_SysWMinfo info; ++ info.subsystem = SDL_SYSWM_X11; ++ ], [have_x11="yes"], [have_x11="no"]) ++ CPPFLAGS="$OLD_CPPFLAGS" ++ if test "x$have_x11" = xyes; then ++ AC_DEFINE(HAVE_X11) ++ X_LIBS="-lX11" ++ fi ++ fi + fi +- ++AC_SUBST(X_LIBS) + + ################################################### + # Test FriBidi +--- src/game/Makefile.am ++++ src/game/Makefile.am +@@ -18,4 +18,4 @@ ICON_LIBS = + endif + + +-fillets_LDADD = $(ICON_LIBS) ../menu/libmenu.a ../level/liblevel.a ../state/libstate.a ../option/liboption.a ../plan/libplan.a ../widget/libwidget.a ../effect/libeffect.a ../gengine/libgengine.a $(SDL_GFX_LIBS) $(SDL_LIBS) $(LUA_LIBS) $(BOOST_LIBS) $(FRIBIDI_LIBS) ++fillets_LDADD = $(ICON_LIBS) ../menu/libmenu.a ../level/liblevel.a ../state/libstate.a ../option/liboption.a ../plan/libplan.a ../widget/libwidget.a ../effect/libeffect.a ../gengine/libgengine.a $(SDL_GFX_LIBS) $(SDL_LIBS) $(LUA_LIBS) $(BOOST_LIBS) $(FRIBIDI_LIBS) $(X_LIBS) diff --git a/fillets-ng-custom-datadir.patch b/fillets-ng-custom-datadir.patch new file mode 100644 index 0000000..3965d9a --- /dev/null +++ b/fillets-ng-custom-datadir.patch @@ -0,0 +1,24 @@ +--- configure.in ++++ configure.in +@@ -151,6 +160,11 @@ case "$target" in + ;; + esac + ++################################################### ++# Mung up datadir if need be ++if test "${datadir}" = '${datarootdir}' ; then ++ datadir='${datarootdir}/games/${PACKAGE}' ++fi + + ################################################### + # Debug on/off +--- src/gengine/Makefile.am ++++ src/gengine/Makefile.am +@@ -1,6 +1,6 @@ + + INCLUDES = $(SDL_CFLAGS) $(LUA_CFLAGS) $(BOOST_CFLAGS) +-AM_CPPFLAGS = -DSYSTEM_DATA_DIR=\""$(datadir)/games/@PACKAGE@"\" ++AM_CPPFLAGS = -DSYSTEM_DATA_DIR=\""@datadir@"\" + + if WITH_BOOST + FSPATH_IMPL = FsPath_boost.cpp diff --git a/fillets-ng-no-local-paths.patch b/fillets-ng-no-local-paths.patch new file mode 100644 index 0000000..72b7c1f --- /dev/null +++ b/fillets-ng-no-local-paths.patch @@ -0,0 +1,12 @@ +--- configure.in ++++ configure.in +@@ -13,9 +13,6 @@ AC_PROG_CC + AC_PROG_INSTALL + AC_PROG_RANLIB + +-CPPFLAGS="-I/usr/local/include $CPPFLAGS" +-LIBS="-L/usr/local/lib $LIBS" +- + ################################################### + # Check for libm + AC_CHECK_LIB(m, sin, LIBS="$LIBS -lm") diff --git a/fillets-ng-use-lua-pkg-config.patch b/fillets-ng-use-lua-pkg-config.patch new file mode 100644 index 0000000..3740458 --- /dev/null +++ b/fillets-ng-use-lua-pkg-config.patch @@ -0,0 +1,43 @@ +--- configure.in ++++ configure.in +@@ -36,22 +36,24 @@ dnl Debian, and possibly other systems, + LUA_CFLAGS="`[$LUACONFIG --include]`" + LUA_LIBS="`[$LUACONFIG --static]`" + else dnl ...otherwise, attempt to guess +- LUA_CFLAGS="" +- LUA_LIBS="" +- AC_CHECK_LIB(lua, lua_setfenv, LUA_LIBS="$LUA_LIBS -llua", +- [AC_CHECK_LIB(lua50, lua_setfenv, LUA_LIBS="$LUA_LIBS -llua50", +- [AC_CHECK_LIB(lua5.0, lua_setfenv, LUA_LIBS="$LUA_LIBS -llua5.0", +- [AC_MSG_ERROR([*** Lua5 is required. +- Try --with-lua=PREFIX +- You can download lua from http://www.lua.org])], +- $LUA_LIBS)], $LUA_LIBS)], $LUA_LIBS) +- +- AC_CHECK_LIB(lualib, luaopen_base, LUA_LIBS="$LUA_LIBS -llualib", +- [AC_CHECK_LIB(lualib50, luaopen_base, LUA_LIBS="$LUA_LIBS -llualib50", +- [AC_CHECK_LIB(lualib5.0, luaopen_base, LUA_LIBS="$LUA_LIBS -llualib5.0", +- [AC_MSG_ERROR([*** Lualib5 is required. +- You can download lua from http://www.lua.org])], +- $LUA_LIBS)], $LUA_LIBS)], $LUA_LIBS) ++ PKG_CHECK_MODULES(LUA, lua, [], [ ++ LUA_CFLAGS="" ++ LUA_LIBS="" ++ AC_CHECK_LIB(lua, lua_setfenv, LUA_LIBS="$LUA_LIBS -llua", ++ [AC_CHECK_LIB(lua50, lua_setfenv, LUA_LIBS="$LUA_LIBS -llua50", ++ [AC_CHECK_LIB(lua5.0, lua_setfenv, LUA_LIBS="$LUA_LIBS -llua5.0", ++ [AC_MSG_ERROR([*** Lua5 is required. ++ Try --with-lua=PREFIX ++ You can download lua from http://www.lua.org])], ++ $LUA_LIBS)], $LUA_LIBS)], $LUA_LIBS) ++ ++ AC_CHECK_LIB(lualib, luaopen_base, LUA_LIBS="$LUA_LIBS -llualib", ++ [AC_CHECK_LIB(lualib50, luaopen_base, LUA_LIBS="$LUA_LIBS -llualib50", ++ [AC_CHECK_LIB(lualib5.0, luaopen_base, LUA_LIBS="$LUA_LIBS -llualib5.0", ++ [AC_MSG_ERROR([*** Lualib5 is required. ++ You can download lua from http://www.lua.org])], ++ $LUA_LIBS)], $LUA_LIBS)], $LUA_LIBS) ++ ]) + fi + fi + AC_SUBST(LUA_CFLAGS) diff --git a/fish-fillets-X.patch b/fish-fillets-X.patch new file mode 100644 index 0000000..3b21525 --- /dev/null +++ b/fish-fillets-X.patch @@ -0,0 +1,56 @@ +--- configure.in ++++ configure.in +@@ -89,21 +89,31 @@ AC_CHECK_LIB([SDL_ttf], [TTF_OpenFont], + + ################################################### + # Test X11 +-OLD_CPPFLAGS="$CPPFLAGS" +-CPPFLAGS="$CPPFLAGS $SDL_CFLAGS" +-AC_TRY_COMPILE([ +- #include "SDL.h" +- #include "SDL_syswm.h" +- #include +- ], [ +- SDL_SysWMinfo info; +- info.subsystem = SDL_SYSWM_X11; +- ], [have_x11="yes"], [have_x11="no"]) +-CPPFLAGS="$OLD_CPPFLAGS" +-if test "x$have_x11" = xyes; then +- AC_DEFINE(HAVE_X11) ++X_LIBS="" ++AC_ARG_WITH(X, ++ [AC_HELP_STRING([--with-x],[enable X window manager support [default=detect]])], ++ [with_x11=$withval],[with_x11="maybe"]) ++if test "x$with_x11" != "xno" ; then ++ AC_CHECK_LIB([X11], [Xutf8TextListToTextProperty], [with_x11="yes"], [with_x11="no"]) ++ if test "x$with_x11" != "xno" ; then ++ OLD_CPPFLAGS="$CPPFLAGS" ++ CPPFLAGS="$CPPFLAGS $SDL_CFLAGS" ++ AC_TRY_COMPILE([ ++ #include "SDL.h" ++ #include "SDL_syswm.h" ++ #include ++ ], [ ++ SDL_SysWMinfo info; ++ info.subsystem = SDL_SYSWM_X11; ++ ], [have_x11="yes"], [have_x11="no"]) ++ CPPFLAGS="$OLD_CPPFLAGS" ++ if test "x$have_x11" = xyes; then ++ AC_DEFINE(HAVE_X11) ++ X_LIBS="-lX11" ++ fi ++ fi + fi +- ++AC_SUBST(X_LIBS) + + ################################################### + # Test FriBidi +--- src/game/Makefile.am ++++ src/game/Makefile.am +@@ -18,4 +18,4 @@ ICON_LIBS = + endif + + +-fillets_LDADD = $(ICON_LIBS) ../menu/libmenu.a ../level/liblevel.a ../state/libstate.a ../option/liboption.a ../plan/libplan.a ../widget/libwidget.a ../effect/libeffect.a ../gengine/libgengine.a $(SDL_GFX_LIBS) $(SDL_LIBS) $(LUA_LIBS) $(BOOST_LIBS) $(FRIBIDI_LIBS) ++fillets_LDADD = $(ICON_LIBS) ../menu/libmenu.a ../level/liblevel.a ../state/libstate.a ../option/liboption.a ../plan/libplan.a ../widget/libwidget.a ../effect/libeffect.a ../gengine/libgengine.a $(SDL_GFX_LIBS) $(SDL_LIBS) $(LUA_LIBS) $(BOOST_LIBS) $(FRIBIDI_LIBS) $(X_LIBS) diff --git a/gaim-2.0.0_beta3-always-idle.patch b/gaim-2.0.0_beta3-always-idle.patch new file mode 100644 index 0000000..ae010cd --- /dev/null +++ b/gaim-2.0.0_beta3-always-idle.patch @@ -0,0 +1,40 @@ +--- gtk/gtkprefs.c ++++ gtk/gtkprefs.c +@@ -1770,6 +1770,7 @@ away_page() + GAIM_PREF_STRING, "/core/away/idle_reporting", + _("Never"), "none", + _("From last sent message"), "gaim", ++ _("Always idle"), "always", + #if defined(USE_SCREENSAVER) || defined(HAVE_IOKIT) + _("Based on keyboard or mouse use"), "system", + #endif +--- libgaim/idle.c ++++ libgaim/idle.c +@@ -57,6 +57,8 @@ static guint idle_timer = 0; + + static time_t last_active_time = 0; + ++static time_t idle_init_time = 0; ++ + static void + set_account_idle(GaimAccount *account, int time_idle) + { +@@ -134,6 +136,10 @@ check_idleness() + /* Use 'Gaim idle' */ + time_idle = time(NULL) - last_active_time; + } ++ else if (!strcmp(idle_reporting, "always")) ++ { ++ time_idle = time(NULL) - idle_init_time; ++ } + else + { + /* Don't report idle time */ +@@ -243,6 +249,7 @@ gaim_idle_init() + gaim_idle_get_handle(), + GAIM_CALLBACK(signing_off_cb), NULL); + ++ time(&idle_init_time); + gaim_idle_touch(); + } + diff --git a/gcc-ca-translation-typo.patch b/gcc-ca-translation-typo.patch new file mode 100644 index 0000000..af95895 --- /dev/null +++ b/gcc-ca-translation-typo.patch @@ -0,0 +1,15 @@ +2006-03-28 Harald van Dijk + + * ca.po: Fix printf flag typo in negative value translation. + +--- gcc/po/ca.po ++++ gcc/po/ca.po +@@ -31083,7 +31083,7 @@ + #~ msgstr "passant el valor negatiu `%E' per a %s %P de \"%D\"" + + #~ msgid "%s of negative value `%E' to `%T'" +-#~ msgstr "%s de valor negatiu `%I' a \"%T\"" ++#~ msgstr "%s de valor negatiu `%E' a \"%T\"" + + #~ msgid "initializing array with parameter list" + #~ msgstr "inicialitzant una matriu amb una llista de paràmetres" diff --git a/gcc-cris-uclibc-subtarget.patch b/gcc-cris-uclibc-subtarget.patch new file mode 100644 index 0000000..c3397e6 --- /dev/null +++ b/gcc-cris-uclibc-subtarget.patch @@ -0,0 +1,20 @@ +2006-04-13 Mike Frysinger + + * config/cris/linux.h (CRIS_SUBTARGET_VERSION): Set to + cris-axis-linux-uclibc for uClibc targets. + +--- config/cris/linux.h ++++ config/cris/linux.h +@@ -74,7 +74,11 @@ Boston, MA 02110-1301, USA. */ + #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" + diff --git a/gcc-default-cross-headers.patch b/gcc-default-cross-headers.patch new file mode 100644 index 0000000..8e8030a --- /dev/null +++ b/gcc-default-cross-headers.patch @@ -0,0 +1,16 @@ +2006-04-30 Mike Frysinger + + * configure.ac: Set default SYSTEM_HEADER_DIR to + build_system_header_dir when build != host. + +--- trunk/gcc/configure.ac ++++ trunk/gcc/configure.ac +@@ -1717,7 +1717,7 @@ then + | powerpc*-*-*,powerpc64*-*-*) + CROSS="$CROSS -DNATIVE_CROSS" ;; + esac +-elif test "x$TARGET_SYSTEM_ROOT" != x; then ++elif test "x$TARGET_SYSTEM_ROOT" != x -o $build != $host; then + SYSTEM_HEADER_DIR=$build_system_header_dir + fi + diff --git a/gcc-invert-Wattributes-doc.patch b/gcc-invert-Wattributes-doc.patch new file mode 100644 index 0000000..4bd6006 --- /dev/null +++ b/gcc-invert-Wattributes-doc.patch @@ -0,0 +1,34 @@ +2007-02-19 Mike Frysinger + + * doc/invoke.texi (-Wattributes): Change documentation to refer to + -Wattributes rather than -Wno-attributes. + +--- trunk/gcc/doc/invoke.texi (revision 121946) ++++ trunk/gcc/doc/invoke.texi (working copy) +@@ -224,7 +224,7 @@ Objective-C and Objective-C++ Dialects}. + @xref{Warning Options,,Options to Request or Suppress Warnings}. + @gccoptlist{-fsyntax-only -pedantic -pedantic-errors @gol + -w -Wextra -Wall -Waggregate-return -Walways-true -Warray-bounds @gol +--Wno-attributes -Wc++-compat -Wc++0x-compat -Wcast-align -Wcast-qual @gol ++-Wattributes -Wc++-compat -Wc++0x-compat -Wcast-align -Wcast-qual @gol + -Wchar-subscripts -Wclobbered -Wcomment @gol + -Wconversion -Wcoverage-mismatch -Wno-deprecated-declarations @gol + -Wdisabled-optimization -Wno-div-by-zero @gol +@@ -3393,13 +3393,12 @@ Warn about comparisons which are always + unsigned values are greater than or equal to zero. This warning is + enabled by @option{-Wall}. + +-@item -Wno-attributes ++@item -Wattributes + @opindex Wno-attributes + @opindex Wattributes +-Do not warn if an unexpected @code{__attribute__} is used, such as +-unrecognized attributes, function attributes applied to variables, +-etc. This will not stop errors for incorrect use of supported +-attributes. ++Warn if an unexpected @code{__attribute__} is used, such as unrecognized ++attributes, function attributes applied to variables, etc. This does not ++affect errors for incorrect use of supported attributes. + + @item -Wstrict-prototypes @r{(C only)} + @opindex Wstrict-prototypes diff --git a/gcc-libtool-generic-linux.patch b/gcc-libtool-generic-linux.patch new file mode 100644 index 0000000..679f0e1 --- /dev/null +++ b/gcc-libtool-generic-linux.patch @@ -0,0 +1,36 @@ +2006-04-10 Mike Frysinger + + * libtool.m4: Accept linux* instead of just linux-gnu*. + * ltconfig: Likewise. Also accept linux-uclibc* as well as linux-gnu*. + +--- libtool.m4 ++++ libtool.m4 +@@ -739,7 +739,7 @@ + ;; + + # This must be Linux ELF. +-linux-gnu*) ++linux*) + lt_cv_deplibs_check_method=pass_all + ;; + +--- ltconfig ++++ 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/gcc-uclinux-not-uclibc.patch b/gcc-uclinux-not-uclibc.patch new file mode 100644 index 0000000..80e7251 --- /dev/null +++ b/gcc-uclinux-not-uclibc.patch @@ -0,0 +1,15 @@ +2006-04-13 Mike Frysinger + + * crossconfig.m4 (_GLIBCXX_USE_LFS): Tweak uClinux/uClibc note. + +--- crossconfig.m4 ++++ crossconfig.m4 +@@ -161,7 +161,7 @@ case "${host}" in + 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 --git a/gdb-clarify-load.patch b/gdb-clarify-load.patch new file mode 100644 index 0000000..f074ddb --- /dev/null +++ b/gdb-clarify-load.patch @@ -0,0 +1,24 @@ +Index: gdb.texinfo +=================================================================== +RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v +retrieving revision 1.487 +diff -u -p -r1.487 gdb.texinfo +--- gdb.texinfo 24 Apr 2008 12:09:49 -0000 1.487 ++++ gdb.texinfo 27 Apr 2008 21:43:57 -0000 +@@ -12795,10 +12795,12 @@ If your @value{GDBN} does not have a @co + execute it gets the error message ``@code{You can't do that when your + target is @dots{}}'' + +-The file is loaded at whatever address is specified in the executable. +-For some object file formats, you can specify the load address when you +-link the program; for other formats, like a.out, the object file format +-specifies a fixed address. ++The file is loaded according to the load addresses (rather than virtual) as ++is specified in the executable. It is expected that the target system will ++do the actual relocation, and in the process, handle such things as setup of ++allocated sections (e.g. the bss). For some object file formats, you can ++specify the load address when you link the program; for other formats, like ++a.out, the object file format specifies a fixed address. + @c FIXME! This would be a good place for an xref to the GNU linker doc. + + Depending on the remote side capabilities, @value{GDBN} may be able to diff --git a/gdb-dont-load-world-writable-gdbinit.patch b/gdb-dont-load-world-writable-gdbinit.patch new file mode 100644 index 0000000..6540184 --- /dev/null +++ b/gdb-dont-load-world-writable-gdbinit.patch @@ -0,0 +1,22 @@ +2007-03-04 Mike Frysinger + + * main.c: Check if .gdbinit is world writable. + +--- main.c 9 Jan 2007 21:34:29 -0000 1.62 ++++ main.c 4 Mar 2007 22:59:00 -0000 +@@ -763,7 +763,14 @@ extern int gdbtk_test (char *); + || memcmp ((char *) &homebuf, (char *) &cwdbuf, sizeof (struct stat))) + if (!inhibit_gdbinit) + { +- catch_command_errors (source_script, gdbinit, 0, RETURN_MASK_ALL); ++ if (cwdbuf.st_mode & S_IWOTH) ++ { ++ warning (_("Refusing to load world writable gdbinit `%s'.\n"), gdbinit); ++ } ++ else ++ { ++ catch_command_errors (source_script, gdbinit, 0, RETURN_MASK_ALL); ++ } + } + + for (i = 0; i < ncmd; i++) diff --git a/gdb-gdbtk-no-sys-ioctl.patch b/gdb-gdbtk-no-sys-ioctl.patch new file mode 100644 index 0000000..8c806b6 --- /dev/null +++ b/gdb-gdbtk-no-sys-ioctl.patch @@ -0,0 +1,51 @@ +2007-07-26 Mike Frysinger + + * generic/gdbtk-cmds.c (sys/ioctl.h): Remove include. + * generic/gdbtk-hooks.c (sys/ioctl.h): Likewise. + * generic/gdbtk.c (sys/ioctl.h): Likewise. + +Index: gdb/gdbtk/generic/gdbtk-cmds.c +=================================================================== +RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk-cmds.c,v +retrieving revision 1.97 +diff -u -p -r1.97 gdbtk-cmds.c +--- gdb/gdbtk/generic/gdbtk-cmds.c 21 Jun 2007 15:18:51 -0000 1.97 ++++ gdb/gdbtk/generic/gdbtk-cmds.c 26 Jul 2007 08:57:01 -0000 +@@ -57,7 +57,6 @@ + + #include + #include +-#include + #include + #include + +Index: gdb/gdbtk/generic/gdbtk-hooks.c +=================================================================== +RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk-hooks.c,v +retrieving revision 1.41 +diff -u -p -r1.41 gdbtk-hooks.c +--- gdb/gdbtk/generic/gdbtk-hooks.c 23 Dec 2005 18:23:16 -0000 1.41 ++++ gdb/gdbtk/generic/gdbtk-hooks.c 26 Jul 2007 08:57:01 -0000 +@@ -51,7 +51,6 @@ + + #include + #include +-#include + #include + + #include "gdb_string.h" +Index: gdb/gdbtk/generic/gdbtk.c +=================================================================== +RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk.c,v +retrieving revision 1.45 +diff -u -p -r1.45 gdbtk.c +--- gdb/gdbtk/generic/gdbtk.c 1 Dec 2006 02:09:24 -0000 1.45 ++++ gdb/gdbtk/generic/gdbtk.c 26 Jul 2007 08:57:01 -0000 +@@ -49,7 +49,6 @@ + + #include + #include +-#include + #include + #include + diff --git a/gdb-gdbtk-pull-in-windows.patch b/gdb-gdbtk-pull-in-windows.patch new file mode 100644 index 0000000..8d8ffd8 --- /dev/null +++ b/gdb-gdbtk-pull-in-windows.patch @@ -0,0 +1,24 @@ +2007-07-26 Mike Frysinger + + * generic/gdbtk-interp.c: For _WIN32, define WIN32_LEAN_AND_MEAN + and include windows.h. + +Index: gdb/gdbtk/generic/gdbtk-interp.c +=================================================================== +RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk-interp.c,v +retrieving revision 1.8 +diff -u -p -r1.8 gdbtk-interp.c +--- gdb/gdbtk/generic/gdbtk-interp.c 23 Dec 2005 18:23:16 -0000 1.8 ++++ gdb/gdbtk/generic/gdbtk-interp.c 26 Jul 2007 09:08:20 -0000 +@@ -34,6 +34,11 @@ + #include "tk.h" + #include "gdbtk.h" + ++#ifdef _WIN32 ++#define WIN32_LEAN_AND_MEAN ++#include ++#endif ++ + static void gdbtk_command_loop (void); + static void hack_disable_interpreter_exec (char *, int); + diff --git a/gdb-hppa-dollar-lookups.patch b/gdb-hppa-dollar-lookups.patch new file mode 100644 index 0000000..2911667 --- /dev/null +++ b/gdb-hppa-dollar-lookups.patch @@ -0,0 +1,28 @@ +2006-08-20 Mike Frysinger + + * parse.c (write_dollar_variable): Check LOOKUP_DOLLAR_SYMBOLS. + * config/pa/tm-hppa.h [LOOKUP_DOLLAR_SYMBOLS]: Define. + +--- gdb/parse.c ++++ gdb/parse.c +@@ -489,8 +489,12 @@ write_dollar_variable (struct stoken str + /* On some systems, such as HP-UX and hppa-linux, certain system routines + have names beginning with $ or $$. Check for those, first. */ + ++#ifdef LOOKUP_DOLLAR_SYMBOLS + sym = lookup_symbol (copy_name (str), (struct block *) NULL, + VAR_DOMAIN, (int *) NULL, (struct symtab **) NULL); ++#else ++ sym = NULL; ++#endif + if (sym) + { + write_exp_elt_opcode (OP_VAR_VALUE); +--- gdb/config/pa/tm-hppa.h ++++ gdb/config/pa/tm-hppa.h +@@ -28,3 +28,5 @@ + + extern int hppa_pc_requires_run_before_use (CORE_ADDR pc); + #define DEPRECATED_PC_REQUIRES_RUN_BEFORE_USE(pc) hppa_pc_requires_run_before_use (pc) ++ ++#define LOOKUP_DOLLAR_SYMBOLS diff --git a/gdb-locale.patch b/gdb-locale.patch new file mode 100644 index 0000000..25b7fc1 --- /dev/null +++ b/gdb-locale.patch @@ -0,0 +1,58 @@ +2006-06-22 Mike Frysinger : + + * Makefile.in (init.c) [LANG, LC_ALL]: Set to `c'. + * gdb_indent.sh, gdb_mbuild.sh, observer.sh: Likewise + +--- gdb/Makefile.in ++++ gdb/Makefile.in +@@ -1154,6 +1154,8 @@ init.c: $(INIT_FILES) + @rm -f init.c-tmp init.l-tmp + @touch init.c-tmp + @echo gdbtypes > init.l-tmp ++ @-LANG=c ; export LANG ; \ ++ LC_ALL=c ; export LC_ALL ; \ +- @-echo $(INIT_FILES) | \ ++ echo $(INIT_FILES) | \ + tr ' ' '\012' | \ + sed \ +--- gdb/gdb_indent.sh ++++ gdb/gdb_indent.sh +@@ -3,6 +3,11 @@ + # Try to find a GNU indent. There could be a BSD indent in front of a + # GNU gindent so when indent is found, keep looking. + ++# Make certain that the script is running in an internationalized ++# environment. ++LANG=c ; export LANG ++LC_ALL=c ; export LC_ALL ++ + gindent= + indent= + paths=`echo $PATH | sed \ +--- gdb/gdb_mbuild.sh ++++ gdb/gdb_mbuild.sh +@@ -22,6 +22,11 @@ + # Foundation, Inc., 51 Franklin Street, Fifth Floor, + # Boston, MA 02111-1301, USA + ++# Make certain that the script is running in an internationalized ++# environment. ++LANG=c ; export LANG ++LC_ALL=c ; export LC_ALL ++ + usage() + { + cat < " 1>&2 diff --git a/gdb-lookup-internal-first-2.patch b/gdb-lookup-internal-first-2.patch new file mode 100644 index 0000000..b48d4ba --- /dev/null +++ b/gdb-lookup-internal-first-2.patch @@ -0,0 +1,97 @@ +2006-08-21 Mike Frysinger + + * value.h (lookup_only_internalvar): New prototype. + * value.c (lookup_only_internalvar): New function. + (lookup_internalvar): Use lookup_only_internalvar. + * parse.c (write_dollar_variable): Look up $ symbols in internal + table first rather than last. + +--- gdb/value.h ++++ gdb/value.h +@@ -419,6 +419,8 @@ extern void set_internalvar_component (s + int bitpos, int bitsize, + struct value *newvalue); + ++extern struct internalvar *lookup_only_internalvar (char *name); ++ + extern struct internalvar *lookup_internalvar (char *name); + + extern int value_equal (struct value *arg1, struct value *arg2); +--- gdb/value.c ++++ gdb/value.c +@@ -741,10 +741,10 @@ init_if_undefined_command (char* args, i + normally include a dollar sign. + + If the specified internal variable does not exist, +- one is created, with a void value. */ ++ the return value is NULL. */ + + struct internalvar * +-lookup_internalvar (char *name) ++lookup_only_internalvar (char *name) + { + struct internalvar *var; + +@@ -752,6 +752,25 @@ lookup_internalvar (char *name) + if (strcmp (var->name, name) == 0) + return var; + ++ return NULL; ++} ++ ++ ++/* Look up an internal variable with name NAME. NAME should not ++ normally include a dollar sign. ++ ++ If the specified internal variable does not exist, ++ one is created, with a void value. */ ++ ++struct internalvar * ++lookup_internalvar (char *name) ++{ ++ struct internalvar *var; ++ ++ var = lookup_only_internalvar (name); ++ if (var) ++ return var; ++ + var = (struct internalvar *) xmalloc (sizeof (struct internalvar)); + var->name = concat (name, (char *)NULL); + var->value = allocate_value (builtin_type_void); +--- gdb/parse.c ++++ gdb/parse.c +@@ -448,6 +448,7 @@ write_dollar_variable (struct stoken str + { + struct symbol *sym = NULL; + struct minimal_symbol *msym = NULL; ++ struct internalvar *isym = NULL; + + /* Handle the tokens $digits; also $ (short for $0) and $$ (short for $$1) + and $$digits (equivalent to $<-digits> if you could type that). */ +@@ -486,6 +487,17 @@ write_dollar_variable (struct stoken str + if (i >= 0) + goto handle_register; + ++ /* Any names starting with $ are probably debugger internal variables. */ ++ ++ isym = lookup_only_internalvar (copy_name (str) + 1); ++ if (isym) ++ { ++ write_exp_elt_opcode (OP_INTERNALVAR); ++ write_exp_elt_intern (isym); ++ write_exp_elt_opcode (OP_INTERNALVAR); ++ return; ++ } ++ + /* On some systems, such as HP-UX and hppa-linux, certain system routines + have names beginning with $ or $$. Check for those, first. */ + +@@ -508,7 +520,7 @@ write_dollar_variable (struct stoken str + return; + } + +- /* Any other names starting in $ are debugger internal variables. */ ++ /* Any other names are assumed to be debugger internal variables. */ + + write_exp_elt_opcode (OP_INTERNALVAR); + write_exp_elt_intern (lookup_internalvar (copy_name (str) + 1)); diff --git a/gdb-lookup-internal-first-3.patch b/gdb-lookup-internal-first-3.patch new file mode 100644 index 0000000..29dcea0 --- /dev/null +++ b/gdb-lookup-internal-first-3.patch @@ -0,0 +1,124 @@ +2006-08-21 Mike Frysinger + + * value.h (lookup_only_internalvar): New prototype. + (create_internalvar): Likewise. + * value.c (lookup_only_internalvar): New function. + (create_internalvar): Likewise. + (lookup_internalvar): Use new lookup_only_internalvar and + create_internalvar functions. + * parse.c (write_dollar_variable): Look up $ symbols in internal + table first rather than last. + +--- gdb/value.h ++++ gdb/value.h +@@ -419,6 +419,10 @@ extern void set_internalvar_component (s + int bitpos, int bitsize, + struct value *newvalue); + ++extern struct internalvar *lookup_only_internalvar (char *name); ++ ++extern struct internalvar *create_internalvar (char *name); ++ + extern struct internalvar *lookup_internalvar (char *name); + + extern int value_equal (struct value *arg1, struct value *arg2); +--- gdb/value.c ++++ gdb/value.c +@@ -741,10 +741,10 @@ init_if_undefined_command (char* args, i + normally include a dollar sign. + + If the specified internal variable does not exist, +- one is created, with a void value. */ ++ the return value is NULL. */ + + struct internalvar * +-lookup_internalvar (char *name) ++lookup_only_internalvar (char *name) + { + struct internalvar *var; + +@@ -752,6 +752,17 @@ lookup_internalvar (char *name) + if (strcmp (var->name, name) == 0) + return var; + ++ return NULL; ++} ++ ++ ++/* Create an internal variable with name NAME and with a void value. ++ NAME should not normally include a dollar sign. */ ++ ++struct internalvar * ++create_internalvar (char *name) ++{ ++ struct internalvar *var; + var = (struct internalvar *) xmalloc (sizeof (struct internalvar)); + var->name = concat (name, (char *)NULL); + var->value = allocate_value (builtin_type_void); +@@ -762,6 +773,25 @@ lookup_internalvar (char *name) + return var; + } + ++ ++/* Look up an internal variable with name NAME. NAME should not ++ normally include a dollar sign. ++ ++ If the specified internal variable does not exist, ++ one is created, with a void value. */ ++ ++struct internalvar * ++lookup_internalvar (char *name) ++{ ++ struct internalvar *var; ++ ++ var = lookup_only_internalvar (name); ++ if (var) ++ return var; ++ ++ return create_internalvar (name); ++} ++ + struct value * + value_of_internalvar (struct internalvar *var) + { +--- gdb/parse.c ++++ gdb/parse.c +@@ -448,6 +448,7 @@ write_dollar_variable (struct stoken str + { + struct symbol *sym = NULL; + struct minimal_symbol *msym = NULL; ++ struct internalvar *isym = NULL; + + /* Handle the tokens $digits; also $ (short for $0) and $$ (short for $$1) + and $$digits (equivalent to $<-digits> if you could type that). */ +@@ -486,6 +487,17 @@ write_dollar_variable (struct stoken str + if (i >= 0) + goto handle_register; + ++ /* Any names starting with $ are probably debugger internal variables. */ ++ ++ isym = lookup_only_internalvar (copy_name (str) + 1); ++ if (isym) ++ { ++ write_exp_elt_opcode (OP_INTERNALVAR); ++ write_exp_elt_intern (isym); ++ write_exp_elt_opcode (OP_INTERNALVAR); ++ return; ++ } ++ + /* On some systems, such as HP-UX and hppa-linux, certain system routines + have names beginning with $ or $$. Check for those, first. */ + +@@ -508,10 +520,10 @@ write_dollar_variable (struct stoken str + return; + } + +- /* Any other names starting in $ are debugger internal variables. */ ++ /* Any other names are assumed to be debugger internal variables. */ + + write_exp_elt_opcode (OP_INTERNALVAR); +- write_exp_elt_intern (lookup_internalvar (copy_name (str) + 1)); ++ write_exp_elt_intern (create_internalvar (copy_name (str) + 1)); + write_exp_elt_opcode (OP_INTERNALVAR); + return; + handle_last: diff --git a/gdb-lookup-internal-first.patch b/gdb-lookup-internal-first.patch new file mode 100644 index 0000000..58a4cda --- /dev/null +++ b/gdb-lookup-internal-first.patch @@ -0,0 +1,96 @@ +2006-08-21 Mike Frysinger + + * value.h (lookup_only_internalvar): New prototype. + * value.c (lookup_only_internalvar): New function. + (lookup_internalvar): Use lookup_only_internalvar. + * parse.c (write_dollar_variable): Look up $ symbols in internal + table first rather than last. + +--- gdb/value.h ++++ gdb/value.h +@@ -419,6 +419,8 @@ extern void set_internalvar_component (s + int bitpos, int bitsize, + struct value *newvalue); + ++extern struct internalvar *lookup_only_internalvar (char *name); ++ + extern struct internalvar *lookup_internalvar (char *name); + + extern int value_equal (struct value *arg1, struct value *arg2); +--- gdb/value.c ++++ gdb/value.c +@@ -741,10 +741,10 @@ init_if_undefined_command (char* args, i + normally include a dollar sign. + + If the specified internal variable does not exist, +- one is created, with a void value. */ ++ the return value is NULL. */ + + struct internalvar * +-lookup_internalvar (char *name) ++lookup_only_internalvar (char *name) + { + struct internalvar *var; + +@@ -752,6 +752,25 @@ lookup_internalvar (char *name) + if (strcmp (var->name, name) == 0) + return var; + ++ return NULL; ++} ++ ++ ++/* Look up an internal variable with name NAME. NAME should not ++ normally include a dollar sign. ++ ++ If the specified internal variable does not exist, ++ one is created, with a void value. */ ++ ++struct internalvar * ++lookup_internalvar (char *name) ++{ ++ struct internalvar *var; ++ ++ var = lookup_only_internalvar (name); ++ if (var) ++ return var; ++ + var = (struct internalvar *) xmalloc (sizeof (struct internalvar)); + var->name = concat (name, (char *)NULL); + var->value = allocate_value (builtin_type_void); +--- gdb/parse.c ++++ gdb/parse.c +@@ -486,6 +486,17 @@ write_dollar_variable (struct stoken str + if (i >= 0) + goto handle_register; + ++ /* Any names starting with $ are probably debugger internal variables. */ ++ ++ if (str.ptr[0] == '$' && lookup_only_internalvar (copy_name (str) + 1)) ++ { ++internal_lookup: ++ write_exp_elt_opcode (OP_INTERNALVAR); ++ write_exp_elt_intern (lookup_internalvar (copy_name (str) + 1)); ++ write_exp_elt_opcode (OP_INTERNALVAR); ++ return; ++ } ++ + /* On some systems, such as HP-UX and hppa-linux, certain system routines + have names beginning with $ or $$. Check for those, first. */ + +@@ -508,12 +519,9 @@ write_dollar_variable (struct stoken str + return; + } + +- /* Any other names starting in $ are debugger internal variables. */ +- +- write_exp_elt_opcode (OP_INTERNALVAR); +- write_exp_elt_intern (lookup_internalvar (copy_name (str) + 1)); +- write_exp_elt_opcode (OP_INTERNALVAR); +- return; ++ /* Any other names are assumed to be debugger internal variables. */ ++ ++ goto internal_lookup; + handle_last: + write_exp_elt_opcode (OP_LAST); + write_exp_elt_longcst ((LONGEST) i); diff --git a/gdb-sim-superh-targets.patch b/gdb-sim-superh-targets.patch new file mode 100644 index 0000000..fb726c9 --- /dev/null +++ b/gdb-sim-superh-targets.patch @@ -0,0 +1,22 @@ +2007-01-28 Manuel Lauss + + * configure.ac (sh64-*-*): Change to sh64*-*-*. + (sh-*-*): Change to sh*-*-*. + * configure: Regenerated. + +--- sim/configure.ac ++++ sim/configure.ac +@@ -94,11 +94,11 @@ if test "${enable_sim}" != no; then + AC_CONFIG_SUBDIRS(mn10300) + igen=yes + ;; +- sh64-*-*) ++ sh64*-*-*) + AC_CONFIG_SUBDIRS(sh64) + testsuite=yes + ;; +- sh-*-*) ++ sh*-*-*) + AC_CONFIG_SUBDIRS(sh) + testsuite=yes + ;; diff --git a/gdbserver-check-initial-startup.patch b/gdbserver-check-initial-startup.patch new file mode 100644 index 0000000..0e723eb --- /dev/null +++ b/gdbserver-check-initial-startup.patch @@ -0,0 +1,28 @@ +2007-09-21 Mike Frysinger + + * server.c (main): Check status after start_inferior. + +Index: server.c +=================================================================== +RCS file: /cvs/src/src/gdb/gdbserver/server.c,v +retrieving revision 1.56 +diff -u -p -r1.56 server.c +--- server.c 23 Aug 2007 18:08:48 -0000 1.56 ++++ server.c 22 Sep 2007 02:30:10 -0000 +@@ -900,9 +900,14 @@ main (int argc, char *argv[]) + /* Wait till we are at first instruction in program. */ + signal = start_inferior (&argv[2], &status); + ++ if (status == 'W' || status == 'X') ++ { ++ fprintf (stderr, "Aborting server; child exited with %i\n", signal); ++ exit (signal); ++ } ++ + /* We are now (hopefully) stopped at the first instruction of +- the target process. This assumes that the target process was +- successfully created. */ ++ the target process. */ + + /* Don't report shared library events on the initial connection, + even if some libraries are preloaded. */ diff --git a/gdbserver-use-execvp.patch b/gdbserver-use-execvp.patch new file mode 100644 index 0000000..fdc252b --- /dev/null +++ b/gdbserver-use-execvp.patch @@ -0,0 +1,15 @@ +2007-06-12 Mike Frysinger + + * linux-low.c (linux_create_inferior): Change execv to execvp. + +--- linux-low.c ++++ linux-low.c +@@ -165,7 +165,7 @@ linux_create_inferior (char *program, ch + + setpgid (0, 0); + +- execv (program, allargs); ++ execvp (program, allargs); + + fprintf (stderr, "Cannot exec %s: %s.\n", program, + strerror (errno)); diff --git a/genext2fs-chmod-srcdir.patch b/genext2fs-chmod-srcdir.patch new file mode 100644 index 0000000..331a6ea --- /dev/null +++ b/genext2fs-chmod-srcdir.patch @@ -0,0 +1,14 @@ +Index: configure.in +=================================================================== +RCS file: /cvsroot/genext2fs/genext2fs/configure.in,v +retrieving revision 1.6 +diff -u -p -r1.6 configure.in +--- configure.in 20 Dec 2006 00:38:10 -0000 1.6 ++++ configure.in 16 Jan 2007 05:24:33 -0000 +@@ -36,5 +36,5 @@ AC_FUNC_SNPRINTF + AC_FUNC_SCANF_CAN_MALLOC + + AC_OUTPUT([Makefile],[ +-chmod a+x test-mount.sh test.sh ++chmod a+x $ac_top_srcdir/test-mount.sh $ac_top_srcdir/test.sh + ]) diff --git a/genext2fs-integrate-tests.patch b/genext2fs-integrate-tests.patch new file mode 100644 index 0000000..80e4fa2 --- /dev/null +++ b/genext2fs-integrate-tests.patch @@ -0,0 +1,26 @@ +--- Makefile.am ++++ Makefile.am +@@ -2,11 +2,4 @@ bin_PROGRAMS = genext2fs + genext2fs_SOURCES = genext2fs.c + man_MANS = genext2fs.8 + EXTRA_DIST = $(man_MANS) +- +-# test genext2fs by creating the image and comparing checksums +-test: all +- sh ./test.sh +- +-# test genext2fs by actually mounting the created image. +-test-mount: all +- sudo sh ./test-mount.sh ++TESTS = test.sh test-mount.sh +--- configure.in ++++ configure.in +@@ -35,5 +35,6 @@ AC_CHECK_FUNCS([getopt_long getline strt + AC_FUNC_SNPRINTF + AC_FUNC_SCANF_CAN_MALLOC + +-AC_CONFIG_FILES([Makefile]) +-AC_OUTPUT ++AC_OUTPUT([Makefile],[ ++chmod a+x test-mount.sh test.sh ++]) diff --git a/genext2fs-root-test-check.patch b/genext2fs-root-test-check.patch new file mode 100644 index 0000000..6ed54b1 --- /dev/null +++ b/genext2fs-root-test-check.patch @@ -0,0 +1,45 @@ +--- Makefile.am ++++ Makefile.am +@@ -2,4 +2,4 @@ bin_PROGRAMS = genext2fs + genext2fs_SOURCES = genext2fs.c + man_MANS = genext2fs.8 + EXTRA_DIST = $(man_MANS) test-gen.lib test-mount.sh test.sh device_table.txt +-TESTS = test.sh ++TESTS = test-mount.sh test.sh +--- test-gen.lib ++++ test-gen.lib +@@ -52,3 +52,14 @@ calc_digest () { + fi + } + ++if [ "x$NEED_ROOT" = "xyes" ] ; then ++ my_uid=`id -u` ++ if [ $? != 0 ] ; then ++ echo "Failed to run 'id -u'" 1>&2 ++ exit 1 ++ fi ++ if [ "x$my_uid" != "x0" ] ; then ++ echo "Skipping test as this requires root access" ++ exit 0 ++ fi ++fi +--- test-mount.sh ++++ test-mount.sh +@@ -6,6 +6,7 @@ + + set -e + ++NEED_ROOT=yes + . ./test-gen.lib + + test_cleanup () { +--- test.sh ++++ test.sh +@@ -11,6 +11,7 @@ + + set -e + ++NEED_ROOT=no + . ./test-gen.lib + + # md5cmp - Calculate MD5 digest and compare it to an expected value. diff --git a/genkernel-manpage-touchups.patch b/genkernel-manpage-touchups.patch new file mode 100644 index 0000000..76803e0 --- /dev/null +++ b/genkernel-manpage-touchups.patch @@ -0,0 +1,50 @@ +Index: genkernel.8 +=================================================================== +--- genkernel.8 (revision 480) ++++ genkernel.8 (working copy) +@@ -2,7 +2,7 @@ + .SH NAME + genkernel \- the Gentoo Linux automatic kernel compiler. + .SH SYNOPSIS +-genkernel [options...] action ++\fBgenkernel\fR \fI[options...] action\fR + .SH INTRODUCTION + Genkernel is designed to allow users who are not previously used to + compiling a kernel to use a similar setup to that one that is used on +@@ -252,14 +252,14 @@ Passes arguments to dmraid on bootup. + \fBreal_init=\fR<...> + Passes arguments to init on bootup. + .TP +-\fBscandelay\fR=<...> ++\fBscandelay=\fR<...> + Pauses for 10 seconds before running devfsd if no argument is specified; + otherwise pauses for the number of specified seconds. + .TP +-\fBip\fR=<...> ++\fBip=\fR<...> + Normally used to tell the kernel that it should start a network interface. If present, the initrd will try to mount a livecd over NFS. + .TP +-\fBnfsroot\fR=<...> ++\fBnfsroot=\fR<...> + If present, the initrd will try to mount a livecd from that location. Otherwise the location will be deduced from the DCHP request (option root\-path) + .TP + \fBdoevms2\fR +@@ -289,11 +289,10 @@ existing bug documents the same issue be + for kernel sources not supported by Gentoo should go to their relevant + authors. + .SH AUTHORS +-Tim Yamin +-.B +-.sp +-Eric Edgar +-.B +-.sp +-NFS Support by Thomas Seiler +-.B ++.nf ++Tim Yamin ++Eric Edgar ++NFS Support by Thomas Seiler ++.fi ++.SH SEE ALSO ++\fB/etc/genkernel.conf\fR \- genkernel configuration file diff --git a/gentoo-handbook-integrate-ia64-bootloader.patch b/gentoo-handbook-integrate-ia64-bootloader.patch new file mode 100644 index 0000000..64f312a --- /dev/null +++ b/gentoo-handbook-integrate-ia64-bootloader.patch @@ -0,0 +1,134 @@ +? blah.html +? handbook-sh.xml +? hb-install-sh-medium.xml +Index: handbook-ia64.xml +=================================================================== +RCS file: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/handbook-ia64.xml,v +retrieving revision 1.6 +diff -u -p -r1.6 handbook-ia64.xml +--- handbook-ia64.xml 29 Nov 2006 15:35:24 -0000 1.6 ++++ handbook-ia64.xml 13 Feb 2007 03:23:36 -0000 +@@ -213,7 +213,7 @@ explains how to configure your kernel. + The ia64 architecture uses the elilo bootloader. + This chapter explains how to install and configure elilo. + +- ++ + + + +Index: hb-install-x86+amd64-bootloader.xml +=================================================================== +RCS file: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/hb-install-x86+amd64-bootloader.xml,v +retrieving revision 1.6 +diff -u -p -r1.6 hb-install-x86+amd64-bootloader.xml +--- hb-install-x86+amd64-bootloader.xml 2 Nov 2006 07:27:24 -0000 1.6 ++++ hb-install-x86+amd64-bootloader.xml 13 Feb 2007 03:23:36 -0000 +@@ -191,7 +191,7 @@ link="#lilo">LILO. + + + +-
++
+ Default: Using GRUB + + Understanding GRUB's terminology +@@ -658,6 +658,78 @@ You can now continue with ++Alternative: Using ELILO ++ ++Installing ELILO ++ ++ ++

++ELILO, the EFI LInuxLOader, is the standard Linux bootloader for ++EFI ++based systems. This includes all Itanium machines. ++

++ ++
++# emerge elilo
++
++ ++

++You can find the configuration file at /etc/elilo.conf and a ++sample file in the typical docs dir /usr/share/doc/elilo-<ver>/. ++Here is another sample configuration: ++

++ ++
++boot=/dev/sda1
++delay=30
++timeout=50
++default=Gentoo
++append="console=ttyS0,9600"
++prompt
++
++image=/vmlinuz
++	label=Gentoo
++	root=/dev/sda2
++	read-only
++
++image=/vmlinuz.old
++	label=Gentoo.old
++	root=/dev/sda2
++	read-only
++
++ ++

++The boot line tells elilo the location of the boot partition (in this ++case, /dev/sda1). The delay line sets the number of 10th ++of seconds before automatically booting the default when in non-interactive ++mode. The timeout line is just like the delay line but for interactive ++mode. The default line sets the default kernel entry (which is defined ++below). The append line adds extra options to the kernel cmdline. The ++prompt sets the default elilo behavior to interactive. ++

++ ++

++The sections that start with image defines different bootable images. ++Each image has a nice label, a root filesystem, and will only ++mount the root filesystem read-only. ++

++ ++

++When configuration is done, just run elilo --efiboot. The ++--efiboot option adds a menu entry for Gentoo to the EFI Boot Manager. ++

++ ++
++# elilo --efiboot
++
++ ++

++Now continue with Rebooting the System. ++

++ ++
++
+
+ Rebooting the System + +@@ -668,12 +740,18 @@ Exit the chrooted environment and unmoun + that one magical command you have been waiting for: reboot. +

+ +-
++
+ # exit
+ cdimage ~# cd
+ cdimage ~# umount /mnt/gentoo/boot /mnt/gentoo/dev /mnt/gentoo/proc /mnt/gentoo
+ cdimage ~# reboot
+ 
++
++# exit
++cdimage ~# cd
++cdimage ~# umount /mnt/gentoo/boot /mnt/gentoo/dev /mnt/gentoo/proc /mnt/gentoo/sys /mnt/gentoo
++cdimage ~# reboot
++
+ +

+ Of course, don't forget to remove the bootable CD, otherwise the CD will be diff --git a/glibc-2.3.6-i686.patch b/glibc-2.3.6-i686.patch new file mode 100644 index 0000000..f9ce2df --- /dev/null +++ b/glibc-2.3.6-i686.patch @@ -0,0 +1,62 @@ +diff -ur glibc-2.3.6.orig/sysdeps/i386/elf/bsd-setjmp.S glibc-2.3.6/sysdeps/i386/elf/bsd-setjmp.S +--- glibc-2.3.6.orig/sysdeps/i386/elf/bsd-setjmp.S 2007-03-26 22:00:44.000000000 +0200 ++++ glibc-2.3.6/sysdeps/i386/elf/bsd-setjmp.S 2007-03-26 22:00:33.000000000 +0200 +@@ -27,6 +27,9 @@ + #define PARMS LINKAGE /* no space for saved regs */ + #define JMPBUF PARMS + #define SIGMSK JMPBUF+PTR_SIZE ++#ifdef __i686 ++#undef __i686 ++#endif + + ENTRY (BP_SYM (setjmp)) + /* Note that we have to use a non-exported symbol in the next +diff -ur glibc-2.3.6.orig/sysdeps/i386/elf/setjmp.S glibc-2.3.6/sysdeps/i386/elf/setjmp.S +--- glibc-2.3.6.orig/sysdeps/i386/elf/setjmp.S 2007-03-26 22:00:52.000000000 +0200 ++++ glibc-2.3.6/sysdeps/i386/elf/setjmp.S 2007-03-26 22:00:17.000000000 +0200 +@@ -27,6 +27,9 @@ + #define PARMS LINKAGE /* no space for saved regs */ + #define JMPBUF PARMS + #define SIGMSK JMPBUF+PTR_SIZE ++#ifdef __i686 ++#undef __i686 ++#endif + + ENTRY (BP_SYM (__sigsetjmp)) + ENTER +diff -ru glibc-2.3.6/sysdeps/i386/i686/memcmp.S glibc-2.3.6.new/sysdeps/i386/i686/memcmp.S +--- glibc-2.3.6/sysdeps/i386/i686/memcmp.S 2004-04-02 01:28:37.000000000 +0200 ++++ glibc-2.3.6.new/sysdeps/i386/i686/memcmp.S 2007-04-19 14:01:44.000000000 +0200 +@@ -350,6 +350,7 @@ + sbbl $-1, %eax + popl %esi + RETURN ++END (BP_SYM (memcmp)) + + .section .rodata + ALIGN (2) +@@ -387,8 +388,6 @@ + .long L(30bytes) - . + 0x78 + .long L(31bytes) - . + 0x7c + +-END (BP_SYM (memcmp)) +- + #undef bcmp + weak_alias (BP_SYM (memcmp), BP_SYM (bcmp)) + libc_hidden_builtin_def (BP_SYM (memcmp)) +diff -ru glibc-2.3.6/sysdeps/unix/sysv/linux/i386/sysdep.h glibc-2.3.6.new/sysdeps/unix/sysv/linux/i386/sysdep.h +--- glibc-2.3.6/sysdeps/unix/sysv/linux/i386/sysdep.h 2005-02-16 12:20:22.000000000 +0100 ++++ glibc-2.3.6.new/sysdeps/unix/sysv/linux/i386/sysdep.h 2007-04-19 14:01:55.000000000 +0200 +@@ -21,6 +21,11 @@ + #ifndef _LINUX_I386_SYSDEP_H + #define _LINUX_I386_SYSDEP_H 1 + ++/* This confuses apple-gcc */ ++#ifdef __i686 ++#undef __i686 ++#endif ++ + /* There is some commonality. */ + #include + #include + diff --git a/glibc-2.5-linuxthreads-gai-headers.patch b/glibc-2.5-linuxthreads-gai-headers.patch new file mode 100644 index 0000000..2087219 --- /dev/null +++ b/glibc-2.5-linuxthreads-gai-headers.patch @@ -0,0 +1,14 @@ +2006-10-12 Mike Frysinger + + * sysdeps/pthread/gai_misc.h: Include pthread.h. + +--- linuxthreads/sysdeps/pthread/gai_misc.h ++++ linuxthreads/sysdeps/pthread/gai_misc.h +@@ -23,6 +23,7 @@ + + #include + #include ++#include + + #undef DONT_NEED_GAI_MISC_COND + diff --git a/glibc-alpha-no-asm-page.patch b/glibc-alpha-no-asm-page.patch new file mode 100644 index 0000000..b198b36 --- /dev/null +++ b/glibc-alpha-no-asm-page.patch @@ -0,0 +1,26 @@ +2008-06-07 Mike Frysinger + + * sysdeps/unix/sysv/linux/alpha/sys/user.h: Copy page.h definitions + from the kernel header to sys/user.h and remove the #include of + sys/user.h. + +--- a/sysdeps/unix/sysv/linux/alpha/sys/user.h ++++ b/sysdeps/unix/sysv/linux/alpha/sys/user.h +@@ -23,7 +23,6 @@ + only. Don't read too much into it. Don't use it for anything other + than gdb/strace unless you know what you are doing. */ + +-#include + #include + + struct user +@@ -41,6 +40,9 @@ struct user + char u_comm[32]; /* user command name */ + }; + ++#define PAGE_SHIFT 13 ++#define PAGE_SIZE (1 << PAGE_SHIFT) ++#define PAGE_MASK (~(PAGE_SIZE-1)) + #define NBPG PAGE_SIZE + #define UPAGES 1 + #define HOST_TEXT_START_ADDR (u.start_code) diff --git a/glibc-awk-in-C-locale.patch b/glibc-awk-in-C-locale.patch new file mode 100644 index 0000000..32fe12c --- /dev/null +++ b/glibc-awk-in-C-locale.patch @@ -0,0 +1,17 @@ +http://bugs.gentoo.org/184281 + +2007-07-05 Mike Frysinger + + * Makeconfig (gnu/lib-names.h): Use LC_ALL=C when running awk script. + +--- libc/Makeconfig ++++ libc/Makeconfig +@@ -856,7 +857,7 @@ $(common-objpfx)gnu/lib-names.stmp: $(.. + $(common-objpfx)soversions.i + $(make-target-directory) + @rm -f ${@:stmp=T} $@ +- $(AWK) -f $^ > ${@:stmp=T} ++ LC_ALL=C $(AWK) -f $^ > ${@:stmp=T} + $(move-if-change) ${@:stmp=T} ${@:stmp=h} + touch $@ + endif diff --git a/glibc-bash-2.patch b/glibc-bash-2.patch new file mode 100644 index 0000000..4829824 --- /dev/null +++ b/glibc-bash-2.patch @@ -0,0 +1,31 @@ +Index: ChangeLog +=================================================================== +RCS file: /cvs/glibc/libc/ChangeLog,v +retrieving revision 1.10667 +diff -u -p -r1.10667 ChangeLog +--- ChangeLog 8 Jun 2007 03:17:15 -0000 1.10667 ++++ ChangeLog 8 Jun 2007 04:46:47 -0000 +@@ -1,6 +1,7 @@ + 2007-06-07 Ulrich Drepper + + * configure.in: Avoid variable named BASH. ++ * config.make.in: Likewise. + Patch in part by Mike Frysinger. + + 2007-06-06 Jakub Jelinek +Index: config.make.in +=================================================================== +RCS file: /cvs/glibc/libc/config.make.in,v +retrieving revision 1.121 +diff -u -p -r1.121 config.make.in +--- config.make.in 17 Mar 2007 17:02:00 -0000 1.121 ++++ config.make.in 8 Jun 2007 04:46:47 -0000 +@@ -117,7 +117,7 @@ LN_S = @LN_S@ + MSGFMT = @MSGFMT@ + + # Script execution tools. +-BASH = @BASH@ ++BASH = @BASH_SHELL@ + KSH = @KSH@ + AWK = @AWK@ + PERL = @PERL@ diff --git a/glibc-bash-prog-search.patch b/glibc-bash-prog-search.patch new file mode 100644 index 0000000..0d11404 --- /dev/null +++ b/glibc-bash-prog-search.patch @@ -0,0 +1,19 @@ +2007-06-01 Mike Frysinger + + * configure.in (AC_PATH_PROG(BASH)): Change BASH to BASH_SHELL + and set BASH to BASH_SHELL. + * configure: Rebuilt. + +--- libc/configure.in ++++ libc/configure.in +@@ -980,7 +980,9 @@ + fi]) + AC_SUBST(libc_cv_gcc_static_libgcc) + +-AC_PATH_PROG(BASH, bash, no) ++dnl bash will set $BASH automatically to $0, so use $BASH_SHELL ++AC_PATH_PROG(BASH_SHELL, bash, no) ++BASH=$BASH_SHELL + if test "$BASH" != no && + $BASH -c 'test "$BASH_VERSINFO" \ + && test "$BASH_VERSINFO" -ge 2 >&/dev/null'; then diff --git a/glibc-error-header-updates.patch b/glibc-error-header-updates.patch new file mode 100644 index 0000000..3d27835 --- /dev/null +++ b/glibc-error-header-updates.patch @@ -0,0 +1,57 @@ +2006-04-07 Mike Frysinger + + * misc/error.h (__attribute__): Rename to __error_attribute__. + (__format__): Rename to __error_format__. + (__printf__): Rename to __error_printf__. + (error): Update prototype to use new names. + (error_at_line): Likewise. + +--- misc/error.h ++++ misc/error.h +@@ -1,5 +1,5 @@ + /* Declaration for error-reporting function +- Copyright (C) 1995, 1996, 1997, 2003 Free Software Foundation, Inc. ++ Copyright (C) 1995, 1996, 1997, 2003, 2006 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 +@@ -20,16 +20,21 @@ + #ifndef _ERROR_H + #define _ERROR_H 1 + +-#ifndef __attribute__ ++#ifndef __error_attribute__ + /* This feature is available in gcc versions 2.5 and later. */ + # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__ +-# define __attribute__(Spec) /* empty */ ++# define __error_attribute__(Spec) /* empty */ ++# else ++# define __error_attribute__(Spec) __attribute__(Spec) + # endif + /* The __-protected variants of `format' and `printf' attributes + are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ + # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) +-# define __format__ format +-# define __printf__ printf ++# define __error_format__ format ++# define __error_printf__ printf ++# else ++# define __error_format__ __format__ ++# define __error_printf__ __printf__ + # endif + #endif + +@@ -44,11 +49,11 @@ extern "C" { + If STATUS is nonzero, terminate the program with `exit (STATUS)'. */ + + extern void error (int __status, int __errnum, const char *__format, ...) +- __attribute__ ((__format__ (__printf__, 3, 4))); ++ __error_attribute__ ((__error_format__ (__error_printf__, 3, 4))); + + extern void error_at_line (int __status, int __errnum, const char *__fname, + unsigned int __lineno, const char *__format, ...) +- __attribute__ ((__format__ (__printf__, 5, 6))); ++ __error_attribute__ ((__error_format__ (__error_printf__, 5, 6))); + + /* If NULL, error will flush stdout, then print on stderr the program + name, a colon and a space. Otherwise, error will call this diff --git a/glibc-fdatasync-lockf-cancellation.patch b/glibc-fdatasync-lockf-cancellation.patch new file mode 100644 index 0000000..5f4ed8f --- /dev/null +++ b/glibc-fdatasync-lockf-cancellation.patch @@ -0,0 +1,129 @@ +05-06-2007 Mike Frysinger + + * sysdeps/unix/make-syscalls.sh: Document "C" syscall signature. + * sysdeps/unix/sysv/linux/syscalls.list (fdatasync): Add "C" to args. + * io/lockf.c: Handle pthread cancellation. + * nptl/tst-cancel-wrappers.sh: Set C["fdatasync"] and C["lockf"] to 1. + * nptl/tst-cancel4.c (tf_fdatasync): New test. + +--- sysdeps/unix/make-syscalls.sh ++++ sysdeps/unix/make-syscalls.sh +@@ -10,6 +10,7 @@ + # a: unchecked address (e.g., 1st arg to mmap) + # b: non-NULL buffer (e.g., 2nd arg to read; return value from mmap) + # B: optionally-NULL buffer (e.g., 4th arg to getsockopt) ++# C: pthread cancellation endpoint + # f: buffer of 2 ints (e.g., 4th arg to socketpair) + # F: 3rd arg to fcntl + # i: scalar (any signedness & size: int, long, long long, enum, whatever) +--- sysdeps/unix/sysv/linux/syscalls.list ++++ sysdeps/unix/sysv/linux/syscalls.list +@@ -11,7 +11,7 @@ + epoll_ctl EXTRA epoll_ctl i:iiip epoll_ctl + epoll_wait EXTRA epoll_wait Ci:ipii epoll_wait + epoll_pwait EXTRA epoll_pwait Ci:ipiipi epoll_pwait +-fdatasync - fdatasync i:i fdatasync ++fdatasync - fdatasync Ci:i fdatasync + flock - flock i:ii __flock flock + fork - fork i: __libc_fork __fork fork + get_kernel_syms EXTRA get_kernel_syms i:p get_kernel_syms +--- io/lockf.c ++++ io/lockf.c +@@ -18,6 +18,7 @@ + + #include + #include ++#include /* Must come before . */ + #include + #include + #include +@@ -68,7 +69,16 @@ + } + + /* lockf() is a cancellation point but so is fcntl() if F_SETLKW is +- used. Therefore we don't have to care about cancellation here, +- the fcntl() function will take care of it. */ +- return __fcntl (fd, cmd, &fl); ++ used. Therefore we don't have to care about cancellation in that ++ case as the fcntl() function will take care of it. */ ++ if (SINGLE_THREAD_P || cmd == F_SETLKW) ++ return __fcntl (fd, cmd, &fl); ++ ++ int oldtype = LIBC_CANCEL_ASYNC (); ++ ++ int result = __fcntl (fd, cmd, &fl); ++ ++ LIBC_CANCEL_RESET (oldtype); ++ ++ return result; + } +--- nptl/tst-cancel-wrappers.sh ++++ nptl/tst-cancel-wrappers.sh +@@ -26,7 +26,9 @@ C["close"]=1 + C["connect"]=1 + C["creat"]=1 + C["fcntl"]=1 ++C["fdatasync"]=1 + C["fsync"]=1 ++C["lockf"]=1 + C["msgrcv"]=1 + C["msgsnd"]=1 + C["msync"]=1 +--- nptl/tst-cancel4.c ++++ nptl/tst-cancel4.c +@@ -1571,6 +1571,47 @@ tf_fsync (void *arg) + + + static void * ++tf_fdatasync (void *arg) ++{ ++ if (arg == NULL) ++ // XXX If somebody can provide a portable test case in which fdatasync() ++ // blocks we can enable this test to run in both rounds. ++ abort (); ++ ++ tempfd = open ("Makefile", O_RDONLY); ++ if (tempfd == -1) ++ { ++ printf ("%s: cannot open Makefile\n", __FUNCTION__); ++ exit (1); ++ } ++ ++ int r = pthread_barrier_wait (&b2); ++ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) ++ { ++ printf ("%s: barrier_wait failed\n", __FUNCTION__); ++ exit (1); ++ } ++ ++ r = pthread_barrier_wait (&b2); ++ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) ++ { ++ printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__); ++ exit (1); ++ } ++ ++ pthread_cleanup_push (cl, NULL); ++ ++ fdatasync (tempfd); ++ ++ pthread_cleanup_pop (0); ++ ++ printf ("%s: fdatasync returned\n", __FUNCTION__); ++ ++ exit (1); ++} ++ ++ ++static void * + tf_msync (void *arg) + { + if (arg == NULL) +@@ -2078,6 +2119,7 @@ static struct + ADD_TEST (pread, 2, 1), + ADD_TEST (pwrite, 2, 1), + ADD_TEST (fsync, 2, 1), ++ ADD_TEST (fdatasync, 2, 1), + ADD_TEST (msync, 2, 1), + ADD_TEST (sendto, 2, 1), + ADD_TEST (sendmsg, 2, 1), diff --git a/glibc-fix-generic-strchr-signed-warning.patch b/glibc-fix-generic-strchr-signed-warning.patch new file mode 100644 index 0000000..bc8e457 --- /dev/null +++ b/glibc-fix-generic-strchr-signed-warning.patch @@ -0,0 +1,17 @@ +2006-05-15 Mike Frysinger + + * string/strchr.c: Add cast to avoid warning. + +--- string/strchr.c ++++ string/strchr.c +@@ -42,8 +42,8 @@ strchr (s, c_in) + + /* Handle the first few characters by reading one character at a time. + Do this until CHAR_PTR is aligned on a longword boundary. */ +- for (char_ptr = s; ((unsigned long int) char_ptr +- & (sizeof (longword) - 1)) != 0; ++ for (char_ptr = (const unsigned char *) s; ++ ((unsigned long int) char_ptr & (sizeof (longword) - 1)) != 0; + ++char_ptr) + if (*char_ptr == c) + return (void *) char_ptr; diff --git a/glibc-getcwd-param-MAX.patch b/glibc-getcwd-param-MAX.patch new file mode 100644 index 0000000..e8cb45e --- /dev/null +++ b/glibc-getcwd-param-MAX.patch @@ -0,0 +1,14 @@ +2006-06-18 Mike Frysinger + + * sysdeps/unix/sysv/linux/getcwd.c: Include sys/param.h. + +--- sysdeps/unix/sysv/linux/getcwd.c ++++ sysdeps/unix/sysv/linux/getcwd.c +@@ -24,6 +24,7 @@ + #include + #include + #include ++#include + + #include + #include diff --git a/glibc-handle-long-kernel-versions.patch b/glibc-handle-long-kernel-versions.patch new file mode 100644 index 0000000..bda3ca7 --- /dev/null +++ b/glibc-handle-long-kernel-versions.patch @@ -0,0 +1,16 @@ +2007-07-07 Mike Frysinger + + * sysdeps/unix/sysv/linux/dl-osinfo.h (_dl_discover_osversion): Break + after reading the first 3 parts of the kernel version. + +--- libc/sysdeps/unix/sysv/linux/dl-osinfo.h ++++ libc/sysdeps/unix/sysv/linux/dl-osinfo.h +@@ -112,7 +112,7 @@ _dl_discover_osversion (void) + version = 0; + parts = 0; + cp = buf; +- while ((*cp >= '0') && (*cp <= '9')) ++ while ((*cp >= '0') && (*cp <= '9') && parts < 3) + { + unsigned int here = *cp++ - '0'; + diff --git a/glibc-hppa-tighter-atomic-constraints.patch b/glibc-hppa-tighter-atomic-constraints.patch new file mode 100644 index 0000000..79b7eab --- /dev/null +++ b/glibc-hppa-tighter-atomic-constraints.patch @@ -0,0 +1,21 @@ +With some code compiled with -fPIC -O1, gcc may use a "register(register)" +format when stw can only take "constant(register)" ... so change the +constraint to match this requirement. + +2007-02-10 Mike Frysinger + + * sysdeps/unix/sysv/linux/hppa/bits/atomic.h + (atomic_compare_and_exchange_val_acq): Change `m' constraint to an + `o' memory constraint for first two input operands. + +--- ports/sysdeps/unix/sysv/linux/hppa/bits/atomic.h ++++ ports/sysdeps/unix/sysv/linux/hppa/bits/atomic.h +@@ -76,7 +76,7 @@ typedef uintmax_t uatomic_max_t; + "stw %%r28, %0 \n\t" \ + "sub %%r0, %%r21, %%r21 \n\t" \ + "stw %%r21, %1 \n\t" \ +- : "=m" (lws_ret), "=m" (lws_errno), "=m" (*mem) \ ++ : "=o" (lws_ret), "=o" (lws_errno), "=m" (*mem) \ + : "r" (mem), "r" (oldval), "r" (newval) \ + : LWS_CLOBBER \ + ); \ diff --git a/glibc-inet-network-0x.patch b/glibc-inet-network-0x.patch new file mode 100644 index 0000000..7f52fbc --- /dev/null +++ b/glibc-inet-network-0x.patch @@ -0,0 +1,39 @@ +2007-09-15 Mike Frysinger + + * inet/inet_net.c: Reset digit to 0 for inputs starting with "0x". + * inet/tst-network.c (tests): Add edge case tests for "0", "0x", "0x0". + +Index: inet/inet_net.c +=================================================================== +RCS file: /cvs/glibc/libc/inet/inet_net.c,v +retrieving revision 1.10 +diff -u -p -r1.10 inet_net.c +--- inet/inet_net.c 12 Feb 2000 07:38:04 -0000 1.10 ++++ inet/inet_net.c 15 Sep 2007 06:14:59 -0000 +@@ -55,7 +55,7 @@ again: + if (*cp == '0') + digit = 1, base = 8, cp++; + if (*cp == 'x' || *cp == 'X') +- base = 16, cp++; ++ digit = 0, base = 16, cp++; + while ((c = *cp) != 0) { + if (isdigit(c)) { + if (base == 8 && (c == '8' || c == '9')) +Index: inet/tst-network.c +=================================================================== +RCS file: /cvs/glibc/libc/inet/tst-network.c,v +retrieving revision 1.4 +diff -u -p -r1.4 tst-network.c +--- inet/tst-network.c 15 Sep 2007 04:10:38 -0000 1.4 ++++ inet/tst-network.c 15 Sep 2007 06:14:59 -0000 +@@ -34,7 +34,10 @@ struct + {"1.0", 0x100}, + {"1", 0x1}, + {"192.168.0.0", 0xC0A80000}, ++ {"0", 0}, ++ {"0x0", 0}, + /* Now some invalid addresses. */ ++ {"0x", INADDR_NONE}, + {"141.30.225.2800", INADDR_NONE}, + {"141.76.1.1.1", INADDR_NONE}, + {"141.76.1.11.", INADDR_NONE}, diff --git a/glibc-libc-symbols-set-support.patch b/glibc-libc-symbols-set-support.patch new file mode 100644 index 0000000..11d70ab --- /dev/null +++ b/glibc-libc-symbols-set-support.patch @@ -0,0 +1,44 @@ +2006-05-04 Bernd Schmidt + + * include/libc-symbols.h [HAVE_ASM_SET_DIRECTIVE]: Update weak_alias() + to utilize .set where appropriate. + +--- include/libc-symbols.h ++++ include/libc-symbols.h +@@ -176,18 +176,31 @@ + + # else /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */ + +-# ifdef HAVE_ASM_GLOBAL_DOT_NAME +-# define weak_alias(original, alias) \ ++# ifdef HAVE_ASM_SET_DIRECTIVE ++# ifdef HAVE_ASM_GLOBAL_DOT_NAME ++# define weak_alias(original, alias) \ ++ .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \ ++ .set C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original) ASM_LINE_SEP \ ++ .weak C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \ ++ .set C_SYMBOL_DOT_NAME (alias), C_SYMBOL_DOT_NAME (original) ++# else ++# define weak_alias(original, alias) \ ++ .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \ ++ .set C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original) ++# endif ++# else /* ! HAVE_ASM_SET_DIRECTIVE */ ++# ifdef HAVE_ASM_GLOBAL_DOT_NAME ++# define weak_alias(original, alias) \ + .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \ + C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP \ + .weak C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \ + C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original) +-# else +-# define weak_alias(original, alias) \ ++# else ++# define weak_alias(original, alias) \ + .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \ + C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ++# endif + # endif +- + # define weak_extern(symbol) \ + .weak C_SYMBOL_NAME (symbol) + diff --git a/glibc-linux-ptrace-updates.patch b/glibc-linux-ptrace-updates.patch new file mode 100644 index 0000000..5837c79 --- /dev/null +++ b/glibc-linux-ptrace-updates.patch @@ -0,0 +1,78 @@ +2006-09-17 Mike Frysinger + + * sysdeps/unix/sysv/linux/sys/ptrace.h [PTRACE_SETOPTIONS, + PTRACE_GETEVENTMSG, PTRACE_GETSIGINFO, PTRACE_SETSIGINFO]: Define. + * sysdeps/unix/sysv/linux/ptrace.c [PTRACE_SETOPTIONS, + PTRACE_GETEVENTMSG, PTRACE_GETSIGINFO, PTRACE_SETSIGINFO]: Check. + +--- libc/sysdeps/unix/sysv/linux/ptrace.c ++++ libc/sysdeps/unix/sysv/linux/ptrace.c +@@ -1,4 +1,4 @@ +-/* Copyright (C) 1995,1996,1997,1998,2000,2003 Free Software Foundation, Inc. ++/* Copyright (C) 1995-1998,2000,2003,2006 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 +@@ -21,6 +21,7 @@ + #include + #include + #include ++#include + + #include + #include +@@ -89,6 +90,19 @@ ptrace (enum __ptrace_request request, . + #endif + break; + ++ case PTRACE_GETSIGINFO: ++ case PTRACE_SETSIGINFO: ++ (void) CHECK_1 ((siginfo_t *) data); ++ break; ++ ++ case PTRACE_GETEVENTMSG: ++ (void) CHECK_1 ((unsigned long *) data); ++ break; ++ ++ case PTRACE_SETOPTIONS: ++ (void) CHECK_1 ((long *) data); ++ break; ++ + case PTRACE_TRACEME: + case PTRACE_CONT: + case PTRACE_KILL: +--- libc/sysdeps/unix/sysv/linux/sys/ptrace.h ++++ libc/sysdeps/unix/sysv/linux/sys/ptrace.h +@@ -1,5 +1,5 @@ + /* `ptrace' debugger support interface. Linux version. +- Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. ++ Copyright (C) 1996-1999,2000,2006 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 +@@ -109,8 +109,24 @@ enum __ptrace_request + #define PT_SETFPXREGS PTRACE_SETFPXREGS + + /* Continue and stop at the next (return from) syscall. */ +- PTRACE_SYSCALL = 24 ++ PTRACE_SYSCALL = 24, + #define PT_SYSCALL PTRACE_SYSCALL ++ ++ /* Set ptrace filter options. */ ++ PTRACE_SETOPTIONS = 0x4200, ++#define PT_SETOPTIONS PTRACE_SETOPTIONS ++ ++ /* Get last ptrace message. */ ++ PTRACE_GETEVENTMSG = 0x4201, ++#define PT_GETEVENTMSG PT_SETOPTIONS ++ ++ /* Get siginfo for process. */ ++ PTRACE_GETSIGINFO = 0x4202, ++#define PT_GETSIGINFO PTRACE_GETSIGINFO ++ ++ /* Set new siginfo for process. */ ++ PTRACE_SETSIGINFO = 0x4203 ++#define PT_SETSIGINFO PTRACE_SETSIGINFO + }; + + /* Perform process tracing functions. REQUEST is one of the values diff --git a/glibc-locale-gen-src-install.patch b/glibc-locale-gen-src-install.patch new file mode 100644 index 0000000..29f0086 --- /dev/null +++ b/glibc-locale-gen-src-install.patch @@ -0,0 +1,25 @@ +--- glibc-2.5.ebuild 27 Jan 2007 02:21:17 -0000 1.22 ++++ glibc-2.5.ebuild 29 Jan 2007 07:31:55 -0000 +@@ -468,6 +468,13 @@ toolchain-glibc_src_install() { + # creation of the "factory" symlink in pkg_postinst(). + rm -f "${D}"/etc/localtime + ++ # Generate all locales if this is a native build as locale generation ++ if [[ ${CBUILD} == ${CHOST} ]] ; then ++ local x jobs ++ for x in ${MAKEOPTS} ; do [[ ${x} == -j* ]] && jobs=${x#-j} ; done ++ "${D}"/usr/sbin/locale-gen -j ${jobs:-1} --all --destdir "${D}" ++ fi ++ + # simple test to make sure our new glibc isnt completely broken. + # for now, skip the multilib scenario. also make sure we don't + # test with statically built binaries since they will fail. +@@ -544,7 +551,7 @@ toolchain-glibc_pkg_postinst() { + fi + local x jobs + for x in ${MAKEOPTS} ; do [[ ${x} == -j* ]] && jobs=${x#-j} ; done +- locale-gen -j ${jobs:-1} --config "${locale_list}" ++ locale-gen -j ${jobs:-1} --update --config "${locale_list}" + fi + + echo diff --git a/glibc-no-elf-header.patch b/glibc-no-elf-header.patch new file mode 100644 index 0000000..dfb7beb --- /dev/null +++ b/glibc-no-elf-header.patch @@ -0,0 +1,178 @@ +2008-06-07 Mike Frysinger + + * sysdeps/unix/sysv/linux/sys/procfs.h: Replace with #error stub. + * sysdeps/unix/sysv/linux/alpha/sys/procfs.h: Copy some asm/elf.h + definitions from the kernel header to sys/procfs.h and remove the + #include of asm/elf.h. + * sysdeps/unix/sysv/linux/sh/sys/procfs.h: Likewise. + +--- a/sysdeps/unix/sysv/linux/alpha/sys/procfs.h ++++ b/sysdeps/unix/sysv/linux/alpha/sys/procfs.h +@@ -29,10 +29,23 @@ + #include + #include + #include +-#include + + __BEGIN_DECLS + ++/* ++ * The OSF/1 version of makes gregset_t 46 entries long. ++ * I have no idea why that is so. For now, we just leave it at 33 ++ * (32 general regs + processor status word). ++ */ ++#define ELF_NGREG 33 ++#define ELF_NFPREG 32 ++ ++typedef unsigned long elf_greg_t; ++typedef elf_greg_t elf_gregset_t[ELF_NGREG]; ++ ++typedef double elf_fpreg_t; ++typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG]; ++ + struct elf_siginfo + { + int si_signo; /* Signal number. */ +--- a/sysdeps/unix/sysv/linux/sh/sys/procfs.h ++++ b/sysdeps/unix/sysv/linux/sh/sys/procfs.h +@@ -29,10 +29,19 @@ + #include + #include + #include +-#include + + __BEGIN_DECLS + ++/* ++ * ELF register definitions... ++ */ ++typedef unsigned long elf_greg_t; ++ ++#define ELF_NGREG (sizeof (struct pt_regs) / sizeof(elf_greg_t)) ++typedef elf_greg_t elf_gregset_t[ELF_NGREG]; ++ ++typedef struct user_fpu_struct elf_fpregset_t; ++ + struct elf_siginfo + { + int si_signo; /* Signal number. */ +--- a/sysdeps/unix/sysv/linux/sys/procfs.h ++++ b/sysdeps/unix/sysv/linux/sys/procfs.h +@@ -1,115 +1,2 @@ +-/* Copyright (C) 1996, 1997, 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_PROCFS_H +-#define _SYS_PROCFS_H 1 +- +-/* This is somehow modelled after the file of the same name on SysVr4 +- systems. It provides a definition of the core file format for ELF +- used on Linux. */ +- +-#include +-#include +-#include +-#include +-#include +-#include +-#include +- +-__BEGIN_DECLS +- +-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. Fields present but not used are +- marked with "XXX". */ +-struct elf_prstatus +- { +-#if 0 +- long int pr_flags; /* XXX Process flags. */ +- short int pr_why; /* XXX Reason for process halt. */ +- short int pr_what; /* XXX More detailed reason. */ +-#endif +- 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. */ +-#if 0 +- struct sigaltstack pr_altstack; /* Alternate stack info. */ +- struct sigaction pr_action; /* Signal action for current sig. */ +-#endif +- __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. */ +-#if 0 +- long int pr_instr; /* Current instruction. */ +-#endif +- 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. */ +- }; +- +-/* Addresses. */ +-typedef void *psaddr_t; +- +-/* Register sets. Linux has different names. */ +-typedef gregset_t prgregset_t; +-typedef fpregset_t prfpregset_t; +- +-/* We don't have any differences between processes and threads, +- therefore habe only ine PID type. */ +-typedef __pid_t lwpid_t; +- +- +-typedef struct elf_prstatus prstatus_t; +-typedef struct elf_prpsinfo prpsinfo_t; +- +-__END_DECLS +- +-#endif /* sys/procfs.h */ ++/* sys/procfs.h is architecture specific. */ ++#error "This file must be supplied by every Linux architecture." diff --git a/glibc-sh-broken-nptl-lock-macros.patch b/glibc-sh-broken-nptl-lock-macros.patch new file mode 100644 index 0000000..0162a24 --- /dev/null +++ b/glibc-sh-broken-nptl-lock-macros.patch @@ -0,0 +1,73 @@ +2007-11-03 Mike Frysinger + + * sysdeps/unix/sysv/linux/sh/lowlevellock.S (LOAD_FUTEX_WAIT): Add + missing line continuations. + * sysdeps/unix/sysv/linux/sh/lowlevelrobustlock.S (LOAD_FUTEX_WAIT, + LOAD_FUTEX_WAKE): Likewise. Also add missing 3rd parameter. + +Index: nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.S +=================================================================== +RCS file: /cvs/glibc/libc/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.S,v +retrieving revision 1.14 +diff -u -p -r1.14 lowlevellock.S +--- nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.S 3 Aug 2007 15:44:15 -0000 1.14 ++++ nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.S 4 Nov 2007 03:50:46 -0000 +@@ -76,7 +76,7 @@ + add tmp2, tmp ; \ + mov.l @tmp, tmp2 ; \ + bra 98f ; \ +- mov #FUTEX_PRIVATE_FLAG, tmp ++ mov #FUTEX_PRIVATE_FLAG, tmp ; \ + 99: .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE ; \ + 98: extu.b tmp, tmp ; \ + xor tmp, reg ; \ +@@ -88,7 +88,7 @@ + add tmp2, tmp ; \ + mov.l @tmp, tmp2 ; \ + bra 98f ; \ +- mov #FUTEX_PRIVATE_FLAG, tmp ++ mov #FUTEX_PRIVATE_FLAG, tmp ; \ + 99: .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE ; \ + 98: extu.b tmp, tmp ; \ + xor tmp, reg ; \ +@@ -96,13 +96,13 @@ + mov #FUTEX_WAIT, tmp ; \ + or tmp, reg + # endif +-# define LOAD_FUTEX_WAKE(reg,tmp) \ ++# define LOAD_FUTEX_WAKE(reg,tmp,tmp2) \ + stc gbr, tmp ; \ + mov.w 99f, tmp2 ; \ + add tmp2, tmp ; \ + mov.l @tmp, tmp2 ; \ + bra 98f ; \ +- mov #FUTEX_PRIVATE_FLAG, tmp ++ mov #FUTEX_PRIVATE_FLAG, tmp ; \ + 99: .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE ; \ + 98: extu.b tmp, tmp ; \ + xor tmp, reg ; \ +Index: nptl/sysdeps/unix/sysv/linux/sh/lowlevelrobustlock.S +=================================================================== +RCS file: /cvs/glibc/libc/nptl/sysdeps/unix/sysv/linux/sh/lowlevelrobustlock.S,v +retrieving revision 1.2 +diff -u -p -r1.2 lowlevelrobustlock.S +--- nptl/sysdeps/unix/sysv/linux/sh/lowlevelrobustlock.S 3 Aug 2007 15:44:57 -0000 1.2 ++++ nptl/sysdeps/unix/sysv/linux/sh/lowlevelrobustlock.S 4 Nov 2007 03:50:46 -0000 +@@ -42,7 +42,7 @@ + add tmp2, tmp ; \ + mov.l @tmp, tmp2 ; \ + bra 98f ; \ +- mov #FUTEX_PRIVATE_FLAG, tmp ++ mov #FUTEX_PRIVATE_FLAG, tmp ; \ + 99: .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE ; \ + 98: extu.b tmp, tmp ; \ + xor tmp, reg ; \ +@@ -54,7 +54,7 @@ + add tmp2, tmp ; \ + mov.l @tmp, tmp2 ; \ + bra 98f ; \ +- mov #FUTEX_PRIVATE_FLAG, tmp ++ mov #FUTEX_PRIVATE_FLAG, tmp ; \ + 99: .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE ; \ + 98: extu.b tmp, tmp ; \ + xor tmp, reg ; \ diff --git a/glibc-sh-no-sys-io-header.patch b/glibc-sh-no-sys-io-header.patch new file mode 100644 index 0000000..f697416 --- /dev/null +++ b/glibc-sh-no-sys-io-header.patch @@ -0,0 +1,18 @@ +2007-02-10 Mike Frysinger + + * sysdeps/unix/sysv/linux/sh/Makefile: Remove sys/io.h + from sysdep_headers. + +--- libc/sysdeps/unix/sysv/linux/sh/Makefile ++++ libc/sysdeps/unix/sysv/linux/sh/Makefile +@@ -2,10 +2,6 @@ ifeq ($(subdir),io) + sysdep_routines += pipe + endif + +-ifeq ($(subdir),misc) +-sysdep_headers += sys/io.h +-endif +- + ifeq ($(subdir),stdlib) + gen-as-const-headers += ucontext_i.sym + endif diff --git a/glibc-tst-network.patch b/glibc-tst-network.patch new file mode 100644 index 0000000..03010c1 --- /dev/null +++ b/glibc-tst-network.patch @@ -0,0 +1,19 @@ +2007-09-14 Mike Frysinger + + * inet/tst-network.c: Increment errors when res != tests[i].number. + +Index: inet/tst-network.c +=================================================================== +RCS file: /cvs/glibc/libc/inet/tst-network.c,v +retrieving revision 1.3 +diff -u -p -r1.3 tst-network.c +--- inet/tst-network.c 24 Sep 2002 04:21:03 -0000 1.3 ++++ inet/tst-network.c 15 Sep 2007 03:58:49 -0000 +@@ -61,6 +61,7 @@ main (void) + + if (res != tests[i].number) + { ++ ++errors; + printf ("Test failed for inet_network (\"%s\"):\n", + tests[i].network); + printf ("Expected return value %u (0x%x) but got %u (0x%x).\n", diff --git a/glibc-undefine-__i686.patch b/glibc-undefine-__i686.patch new file mode 100644 index 0000000..a99023c --- /dev/null +++ b/glibc-undefine-__i686.patch @@ -0,0 +1,59 @@ +If gcc is configured to generate i686 code or better by default (like +when using the --with-arch=pentium3 configure option), then the __i686 +macro will always be defined automatically and thus screw up the +compilation of some .S files. +http://bugs.gentoo.org/131108 + +2006-04-25 Mike Frysinger + + * sysdeps/i386/sysdep.h (__i686): Undefine. + +--- sysdeps/i386/sysdep.h ++++ sysdeps/i386/sysdep.h +@@ -1,5 +1,6 @@ + /* Assembler macros for i386. +- Copyright (C) 1991-93,95,96,98,2002,2003,2005 Free Software Foundation, Inc. ++ Copyright (C) 1991-93,95,96,98,2002,2003,2005,2006 ++ 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 +@@ -17,6 +18,14 @@ + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + ++/* ++ * When building for i686 targets or better, gcc automatically defines ++ * '__i686' to '1' for us which causes trouble when using section names ++ * like '__i686.get_pc_thunk.reg'. Since we check for __i686__ in the ++ * code, killing '__i686' shouldn't be a problem. ++ */ ++#undef __i686 ++ + #include + + #ifdef __ASSEMBLER__ + +2006-04-25 Mike Frysinger + + * sysdeps/pthread/pt-initfini.c: Include sysdep.h. + +--- nptl/sysdeps/pthread/pt-initfini.c ++++ nptl/sysdeps/pthread/pt-initfini.c +@@ -1,5 +1,5 @@ + /* Special .init and .fini section support. Linuxthread version. +- Copyright (C) 1995,1996,1997,2000,2001,2002 Free Software Foundation, Inc. ++ Copyright (C) 1995-1997,2000-2002,2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it +@@ -45,6 +45,9 @@ + /* Embed an #include to pull in the alignment and .end directives. */ + asm ("\n#include \"defs.h\""); + ++/* Embed an #include to pull in asm settings. */ ++asm ("\n#include "); ++ + /* The initial common code ends here. */ + asm ("\n/*@HEADER_ENDS*/"); + diff --git a/gnuconfig-no-function.patch b/gnuconfig-no-function.patch new file mode 100644 index 0000000..13f8ce0 --- /dev/null +++ b/gnuconfig-no-function.patch @@ -0,0 +1,32 @@ +Index: testsuite/config-guess.sh +=================================================================== +RCS file: /cvsroot/config/config/testsuite/config-guess.sh,v +retrieving revision 1.4 +diff -u -p -r1.4 config-guess.sh +--- testsuite/config-guess.sh 10 Feb 2005 03:46:56 -0000 1.4 ++++ testsuite/config-guess.sh 24 Jul 2007 18:21:55 -0000 +@@ -10,7 +10,7 @@ verbose=false + export PATH=`pwd`:$PATH + IFS=" " # tab + +-function run_config_guess () ++run_config_guess () + { + rc=0 + while read machine release system version triplet ; do +Index: testsuite/config-sub.sh +=================================================================== +RCS file: /cvsroot/config/config/testsuite/config-sub.sh,v +retrieving revision 1.2 +diff -u -p -r1.2 config-sub.sh +--- testsuite/config-sub.sh 10 Feb 2005 03:46:56 -0000 1.2 ++++ testsuite/config-sub.sh 24 Jul 2007 18:21:55 -0000 +@@ -9,7 +9,7 @@ + + verbose=false + +-function run_config_sub () ++run_config_sub () + { + rc=0 + while read alias canonical ; do diff --git a/gnulib-acl-optional.patch b/gnulib-acl-optional.patch new file mode 100644 index 0000000..47e8dee --- /dev/null +++ b/gnulib-acl-optional.patch @@ -0,0 +1,65 @@ +2007-07-25 Mike Frysinger + + * m4/acl.m4 (AC_FUNC_ACL): Wrap all ACL logic in a call to + AC_ARG_ENABLE(acl). + +diff --git a/m4/acl.m4 b/m4/acl.m4 +index 6e6bd08..472d257 100644 +--- a/m4/acl.m4 ++++ b/m4/acl.m4 +@@ -12,27 +12,35 @@ AC_DEFUN([AC_FUNC_ACL], + AC_LIBOBJ([acl]) + AC_LIBOBJ([file-has-acl]) + +- dnl Prerequisites of lib/acl.c. +- AC_CHECK_HEADERS(sys/acl.h) +- AC_CHECK_FUNCS(acl) +- ac_save_LIBS="$LIBS" +- AC_SEARCH_LIBS(acl_get_file, acl, +- [test "$ac_cv_search_acl_get_file" = "none required" || +- LIB_ACL=$ac_cv_search_acl_get_file]) +- AC_SUBST(LIB_ACL) +- AC_CHECK_HEADERS(acl/libacl.h) +- AC_CHECK_FUNCS(acl_get_file acl_get_fd acl_set_file acl_set_fd \ +- acl_free acl_from_mode acl_from_text \ +- acl_delete_def_file acl_extended_file) +- if test $ac_cv_header_sys_acl_h = yes; then +- use_acl=1 +- if test $ac_cv_func_acl_get_file = yes; then +- # If we detect the acl_get_file bug, disable ACL support altogether. +- gl_ACL_GET_FILE( , [use_acl=0]) ++ AC_ARG_ENABLE(acl, ++ AC_HELP_STRING([--disable-acl], [turn off support for ACLs], ++ [use_acl=$enableval], [use_acl=yes]) ++ ++ if test "$use_acl" = "yes"; then ++ dnl Prerequisites of lib/acl.c. ++ AC_CHECK_HEADERS(sys/acl.h) ++ AC_CHECK_FUNCS(acl) ++ ac_save_LIBS="$LIBS" ++ AC_SEARCH_LIBS(acl_get_file, acl, ++ [test "$ac_cv_search_acl_get_file" = "none required" || ++ LIB_ACL=$ac_cv_search_acl_get_file]) ++ AC_SUBST(LIB_ACL) ++ AC_CHECK_HEADERS(acl/libacl.h) ++ AC_CHECK_FUNCS(acl_get_file acl_get_fd acl_set_file acl_set_fd \ ++ acl_free acl_from_mode acl_from_text \ ++ acl_delete_def_file acl_extended_file) ++ if test $ac_cv_header_sys_acl_h = yes; then ++ use_acl=1 ++ if test $ac_cv_func_acl_get_file = yes; then ++ # If we detect the acl_get_file bug, disable ACL support altogether. ++ gl_ACL_GET_FILE( , [use_acl=0]) ++ fi ++ else ++ use_acl=0 + fi +- else +- use_acl=0 +- fi ++ else ++ use_acl=0 ++ fi + if test $use_acl = 1 && + test $ac_cv_func_acl_get_file = yes && + test $ac_cv_func_acl_free = yes; then diff --git a/hal-use-libpci.patch b/hal-use-libpci.patch new file mode 100644 index 0000000..192375a --- /dev/null +++ b/hal-use-libpci.patch @@ -0,0 +1,549 @@ +diff --git a/configure.in b/configure.in +index 0b6734c..647c0c6 100644 +--- a/configure.in ++++ b/configure.in +@@ -46,20 +46,10 @@ AC_ARG_WITH([pid-file], + AS_HELP_STRING([--with-pid-file=], + [PID file for HAL daemon])) + +-AC_ARG_WITH([hwdata], +- AS_HELP_STRING([--with-hwdata=

], +- [Where PCI and USB IDs are found])) +-AC_ARG_WITH([pci-ids], +- AS_HELP_STRING([--with-pci-ids=], +- [Where PCI IDs are found (overrides --with-hwdata)])) + AC_ARG_WITH([usb-ids], + AS_HELP_STRING([--with-usb-ids=], + [Where USB IDs are found (overrides --with-hwdata)])) + +-AC_ARG_ENABLE([pci-ids], +- AS_HELP_STRING([--disable-pci-ids], +- [Do not build with PCI IDs support]), +- [enable_pci_ids=$enableval], [enable_pci_ids=yes]) + AC_ARG_ENABLE([usb-ids], + AS_HELP_STRING([--disable-usb-ids], + [Do not build with USB IDs support]), +@@ -73,34 +63,10 @@ AC_ARG_WITH([socket-dir], + AS_HELP_STRING([--with-socket-dir=], + [Location of the HAL D-BUS listening sockets (auto)])) + +-if ! test -z "$with_hwdata" ; then +- PCI_IDS_DIR="$with_hwdata" +- USB_IDS_DIR="$with_hwdata" +-fi +-if ! test -z "$with_pci_ids" ; then +- PCI_IDS_DIR="$with_pci_ids" +-fi + if ! test -z "$with_usb_ids" ; then + USB_IDS_DIR="$with_usb_ids" + fi + +-if test "x$enable_pci_ids" = "xno" ; then +- USE_PCI_IDS=no +-else +- if test -z "$PCI_IDS_DIR"; then +- for dir in /usr/share/hwdata /usr/share/misc /usr/share /var/lib/misc; do +- AC_CHECK_FILE([$dir/pci.ids], [PCI_IDS_DIR=$dir]) +- done +- if test -z "$PCI_IDS_DIR"; then +- AC_MSG_ERROR([cannot find pci.ids. Use --with-pci-ids to specify location]) +- else +- AC_MSG_WARN([autodetected pci.ids in $PCI_IDS_DIR]) +- fi +- fi +- USE_PCI_IDS=yes +- AC_DEFINE([USE_PCI_IDS], [1], [Whether pci.ids is to be used]) +-fi +- + if test "x$enable_usb_ids" = "xno" ; then + USE_USB_IDS=no + else +@@ -125,9 +91,7 @@ else + AC_DEFINE([USE_PNP_IDS], [1], [Whether builtin PNP IDs are to be used]) + fi + +-AC_SUBST(PCI_IDS_DIR) + AC_SUBST(USB_IDS_DIR) +-AC_SUBST(USE_PCI_IDS) + AC_SUBST(USE_USB_IDS) + AC_SUBST(USE_PNP_IDS) + +@@ -422,11 +386,13 @@ AC_ARG_WITH([libpci], + [], [with_libpci=yes]) + + USE_LIBPCI="no" ++PCI_LIBS="" + if test "x$with_libpci" != xno ; then + dnl check for libpci + AC_CHECK_HEADERS([pci/pci.h], +- [AC_CHECK_LIB([pci], [pci_init], [USE_LIBPCI="yes"], [], [-lz])]) +-fi ++ [AC_CHECK_LIB([pci], [pci_init], [USE_LIBPCI="yes" PCI_LIBS="-lpci -lz"], [], [-lz])]) ++fi ++AC_SUBST([PCI_LIBS]) + AM_CONDITIONAL([HAVE_LIBPCI], [test "x$USE_LIBPCI" = "xyes"]) + + AC_ARG_WITH([backend], +@@ -979,7 +945,6 @@ echo " + localstatedir: ${localstatedir} + docdir: ${docdir} + dbus-1 system.d dir: ${DBUS_SYS_DIR} +- pci.ids dir: ${PCI_IDS_DIR} + usb.ids dir: ${USB_IDS_DIR} + + compiler: ${CC} +diff --git a/hald/Makefile.am b/hald/Makefile.am +index ea396f6..fbf2d5d 100644 +--- a/hald/Makefile.am ++++ b/hald/Makefile.am +@@ -12,7 +12,6 @@ AM_CPPFLAGS = \ + -DPACKAGE_SCRIPT_DIR=\""$(libdir)/hal/scripts"\" \ + -DHALD_SOCKET_DIR=\""$(HALD_SOCKET_DIR)"\" \ + -DHALD_PID_FILE=\""$(HALD_PID_FILE)"\" \ +- -DPCI_IDS_DIR=\""$(PCI_IDS_DIR)"\" \ + -DUSB_IDS_DIR=\""$(USB_IDS_DIR)"\" \ + -I$(top_srcdir) \ + @GLIB_CFLAGS@ @DBUS_CFLAGS@ @POLKIT_CFLAGS@ +@@ -73,7 +72,7 @@ if HAVE_CONKIT + hald_SOURCES += ck-tracker.h ck-tracker.c + endif + +-hald_LDADD = @GLIB_LIBS@ @DBUS_LIBS@ @POLKIT_LIBS@ -lm @HALD_OS_LIBS@ $(top_builddir)/hald/$(HALD_BACKEND)/libhald_$(HALD_BACKEND).la ++hald_LDADD = @PCI_LIBS@ @GLIB_LIBS@ @DBUS_LIBS@ @POLKIT_LIBS@ -lm @HALD_OS_LIBS@ $(top_builddir)/hald/$(HALD_BACKEND)/libhald_$(HALD_BACKEND).la + + #### Init scripts fun + SCRIPT_IN_FILES=haldaemon.in +diff --git a/hald/ids.c b/hald/ids.c +index 9949eab..b8dc344 100644 +--- a/hald/ids.c ++++ b/hald/ids.c +@@ -44,72 +44,17 @@ + + #include "ids.h" + +-#ifdef USE_PCI_IDS +-/** Pointer to where the pci.ids file is loaded */ +-static char *pci_ids = NULL; +- +-/** Length of data store at at pci_ids */ +-static size_t pci_ids_len; ++#ifdef HAVE_PCI + +-/** Iterator position into pci_ids */ +-static size_t pci_ids_iter_pos; ++#include + +-/** Initialize the pci.ids line iterator to the beginning of the file */ +-static void +-pci_ids_line_iter_init () +-{ +- pci_ids_iter_pos = 0; +-} ++/** Pointer to where the pci.ids file is loaded */ ++static struct pci_access *pacc = NULL; + + /** Maximum length of lines in pci.ids */ + #define PCI_IDS_MAX_LINE_LEN 512 + +-/** +- * pci_ids_line_iter_get_line: +- * @line_len: Pointer to where number of bytes in line will +- * be stored +- * Returns: Pointer to the line; only valid until the +- * next invocation of this function +- * +- * Get the next line from pci.ids +- */ +-static char * +-pci_ids_line_iter_get_line (unsigned int *line_len) +-{ +- unsigned int i; +- static char line[PCI_IDS_MAX_LINE_LEN]; +- +- for (i = 0; +- pci_ids_iter_pos < pci_ids_len && +- i < PCI_IDS_MAX_LINE_LEN - 1 && +- pci_ids[pci_ids_iter_pos] != '\n'; i++, pci_ids_iter_pos++) { +- line[i] = pci_ids[pci_ids_iter_pos]; +- } +- +- line[i] = '\0'; +- if (line_len != NULL) +- *line_len = i; +- +- pci_ids_iter_pos++; +- +- return line; +-} +- +-/** +- * pci_ids_line_iter_has_more: +- * +- * Returns: #TRUE iff there are more lines to process +- * +- * See if there are more lines to process in pci.ids +- */ +-static dbus_bool_t +-pci_ids_line_iter_has_more () +-{ +- return pci_ids_iter_pos < pci_ids_len; +-} +- +- +-/** ++/** + * ids_find_pci: + * @vendor_id: PCI vendor id or 0 if unknown + * @product_id: PCI product id or 0 if unknown +@@ -131,199 +76,64 @@ ids_find_pci (int vendor_id, int product_id, + char **vendor_name, char **product_name, + char **subsys_vendor_name, char **subsys_product_name) + { +- char *line; +- unsigned int i; +- unsigned int line_len; +- unsigned int num_tabs; +- char rep_vi[8]; +- char rep_pi[8]; +- char rep_svi[8]; +- char rep_spi[8]; +- dbus_bool_t vendor_matched = FALSE; +- dbus_bool_t product_matched = FALSE; + static char store_vn[PCI_IDS_MAX_LINE_LEN]; + static char store_pn[PCI_IDS_MAX_LINE_LEN]; + static char store_svn[PCI_IDS_MAX_LINE_LEN]; + static char store_spn[PCI_IDS_MAX_LINE_LEN]; + +- snprintf (rep_vi, 8, "%04x", vendor_id); +- snprintf (rep_pi, 8, "%04x", product_id); +- snprintf (rep_svi, 8, "%04x", subsys_vendor_id); +- snprintf (rep_spi, 8, "%04x", subsys_product_id); +- + *vendor_name = NULL; + *product_name = NULL; + *subsys_vendor_name = NULL; + *subsys_product_name = NULL; + +- for (pci_ids_line_iter_init (); pci_ids_line_iter_has_more ();) { +- line = pci_ids_line_iter_get_line (&line_len); +- +- /* skip lines with no content */ +- if (line_len < 4) +- continue; +- +- /* skip comments */ +- if (line[0] == '#') +- continue; +- +- /* count number of tabs */ +- num_tabs = 0; +- for (i = 0; i < line_len; i++) { +- if (line[i] != '\t') +- break; +- num_tabs++; +- } +- +- switch (num_tabs) { +- case 0: +- /* vendor names */ +- vendor_matched = FALSE; +- +- /* first check subsys_vendor_id, if haven't done +- * already */ +- if (*subsys_vendor_name == NULL +- && subsys_vendor_id != 0) { +- if ((*((dbus_uint32_t *) line)) == +- (*((dbus_uint32_t *) rep_svi))) { +- /* found it */ +- for (i = 4; i < line_len; i++) { +- if (!isspace (line[i])) +- break; +- } +- strncpy (store_svn, line + i, +- PCI_IDS_MAX_LINE_LEN); +- *subsys_vendor_name = store_svn; +- } +- } +- +- /* check vendor_id */ +- if (vendor_id != 0) { +- if (memcmp (line, rep_vi, 4) == 0) { +- /* found it */ +- vendor_matched = TRUE; +- +- for (i = 4; i < line_len; i++) { +- if (!isspace (line[i])) +- break; +- } +- strncpy (store_vn, line + i, +- PCI_IDS_MAX_LINE_LEN); +- *vendor_name = store_vn; +- } +- } +- +- break; +- +- case 1: +- product_matched = FALSE; +- +- /* product names */ +- if (!vendor_matched) +- continue; +- +- /* check product_id */ +- if (product_id != 0) { +- if (memcmp (line + 1, rep_pi, 4) == 0) { +- /* found it */ +- +- product_matched = TRUE; +- +- for (i = 5; i < line_len; i++) { +- if (!isspace (line[i])) +- break; +- } +- strncpy (store_pn, line + i, +- PCI_IDS_MAX_LINE_LEN); +- *product_name = store_pn; +- } +- } +- break; +- +- case 2: +- /* subsystem_vendor subsystem_product */ +- if (!vendor_matched || !product_matched) +- continue; +- +- /* check product_id */ +- if (subsys_vendor_id != 0 +- && subsys_product_id != 0) { +- if (memcmp (line + 2, rep_svi, 4) == 0 +- && memcmp (line + 7, rep_spi, +- 4) == 0) { +- /* found it */ +- for (i = 11; i < line_len; i++) { +- if (!isspace (line[i])) +- break; +- } +- strncpy (store_spn, line + i, +- PCI_IDS_MAX_LINE_LEN); +- *subsys_product_name = store_spn; +- } +- } +- +- break; +- +- default: +- break; +- } +- +- } ++ if (vendor_id == 0) ++ return; ++ *vendor_name = pci_lookup_name (pacc, store_vn, sizeof(store_vn), ++ PCI_LOOKUP_VENDOR, vendor_id, product_id); ++ if (*vendor_name == NULL) ++ return; ++ ++ if (product_id == 0) ++ return; ++ *product_name = pci_lookup_name (pacc, store_pn, sizeof(store_pn), ++ PCI_LOOKUP_DEVICE, vendor_id, product_id); ++ if (*product_name == NULL) ++ return; ++ ++ if (subsys_vendor_id == 0) ++ return; ++ *subsys_vendor_name = pci_lookup_name (pacc, store_svn, sizeof(store_svn), ++ PCI_LOOKUP_SUBSYSTEM | PCI_LOOKUP_VENDOR, subsys_vendor_id); ++ if (*subsys_vendor_name == NULL) ++ return; ++ ++ if (subsys_product_id == 0) ++ return; ++ *subsys_product_name = pci_lookup_name (pacc, store_spn, sizeof(store_spn), ++ PCI_LOOKUP_SUBSYSTEM | PCI_LOOKUP_DEVICE, subsys_vendor_id, subsys_product_id); ++ if (*subsys_product_name == NULL) ++ return; + } + +- +-/** +- * pci_ids_load: +- * @path: Path of the pci.ids file, e.g. /usr/share/hwdata/pci.ids +- * +- * Returns: #TRUE if the file was succesfully loaded +- * +- * Load the PCI database used for mapping vendor, product, subsys_vendor +- * and subsys_product numbers into names. +- */ +-static dbus_bool_t +-pci_ids_load (const char *path) ++static void ++pci_ids_error (char *msg, ...) + { +- int fd; +- struct stat statbuf; +- gboolean ret; +- +- ret = FALSE; +- +- if (stat (path, &statbuf) != 0) { +- HAL_WARNING (("Couldn't stat pci.ids file '%s', errno=%d: %s", path, errno, strerror (errno))); +- goto out; +- } +- pci_ids_len = statbuf.st_size; +- +- fd = open (path, O_RDONLY); +- if (fd < 0) { +- HAL_WARNING (("Couldn't open pci.ids file '%s', errno=%d: %s", path, errno, strerror (errno))); +- goto out; +- } +- +- pci_ids = mmap (NULL, pci_ids_len, PROT_READ, MAP_SHARED, fd, 0); +- if (pci_ids == MAP_FAILED) { +- HAL_WARNING (("Couldn't mmap pci.ids file '%s', errno=%d: %s", path, errno, strerror (errno))); +- close (fd); +- goto out; +- } +- +- ret = TRUE; +- +- close (fd); +-out: +- return ret; ++ va_list args; ++ va_start (args, msg); ++ logger_setup (HAL_LOGPRI_ERROR, __FILE__, __LINE__, __FUNCTION__); ++ logger_emit_var (msg, args); ++ va_end (args); + } + + void + pci_ids_init (void) + { +- /* Load /usr/share/hwdata/pci.ids */ +- pci_ids_load (PCI_IDS_DIR "/pci.ids"); ++ pacc = pci_alloc(); ++ pacc->error = pci_ids_error; ++ pci_init(pacc); + } + +-#endif /*USE_PCI_IDS*/ ++#endif /*HAVE_PCI*/ + + /*==========================================================================*/ + +diff --git a/hald/ids.h b/hald/ids.h +index 7773211..e0a8679 100644 +--- a/hald/ids.h ++++ b/hald/ids.h +@@ -28,7 +28,7 @@ + + #include + +-#ifdef USE_PCI_IDS ++#ifdef HAVE_PCI + + void pci_ids_init (void); + +@@ -38,7 +38,7 @@ ids_find_pci (int vendor_id, int product_id, + char **vendor_name, char **product_name, + char **subsys_vendor_name, char **subsys_product_name); + +-#else /*USE_PCI_IDS*/ ++#else /*HAVE_PCI*/ + static inline void pci_ids_init (void) {return;}; + + static inline void +@@ -46,7 +46,7 @@ ids_find_pci (int vendor_id, int product_id, + int subsys_vendor_id, int subsys_product_id, + char **vendor_name, char **product_name, + char **subsys_vendor_name, char **subsys_product_name) {return;} +-#endif /*USE_PCI_IDS*/ ++#endif /*HAVE_PCI*/ + + #ifdef USE_PNP_IDS + +diff --git a/hald/logger.c b/hald/logger.c +index a2d04b5..c23ea71 100644 +--- a/hald/logger.c ++++ b/hald/logger.c +@@ -138,16 +138,15 @@ logger_setup (int _priority, const char *_file, int _line, const char *_function + } + + /** +- * logger_emit: ++ * logger_emit_var: + * @format: Message format string, printf style +- * @...: Parameters for message, printf style ++ * @args: Parameters for message, vprintf style + * + * Emit logging entry + */ + void +-logger_emit (const char *format, ...) ++logger_emit_var (const char *format, va_list args) + { +- va_list args; + char buf[512]; + char *pri; + char tbuf[256]; +@@ -160,7 +159,6 @@ logger_emit (const char *format, ...) + if (!is_enabled) + return; + +- va_start (args, format); + vsnprintf (buf, sizeof (buf), format, args); + + switch (priority) { +@@ -213,7 +211,21 @@ logger_emit (const char *format, ...) + break; + } + } ++} + ++/** ++ * loger_emit: ++ * @format: Message format string, printf style ++ * @...: Parameters for message, printf style ++ * ++ * Emit logging entry ++ */ ++void ++logger_emit (const char *format, ...) ++{ ++ va_list args; ++ va_start (args, format); ++ logger_emit_var (format, args); + va_end (args); + } + +diff --git a/hald/logger.h b/hald/logger.h +index f32216c..dd55eb5 100644 +--- a/hald/logger.h ++++ b/hald/logger.h +@@ -30,6 +30,7 @@ extern "C" { + #ifndef LOGGER_H + #define LOGGER_H + ++#include + #include + #include + +@@ -45,6 +46,7 @@ enum { + void logger_setup (int priority, const char *file, int line, const char *function); + + void logger_emit (const char *format, ...); ++void logger_emit_var (const char *format, va_list args); + /* void logger_forward_debug (const char *format, va_list args); */ + void logger_forward_debug (const char *format, ...); + +@@ -72,7 +74,7 @@ void setup_logger (void); + /** Warning level logging macro */ + #define HAL_WARNING(expr) do {logger_setup(HAL_LOGPRI_WARNING, __FILE__, __LINE__, __FUNCTION__); logger_emit expr; } while(0) + +-/** Error leve logging macro */ ++/** Error level logging macro */ + #define HAL_ERROR(expr) do {logger_setup(HAL_LOGPRI_ERROR, __FILE__, __LINE__, __FUNCTION__); logger_emit expr; } while(0) + + /** Macro for terminating the program on an unrecoverable error */ diff --git a/hwtracebuffer.patch b/hwtracebuffer.patch new file mode 100644 index 0000000..bf0742b --- /dev/null +++ b/hwtracebuffer.patch @@ -0,0 +1,47 @@ +Index: arch/blackfin/mach-common/entry.S +=================================================================== +RCS file: /usr/local/src/blackfin/rsync/uclinux533/uClinux-dist/linux-2.6.x/arch/blackfin/mach-common/entry.S,v +retrieving revision 1.43 +diff -u -p -r1.43 entry.S +--- arch/blackfin/mach-common/entry.S 31 Aug 2006 06:22:41 -0000 1.43 ++++ arch/blackfin/mach-common/entry.S 2 Sep 2006 01:22:06 -0000 +@@ -57,6 +57,29 @@ + #include /* TIF_NEED_RESCHED */ + #include + ++#ifdef CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE ++ /* ++ * TODO: this should be proper save/restore, but for now ++ * we'll just cheat and use 0x1/0x13 ++ */ ++# define DEBUG_START_HWTRACE \ ++ P0.l = LO(TBUFCTL); \ ++ P0.h = HI(TBUFCTL); \ ++ R0 = [SP++]; \ ++ [P0] = R0; ++# define DEBUG_STOP_HWTRACE \ ++ P0.l = LO(TBUFCTL); \ ++ P0.h = HI(TBUFCTL); \ ++ R0 = [P0]; \ ++ R1 = ~TBUFEN; \ ++ [SP--] = R0; \ ++ R2 = R0 & R1; \ ++ [P0] = R2; ++#else ++# define DEBUG_START_HWTRACE ++# define DEBUG_STOP_HWTRACE ++#endif ++ + .data + ALIGN + _extable: +@@ -149,7 +172,9 @@ ENTRY(_ex_icplb) + (R7:6,P5:4) = [sp++]; + ASTAT = [sp++]; + SAVE_ALL_SYS ++ DEBUG_STOP_HWTRACE + call __cplb_hdr; ++ DEBUG_START_HWTRACE + RESTORE_ALL_SYS + SP = RETN; + rtx; diff --git a/imlib2-gnu99.patch b/imlib2-gnu99.patch new file mode 100644 index 0000000..eae3039 --- /dev/null +++ b/imlib2-gnu99.patch @@ -0,0 +1,23 @@ +Index: configure.in +=================================================================== +RCS file: /cvs/e/e17/libs/imlib2/configure.in,v +retrieving revision 1.133 +diff -u -p -r1.133 configure.in +--- configure.in 25 Oct 2006 04:45:08 -0000 1.133 ++++ configure.in 6 Nov 2006 15:35:41 -0000 +@@ -39,6 +39,15 @@ m4_defun([AC_PROG_F77],[]) + + AM_PROG_LIBTOOL + ++dnl See if the compiler supports -std=gnu99 since some math ++dnl functions need it (aka round()) ++AC_MSG_CHECKING(whether $CC accepts -std=gnu99) ++cc_supports_gnu99="yes" ++save_CPPFLAGS="$CPPFLAGS" ++CPPFLAGS="$CPPFLAGS -std=gnu99" ++AC_TRY_COMPILE(,,,[cc_supports_gnu99="no";CPPFLAGS="$save_CPPFLAGS"]) ++AC_MSG_RESULT($cc_supports_gnu99) ++ + if test "x${bindir}" = 'x${exec_prefix}/bin'; then + if test "x${exec_prefix}" = "xNONE"; then + if test "x${prefix}" = "xNONE"; then diff --git a/inotify.patch b/inotify.patch new file mode 100644 index 0000000..f999ea9 --- /dev/null +++ b/inotify.patch @@ -0,0 +1,43 @@ +Index: inotify01.c +=================================================================== +--- inotify01.c (revision 127) ++++ inotify01.c (working copy) +@@ -73,6 +73,8 @@ + + int event_set[EVENT_MAX]; + ++char event_buf[EVENT_BUF_LEN]; ++ + static long myinotify_init() + { + return syscall(__NR_inotify_init); +@@ -180,7 +182,6 @@ + /* + * get list on events + */ +- char event_buf[EVENT_BUF_LEN]; + int len, i = 0, test_num = 0; + if ((len = read(fd_notify, event_buf, EVENT_BUF_LEN)) < 0) { + tst_brkm(TBROK, cleanup, +Index: inotify02.c +=================================================================== +--- inotify02.c (revision 127) ++++ inotify02.c (working copy) +@@ -85,6 +85,8 @@ + + struct event_t event_set [EVENT_MAX]; + ++char event_buf[EVENT_BUF_LEN]; ++ + static long myinotify_init() + { + return syscall(__NR_inotify_init); +@@ -222,8 +224,6 @@ + + Tst_count = 0; + +- +- char event_buf[EVENT_BUF_LEN]; + int len, i = 0, test_num = 0; + if ((len = read(fd_notify, event_buf, EVENT_BUF_LEN)) < 0) { + tst_brkm(TBROK, cleanup, diff --git a/iproute2-2.6.16.20060323-build.patch b/iproute2-2.6.16.20060323-build.patch new file mode 100644 index 0000000..7512cfc --- /dev/null +++ b/iproute2-2.6.16.20060323-build.patch @@ -0,0 +1,41 @@ +let portage strip the binaries + +http://bugs.gentoo.org/137574 + +--- ip/Makefile ++++ ip/Makefile +@@ -16,7 +16,7 @@ + rtmon: $(RTMONOBJ) $(LIBNETLINK) + + install: all +- install -m 0755 -s $(TARGETS) $(DESTDIR)$(SBINDIR) ++ install -m 0755 $(TARGETS) $(DESTDIR)$(SBINDIR) + install -m 0755 $(SCRIPTS) $(DESTDIR)$(SBINDIR) + + clean: + +--- misc/Makefile ++++ misc/Makefile +@@ -27,7 +27,7 @@ + lnstat: $(LNSTATOBJ) + + install: all +- install -m 0755 -s $(TARGETS) $(DESTDIR)$(SBINDIR) ++ install -m 0755 $(TARGETS) $(DESTDIR)$(SBINDIR) + ln -sf lnstat $(DESTDIR)$(SBINDIR)/rtstat + ln -sf lnstat $(DESTDIR)$(SBINDIR)/ctstat + +--- tc/Makefile ++++ tc/Makefile +@@ -70,9 +70,9 @@ + + install: all + mkdir -p $(DESTDIR)/usr/lib/tc +- install -m 0755 -s tc $(DESTDIR)$(SBINDIR) ++ install -m 0755 tc $(DESTDIR)$(SBINDIR) + for i in $(TCSO); \ +- do install -m 755 -s $$i $(DESTDIR)/usr/lib/tc; \ ++ do install -m 755 $$i $(DESTDIR)/usr/lib/tc; \ + done + + clean: diff --git a/iproute2-check-make-exit-status.patch b/iproute2-check-make-exit-status.patch new file mode 100644 index 0000000..09d6dec --- /dev/null +++ b/iproute2-check-make-exit-status.patch @@ -0,0 +1,14 @@ +diff --git a/Makefile b/Makefile +index 3fc3a15..dbcb249 100644 +--- a/Makefile ++++ b/Makefile +@@ -32,7 +32,8 @@ SUBDIRS=lib ip tc misc netem genl + LIBNETLINK=../lib/libnetlink.a ../lib/libutil.a + + all: Config +- @for i in $(SUBDIRS); \ ++ @set -e; \ ++ for i in $(SUBDIRS); \ + do $(MAKE) $(MFLAGS) -C $$i; done + + Config: diff --git a/iproute2-genl-linking-order.patch b/iproute2-genl-linking-order.patch new file mode 100644 index 0000000..f306736 --- /dev/null +++ b/iproute2-genl-linking-order.patch @@ -0,0 +1,22 @@ +diff --git a/genl/Makefile b/genl/Makefile +index 4436508..b7dbe28 100644 +--- a/genl/Makefile ++++ b/genl/Makefile +@@ -9,14 +9,15 @@ GENLOBJ += $(GENLMODULES) + + GENLLIB := + +-LDFLAGS += -Wl,-export-dynamic -lm -ldl ++LDLIBS += -lm -ldl ++LDFLAGS += -Wl,-export-dynamic + + all: genl + + genl: $(GENLOBJ) $(LIBNETLINK) $(LIBUTIL) $(GENLLIB) + + install: all +- install -m 0755 -s genl $(DESTDIR)$(SBINDIR) ++ install -m 0755 genl $(DESTDIR)$(SBINDIR) + + clean: + rm -f $(GENLOBJ) $(GENLLIB) genl diff --git a/iptables-log-prefix-no-empty-strings.patch b/iptables-log-prefix-no-empty-strings.patch new file mode 100644 index 0000000..42ccd28 --- /dev/null +++ b/iptables-log-prefix-no-empty-strings.patch @@ -0,0 +1,45 @@ +http://bugs.gentoo.org/148169 + +--- extensions/libip6t_LOG.c ++++ extensions/libip6t_LOG.c +@@ -143,6 +143,10 @@ parse(int c, char **argv, int invert, un + "Maximum prefix length %u for --log-prefix", + (unsigned int)sizeof(loginfo->prefix) - 1); + ++ if (strlen(optarg) == 0) ++ exit_error(PARAMETER_PROBLEM, ++ "No prefix specified for --log-prefix"); ++ + if (strlen(optarg) != strlen(strtok(optarg, "\n"))) + exit_error(PARAMETER_PROBLEM, + "Newlines not allowed in --log-prefix"); +--- extensions/libipt_LOG.c ++++ extensions/libipt_LOG.c +@@ -143,6 +143,10 @@ parse(int c, char **argv, int invert, un + "Maximum prefix length %u for --log-prefix", + (unsigned int)sizeof(loginfo->prefix) - 1); + ++ if (strlen(optarg) == 0) ++ exit_error(PARAMETER_PROBLEM, ++ "No prefix specified for --log-prefix"); ++ + if (strlen(optarg) != strlen(strtok(optarg, "\n"))) + exit_error(PARAMETER_PROBLEM, + "Newlines not allowed in --log-prefix"); +--- extensions/libipt_ULOG.c ++++ extensions/libipt_ULOG.c +@@ -110,6 +110,14 @@ static int parse(int c, char **argv, int + "Maximum prefix length %u for --ulog-prefix", + (unsigned int)sizeof(loginfo->prefix) - 1); + ++ if (strlen(optarg) == 0) ++ exit_error(PARAMETER_PROBLEM, ++ "No prefix specified for --ulog-prefix"); ++ ++ if (strlen(optarg) != strlen(strtok(optarg, "\n"))) ++ exit_error(PARAMETER_PROBLEM, ++ "Newlines not allowed in --ulog-prefix"); ++ + strcpy(loginfo->prefix, optarg); + *flags |= IPT_LOG_OPT_PREFIX; + break; diff --git a/iputils-ipg-tweaks.patch b/iputils-ipg-tweaks.patch new file mode 100644 index 0000000..8c6ebd5 --- /dev/null +++ b/iputils-ipg-tweaks.patch @@ -0,0 +1,46 @@ +Only load modules if kernel supports modules and try a little bit +harder to locate the pg directory in /proc with newer kernels. + +Signed-off-by: Mike Frysinger + +--- a/ipg ++++ b/ipg +@@ -1,21 +1,32 @@ + #! /bin/bash + +-modprobe pg3 ++if [ -e /proc/modules ] ; then ++ modprobe pg3 >& /dev/null ++ modprobe pktgen >& /dev/null ++fi ++ ++for PGDEV in /proc/net/pg /proc/net/pktgen/pg0 / ; do ++ [ -e ${PGDEV} ] && break ++done ++if [ "${PGDEV}" = "/" ] ; then ++ echo "Could not locate pg in /proc/net" 1>&2 ++ exit 1 ++fi + + function pgset() { + local result + +- echo $1 > /proc/net/pg ++ echo $1 > ${PGDEV} + +- result=`cat /proc/net/pg | fgrep "Result: OK:"` ++ result=`cat ${PGDEV} | fgrep "Result: OK:"` + if [ "$result" = "" ]; then +- cat /proc/net/pg | fgrep Result: ++ cat ${PGDEV} | fgrep Result: + fi + } + + function pg() { +- echo inject > /proc/net/pg +- cat /proc/net/pg ++ echo inject > ${PGDEV} ++ cat ${PGDEV} + } + + pgset "odev eth0" diff --git a/iputils-makefile.patch b/iputils-makefile.patch new file mode 100644 index 0000000..b0d4820 --- /dev/null +++ b/iputils-makefile.patch @@ -0,0 +1,44 @@ +Respect user environment variables. + +Signed-off-by: Mike Frysinger + +diff --git a/Makefile b/Makefile +index 54c1de5..7a7b045 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,20 +1,18 @@ + # Path to parent kernel include files directory + LIBC_INCLUDE=/usr/include + +-DEFINES= +- + #options if you have a bind>=4.9.4 libresolv (or, maybe, glibc) + LDLIBS=-lresolv +-ADDLIB= + + #options if you compile with libc5, and without a bind>=4.9.4 libresolv + # NOT AVAILABLE. Please, use libresolv. + +-CC=gcc ++CC ?= gcc + # What a pity, all new gccs are buggy and -Werror does not work. Sigh. + #CCOPT=-D_GNU_SOURCE -O2 -Wstrict-prototypes -Wall -g -Werror +-CCOPT=-D_GNU_SOURCE -O2 -Wstrict-prototypes -Wall -g +-CFLAGS=$(CCOPT) $(GLIBCFIX) $(DEFINES) ++CFLAGS ?= -O2 -g ++CFLAGS += -Wstrict-prototypes -Wall ++CPPFLAGS += -D_GNU_SOURCE + + IPV4_TARGETS=tracepath ping clockdiff rdisc arping tftpd rarpd + IPV6_TARGETS=tracepath6 traceroute6 ping6 +@@ -33,9 +31,8 @@ ping.o ping6.o ping_common.o: ping_common.h + tftpd.o tftpsubs.o: tftp.h + + rdisc_srv: rdisc_srv.o +- + rdisc_srv.o: rdisc.c +- $(CC) $(CFLAGS) -DRDISC_SERVER -o rdisc_srv.o rdisc.c ++ $(CC) $(CFLAGS) $(CPPFLAGS) -DRDISC_SERVER -o rdisc_srv.o rdisc.c + + + check-kernel: diff --git a/iputils-socklen.patch b/iputils-socklen.patch new file mode 100644 index 0000000..c6a83a3 --- /dev/null +++ b/iputils-socklen.patch @@ -0,0 +1,188 @@ +Use socklen_t in all the right places. + +Signed-off-by: Mike Frysinger + +diff --git a/arping.c b/arping.c +index 73a7e6f..86f1607 100644 +--- a/arping.c ++++ b/arping.c +@@ -439,7 +439,7 @@ main(int argc, char **argv) + } + } else if (!dad) { + int on = 1; +- int alen = sizeof(saddr); ++ socklen_t alen = sizeof(saddr); + + saddr.sin_port = htons(1025); + saddr.sin_addr = dst; +@@ -468,7 +468,7 @@ main(int argc, char **argv) + } + + if (1) { +- int alen = sizeof(me); ++ socklen_t alen = sizeof(me); + if (getsockname(s, (struct sockaddr*)&me, &alen) == -1) { + perror("getsockname"); + exit(2); +@@ -500,9 +500,9 @@ main(int argc, char **argv) + + while(1) { + sigset_t sset, osset; +- char packet[4096]; ++ unsigned char packet[4096]; + struct sockaddr_ll from; +- int alen = sizeof(from); ++ socklen_t alen = sizeof(from); + int cc; + + if ((cc = recvfrom(s, packet, sizeof(packet), 0, +diff --git a/clockdiff.c b/clockdiff.c +index 009eed4..e17e0b8 100644 +--- a/clockdiff.c ++++ b/clockdiff.c +@@ -121,7 +121,7 @@ long rtt_sigma = 0; + int + measure(struct sockaddr_in * addr) + { +- int length; ++ socklen_t length; + int msgcount; + int cc, count; + fd_set ready; +@@ -299,7 +299,7 @@ char *myname, *hisname; + int + measure_opt(struct sockaddr_in * addr) + { +- int length; ++ socklen_t length; + int msgcount; + int cc, count; + fd_set ready; +@@ -602,7 +602,7 @@ main(int argc, char *argv[]) + } + if (ip_opt_len) { + struct sockaddr_in myaddr; +- int addrlen = sizeof(myaddr); ++ socklen_t addrlen = sizeof(myaddr); + unsigned char rspace[ip_opt_len]; + + bzero(rspace, sizeof(rspace)); +diff --git a/ping.c b/ping.c +index 825f85b..561e71a 100644 +--- a/ping.c ++++ b/ping.c +@@ -259,7 +259,7 @@ main(int argc, char **argv) + } + + if (source.sin_addr.s_addr == 0) { +- int alen; ++ socklen_t alen; + struct sockaddr_in dst = whereto; + int probe_fd = socket(AF_INET, SOCK_DGRAM, 0); + +diff --git a/ping6.c b/ping6.c +index 5aef459..d85a659 100644 +--- a/ping6.c ++++ b/ping6.c +@@ -344,7 +344,7 @@ int main(int argc, char *argv[]) + hostname = target; + + if (ipv6_addr_any(&source.sin6_addr)) { +- int alen; ++ socklen_t alen; + int probe_fd = socket(AF_INET6, SOCK_DGRAM, 0); + + if (probe_fd < 0) { +diff --git a/ping_common.c b/ping_common.c +index dd111f7..acd9b8e 100644 +--- a/ping_common.c ++++ b/ping_common.c +@@ -67,7 +67,7 @@ static void fill(char *patp) + int ii, jj, kk; + int pat[16]; + char *cp; +- char *bp = outpack+8; ++ u_char *bp = outpack+8; + + for (cp = patp; *cp; cp++) { + if (!isxdigit(*cp)) { +@@ -393,7 +393,7 @@ resend: + void sock_setbufs(int icmp_sock, int alloc) + { + int rcvbuf, hold; +- int tmplen = sizeof(hold); ++ socklen_t tmplen = sizeof(hold); + + if (!sndbuf) + sndbuf = alloc; +@@ -464,7 +464,7 @@ void setup(int icmp_sock) + + if (!(options & F_PINGFILLED)) { + int i; +- char *p = outpack+8; ++ u_char *p = outpack+8; + + /* Do not forget about case of small datalen, + * fill timestamp area too! +diff --git a/rarpd.c b/rarpd.c +index 5cb0ab8..65fd57f 100644 +--- a/rarpd.c ++++ b/rarpd.c +@@ -417,7 +417,7 @@ void serve_it(int fd) + { + unsigned char buf[1024]; + struct sockaddr_ll sll; +- int sll_len = sizeof(sll); ++ socklen_t sll_len = sizeof(sll); + struct arphdr *a = (struct arphdr*)buf; + struct rarp_map *rmap; + unsigned char *ptr; +diff --git a/rdisc.c b/rdisc.c +index 5f598e2..dc52b3e 100644 +--- a/rdisc.c ++++ b/rdisc.c +@@ -451,7 +451,7 @@ next: + for (;;) { + u_char packet[MAXPACKET]; + int len = sizeof (packet); +- int fromlen = sizeof (from); ++ socklen_t fromlen = sizeof (from); + int cc; + + cc=recvfrom(s, (char *)packet, len, 0, +diff --git a/tftpd.c b/tftpd.c +index 301151e..39f2164 100644 +--- a/tftpd.c ++++ b/tftpd.c +@@ -88,7 +88,7 @@ union { + struct sockaddr_in sin; + struct sockaddr_in6 sin6; + } from; +-int fromlen; ++socklen_t fromlen; + + #define MAXARG 1 + char *dirs[MAXARG+1]; +@@ -148,7 +148,8 @@ int main(int ac, char **av) + */ + { + int pid; +- int i, j; ++ int i; ++ socklen_t j; + + for (i = 1; i < 20; i++) { + pid = fork(); +diff --git a/traceroute6.c b/traceroute6.c +index fdb631f..114cb0a 100644 +--- a/traceroute6.c ++++ b/traceroute6.c +@@ -510,7 +510,7 @@ int main(int argc, char *argv[]) + (char *)&on, sizeof(on)); + + if (source == NULL) { +- int alen; ++ socklen_t alen; + int probe_fd = socket(AF_INET6, SOCK_DGRAM, 0); + + if (probe_fd < 0) { diff --git a/iputils-use-proper-loops.patch b/iputils-use-proper-loops.patch new file mode 100644 index 0000000..df36b89 --- /dev/null +++ b/iputils-use-proper-loops.patch @@ -0,0 +1,137 @@ +use proper looping code rather than labels/gotos as some versions of +gcc may miscompile the code. + +Signed-off-by: Robert Moss +Signed-off-by: Mike Frysinger + +diff --git a/tracepath.c b/tracepath.c +index c3f6f74..7ff85a2 100644 +--- a/tracepath.c ++++ b/tracepath.c +@@ -77,7 +77,7 @@ int recverr(int fd, int ttl) + int progress = -1; + int broken_router; + +-restart: ++ while (1) { + memset(&rcvbuf, -1, sizeof(rcvbuf)); + iov.iov_base = &rcvbuf; + iov.iov_len = sizeof(rcvbuf); +@@ -94,7 +94,7 @@ restart: + if (res < 0) { + if (errno == EAGAIN) + return progress; +- goto restart; ++ continue; + } + + progress = mtu; +@@ -217,7 +217,7 @@ restart: + perror("NET ERROR"); + return 0; + } +- goto restart; ++ } + } + + int probe_ttl(int fd, int ttl) +@@ -228,7 +228,6 @@ int probe_ttl(int fd, int ttl) + + memset(sndbuf,0,mtu); + +-restart: + for (i=0; i<10; i++) { + int res; + +@@ -244,7 +243,8 @@ restart: + if (res==0) + return 0; + if (res > 0) +- goto restart; ++ i = 0; ++ continue; + } + hisptr = (hisptr + 1)&63; + +diff --git a/tracepath6.c b/tracepath6.c +index 23d6a8c..6d2a95b 100644 +--- a/tracepath6.c ++++ b/tracepath6.c +@@ -71,7 +71,7 @@ int recverr(int fd, int ttl) + int progress = -1; + int broken_router; + +-restart: ++ while (1) { + memset(&rcvbuf, -1, sizeof(rcvbuf)); + iov.iov_base = &rcvbuf; + iov.iov_len = sizeof(rcvbuf); +@@ -88,7 +88,7 @@ restart: + if (res < 0) { + if (errno == EAGAIN) + return progress; +- goto restart; ++ continue; + } + + progress = 2; +@@ -233,34 +233,29 @@ restart: + perror("NET ERROR"); + return 0; + } +- goto restart; ++ } + } + + int probe_ttl(int fd, int ttl) + { +- int i; ++ int i=0, res; + char sndbuf[mtu]; + struct probehdr *hdr = (struct probehdr*)sndbuf; + +-restart: +- +- for (i=0; i<10; i++) { +- int res; +- +- hdr->ttl = ttl; +- gettimeofday(&hdr->tv, NULL); +- if (send(fd, sndbuf, mtu-overhead, 0) > 0) +- break; +- res = recverr(fd, ttl); +- if (res==0) +- return 0; +- if (res > 0) +- goto restart; +- } +- +- if (i<10) { +- int res; +- ++ while (i<10) { ++ for (i=0; i<10; i++) { ++ hdr->ttl = ttl; ++ gettimeofday(&hdr->tv, NULL); ++ if (send(fd, sndbuf, mtu-overhead, 0) > 0) ++ break; ++ res = recverr(fd, ttl); ++ if (res==0) ++ return 0; ++ if (res > 0) { ++ i = 0; ++ continue; ++ } ++ } + data_wait(fd); + if (recv(fd, sndbuf, sizeof(sndbuf), MSG_DONTWAIT) > 0) { + printf("%2d?: reply received 8)\n", ttl); +@@ -268,7 +263,7 @@ restart: + } + res = recverr(fd, ttl); + if (res == 1) +- goto restart; ++ continue; + return res; + } + diff --git a/kbd-1.12-cz-qwerty-map.patch b/kbd-1.12-cz-qwerty-map.patch new file mode 100644 index 0000000..8e534bf --- /dev/null +++ b/kbd-1.12-cz-qwerty-map.patch @@ -0,0 +1,101 @@ +kavol@email.cz writes: + +I wanted to use the keymap file /usr/share/keymaps/i386/qwerty/cz.map.gz, +but I have found this to be qwertz so I think it should be placed in +/usr/share/keymaps/i386/qwertz/ (or, much better, converted to qwerty - +I don't understand the masochists who use us-qwerty and cz-qwertz together :-) + +http://bugs.gentoo.org/19010 + +Gentoo notes: +We copy the qwerty/cz.map to qwertz/cz.map and then apply this patch ... +that way we end up with both a qwerty and qwertz version of the cz.map + +--- data/keymaps/i386/qwerty/cz.map.old 2004-06-21 00:03:22.000000000 +0200 ++++ data/keymaps/i386/qwerty/cz.map 2004-10-24 16:04:44.471056808 +0200 +@@ -1,6 +1,9 @@ ++# *** toto neni originalni verze souboru: ++# *** upraveno z puvodni QWERTZ na QWERTY + opraveno par preklepu ++# + # Tato keymapa NENI urcena pro jadro "opatchovane" programem "patch-capslock" + # +-# klavesova mapa kompatibilni s windows QWERTZ ++# klavesova mapa kompatibilni s windows QWERTY + # + # Vytvoril: Richard S~puta, Richard.Sputa@os3.os.ds.mfcr.cz + # +@@ -11,7 +14,7 @@ + # Links: ftp://ftp.penguin.cz/pub/cestina/klavesnice/console/ + # - primary ftp archiv + # http://www.debian.cz/proj/czkbd/index.php3 +-# - czech keyboard standarts ++# - czech keyboard standards + # + # + # POZOR: Tato klavesova mapa obsahuje ve skutecnosti 2 (dve) klavesnice +@@ -27,7 +30,7 @@ + # Navic klavesa "PrintScreen" funguje jako carka a hacek + # + # +-# Rozsireni oproti standartni_CESKE_unikodove_klavesnici ++# Rozsireni oproti standardni_CESKE_unikodove_klavesnici + # (zde jsou popsany pouze kombinace, jejichz umisteni je diskutabilni) + # (popis ostatnich rozsireni je v souboru "readme.txt") + # 1) AltGr-SPACE => znak "nobreakspace" (neoddelitelna mezera kod 0xa0) +@@ -148,7 +151,7 @@ + # Linefeed (primarni) => Control_j + # + # vzdalenost mezi zacatky symbolu: +-# 12 znaku (standartne) vyhovuje 80% symbolickych nazvu ++# 12 znaku (standardne) vyhovuje 80% symbolickych nazvu + # 25 znaku ma symbolicky nazev Meta_Control_bracketright + # 123456789012 123456789012 123456789012 123456789012 123456789012 + keycode 1 = Escape Escape VoidSymbol VoidSymbol VoidSymbol \ +@@ -383,15 +386,15 @@ + VoidSymbol VoidSymbol +T t VoidSymbol \ + VoidSymbol VoidSymbol VoidSymbol Meta_T Meta_t \ + VoidSymbol +-keycode 21 = +z Z VoidSymbol VoidSymbol Control_z \ +- Control_z VoidSymbol VoidSymbol Meta_z Meta_Z \ +- VoidSymbol VoidSymbol +Z z VoidSymbol \ +- VoidSymbol VoidSymbol VoidSymbol Meta_Z Meta_z \ ++keycode 21 = +y Y VoidSymbol VoidSymbol Control_y \ ++ Control_y VoidSymbol VoidSymbol Meta_y Meta_Y \ ++ VoidSymbol VoidSymbol +Y y VoidSymbol \ ++ VoidSymbol VoidSymbol VoidSymbol Meta_Z Meta_y \ + VoidSymbol \ +- +z Z VoidSymbol VoidSymbol Control_z \ +- Control_z VoidSymbol VoidSymbol Meta_z Meta_Z \ +- VoidSymbol VoidSymbol +Z z VoidSymbol \ +- VoidSymbol VoidSymbol VoidSymbol Meta_Z Meta_z \ ++ +y Y VoidSymbol VoidSymbol Control_y \ ++ Control_y VoidSymbol VoidSymbol Meta_y Meta_Y \ ++ VoidSymbol VoidSymbol +Y y VoidSymbol \ ++ VoidSymbol VoidSymbol VoidSymbol Meta_Y Meta_y \ + VoidSymbol + keycode 22 = +u U VoidSymbol VoidSymbol Control_u \ + Control_u VoidSymbol VoidSymbol Meta_u Meta_U \ +@@ -601,15 +604,15 @@ + Meta_Control_backslash bar bar VoidSymbol \ + VoidSymbol VoidSymbol VoidSymbol Meta_bar Meta_bar \ + VoidSymbol +-keycode 44 = +y Y degree degree Control_y \ +- Control_y VoidSymbol VoidSymbol Meta_y Meta_Y \ +- VoidSymbol VoidSymbol +Y y VoidSymbol \ +- VoidSymbol VoidSymbol VoidSymbol Meta_Y Meta_y \ ++keycode 44 = +z Z degree degree Control_z \ ++ Control_z VoidSymbol VoidSymbol Meta_z Meta_Z \ ++ VoidSymbol VoidSymbol +Z z VoidSymbol \ ++ VoidSymbol VoidSymbol VoidSymbol Meta_Z Meta_z \ + VoidSymbol \ +- +y Y degree degree Control_y \ +- Control_y VoidSymbol VoidSymbol Meta_y Meta_Y \ +- VoidSymbol VoidSymbol +Y y VoidSymbol \ +- VoidSymbol VoidSymbol VoidSymbol Meta_Y Meta_y \ ++ +z Z degree degree Control_z \ ++ Control_z VoidSymbol VoidSymbol Meta_z Meta_Z \ ++ VoidSymbol VoidSymbol +Z z VoidSymbol \ ++ VoidSymbol VoidSymbol VoidSymbol Meta_Z Meta_z \ + VoidSymbol + keycode 45 = +x X numbersign numbersign Control_x \ + Control_x VoidSymbol VoidSymbol Meta_x Meta_X \ diff --git a/kbd-1.12-jp-escape.patch b/kbd-1.12-jp-escape.patch new file mode 100644 index 0000000..f413f00 --- /dev/null +++ b/kbd-1.12-jp-escape.patch @@ -0,0 +1,16 @@ +Recognize Ctrl-[ as Escape. + +Patch by OKUMURA N. Shin-ya. + +http://bugs.gentoo.org/71870 + +--- data/keymaps/i386/qwerty/jp106.map ++++ data/keymaps/i386/qwerty/jp106.map +@@ -35,6 +35,7 @@ + keycode 26 = at grave + control keycode 26 = nul + keycode 27 = bracketleft braceleft ++ control keycode 27 = Escape + keycode 28 = Return + alt keycode 28 = Meta_Control_m + keycode 29 = Control diff --git a/kbd-1.12-unimap.patch b/kbd-1.12-unimap.patch new file mode 100644 index 0000000..6b01819 --- /dev/null +++ b/kbd-1.12-unimap.patch @@ -0,0 +1,12 @@ +--- kbd-1.12/src/loadunimap.c.orig 2006-08-24 13:48:11.000000000 +0100 ++++ kbd-1.12/src/loadunimap.c 2006-08-24 13:49:07.000000000 +0100 +@@ -28,7 +28,7 @@ + extern char *progname; + extern int force; + +-static char *unidirpath[] = { "", DATADIR "/" TRANSDIR "/", 0 }; +-static char *unisuffixes[] = { "", ".sfm", ".uni", 0 }; ++static char *unidirpath[] = { "", DATADIR "/" UNIMAPDIR "/", DATADIR "/" TRANSDIR "/", 0 }; ++static char *unisuffixes[] = { "", ".uni", ".sfm", 0 }; + + #ifdef MAIN diff --git a/kbd-1.14.1-missing-configure.patch b/kbd-1.14.1-missing-configure.patch new file mode 100644 index 0000000..b9fe961 --- /dev/null +++ b/kbd-1.14.1-missing-configure.patch @@ -0,0 +1,15 @@ +fix from Charles Clément for missing binaries + +http://bugs.gentoo.org/215610 + +--- kbd-1.14.1/src/Makefile.in ++++ kbd-1.14.1/src/Makefile.in +@@ -2,6 +2,8 @@ prefix = @prefix@ + exec_prefix = @exec_prefix@ + bindir = $(DESTDIR)@bindir@ + datarootdir = @datarootdir@ ++KEYCODES_PROGS = @KEYCODES_PROGS@ ++RESIZECONS_PROGS = @RESIZECONS_PROGS@ + OPTIONAL_PROGS = @OPTIONAL_PROGS@ + + # Something like /usr/lib/kbd or /usr/share/kbd diff --git a/ldr-utils-prompt.patch b/ldr-utils-prompt.patch new file mode 100644 index 0000000..2064fd8 --- /dev/null +++ b/ldr-utils-prompt.patch @@ -0,0 +1,148 @@ +Index: lfd.c +=================================================================== +--- lfd.c (revision 1684) ++++ lfd.c (working copy) +@@ -493,6 +493,16 @@ static void ldr_send_timeout(int sig) + warn("received signal %i: timeout while sending; aborting", sig); + exit(2); + } ++static char ldr_send_prompt(const char *msg) ++{ ++ int foo; ++ char dummy; ++ alarm(0); ++ printf("%s: ", msg); ++ fflush(stdout); ++ foo = scanf("%c", &dummy); ++ return (foo == EOF ? EOF : dummy); ++} + static bool ldr_load_uart(LFD *alfd, const void *void_opts) + { + const struct ldr_load_options *opts = void_opts; +@@ -515,10 +525,9 @@ static bool ldr_load_uart(LFD *alfd, con + + setbuf(stdout, NULL); + +- /* give ourselves like ten seconds to do autobaud */ + old_alarm = signal(SIGALRM, ldr_send_timeout); +- alarm(10); + ++ alarm(10); + printf("Opening %s ... ", tty); + if (tty[0] != '#') { + fd = open(tty, O_RDWR); +@@ -538,6 +547,10 @@ static bool ldr_load_uart(LFD *alfd, con + } else + printf("OK!\n"); + ++ if (opts->prompt) ++ ldr_send_prompt("Press any key to send autobaud"); ++ ++ alarm(10); + printf("Trying to send autobaud ... "); + ret = write(fd, "@", 1); + if (ret != 1) +@@ -545,6 +558,10 @@ static bool ldr_load_uart(LFD *alfd, con + tcdrain(fd); + printf("OK!\n"); + ++ if (opts->prompt) ++ ldr_send_prompt("Press any key to read autobaud"); ++ ++ alarm(10); + printf("Trying to read autobaud ... "); + ret = read_retry(fd, autobaud, 4); + if (ret != 4) +@@ -567,10 +584,15 @@ static bool ldr_load_uart(LFD *alfd, con + autobaud[0], autobaud[1], autobaud[2], autobaud[3]); + + if (ldr->header) { ++ if (opts->prompt) ++ ldr_send_prompt("Press any key to send global LDR header"); ++ ++ alarm(10); + printf("Sending global LDR header ... "); + ret = write(fd, ldr->header, ldr->header_size); + if (ret != (ssize_t)ldr->header_size) + goto out; ++ tcdrain(fd); + printf("OK!\n"); + } + +@@ -580,6 +602,9 @@ static bool ldr_load_uart(LFD *alfd, con + BLOCK *block = &(ldr->dxes[d].blocks[b]); + int del; + ++ if (opts->prompt) ++ ldr_send_prompt("Press any key to send block header"); ++ + alarm(60); + + if (verbose) +@@ -591,6 +616,9 @@ static bool ldr_load_uart(LFD *alfd, con + goto out; + tcdrain(fd); + ++ if (opts->prompt && block->data != NULL) ++ ldr_send_prompt("Press any key to send block data"); ++ + del += printf("%zi] (%2.0f%%)", ldr->dxes[d].num_blocks, + ((float)(b+1) / (float)ldr->dxes[d].num_blocks) * 100); + if (block->data != NULL) { +Index: ldr.c +=================================================================== +--- ldr.c (revision 1684) ++++ ldr.c (working copy) +@@ -101,13 +101,15 @@ static struct option_help const create_o + }; + #define show_create_usage(status) show_some_usage("create", create_long_opts, create_opts_help, CREATE_PARSE_FLAGS, status) + +-#define LOAD_PARSE_FLAGS COMMON_FLAGS "b:f" ++#define LOAD_PARSE_FLAGS COMMON_FLAGS "b:p" + static struct option const load_long_opts[] = { + {"baud", a_argument, NULL, 'b'}, ++ {"prompt", no_argument, NULL, 'p'}, + COMMON_LONG_OPTS + }; + static struct option_help const load_opts_help[] = { +- {"Set baud rate (default 115200)", ""}, ++ {"Set baud rate (default 115200)", ""}, ++ {"Prompt for data flow", NULL}, + COMMON_HELP_OPTS + }; + #define show_load_usage(status) show_some_usage("load", load_long_opts, load_opts_help, LOAD_PARSE_FLAGS, status) +@@ -238,11 +240,13 @@ static bool load_ldr(const int argc, cha + struct ldr_load_options opts = { + .tty = NULL, + .baud = 115200, ++ .prompt = false, + }; + + while ((i=getopt_long(argc, argv, LOAD_PARSE_FLAGS, load_long_opts, NULL)) != -1) { + switch (i) { + case 'b': opts.baud = atoi(optarg); break; ++ case 'p': opts.prompt = true; break; + case 'h': show_load_usage(0); + CASE_common_errors + } +Index: ldr.h +=================================================================== +--- ldr.h (revision 1684) ++++ ldr.h (working copy) +@@ -46,6 +46,7 @@ struct ldr_create_options { + struct ldr_load_options { + const char *tty; + size_t baud; ++ bool prompt; + }; + + struct ldr_dump_options { +Index: .depend +=================================================================== +--- .depend (revision 1684) ++++ .depend (working copy) +@@ -11,3 +11,4 @@ lfd_bf561.o: lfd_bf561.c ldr.h headers.h + dxe_jump.h blackfin_defines.h ldr_elf.h + lfd.o: lfd.c ldr.h headers.h elf.h helpers.h lfd.h dxes.h dxe_jump.h \ + blackfin_defines.h ldr_elf.h ++test.o: test.c diff --git a/ldr.patch b/ldr.patch new file mode 100644 index 0000000..cb3b005 --- /dev/null +++ b/ldr.patch @@ -0,0 +1,33 @@ +--- toolchain/ldrviewer/ldr.c~ 2006-10-17 15:14:17.000000000 -0400 ++++ toolchain/ldrviewer/ldr.c 2006-10-17 15:27:20.000000000 -0400 +@@ -353,15 +353,27 @@ + printf("Trying to read autobaud ... "); + ret = read(fd, autobaud, 4); + if (ret != 4) { ++ /* + printf(" read failed we got %d bytes\n", ret); + printf(" Data %02x %02x %02x %02x \n", + autobaud[0], + autobaud[1], + autobaud[2], + autobaud[3]); +- //if (autobaud[0]==0xBF) +- +- goto canned_failure; ++ */ ++ if ((autobaud[0]==0xBF) && (ret > 1)) { ++ ret += read(fd, &autobaud[ret], 4-ret); ++ /* ++ printf(" after 2nd read ret = %d\n", ret); ++ ++ printf(" Data %02x %02x %02x %02x \n", ++ autobaud[0], ++ autobaud[1], ++ autobaud[2], ++ autobaud[3]); ++ */ ++ } ++ if ( ret != 4 ) goto canned_failure; + } + printf("OK!\n"); + diff --git a/ldrviewer-retry.patch b/ldrviewer-retry.patch new file mode 100644 index 0000000..97d2d9b --- /dev/null +++ b/ldrviewer-retry.patch @@ -0,0 +1,79 @@ +? ldrs +? ldrviewer +Index: headers.h +=================================================================== +RCS file: /cvsroot/gcc3/ldrviewer/headers.h,v +retrieving revision 1.2 +diff -u -p -r1.2 headers.h +--- headers.h 22 Sep 2006 01:44:59 -0000 1.2 ++++ headers.h 17 Oct 2006 20:54:10 -0000 +@@ -21,6 +21,7 @@ + #include + #include + #include ++#include + #include + #include + #include +Index: helpers.c +=================================================================== +RCS file: /cvsroot/gcc3/ldrviewer/helpers.c,v +retrieving revision 1.2 +diff -u -p -r1.2 helpers.c +--- helpers.c 22 Sep 2006 01:44:59 -0000 1.2 ++++ helpers.c 17 Oct 2006 20:54:10 -0000 +@@ -40,3 +40,24 @@ int parse_bool(const char *boo) + return 0; + err("Invalid boolean: '%s'", boo); + } ++ ++ssize_t read_retry(int fd, void *buf, size_t count) ++{ ++ ssize_t ret = 0, temp_ret; ++ while (count > 0) { ++ temp_ret = read(fd, buf, count); ++ if (temp_ret > 0) { ++ ret += temp_ret; ++ buf += temp_ret; ++ count -= temp_ret; ++ } else if (temp_ret == 0) { ++ break; ++ } else { ++ if (errno == EINTR) ++ continue; ++ ret = -1; ++ break; ++ } ++ } ++ return ret; ++} +Index: helpers.h +=================================================================== +RCS file: /cvsroot/gcc3/ldrviewer/helpers.h,v +retrieving revision 1.2 +diff -u -p -r1.2 helpers.h +--- helpers.h 22 Sep 2006 01:44:59 -0000 1.2 ++++ helpers.h 17 Oct 2006 20:54:10 -0000 +@@ -41,5 +41,6 @@ extern const char *argv0; + void *xmalloc(size_t); + void *xrealloc(void *, size_t); + int parse_bool(const char *); ++ssize_t read_retry(int, void *, size_t); + + #endif +Index: ldr.c +=================================================================== +RCS file: /cvsroot/gcc3/ldrviewer/ldr.c,v +retrieving revision 1.2 +diff -u -p -r1.2 ldr.c +--- ldr.c 22 Sep 2006 01:44:59 -0000 1.2 ++++ ldr.c 17 Oct 2006 20:54:10 -0000 +@@ -379,7 +379,7 @@ canned_failure: + printf("OK!\n"); + + printf("Trying to read autobaud ... "); +- ret = read(fd, autobaud, 4); ++ ret = read_retry(fd, autobaud, 4); + if (ret != 4) + goto canned_failure; + printf("OK!\n"); diff --git a/ldso-safe-runpath.patch b/ldso-safe-runpath.patch new file mode 100644 index 0000000..e2f87b0 --- /dev/null +++ b/ldso-safe-runpath.patch @@ -0,0 +1,14 @@ +Index: dl-elf.c +=================================================================== +--- dl-elf.c (revision 10603) ++++ dl-elf.c (working copy) +@@ -174,6 +174,9 @@ + _dl_strcpy(mylibname, "."); /* Assume current dir if empty path */ + _dl_strcat(mylibname, "/"); + _dl_strcat(mylibname, name); ++#ifdef __LDSO_SAFE_RUNPATHS__ ++ if (*mylibname == '/') ++#endif + if ((tpnt = _dl_load_elf_shared_library(secure, rpnt, mylibname)) != NULL) + return tpnt; + path_n = path+1; diff --git a/less.patch b/less.patch new file mode 100644 index 0000000..a0549d0 --- /dev/null +++ b/less.patch @@ -0,0 +1,272 @@ +--- busybox/miscutils/less.c 2006-04-22 08:20:29.000000000 +0100 ++++ busybox/miscutils/less.c 2006-04-23 11:28:08.000000000 +0100 +@@ -104,10 +104,11 @@ + + #ifdef CONFIG_FEATURE_LESS_REGEXP + static int match_found; +-static int match_lines[100]; ++static int *match_lines; + static int match_pos; + static int num_matches; + static int match_backwards; ++static regex_t old_pattern; + #endif + + /* Needed termios structures */ +@@ -235,14 +236,6 @@ + add_linenumbers(); + } + +-/* Turn a percentage into a line number */ +-static int reverse_percent(int percentage) +-{ +- double linenum = percentage; +- linenum = ((linenum / 100) * num_flines) - 1; +- return(linenum); +-} +- + #ifdef CONFIG_FEATURE_LESS_FLAGS + + /* Interestingly, writing calc_percent as a function and not a prototype saves around 32 bytes +@@ -463,12 +456,11 @@ + static void buffer_line(int linenum) + { + int i; +- + past_eof = 0; + +- if (linenum < 1 || linenum > num_flines) { ++ if (linenum < 0 || linenum > num_flines) { + clear_line(); +- printf("%s%s%i%s", HIGHLIGHT, "Cannot seek to line number ", linenum, NORMAL); ++ printf("%s%s%i%s", HIGHLIGHT, "Cannot seek to line number ", linenum + 1, NORMAL); + } + else if (linenum < (num_flines - height - 2)) { + for (i = 0; i < (height - 1); i++) { +@@ -476,6 +468,7 @@ + buffer[i] = bb_xstrdup(flines[linenum + i]); + } + line_pos = linenum; ++ buffer_print(); + } + else { + for (i = 0; i < (height - 1); i++) { +@@ -488,6 +481,7 @@ + line_pos = linenum; + /* Set past_eof so buffer_down and buffer_up act differently */ + past_eof = 1; ++ buffer_print(); + } + } + +@@ -610,46 +604,44 @@ + /* Get a regular expression from the user, and then go through the current + file line by line, running a processing regex function on each one. */ + +-static char *insert_highlights(char *line, int start, int end) +-{ +- return bb_xasprintf("%.*s%s%.*s%s%s", start, line, HIGHLIGHT, +- end - start, line + start, NORMAL, line + end); +-} +- +-static char *process_regex_on_line(char *line, regex_t *pattern) ++static char *process_regex_on_line(char *line, regex_t *pattern, int action) + { + /* This function takes the regex and applies it to the line. + Each part of the line that matches has the HIGHLIGHT + and NORMAL escape sequences placed around it by +- insert_highlights, and then the line is returned. */ +- ++ insert_highlights if action = 1, or has the escape sequences ++ removed if action = 0, and then the line is returned. */ + int match_status; + char *line2 = (char *) xmalloc((sizeof(char) * (strlen(line) + 1)) + 64); +- char sub_line[256]; +- int prev_eo = 0; ++ char *growline = ""; + regmatch_t match_structs; + +- strcpy(line2, line); ++ line2 = bb_xstrdup(line); + + match_found = 0; + match_status = regexec(pattern, line2, 1, &match_structs, 0); +- ++ + while (match_status == 0) { +- +- memset(sub_line, 0, sizeof(sub_line)); +- + if (match_found == 0) + match_found = 1; +- +- line2 = insert_highlights(line2, match_structs.rm_so + prev_eo, match_structs.rm_eo + prev_eo); +- if ((size_t)match_structs.rm_eo + 11 + prev_eo < strlen(line2)) +- strcat(sub_line, line2 + match_structs.rm_eo + 11 + prev_eo); +- +- prev_eo += match_structs.rm_eo + 11; +- match_status = regexec(pattern, sub_line, 1, &match_structs, REG_NOTBOL); ++ ++ if (action) { ++ growline = bb_xasprintf("%s%.*s%s%.*s%s", growline, match_structs.rm_so, line2, HIGHLIGHT, match_structs.rm_eo - match_structs.rm_so, line2 + match_structs.rm_so, NORMAL); ++ } ++ else { ++ growline = bb_xasprintf("%s%.*s%.*s", growline, match_structs.rm_so - 4, line2, match_structs.rm_eo - match_structs.rm_so, line2 + match_structs.rm_so); ++ } ++ ++ line2 += match_structs.rm_eo; ++ match_status = regexec(pattern, line2, 1, &match_structs, REG_NOTBOL); + } +- +- return line2; ++ ++ growline = bb_xasprintf("%s%s", growline, line2); ++ ++ return (match_found ? growline : line); ++ ++ free(growline); ++ free(line2); + } + + static void goto_match(int match) +@@ -665,11 +657,10 @@ + static void regex_process(void) + { + char uncomp_regex[100]; +- char current_line[256]; ++ char *current_line; + int i; + int j = 0; + regex_t pattern; +- + /* Get the uncompiled regular expression from the user */ + clear_line(); + putchar((match_backwards) ? '?' : '/'); +@@ -677,32 +668,43 @@ + fgets(uncomp_regex, sizeof(uncomp_regex), inp); + + if (strlen(uncomp_regex) == 1) { +- goto_match(match_backwards ? match_pos - 1 : match_pos + 1); +- buffer_print(); ++ if (num_matches) ++ goto_match(match_backwards ? match_pos - 1 : match_pos + 1); ++ else ++ buffer_print(); + return; + } +- + uncomp_regex[strlen(uncomp_regex) - 1] = '\0'; + + /* Compile the regex and check for errors */ + xregcomp(&pattern, uncomp_regex, 0); + ++ if (num_matches) { ++ /* Get rid of all the highlights we added previously */ ++ for (i = 0; i <= num_flines; i++) { ++ current_line = process_regex_on_line(flines[i], &old_pattern, 0); ++ flines[i] = bb_xstrdup(current_line); ++ } ++ } ++ old_pattern = pattern; ++ + /* Reset variables */ ++ match_lines = xrealloc(match_lines, sizeof(int)); + match_lines[0] = -1; + match_pos = 0; + num_matches = 0; + match_found = 0; +- + /* Run the regex on each line of the current file here */ + for (i = 0; i <= num_flines; i++) { +- strcpy(current_line, process_regex_on_line(flines[i], &pattern)); ++ current_line = process_regex_on_line(flines[i], &pattern, 1); + flines[i] = bb_xstrdup(current_line); + if (match_found) { ++ match_lines = xrealloc(match_lines, (j + 1) * sizeof(int)); + match_lines[j] = i; + j++; + } + } +- ++ + num_matches = j; + if ((match_lines[0] != -1) && (num_flines > height - 2)) { + if (match_backwards) { +@@ -764,7 +766,7 @@ + buffer_line(num - 1); + break; + case 'p': case '%': +- buffer_line(reverse_percent(num)); ++ buffer_line(((num / 100) * num_flines) - 1); + break; + #ifdef CONFIG_FEATURE_LESS_REGEXP + case 'n': +@@ -852,7 +854,6 @@ + data_readlines(); + buffer_init(); + buffer_line(temp_line_pos); +- buffer_print(); + } + + +@@ -866,7 +867,7 @@ + printf("Log file: "); + fgets(current_line, 256, inp); + current_line[strlen(current_line) - 1] = '\0'; +- if (strlen(current_line)) { ++ if (strlen(current_line) > 1) { + fp = bb_xfopen(current_line, "w"); + for (i = 0; i < num_flines; i++) + fprintf(fp, "%s", flines[i]); +@@ -973,7 +974,6 @@ + printf("%s%s%s", HIGHLIGHT, "No matching bracket found", NORMAL); + + buffer_line(bracket_line - height + 2); +- buffer_print(); + } + } + +@@ -1001,7 +1001,6 @@ + printf("%s%s%s", HIGHLIGHT, "No matching bracket found", NORMAL); + + buffer_line(bracket_line); +- buffer_print(); + } + } + +@@ -1035,12 +1034,10 @@ + buffer_print(); + break; + case 'g': case 'p': case '<': case '%': +- buffer_up(num_flines + 1); +- buffer_print(); ++ buffer_line(0); + break; + case 'G': case '>': +- buffer_down(num_flines + 1); +- buffer_print(); ++ buffer_line(num_flines - height + 2); + break; + case 'q': case 'Q': + tless_exit(0); +@@ -1078,20 +1075,16 @@ + case '/': + match_backwards = 0; + regex_process(); +- buffer_print(); + break; + case 'n': + goto_match(match_pos + 1); +- buffer_print(); + break; + case 'N': + goto_match(match_pos - 1); +- buffer_print(); + break; + case '?': + match_backwards = 1; + regex_process(); +- buffer_print(); + break; + #endif + #ifdef CONFIG_FEATURE_LESS_FLAGCS diff --git a/libc-string-x86_64-head.diff.patch b/libc-string-x86_64-head.diff.patch new file mode 100644 index 0000000..631d141 --- /dev/null +++ b/libc-string-x86_64-head.diff.patch @@ -0,0 +1,47 @@ +--- libc-string-x86_64-head.diff ++++ libc-string-x86_64-head.diff +@@ -244,7 +244,7 @@ + +# include + +#endif + + +-+#ifdef PIC +++#if defined PIC && defined SHARED + + .globl _rtld_local_ro + + .hidden _rtld_local_ro + + .set _rtld_local_ro,_rtld_global_ro +@@ -715,7 +715,7 @@ + - and the return value is the byte after the last one copied in + - the destination. */ + -#define MEMPCPY_P (defined memcpy) +-+#ifdef PIC +++#if defined PIC && defined SHARED + + .globl _rtld_local_ro + + .hidden _rtld_local_ro + + .set _rtld_local_ro,_rtld_global_ro +@@ -1298,7 +1298,7 @@ + -/* This is somehow experimental and could made dependend on the cache + - size. */ + -#define LARGE $120000 +-+#ifdef PIC +++#if defined PIC && defined SHARED + + .globl _rtld_local_ro + + .hidden _rtld_local_ro + + .set _rtld_local_ro,_rtld_global_ro +@@ -2255,7 +2255,7 @@ + + -#ifndef USE_AS_STPCPY + -# define STRCPY strcpy +-+#ifdef PIC +++#if defined PIC && defined SHARED + + .globl _rtld_local_ro + + .hidden _rtld_local_ro + + .set _rtld_local_ro,_rtld_global_ro +@@ -3543,7 +3543,7 @@ + +# include + +#endif + + +-+#ifdef PIC +++#if defined PIC && defined SHARED + + .globl _rtld_local_ro + + .hidden _rtld_local_ro + + .set _rtld_local_ro,_rtld_global_ro diff --git a/libdv-0.104-pic-fix-pax.patch b/libdv-0.104-pic-fix-pax.patch new file mode 100644 index 0000000..00dec02 --- /dev/null +++ b/libdv-0.104-pic-fix-pax.patch @@ -0,0 +1,2007 @@ +diff -Nurp libdv-0.104-old/libdv/asm_common.S libdv-0.104/libdv/asm_common.S +--- libdv-0.104-old/libdv/asm_common.S 1970-01-01 01:00:00.000000000 +0100 ++++ libdv-0.104/libdv/asm_common.S 2006-01-01 22:44:43.000000000 +0100 +@@ -0,0 +1,37 @@ ++/* public domain, do what you want */ ++ ++#ifdef __PIC__ ++# define MUNG(sym) sym##@GOTOFF(%ebp) ++# define MUNG_ARR(sym, args...) sym##@GOTOFF(%ebp,##args) ++#else ++# define MUNG(sym) sym ++# define MUNG_ARR(sym, args...) sym(,##args) ++#endif ++ ++#ifdef __PIC__ ++# undef __i686 /* gcc define gets in our way */ ++ .section .gnu.linkonce.t.__i686.get_pc_thunk.bp,"ax",@progbits ++.globl __i686.get_pc_thunk.bp ++ .hidden __i686.get_pc_thunk.bp ++ .type __i686.get_pc_thunk.bp,@function ++__i686.get_pc_thunk.bp: ++ movl (%esp), %ebp ++ ret ++# define LOAD_PIC_REG_BP() \ ++ call __i686.get_pc_thunk.bp ; \ ++ addl $_GLOBAL_OFFSET_TABLE_, %ebp ++ ++ .section .gnu.linkonce.t.__i686.get_pc_thunk.si,"ax",@progbits ++.globl __i686.get_pc_thunk.si ++ .hidden __i686.get_pc_thunk.si ++ .type __i686.get_pc_thunk.si,@function ++__i686.get_pc_thunk.si: ++ movl (%esp), %esi ++ ret ++# define LOAD_PIC_REG_SI() \ ++ call __i686.get_pc_thunk.si ; \ ++ addl $_GLOBAL_OFFSET_TABLE_, %esi ++#else ++# define LOAD_PIC_REG_BP() ++# define LOAD_PIC_REG_SI() ++#endif +diff -Nurp libdv-0.104-old/libdv/dct_block_mmx.S libdv-0.104/libdv/dct_block_mmx.S +--- libdv-0.104-old/libdv/dct_block_mmx.S 2006-01-01 22:44:22.000000000 +0100 ++++ libdv-0.104/libdv/dct_block_mmx.S 2006-01-01 22:44:43.000000000 +0100 +@@ -53,17 +53,22 @@ scratch2: .quad 0 + scratch3: .quad 0 + scratch4: .quad 0 + ++#include "asm_common.S" ++ + .text + + .align 8 + .global _dv_dct_88_block_mmx ++.hidden _dv_dct_88_block_mmx ++.type _dv_dct_88_block_mmx,@function + _dv_dct_88_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + +- movl 8(%ebp), %esi # source ++ LOAD_PIC_REG_BP() ++ ++ movl 12(%esp), %esi # source + + # column 0 + movq 16*0(%esi), %mm0 # v0 +@@ -86,22 +91,22 @@ _dv_dct_88_block_mmx: + + movq 16*3(%esi), %mm5 # v3 + movq 16*4(%esi), %mm7 # v4 +- movq %mm7, scratch1 # scratch1: v4 ; ++ movq %mm7, MUNG(scratch1) # scratch1: v4 ; + movq %mm5, %mm7 # duplicate v3 +- paddw scratch1, %mm5 # v03: v3+v4 +- psubw scratch1, %mm7 # v04: v3-v4 +- movq %mm5, scratch2 # scratch2: v03 ++ paddw MUNG(scratch1), %mm5 # v03: v3+v4 ++ psubw MUNG(scratch1), %mm7 # v04: v3-v4 ++ movq %mm5, MUNG(scratch2) # scratch2: v03 + movq %mm0, %mm5 # mm5: v00 + +- paddw scratch2, %mm0 # v10: v00+v03 +- psubw scratch2, %mm5 # v13: v00-v03 +- movq %mm3, scratch3 # scratch3: v02 ++ paddw MUNG(scratch2), %mm0 # v10: v00+v03 ++ psubw MUNG(scratch2), %mm5 # v13: v00-v03 ++ movq %mm3, MUNG(scratch3) # scratch3: v02 + movq %mm1, %mm3 # duplicate v01 + +- paddw scratch3, %mm1 # v11: v01+v02 +- psubw scratch3, %mm3 # v12: v01-v02 ++ paddw MUNG(scratch3), %mm1 # v11: v01+v02 ++ psubw MUNG(scratch3), %mm3 # v12: v01-v02 + +- movq %mm6, scratch4 # scratch4: v05 ++ movq %mm6, MUNG(scratch4) # scratch4: v05 + movq %mm0, %mm6 # duplicate v10 + + paddw %mm1, %mm0 # v10+v11 +@@ -111,10 +116,10 @@ _dv_dct_88_block_mmx: + movq %mm6, 16*4(%esi) # out4: v10-v11 + + movq %mm4, %mm0 # mm0: v06 +- paddw scratch4, %mm4 # v15: v05+v06 ++ paddw MUNG(scratch4), %mm4 # v15: v05+v06 + paddw %mm2, %mm0 # v16: v07+v06 + +- pmulhw WA3, %mm4 # v35~: WA3*v15 ++ pmulhw MUNG(WA3), %mm4 # v35~: WA3*v15 + psllw $1, %mm4 # v35: compensate the coeefient scale + + movq %mm4, %mm6 # duplicate v35 +@@ -123,7 +128,7 @@ _dv_dct_88_block_mmx: + + paddw %mm5, %mm3 # v22: v12+v13 + +- pmulhw WA1, %mm3 # v32~: WA1*v22 ++ pmulhw MUNG(WA1), %mm3 # v32~: WA1*v22 + psllw $16-NSHIFT, %mm3 # v32: compensate the coeefient scale + movq %mm5, %mm6 # duplicate v13 + +@@ -134,13 +139,13 @@ _dv_dct_88_block_mmx: + movq %mm6, 16*6(%esi) # out6: v13-v32 + + +- paddw scratch4, %mm7 # v14n: v04+v05 ++ paddw MUNG(scratch4), %mm7 # v14n: v04+v05 + movq %mm0, %mm5 # duplicate v16 + + psubw %mm7, %mm0 # va1: v16-v14n +- pmulhw WA5, %mm0 # va0~: va1*WA5 +- pmulhw WA4, %mm5 # v36~~: v16*WA4 +- pmulhw WA2, %mm7 # v34~~: v14n*WA2 ++ pmulhw MUNG(WA5), %mm0 # va0~: va1*WA5 ++ pmulhw MUNG(WA4), %mm5 # v36~~: v16*WA4 ++ pmulhw MUNG(WA2), %mm7 # v34~~: v14n*WA2 + psllw $16-WA4_SHIFT, %mm5 # v36: compensate the coeefient scale + psllw $16-NSHIFT, %mm7 # v34: compensate the coeefient scale + +@@ -188,22 +193,22 @@ _dv_dct_88_block_mmx: + + movq 16*3(%esi), %mm5 # v3 + movq 16*4(%esi), %mm7 # v4 +- movq %mm7, scratch1 # scratch1: v4 ; ++ movq %mm7, MUNG(scratch1) # scratch1: v4 ; + movq %mm5, %mm7 # duplicate v3 +- paddw scratch1, %mm5 # v03: v3+v4 +- psubw scratch1, %mm7 # v04: v3-v4 +- movq %mm5, scratch2 # scratch2: v03 ++ paddw MUNG(scratch1), %mm5 # v03: v3+v4 ++ psubw MUNG(scratch1), %mm7 # v04: v3-v4 ++ movq %mm5, MUNG(scratch2) # scratch2: v03 + movq %mm0, %mm5 # mm5: v00 + +- paddw scratch2, %mm0 # v10: v00+v03 +- psubw scratch2, %mm5 # v13: v00-v03 +- movq %mm3, scratch3 # scratc3: v02 ++ paddw MUNG(scratch2), %mm0 # v10: v00+v03 ++ psubw MUNG(scratch2), %mm5 # v13: v00-v03 ++ movq %mm3, MUNG(scratch3) # scratc3: v02 + movq %mm1, %mm3 # duplicate v01 + +- paddw scratch3, %mm1 # v11: v01+v02 +- psubw scratch3, %mm3 # v12: v01-v02 ++ paddw MUNG(scratch3), %mm1 # v11: v01+v02 ++ psubw MUNG(scratch3), %mm3 # v12: v01-v02 + +- movq %mm6, scratch4 # scratc4: v05 ++ movq %mm6, MUNG(scratch4) # scratc4: v05 + movq %mm0, %mm6 # duplicate v10 + + paddw %mm1, %mm0 # v10+v11 +@@ -213,10 +218,10 @@ _dv_dct_88_block_mmx: + movq %mm6, 16*4(%esi) # out4: v10-v11 + + movq %mm4, %mm0 # mm0: v06 +- paddw scratch4, %mm4 # v15: v05+v06 ++ paddw MUNG(scratch4), %mm4 # v15: v05+v06 + paddw %mm2, %mm0 # v16: v07+v06 + +- pmulhw WA3, %mm4 # v35~: WA3*v15 ++ pmulhw MUNG(WA3), %mm4 # v35~: WA3*v15 + psllw $16-NSHIFT, %mm4 # v35: compensate the coeefient scale + + movq %mm4, %mm6 # duplicate v35 +@@ -225,7 +230,7 @@ _dv_dct_88_block_mmx: + + paddw %mm5, %mm3 # v22: v12+v13 + +- pmulhw WA1, %mm3 # v32~: WA3*v15 ++ pmulhw MUNG(WA1), %mm3 # v32~: WA3*v15 + psllw $16-NSHIFT, %mm3 # v32: compensate the coeefient scale + movq %mm5, %mm6 # duplicate v13 + +@@ -235,13 +240,13 @@ _dv_dct_88_block_mmx: + movq %mm5, 16*2(%esi) # out2: v13+v32 + movq %mm6, 16*6(%esi) # out6: v13-v32 + +- paddw scratch4, %mm7 # v14n: v04+v05 ++ paddw MUNG(scratch4), %mm7 # v14n: v04+v05 + movq %mm0, %mm5 # duplicate v16 + + psubw %mm7, %mm0 # va1: v16-v14n +- pmulhw WA2, %mm7 # v34~~: v14n*WA2 +- pmulhw WA5, %mm0 # va0~: va1*WA5 +- pmulhw WA4, %mm5 # v36~~: v16*WA4 ++ pmulhw MUNG(WA2), %mm7 # v34~~: v14n*WA2 ++ pmulhw MUNG(WA5), %mm0 # va0~: va1*WA5 ++ pmulhw MUNG(WA4), %mm5 # v36~~: v16*WA4 + psllw $16-NSHIFT, %mm7 + psllw $16-WA4_SHIFT, %mm5 # v36: compensate the coeffient + # scale note that WA4 is shifted 1 bit less than the others +@@ -272,6 +277,8 @@ _dv_dct_88_block_mmx: + + .align 8 + .global _dv_dct_block_mmx_postscale_88 ++.hidden _dv_dct_block_mmx_postscale_88 ++.type _dv_dct_block_mmx_postscale_88,@function + _dv_dct_block_mmx_postscale_88: + + pushl %ebp +@@ -748,14 +755,17 @@ _dv_dct_block_mmx_postscale_88: + + .align 8 + .global _dv_dct_248_block_mmx ++.hidden _dv_dct_248_block_mmx ++.type _dv_dct_248_block_mmx,@function + _dv_dct_248_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + pushl %edi + +- movl 8(%ebp), %esi # source ++ LOAD_PIC_REG_BP() ++ ++ movl 16(%esp), %esi # source + + # column 0 + +@@ -779,7 +789,7 @@ _dv_dct_248_block_mmx: + paddw %mm1, %mm0 # v20: v10+v11 + psubw %mm1, %mm3 # v21: v10-v11 + +- pmulhw WA1, %mm5 # v32~: WA1*v22 ++ pmulhw MUNG(WA1), %mm5 # v32~: WA1*v22 + movq %mm4, %mm2 + psllw $16-NSHIFT, %mm5 # v32: compensate the coeffient scale + +@@ -818,7 +828,7 @@ _dv_dct_248_block_mmx: + paddw %mm1, %mm0 # v20: v10+v11 + psubw %mm1, %mm3 # v21: v10-v11 + +- pmulhw WA1, %mm5 # v32~: WA1*v22 ++ pmulhw MUNG(WA1), %mm5 # v32~: WA1*v22 + movq %mm4, %mm2 + psllw $16-NSHIFT, %mm5 # v32: compensate the coeffient scale + +@@ -855,7 +865,7 @@ _dv_dct_248_block_mmx: + paddw %mm1, %mm0 # v20: v10+v11 + psubw %mm1, %mm3 # v21: v10-v11 + +- pmulhw WA1, %mm5 # v32~: WA1*v22 ++ pmulhw MUNG(WA1), %mm5 # v32~: WA1*v22 + movq %mm4, %mm2 + psllw $16-NSHIFT, %mm5 # v32: compensate the coeffient scale + +@@ -892,7 +902,7 @@ _dv_dct_248_block_mmx: + paddw %mm1, %mm0 # v20: v10+v11 + psubw %mm1, %mm3 # v21: v10-v11 + +- pmulhw WA1, %mm5 # v32~: WA1*v22 ++ pmulhw MUNG(WA1), %mm5 # v32~: WA1*v22 + movq %mm4, %mm2 + psllw $16-NSHIFT, %mm5 # v32: compensate the coeffient scale + +@@ -912,6 +922,8 @@ _dv_dct_248_block_mmx: + + .align 8 + .global _dv_dct_248_block_mmx_post_sum ++.hidden _dv_dct_248_block_mmx_post_sum ++.type _dv_dct_248_block_mmx_post_sum,@function + _dv_dct_248_block_mmx_post_sum: + + pushl %ebp +@@ -992,6 +1004,8 @@ _dv_dct_248_block_mmx_post_sum: + + .align 8 + .global _dv_dct_block_mmx_postscale_248 ++.hidden _dv_dct_block_mmx_postscale_248 ++.type _dv_dct_block_mmx_postscale_248,@function + _dv_dct_block_mmx_postscale_248: + + pushl %ebp +diff -Nurp libdv-0.104-old/libdv/dct_block_mmx_x86_64.S libdv-0.104/libdv/dct_block_mmx_x86_64.S +--- libdv-0.104-old/libdv/dct_block_mmx_x86_64.S 2006-01-01 22:44:22.000000000 +0100 ++++ libdv-0.104/libdv/dct_block_mmx_x86_64.S 2006-01-01 22:44:43.000000000 +0100 +@@ -57,6 +57,8 @@ scratch4: .quad 0 + + .align 8 + .global _dv_dct_88_block_mmx_x86_64 ++.hidden _dv_dct_88_block_mmx_x86_64 ++.type _dv_dct_88_block_mmx_x86_64,@function + _dv_dct_88_block_mmx_x86_64: + + /* void _dv_dct_88_block_mmx_x86_64(int16_t* block); */ +@@ -269,6 +271,8 @@ _dv_dct_88_block_mmx_x86_64: + + .align 8 + .global _dv_dct_block_mmx_x86_64_postscale_88 ++.hidden _dv_dct_block_mmx_x86_64_postscale_88 ++.type _dv_dct_block_mmx_x86_64_postscale_88,@function + _dv_dct_block_mmx_x86_64_postscale_88: + + /* void _dv_dct_block_mmx_x86_64_postscale_88(int16_t* block, int16_t* postscale_matrix); */ +diff -Nurp libdv-0.104-old/libdv/dv.c libdv-0.104/libdv/dv.c +--- libdv-0.104-old/libdv/dv.c 2004-10-20 05:49:24.000000000 +0200 ++++ libdv-0.104/libdv/dv.c 2006-01-01 22:44:43.000000000 +0100 +@@ -205,6 +205,9 @@ dv_reconfigure(int clamp_luma, int clamp + } /* dv_reconfigure */ + + ++extern uint8_t dv_quant_offset[4]; ++extern uint8_t dv_quant_shifts[22][4]; ++ + static inline void + dv_decode_macroblock(dv_decoder_t *dv, dv_macroblock_t *mb, unsigned int quality) { + int i; +@@ -218,7 +221,7 @@ dv_decode_macroblock(dv_decoder_t *dv, d + dv_idct_248 (co248, mb->b[i].coeffs); + } else { + #if ARCH_X86 +- _dv_quant_88_inverse_x86(mb->b[i].coeffs,mb->qno,mb->b[i].class_no); ++ _dv_quant_88_inverse_x86(mb->b[i].coeffs,mb->qno,mb->b[i].class_no,dv_quant_offset,dv_quant_shifts); + _dv_idct_88(mb->b[i].coeffs); + #elif ARCH_X86_64 + _dv_quant_88_inverse_x86_64(mb->b[i].coeffs,mb->qno,mb->b[i].class_no); +@@ -250,7 +253,7 @@ dv_decode_video_segment(dv_decoder_t *dv + dv_idct_248 (co248, mb->b[b].coeffs); + } else { + #if ARCH_X86 +- _dv_quant_88_inverse_x86(bl->coeffs,mb->qno,bl->class_no); ++ _dv_quant_88_inverse_x86(bl->coeffs,mb->qno,bl->class_no,dv_quant_offset,dv_quant_shifts); + _dv_weight_88_inverse(bl->coeffs); + _dv_idct_88(bl->coeffs); + #elif ARCH_X86_64 +diff -Nurp libdv-0.104-old/libdv/encode.c libdv-0.104/libdv/encode.c +--- libdv-0.104-old/libdv/encode.c 2004-11-17 04:36:30.000000000 +0100 ++++ libdv-0.104/libdv/encode.c 2006-01-01 22:44:43.000000000 +0100 +@@ -521,7 +521,8 @@ static void reorder_block(dv_block_t *bl + } + + extern unsigned long _dv_vlc_encode_block_mmx(dv_coeff_t* coeffs, +- dv_vlc_entry_t ** out); ++ dv_vlc_entry_t ** out, ++ dv_vlc_entry_t * lookup); + + extern unsigned long _dv_vlc_encode_block_mmx_x86_64(dv_coeff_t* coeffs, + dv_vlc_entry_t ** out); +@@ -558,7 +559,7 @@ static unsigned long vlc_encode_block(dv + #elif ARCH_X86 + int num_bits; + +- num_bits = _dv_vlc_encode_block_mmx(coeffs, &o); ++ num_bits = _dv_vlc_encode_block_mmx(coeffs, &o, vlc_encode_lookup); + emms(); + #else + int num_bits; +@@ -574,7 +575,7 @@ static unsigned long vlc_encode_block(dv + return num_bits; + } + +-extern unsigned long _dv_vlc_num_bits_block_x86(dv_coeff_t* coeffs); ++extern unsigned long _dv_vlc_num_bits_block_x86(dv_coeff_t* coeffs, unsigned char* lookup); + extern unsigned long _dv_vlc_num_bits_block_x86_64(dv_coeff_t* coeffs); + + extern unsigned long _dv_vlc_num_bits_block(dv_coeff_t* coeffs) +@@ -600,7 +601,7 @@ extern unsigned long _dv_vlc_num_bits_bl + #elif ARCH_X86_64 + return _dv_vlc_num_bits_block_x86_64(coeffs); + #else +- return _dv_vlc_num_bits_block_x86(coeffs); ++ return _dv_vlc_num_bits_block_x86(coeffs, vlc_num_bits_lookup); + #endif + } + +diff -Nurp libdv-0.104-old/libdv/encode_x86.S libdv-0.104/libdv/encode_x86.S +--- libdv-0.104-old/libdv/encode_x86.S 2006-01-01 22:44:22.000000000 +0100 ++++ libdv-0.104/libdv/encode_x86.S 2006-01-01 22:44:43.000000000 +0100 +@@ -23,13 +23,11 @@ + * The libdv homepage is http://libdv.sourceforge.net/. + */ + +-.data +-ALLONE: .word 1,1,1,1 +-VLCADDMASK: .byte 255,0,0,0,255,0,0,0 +- + .text + + .global _dv_vlc_encode_block_mmx ++.hidden _dv_vlc_encode_block_mmx ++.type _dv_vlc_encode_block_mmx,@function + _dv_vlc_encode_block_mmx: + pushl %ebx + pushl %esi +@@ -45,11 +43,14 @@ _dv_vlc_encode_block_mmx: + + movl $63, %ecx + +- movl vlc_encode_lookup, %esi ++ movl 4+4*4+8(%esp), %esi # vlc_encode_lookup + + pxor %mm0, %mm0 + pxor %mm2, %mm2 +- movq VLCADDMASK, %mm1 ++ pushl $0x000000FF # these four lines ++ pushl $0x000000FF # load VLCADDMASK ++ movq (%esp), %mm1 # into %mm1 off the stack ++ addl $8, %esp # --> no TEXTRELs + xorl %ebp, %ebp + subl $8, %edx + vlc_encode_block_mmx_loop: +@@ -106,6 +107,8 @@ vlc_encode_block_out: + ret + + .global _dv_vlc_num_bits_block_x86 ++.hidden _dv_vlc_num_bits_block_x86 ++.type _dv_vlc_num_bits_block_x86,@function + _dv_vlc_num_bits_block_x86: + pushl %ebx + pushl %esi +@@ -121,7 +124,7 @@ _dv_vlc_num_bits_block_x86: + addl $2, %edi + + movl $63, %ecx +- movl vlc_num_bits_lookup, %esi ++ movl 4+4*4+4(%esp), %esi # vlc_num_bits_lookup + + vlc_num_bits_block_x86_loop: + movw (%edi), %ax +@@ -164,6 +167,8 @@ vlc_num_bits_block_out: + ret + + .global _dv_vlc_encode_block_pass_1_x86 ++.hidden _dv_vlc_encode_block_pass_1_x86 ++.type _dv_vlc_encode_block_pass_1_x86,@function + _dv_vlc_encode_block_pass_1_x86: + pushl %ebx + pushl %esi +@@ -240,6 +245,8 @@ vlc_encode_block_pass1_x86_out: + ret + + .global _dv_classify_mmx ++.hidden _dv_classify_mmx ++.type _dv_classify_mmx,@function + _dv_classify_mmx: + + pushl %ebp +@@ -345,6 +352,8 @@ _dv_classify_mmx: + don't know why... */ + + .global _dv_reorder_block_mmx ++.hidden _dv_reorder_block_mmx ++.type _dv_reorder_block_mmx,@function + _dv_reorder_block_mmx: + + pushl %ebp +@@ -460,6 +469,8 @@ reorder_loop: + ret + + .global _dv_need_dct_248_mmx_rows ++.hidden _dv_need_dct_248_mmx_rows ++.type _dv_need_dct_248_mmx_rows,@function + _dv_need_dct_248_mmx_rows: + + pushl %ebp +@@ -579,8 +590,11 @@ _dv_need_dct_248_mmx_rows: + paddw %mm5, %mm1 + + paddw %mm1, %mm0 +- +- pmaddwd ALLONE, %mm0 ++ ++ pushl $0x00010001 # these four lines ++ pushl $0x00010001 # load ALLONE ++ pmaddwd (%esp), %mm0 # into %mm0 off the stack ++ addl $8, %esp # --> no TEXTRELs + movq %mm0, %mm1 + psrlq $32, %mm1 + paddd %mm1, %mm0 +diff -Nurp libdv-0.104-old/libdv/encode_x86_64.S libdv-0.104/libdv/encode_x86_64.S +--- libdv-0.104-old/libdv/encode_x86_64.S 2006-01-01 22:44:22.000000000 +0100 ++++ libdv-0.104/libdv/encode_x86_64.S 2006-01-01 22:44:43.000000000 +0100 +@@ -30,6 +30,8 @@ VLCADDMASK: .byte 255,0,0,0,255,0,0,0 + .text + + .global _dv_vlc_encode_block_mmx_x86_64 ++.hidden _dv_vlc_encode_block_mmx_x86_64 ++.type _dv_vlc_encode_block_mmx_x86_64,@function + _dv_vlc_encode_block_mmx_x86_64: + + /* extern unsigned long _dv_vlc_encode_block_mmx(dv_coeff_t* coeffs, +@@ -113,6 +115,8 @@ vlc_encode_block_out: + ret + + .global _dv_vlc_num_bits_block_x86_64 ++.hidden _dv_vlc_num_bits_block_x86_64 ++.type _dv_vlc_num_bits_block_x86_64,@function + _dv_vlc_num_bits_block_x86_64: + + /* extern unsigned long _dv_vlc_num_bits_block_x86_64(dv_coeff_t* coeffs); */ +@@ -173,6 +177,8 @@ vlc_num_bits_block_out: + ret + + .global _dv_vlc_encode_block_pass_1_x86_64 ++.hidden _dv_vlc_encode_block_pass_1_x86_64 ++.type _dv_vlc_encode_block_pass_1_x86_64,@function + _dv_vlc_encode_block_pass_1_x86_64: + + /* +@@ -251,6 +257,8 @@ vlc_encode_block_pass1_x86_out: + ret + + .global _dv_classify_mmx_x86_64 ++.hidden _dv_classify_mmx_x86_64 ++.type _dv_classify_mmx_x86_64,@function + _dv_classify_mmx_x86_64: + + /* extern int _dv_classify_mmx_x86_64(dv_coeff_t * a, rdi +@@ -355,6 +363,8 @@ _dv_classify_mmx_x86_64: + don't know why... */ + + .global _dv_reorder_block_mmx_x86_64 ++.hidden _dv_reorder_block_mmx_x86_64 ++.type _dv_reorder_block_mmx_x86_64,@function + _dv_reorder_block_mmx_x86_64: + + /*extern int _dv_reorder_block_mmx_x86_64(dv_coeff_t * a, rdi +@@ -469,6 +479,8 @@ reorder_loop: + ret + + .global _dv_need_dct_248_mmx_x86_64_rows ++.hidden _dv_need_dct_248_mmx_x86_64_rows ++.type _dv_need_dct_248_mmx_x86_64_rows,@function + _dv_need_dct_248_mmx_x86_64_rows: + + /* extern int _dv_need_dct_248_mmx_x86_64_rows(dv_coeff_t * bl); rdi */ +diff -Nurp libdv-0.104-old/libdv/idct_block_mmx.S libdv-0.104/libdv/idct_block_mmx.S +--- libdv-0.104-old/libdv/idct_block_mmx.S 2006-01-01 22:44:22.000000000 +0100 ++++ libdv-0.104/libdv/idct_block_mmx.S 2006-01-01 22:44:43.000000000 +0100 +@@ -8,16 +8,22 @@ + + + ++#include "asm_common.S" ++ + .text ++ + .align 4 + .globl _dv_idct_block_mmx ++.hidden _dv_idct_block_mmx + .type _dv_idct_block_mmx,@function + _dv_idct_block_mmx: + pushl %ebp +- movl %esp,%ebp + pushl %esi +- leal preSC, %ecx +- movl 8(%ebp),%esi /* source matrix */ ++ ++ LOAD_PIC_REG_BP() ++ ++ leal MUNG(preSC), %ecx ++ movl 12(%esp),%esi /* source matrix */ + + /* + * column 0: even part +@@ -35,7 +41,7 @@ _dv_idct_block_mmx: + movq %mm1, %mm2 /* added 11/1/96 */ + pmulhw 8*8(%esi),%mm5 /* V8 */ + psubsw %mm0, %mm1 /* V16 */ +- pmulhw x5a825a825a825a82, %mm1 /* 23170 ->V18 */ ++ pmulhw MUNG(x5a825a825a825a82), %mm1 /* 23170 ->V18 */ + paddsw %mm0, %mm2 /* V17 */ + movq %mm2, %mm0 /* duplicate V17 */ + psraw $1, %mm2 /* t75=t82 */ +@@ -76,7 +82,7 @@ _dv_idct_block_mmx: + paddsw %mm0, %mm3 /* V29 ; free mm0 */ + movq %mm7, %mm1 /* duplicate V26 */ + psraw $1, %mm3 /* t91=t94 */ +- pmulhw x539f539f539f539f,%mm7 /* V33 */ ++ pmulhw MUNG(x539f539f539f539f),%mm7 /* V33 */ + psraw $1, %mm1 /* t96 */ + movq %mm5, %mm0 /* duplicate V2 */ + psraw $2, %mm4 /* t85=t87 */ +@@ -84,15 +90,15 @@ _dv_idct_block_mmx: + psubsw %mm4, %mm0 /* V28 ; free mm4 */ + movq %mm0, %mm2 /* duplicate V28 */ + psraw $1, %mm5 /* t90=t93 */ +- pmulhw x4546454645464546,%mm0 /* V35 */ ++ pmulhw MUNG(x4546454645464546),%mm0 /* V35 */ + psraw $1, %mm2 /* t97 */ + movq %mm5, %mm4 /* duplicate t90=t93 */ + psubsw %mm2, %mm1 /* V32 ; free mm2 */ +- pmulhw x61f861f861f861f8,%mm1 /* V36 */ ++ pmulhw MUNG(x61f861f861f861f8),%mm1 /* V36 */ + psllw $1, %mm7 /* t107 */ + paddsw %mm3, %mm5 /* V31 */ + psubsw %mm3, %mm4 /* V30 ; free mm3 */ +- pmulhw x5a825a825a825a82,%mm4 /* V34 */ ++ pmulhw MUNG(x5a825a825a825a82),%mm4 /* V34 */ + nop + psubsw %mm1, %mm0 /* V38 */ + psubsw %mm7, %mm1 /* V37 ; free mm7 */ +@@ -159,7 +165,7 @@ _dv_idct_block_mmx: + psubsw %mm7, %mm1 /* V50 */ + pmulhw 8*9(%esi), %mm5 /* V9 */ + paddsw %mm7, %mm2 /* V51 */ +- pmulhw x5a825a825a825a82, %mm1 /* 23170 ->V52 */ ++ pmulhw MUNG(x5a825a825a825a82), %mm1 /* 23170 ->V52 */ + movq %mm2, %mm6 /* duplicate V51 */ + psraw $1, %mm2 /* t138=t144 */ + movq %mm3, %mm4 /* duplicate V1 */ +@@ -200,11 +206,11 @@ _dv_idct_block_mmx: + * even more by doing the correction step in a later stage when the number + * is actually multiplied by 16 + */ +- paddw x0005000200010001, %mm4 ++ paddw MUNG(x0005000200010001), %mm4 + psubsw %mm6, %mm3 /* V60 ; free mm6 */ + psraw $1, %mm0 /* t154=t156 */ + movq %mm3, %mm1 /* duplicate V60 */ +- pmulhw x539f539f539f539f, %mm1 /* V67 */ ++ pmulhw MUNG(x539f539f539f539f), %mm1 /* V67 */ + movq %mm5, %mm6 /* duplicate V3 */ + psraw $2, %mm4 /* t148=t150 */ + paddsw %mm4, %mm5 /* V61 */ +@@ -213,13 +219,13 @@ _dv_idct_block_mmx: + psllw $1, %mm1 /* t169 */ + paddsw %mm0, %mm5 /* V65 -> result */ + psubsw %mm0, %mm4 /* V64 ; free mm0 */ +- pmulhw x5a825a825a825a82, %mm4 /* V68 */ ++ pmulhw MUNG(x5a825a825a825a82), %mm4 /* V68 */ + psraw $1, %mm3 /* t158 */ + psubsw %mm6, %mm3 /* V66 */ + movq %mm5, %mm2 /* duplicate V65 */ +- pmulhw x61f861f861f861f8, %mm3 /* V70 */ ++ pmulhw MUNG(x61f861f861f861f8), %mm3 /* V70 */ + psllw $1, %mm6 /* t165 */ +- pmulhw x4546454645464546, %mm6 /* V69 */ ++ pmulhw MUNG(x4546454645464546), %mm6 /* V69 */ + psraw $1, %mm2 /* t172 */ + /* moved from next block */ + movq 8*5(%esi), %mm0 /* V56 */ +@@ -344,7 +350,7 @@ _dv_idct_block_mmx: + * movq 8*13(%esi), %mm4 tmt13 + */ + psubsw %mm4, %mm3 /* V134 */ +- pmulhw x5a825a825a825a82, %mm3 /* 23170 ->V136 */ ++ pmulhw MUNG(x5a825a825a825a82), %mm3 /* 23170 ->V136 */ + movq 8*9(%esi), %mm6 /* tmt9 */ + paddsw %mm4, %mm5 /* V135 ; mm4 free */ + movq %mm0, %mm4 /* duplicate tmt1 */ +@@ -373,17 +379,17 @@ _dv_idct_block_mmx: + psubsw %mm7, %mm0 /* V144 */ + movq %mm0, %mm3 /* duplicate V144 */ + paddsw %mm7, %mm2 /* V147 ; free mm7 */ +- pmulhw x539f539f539f539f, %mm0 /* 21407-> V151 */ ++ pmulhw MUNG(x539f539f539f539f), %mm0 /* 21407-> V151 */ + movq %mm1, %mm7 /* duplicate tmt3 */ + paddsw %mm5, %mm7 /* V145 */ + psubsw %mm5, %mm1 /* V146 ; free mm5 */ + psubsw %mm1, %mm3 /* V150 */ + movq %mm7, %mm5 /* duplicate V145 */ +- pmulhw x4546454645464546, %mm1 /* 17734-> V153 */ ++ pmulhw MUNG(x4546454645464546), %mm1 /* 17734-> V153 */ + psubsw %mm2, %mm5 /* V148 */ +- pmulhw x61f861f861f861f8, %mm3 /* 25080-> V154 */ ++ pmulhw MUNG(x61f861f861f861f8), %mm3 /* 25080-> V154 */ + psllw $2, %mm0 /* t311 */ +- pmulhw x5a825a825a825a82, %mm5 /* 23170-> V152 */ ++ pmulhw MUNG(x5a825a825a825a82), %mm5 /* 23170-> V152 */ + paddsw %mm2, %mm7 /* V149 ; free mm2 */ + psllw $1, %mm1 /* t313 */ + nop /* without the nop - freeze here for one clock */ +@@ -409,7 +415,7 @@ _dv_idct_block_mmx: + paddsw %mm3, %mm6 /* V164 ; free mm3 */ + movq %mm4, %mm3 /* duplicate V142 */ + psubsw %mm5, %mm4 /* V165 ; free mm5 */ +- movq %mm2, scratch7 /* out7 */ ++ movq %mm2, MUNG(scratch7) /* out7 */ + psraw $4, %mm6 + psraw $4, %mm4 + paddsw %mm5, %mm3 /* V162 */ +@@ -420,11 +426,11 @@ _dv_idct_block_mmx: + */ + movq %mm6, 8*9(%esi) /* out9 */ + paddsw %mm1, %mm0 /* V161 */ +- movq %mm3, scratch5 /* out5 */ ++ movq %mm3, MUNG(scratch5) /* out5 */ + psubsw %mm1, %mm5 /* V166 ; free mm1 */ + movq %mm4, 8*11(%esi) /* out11 */ + psraw $4, %mm5 +- movq %mm0, scratch3 /* out3 */ ++ movq %mm0, MUNG(scratch3) /* out3 */ + movq %mm2, %mm4 /* duplicate V140 */ + movq %mm5, 8*13(%esi) /* out13 */ + paddsw %mm7, %mm2 /* V160 */ +@@ -434,7 +440,7 @@ _dv_idct_block_mmx: + /* moved from the next block */ + movq 8*3(%esi), %mm7 + psraw $4, %mm4 +- movq %mm2, scratch1 /* out1 */ ++ movq %mm2, MUNG(scratch1) /* out1 */ + /* moved from the next block */ + movq %mm0, %mm1 + movq %mm4, 8*15(%esi) /* out15 */ +@@ -491,15 +497,15 @@ _dv_idct_block_mmx: + paddsw %mm4, %mm3 /* V113 ; free mm4 */ + movq %mm0, %mm4 /* duplicate V110 */ + paddsw %mm1, %mm2 /* V111 */ +- pmulhw x539f539f539f539f, %mm0 /* 21407-> V117 */ ++ pmulhw MUNG(x539f539f539f539f), %mm0 /* 21407-> V117 */ + psubsw %mm1, %mm5 /* V112 ; free mm1 */ + psubsw %mm5, %mm4 /* V116 */ + movq %mm2, %mm1 /* duplicate V111 */ +- pmulhw x4546454645464546, %mm5 /* 17734-> V119 */ ++ pmulhw MUNG(x4546454645464546), %mm5 /* 17734-> V119 */ + psubsw %mm3, %mm2 /* V114 */ +- pmulhw x61f861f861f861f8, %mm4 /* 25080-> V120 */ ++ pmulhw MUNG(x61f861f861f861f8), %mm4 /* 25080-> V120 */ + paddsw %mm3, %mm1 /* V115 ; free mm3 */ +- pmulhw x5a825a825a825a82, %mm2 /* 23170-> V118 */ ++ pmulhw MUNG(x5a825a825a825a82), %mm2 /* 23170-> V118 */ + psllw $2, %mm0 /* t266 */ + movq %mm1, (%esi) /* save V115 */ + psllw $1, %mm5 /* t268 */ +@@ -517,7 +523,7 @@ _dv_idct_block_mmx: + movq %mm6, %mm3 /* duplicate tmt4 */ + psubsw %mm0, %mm6 /* V100 */ + paddsw %mm0, %mm3 /* V101 ; free mm0 */ +- pmulhw x5a825a825a825a82, %mm6 /* 23170 ->V102 */ ++ pmulhw MUNG(x5a825a825a825a82), %mm6 /* 23170 ->V102 */ + movq %mm7, %mm5 /* duplicate tmt0 */ + movq 8*8(%esi), %mm1 /* tmt8 */ + paddsw %mm1, %mm7 /* V103 */ +@@ -551,10 +557,10 @@ _dv_idct_block_mmx: + movq 8*2(%esi), %mm3 /* V123 */ + paddsw %mm4, %mm7 /* out0 */ + /* moved up from next block */ +- movq scratch3, %mm0 ++ movq MUNG(scratch3), %mm0 + psraw $4, %mm7 + /* moved up from next block */ +- movq scratch5, %mm6 ++ movq MUNG(scratch5), %mm6 + psubsw %mm4, %mm1 /* out14 ; free mm4 */ + paddsw %mm3, %mm5 /* out2 */ + psraw $4, %mm1 +@@ -565,7 +571,7 @@ _dv_idct_block_mmx: + movq %mm5, 8*2(%esi) /* out2 ; free mm5 */ + psraw $4, %mm2 + /* moved up to the prev block */ +- movq scratch7, %mm4 ++ movq MUNG(scratch7), %mm4 + /* moved up to the prev block */ + psraw $4, %mm0 + movq %mm2, 8*12(%esi) /* out12 ; free mm2 */ +@@ -579,7 +585,7 @@ _dv_idct_block_mmx: + * psraw $4, %mm0 + * psraw $4, %mm6 + */ +- movq scratch1, %mm1 ++ movq MUNG(scratch1), %mm1 + psraw $4, %mm4 + movq %mm0, 8*3(%esi) /* out3 */ + psraw $4, %mm1 +diff -Nurp libdv-0.104-old/libdv/idct_block_mmx_x86_64.S libdv-0.104/libdv/idct_block_mmx_x86_64.S +--- libdv-0.104-old/libdv/idct_block_mmx_x86_64.S 2006-01-01 22:44:22.000000000 +0100 ++++ libdv-0.104/libdv/idct_block_mmx_x86_64.S 2006-01-01 22:44:43.000000000 +0100 +@@ -17,6 +17,7 @@ + .text + .align 4 + .globl _dv_idct_block_mmx_x86_64 ++.hidden _dv_idct_block_mmx_x86_64 + .type _dv_idct_block_mmx_x86_64,@function + _dv_idct_block_mmx_x86_64: + /* void _dv_idct_88(dv_coeff_t *block) */ +diff -Nurp libdv-0.104-old/libdv/parse.c libdv-0.104/libdv/parse.c +--- libdv-0.104-old/libdv/parse.c 2004-10-20 05:49:24.000000000 +0200 ++++ libdv-0.104/libdv/parse.c 2006-01-01 22:44:43.000000000 +0100 +@@ -477,6 +477,13 @@ dv_parse_ac_coeffs(dv_videosegment_t *se + exit(0); + #endif + } /* dv_parse_ac_coeffs */ ++#if defined __GNUC__ && __ELF__ ++# define dv_strong_hidden_alias(name, aliasname) \ ++ extern __typeof (name) aliasname __attribute__ ((alias (#name), visibility ("hidden"))) ++dv_strong_hidden_alias(dv_parse_ac_coeffs, asm_dv_parse_ac_coeffs); ++#else ++int asm_dv_parse_ac_coeffs(dv_videosegment_t *seg) { return dv_parse_ac_coeffs(seg); } ++#endif + + /* --------------------------------------------------------------------------- + */ +diff -Nurp libdv-0.104-old/libdv/quant.c libdv-0.104/libdv/quant.c +--- libdv-0.104-old/libdv/quant.c 2004-10-20 05:49:24.000000000 +0200 ++++ libdv-0.104/libdv/quant.c 2006-01-01 22:44:43.000000000 +0100 +@@ -144,7 +144,7 @@ uint8_t dv_quant_offset[4] = { 6,3,0,1 + uint32_t dv_quant_248_mul_tab [2] [22] [64]; + uint32_t dv_quant_88_mul_tab [2] [22] [64]; + +-extern void _dv_quant_x86(dv_coeff_t *block,int qno,int klass); ++extern void _dv_quant_x86(dv_coeff_t *block,int qno,int klass,uint8_t dv_quant_offset[],uint8_t dv_quant_shifts[][]); + extern void _dv_quant_x86_64(dv_coeff_t *block,int qno,int klass); + static void quant_248_inverse_std(dv_coeff_t *block,int qno,int klass,dv_248_coeff_t *co); + static void quant_248_inverse_mmx(dv_coeff_t *block,int qno,int klass,dv_248_coeff_t *co); +@@ -210,7 +210,7 @@ void _dv_quant(dv_coeff_t *block,int qno + _dv_quant_x86_64(block, qno, klass); + emms(); + #else +- _dv_quant_x86(block, qno, klass); ++ _dv_quant_x86(block, qno, klass, dv_quant_offset, dv_quant_shifts); + emms(); + #endif + } +diff -Nurp libdv-0.104-old/libdv/quant.h libdv-0.104/libdv/quant.h +--- libdv-0.104-old/libdv/quant.h 2004-10-20 05:49:24.000000000 +0200 ++++ libdv-0.104/libdv/quant.h 2006-01-01 22:44:43.000000000 +0100 +@@ -27,7 +27,7 @@ extern void _dv_quant(dv_coeff_t *block, + extern void _dv_quant_88_inverse(dv_coeff_t *block,int qno,int klass); + extern void (*_dv_quant_248_inverse) (dv_coeff_t *block,int qno,int klass, + dv_248_coeff_t *co); +-extern void _dv_quant_88_inverse_x86(dv_coeff_t *block,int qno,int klass); ++extern void _dv_quant_88_inverse_x86(dv_coeff_t *block,int qno,int klass, uint8_t offset[], uint8_t shifts[][]); + extern void _dv_quant_88_inverse_x86_64(dv_coeff_t *block,int qno,int klass); + extern void dv_quant_init (void); + #ifdef __cplusplus +diff -Nurp libdv-0.104-old/libdv/quant_x86.S libdv-0.104/libdv/quant_x86.S +--- libdv-0.104-old/libdv/quant_x86.S 2006-01-01 22:44:22.000000000 +0100 ++++ libdv-0.104/libdv/quant_x86.S 2006-01-01 22:44:43.000000000 +0100 +@@ -55,6 +55,8 @@ void _dv_quant_88_inverse(dv_coeff_t *bl + .text + .align 4 + .globl _dv_quant_88_inverse_x86 ++.hidden _dv_quant_88_inverse_x86 ++.type _dv_quant_88_inverse_x86,@function + _dv_quant_88_inverse_x86: + pushl %ebx + pushl %esi +@@ -71,10 +73,13 @@ _dv_quant_88_inverse_x86: + + /* pq = dv_quant_shifts[qno + dv_quant_offset[class]]; */ + movl ARGn(1),%eax /* qno */ ++ movl ARGn(3),%ebx /* dv_quant_offset */ ++ addl ARGn(2),%ebx /* class */ ++ movzbl (%ebx),%ecx + movl ARGn(2),%ebx /* class */ +- movzbl dv_quant_offset(%ebx),%ecx + addl %ecx,%eax +- leal dv_quant_shifts(,%eax,4),%edx /* edx is pq */ ++ movl ARGn(4),%edx /* dv_quant_shifts */ ++ leal (%edx,%eax,4),%edx /* edx is pq */ + + /* extra = (class == 3); */ + /* 0 1 2 3 */ +@@ -193,6 +198,8 @@ _dv_quant_88_inverse_x86: + + .align 4 + .globl _dv_quant_x86 ++.hidden _dv_quant_x86 ++.type _dv_quant_x86,@function + _dv_quant_x86: + pushl %ebx + pushl %ecx +@@ -212,11 +219,13 @@ _dv_quant_x86: + + /* pq = dv_quant_shifts[qno + dv_quant_offset[class]]; */ + movl ARGn(1),%eax /* qno */ ++ movl ARGn(3),%ebx /* offset */ ++ addl ARGn(2),%ebx /* class */ ++ movzbl (%ebx),%ecx + movl ARGn(2),%ebx /* class */ +- +- movzbl dv_quant_offset(%ebx),%ecx ++ movl ARGn(4),%edx /* shifts */ + addl %ecx,%eax +- leal dv_quant_shifts(,%eax,4),%edx /* edx is pq */ ++ leal (%edx,%eax,4),%edx /* edx is pq */ + + /* extra = (class == 3); */ + /* 0 1 2 3 */ +diff -Nurp libdv-0.104-old/libdv/quant_x86_64.S libdv-0.104/libdv/quant_x86_64.S +--- libdv-0.104-old/libdv/quant_x86_64.S 2006-01-01 22:44:22.000000000 +0100 ++++ libdv-0.104/libdv/quant_x86_64.S 2006-01-01 22:44:43.000000000 +0100 +@@ -55,6 +55,8 @@ void _dv_quant_88_inverse(dv_coeff_t *bl + .text + .align 4 + .globl _dv_quant_88_inverse_x86_64 ++.hidden _dv_quant_88_inverse_x86_64 ++.type _dv_quant_88_inverse_x86_64,@function + _dv_quant_88_inverse_x86_64: + + /* Args are at block=rdi, qno=rsi, class=rdx */ +@@ -195,6 +197,8 @@ _dv_quant_88_inverse_x86_64: + + .align 4 + .globl _dv_quant_x86_64 ++.hidden _dv_quant_x86_64 ++.type _dv_quant_x86_64,@function + _dv_quant_x86_64: + + /* Args are at block=rdi, qno=rsi, class=rdx */ +diff -Nurp libdv-0.104-old/libdv/rgbtoyuv.S libdv-0.104/libdv/rgbtoyuv.S +--- libdv-0.104-old/libdv/rgbtoyuv.S 2006-01-01 22:44:22.000000000 +0100 ++++ libdv-0.104/libdv/rgbtoyuv.S 2006-01-01 22:44:43.000000000 +0100 +@@ -41,9 +41,6 @@ + #define DV_WIDTH_SHORT_HALF 720 + #define DV_WIDTH_BYTE_HALF 360 + +-.global _dv_rgbtoycb_mmx +-# .global yuvtoycb_mmx +- + .data + + .align 8 +@@ -110,20 +107,24 @@ VR0GR: .long 0,0 + VBG0B: .long 0,0 + + #endif +- ++ ++#include "asm_common.S" ++ + .text + +-#define _inPtr 8 +-#define _rows 12 +-#define _columns 16 +-#define _outyPtr 20 +-#define _outuPtr 24 +-#define _outvPtr 28 ++#define _inPtr 24+8 ++#define _rows 24+12 ++#define _columns 24+16 ++#define _outyPtr 24+20 ++#define _outuPtr 24+24 ++#define _outvPtr 24+28 + ++.global _dv_rgbtoycb_mmx ++.hidden _dv_rgbtoycb_mmx ++.type _dv_rgbtoycb_mmx,@function + _dv_rgbtoycb_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %eax + pushl %ebx + pushl %ecx +@@ -131,46 +132,47 @@ _dv_rgbtoycb_mmx: + pushl %esi + pushl %edi + +- leal ZEROSX, %eax #This section gets around a bug ++ LOAD_PIC_REG_BP() ++ ++ leal MUNG(ZEROSX), %eax #This section gets around a bug + movq (%eax), %mm0 #unlikely to persist +- movq %mm0, ZEROS +- leal OFFSETDX, %eax ++ movq %mm0, MUNG(ZEROS) ++ leal MUNG(OFFSETDX), %eax + movq (%eax), %mm0 +- movq %mm0, OFFSETD +- leal OFFSETWX, %eax ++ movq %mm0, MUNG(OFFSETD) ++ leal MUNG(OFFSETWX), %eax + movq (%eax), %mm0 +- movq %mm0, OFFSETW +- leal OFFSETBX, %eax ++ movq %mm0, MUNG(OFFSETW) ++ leal MUNG(OFFSETBX), %eax + movq (%eax), %mm0 +- movq %mm0, OFFSETB +- leal YR0GRX, %eax ++ movq %mm0, MUNG(OFFSETB) ++ leal MUNG(YR0GRX), %eax + movq (%eax), %mm0 +- movq %mm0, YR0GR +- leal YBG0BX, %eax ++ movq %mm0, MUNG(YR0GR) ++ leal MUNG(YBG0BX), %eax + movq (%eax), %mm0 +- movq %mm0, YBG0B +- leal UR0GRX, %eax ++ movq %mm0, MUNG(YBG0B) ++ leal MUNG(UR0GRX), %eax + movq (%eax), %mm0 +- movq %mm0, UR0GR +- leal UBG0BX, %eax ++ movq %mm0, MUNG(UR0GR) ++ leal MUNG(UBG0BX), %eax + movq (%eax), %mm0 +- movq %mm0, UBG0B +- leal VR0GRX, %eax ++ movq %mm0, MUNG(UBG0B) ++ leal MUNG(VR0GRX), %eax + movq (%eax), %mm0 +- movq %mm0, VR0GR +- leal VBG0BX, %eax ++ movq %mm0, MUNG(VR0GR) ++ leal MUNG(VBG0BX), %eax + movq (%eax), %mm0 +- movq %mm0, VBG0B +- +- movl _rows(%ebp), %eax +- movl _columns(%ebp), %ebx ++ movq %mm0, MUNG(VBG0B) ++ movl _rows(%esp), %eax ++ movl _columns(%esp), %ebx + mull %ebx #number pixels + shrl $3, %eax #number of loops + movl %eax, %edi #loop counter in edi +- movl _inPtr(%ebp), %eax +- movl _outyPtr(%ebp), %ebx +- movl _outuPtr(%ebp), %ecx +- movl _outvPtr(%ebp), %edx ++ movl _inPtr(%esp), %eax ++ movl _outyPtr(%esp), %ebx ++ movl _outuPtr(%esp), %ecx ++ movl _outvPtr(%esp), %edx + rgbtoycb_mmx_loop: + movq (%eax), %mm1 #load G2R2B1G1R1B0G0R0 + pxor %mm6, %mm6 #0 -> mm6 +@@ -184,29 +186,29 @@ rgbtoycb_mmx_loop: + punpcklbw %mm6, %mm1 #B1G1R1B0 -> mm1 + movq %mm0, %mm2 #R1B0G0R0 -> mm2 + +- pmaddwd YR0GR, %mm0 #yrR1,ygG0+yrR0 -> mm0 ++ pmaddwd MUNG(YR0GR), %mm0 #yrR1,ygG0+yrR0 -> mm0 + movq %mm1, %mm3 #B1G1R1B0 -> mm3 + +- pmaddwd YBG0B, %mm1 #ybB1+ygG1,ybB0 -> mm1 ++ pmaddwd MUNG(YBG0B), %mm1 #ybB1+ygG1,ybB0 -> mm1 + movq %mm2, %mm4 #R1B0G0R0 -> mm4 + +- pmaddwd UR0GR, %mm2 #urR1,ugG0+urR0 -> mm2 ++ pmaddwd MUNG(UR0GR), %mm2 #urR1,ugG0+urR0 -> mm2 + movq %mm3, %mm5 #B1G1R1B0 -> mm5 + +- pmaddwd UBG0B, %mm3 #ubB1+ugG1,ubB0 -> mm3 ++ pmaddwd MUNG(UBG0B), %mm3 #ubB1+ugG1,ubB0 -> mm3 + punpckhbw %mm6, %mm7 # 00G2R2 -> mm7 + +- pmaddwd VR0GR, %mm4 #vrR1,vgG0+vrR0 -> mm4 ++ pmaddwd MUNG(VR0GR), %mm4 #vrR1,vgG0+vrR0 -> mm4 + paddd %mm1, %mm0 #Y1Y0 -> mm0 + +- pmaddwd VBG0B, %mm5 #vbB1+vgG1,vbB0 -> mm5 ++ pmaddwd MUNG(VBG0B), %mm5 #vbB1+vgG1,vbB0 -> mm5 + + movq 8(%eax), %mm1 #R5B4G4R4B3G3R3B2 -> mm1 + paddd %mm3, %mm2 #U1U0 -> mm2 + + movq %mm1, %mm6 #R5B4G4R4B3G3R3B2 -> mm6 + +- punpcklbw ZEROS, %mm1 #B3G3R3B2 -> mm1 ++ punpcklbw MUNG(ZEROS), %mm1 #B3G3R3B2 -> mm1 + paddd %mm5, %mm4 #V1V0 -> mm4 + + movq %mm1, %mm5 #B3G3R3B2 -> mm5 +@@ -214,29 +216,29 @@ rgbtoycb_mmx_loop: + + paddd %mm7, %mm1 #R3B200+00G2R2=R3B2G2R2->mm1 + +- punpckhbw ZEROS, %mm6 #R5B4G4R3 -> mm6 ++ punpckhbw MUNG(ZEROS), %mm6 #R5B4G4R3 -> mm6 + movq %mm1, %mm3 #R3B2G2R2 -> mm3 + +- pmaddwd YR0GR, %mm1 #yrR3,ygG2+yrR2 -> mm1 ++ pmaddwd MUNG(YR0GR), %mm1 #yrR3,ygG2+yrR2 -> mm1 + movq %mm5, %mm7 #B3G3R3B2 -> mm7 + +- pmaddwd YBG0B, %mm5 #ybB3+ygG3,ybB2 -> mm5 ++ pmaddwd MUNG(YBG0B), %mm5 #ybB3+ygG3,ybB2 -> mm5 + psrad $FIXPSHIFT, %mm0 #32-bit scaled Y1Y0 -> mm0 + +- movq %mm6, TEMP0 #R5B4G4R4 -> TEMP0 ++ movq %mm6, MUNG(TEMP0) #R5B4G4R4 -> TEMP0 + movq %mm3, %mm6 #R3B2G2R2 -> mm6 +- pmaddwd UR0GR, %mm6 #urR3,ugG2+urR2 -> mm6 ++ pmaddwd MUNG(UR0GR), %mm6 #urR3,ugG2+urR2 -> mm6 + psrad $FIXPSHIFT, %mm2 #32-bit scaled U1U0 -> mm2 + + paddd %mm5, %mm1 #Y3Y2 -> mm1 + movq %mm7, %mm5 #B3G3R3B2 -> mm5 +- pmaddwd UBG0B, %mm7 #ubB3+ugG3,ubB2 ++ pmaddwd MUNG(UBG0B), %mm7 #ubB3+ugG3,ubB2 + psrad $FIXPSHIFT, %mm1 #32-bit scaled Y3Y2 -> mm1 + +- pmaddwd VR0GR, %mm3 #vrR3,vgG2+vgR2 ++ pmaddwd MUNG(VR0GR), %mm3 #vrR3,vgG2+vgR2 + packssdw %mm1, %mm0 #Y3Y2Y1Y0 -> mm0 + +- pmaddwd VBG0B, %mm5 #vbB3+vgG3,vbB2 -> mm5 ++ pmaddwd MUNG(VBG0B), %mm5 #vbB3+vgG3,vbB2 -> mm5 + psrad $FIXPSHIFT, %mm4 #32-bit scaled V1V0 -> mm4 + + movq 16(%eax), %mm1 #B7G7R7B6G6R6B5G5 -> mm7 +@@ -251,58 +253,58 @@ rgbtoycb_mmx_loop: + movq %mm7, %mm5 #R7B6G6R6B5G500 -> mm5 + psrad $FIXPSHIFT, %mm3 #32-bit scaled V3V2 -> mm3 + +- paddw OFFSETY, %mm0 ++ paddw MUNG(OFFSETY), %mm0 + movq %mm0, (%ebx) #store Y3Y2Y1Y0 + packssdw %mm6, %mm2 #32-bit scaled U3U2U1U0 -> mm2 + +- movq TEMP0, %mm0 #R5B4G4R4 -> mm0 ++ movq MUNG(TEMP0), %mm0 #R5B4G4R4 -> mm0 + addl $8, %ebx +- +- punpcklbw ZEROS, %mm7 #B5G500 -> mm7 ++ ++ punpcklbw MUNG(ZEROS), %mm7 #B5G500 -> mm7 + movq %mm0, %mm6 #R5B4G4R4 -> mm6 + +- movq %mm2, TEMPU #32-bit scaled U3U2U1U0 -> TEMPU ++ movq %mm2, MUNG(TEMPU) #32-bit scaled U3U2U1U0 -> TEMPU + psrlq $32, %mm0 #00R5B4 -> mm0 + + paddw %mm0, %mm7 #B5G5R5B4 -> mm7 + movq %mm6, %mm2 #B5B4G4R4 -> mm2 + +- pmaddwd YR0GR, %mm2 #yrR5,ygG4+yrR4 -> mm2 ++ pmaddwd MUNG(YR0GR), %mm2 #yrR5,ygG4+yrR4 -> mm2 + movq %mm7, %mm0 #B5G5R5B4 -> mm0 + +- pmaddwd YBG0B, %mm7 #ybB5+ygG5,ybB4 -> mm7 ++ pmaddwd MUNG(YBG0B), %mm7 #ybB5+ygG5,ybB4 -> mm7 + packssdw %mm3, %mm4 #32-bit scaled V3V2V1V0 -> mm4 + + addl $24, %eax #increment RGB count + +- movq %mm4, TEMPV #(V3V2V1V0)/256 -> mm4 ++ movq %mm4, MUNG(TEMPV) #(V3V2V1V0)/256 -> mm4 + movq %mm6, %mm4 #B5B4G4R4 -> mm4 + +- pmaddwd UR0GR, %mm6 #urR5,ugG4+urR4 ++ pmaddwd MUNG(UR0GR), %mm6 #urR5,ugG4+urR4 + movq %mm0, %mm3 #B5G5R5B4 -> mm0 + +- pmaddwd UBG0B, %mm0 #ubB5+ugG5,ubB4 ++ pmaddwd MUNG(UBG0B), %mm0 #ubB5+ugG5,ubB4 + paddd %mm7, %mm2 #Y5Y4 -> mm2 + +- pmaddwd VR0GR, %mm4 #vrR5,vgG4+vrR4 -> mm4 ++ pmaddwd MUNG(VR0GR), %mm4 #vrR5,vgG4+vrR4 -> mm4 + pxor %mm7, %mm7 #0 -> mm7 + +- pmaddwd VBG0B, %mm3 #vbB5+vgG5,vbB4 -> mm3 ++ pmaddwd MUNG(VBG0B), %mm3 #vbB5+vgG5,vbB4 -> mm3 + punpckhbw %mm7, %mm1 #B7G7R7B6 -> mm1 + + paddd %mm6, %mm0 #U5U4 -> mm0 + movq %mm1, %mm6 #B7G7R7B6 -> mm6 + +- pmaddwd YBG0B, %mm6 #ybB7+ygG7,ybB6 -> mm6 ++ pmaddwd MUNG(YBG0B), %mm6 #ybB7+ygG7,ybB6 -> mm6 + punpckhbw %mm7, %mm5 #R7B6G6R6 -> mm5 + + movq %mm5, %mm7 #R7B6G6R6 -> mm7 + paddd %mm4, %mm3 #V5V4 -> mm3 + +- pmaddwd YR0GR, %mm5 #yrR7,ygG6+yrR6 -> mm5 ++ pmaddwd MUNG(YR0GR), %mm5 #yrR7,ygG6+yrR6 -> mm5 + movq %mm1, %mm4 #B7G7R7B6 -> mm4 + +- pmaddwd UBG0B, %mm4 #ubB7+ugG7,ubB6 -> mm4 ++ pmaddwd MUNG(UBG0B), %mm4 #ubB7+ugG7,ubB6 -> mm4 + psrad $FIXPSHIFT, %mm0 #32-bit scaled U5U4 -> mm0 + + psrad $FIXPSHIFT, %mm2 #32-bit scaled Y5Y4 -> mm2 +@@ -310,25 +312,25 @@ rgbtoycb_mmx_loop: + paddd %mm5, %mm6 #Y7Y6 -> mm6 + movq %mm7, %mm5 #R7B6G6R6 -> mm5 + +- pmaddwd UR0GR, %mm7 #urR7,ugG6+ugR6 -> mm7 ++ pmaddwd MUNG(UR0GR), %mm7 #urR7,ugG6+ugR6 -> mm7 + psrad $FIXPSHIFT, %mm3 #32-bit scaled V5V4 -> mm3 + +- pmaddwd VBG0B, %mm1 #vbB7+vgG7,vbB6 -> mm1 ++ pmaddwd MUNG(VBG0B), %mm1 #vbB7+vgG7,vbB6 -> mm1 + psrad $FIXPSHIFT, %mm6 #32-bit scaled Y7Y6 -> mm6 + + packssdw %mm6, %mm2 #Y7Y6Y5Y4 -> mm2 + +- pmaddwd VR0GR, %mm5 #vrR7,vgG6+vrR6 -> mm5 ++ pmaddwd MUNG(VR0GR), %mm5 #vrR7,vgG6+vrR6 -> mm5 + paddd %mm4, %mm7 #U7U6 -> mm7 + + psrad $FIXPSHIFT, %mm7 #32-bit scaled U7U6 -> mm7 +- paddw OFFSETY, %mm2 ++ paddw MUNG(OFFSETY), %mm2 + movq %mm2, (%ebx) #store Y7Y6Y5Y4 + +- movq ALLONE, %mm6 ++ movq MUNG(ALLONE), %mm6 + packssdw %mm7, %mm0 #32-bit scaled U7U6U5U4 -> mm0 + +- movq TEMPU, %mm4 #32-bit scaled U3U2U1U0 -> mm4 ++ movq MUNG(TEMPU), %mm4 #32-bit scaled U3U2U1U0 -> mm4 + pmaddwd %mm6, %mm0 #U7U6U5U4 averaged -> (U7U6)(U5U4)=UU3 UU2->mm0 + + pmaddwd %mm6, %mm4 #U3U2U1U0 averaged -> (U3U2)(U1U0)=UU1 UU0->mm4 +@@ -338,8 +340,8 @@ rgbtoycb_mmx_loop: + + psrad $FIXPSHIFT, %mm1 #32-bit scaled V7V6 -> mm1 + psraw $1, %mm4 #divide UU3 UU2 UU1 UU0 by 2 -> mm4 +- +- movq TEMPV, %mm5 #32-bit scaled V3V2V1V0 -> mm5 ++ ++ movq MUNG(TEMPV), %mm5 #32-bit scaled V3V2V1V0 -> mm5 + + movq %mm4, (%ecx) # store U + +@@ -372,6 +374,8 @@ rgbtoycb_mmx_loop: + ret + + .global _dv_ppm_copy_y_block_mmx ++.hidden _dv_ppm_copy_y_block_mmx ++.type _dv_ppm_copy_y_block_mmx,@function + _dv_ppm_copy_y_block_mmx: + + pushl %ebp +@@ -422,17 +426,20 @@ _dv_ppm_copy_y_block_mmx: + ret + + .global _dv_pgm_copy_y_block_mmx ++.hidden _dv_pgm_copy_y_block_mmx ++.type _dv_ppm_copy_y_block_mmx,@function + _dv_pgm_copy_y_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + pushl %edi +- +- movl 8(%ebp), %edi # dest +- movl 12(%ebp), %esi # src + +- movq OFFSETY, %mm7 ++ LOAD_PIC_REG_BP() ++ ++ movl 16(%esp), %edi # dest ++ movl 20(%esp), %esi # src ++ ++ movq MUNG(OFFSETY), %mm7 + pxor %mm6, %mm6 + + movq (%esi), %mm0 +@@ -564,17 +571,20 @@ _dv_pgm_copy_y_block_mmx: + ret + + .global _dv_video_copy_y_block_mmx ++.hidden _dv_video_copy_y_block_mmx ++.type _dv_video_copy_y_block_mmx,@function + _dv_video_copy_y_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + pushl %edi +- +- movl 8(%ebp), %edi # dest +- movl 12(%ebp), %esi # src + +- movq OFFSETBX, %mm7 ++ LOAD_PIC_REG_BP() ++ ++ movl 16(%esp), %edi # dest ++ movl 20(%esp), %esi # src ++ ++ movq MUNG(OFFSETBX), %mm7 + pxor %mm6, %mm6 + + movq (%esi), %mm0 +@@ -709,6 +719,8 @@ _dv_video_copy_y_block_mmx: + + + .global _dv_ppm_copy_pal_c_block_mmx ++.hidden _dv_ppm_copy_pal_c_block_mmx ++.type _dv_ppm_copy_pal_c_block_mmx,@function + _dv_ppm_copy_pal_c_block_mmx: + + pushl %ebp +@@ -852,19 +864,21 @@ _dv_ppm_copy_pal_c_block_mmx: + ret + + .global _dv_pgm_copy_pal_c_block_mmx ++.hidden _dv_ppm_copy_pal_c_block_mmx ++.type _dv_pgm_copy_pal_c_block_mmx,@function + _dv_pgm_copy_pal_c_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + pushl %edi + pushl %ebx +- +- movl 8(%ebp), %edi # dest +- movl 12(%ebp), %esi # src + ++ LOAD_PIC_REG_BP() ++ ++ movl 20(%esp), %edi # dest ++ movl 24(%esp), %esi # src + +- movq OFFSETBX, %mm7 ++ movq MUNG(OFFSETBX), %mm7 + pxor %mm6, %mm6 + + +@@ -1000,18 +1014,21 @@ _dv_pgm_copy_pal_c_block_mmx: + ret + + .global _dv_video_copy_pal_c_block_mmx ++.hidden _dv_video_copy_pal_c_block_mmx ++.type _dv_video_copy_pal_c_block_mmx,@function + _dv_video_copy_pal_c_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + pushl %edi + pushl %ebx +- +- movl 8(%ebp), %edi # dest +- movl 12(%ebp), %esi # src + +- movq OFFSETBX, %mm7 ++ LOAD_PIC_REG_BP() ++ ++ movl 20(%esp), %edi # dest ++ movl 24(%esp), %esi # src ++ ++ movq MUNG(OFFSETBX), %mm7 + paddw %mm7, %mm7 + pxor %mm6, %mm6 + +@@ -1095,21 +1112,23 @@ video_copy_pal_c_block_mmx_loop: + ret + + .global _dv_ppm_copy_ntsc_c_block_mmx ++.hidden _dv_ppm_copy_ntsc_c_block_mmx ++.type _dv_ppm_copy_ntsc_c_block_mmx,@function + _dv_ppm_copy_ntsc_c_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + pushl %edi + pushl %ebx +- +- movl 8(%ebp), %edi # dest +- movl 12(%ebp), %esi # src ++ ++ LOAD_PIC_REG_BP() ++ ++ movl 20(%esp), %edi # dest ++ movl 24(%esp), %esi # src + + movl $4, %ebx + +- movq ALLONE, %mm6 +- ++ movq MUNG(ALLONE), %mm6 + ppm_copy_ntsc_c_block_mmx_loop: + + movq (%esi), %mm0 +@@ -1168,17 +1187,20 @@ ppm_copy_ntsc_c_block_mmx_loop: + ret + + .global _dv_pgm_copy_ntsc_c_block_mmx ++.hidden _dv_pgm_copy_ntsc_c_block_mmx ++.type _dv_pgm_copy_ntsc_c_block_mmx,@function + _dv_pgm_copy_ntsc_c_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + pushl %edi +- +- movl 8(%ebp), %edi # dest +- movl 12(%ebp), %esi # src + +- movq OFFSETBX, %mm7 ++ LOAD_PIC_REG_BP() ++ ++ movl 16(%esp), %edi # dest ++ movl 20(%esp), %esi # src ++ ++ movq MUNG(OFFSETBX), %mm7 + paddw %mm7, %mm7 + pxor %mm6, %mm6 + +@@ -1325,18 +1347,21 @@ _dv_pgm_copy_ntsc_c_block_mmx: + ret + + .global _dv_video_copy_ntsc_c_block_mmx ++.hidden _dv_video_copy_ntsc_c_block_mmx ++.type _dv_video_copy_ntsc_c_block_mmx,@function + _dv_video_copy_ntsc_c_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + pushl %edi + pushl %ebx +- +- movl 8(%ebp), %edi # dest +- movl 12(%ebp), %esi # src + +- movq OFFSETBX, %mm7 ++ LOAD_PIC_REG_BP() ++ ++ movl 20(%esp), %edi # dest ++ movl 24(%esp), %esi # src ++ ++ movq MUNG(OFFSETBX), %mm7 + paddw %mm7, %mm7 + pxor %mm6, %mm6 + +diff -Nurp libdv-0.104-old/libdv/rgbtoyuv_x86_64.S libdv-0.104/libdv/rgbtoyuv_x86_64.S +--- libdv-0.104-old/libdv/rgbtoyuv_x86_64.S 2006-01-01 22:44:22.000000000 +0100 ++++ libdv-0.104/libdv/rgbtoyuv_x86_64.S 2006-01-01 22:44:43.000000000 +0100 +@@ -41,9 +41,6 @@ + #define DV_WIDTH_SHORT_HALF 720 + #define DV_WIDTH_BYTE_HALF 360 + +-.global _dv_rgbtoycb_mmx_x86_64 +-# .global yuvtoycb_mmx_x86_64 +- + .data + + .align 8 +diff -Nurp libdv-0.104-old/libdv/transpose_x86.S libdv-0.104/libdv/transpose_x86.S +--- libdv-0.104-old/libdv/transpose_x86.S 2006-01-01 22:44:22.000000000 +0100 ++++ libdv-0.104/libdv/transpose_x86.S 2006-01-01 22:44:43.000000000 +0100 +@@ -1,5 +1,7 @@ + .text + .global _dv_transpose_mmx ++.hidden _dv_transpose_mmx ++.type _dv_transpose_mmx,@function + + _dv_transpose_mmx: + pushl %ebp +diff -Nurp libdv-0.104-old/libdv/transpose_x86_64.S libdv-0.104/libdv/transpose_x86_64.S +--- libdv-0.104-old/libdv/transpose_x86_64.S 2006-01-01 22:44:22.000000000 +0100 ++++ libdv-0.104/libdv/transpose_x86_64.S 2006-01-01 22:44:43.000000000 +0100 +@@ -1,5 +1,7 @@ + .text + .global _dv_transpose_mmx_x86_64 ++.hidden _dv_transpose_mmx_x86_64 ++.type _dv_transpose_mmx_x86_64,@function + + _dv_transpose_mmx_x86_64: + +diff -Nurp libdv-0.104-old/libdv/vlc_x86.S libdv-0.104/libdv/vlc_x86.S +--- libdv-0.104-old/libdv/vlc_x86.S 2006-01-01 22:44:22.000000000 +0100 ++++ libdv-0.104/libdv/vlc_x86.S 2006-01-01 22:45:51.000000000 +0100 +@@ -1,29 +1,38 @@ + #include "asmoff.h" ++ #include "asm_common.S" ++ + .text + .align 4 + .globl dv_decode_vlc ++.globl asm_dv_decode_vlc ++.hidden asm_dv_decode_vlc ++asm_dv_decode_vlc = dv_decode_vlc ++ + .type dv_decode_vlc,@function + dv_decode_vlc: + pushl %ebx ++ pushl %ebp + +- /* Args are at 8(%esp). */ +- movl 8(%esp),%eax /* %eax is bits */ +- movl 12(%esp),%ebx /* %ebx is maxbits */ ++ LOAD_PIC_REG_BP() ++ ++ /* Args are at 12(%esp). */ ++ movl 12(%esp),%eax /* %eax is bits */ ++ movl 16(%esp),%ebx /* %ebx is maxbits */ + andl $0x3f,%ebx /* limit index range STL*/ + +- movl dv_vlc_class_index_mask(,%ebx,4),%edx ++ movl MUNG_ARR(dv_vlc_class_index_mask,%ebx,4),%edx + andl %eax,%edx +- movl dv_vlc_class_index_rshift(,%ebx,4),%ecx ++ movl MUNG_ARR(dv_vlc_class_index_rshift,%ebx,4),%ecx + sarl %cl,%edx +- movl dv_vlc_classes(,%ebx,4),%ecx ++ movl MUNG_ARR(dv_vlc_classes,%ebx,4),%ecx + movsbl (%ecx,%edx,1),%edx /* %edx is class */ + +- movl dv_vlc_index_mask(,%edx,4),%ebx +- movl dv_vlc_index_rshift(,%edx,4),%ecx ++ movl MUNG_ARR(dv_vlc_index_mask,%edx,4),%ebx ++ movl MUNG_ARR(dv_vlc_index_rshift,%edx,4),%ecx + andl %eax,%ebx + sarl %cl,%ebx + +- movl dv_vlc_lookups(,%edx,4),%edx ++ movl MUNG_ARR(dv_vlc_lookups,%edx,4),%edx + movl (%edx,%ebx,4),%edx + + /* Now %edx holds result, like this: +@@ -42,7 +51,7 @@ dv_decode_vlc: + movl %edx,%ecx + sarl $8,%ecx + andl $0xff,%ecx +- movl sign_mask(,%ecx,4),%ebx ++ movl MUNG_ARR(sign_mask,%ecx,4),%ebx + andl %ebx,%eax + negl %eax + sarl $31,%eax +@@ -63,14 +72,14 @@ dv_decode_vlc: + *result = broken; + Note that the 'broken' pattern is all ones (i.e. 0xffffffff) + */ +- movl 12(%esp),%ebx /* %ebx is maxbits */ ++ movl 20(%esp),%ebx /* %ebx is maxbits */ + subl %ecx,%ebx + sbbl %ebx,%ebx + orl %ebx,%edx + +- movl 16(%esp),%eax ++ movl 24(%esp),%eax + movl %edx,(%eax) +- ++ popl %ebp + popl %ebx + ret + +@@ -80,21 +89,28 @@ dv_decode_vlc: + .type __dv_decode_vlc,@function + __dv_decode_vlc: + pushl %ebx ++ pushl %ebp ++ ++ LOAD_PIC_REG_BP() + +- /* Args are at 8(%esp). */ +- movl 8(%esp),%eax /* %eax is bits */ ++ /* Args are at 12(%esp). */ ++ movl 12(%esp),%eax /* %eax is bits */ + + movl %eax,%edx /* %edx is class */ + andl $0xfe00,%edx + sarl $9,%edx ++#ifdef __PIC__ ++ movsbl dv_vlc_class_lookup5@GOTOFF(%ebp,%edx),%edx ++#else + movsbl dv_vlc_class_lookup5(%edx),%edx +- +- movl dv_vlc_index_mask(,%edx,4),%ebx +- movl dv_vlc_index_rshift(,%edx,4),%ecx ++#endif ++ ++ movl MUNG_ARR(dv_vlc_index_mask,%edx,4),%ebx ++ movl MUNG_ARR(dv_vlc_index_rshift,%edx,4),%ecx + andl %eax,%ebx + sarl %cl,%ebx + +- movl dv_vlc_lookups(,%edx,4),%edx ++ movl MUNG_ARR(dv_vlc_lookups,%edx,4),%edx + movl (%edx,%ebx,4),%edx + + /* Now %edx holds result, like this: +@@ -112,7 +128,7 @@ __dv_decode_vlc: + movl %edx,%ecx + sarl $8,%ecx + andl $0xff,%ecx +- movl sign_mask(,%ecx,4),%ecx ++ movl MUNG_ARR(sign_mask,%ecx,4),%ecx + andl %ecx,%eax + negl %eax + sarl $31,%eax +@@ -127,9 +143,9 @@ __dv_decode_vlc: + xorl %eax,%edx + subl %eax,%edx + +- movl 12(%esp),%eax ++ movl 16(%esp),%eax + movl %edx,(%eax) +- ++ popl %ebp + popl %ebx + ret + +@@ -140,13 +156,20 @@ void dv_parse_ac_coeffs_pass0(bitstream_ + */ + .text + .align 4 ++.globl asm_dv_parse_ac_coeffs_pass0 ++.hidden asm_dv_parse_ac_coeffs_pass0 ++ asm_dv_parse_ac_coeffs_pass0 = dv_parse_ac_coeffs_pass0 ++ + .globl dv_parse_ac_coeffs_pass0 ++.type dv_parse_ac_coeffs_pass0,@function + dv_parse_ac_coeffs_pass0: + pushl %ebx + pushl %edi + pushl %esi + pushl %ebp + ++ LOAD_PIC_REG_SI() ++ + #define ARGn(N) (20+(4*(N)))(%esp) + + /* +@@ -159,8 +182,10 @@ dv_parse_ac_coeffs_pass0: + ebp bl + */ + movl ARGn(2),%ebp ++#ifndef __PIC__ + movl ARGn(0),%esi + movl bitstream_t_buf(%esi),%esi ++#endif + movl dv_block_t_offset(%ebp),%edi + movl dv_block_t_reorder(%ebp),%ebx + +@@ -170,7 +195,11 @@ dv_parse_ac_coeffs_pass0: + + movq dv_block_t_coeffs(%ebp),%mm1 + pxor %mm0,%mm0 ++#ifdef __PIC__ ++ pand const_f_0_0_0@GOTOFF(%esi),%mm1 ++#else + pand const_f_0_0_0,%mm1 ++#endif + movq %mm1,dv_block_t_coeffs(%ebp) + movq %mm0,(dv_block_t_coeffs + 8)(%ebp) + movq %mm0,(dv_block_t_coeffs + 16)(%ebp) +@@ -191,9 +220,17 @@ dv_parse_ac_coeffs_pass0: + readloop: + movl %edi,%ecx + shrl $3,%ecx ++#ifdef __PIC__ ++ pushl %esi ++ movl ARGn(1),%esi ++ movl bitstream_t_buf(%esi),%esi ++#endif + movzbl (%esi,%ecx,1),%eax + movzbl 1(%esi,%ecx,1),%edx + movzbl 2(%esi,%ecx,1),%ecx ++#ifdef __PIC__ ++ popl %esi ++#endif + shll $16,%eax + shll $8,%edx + orl %ecx,%eax +@@ -217,7 +254,11 @@ readloop: + + /* Attempt to use the shortcut first. If it hits, then + this vlc term has been decoded. */ ++#ifdef __PIC__ ++ movl dv_vlc_class1_shortcut@GOTOFF(%esi,%ecx,4),%edx ++#else + movl dv_vlc_class1_shortcut(,%ecx,4),%edx ++#endif + test $0x80,%edx + je done_decode + +@@ -228,12 +269,19 @@ readloop: + movl %ebx,dv_block_t_reorder(%ebp) + + /* %eax is bits */ +- ++#ifdef __PIC__ ++ movsbl dv_vlc_class_lookup5@GOTOFF(%esi,%ecx),%ecx ++ ++ movl dv_vlc_index_mask@GOTOFF(%esi,%ecx,4),%ebx ++ movl dv_vlc_lookups@GOTOFF(%esi,%ecx,4),%edx ++ movl dv_vlc_index_rshift@GOTOFF(%esi,%ecx,4),%ecx ++#else + movsbl dv_vlc_class_lookup5(%ecx),%ecx + + movl dv_vlc_index_mask(,%ecx,4),%ebx + movl dv_vlc_lookups(,%ecx,4),%edx + movl dv_vlc_index_rshift(,%ecx,4),%ecx ++#endif + andl %eax,%ebx + sarl %cl,%ebx + +@@ -256,7 +304,11 @@ readloop: + movl %edx,%ecx + sarl $8,%ecx + andl $0xff,%ecx ++#ifdef __PIC__ ++ movl sign_mask@GOTOFF(%esi,%ecx,4),%ecx ++#else + movl sign_mask(,%ecx,4),%ecx ++#endif + andl %ecx,%eax + negl %eax + sarl $31,%eax +@@ -326,10 +378,16 @@ alldone: + + slowpath: + /* slow path: use dv_decode_vlc */; ++#ifdef __PIC__ ++ pushl %esi ++ leal vlc@GOTOFF(%esi),%esi ++ xchgl %esi,(%esp) /* last parameter is &vlc */ ++#else + pushl $vlc /* last parameter is &vlc */ ++#endif + pushl %edx /* bits_left */ + pushl %eax /* bits */ +- call dv_decode_vlc ++ call asm_dv_decode_vlc + addl $12,%esp + test $0x80,%edx /* If (vlc.run < 0) break */ + jne escape +@@ -359,12 +417,15 @@ show16: + gint dv_parse_video_segment(dv_videosegment_t *seg, guint quality) { + */ + .globl dv_parse_video_segment ++ .type dv_parse_video_segment,@function + dv_parse_video_segment: + pushl %ebx + pushl %edi + pushl %esi + pushl %ebp + ++ LOAD_PIC_REG_SI() ++ + #define ARGn(N) (20+(4*(N)))(%esp) + + movl ARGn(1),%eax /* quality */ +@@ -373,7 +434,11 @@ dv_parse_video_segment: + jz its_mono + movl $6,%ebx + its_mono: ++#ifdef __PIC__ ++ movl %ebx,n_blocks@GOTOFF(%esi) ++#else + movl %ebx,n_blocks ++#endif + + /* + * ebx seg/b +@@ -384,15 +449,22 @@ its_mono: + * ebp bl + */ + movl ARGn(0),%ebx ++#ifndef __PIC__ + movl dv_videosegment_t_bs(%ebx),%esi + movl bitstream_t_buf(%esi),%esi ++#endif + leal dv_videosegment_t_mb(%ebx),%edi + + movl $0,%eax + movl $0,%ecx + macloop: ++#ifdef __PIC__ ++ movl %eax,m@GOTOFF(%esi) ++ movl %ecx,mb_start@GOTOFF(%esi) ++#else + movl %eax,m + movl %ecx,mb_start ++#endif + + movl ARGn(0),%ebx + +@@ -400,7 +472,15 @@ macloop: + /* mb->qno = bitstream_get(bs,4); */ + movl %ecx,%edx + shr $3,%edx ++#ifdef __PIC__ ++ pushl %esi ++ movl dv_videosegment_t_bs(%ebx),%esi ++ movl bitstream_t_buf(%esi),%esi ++#endif + movzbl 3(%esi,%edx,1),%edx ++#ifdef __PIC__ ++ popl %esi ++#endif + andl $0xf,%edx + movl %edx,dv_macroblock_t_qno(%edi) + +@@ -411,7 +491,11 @@ macloop: + movl %edx,dv_macroblock_t_eob_count(%edi) + + /* mb->i = (seg->i + dv_super_map_vertical[m]) % (seg->isPAL?12:10); */ ++#ifdef __PIC__ ++ movl dv_super_map_vertical@GOTOFF(%esi,%eax,4),%edx ++#else + movl dv_super_map_vertical(,%eax,4),%edx ++#endif + movl dv_videosegment_t_i(%ebx),%ecx + addl %ecx,%edx + +@@ -422,11 +506,20 @@ skarly: + andl $1,%ecx + shll $5,%ecx /* ecx = (isPAL ? 32 : 0) */ + ++#ifdef __PIC__ ++ leal mod_10@GOTOFF(%esi,%edx),%edx ++ movzbl (%edx,%ecx,1),%edx /* uses mod_12 for PAL */ ++#else + movzbl mod_10(%edx,%ecx,1),%edx /* uses mod_12 for PAL */ ++#endif + movl %edx,dv_macroblock_t_i(%edi) + + /* mb->j = dv_super_map_horizontal[m]; */ ++#ifdef __PIC__ ++ movl dv_super_map_horizontal@GOTOFF(%esi,%eax,4),%edx ++#else + movl dv_super_map_horizontal(,%eax,4),%edx ++#endif + movl %edx,dv_macroblock_t_j(%edi) + + /* mb->k = seg->k; */ +@@ -445,12 +538,29 @@ blkloop: + +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ + */ + /* dc = bitstream_get(bs,9); */ ++#ifdef __PIC__ ++ movl mb_start@GOTOFF(%esi),%ecx ++#else + movl mb_start,%ecx ++#endif + shr $3,%ecx ++#ifdef __PIC__ ++ movzbl blk_start@GOTOFF(%esi,%ebx),%edx ++#else + movzbl blk_start(%ebx),%edx ++#endif + addl %ecx,%edx ++#ifdef __PIC__ ++ pushl %esi ++ movl ARGn(1),%esi ++ movl dv_videosegment_t_bs(%esi),%esi ++ movl bitstream_t_buf(%esi),%esi ++#endif + movzbl (%esi,%edx,1),%eax /* hi byte */ + movzbl 1(%esi,%edx,1),%ecx /* lo byte */ ++#ifdef __PIC__ ++ popl %esi ++#endif + shll $8,%eax + orl %ecx,%eax + +@@ -477,7 +587,11 @@ blkloop: + + /* bl->reorder = &dv_reorder[bl->dct_mode][1]; */ + shll $6,%eax ++#ifdef __PIC__ ++ addl dv_reorder@GOTOFF+1(%esi),%eax ++#else + addl $(dv_reorder+1),%eax ++#endif + movl %eax,dv_block_t_reorder(%ebp) + + /* bl->reorder_sentinel = bl->reorder + 63; */ +@@ -485,13 +599,22 @@ blkloop: + movl %eax,dv_block_t_reorder_sentinel(%ebp) + + /* bl->offset= mb_start + dv_parse_bit_start[b]; */ ++#ifdef __PIC__ ++ movl mb_start@GOTOFF(%esi),%ecx ++ movl dv_parse_bit_start@GOTOFF(%esi,%ebx,4),%eax ++#else + movl mb_start,%ecx + movl dv_parse_bit_start(,%ebx,4),%eax ++#endif + addl %ecx,%eax + movl %eax,dv_block_t_offset(%ebp) + + /* bl->end= mb_start + dv_parse_bit_end[b]; */ ++#ifdef __PIC__ ++ movl dv_parse_bit_end@GOTOFF(%esi,%ebx,4),%eax ++#else + movl dv_parse_bit_end(,%ebx,4),%eax ++#endif + addl %ecx,%eax + movl %eax,dv_block_t_end(%ebp) + +@@ -503,7 +626,11 @@ blkloop: + /* no AC pass. Just zero out the remaining coeffs */ + movq dv_block_t_coeffs(%ebp),%mm1 + pxor %mm0,%mm0 ++#ifdef __PIC__ ++ pand const_f_0_0_0@GOTOFF(%esi),%mm1 ++#else + pand const_f_0_0_0,%mm1 ++#endif + movq %mm1,dv_block_t_coeffs(%ebp) + movq %mm0,(dv_block_t_coeffs + 8)(%ebp) + movq %mm0,(dv_block_t_coeffs + 16)(%ebp) +@@ -528,18 +655,27 @@ do_ac_pass: + pushl %ebp + pushl %edi + pushl %eax +- call dv_parse_ac_coeffs_pass0 ++ call asm_dv_parse_ac_coeffs_pass0 + addl $12,%esp + done_ac: + ++#ifdef __PIC__ ++ movl n_blocks@GOTOFF(%esi),%eax ++#else + movl n_blocks,%eax ++#endif + addl $dv_block_t_size,%ebp + incl %ebx + cmpl %eax,%ebx + jnz blkloop + ++#ifdef __PIC__ ++ movl m@GOTOFF(%esi),%eax ++ movl mb_start@GOTOFF(%esi),%ecx ++#else + movl m,%eax + movl mb_start,%ecx ++#endif + addl $(8 * 80),%ecx + addl $dv_macroblock_t_size,%edi + incl %eax +@@ -557,7 +693,7 @@ done_ac: + + andl $DV_QUALITY_AC_MASK,%eax + cmpl $DV_QUALITY_AC_2,%eax +- jz dv_parse_ac_coeffs ++ jz asm_dv_parse_ac_coeffs + movl $0,%eax + ret + +diff -Nurp libdv-0.104-old/libdv/vlc_x86_64.S libdv-0.104/libdv/vlc_x86_64.S +--- libdv-0.104-old/libdv/vlc_x86_64.S 2006-01-01 22:44:23.000000000 +0100 ++++ libdv-0.104/libdv/vlc_x86_64.S 2006-01-01 22:44:43.000000000 +0100 +@@ -169,7 +169,8 @@ void dv_parse_ac_coeffs_pass0(bitstream_ + .text + .align 4 + .globl dv_parse_ac_coeffs_pass0 +- ++.type dv_parse_ac_coeffs_pass0,@function ++ + dv_parse_ac_coeffs_pass0: + + /* Args are at rdi=bs, rsi=mb, rdx=bl */ +@@ -422,6 +423,7 @@ show16: /* not u + gint dv_parse_video_segment(dv_videosegment_t *seg, guint quality) { + */ + .globl dv_parse_video_segment ++ .type dv_parse_video_segment,@function + dv_parse_video_segment: + + /* Args are at rdi=seg, rsi=quality */ +diff -Nurp libdv-0.104-old/libdv-0.104/libdv/asm_common.S libdv-0.104/libdv-0.104/libdv/asm_common.S +--- libdv-0.104-old/libdv-0.104/libdv/asm_common.S 1970-01-01 01:00:00.000000000 +0100 ++++ libdv-0.104/libdv-0.104/libdv/asm_common.S 2006-01-01 22:44:43.000000000 +0100 +@@ -0,0 +1,37 @@ ++/* public domain, do what you want */ ++ ++#ifdef __PIC__ ++# define MUNG(sym) sym##@GOTOFF(%ebp) ++# define MUNG_ARR(sym, args...) sym##@GOTOFF(%ebp,##args) ++#else ++# define MUNG(sym) sym ++# define MUNG_ARR(sym, args...) sym(,##args) ++#endif ++ ++#ifdef __PIC__ ++# undef __i686 /* gcc define gets in our way */ ++ .section .gnu.linkonce.t.__i686.get_pc_thunk.bp,"ax",@progbits ++.globl __i686.get_pc_thunk.bp ++ .hidden __i686.get_pc_thunk.bp ++ .type __i686.get_pc_thunk.bp,@function ++__i686.get_pc_thunk.bp: ++ movl (%esp), %ebp ++ ret ++# define LOAD_PIC_REG_BP() \ ++ call __i686.get_pc_thunk.bp ; \ ++ addl $_GLOBAL_OFFSET_TABLE_, %ebp ++ ++ .section .gnu.linkonce.t.__i686.get_pc_thunk.si,"ax",@progbits ++.globl __i686.get_pc_thunk.si ++ .hidden __i686.get_pc_thunk.si ++ .type __i686.get_pc_thunk.si,@function ++__i686.get_pc_thunk.si: ++ movl (%esp), %esi ++ ret ++# define LOAD_PIC_REG_SI() \ ++ call __i686.get_pc_thunk.si ; \ ++ addl $_GLOBAL_OFFSET_TABLE_, %esi ++#else ++# define LOAD_PIC_REG_BP() ++# define LOAD_PIC_REG_SI() ++#endif diff --git a/libdv-0.104-pic-fix.patch b/libdv-0.104-pic-fix.patch new file mode 100644 index 0000000..4f4d422 --- /dev/null +++ b/libdv-0.104-pic-fix.patch @@ -0,0 +1,1995 @@ +diff -urp libdv-0.104-old/libdv/dct_block_mmx.S libdv-0.104/libdv/dct_block_mmx.S +--- libdv-0.104-old/libdv/dct_block_mmx.S 2005-10-23 19:40:58.000000000 +0200 ++++ libdv-0.104/libdv/dct_block_mmx.S 2005-10-24 00:11:39.000000000 +0200 +@@ -53,6 +53,17 @@ scratch2: .quad 0 + scratch3: .quad 0 + scratch4: .quad 0 + ++#ifdef __PIC__ ++# undef __i686 /* gcc define gets in our way */ ++ .section .gnu.linkonce.t.__i686.get_pc_thunk.bp,"ax",@progbits ++.globl __i686.get_pc_thunk.bp ++ .hidden __i686.get_pc_thunk.bp ++ .type __i686.get_pc_thunk.bp,@function ++__i686.get_pc_thunk.bp: ++ movl (%esp), %ebp ++ ret ++#endif ++ + .text + + .align 8 +@@ -60,10 +71,14 @@ scratch4: .quad 0 + _dv_dct_88_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + +- movl 8(%ebp), %esi # source ++#ifdef __PIC__ ++ call __i686.get_pc_thunk.bp ++ addl $_GLOBAL_OFFSET_TABLE_, %ebp ++#endif ++ ++ movl 12(%ebp), %esi # source + + # column 0 + movq 16*0(%esi), %mm0 # v0 +@@ -86,22 +101,45 @@ _dv_dct_88_block_mmx: + + movq 16*3(%esi), %mm5 # v3 + movq 16*4(%esi), %mm7 # v4 ++#ifdef __PIC__ ++ movq %mm7, scratch1@GOTOFF(%ebp) # scratch1: v4 ; ++#else + movq %mm7, scratch1 # scratch1: v4 ; ++#endif + movq %mm5, %mm7 # duplicate v3 ++#ifdef __PIC__ ++ paddw scratch1@GOTOFF(%ebp), %mm5 # v03: v3+v4 ++ psubw scratch1@GOTOFF(%ebp), %mm7 # v04: v3-v4 ++ movq %mm5, scratch2@GOTOFF(%ebp) # scratch2: v03 ++#else + paddw scratch1, %mm5 # v03: v3+v4 + psubw scratch1, %mm7 # v04: v3-v4 + movq %mm5, scratch2 # scratch2: v03 ++#endif + movq %mm0, %mm5 # mm5: v00 + ++#ifdef __PIC__ ++ paddw scratch2@GOTOFF(%ebp), %mm0 # v10: v00+v03 ++ psubw scratch2@GOTOFF(%ebp), %mm5 # v13: v00-v03 ++ movq %mm3, scratch3@GOTOFF(%ebp) # scratch3: v02 ++#else + paddw scratch2, %mm0 # v10: v00+v03 + psubw scratch2, %mm5 # v13: v00-v03 + movq %mm3, scratch3 # scratch3: v02 ++#endif + movq %mm1, %mm3 # duplicate v01 + ++#ifdef __PIC__ ++ paddw scratch3@GOTOFF(%ebp), %mm1 # v11: v01+v02 ++ psubw scratch3@GOTOFF(%ebp), %mm3 # v12: v01-v02 ++ ++ movq %mm6, scratch4@GOTOFF(%ebp) # scratch4: v05 ++#else + paddw scratch3, %mm1 # v11: v01+v02 + psubw scratch3, %mm3 # v12: v01-v02 + + movq %mm6, scratch4 # scratch4: v05 ++#endif + movq %mm0, %mm6 # duplicate v10 + + paddw %mm1, %mm0 # v10+v11 +@@ -111,10 +149,18 @@ _dv_dct_88_block_mmx: + movq %mm6, 16*4(%esi) # out4: v10-v11 + + movq %mm4, %mm0 # mm0: v06 ++#ifdef __PIC__ ++ paddw scratch4@GOTOFF(%ebp), %mm4 # v15: v05+v06 ++#else + paddw scratch4, %mm4 # v15: v05+v06 ++#endif + paddw %mm2, %mm0 # v16: v07+v06 + ++#ifdef __PIC__ ++ pmulhw WA3@GOTOFF(%ebp), %mm4 # v35~: WA3*v15 ++#else + pmulhw WA3, %mm4 # v35~: WA3*v15 ++#endif + psllw $1, %mm4 # v35: compensate the coeefient scale + + movq %mm4, %mm6 # duplicate v35 +@@ -123,7 +169,11 @@ _dv_dct_88_block_mmx: + + paddw %mm5, %mm3 # v22: v12+v13 + ++#ifdef __PIC__ ++ pmulhw WA1@GOTOFF(%ebp), %mm3 # v32~: WA1*v22 ++#else + pmulhw WA1, %mm3 # v32~: WA1*v22 ++#endif + psllw $16-NSHIFT, %mm3 # v32: compensate the coeefient scale + movq %mm5, %mm6 # duplicate v13 + +@@ -134,13 +184,23 @@ _dv_dct_88_block_mmx: + movq %mm6, 16*6(%esi) # out6: v13-v32 + + ++#ifdef __PIC__ ++ paddw scratch4@GOTOFF(%ebp), %mm7 # v14n: v04+v05 ++#else + paddw scratch4, %mm7 # v14n: v04+v05 ++#endif + movq %mm0, %mm5 # duplicate v16 + + psubw %mm7, %mm0 # va1: v16-v14n ++#ifdef __PIC__ ++ pmulhw WA5@GOTOFF(%ebp), %mm0 # va0~: va1*WA5 ++ pmulhw WA4@GOTOFF(%ebp), %mm5 # v36~~: v16*WA4 ++ pmulhw WA2@GOTOFF(%ebp), %mm7 # v34~~: v14n*WA2 ++#else + pmulhw WA5, %mm0 # va0~: va1*WA5 + pmulhw WA4, %mm5 # v36~~: v16*WA4 + pmulhw WA2, %mm7 # v34~~: v14n*WA2 ++#endif + psllw $16-WA4_SHIFT, %mm5 # v36: compensate the coeefient scale + psllw $16-NSHIFT, %mm7 # v34: compensate the coeefient scale + +@@ -188,22 +248,45 @@ _dv_dct_88_block_mmx: + + movq 16*3(%esi), %mm5 # v3 + movq 16*4(%esi), %mm7 # v4 ++#ifdef __PIC__ ++ movq %mm7, scratch1@GOTOFF(%ebp) # scratch1: v4 ; ++#else + movq %mm7, scratch1 # scratch1: v4 ; ++#endif + movq %mm5, %mm7 # duplicate v3 ++#ifdef __PIC__ ++ paddw scratch1@GOTOFF(%ebp), %mm5 # v03: v3+v4 ++ psubw scratch1@GOTOFF(%ebp), %mm7 # v04: v3-v4 ++ movq %mm5, scratch2@GOTOFF(%ebp) # scratch2: v03 ++#else + paddw scratch1, %mm5 # v03: v3+v4 + psubw scratch1, %mm7 # v04: v3-v4 + movq %mm5, scratch2 # scratch2: v03 ++#endif + movq %mm0, %mm5 # mm5: v00 + ++#ifdef __PIC__ ++ paddw scratch2@GOTOFF(%ebp), %mm0 # v10: v00+v03 ++ psubw scratch2@GOTOFF(%ebp), %mm5 # v13: v00-v03 ++ movq %mm3, scratch3@GOTOFF(%ebp) # scratc3: v02 ++#else + paddw scratch2, %mm0 # v10: v00+v03 + psubw scratch2, %mm5 # v13: v00-v03 + movq %mm3, scratch3 # scratc3: v02 ++#endif + movq %mm1, %mm3 # duplicate v01 + ++#ifdef __PIC__ ++ paddw scratch3@GOTOFF(%ebp), %mm1 # v11: v01+v02 ++ psubw scratch3@GOTOFF(%ebp), %mm3 # v12: v01-v02 ++ ++ movq %mm6, scratch4@GOTOFF(%ebp) # scratc4: v05 ++#else + paddw scratch3, %mm1 # v11: v01+v02 + psubw scratch3, %mm3 # v12: v01-v02 + + movq %mm6, scratch4 # scratc4: v05 ++#endif + movq %mm0, %mm6 # duplicate v10 + + paddw %mm1, %mm0 # v10+v11 +@@ -213,10 +296,18 @@ _dv_dct_88_block_mmx: + movq %mm6, 16*4(%esi) # out4: v10-v11 + + movq %mm4, %mm0 # mm0: v06 ++#ifdef __PIC__ ++ paddw scratch4@GOTOFF(%ebp), %mm4 # v15: v05+v06 ++#else + paddw scratch4, %mm4 # v15: v05+v06 ++#endif + paddw %mm2, %mm0 # v16: v07+v06 + ++#ifdef __PIC__ ++ pmulhw WA3@GOTOFF(%ebp), %mm4 # v35~: WA3*v15 ++#else + pmulhw WA3, %mm4 # v35~: WA3*v15 ++#endif + psllw $16-NSHIFT, %mm4 # v35: compensate the coeefient scale + + movq %mm4, %mm6 # duplicate v35 +@@ -225,7 +316,11 @@ _dv_dct_88_block_mmx: + + paddw %mm5, %mm3 # v22: v12+v13 + ++#ifdef __PIC__ ++ pmulhw WA1@GOTOFF(%ebp), %mm3 # v32~: WA3*v15 ++#else + pmulhw WA1, %mm3 # v32~: WA3*v15 ++#endif + psllw $16-NSHIFT, %mm3 # v32: compensate the coeefient scale + movq %mm5, %mm6 # duplicate v13 + +@@ -235,13 +330,23 @@ _dv_dct_88_block_mmx: + movq %mm5, 16*2(%esi) # out2: v13+v32 + movq %mm6, 16*6(%esi) # out6: v13-v32 + ++#ifdef __PIC__ ++ paddw scratch4@GOTOFF(%ebp), %mm7 # v14n: v04+v05 ++#else + paddw scratch4, %mm7 # v14n: v04+v05 ++#endif + movq %mm0, %mm5 # duplicate v16 + + psubw %mm7, %mm0 # va1: v16-v14n ++#ifdef __PIC__ ++ pmulhw WA2@GOTOFF(%ebp), %mm7 # v34~~: v14n*WA2 ++ pmulhw WA5@GOTOFF(%ebp), %mm0 # va0~: va1*WA5 ++ pmulhw WA4@GOTOFF(%ebp), %mm5 # v36~~: v16*WA4 ++#else + pmulhw WA2, %mm7 # v34~~: v14n*WA2 + pmulhw WA5, %mm0 # va0~: va1*WA5 + pmulhw WA4, %mm5 # v36~~: v16*WA4 ++#endif + psllw $16-NSHIFT, %mm7 + psllw $16-WA4_SHIFT, %mm5 # v36: compensate the coeffient + # scale note that WA4 is shifted 1 bit less than the others +@@ -751,11 +856,15 @@ _dv_dct_block_mmx_postscale_88: + _dv_dct_248_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + pushl %edi + +- movl 8(%ebp), %esi # source ++#ifdef __PIC__ ++ call __i686.get_pc_thunk.bp ++ addl $_GLOBAL_OFFSET_TABLE_, %ebp ++#endif ++ ++ movl 16(%ebp), %esi # source + + # column 0 + +@@ -779,7 +888,11 @@ _dv_dct_248_block_mmx: + paddw %mm1, %mm0 # v20: v10+v11 + psubw %mm1, %mm3 # v21: v10-v11 + ++#ifdef __PIC__ ++ pmulhw WA1@GOTOFF(%ebp), %mm5 # v32~: WA1*v22 ++#else + pmulhw WA1, %mm5 # v32~: WA1*v22 ++#endif + movq %mm4, %mm2 + psllw $16-NSHIFT, %mm5 # v32: compensate the coeffient scale + +@@ -818,7 +931,11 @@ _dv_dct_248_block_mmx: + paddw %mm1, %mm0 # v20: v10+v11 + psubw %mm1, %mm3 # v21: v10-v11 + ++#ifdef __PIC__ ++ pmulhw WA1@GOTOFF(%ebp), %mm5 # v32~: WA1*v22 ++#else + pmulhw WA1, %mm5 # v32~: WA1*v22 ++#endif + movq %mm4, %mm2 + psllw $16-NSHIFT, %mm5 # v32: compensate the coeffient scale + +@@ -855,7 +972,11 @@ _dv_dct_248_block_mmx: + paddw %mm1, %mm0 # v20: v10+v11 + psubw %mm1, %mm3 # v21: v10-v11 + ++#ifdef __PIC__ ++ pmulhw WA1@GOTOFF(%ebp), %mm5 # v32~: WA1*v22 ++#else + pmulhw WA1, %mm5 # v32~: WA1*v22 ++#endif + movq %mm4, %mm2 + psllw $16-NSHIFT, %mm5 # v32: compensate the coeffient scale + +@@ -892,7 +1013,11 @@ _dv_dct_248_block_mmx: + paddw %mm1, %mm0 # v20: v10+v11 + psubw %mm1, %mm3 # v21: v10-v11 + ++#ifdef __PIC__ ++ pmulhw WA1@GOTOFF(%ebp), %mm5 # v32~: WA1*v22 ++#else + pmulhw WA1, %mm5 # v32~: WA1*v22 ++#endif + movq %mm4, %mm2 + psllw $16-NSHIFT, %mm5 # v32: compensate the coeffient scale + +diff -urp libdv-0.104-old/libdv/dv.c libdv-0.104/libdv/dv.c +--- libdv-0.104-old/libdv/dv.c 2004-10-20 05:49:24.000000000 +0200 ++++ libdv-0.104/libdv/dv.c 2005-10-24 00:59:57.000000000 +0200 +@@ -205,6 +205,9 @@ dv_reconfigure(int clamp_luma, int clamp + } /* dv_reconfigure */ + + ++extern uint8_t dv_quant_offset[4]; ++extern uint8_t dv_quant_shifts[22][4]; ++ + static inline void + dv_decode_macroblock(dv_decoder_t *dv, dv_macroblock_t *mb, unsigned int quality) { + int i; +@@ -218,7 +221,7 @@ dv_decode_macroblock(dv_decoder_t *dv, d + dv_idct_248 (co248, mb->b[i].coeffs); + } else { + #if ARCH_X86 +- _dv_quant_88_inverse_x86(mb->b[i].coeffs,mb->qno,mb->b[i].class_no); ++ _dv_quant_88_inverse_x86(mb->b[i].coeffs,mb->qno,mb->b[i].class_no,dv_quant_offset,dv_quant_shifts); + _dv_idct_88(mb->b[i].coeffs); + #elif ARCH_X86_64 + _dv_quant_88_inverse_x86_64(mb->b[i].coeffs,mb->qno,mb->b[i].class_no); +@@ -250,7 +253,7 @@ dv_decode_video_segment(dv_decoder_t *dv + dv_idct_248 (co248, mb->b[b].coeffs); + } else { + #if ARCH_X86 +- _dv_quant_88_inverse_x86(bl->coeffs,mb->qno,bl->class_no); ++ _dv_quant_88_inverse_x86(bl->coeffs,mb->qno,bl->class_no,dv_quant_offset,dv_quant_shifts); + _dv_weight_88_inverse(bl->coeffs); + _dv_idct_88(bl->coeffs); + #elif ARCH_X86_64 +diff -urp libdv-0.104-old/libdv/encode.c libdv-0.104/libdv/encode.c +--- libdv-0.104-old/libdv/encode.c 2004-11-17 04:36:30.000000000 +0100 ++++ libdv-0.104/libdv/encode.c 2005-10-24 01:17:41.000000000 +0200 +@@ -521,7 +521,8 @@ static void reorder_block(dv_block_t *bl + } + + extern unsigned long _dv_vlc_encode_block_mmx(dv_coeff_t* coeffs, +- dv_vlc_entry_t ** out); ++ dv_vlc_entry_t ** out, ++ dv_vlc_entry_t * lookup); + + extern unsigned long _dv_vlc_encode_block_mmx_x86_64(dv_coeff_t* coeffs, + dv_vlc_entry_t ** out); +@@ -558,7 +559,7 @@ static unsigned long vlc_encode_block(dv + #elif ARCH_X86 + int num_bits; + +- num_bits = _dv_vlc_encode_block_mmx(coeffs, &o); ++ num_bits = _dv_vlc_encode_block_mmx(coeffs, &o, vlc_encode_lookup); + emms(); + #else + int num_bits; +@@ -574,7 +575,7 @@ static unsigned long vlc_encode_block(dv + return num_bits; + } + +-extern unsigned long _dv_vlc_num_bits_block_x86(dv_coeff_t* coeffs); ++extern unsigned long _dv_vlc_num_bits_block_x86(dv_coeff_t* coeffs, unsigned char* lookup); + extern unsigned long _dv_vlc_num_bits_block_x86_64(dv_coeff_t* coeffs); + + extern unsigned long _dv_vlc_num_bits_block(dv_coeff_t* coeffs) +@@ -600,7 +601,7 @@ extern unsigned long _dv_vlc_num_bits_bl + #elif ARCH_X86_64 + return _dv_vlc_num_bits_block_x86_64(coeffs); + #else +- return _dv_vlc_num_bits_block_x86(coeffs); ++ return _dv_vlc_num_bits_block_x86(coeffs, vlc_num_bits_lookup); + #endif + } + +diff -urp libdv-0.104-old/libdv/encode_x86.S libdv-0.104/libdv/encode_x86.S +--- libdv-0.104-old/libdv/encode_x86.S 2005-10-23 19:40:58.000000000 +0200 ++++ libdv-0.104/libdv/encode_x86.S 2005-10-24 01:18:32.000000000 +0200 +@@ -23,10 +23,6 @@ + * The libdv homepage is http://libdv.sourceforge.net/. + */ + +-.data +-ALLONE: .word 1,1,1,1 +-VLCADDMASK: .byte 255,0,0,0,255,0,0,0 +- + .text + + .global _dv_vlc_encode_block_mmx +@@ -45,11 +41,14 @@ _dv_vlc_encode_block_mmx: + + movl $63, %ecx + +- movl vlc_encode_lookup, %esi ++ movl 4+4*4+8(%esp), %esi # vlc_encode_lookup + + pxor %mm0, %mm0 + pxor %mm2, %mm2 +- movq VLCADDMASK, %mm1 ++ pushl $0x000000FF ++ pushl $0x000000FF ++ movq (%esp), %mm1 ++ addl $8, %esp + xorl %ebp, %ebp + subl $8, %edx + vlc_encode_block_mmx_loop: +@@ -121,7 +120,7 @@ _dv_vlc_num_bits_block_x86: + addl $2, %edi + + movl $63, %ecx +- movl vlc_num_bits_lookup, %esi ++ movl 4+4*4+4(%esp), %esi # vlc_num_bits_lookup + + vlc_num_bits_block_x86_loop: + movw (%edi), %ax +@@ -579,8 +578,11 @@ _dv_need_dct_248_mmx_rows: + paddw %mm5, %mm1 + + paddw %mm1, %mm0 +- +- pmaddwd ALLONE, %mm0 ++ ++ pushl $0x00010001 ++ pushl $0x00010001 ++ pmaddwd (%esp), %mm0 ++ addl $8, %esp + movq %mm0, %mm1 + psrlq $32, %mm1 + paddd %mm1, %mm0 +diff -urp libdv-0.104-old/libdv/idct_block_mmx.S libdv-0.104/libdv/idct_block_mmx.S +--- libdv-0.104-old/libdv/idct_block_mmx.S 2005-10-23 19:40:58.000000000 +0200 ++++ libdv-0.104/libdv/idct_block_mmx.S 2005-10-24 01:12:12.000000000 +0200 +@@ -8,16 +8,37 @@ + + + ++#ifdef __PIC__ ++# undef __i686 /* gcc define gets in our way */ ++ .section .gnu.linkonce.t.__i686.get_pc_thunk.bp,"ax",@progbits ++.globl __i686.get_pc_thunk.bp ++ .hidden __i686.get_pc_thunk.bp ++ .type __i686.get_pc_thunk.bp,@function ++__i686.get_pc_thunk.bp: ++ movl (%esp), %ebp ++ ret ++#endif ++ + .text ++ + .align 4 + .globl _dv_idct_block_mmx + .type _dv_idct_block_mmx,@function + _dv_idct_block_mmx: + pushl %ebp +- movl %esp,%ebp + pushl %esi ++ ++#ifdef __PIC__ ++ call __i686.get_pc_thunk.bp ++ addl $_GLOBAL_OFFSET_TABLE_, %ebp ++#endif ++ ++#ifdef __PIC__ ++ leal preSC@GOTOFF(%ebp), %ecx ++#else + leal preSC, %ecx +- movl 8(%ebp),%esi /* source matrix */ ++#endif ++ movl 12(%esp),%esi /* source matrix */ + + /* + * column 0: even part +@@ -35,7 +56,11 @@ _dv_idct_block_mmx: + movq %mm1, %mm2 /* added 11/1/96 */ + pmulhw 8*8(%esi),%mm5 /* V8 */ + psubsw %mm0, %mm1 /* V16 */ ++#ifdef __PIC__ ++ pmulhw x5a825a825a825a82@GOTOFF(%ebp), %mm1 /* 23170 ->V18 */ ++#else + pmulhw x5a825a825a825a82, %mm1 /* 23170 ->V18 */ ++#endif + paddsw %mm0, %mm2 /* V17 */ + movq %mm2, %mm0 /* duplicate V17 */ + psraw $1, %mm2 /* t75=t82 */ +@@ -76,7 +101,11 @@ _dv_idct_block_mmx: + paddsw %mm0, %mm3 /* V29 ; free mm0 */ + movq %mm7, %mm1 /* duplicate V26 */ + psraw $1, %mm3 /* t91=t94 */ ++#ifdef __PIC__ ++ pmulhw x539f539f539f539f@GOTOFF(%ebp),%mm7 /* V33 */ ++#else + pmulhw x539f539f539f539f,%mm7 /* V33 */ ++#endif + psraw $1, %mm1 /* t96 */ + movq %mm5, %mm0 /* duplicate V2 */ + psraw $2, %mm4 /* t85=t87 */ +@@ -84,15 +113,27 @@ _dv_idct_block_mmx: + psubsw %mm4, %mm0 /* V28 ; free mm4 */ + movq %mm0, %mm2 /* duplicate V28 */ + psraw $1, %mm5 /* t90=t93 */ ++#ifdef __PIC__ ++ pmulhw x4546454645464546@GOTOFF(%ebp),%mm0 /* V35 */ ++#else + pmulhw x4546454645464546,%mm0 /* V35 */ ++#endif + psraw $1, %mm2 /* t97 */ + movq %mm5, %mm4 /* duplicate t90=t93 */ + psubsw %mm2, %mm1 /* V32 ; free mm2 */ ++#ifdef __PIC__ ++ pmulhw x61f861f861f861f8@GOTOFF(%ebp),%mm1 /* V36 */ ++#else + pmulhw x61f861f861f861f8,%mm1 /* V36 */ ++#endif + psllw $1, %mm7 /* t107 */ + paddsw %mm3, %mm5 /* V31 */ + psubsw %mm3, %mm4 /* V30 ; free mm3 */ ++#ifdef __PIC__ ++ pmulhw x5a825a825a825a82@GOTOFF(%ebp),%mm4 /* V34 */ ++#else + pmulhw x5a825a825a825a82,%mm4 /* V34 */ ++#endif + nop + psubsw %mm1, %mm0 /* V38 */ + psubsw %mm7, %mm1 /* V37 ; free mm7 */ +@@ -159,7 +200,11 @@ _dv_idct_block_mmx: + psubsw %mm7, %mm1 /* V50 */ + pmulhw 8*9(%esi), %mm5 /* V9 */ + paddsw %mm7, %mm2 /* V51 */ ++#ifdef __PIC__ ++ pmulhw x5a825a825a825a82@GOTOFF(%ebp), %mm1 /* 23170 ->V52 */ ++#else + pmulhw x5a825a825a825a82, %mm1 /* 23170 ->V52 */ ++#endif + movq %mm2, %mm6 /* duplicate V51 */ + psraw $1, %mm2 /* t138=t144 */ + movq %mm3, %mm4 /* duplicate V1 */ +@@ -200,11 +245,19 @@ _dv_idct_block_mmx: + * even more by doing the correction step in a later stage when the number + * is actually multiplied by 16 + */ ++#ifdef __PIC__ ++ paddw x0005000200010001@GOTOFF(%ebp), %mm4 ++#else + paddw x0005000200010001, %mm4 ++#endif + psubsw %mm6, %mm3 /* V60 ; free mm6 */ + psraw $1, %mm0 /* t154=t156 */ + movq %mm3, %mm1 /* duplicate V60 */ ++#ifdef __PIC__ ++ pmulhw x539f539f539f539f@GOTOFF(%ebp), %mm1 /* V67 */ ++#else + pmulhw x539f539f539f539f, %mm1 /* V67 */ ++#endif + movq %mm5, %mm6 /* duplicate V3 */ + psraw $2, %mm4 /* t148=t150 */ + paddsw %mm4, %mm5 /* V61 */ +@@ -213,13 +266,25 @@ _dv_idct_block_mmx: + psllw $1, %mm1 /* t169 */ + paddsw %mm0, %mm5 /* V65 -> result */ + psubsw %mm0, %mm4 /* V64 ; free mm0 */ ++#ifdef __PIC__ ++ pmulhw x5a825a825a825a82@GOTOFF(%ebp), %mm4 /* V68 */ ++#else + pmulhw x5a825a825a825a82, %mm4 /* V68 */ ++#endif + psraw $1, %mm3 /* t158 */ + psubsw %mm6, %mm3 /* V66 */ + movq %mm5, %mm2 /* duplicate V65 */ ++#ifdef __PIC__ ++ pmulhw x61f861f861f861f8@GOTOFF(%ebp), %mm3 /* V70 */ ++#else + pmulhw x61f861f861f861f8, %mm3 /* V70 */ ++#endif + psllw $1, %mm6 /* t165 */ ++#ifdef __PIC__ ++ pmulhw x4546454645464546@GOTOFF(%ebp), %mm6 /* V69 */ ++#else + pmulhw x4546454645464546, %mm6 /* V69 */ ++#endif + psraw $1, %mm2 /* t172 */ + /* moved from next block */ + movq 8*5(%esi), %mm0 /* V56 */ +@@ -344,7 +409,11 @@ _dv_idct_block_mmx: + * movq 8*13(%esi), %mm4 tmt13 + */ + psubsw %mm4, %mm3 /* V134 */ ++#ifdef __PIC__ ++ pmulhw x5a825a825a825a82@GOTOFF(%ebp), %mm3 /* 23170 ->V136 */ ++#else + pmulhw x5a825a825a825a82, %mm3 /* 23170 ->V136 */ ++#endif + movq 8*9(%esi), %mm6 /* tmt9 */ + paddsw %mm4, %mm5 /* V135 ; mm4 free */ + movq %mm0, %mm4 /* duplicate tmt1 */ +@@ -373,17 +442,33 @@ _dv_idct_block_mmx: + psubsw %mm7, %mm0 /* V144 */ + movq %mm0, %mm3 /* duplicate V144 */ + paddsw %mm7, %mm2 /* V147 ; free mm7 */ ++#ifdef __PIC__ ++ pmulhw x539f539f539f539f@GOTOFF(%ebp), %mm0 /* 21407-> V151 */ ++#else + pmulhw x539f539f539f539f, %mm0 /* 21407-> V151 */ ++#endif + movq %mm1, %mm7 /* duplicate tmt3 */ + paddsw %mm5, %mm7 /* V145 */ + psubsw %mm5, %mm1 /* V146 ; free mm5 */ + psubsw %mm1, %mm3 /* V150 */ + movq %mm7, %mm5 /* duplicate V145 */ ++#ifdef __PIC__ ++ pmulhw x4546454645464546@GOTOFF(%ebp), %mm1 /* 17734-> V153 */ ++#else + pmulhw x4546454645464546, %mm1 /* 17734-> V153 */ ++#endif + psubsw %mm2, %mm5 /* V148 */ ++#ifdef __PIC__ ++ pmulhw x61f861f861f861f8@GOTOFF(%ebp), %mm3 /* 25080-> V154 */ ++#else + pmulhw x61f861f861f861f8, %mm3 /* 25080-> V154 */ ++#endif + psllw $2, %mm0 /* t311 */ ++#ifdef __PIC__ ++ pmulhw x5a825a825a825a82@GOTOFF(%ebp), %mm5 /* 23170-> V152 */ ++#else + pmulhw x5a825a825a825a82, %mm5 /* 23170-> V152 */ ++#endif + paddsw %mm2, %mm7 /* V149 ; free mm2 */ + psllw $1, %mm1 /* t313 */ + nop /* without the nop - freeze here for one clock */ +@@ -409,7 +494,11 @@ _dv_idct_block_mmx: + paddsw %mm3, %mm6 /* V164 ; free mm3 */ + movq %mm4, %mm3 /* duplicate V142 */ + psubsw %mm5, %mm4 /* V165 ; free mm5 */ ++#ifdef __PIC__ ++ movq %mm2, scratch7@GOTOFF(%ebp) /* out7 */ ++#else + movq %mm2, scratch7 /* out7 */ ++#endif + psraw $4, %mm6 + psraw $4, %mm4 + paddsw %mm5, %mm3 /* V162 */ +@@ -420,11 +509,19 @@ _dv_idct_block_mmx: + */ + movq %mm6, 8*9(%esi) /* out9 */ + paddsw %mm1, %mm0 /* V161 */ ++#ifdef __PIC__ ++ movq %mm3, scratch5@GOTOFF(%ebp) /* out5 */ ++#else + movq %mm3, scratch5 /* out5 */ ++#endif + psubsw %mm1, %mm5 /* V166 ; free mm1 */ + movq %mm4, 8*11(%esi) /* out11 */ + psraw $4, %mm5 ++#ifdef __PIC__ ++ movq %mm0, scratch3@GOTOFF(%ebp) /* out3 */ ++#else + movq %mm0, scratch3 /* out3 */ ++#endif + movq %mm2, %mm4 /* duplicate V140 */ + movq %mm5, 8*13(%esi) /* out13 */ + paddsw %mm7, %mm2 /* V160 */ +@@ -434,7 +531,11 @@ _dv_idct_block_mmx: + /* moved from the next block */ + movq 8*3(%esi), %mm7 + psraw $4, %mm4 ++#ifdef __PIC__ ++ movq %mm2, scratch1@GOTOFF(%ebp) /* out1 */ ++#else + movq %mm2, scratch1 /* out1 */ ++#endif + /* moved from the next block */ + movq %mm0, %mm1 + movq %mm4, 8*15(%esi) /* out15 */ +@@ -491,15 +592,31 @@ _dv_idct_block_mmx: + paddsw %mm4, %mm3 /* V113 ; free mm4 */ + movq %mm0, %mm4 /* duplicate V110 */ + paddsw %mm1, %mm2 /* V111 */ ++#ifdef __PIC__ ++ pmulhw x539f539f539f539f@GOTOFF(%ebp), %mm0 /* 21407-> V117 */ ++#else + pmulhw x539f539f539f539f, %mm0 /* 21407-> V117 */ ++#endif + psubsw %mm1, %mm5 /* V112 ; free mm1 */ + psubsw %mm5, %mm4 /* V116 */ + movq %mm2, %mm1 /* duplicate V111 */ ++#ifdef __PIC__ ++ pmulhw x4546454645464546@GOTOFF(%ebp), %mm5 /* 17734-> V119 */ ++#else + pmulhw x4546454645464546, %mm5 /* 17734-> V119 */ ++#endif + psubsw %mm3, %mm2 /* V114 */ ++#ifdef __PIC__ ++ pmulhw x61f861f861f861f8@GOTOFF(%ebp), %mm4 /* 25080-> V120 */ ++#else + pmulhw x61f861f861f861f8, %mm4 /* 25080-> V120 */ ++#endif + paddsw %mm3, %mm1 /* V115 ; free mm3 */ ++#ifdef __PIC__ ++ pmulhw x5a825a825a825a82@GOTOFF(%ebp), %mm2 /* 23170-> V118 */ ++#else + pmulhw x5a825a825a825a82, %mm2 /* 23170-> V118 */ ++#endif + psllw $2, %mm0 /* t266 */ + movq %mm1, (%esi) /* save V115 */ + psllw $1, %mm5 /* t268 */ +@@ -517,7 +634,11 @@ _dv_idct_block_mmx: + movq %mm6, %mm3 /* duplicate tmt4 */ + psubsw %mm0, %mm6 /* V100 */ + paddsw %mm0, %mm3 /* V101 ; free mm0 */ ++#ifdef __PIC__ ++ pmulhw x5a825a825a825a82@GOTOFF(%ebp), %mm6 /* 23170 ->V102 */ ++#else + pmulhw x5a825a825a825a82, %mm6 /* 23170 ->V102 */ ++#endif + movq %mm7, %mm5 /* duplicate tmt0 */ + movq 8*8(%esi), %mm1 /* tmt8 */ + paddsw %mm1, %mm7 /* V103 */ +@@ -551,10 +672,18 @@ _dv_idct_block_mmx: + movq 8*2(%esi), %mm3 /* V123 */ + paddsw %mm4, %mm7 /* out0 */ + /* moved up from next block */ ++#ifdef __PIC__ ++ movq scratch3@GOTOFF(%ebp), %mm0 ++#else + movq scratch3, %mm0 ++#endif + psraw $4, %mm7 + /* moved up from next block */ ++#ifdef __PIC__ ++ movq scratch5@GOTOFF(%ebp), %mm6 ++#else + movq scratch5, %mm6 ++#endif + psubsw %mm4, %mm1 /* out14 ; free mm4 */ + paddsw %mm3, %mm5 /* out2 */ + psraw $4, %mm1 +@@ -565,7 +694,11 @@ _dv_idct_block_mmx: + movq %mm5, 8*2(%esi) /* out2 ; free mm5 */ + psraw $4, %mm2 + /* moved up to the prev block */ ++#ifdef __PIC__ ++ movq scratch7@GOTOFF(%ebp), %mm4 ++#else + movq scratch7, %mm4 ++#endif + /* moved up to the prev block */ + psraw $4, %mm0 + movq %mm2, 8*12(%esi) /* out12 ; free mm2 */ +@@ -579,7 +712,11 @@ _dv_idct_block_mmx: + * psraw $4, %mm0 + * psraw $4, %mm6 + */ ++#ifdef __PIC__ ++ movq scratch1@GOTOFF(%ebp), %mm1 ++#else + movq scratch1, %mm1 ++#endif + psraw $4, %mm4 + movq %mm0, 8*3(%esi) /* out3 */ + psraw $4, %mm1 +diff -urp libdv-0.104-old/libdv/quant.c libdv-0.104/libdv/quant.c +--- libdv-0.104-old/libdv/quant.c 2004-10-20 05:49:24.000000000 +0200 ++++ libdv-0.104/libdv/quant.c 2005-10-24 01:06:24.000000000 +0200 +@@ -144,7 +144,7 @@ uint8_t dv_quant_offset[4] = { 6,3,0,1 + uint32_t dv_quant_248_mul_tab [2] [22] [64]; + uint32_t dv_quant_88_mul_tab [2] [22] [64]; + +-extern void _dv_quant_x86(dv_coeff_t *block,int qno,int klass); ++extern void _dv_quant_x86(dv_coeff_t *block,int qno,int klass,uint8_t dv_quant_offset[],uint8_t dv_quant_shifts[][]); + extern void _dv_quant_x86_64(dv_coeff_t *block,int qno,int klass); + static void quant_248_inverse_std(dv_coeff_t *block,int qno,int klass,dv_248_coeff_t *co); + static void quant_248_inverse_mmx(dv_coeff_t *block,int qno,int klass,dv_248_coeff_t *co); +@@ -210,7 +210,7 @@ void _dv_quant(dv_coeff_t *block,int qno + _dv_quant_x86_64(block, qno, klass); + emms(); + #else +- _dv_quant_x86(block, qno, klass); ++ _dv_quant_x86(block, qno, klass, dv_quant_offset, dv_quant_shifts); + emms(); + #endif + } +diff -urp libdv-0.104-old/libdv/quant.h libdv-0.104/libdv/quant.h +--- libdv-0.104-old/libdv/quant.h 2004-10-20 05:49:24.000000000 +0200 ++++ libdv-0.104/libdv/quant.h 2005-10-24 00:57:43.000000000 +0200 +@@ -27,7 +27,7 @@ extern void _dv_quant(dv_coeff_t *block, + extern void _dv_quant_88_inverse(dv_coeff_t *block,int qno,int klass); + extern void (*_dv_quant_248_inverse) (dv_coeff_t *block,int qno,int klass, + dv_248_coeff_t *co); +-extern void _dv_quant_88_inverse_x86(dv_coeff_t *block,int qno,int klass); ++extern void _dv_quant_88_inverse_x86(dv_coeff_t *block,int qno,int klass, uint8_t offset[], uint8_t shifts[][]); + extern void _dv_quant_88_inverse_x86_64(dv_coeff_t *block,int qno,int klass); + extern void dv_quant_init (void); + #ifdef __cplusplus +diff -urp libdv-0.104-old/libdv/quant_x86.S libdv-0.104/libdv/quant_x86.S +--- libdv-0.104-old/libdv/quant_x86.S 2005-10-23 19:40:58.000000000 +0200 ++++ libdv-0.104/libdv/quant_x86.S 2005-10-24 01:10:21.000000000 +0200 +@@ -71,10 +71,13 @@ _dv_quant_88_inverse_x86: + + /* pq = dv_quant_shifts[qno + dv_quant_offset[class]]; */ + movl ARGn(1),%eax /* qno */ ++ movl ARGn(3),%ebx /* dv_quant_offset */ ++ addl ARGn(2),%ebx /* class */ ++ movzbl (%ebx),%ecx + movl ARGn(2),%ebx /* class */ +- movzbl dv_quant_offset(%ebx),%ecx + addl %ecx,%eax +- leal dv_quant_shifts(,%eax,4),%edx /* edx is pq */ ++ movl ARGn(4),%edx /* dv_quant_shifts */ ++ leal (%edx,%eax,4),%edx /* edx is pq */ + + /* extra = (class == 3); */ + /* 0 1 2 3 */ +@@ -212,11 +215,13 @@ _dv_quant_x86: + + /* pq = dv_quant_shifts[qno + dv_quant_offset[class]]; */ + movl ARGn(1),%eax /* qno */ ++ movl ARGn(3),%ebx /* offset */ ++ addl ARGn(2),%ebx /* class */ ++ movzbl (%ebx),%ecx + movl ARGn(2),%ebx /* class */ +- +- movzbl dv_quant_offset(%ebx),%ecx ++ movl ARGn(4),%edx /* shifts */ + addl %ecx,%eax +- leal dv_quant_shifts(,%eax,4),%edx /* edx is pq */ ++ leal (%edx,%eax,4),%edx /* edx is pq */ + + /* extra = (class == 3); */ + /* 0 1 2 3 */ +diff -urp libdv-0.104-old/libdv/rgbtoyuv.S libdv-0.104/libdv/rgbtoyuv.S +--- libdv-0.104-old/libdv/rgbtoyuv.S 2005-10-23 19:40:58.000000000 +0200 ++++ libdv-0.104/libdv/rgbtoyuv.S 2005-10-24 00:46:34.000000000 +0200 +@@ -110,20 +110,30 @@ VR0GR: .long 0,0 + VBG0B: .long 0,0 + + #endif +- ++ ++#ifdef __PIC__ ++# undef __i686 /* gcc define gets in our way */ ++ .section .gnu.linkonce.t.__i686.get_pc_thunk.bp,"ax",@progbits ++.globl __i686.get_pc_thunk.bp ++ .hidden __i686.get_pc_thunk.bp ++ .type __i686.get_pc_thunk.bp,@function ++__i686.get_pc_thunk.bp: ++ movl (%esp), %ebp ++ ret ++#endif ++ + .text + +-#define _inPtr 8 +-#define _rows 12 +-#define _columns 16 +-#define _outyPtr 20 +-#define _outuPtr 24 +-#define _outvPtr 28 ++#define _inPtr 24+8 ++#define _rows 24+12 ++#define _columns 24+16 ++#define _outyPtr 24+20 ++#define _outuPtr 24+24 ++#define _outvPtr 24+28 + + _dv_rgbtoycb_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %eax + pushl %ebx + pushl %ecx +@@ -131,46 +141,103 @@ _dv_rgbtoycb_mmx: + pushl %esi + pushl %edi + ++#ifdef __PIC__ ++ call __i686.get_pc_thunk.bp ++ addl $_GLOBAL_OFFSET_TABLE_, %ebp ++#endif ++ ++#ifdef __PIC__ ++ leal ZEROSX@GOTOFF(%ebp), %eax #This section gets around a bug ++#else + leal ZEROSX, %eax #This section gets around a bug ++#endif + movq (%eax), %mm0 #unlikely to persist ++#ifdef __PIC__ ++ movq %mm0, ZEROS@GOTOFF(%ebp) ++ leal OFFSETDX@GOTOFF(%ebp), %eax ++#else + movq %mm0, ZEROS + leal OFFSETDX, %eax ++#endif + movq (%eax), %mm0 ++#ifdef __PIC__ ++ movq %mm0, OFFSETD@GOTOFF(%ebp) ++ leal OFFSETWX@GOTOFF(%ebp), %eax ++#else + movq %mm0, OFFSETD + leal OFFSETWX, %eax ++#endif + movq (%eax), %mm0 ++#ifdef __PIC__ ++ movq %mm0, OFFSETW@GOTOFF(%ebp) ++ leal OFFSETBX@GOTOFF(%ebp), %eax ++#else + movq %mm0, OFFSETW + leal OFFSETBX, %eax ++#endif + movq (%eax), %mm0 ++#ifdef __PIC__ ++ movq %mm0, OFFSETB@GOTOFF(%ebp) ++ leal YR0GRX@GOTOFF(%ebp), %eax ++#else + movq %mm0, OFFSETB + leal YR0GRX, %eax ++#endif + movq (%eax), %mm0 ++#ifdef __PIC__ ++ movq %mm0, YR0GR@GOTOFF(%ebp) ++ leal YBG0BX@GOTOFF(%ebp), %eax ++#else + movq %mm0, YR0GR + leal YBG0BX, %eax ++#endif + movq (%eax), %mm0 ++#ifdef __PIC__ ++ movq %mm0, YBG0B@GOTOFF(%ebp) ++ leal UR0GRX@GOTOFF(%ebp), %eax ++#else + movq %mm0, YBG0B + leal UR0GRX, %eax ++#endif + movq (%eax), %mm0 ++#ifdef __PIC__ ++ movq %mm0, UR0GR@GOTOFF(%ebp) ++ leal UBG0BX@GOTOFF(%ebp), %eax ++#else + movq %mm0, UR0GR + leal UBG0BX, %eax ++#endif + movq (%eax), %mm0 ++#ifdef __PIC__ ++ movq %mm0, UBG0B@GOTOFF(%ebp) ++ leal VR0GRX@GOTOFF(%ebp), %eax ++#else + movq %mm0, UBG0B + leal VR0GRX, %eax ++#endif + movq (%eax), %mm0 ++#ifdef __PIC__ ++ movq %mm0, VR0GR@GOTOFF(%ebp) ++ leal VBG0BX@GOTOFF(%ebp), %eax ++#else + movq %mm0, VR0GR + leal VBG0BX, %eax ++#endif + movq (%eax), %mm0 ++#ifdef __PIC__ ++ movq %mm0, VBG0B@GOTOFF(%ebp) ++#else + movq %mm0, VBG0B +- +- movl _rows(%ebp), %eax +- movl _columns(%ebp), %ebx ++#endif ++ movl _rows(%esp), %eax ++ movl _columns(%esp), %ebx + mull %ebx #number pixels + shrl $3, %eax #number of loops + movl %eax, %edi #loop counter in edi +- movl _inPtr(%ebp), %eax +- movl _outyPtr(%ebp), %ebx +- movl _outuPtr(%ebp), %ecx +- movl _outvPtr(%ebp), %edx ++ movl _inPtr(%esp), %eax ++ movl _outyPtr(%esp), %ebx ++ movl _outuPtr(%esp), %ecx ++ movl _outvPtr(%esp), %edx + rgbtoycb_mmx_loop: + movq (%eax), %mm1 #load G2R2B1G1R1B0G0R0 + pxor %mm6, %mm6 #0 -> mm6 +@@ -184,29 +251,57 @@ rgbtoycb_mmx_loop: + punpcklbw %mm6, %mm1 #B1G1R1B0 -> mm1 + movq %mm0, %mm2 #R1B0G0R0 -> mm2 + ++#ifdef __PIC__ ++ pmaddwd YR0GR@GOTOFF(%ebp), %mm0 #yrR1,ygG0+yrR0 -> mm0 ++#else + pmaddwd YR0GR, %mm0 #yrR1,ygG0+yrR0 -> mm0 ++#endif + movq %mm1, %mm3 #B1G1R1B0 -> mm3 + ++#ifdef __PIC__ ++ pmaddwd YBG0B@GOTOFF(%ebp), %mm1 #ybB1+ygG1,ybB0 -> mm1 ++#else + pmaddwd YBG0B, %mm1 #ybB1+ygG1,ybB0 -> mm1 ++#endif + movq %mm2, %mm4 #R1B0G0R0 -> mm4 + ++#ifdef __PIC__ ++ pmaddwd UR0GR@GOTOFF(%ebp), %mm2 #urR1,ugG0+urR0 -> mm2 ++#else + pmaddwd UR0GR, %mm2 #urR1,ugG0+urR0 -> mm2 ++#endif + movq %mm3, %mm5 #B1G1R1B0 -> mm5 + ++#ifdef __PIC__ ++ pmaddwd UBG0B@GOTOFF(%ebp), %mm3 #ubB1+ugG1,ubB0 -> mm3 ++#else + pmaddwd UBG0B, %mm3 #ubB1+ugG1,ubB0 -> mm3 ++#endif + punpckhbw %mm6, %mm7 # 00G2R2 -> mm7 + ++#ifdef __PIC__ ++ pmaddwd VR0GR@GOTOFF(%ebp), %mm4 #vrR1,vgG0+vrR0 -> mm4 ++#else + pmaddwd VR0GR, %mm4 #vrR1,vgG0+vrR0 -> mm4 ++#endif + paddd %mm1, %mm0 #Y1Y0 -> mm0 + ++#ifdef __PIC__ ++ pmaddwd VBG0B@GOTOFF(%ebp), %mm5 #vbB1+vgG1,vbB0 -> mm5 ++#else + pmaddwd VBG0B, %mm5 #vbB1+vgG1,vbB0 -> mm5 ++#endif + + movq 8(%eax), %mm1 #R5B4G4R4B3G3R3B2 -> mm1 + paddd %mm3, %mm2 #U1U0 -> mm2 + + movq %mm1, %mm6 #R5B4G4R4B3G3R3B2 -> mm6 + ++#ifdef __PIC__ ++ punpcklbw ZEROS@GOTOFF(%ebp), %mm1 #B3G3R3B2 -> mm1 ++#else + punpcklbw ZEROS, %mm1 #B3G3R3B2 -> mm1 ++#endif + paddd %mm5, %mm4 #V1V0 -> mm4 + + movq %mm1, %mm5 #B3G3R3B2 -> mm5 +@@ -214,29 +309,61 @@ rgbtoycb_mmx_loop: + + paddd %mm7, %mm1 #R3B200+00G2R2=R3B2G2R2->mm1 + ++#ifdef __PIC__ ++ punpckhbw ZEROS@GOTOFF(%ebp), %mm6 #R5B4G4R3 -> mm6 ++#else + punpckhbw ZEROS, %mm6 #R5B4G4R3 -> mm6 ++#endif + movq %mm1, %mm3 #R3B2G2R2 -> mm3 + ++#ifdef __PIC__ ++ pmaddwd YR0GR@GOTOFF(%ebp), %mm1 #yrR3,ygG2+yrR2 -> mm1 ++#else + pmaddwd YR0GR, %mm1 #yrR3,ygG2+yrR2 -> mm1 ++#endif + movq %mm5, %mm7 #B3G3R3B2 -> mm7 + ++#ifdef __PIC__ ++ pmaddwd YBG0B@GOTOFF(%ebp), %mm5 #ybB3+ygG3,ybB2 -> mm5 ++#else + pmaddwd YBG0B, %mm5 #ybB3+ygG3,ybB2 -> mm5 ++#endif + psrad $FIXPSHIFT, %mm0 #32-bit scaled Y1Y0 -> mm0 + ++#ifdef __PIC__ ++ movq %mm6, TEMP0@GOTOFF(%ebp) #R5B4G4R4 -> TEMP0 ++#else + movq %mm6, TEMP0 #R5B4G4R4 -> TEMP0 ++#endif + movq %mm3, %mm6 #R3B2G2R2 -> mm6 ++#ifdef __PIC__ ++ pmaddwd UR0GR@GOTOFF(%ebp), %mm6 #urR3,ugG2+urR2 -> mm6 ++#else + pmaddwd UR0GR, %mm6 #urR3,ugG2+urR2 -> mm6 ++#endif + psrad $FIXPSHIFT, %mm2 #32-bit scaled U1U0 -> mm2 + + paddd %mm5, %mm1 #Y3Y2 -> mm1 + movq %mm7, %mm5 #B3G3R3B2 -> mm5 ++#ifdef __PIC__ ++ pmaddwd UBG0B@GOTOFF(%ebp), %mm7 #ubB3+ugG3,ubB2 ++#else + pmaddwd UBG0B, %mm7 #ubB3+ugG3,ubB2 ++#endif + psrad $FIXPSHIFT, %mm1 #32-bit scaled Y3Y2 -> mm1 + ++#ifdef __PIC__ ++ pmaddwd VR0GR@GOTOFF(%ebp), %mm3 #vrR3,vgG2+vgR2 ++#else + pmaddwd VR0GR, %mm3 #vrR3,vgG2+vgR2 ++#endif + packssdw %mm1, %mm0 #Y3Y2Y1Y0 -> mm0 + ++#ifdef __PIC__ ++ pmaddwd VBG0B@GOTOFF(%ebp), %mm5 #vbB3+vgG3,vbB2 -> mm5 ++#else + pmaddwd VBG0B, %mm5 #vbB3+vgG3,vbB2 -> mm5 ++#endif + psrad $FIXPSHIFT, %mm4 #32-bit scaled V1V0 -> mm4 + + movq 16(%eax), %mm1 #B7G7R7B6G6R6B5G5 -> mm7 +@@ -251,58 +378,114 @@ rgbtoycb_mmx_loop: + movq %mm7, %mm5 #R7B6G6R6B5G500 -> mm5 + psrad $FIXPSHIFT, %mm3 #32-bit scaled V3V2 -> mm3 + ++#ifdef __PIC__ ++ paddw OFFSETY@GOTOFF(%ebp), %mm0 ++#else + paddw OFFSETY, %mm0 ++#endif + movq %mm0, (%ebx) #store Y3Y2Y1Y0 + packssdw %mm6, %mm2 #32-bit scaled U3U2U1U0 -> mm2 + ++#ifdef __PIC__ ++ movq TEMP0@GOTOFF(%ebp), %mm0 #R5B4G4R4 -> mm0 ++#else + movq TEMP0, %mm0 #R5B4G4R4 -> mm0 ++#endif + addl $8, %ebx +- ++ ++#ifdef __PIC__ ++ punpcklbw ZEROS@GOTOFF(%ebp), %mm7 #B5G500 -> mm7 ++#else + punpcklbw ZEROS, %mm7 #B5G500 -> mm7 ++#endif + movq %mm0, %mm6 #R5B4G4R4 -> mm6 + ++#ifdef __PIC__ ++ movq %mm2, TEMPU@GOTOFF(%ebp) #32-bit scaled U3U2U1U0 -> TEMPU ++#else + movq %mm2, TEMPU #32-bit scaled U3U2U1U0 -> TEMPU ++#endif + psrlq $32, %mm0 #00R5B4 -> mm0 + + paddw %mm0, %mm7 #B5G5R5B4 -> mm7 + movq %mm6, %mm2 #B5B4G4R4 -> mm2 + ++#ifdef __PIC__ ++ pmaddwd YR0GR@GOTOFF(%ebp), %mm2 #yrR5,ygG4+yrR4 -> mm2 ++#else + pmaddwd YR0GR, %mm2 #yrR5,ygG4+yrR4 -> mm2 ++#endif + movq %mm7, %mm0 #B5G5R5B4 -> mm0 + ++#ifdef __PIC__ ++ pmaddwd YBG0B@GOTOFF(%ebp), %mm7 #ybB5+ygG5,ybB4 -> mm7 ++#else + pmaddwd YBG0B, %mm7 #ybB5+ygG5,ybB4 -> mm7 ++#endif + packssdw %mm3, %mm4 #32-bit scaled V3V2V1V0 -> mm4 + + addl $24, %eax #increment RGB count + ++#ifdef __PIC__ ++ movq %mm4, TEMPV@GOTOFF(%ebp) #(V3V2V1V0)/256 -> mm4 ++#else + movq %mm4, TEMPV #(V3V2V1V0)/256 -> mm4 ++#endif + movq %mm6, %mm4 #B5B4G4R4 -> mm4 + ++#ifdef __PIC__ ++ pmaddwd UR0GR@GOTOFF(%ebp), %mm6 #urR5,ugG4+urR4 ++#else + pmaddwd UR0GR, %mm6 #urR5,ugG4+urR4 ++#endif + movq %mm0, %mm3 #B5G5R5B4 -> mm0 + ++#ifdef __PIC__ ++ pmaddwd UBG0B@GOTOFF(%ebp), %mm0 #ubB5+ugG5,ubB4 ++#else + pmaddwd UBG0B, %mm0 #ubB5+ugG5,ubB4 ++#endif + paddd %mm7, %mm2 #Y5Y4 -> mm2 + ++#ifdef __PIC__ ++ pmaddwd VR0GR@GOTOFF(%ebp), %mm4 #vrR5,vgG4+vrR4 -> mm4 ++#else + pmaddwd VR0GR, %mm4 #vrR5,vgG4+vrR4 -> mm4 ++#endif + pxor %mm7, %mm7 #0 -> mm7 + ++#ifdef __PIC__ ++ pmaddwd VBG0B@GOTOFF(%ebp), %mm3 #vbB5+vgG5,vbB4 -> mm3 ++#else + pmaddwd VBG0B, %mm3 #vbB5+vgG5,vbB4 -> mm3 ++#endif + punpckhbw %mm7, %mm1 #B7G7R7B6 -> mm1 + + paddd %mm6, %mm0 #U5U4 -> mm0 + movq %mm1, %mm6 #B7G7R7B6 -> mm6 + ++#ifdef __PIC__ ++ pmaddwd YBG0B@GOTOFF(%ebp), %mm6 #ybB7+ygG7,ybB6 -> mm6 ++#else + pmaddwd YBG0B, %mm6 #ybB7+ygG7,ybB6 -> mm6 ++#endif + punpckhbw %mm7, %mm5 #R7B6G6R6 -> mm5 + + movq %mm5, %mm7 #R7B6G6R6 -> mm7 + paddd %mm4, %mm3 #V5V4 -> mm3 + ++#ifdef __PIC__ ++ pmaddwd YR0GR@GOTOFF(%ebp), %mm5 #yrR7,ygG6+yrR6 -> mm5 ++#else + pmaddwd YR0GR, %mm5 #yrR7,ygG6+yrR6 -> mm5 ++#endif + movq %mm1, %mm4 #B7G7R7B6 -> mm4 + ++#ifdef __PIC__ ++ pmaddwd UBG0B@GOTOFF(%ebp), %mm4 #ubB7+ugG7,ubB6 -> mm4 ++#else + pmaddwd UBG0B, %mm4 #ubB7+ugG7,ubB6 -> mm4 ++#endif + psrad $FIXPSHIFT, %mm0 #32-bit scaled U5U4 -> mm0 + + psrad $FIXPSHIFT, %mm2 #32-bit scaled Y5Y4 -> mm2 +@@ -310,25 +493,49 @@ rgbtoycb_mmx_loop: + paddd %mm5, %mm6 #Y7Y6 -> mm6 + movq %mm7, %mm5 #R7B6G6R6 -> mm5 + ++#ifdef __PIC__ ++ pmaddwd UR0GR@GOTOFF(%ebp), %mm7 #urR7,ugG6+ugR6 -> mm7 ++#else + pmaddwd UR0GR, %mm7 #urR7,ugG6+ugR6 -> mm7 ++#endif + psrad $FIXPSHIFT, %mm3 #32-bit scaled V5V4 -> mm3 + ++#ifdef __PIC__ ++ pmaddwd VBG0B@GOTOFF(%ebp), %mm1 #vbB7+vgG7,vbB6 -> mm1 ++#else + pmaddwd VBG0B, %mm1 #vbB7+vgG7,vbB6 -> mm1 ++#endif + psrad $FIXPSHIFT, %mm6 #32-bit scaled Y7Y6 -> mm6 + + packssdw %mm6, %mm2 #Y7Y6Y5Y4 -> mm2 + ++#ifdef __PIC__ ++ pmaddwd VR0GR@GOTOFF(%ebp), %mm5 #vrR7,vgG6+vrR6 -> mm5 ++#else + pmaddwd VR0GR, %mm5 #vrR7,vgG6+vrR6 -> mm5 ++#endif + paddd %mm4, %mm7 #U7U6 -> mm7 + + psrad $FIXPSHIFT, %mm7 #32-bit scaled U7U6 -> mm7 ++#ifdef __PIC__ ++ paddw OFFSETY@GOTOFF(%ebp), %mm2 ++#else + paddw OFFSETY, %mm2 ++#endif + movq %mm2, (%ebx) #store Y7Y6Y5Y4 + ++#ifdef __PIC__ ++ movq ALLONE@GOTOFF(%ebp), %mm6 ++#else + movq ALLONE, %mm6 ++#endif + packssdw %mm7, %mm0 #32-bit scaled U7U6U5U4 -> mm0 + ++#ifdef __PIC__ ++ movq TEMPU@GOTOFF(%ebp), %mm4 #32-bit scaled U3U2U1U0 -> mm4 ++#else + movq TEMPU, %mm4 #32-bit scaled U3U2U1U0 -> mm4 ++#endif + pmaddwd %mm6, %mm0 #U7U6U5U4 averaged -> (U7U6)(U5U4)=UU3 UU2->mm0 + + pmaddwd %mm6, %mm4 #U3U2U1U0 averaged -> (U3U2)(U1U0)=UU1 UU0->mm4 +@@ -338,8 +545,12 @@ rgbtoycb_mmx_loop: + + psrad $FIXPSHIFT, %mm1 #32-bit scaled V7V6 -> mm1 + psraw $1, %mm4 #divide UU3 UU2 UU1 UU0 by 2 -> mm4 +- ++ ++#ifdef __PIC__ ++ movq TEMPV@GOTOFF(%ebp), %mm5 #32-bit scaled V3V2V1V0 -> mm5 ++#else + movq TEMPV, %mm5 #32-bit scaled V3V2V1V0 -> mm5 ++#endif + + movq %mm4, (%ecx) # store U + +@@ -425,14 +636,22 @@ _dv_ppm_copy_y_block_mmx: + _dv_pgm_copy_y_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + pushl %edi +- +- movl 8(%ebp), %edi # dest +- movl 12(%ebp), %esi # src + ++#ifdef __PIC__ ++ call __i686.get_pc_thunk.bp ++ addl $_GLOBAL_OFFSET_TABLE_, %ebp ++#endif ++ ++ movl 16(%esp), %edi # dest ++ movl 20(%esp), %esi # src ++ ++#ifdef __PIC__ ++ movq OFFSETY@GOTOFF(%ebp), %mm7 ++#else + movq OFFSETY, %mm7 ++#endif + pxor %mm6, %mm6 + + movq (%esi), %mm0 +@@ -567,14 +786,22 @@ _dv_pgm_copy_y_block_mmx: + _dv_video_copy_y_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + pushl %edi +- +- movl 8(%ebp), %edi # dest +- movl 12(%ebp), %esi # src + ++#ifdef __PIC__ ++ call __i686.get_pc_thunk.bp ++ addl $_GLOBAL_OFFSET_TABLE_, %ebp ++#endif ++ ++ movl 16(%esp), %edi # dest ++ movl 20(%esp), %esi # src ++ ++#ifdef __PIC__ ++ movq OFFSETBX@GOTOFF(%ebp), %mm7 ++#else + movq OFFSETBX, %mm7 ++#endif + pxor %mm6, %mm6 + + movq (%esi), %mm0 +@@ -855,16 +1082,23 @@ _dv_ppm_copy_pal_c_block_mmx: + _dv_pgm_copy_pal_c_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + pushl %edi + pushl %ebx +- +- movl 8(%ebp), %edi # dest +- movl 12(%ebp), %esi # src + ++#ifdef __PIC__ ++ call __i686.get_pc_thunk.bp ++ addl $_GLOBAL_OFFSET_TABLE_, %ebp ++#endif ++ ++ movl 20(%esp), %edi # dest ++ movl 24(%esp), %esi # src + ++#ifdef __PIC__ ++ movq OFFSETBX@GOTOFF(%ebp), %mm7 ++#else + movq OFFSETBX, %mm7 ++#endif + pxor %mm6, %mm6 + + +@@ -1003,15 +1237,23 @@ _dv_pgm_copy_pal_c_block_mmx: + _dv_video_copy_pal_c_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + pushl %edi + pushl %ebx +- +- movl 8(%ebp), %edi # dest +- movl 12(%ebp), %esi # src + ++#ifdef __PIC__ ++ call __i686.get_pc_thunk.bp ++ addl $_GLOBAL_OFFSET_TABLE_, %ebp ++#endif ++ ++ movl 20(%esp), %edi # dest ++ movl 24(%esp), %esi # src ++ ++#ifdef __PIC__ ++ movq OFFSETBX@GOTOFF(%ebp), %mm7 ++#else + movq OFFSETBX, %mm7 ++#endif + paddw %mm7, %mm7 + pxor %mm6, %mm6 + +@@ -1098,18 +1340,25 @@ video_copy_pal_c_block_mmx_loop: + _dv_ppm_copy_ntsc_c_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + pushl %edi + pushl %ebx +- +- movl 8(%ebp), %edi # dest +- movl 12(%ebp), %esi # src ++ ++#ifdef __PIC__ ++ call __i686.get_pc_thunk.bp ++ addl $_GLOBAL_OFFSET_TABLE_, %ebp ++#endif ++ ++ movl 20(%esp), %edi # dest ++ movl 24(%esp), %esi # src + + movl $4, %ebx + ++#ifdef __PIC__ ++ movq ALLONE@GOTOFF(%ebp), %mm6 ++#else + movq ALLONE, %mm6 +- ++#endif + ppm_copy_ntsc_c_block_mmx_loop: + + movq (%esi), %mm0 +@@ -1171,14 +1420,22 @@ ppm_copy_ntsc_c_block_mmx_loop: + _dv_pgm_copy_ntsc_c_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + pushl %edi +- +- movl 8(%ebp), %edi # dest +- movl 12(%ebp), %esi # src + ++#ifdef __PIC__ ++ call __i686.get_pc_thunk.bp ++ addl $_GLOBAL_OFFSET_TABLE_, %ebp ++#endif ++ ++ movl 16(%esp), %edi # dest ++ movl 20(%esp), %esi # src ++ ++#ifdef __PIC__ ++ movq OFFSETBX@GOTOFF(%ebp), %mm7 ++#else + movq OFFSETBX, %mm7 ++#endif + paddw %mm7, %mm7 + pxor %mm6, %mm6 + +@@ -1328,15 +1585,23 @@ _dv_pgm_copy_ntsc_c_block_mmx: + _dv_video_copy_ntsc_c_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + pushl %edi + pushl %ebx +- +- movl 8(%ebp), %edi # dest +- movl 12(%ebp), %esi # src + ++#ifdef __PIC__ ++ call __i686.get_pc_thunk.bp ++ addl $_GLOBAL_OFFSET_TABLE_, %ebp ++#endif ++ ++ movl 20(%esp), %edi # dest ++ movl 24(%esp), %esi # src ++ ++#ifdef __PIC__ ++ movq OFFSETBX@GOTOFF(%ebp), %mm7 ++#else + movq OFFSETBX, %mm7 ++#endif + paddw %mm7, %mm7 + pxor %mm6, %mm6 + +diff -urp libdv-0.104-old/libdv/vlc_x86.S libdv-0.104/libdv/vlc_x86.S +--- libdv-0.104-old/libdv/vlc_x86.S 2005-10-23 19:40:58.000000000 +0200 ++++ libdv-0.104/libdv/vlc_x86.S 2005-10-25 01:47:14.000000000 +0200 +@@ -1,29 +1,76 @@ + #include "asmoff.h" + .text ++ ++#ifdef __PIC__ ++# undef __i686 /* gcc define gets in our way */ ++ .section .gnu.linkonce.t.__i686.get_pc_thunk.bp,"ax",@progbits ++.globl __i686.get_pc_thunk.bp ++ .hidden __i686.get_pc_thunk.bp ++ .type __i686.get_pc_thunk.bp,@function ++__i686.get_pc_thunk.bp: ++ movl (%esp), %ebp ++ ret ++ ++ .section .gnu.linkonce.t.__i686.get_pc_thunk.si,"ax",@progbits ++.globl __i686.get_pc_thunk.si ++ .hidden __i686.get_pc_thunk.si ++ .type __i686.get_pc_thunk.si,@function ++__i686.get_pc_thunk.si: ++ movl (%esp), %esi ++ ret ++#endif ++ + .align 4 + .globl dv_decode_vlc + .type dv_decode_vlc,@function + dv_decode_vlc: + pushl %ebx ++ pushl %ebp ++ ++#ifdef __PIC__ ++ call __i686.get_pc_thunk.bp ++ addl $_GLOBAL_OFFSET_TABLE_, %ebp ++#endif + +- /* Args are at 8(%esp). */ +- movl 8(%esp),%eax /* %eax is bits */ +- movl 12(%esp),%ebx /* %ebx is maxbits */ ++ /* Args are at 12(%esp). */ ++ movl 12(%esp),%eax /* %eax is bits */ ++ movl 16(%esp),%ebx /* %ebx is maxbits */ + andl $0x3f,%ebx /* limit index range STL*/ + ++#ifdef __ELF__ ++ movl dv_vlc_class_index_mask@GOTOFF(%ebp,%ebx,4),%edx ++#else + movl dv_vlc_class_index_mask(,%ebx,4),%edx ++#endif + andl %eax,%edx ++#ifdef __ELF__ ++ movl dv_vlc_class_index_rshift@GOTOFF(%ebp,%ebx,4),%ecx ++#else + movl dv_vlc_class_index_rshift(,%ebx,4),%ecx ++#endif + sarl %cl,%edx ++#ifdef __ELF__ ++ movl dv_vlc_classes@GOTOFF(%ebp,%ebx,4),%ecx ++#else + movl dv_vlc_classes(,%ebx,4),%ecx ++#endif + movsbl (%ecx,%edx,1),%edx /* %edx is class */ +- ++ ++#ifdef __ELF__ ++ movl dv_vlc_index_mask@GOTOFF(%ebp,%edx,4),%ebx ++ movl dv_vlc_index_rshift@GOTOFF(%ebp,%edx,4),%ecx ++#else + movl dv_vlc_index_mask(,%edx,4),%ebx + movl dv_vlc_index_rshift(,%edx,4),%ecx ++#endif + andl %eax,%ebx + sarl %cl,%ebx + ++#ifdef __ELF__ ++ movl dv_vlc_lookups@GOTOFF(%ebp,%edx,4),%edx ++#else + movl dv_vlc_lookups(,%edx,4),%edx ++#endif + movl (%edx,%ebx,4),%edx + + /* Now %edx holds result, like this: +@@ -42,7 +89,11 @@ dv_decode_vlc: + movl %edx,%ecx + sarl $8,%ecx + andl $0xff,%ecx ++#ifdef __ELF__ ++ movl sign_mask@GOTOFF(%ebp,%ecx,4),%ebx ++#else + movl sign_mask(,%ecx,4),%ebx ++#endif + andl %ebx,%eax + negl %eax + sarl $31,%eax +@@ -63,14 +114,14 @@ dv_decode_vlc: + *result = broken; + Note that the 'broken' pattern is all ones (i.e. 0xffffffff) + */ +- movl 12(%esp),%ebx /* %ebx is maxbits */ ++ movl 16(%esp),%ebx /* %ebx is maxbits */ + subl %ecx,%ebx + sbbl %ebx,%ebx + orl %ebx,%edx + +- movl 16(%esp),%eax ++ movl 20(%esp),%eax + movl %edx,(%eax) +- ++ popl %ebp + popl %ebx + ret + +@@ -80,21 +131,38 @@ dv_decode_vlc: + .type __dv_decode_vlc,@function + __dv_decode_vlc: + pushl %ebx ++ pushl %ebp ++ ++#ifdef __PIC__ ++ call __i686.get_pc_thunk.bp ++ addl $_GLOBAL_OFFSET_TABLE_, %ebp ++#endif + +- /* Args are at 8(%esp). */ +- movl 8(%esp),%eax /* %eax is bits */ ++ /* Args are at 12(%esp). */ ++ movl 12(%esp),%eax /* %eax is bits */ + + movl %eax,%edx /* %edx is class */ + andl $0xfe00,%edx + sarl $9,%edx ++#ifdef __PIC__ ++ movsbl dv_vlc_class_lookup5@GOTOFF(%ebp,%edx),%edx ++ ++ movl dv_vlc_index_mask@GOTOFF(%ebp,%edx,4),%ebx ++ movl dv_vlc_index_rshift@GOTOFF(%ebp,%edx,4),%ecx ++#else + movsbl dv_vlc_class_lookup5(%edx),%edx +- ++ + movl dv_vlc_index_mask(,%edx,4),%ebx + movl dv_vlc_index_rshift(,%edx,4),%ecx ++#endif + andl %eax,%ebx + sarl %cl,%ebx + ++#ifdef __PIC__ ++ movl dv_vlc_lookups@GOTOFF(%ebp,%edx,4),%edx ++#else + movl dv_vlc_lookups(,%edx,4),%edx ++#endif + movl (%edx,%ebx,4),%edx + + /* Now %edx holds result, like this: +@@ -112,7 +180,11 @@ __dv_decode_vlc: + movl %edx,%ecx + sarl $8,%ecx + andl $0xff,%ecx ++#ifdef __PIC__ ++ movl sign_mask@GOTOFF(%ebp,%ecx,4),%ecx ++#else + movl sign_mask(,%ecx,4),%ecx ++#endif + andl %ecx,%eax + negl %eax + sarl $31,%eax +@@ -127,9 +199,9 @@ __dv_decode_vlc: + xorl %eax,%edx + subl %eax,%edx + +- movl 12(%esp),%eax ++ movl 16(%esp),%eax + movl %edx,(%eax) +- ++ popl %ebp + popl %ebx + ret + +@@ -147,6 +219,11 @@ dv_parse_ac_coeffs_pass0: + pushl %esi + pushl %ebp + ++#ifdef __PIC__ ++ call __i686.get_pc_thunk.si ++ addl $_GLOBAL_OFFSET_TABLE_, %esi ++#endif ++ + #define ARGn(N) (20+(4*(N)))(%esp) + + /* +@@ -159,8 +236,10 @@ dv_parse_ac_coeffs_pass0: + ebp bl + */ + movl ARGn(2),%ebp ++#ifndef __PIC__ + movl ARGn(0),%esi + movl bitstream_t_buf(%esi),%esi ++#endif + movl dv_block_t_offset(%ebp),%edi + movl dv_block_t_reorder(%ebp),%ebx + +@@ -170,7 +249,11 @@ dv_parse_ac_coeffs_pass0: + + movq dv_block_t_coeffs(%ebp),%mm1 + pxor %mm0,%mm0 ++#ifdef __PIC__ ++ pand const_f_0_0_0@GOTOFF(%esi),%mm1 ++#else + pand const_f_0_0_0,%mm1 ++#endif + movq %mm1,dv_block_t_coeffs(%ebp) + movq %mm0,(dv_block_t_coeffs + 8)(%ebp) + movq %mm0,(dv_block_t_coeffs + 16)(%ebp) +@@ -191,9 +274,17 @@ dv_parse_ac_coeffs_pass0: + readloop: + movl %edi,%ecx + shrl $3,%ecx ++#ifdef __PIC__ ++ pushl %esi ++ movl ARGn(1),%esi ++ movl bitstream_t_buf(%esi),%esi ++#endif + movzbl (%esi,%ecx,1),%eax + movzbl 1(%esi,%ecx,1),%edx + movzbl 2(%esi,%ecx,1),%ecx ++#ifdef __PIC__ ++ popl %esi ++#endif + shll $16,%eax + shll $8,%edx + orl %ecx,%eax +@@ -217,7 +308,11 @@ readloop: + + /* Attempt to use the shortcut first. If it hits, then + this vlc term has been decoded. */ ++#ifdef __PIC__ ++ movl dv_vlc_class1_shortcut@GOTOFF(%esi,%ecx,4),%edx ++#else + movl dv_vlc_class1_shortcut(,%ecx,4),%edx ++#endif + test $0x80,%edx + je done_decode + +@@ -228,12 +323,19 @@ readloop: + movl %ebx,dv_block_t_reorder(%ebp) + + /* %eax is bits */ +- ++#ifdef __PIC__ ++ movsbl dv_vlc_class_lookup5@GOTOFF(%esi,%ecx),%ecx ++ ++ movl dv_vlc_index_mask@GOTOFF(%esi,%ecx,4),%ebx ++ movl dv_vlc_lookups@GOTOFF(%esi,%ecx,4),%edx ++ movl dv_vlc_index_rshift@GOTOFF(%esi,%ecx,4),%ecx ++#else + movsbl dv_vlc_class_lookup5(%ecx),%ecx + + movl dv_vlc_index_mask(,%ecx,4),%ebx + movl dv_vlc_lookups(,%ecx,4),%edx + movl dv_vlc_index_rshift(,%ecx,4),%ecx ++#endif + andl %eax,%ebx + sarl %cl,%ebx + +@@ -256,7 +358,11 @@ readloop: + movl %edx,%ecx + sarl $8,%ecx + andl $0xff,%ecx ++#ifdef __PIC__ ++ movl sign_mask@GOTOFF(%esi,%ecx,4),%ecx ++#else + movl sign_mask(,%ecx,4),%ecx ++#endif + andl %ecx,%eax + negl %eax + sarl $31,%eax +@@ -326,10 +432,20 @@ alldone: + + slowpath: + /* slow path: use dv_decode_vlc */; ++#ifdef __PIC__ ++ pushl %esi ++ leal vlc@GOTOFF(%esi),%esi ++ xchgl %esi,(%esp) /* last parameter is &vlc */ ++#else + pushl $vlc /* last parameter is &vlc */ ++#endif + pushl %edx /* bits_left */ + pushl %eax /* bits */ ++#ifdef __PIC__ ++ call dv_decode_vlc@PLT ++#else + call dv_decode_vlc ++#endif + addl $12,%esp + test $0x80,%edx /* If (vlc.run < 0) break */ + jne escape +@@ -365,6 +481,11 @@ dv_parse_video_segment: + pushl %esi + pushl %ebp + ++#ifdef __PIC__ ++ call __i686.get_pc_thunk.si ++ addl $_GLOBAL_OFFSET_TABLE_, %esi ++#endif ++ + #define ARGn(N) (20+(4*(N)))(%esp) + + movl ARGn(1),%eax /* quality */ +@@ -373,7 +494,11 @@ dv_parse_video_segment: + jz its_mono + movl $6,%ebx + its_mono: ++#ifdef __PIC__ ++ movl %ebx,n_blocks@GOTOFF(%esi) ++#else + movl %ebx,n_blocks ++#endif + + /* + * ebx seg/b +@@ -384,15 +509,22 @@ its_mono: + * ebp bl + */ + movl ARGn(0),%ebx ++#ifndef __PIC__ + movl dv_videosegment_t_bs(%ebx),%esi + movl bitstream_t_buf(%esi),%esi ++#endif + leal dv_videosegment_t_mb(%ebx),%edi + + movl $0,%eax + movl $0,%ecx + macloop: ++#ifdef __PIC__ ++ movl %eax,m@GOTOFF(%esi) ++ movl %ecx,mb_start@GOTOFF(%esi) ++#else + movl %eax,m + movl %ecx,mb_start ++#endif + + movl ARGn(0),%ebx + +@@ -400,7 +532,15 @@ macloop: + /* mb->qno = bitstream_get(bs,4); */ + movl %ecx,%edx + shr $3,%edx ++#ifdef __PIC__ ++ pushl %esi ++ movl dv_videosegment_t_bs(%ebx),%esi ++ movl bitstream_t_buf(%esi),%esi ++#endif + movzbl 3(%esi,%edx,1),%edx ++#ifdef __PIC__ ++ popl %esi ++#endif + andl $0xf,%edx + movl %edx,dv_macroblock_t_qno(%edi) + +@@ -411,7 +551,11 @@ macloop: + movl %edx,dv_macroblock_t_eob_count(%edi) + + /* mb->i = (seg->i + dv_super_map_vertical[m]) % (seg->isPAL?12:10); */ ++#ifdef __PIC__ ++ movl dv_super_map_vertical@GOTOFF(%esi,%eax,4),%edx ++#else + movl dv_super_map_vertical(,%eax,4),%edx ++#endif + movl dv_videosegment_t_i(%ebx),%ecx + addl %ecx,%edx + +@@ -422,11 +566,20 @@ skarly: + andl $1,%ecx + shll $5,%ecx /* ecx = (isPAL ? 32 : 0) */ + ++#ifdef __PIC__ ++ leal mod_10@GOTOFF(%esi,%edx),%edx ++ movzbl (%edx,%ecx,1),%edx /* uses mod_12 for PAL */ ++#else + movzbl mod_10(%edx,%ecx,1),%edx /* uses mod_12 for PAL */ ++#endif + movl %edx,dv_macroblock_t_i(%edi) + + /* mb->j = dv_super_map_horizontal[m]; */ ++#ifdef __PIC__ ++ movl dv_super_map_horizontal@GOTOFF(%esi,%eax,4),%edx ++#else + movl dv_super_map_horizontal(,%eax,4),%edx ++#endif + movl %edx,dv_macroblock_t_j(%edi) + + /* mb->k = seg->k; */ +@@ -445,12 +598,29 @@ blkloop: + +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ + */ + /* dc = bitstream_get(bs,9); */ ++#ifdef __PIC__ ++ movl mb_start@GOTOFF(%esi),%ecx ++#else + movl mb_start,%ecx ++#endif + shr $3,%ecx ++#ifdef __PIC__ ++ movzbl blk_start@GOTOFF(%esi,%ebx),%edx ++#else + movzbl blk_start(%ebx),%edx ++#endif + addl %ecx,%edx ++#ifdef __PIC__ ++ pushl %esi ++ movl ARGn(1),%esi ++ movl dv_videosegment_t_bs(%esi),%esi ++ movl bitstream_t_buf(%esi),%esi ++#endif + movzbl (%esi,%edx,1),%eax /* hi byte */ + movzbl 1(%esi,%edx,1),%ecx /* lo byte */ ++#ifdef __PIC__ ++ popl %esi ++#endif + shll $8,%eax + orl %ecx,%eax + +@@ -477,7 +647,11 @@ blkloop: + + /* bl->reorder = &dv_reorder[bl->dct_mode][1]; */ + shll $6,%eax ++#ifdef __PIC__ ++ addl dv_reorder@GOTOFF+1(%esi),%eax ++#else + addl $(dv_reorder+1),%eax ++#endif + movl %eax,dv_block_t_reorder(%ebp) + + /* bl->reorder_sentinel = bl->reorder + 63; */ +@@ -485,13 +659,22 @@ blkloop: + movl %eax,dv_block_t_reorder_sentinel(%ebp) + + /* bl->offset= mb_start + dv_parse_bit_start[b]; */ ++#ifdef __PIC__ ++ movl mb_start@GOTOFF(%esi),%ecx ++ movl dv_parse_bit_start@GOTOFF(%esi,%ebx,4),%eax ++#else + movl mb_start,%ecx + movl dv_parse_bit_start(,%ebx,4),%eax ++#endif + addl %ecx,%eax + movl %eax,dv_block_t_offset(%ebp) + + /* bl->end= mb_start + dv_parse_bit_end[b]; */ ++#ifdef __PIC__ ++ movl dv_parse_bit_end@GOTOFF(%esi,%ebx,4),%eax ++#else + movl dv_parse_bit_end(,%ebx,4),%eax ++#endif + addl %ecx,%eax + movl %eax,dv_block_t_end(%ebp) + +@@ -503,7 +686,11 @@ blkloop: + /* no AC pass. Just zero out the remaining coeffs */ + movq dv_block_t_coeffs(%ebp),%mm1 + pxor %mm0,%mm0 ++#ifdef __PIC__ ++ pand const_f_0_0_0@GOTOFF(%esi),%mm1 ++#else + pand const_f_0_0_0,%mm1 ++#endif + movq %mm1,dv_block_t_coeffs(%ebp) + movq %mm0,(dv_block_t_coeffs + 8)(%ebp) + movq %mm0,(dv_block_t_coeffs + 16)(%ebp) +@@ -528,18 +715,31 @@ do_ac_pass: + pushl %ebp + pushl %edi + pushl %eax ++#ifdef __PIC__ ++ call dv_parse_ac_coeffs_pass0@PLT ++#else + call dv_parse_ac_coeffs_pass0 ++#endif + addl $12,%esp + done_ac: + ++#ifdef __PIC__ ++ movl n_blocks@GOTOFF(%esi),%eax ++#else + movl n_blocks,%eax ++#endif + addl $dv_block_t_size,%ebp + incl %ebx + cmpl %eax,%ebx + jnz blkloop + ++#ifdef __PIC__ ++ movl m@GOTOFF(%esi),%eax ++ movl mb_start@GOTOFF(%esi),%ecx ++#else + movl m,%eax + movl mb_start,%ecx ++#endif + addl $(8 * 80),%ecx + addl $dv_macroblock_t_size,%edi + incl %eax +@@ -557,7 +757,11 @@ done_ac: + + andl $DV_QUALITY_AC_MASK,%eax + cmpl $DV_QUALITY_AC_2,%eax ++#ifdef __PIC__ ++ jz dv_parse_ac_coeffs@PLT ++#else + jz dv_parse_ac_coeffs ++#endif + movl $0,%eax + ret + diff --git a/libdv-1.0.0-pic.patch b/libdv-1.0.0-pic.patch new file mode 100644 index 0000000..c847893 --- /dev/null +++ b/libdv-1.0.0-pic.patch @@ -0,0 +1,1630 @@ +--- libdv-0.104-old/libdv/asm_common.S ++++ libdv-0.104/libdv/asm_common.S +@@ -0,0 +1,29 @@ ++/* public domain, do what you want */ ++ ++#ifdef __PIC__ ++# define MUNG(sym) sym##@GOTOFF(%ebp) ++# define MUNG_ARR(sym, args...) sym##@GOTOFF(%ebp,##args) ++#else ++# define MUNG(sym) sym ++# define MUNG_ARR(sym, args...) sym(,##args) ++#endif ++ ++#ifdef __PIC__ ++# undef __i686 /* gcc define gets in our way */ ++# define LOAD_PIC_REG(reg) \ ++ .ifndef __i686.get_pc_thunk.reg; \ ++ .section .gnu.linkonce.t.__i686.get_pc_thunk.reg,"ax",@progbits; \ ++ .global __i686.get_pc_thunk.reg; \ ++ .hidden __i686.get_pc_thunk.reg; \ ++ .type __i686.get_pc_thunk.reg,@function; \ ++ __i686.get_pc_thunk.reg: \ ++ movl (%esp), %e##reg; \ ++ ret; \ ++ .size __i686.get_pc_thunk.reg,.-__i686.get_pc_thunk.reg; \ ++ .previous; \ ++ .endif; \ ++ call __i686.get_pc_thunk.reg; \ ++ addl $_GLOBAL_OFFSET_TABLE_, %e##reg ++#else ++# define LOAD_PIC_REG(reg) ++#endif +--- libdv-0.104-old/libdv/dct_block_mmx.S ++++ libdv-0.104/libdv/dct_block_mmx.S +@@ -53,19 +53,22 @@ scratch2: .quad 0 + + .section .note.GNU-stack, "", @progbits + ++#include "asm_common.S" ++ + .text + + .align 8 + .global _dv_dct_88_block_mmx + .hidden _dv_dct_88_block_mmx + .type _dv_dct_88_block_mmx,@function + _dv_dct_88_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + +- movl 8(%ebp), %esi # source ++ LOAD_PIC_REG(bp) ++ ++ movl 12(%esp), %esi # source + + # column 0 + movq 16*0(%esi), %mm0 # v0 +@@ -86,22 +91,22 @@ _dv_dct_88_block_mmx: + + movq 16*3(%esi), %mm5 # v3 + movq 16*4(%esi), %mm7 # v4 +- movq %mm7, scratch1 # scratch1: v4 ; ++ movq %mm7, MUNG(scratch1) # scratch1: v4 ; + movq %mm5, %mm7 # duplicate v3 +- paddw scratch1, %mm5 # v03: v3+v4 +- psubw scratch1, %mm7 # v04: v3-v4 +- movq %mm5, scratch2 # scratch2: v03 ++ paddw MUNG(scratch1), %mm5 # v03: v3+v4 ++ psubw MUNG(scratch1), %mm7 # v04: v3-v4 ++ movq %mm5, MUNG(scratch2) # scratch2: v03 + movq %mm0, %mm5 # mm5: v00 + +- paddw scratch2, %mm0 # v10: v00+v03 +- psubw scratch2, %mm5 # v13: v00-v03 +- movq %mm3, scratch3 # scratch3: v02 ++ paddw MUNG(scratch2), %mm0 # v10: v00+v03 ++ psubw MUNG(scratch2), %mm5 # v13: v00-v03 ++ movq %mm3, MUNG(scratch3) # scratch3: v02 + movq %mm1, %mm3 # duplicate v01 + +- paddw scratch3, %mm1 # v11: v01+v02 +- psubw scratch3, %mm3 # v12: v01-v02 ++ paddw MUNG(scratch3), %mm1 # v11: v01+v02 ++ psubw MUNG(scratch3), %mm3 # v12: v01-v02 + +- movq %mm6, scratch4 # scratch4: v05 ++ movq %mm6, MUNG(scratch4) # scratch4: v05 + movq %mm0, %mm6 # duplicate v10 + + paddw %mm1, %mm0 # v10+v11 +@@ -111,10 +116,10 @@ _dv_dct_88_block_mmx: + movq %mm6, 16*4(%esi) # out4: v10-v11 + + movq %mm4, %mm0 # mm0: v06 +- paddw scratch4, %mm4 # v15: v05+v06 ++ paddw MUNG(scratch4), %mm4 # v15: v05+v06 + paddw %mm2, %mm0 # v16: v07+v06 + +- pmulhw WA3, %mm4 # v35~: WA3*v15 ++ pmulhw MUNG(WA3), %mm4 # v35~: WA3*v15 + psllw $1, %mm4 # v35: compensate the coeefient scale + + movq %mm4, %mm6 # duplicate v35 +@@ -123,7 +128,7 @@ _dv_dct_88_block_mmx: + + paddw %mm5, %mm3 # v22: v12+v13 + +- pmulhw WA1, %mm3 # v32~: WA1*v22 ++ pmulhw MUNG(WA1), %mm3 # v32~: WA1*v22 + psllw $16-NSHIFT, %mm3 # v32: compensate the coeefient scale + movq %mm5, %mm6 # duplicate v13 + +@@ -134,13 +139,13 @@ _dv_dct_88_block_mmx: + movq %mm6, 16*6(%esi) # out6: v13-v32 + + +- paddw scratch4, %mm7 # v14n: v04+v05 ++ paddw MUNG(scratch4), %mm7 # v14n: v04+v05 + movq %mm0, %mm5 # duplicate v16 + + psubw %mm7, %mm0 # va1: v16-v14n +- pmulhw WA5, %mm0 # va0~: va1*WA5 +- pmulhw WA4, %mm5 # v36~~: v16*WA4 +- pmulhw WA2, %mm7 # v34~~: v14n*WA2 ++ pmulhw MUNG(WA5), %mm0 # va0~: va1*WA5 ++ pmulhw MUNG(WA4), %mm5 # v36~~: v16*WA4 ++ pmulhw MUNG(WA2), %mm7 # v34~~: v14n*WA2 + psllw $16-WA4_SHIFT, %mm5 # v36: compensate the coeefient scale + psllw $16-NSHIFT, %mm7 # v34: compensate the coeefient scale + +@@ -188,22 +193,22 @@ _dv_dct_88_block_mmx: + + movq 16*3(%esi), %mm5 # v3 + movq 16*4(%esi), %mm7 # v4 +- movq %mm7, scratch1 # scratch1: v4 ; ++ movq %mm7, MUNG(scratch1) # scratch1: v4 ; + movq %mm5, %mm7 # duplicate v3 +- paddw scratch1, %mm5 # v03: v3+v4 +- psubw scratch1, %mm7 # v04: v3-v4 +- movq %mm5, scratch2 # scratch2: v03 ++ paddw MUNG(scratch1), %mm5 # v03: v3+v4 ++ psubw MUNG(scratch1), %mm7 # v04: v3-v4 ++ movq %mm5, MUNG(scratch2) # scratch2: v03 + movq %mm0, %mm5 # mm5: v00 + +- paddw scratch2, %mm0 # v10: v00+v03 +- psubw scratch2, %mm5 # v13: v00-v03 +- movq %mm3, scratch3 # scratc3: v02 ++ paddw MUNG(scratch2), %mm0 # v10: v00+v03 ++ psubw MUNG(scratch2), %mm5 # v13: v00-v03 ++ movq %mm3, MUNG(scratch3) # scratc3: v02 + movq %mm1, %mm3 # duplicate v01 + +- paddw scratch3, %mm1 # v11: v01+v02 +- psubw scratch3, %mm3 # v12: v01-v02 ++ paddw MUNG(scratch3), %mm1 # v11: v01+v02 ++ psubw MUNG(scratch3), %mm3 # v12: v01-v02 + +- movq %mm6, scratch4 # scratc4: v05 ++ movq %mm6, MUNG(scratch4) # scratc4: v05 + movq %mm0, %mm6 # duplicate v10 + + paddw %mm1, %mm0 # v10+v11 +@@ -213,10 +218,10 @@ _dv_dct_88_block_mmx: + movq %mm6, 16*4(%esi) # out4: v10-v11 + + movq %mm4, %mm0 # mm0: v06 +- paddw scratch4, %mm4 # v15: v05+v06 ++ paddw MUNG(scratch4), %mm4 # v15: v05+v06 + paddw %mm2, %mm0 # v16: v07+v06 + +- pmulhw WA3, %mm4 # v35~: WA3*v15 ++ pmulhw MUNG(WA3), %mm4 # v35~: WA3*v15 + psllw $16-NSHIFT, %mm4 # v35: compensate the coeefient scale + + movq %mm4, %mm6 # duplicate v35 +@@ -225,7 +230,7 @@ _dv_dct_88_block_mmx: + + paddw %mm5, %mm3 # v22: v12+v13 + +- pmulhw WA1, %mm3 # v32~: WA3*v15 ++ pmulhw MUNG(WA1), %mm3 # v32~: WA3*v15 + psllw $16-NSHIFT, %mm3 # v32: compensate the coeefient scale + movq %mm5, %mm6 # duplicate v13 + +@@ -235,13 +240,13 @@ _dv_dct_88_block_mmx: + movq %mm5, 16*2(%esi) # out2: v13+v32 + movq %mm6, 16*6(%esi) # out6: v13-v32 + +- paddw scratch4, %mm7 # v14n: v04+v05 ++ paddw MUNG(scratch4), %mm7 # v14n: v04+v05 + movq %mm0, %mm5 # duplicate v16 + + psubw %mm7, %mm0 # va1: v16-v14n +- pmulhw WA2, %mm7 # v34~~: v14n*WA2 +- pmulhw WA5, %mm0 # va0~: va1*WA5 +- pmulhw WA4, %mm5 # v36~~: v16*WA4 ++ pmulhw MUNG(WA2), %mm7 # v34~~: v14n*WA2 ++ pmulhw MUNG(WA5), %mm0 # va0~: va1*WA5 ++ pmulhw MUNG(WA4), %mm5 # v36~~: v16*WA4 + psllw $16-NSHIFT, %mm7 + psllw $16-WA4_SHIFT, %mm5 # v36: compensate the coeffient + # scale note that WA4 is shifted 1 bit less than the others +@@ -748,11 +755,12 @@ _dv_dct_block_mmx_postscale_88: + _dv_dct_248_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + pushl %edi + +- movl 8(%ebp), %esi # source ++ LOAD_PIC_REG(bp) ++ ++ movl 16(%esp), %esi # source + + # column 0 + +@@ -779,7 +789,7 @@ _dv_dct_248_block_mmx: + paddw %mm1, %mm0 # v20: v10+v11 + psubw %mm1, %mm3 # v21: v10-v11 + +- pmulhw WA1, %mm5 # v32~: WA1*v22 ++ pmulhw MUNG(WA1), %mm5 # v32~: WA1*v22 + movq %mm4, %mm2 + psllw $16-NSHIFT, %mm5 # v32: compensate the coeffient scale + +@@ -818,7 +828,7 @@ _dv_dct_248_block_mmx: + paddw %mm1, %mm0 # v20: v10+v11 + psubw %mm1, %mm3 # v21: v10-v11 + +- pmulhw WA1, %mm5 # v32~: WA1*v22 ++ pmulhw MUNG(WA1), %mm5 # v32~: WA1*v22 + movq %mm4, %mm2 + psllw $16-NSHIFT, %mm5 # v32: compensate the coeffient scale + +@@ -855,7 +865,7 @@ _dv_dct_248_block_mmx: + paddw %mm1, %mm0 # v20: v10+v11 + psubw %mm1, %mm3 # v21: v10-v11 + +- pmulhw WA1, %mm5 # v32~: WA1*v22 ++ pmulhw MUNG(WA1), %mm5 # v32~: WA1*v22 + movq %mm4, %mm2 + psllw $16-NSHIFT, %mm5 # v32: compensate the coeffient scale + +@@ -892,7 +902,7 @@ _dv_dct_248_block_mmx: + paddw %mm1, %mm0 # v20: v10+v11 + psubw %mm1, %mm3 # v21: v10-v11 + +- pmulhw WA1, %mm5 # v32~: WA1*v22 ++ pmulhw MUNG(WA1), %mm5 # v32~: WA1*v22 + movq %mm4, %mm2 + psllw $16-NSHIFT, %mm5 # v32: compensate the coeffient scale + +--- libdv-0.104-old/libdv/dv.c ++++ libdv-0.104/libdv/dv.c +@@ -205,6 +205,9 @@ dv_reconfigure(int clamp_luma, int clamp + } /* dv_reconfigure */ + + ++extern uint8_t dv_quant_offset[4]; ++extern uint8_t dv_quant_shifts[22][4]; ++ + static inline void + dv_decode_macroblock(dv_decoder_t *dv, dv_macroblock_t *mb, unsigned int quality) { + int i; +@@ -218,7 +221,7 @@ dv_decode_macroblock(dv_decoder_t *dv, d + dv_idct_248 (co248, mb->b[i].coeffs); + } else { + #if ARCH_X86 +- _dv_quant_88_inverse_x86(mb->b[i].coeffs,mb->qno,mb->b[i].class_no); ++ _dv_quant_88_inverse_x86(mb->b[i].coeffs,mb->qno,mb->b[i].class_no,dv_quant_offset,dv_quant_shifts); + _dv_idct_88(mb->b[i].coeffs); + #elif ARCH_X86_64 + _dv_quant_88_inverse_x86_64(mb->b[i].coeffs,mb->qno,mb->b[i].class_no); +@@ -250,7 +253,7 @@ dv_decode_video_segment(dv_decoder_t *dv + dv_idct_248 (co248, mb->b[b].coeffs); + } else { + #if ARCH_X86 +- _dv_quant_88_inverse_x86(bl->coeffs,mb->qno,bl->class_no); ++ _dv_quant_88_inverse_x86(bl->coeffs,mb->qno,bl->class_no,dv_quant_offset,dv_quant_shifts); + _dv_weight_88_inverse(bl->coeffs); + _dv_idct_88(bl->coeffs); + #elif ARCH_X86_64 +--- libdv-0.104-old/libdv/encode.c ++++ libdv-0.104/libdv/encode.c +@@ -521,7 +521,8 @@ static void reorder_block(dv_block_t *bl + } + + extern unsigned long _dv_vlc_encode_block_mmx(dv_coeff_t* coeffs, +- dv_vlc_entry_t ** out); ++ dv_vlc_entry_t ** out, ++ dv_vlc_entry_t * lookup); + + extern unsigned long _dv_vlc_encode_block_mmx_x86_64(dv_coeff_t* coeffs, + dv_vlc_entry_t ** out); +@@ -558,7 +559,7 @@ static unsigned long vlc_encode_block(dv + #elif ARCH_X86 + int num_bits; + +- num_bits = _dv_vlc_encode_block_mmx(coeffs, &o); ++ num_bits = _dv_vlc_encode_block_mmx(coeffs, &o, vlc_encode_lookup); + emms(); + #else + int num_bits; +@@ -574,7 +575,7 @@ static unsigned long vlc_encode_block(dv + return num_bits; + } + +-extern unsigned long _dv_vlc_num_bits_block_x86(dv_coeff_t* coeffs); ++extern unsigned long _dv_vlc_num_bits_block_x86(dv_coeff_t* coeffs, unsigned char* lookup); + extern unsigned long _dv_vlc_num_bits_block_x86_64(dv_coeff_t* coeffs); + + extern unsigned long _dv_vlc_num_bits_block(dv_coeff_t* coeffs) +@@ -600,7 +601,7 @@ extern unsigned long _dv_vlc_num_bits_bl + #elif ARCH_X86_64 + return _dv_vlc_num_bits_block_x86_64(coeffs); + #else +- return _dv_vlc_num_bits_block_x86(coeffs); ++ return _dv_vlc_num_bits_block_x86(coeffs, vlc_num_bits_lookup); + #endif + } + +--- libdv-0.104-old/libdv/encode_x86.S ++++ libdv-0.104/libdv/encode_x86.S +@@ -23,9 +23,6 @@ + * The libdv homepage is http://libdv.sourceforge.net/. + */ + +-.data +-ALLONE: .word 1,1,1,1 +-VLCADDMASK: .byte 255,0,0,0,255,0,0,0 + + + .section .note.GNU-stack, "", @progbits +@@ -45,11 +43,14 @@ _dv_vlc_encode_block_mmx: + + movl $63, %ecx + +- movl vlc_encode_lookup, %esi ++ movl 4+4*4+8(%esp), %esi # vlc_encode_lookup + + pxor %mm0, %mm0 + pxor %mm2, %mm2 +- movq VLCADDMASK, %mm1 ++ pushl $0x000000FF # these four lines ++ pushl $0x000000FF # load VLCADDMASK ++ movq (%esp), %mm1 # into %mm1 off the stack ++ addl $8, %esp # --> no TEXTRELs + xorl %ebp, %ebp + subl $8, %edx + vlc_encode_block_mmx_loop: +@@ -121,7 +124,7 @@ _dv_vlc_num_bits_block_x86: + addl $2, %edi + + movl $63, %ecx +- movl vlc_num_bits_lookup, %esi ++ movl 4+4*4+4(%esp), %esi # vlc_num_bits_lookup + + vlc_num_bits_block_x86_loop: + movw (%edi), %ax +@@ -579,8 +590,11 @@ _dv_need_dct_248_mmx_rows: + paddw %mm5, %mm1 + + paddw %mm1, %mm0 +- +- pmaddwd ALLONE, %mm0 ++ ++ pushl $0x00010001 # these four lines ++ pushl $0x00010001 # load ALLONE ++ pmaddwd (%esp), %mm0 # into %mm0 off the stack ++ addl $8, %esp # --> no TEXTRELs + movq %mm0, %mm1 + psrlq $32, %mm1 + paddd %mm1, %mm0 +--- libdv-0.104-old/libdv/idct_block_mmx.S ++++ libdv-0.104/libdv/idct_block_mmx.S +@@ -8,17 +8,21 @@ + + .section .note.GNU-stack, "", @progbits + ++#include "asm_common.S" ++ + .text + .align 4 + .global _dv_idct_block_mmx + .hidden _dv_idct_block_mmx + .type _dv_idct_block_mmx,@function + _dv_idct_block_mmx: + pushl %ebp +- movl %esp,%ebp + pushl %esi +- leal preSC, %ecx +- movl 8(%ebp),%esi /* source matrix */ ++ ++ LOAD_PIC_REG(bp) ++ ++ leal MUNG(preSC), %ecx ++ movl 12(%esp),%esi /* source matrix */ + + /* + * column 0: even part +@@ -35,7 +41,7 @@ _dv_idct_block_mmx: + movq %mm1, %mm2 /* added 11/1/96 */ + pmulhw 8*8(%esi),%mm5 /* V8 */ + psubsw %mm0, %mm1 /* V16 */ +- pmulhw x5a825a825a825a82, %mm1 /* 23170 ->V18 */ ++ pmulhw MUNG(x5a825a825a825a82), %mm1 /* 23170 ->V18 */ + paddsw %mm0, %mm2 /* V17 */ + movq %mm2, %mm0 /* duplicate V17 */ + psraw $1, %mm2 /* t75=t82 */ +@@ -76,7 +82,7 @@ _dv_idct_block_mmx: + paddsw %mm0, %mm3 /* V29 ; free mm0 */ + movq %mm7, %mm1 /* duplicate V26 */ + psraw $1, %mm3 /* t91=t94 */ +- pmulhw x539f539f539f539f,%mm7 /* V33 */ ++ pmulhw MUNG(x539f539f539f539f),%mm7 /* V33 */ + psraw $1, %mm1 /* t96 */ + movq %mm5, %mm0 /* duplicate V2 */ + psraw $2, %mm4 /* t85=t87 */ +@@ -84,15 +90,15 @@ _dv_idct_block_mmx: + psubsw %mm4, %mm0 /* V28 ; free mm4 */ + movq %mm0, %mm2 /* duplicate V28 */ + psraw $1, %mm5 /* t90=t93 */ +- pmulhw x4546454645464546,%mm0 /* V35 */ ++ pmulhw MUNG(x4546454645464546),%mm0 /* V35 */ + psraw $1, %mm2 /* t97 */ + movq %mm5, %mm4 /* duplicate t90=t93 */ + psubsw %mm2, %mm1 /* V32 ; free mm2 */ +- pmulhw x61f861f861f861f8,%mm1 /* V36 */ ++ pmulhw MUNG(x61f861f861f861f8),%mm1 /* V36 */ + psllw $1, %mm7 /* t107 */ + paddsw %mm3, %mm5 /* V31 */ + psubsw %mm3, %mm4 /* V30 ; free mm3 */ +- pmulhw x5a825a825a825a82,%mm4 /* V34 */ ++ pmulhw MUNG(x5a825a825a825a82),%mm4 /* V34 */ + nop + psubsw %mm1, %mm0 /* V38 */ + psubsw %mm7, %mm1 /* V37 ; free mm7 */ +@@ -159,7 +165,7 @@ _dv_idct_block_mmx: + psubsw %mm7, %mm1 /* V50 */ + pmulhw 8*9(%esi), %mm5 /* V9 */ + paddsw %mm7, %mm2 /* V51 */ +- pmulhw x5a825a825a825a82, %mm1 /* 23170 ->V52 */ ++ pmulhw MUNG(x5a825a825a825a82), %mm1 /* 23170 ->V52 */ + movq %mm2, %mm6 /* duplicate V51 */ + psraw $1, %mm2 /* t138=t144 */ + movq %mm3, %mm4 /* duplicate V1 */ +@@ -200,11 +206,11 @@ _dv_idct_block_mmx: + * even more by doing the correction step in a later stage when the number + * is actually multiplied by 16 + */ +- paddw x0005000200010001, %mm4 ++ paddw MUNG(x0005000200010001), %mm4 + psubsw %mm6, %mm3 /* V60 ; free mm6 */ + psraw $1, %mm0 /* t154=t156 */ + movq %mm3, %mm1 /* duplicate V60 */ +- pmulhw x539f539f539f539f, %mm1 /* V67 */ ++ pmulhw MUNG(x539f539f539f539f), %mm1 /* V67 */ + movq %mm5, %mm6 /* duplicate V3 */ + psraw $2, %mm4 /* t148=t150 */ + paddsw %mm4, %mm5 /* V61 */ +@@ -213,13 +219,13 @@ _dv_idct_block_mmx: + psllw $1, %mm1 /* t169 */ + paddsw %mm0, %mm5 /* V65 -> result */ + psubsw %mm0, %mm4 /* V64 ; free mm0 */ +- pmulhw x5a825a825a825a82, %mm4 /* V68 */ ++ pmulhw MUNG(x5a825a825a825a82), %mm4 /* V68 */ + psraw $1, %mm3 /* t158 */ + psubsw %mm6, %mm3 /* V66 */ + movq %mm5, %mm2 /* duplicate V65 */ +- pmulhw x61f861f861f861f8, %mm3 /* V70 */ ++ pmulhw MUNG(x61f861f861f861f8), %mm3 /* V70 */ + psllw $1, %mm6 /* t165 */ +- pmulhw x4546454645464546, %mm6 /* V69 */ ++ pmulhw MUNG(x4546454645464546), %mm6 /* V69 */ + psraw $1, %mm2 /* t172 */ + /* moved from next block */ + movq 8*5(%esi), %mm0 /* V56 */ +@@ -344,7 +350,7 @@ _dv_idct_block_mmx: + * movq 8*13(%esi), %mm4 tmt13 + */ + psubsw %mm4, %mm3 /* V134 */ +- pmulhw x5a825a825a825a82, %mm3 /* 23170 ->V136 */ ++ pmulhw MUNG(x5a825a825a825a82), %mm3 /* 23170 ->V136 */ + movq 8*9(%esi), %mm6 /* tmt9 */ + paddsw %mm4, %mm5 /* V135 ; mm4 free */ + movq %mm0, %mm4 /* duplicate tmt1 */ +@@ -373,17 +379,17 @@ _dv_idct_block_mmx: + psubsw %mm7, %mm0 /* V144 */ + movq %mm0, %mm3 /* duplicate V144 */ + paddsw %mm7, %mm2 /* V147 ; free mm7 */ +- pmulhw x539f539f539f539f, %mm0 /* 21407-> V151 */ ++ pmulhw MUNG(x539f539f539f539f), %mm0 /* 21407-> V151 */ + movq %mm1, %mm7 /* duplicate tmt3 */ + paddsw %mm5, %mm7 /* V145 */ + psubsw %mm5, %mm1 /* V146 ; free mm5 */ + psubsw %mm1, %mm3 /* V150 */ + movq %mm7, %mm5 /* duplicate V145 */ +- pmulhw x4546454645464546, %mm1 /* 17734-> V153 */ ++ pmulhw MUNG(x4546454645464546), %mm1 /* 17734-> V153 */ + psubsw %mm2, %mm5 /* V148 */ +- pmulhw x61f861f861f861f8, %mm3 /* 25080-> V154 */ ++ pmulhw MUNG(x61f861f861f861f8), %mm3 /* 25080-> V154 */ + psllw $2, %mm0 /* t311 */ +- pmulhw x5a825a825a825a82, %mm5 /* 23170-> V152 */ ++ pmulhw MUNG(x5a825a825a825a82), %mm5 /* 23170-> V152 */ + paddsw %mm2, %mm7 /* V149 ; free mm2 */ + psllw $1, %mm1 /* t313 */ + nop /* without the nop - freeze here for one clock */ +@@ -409,7 +415,7 @@ _dv_idct_block_mmx: + paddsw %mm3, %mm6 /* V164 ; free mm3 */ + movq %mm4, %mm3 /* duplicate V142 */ + psubsw %mm5, %mm4 /* V165 ; free mm5 */ +- movq %mm2, scratch7 /* out7 */ ++ movq %mm2, MUNG(scratch7) /* out7 */ + psraw $4, %mm6 + psraw $4, %mm4 + paddsw %mm5, %mm3 /* V162 */ +@@ -420,11 +426,11 @@ _dv_idct_block_mmx: + */ + movq %mm6, 8*9(%esi) /* out9 */ + paddsw %mm1, %mm0 /* V161 */ +- movq %mm3, scratch5 /* out5 */ ++ movq %mm3, MUNG(scratch5) /* out5 */ + psubsw %mm1, %mm5 /* V166 ; free mm1 */ + movq %mm4, 8*11(%esi) /* out11 */ + psraw $4, %mm5 +- movq %mm0, scratch3 /* out3 */ ++ movq %mm0, MUNG(scratch3) /* out3 */ + movq %mm2, %mm4 /* duplicate V140 */ + movq %mm5, 8*13(%esi) /* out13 */ + paddsw %mm7, %mm2 /* V160 */ +@@ -434,7 +440,7 @@ _dv_idct_block_mmx: + /* moved from the next block */ + movq 8*3(%esi), %mm7 + psraw $4, %mm4 +- movq %mm2, scratch1 /* out1 */ ++ movq %mm2, MUNG(scratch1) /* out1 */ + /* moved from the next block */ + movq %mm0, %mm1 + movq %mm4, 8*15(%esi) /* out15 */ +@@ -491,15 +497,15 @@ _dv_idct_block_mmx: + paddsw %mm4, %mm3 /* V113 ; free mm4 */ + movq %mm0, %mm4 /* duplicate V110 */ + paddsw %mm1, %mm2 /* V111 */ +- pmulhw x539f539f539f539f, %mm0 /* 21407-> V117 */ ++ pmulhw MUNG(x539f539f539f539f), %mm0 /* 21407-> V117 */ + psubsw %mm1, %mm5 /* V112 ; free mm1 */ + psubsw %mm5, %mm4 /* V116 */ + movq %mm2, %mm1 /* duplicate V111 */ +- pmulhw x4546454645464546, %mm5 /* 17734-> V119 */ ++ pmulhw MUNG(x4546454645464546), %mm5 /* 17734-> V119 */ + psubsw %mm3, %mm2 /* V114 */ +- pmulhw x61f861f861f861f8, %mm4 /* 25080-> V120 */ ++ pmulhw MUNG(x61f861f861f861f8), %mm4 /* 25080-> V120 */ + paddsw %mm3, %mm1 /* V115 ; free mm3 */ +- pmulhw x5a825a825a825a82, %mm2 /* 23170-> V118 */ ++ pmulhw MUNG(x5a825a825a825a82), %mm2 /* 23170-> V118 */ + psllw $2, %mm0 /* t266 */ + movq %mm1, (%esi) /* save V115 */ + psllw $1, %mm5 /* t268 */ +@@ -517,7 +523,7 @@ _dv_idct_block_mmx: + movq %mm6, %mm3 /* duplicate tmt4 */ + psubsw %mm0, %mm6 /* V100 */ + paddsw %mm0, %mm3 /* V101 ; free mm0 */ +- pmulhw x5a825a825a825a82, %mm6 /* 23170 ->V102 */ ++ pmulhw MUNG(x5a825a825a825a82), %mm6 /* 23170 ->V102 */ + movq %mm7, %mm5 /* duplicate tmt0 */ + movq 8*8(%esi), %mm1 /* tmt8 */ + paddsw %mm1, %mm7 /* V103 */ +@@ -551,10 +557,10 @@ _dv_idct_block_mmx: + movq 8*2(%esi), %mm3 /* V123 */ + paddsw %mm4, %mm7 /* out0 */ + /* moved up from next block */ +- movq scratch3, %mm0 ++ movq MUNG(scratch3), %mm0 + psraw $4, %mm7 + /* moved up from next block */ +- movq scratch5, %mm6 ++ movq MUNG(scratch5), %mm6 + psubsw %mm4, %mm1 /* out14 ; free mm4 */ + paddsw %mm3, %mm5 /* out2 */ + psraw $4, %mm1 +@@ -565,7 +571,7 @@ _dv_idct_block_mmx: + movq %mm5, 8*2(%esi) /* out2 ; free mm5 */ + psraw $4, %mm2 + /* moved up to the prev block */ +- movq scratch7, %mm4 ++ movq MUNG(scratch7), %mm4 + /* moved up to the prev block */ + psraw $4, %mm0 + movq %mm2, 8*12(%esi) /* out12 ; free mm2 */ +@@ -579,7 +585,7 @@ _dv_idct_block_mmx: + * psraw $4, %mm0 + * psraw $4, %mm6 + */ +- movq scratch1, %mm1 ++ movq MUNG(scratch1), %mm1 + psraw $4, %mm4 + movq %mm0, 8*3(%esi) /* out3 */ + psraw $4, %mm1 +--- libdv-0.104-old/libdv/parse.c ++++ libdv-0.104/libdv/parse.c +@@ -477,6 +477,13 @@ dv_parse_ac_coeffs(dv_videosegment_t *se + exit(0); + #endif + } /* dv_parse_ac_coeffs */ ++#if defined __GNUC__ && __ELF__ ++# define dv_strong_hidden_alias(name, aliasname) \ ++ extern __typeof (name) aliasname __attribute__ ((alias (#name), visibility ("hidden"))) ++dv_strong_hidden_alias(dv_parse_ac_coeffs, asm_dv_parse_ac_coeffs); ++#else ++int asm_dv_parse_ac_coeffs(dv_videosegment_t *seg) { return dv_parse_ac_coeffs(seg); } ++#endif + + /* --------------------------------------------------------------------------- + */ +--- libdv-0.104-old/libdv/quant.c ++++ libdv-0.104/libdv/quant.c +@@ -144,7 +144,7 @@ uint8_t dv_quant_offset[4] = { 6,3,0,1 + uint32_t dv_quant_248_mul_tab [2] [22] [64]; + uint32_t dv_quant_88_mul_tab [2] [22] [64]; + +-extern void _dv_quant_x86(dv_coeff_t *block,int qno,int klass); ++extern void _dv_quant_x86(dv_coeff_t *block,int qno,int klass,uint8_t *dv_quant_offset,uint8_t *dv_quant_shifts); + extern void _dv_quant_x86_64(dv_coeff_t *block,int qno,int klass); + static void quant_248_inverse_std(dv_coeff_t *block,int qno,int klass,dv_248_coeff_t *co); + static void quant_248_inverse_mmx(dv_coeff_t *block,int qno,int klass,dv_248_coeff_t *co); +@@ -210,7 +210,7 @@ void _dv_quant(dv_coeff_t *block,int qno + _dv_quant_x86_64(block, qno, klass); + emms(); + #else +- _dv_quant_x86(block, qno, klass); ++ _dv_quant_x86(block, qno, klass, dv_quant_offset, dv_quant_shifts); + emms(); + #endif + } +--- libdv-0.104-old/libdv/quant.h ++++ libdv-0.104/libdv/quant.h +@@ -27,7 +27,7 @@ extern void _dv_quant(dv_coeff_t *block, + extern void _dv_quant_88_inverse(dv_coeff_t *block,int qno,int klass); + extern void (*_dv_quant_248_inverse) (dv_coeff_t *block,int qno,int klass, + dv_248_coeff_t *co); +-extern void _dv_quant_88_inverse_x86(dv_coeff_t *block,int qno,int klass); ++extern void _dv_quant_88_inverse_x86(dv_coeff_t *block,int qno,int klass, uint8_t *offset, uint8_t *shifts); + extern void _dv_quant_88_inverse_x86_64(dv_coeff_t *block,int qno,int klass); + extern void dv_quant_init (void); + #ifdef __cplusplus +--- libdv-0.104-old/libdv/quant_x86.S ++++ libdv-0.104/libdv/quant_x86.S +@@ -71,10 +73,13 @@ _dv_quant_88_inverse_x86: + + /* pq = dv_quant_shifts[qno + dv_quant_offset[class]]; */ + movl ARGn(1),%eax /* qno */ ++ movl ARGn(3),%ebx /* dv_quant_offset */ ++ addl ARGn(2),%ebx /* class */ ++ movzbl (%ebx),%ecx + movl ARGn(2),%ebx /* class */ +- movzbl dv_quant_offset(%ebx),%ecx + addl %ecx,%eax +- leal dv_quant_shifts(,%eax,4),%edx /* edx is pq */ ++ movl ARGn(4),%edx /* dv_quant_shifts */ ++ leal (%edx,%eax,4),%edx /* edx is pq */ + + /* extra = (class == 3); */ + /* 0 1 2 3 */ +@@ -212,11 +219,13 @@ _dv_quant_x86: + + /* pq = dv_quant_shifts[qno + dv_quant_offset[class]]; */ + movl ARGn(1),%eax /* qno */ ++ movl ARGn(3),%ebx /* offset */ ++ addl ARGn(2),%ebx /* class */ ++ movzbl (%ebx),%ecx + movl ARGn(2),%ebx /* class */ +- +- movzbl dv_quant_offset(%ebx),%ecx ++ movl ARGn(4),%edx /* shifts */ + addl %ecx,%eax +- leal dv_quant_shifts(,%eax,4),%edx /* edx is pq */ ++ leal (%edx,%eax,4),%edx /* edx is pq */ + + /* extra = (class == 3); */ + /* 0 1 2 3 */ +--- libdv-0.104-old/libdv/rgbtoyuv.S ++++ libdv-0.104/libdv/rgbtoyuv.S +@@ -41,9 +41,6 @@ + #define DV_WIDTH_SHORT_HALF 720 + #define DV_WIDTH_BYTE_HALF 360 + +-.global _dv_rgbtoycb_mmx +-# .global yuvtoycb_mmx +- + .data + + .align 8 +@@ -110,25 +107,26 @@ VR0GR: .long 0,0 + VBG0B: .long 0,0 + + #endif +- ++ ++#include "asm_common.S" ++ + .section .note.GNU-stack, "", @progbits + + .text + +-#define _inPtr 8 +-#define _rows 12 +-#define _columns 16 +-#define _outyPtr 20 +-#define _outuPtr 24 +-#define _outvPtr 28 ++#define _inPtr 24+8 ++#define _rows 24+12 ++#define _columns 24+16 ++#define _outyPtr 24+20 ++#define _outuPtr 24+24 ++#define _outvPtr 24+28 + + .global _dv_rgbtoycb_mmx + .hidden _dv_rgbtoycb_mmx + .type _dv_rgbtoycb_mmx,@function + _dv_rgbtoycb_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %eax + pushl %ebx + pushl %ecx +@@ -131,46 +132,47 @@ _dv_rgbtoycb_mmx: + pushl %esi + pushl %edi + +- leal ZEROSX, %eax #This section gets around a bug ++ LOAD_PIC_REG(bp) ++ ++ leal MUNG(ZEROSX), %eax #This section gets around a bug + movq (%eax), %mm0 #unlikely to persist +- movq %mm0, ZEROS +- leal OFFSETDX, %eax ++ movq %mm0, MUNG(ZEROS) ++ leal MUNG(OFFSETDX), %eax + movq (%eax), %mm0 +- movq %mm0, OFFSETD +- leal OFFSETWX, %eax ++ movq %mm0, MUNG(OFFSETD) ++ leal MUNG(OFFSETWX), %eax + movq (%eax), %mm0 +- movq %mm0, OFFSETW +- leal OFFSETBX, %eax ++ movq %mm0, MUNG(OFFSETW) ++ leal MUNG(OFFSETBX), %eax + movq (%eax), %mm0 +- movq %mm0, OFFSETB +- leal YR0GRX, %eax ++ movq %mm0, MUNG(OFFSETB) ++ leal MUNG(YR0GRX), %eax + movq (%eax), %mm0 +- movq %mm0, YR0GR +- leal YBG0BX, %eax ++ movq %mm0, MUNG(YR0GR) ++ leal MUNG(YBG0BX), %eax + movq (%eax), %mm0 +- movq %mm0, YBG0B +- leal UR0GRX, %eax ++ movq %mm0, MUNG(YBG0B) ++ leal MUNG(UR0GRX), %eax + movq (%eax), %mm0 +- movq %mm0, UR0GR +- leal UBG0BX, %eax ++ movq %mm0, MUNG(UR0GR) ++ leal MUNG(UBG0BX), %eax + movq (%eax), %mm0 +- movq %mm0, UBG0B +- leal VR0GRX, %eax ++ movq %mm0, MUNG(UBG0B) ++ leal MUNG(VR0GRX), %eax + movq (%eax), %mm0 +- movq %mm0, VR0GR +- leal VBG0BX, %eax ++ movq %mm0, MUNG(VR0GR) ++ leal MUNG(VBG0BX), %eax + movq (%eax), %mm0 +- movq %mm0, VBG0B +- +- movl _rows(%ebp), %eax +- movl _columns(%ebp), %ebx ++ movq %mm0, MUNG(VBG0B) ++ movl _rows(%esp), %eax ++ movl _columns(%esp), %ebx + mull %ebx #number pixels + shrl $3, %eax #number of loops + movl %eax, %edi #loop counter in edi +- movl _inPtr(%ebp), %eax +- movl _outyPtr(%ebp), %ebx +- movl _outuPtr(%ebp), %ecx +- movl _outvPtr(%ebp), %edx ++ movl _inPtr(%esp), %eax ++ movl _outyPtr(%esp), %ebx ++ movl _outuPtr(%esp), %ecx ++ movl _outvPtr(%esp), %edx + rgbtoycb_mmx_loop: + movq (%eax), %mm1 #load G2R2B1G1R1B0G0R0 + pxor %mm6, %mm6 #0 -> mm6 +@@ -184,29 +186,29 @@ rgbtoycb_mmx_loop: + punpcklbw %mm6, %mm1 #B1G1R1B0 -> mm1 + movq %mm0, %mm2 #R1B0G0R0 -> mm2 + +- pmaddwd YR0GR, %mm0 #yrR1,ygG0+yrR0 -> mm0 ++ pmaddwd MUNG(YR0GR), %mm0 #yrR1,ygG0+yrR0 -> mm0 + movq %mm1, %mm3 #B1G1R1B0 -> mm3 + +- pmaddwd YBG0B, %mm1 #ybB1+ygG1,ybB0 -> mm1 ++ pmaddwd MUNG(YBG0B), %mm1 #ybB1+ygG1,ybB0 -> mm1 + movq %mm2, %mm4 #R1B0G0R0 -> mm4 + +- pmaddwd UR0GR, %mm2 #urR1,ugG0+urR0 -> mm2 ++ pmaddwd MUNG(UR0GR), %mm2 #urR1,ugG0+urR0 -> mm2 + movq %mm3, %mm5 #B1G1R1B0 -> mm5 + +- pmaddwd UBG0B, %mm3 #ubB1+ugG1,ubB0 -> mm3 ++ pmaddwd MUNG(UBG0B), %mm3 #ubB1+ugG1,ubB0 -> mm3 + punpckhbw %mm6, %mm7 # 00G2R2 -> mm7 + +- pmaddwd VR0GR, %mm4 #vrR1,vgG0+vrR0 -> mm4 ++ pmaddwd MUNG(VR0GR), %mm4 #vrR1,vgG0+vrR0 -> mm4 + paddd %mm1, %mm0 #Y1Y0 -> mm0 + +- pmaddwd VBG0B, %mm5 #vbB1+vgG1,vbB0 -> mm5 ++ pmaddwd MUNG(VBG0B), %mm5 #vbB1+vgG1,vbB0 -> mm5 + + movq 8(%eax), %mm1 #R5B4G4R4B3G3R3B2 -> mm1 + paddd %mm3, %mm2 #U1U0 -> mm2 + + movq %mm1, %mm6 #R5B4G4R4B3G3R3B2 -> mm6 + +- punpcklbw ZEROS, %mm1 #B3G3R3B2 -> mm1 ++ punpcklbw MUNG(ZEROS), %mm1 #B3G3R3B2 -> mm1 + paddd %mm5, %mm4 #V1V0 -> mm4 + + movq %mm1, %mm5 #B3G3R3B2 -> mm5 +@@ -214,29 +216,29 @@ rgbtoycb_mmx_loop: + + paddd %mm7, %mm1 #R3B200+00G2R2=R3B2G2R2->mm1 + +- punpckhbw ZEROS, %mm6 #R5B4G4R3 -> mm6 ++ punpckhbw MUNG(ZEROS), %mm6 #R5B4G4R3 -> mm6 + movq %mm1, %mm3 #R3B2G2R2 -> mm3 + +- pmaddwd YR0GR, %mm1 #yrR3,ygG2+yrR2 -> mm1 ++ pmaddwd MUNG(YR0GR), %mm1 #yrR3,ygG2+yrR2 -> mm1 + movq %mm5, %mm7 #B3G3R3B2 -> mm7 + +- pmaddwd YBG0B, %mm5 #ybB3+ygG3,ybB2 -> mm5 ++ pmaddwd MUNG(YBG0B), %mm5 #ybB3+ygG3,ybB2 -> mm5 + psrad $FIXPSHIFT, %mm0 #32-bit scaled Y1Y0 -> mm0 + +- movq %mm6, TEMP0 #R5B4G4R4 -> TEMP0 ++ movq %mm6, MUNG(TEMP0) #R5B4G4R4 -> TEMP0 + movq %mm3, %mm6 #R3B2G2R2 -> mm6 +- pmaddwd UR0GR, %mm6 #urR3,ugG2+urR2 -> mm6 ++ pmaddwd MUNG(UR0GR), %mm6 #urR3,ugG2+urR2 -> mm6 + psrad $FIXPSHIFT, %mm2 #32-bit scaled U1U0 -> mm2 + + paddd %mm5, %mm1 #Y3Y2 -> mm1 + movq %mm7, %mm5 #B3G3R3B2 -> mm5 +- pmaddwd UBG0B, %mm7 #ubB3+ugG3,ubB2 ++ pmaddwd MUNG(UBG0B), %mm7 #ubB3+ugG3,ubB2 + psrad $FIXPSHIFT, %mm1 #32-bit scaled Y3Y2 -> mm1 + +- pmaddwd VR0GR, %mm3 #vrR3,vgG2+vgR2 ++ pmaddwd MUNG(VR0GR), %mm3 #vrR3,vgG2+vgR2 + packssdw %mm1, %mm0 #Y3Y2Y1Y0 -> mm0 + +- pmaddwd VBG0B, %mm5 #vbB3+vgG3,vbB2 -> mm5 ++ pmaddwd MUNG(VBG0B), %mm5 #vbB3+vgG3,vbB2 -> mm5 + psrad $FIXPSHIFT, %mm4 #32-bit scaled V1V0 -> mm4 + + movq 16(%eax), %mm1 #B7G7R7B6G6R6B5G5 -> mm7 +@@ -251,58 +253,58 @@ rgbtoycb_mmx_loop: + movq %mm7, %mm5 #R7B6G6R6B5G500 -> mm5 + psrad $FIXPSHIFT, %mm3 #32-bit scaled V3V2 -> mm3 + +- paddw OFFSETY, %mm0 ++ paddw MUNG(OFFSETY), %mm0 + movq %mm0, (%ebx) #store Y3Y2Y1Y0 + packssdw %mm6, %mm2 #32-bit scaled U3U2U1U0 -> mm2 + +- movq TEMP0, %mm0 #R5B4G4R4 -> mm0 ++ movq MUNG(TEMP0), %mm0 #R5B4G4R4 -> mm0 + addl $8, %ebx +- +- punpcklbw ZEROS, %mm7 #B5G500 -> mm7 ++ ++ punpcklbw MUNG(ZEROS), %mm7 #B5G500 -> mm7 + movq %mm0, %mm6 #R5B4G4R4 -> mm6 + +- movq %mm2, TEMPU #32-bit scaled U3U2U1U0 -> TEMPU ++ movq %mm2, MUNG(TEMPU) #32-bit scaled U3U2U1U0 -> TEMPU + psrlq $32, %mm0 #00R5B4 -> mm0 + + paddw %mm0, %mm7 #B5G5R5B4 -> mm7 + movq %mm6, %mm2 #B5B4G4R4 -> mm2 + +- pmaddwd YR0GR, %mm2 #yrR5,ygG4+yrR4 -> mm2 ++ pmaddwd MUNG(YR0GR), %mm2 #yrR5,ygG4+yrR4 -> mm2 + movq %mm7, %mm0 #B5G5R5B4 -> mm0 + +- pmaddwd YBG0B, %mm7 #ybB5+ygG5,ybB4 -> mm7 ++ pmaddwd MUNG(YBG0B), %mm7 #ybB5+ygG5,ybB4 -> mm7 + packssdw %mm3, %mm4 #32-bit scaled V3V2V1V0 -> mm4 + + addl $24, %eax #increment RGB count + +- movq %mm4, TEMPV #(V3V2V1V0)/256 -> mm4 ++ movq %mm4, MUNG(TEMPV) #(V3V2V1V0)/256 -> mm4 + movq %mm6, %mm4 #B5B4G4R4 -> mm4 + +- pmaddwd UR0GR, %mm6 #urR5,ugG4+urR4 ++ pmaddwd MUNG(UR0GR), %mm6 #urR5,ugG4+urR4 + movq %mm0, %mm3 #B5G5R5B4 -> mm0 + +- pmaddwd UBG0B, %mm0 #ubB5+ugG5,ubB4 ++ pmaddwd MUNG(UBG0B), %mm0 #ubB5+ugG5,ubB4 + paddd %mm7, %mm2 #Y5Y4 -> mm2 + +- pmaddwd VR0GR, %mm4 #vrR5,vgG4+vrR4 -> mm4 ++ pmaddwd MUNG(VR0GR), %mm4 #vrR5,vgG4+vrR4 -> mm4 + pxor %mm7, %mm7 #0 -> mm7 + +- pmaddwd VBG0B, %mm3 #vbB5+vgG5,vbB4 -> mm3 ++ pmaddwd MUNG(VBG0B), %mm3 #vbB5+vgG5,vbB4 -> mm3 + punpckhbw %mm7, %mm1 #B7G7R7B6 -> mm1 + + paddd %mm6, %mm0 #U5U4 -> mm0 + movq %mm1, %mm6 #B7G7R7B6 -> mm6 + +- pmaddwd YBG0B, %mm6 #ybB7+ygG7,ybB6 -> mm6 ++ pmaddwd MUNG(YBG0B), %mm6 #ybB7+ygG7,ybB6 -> mm6 + punpckhbw %mm7, %mm5 #R7B6G6R6 -> mm5 + + movq %mm5, %mm7 #R7B6G6R6 -> mm7 + paddd %mm4, %mm3 #V5V4 -> mm3 + +- pmaddwd YR0GR, %mm5 #yrR7,ygG6+yrR6 -> mm5 ++ pmaddwd MUNG(YR0GR), %mm5 #yrR7,ygG6+yrR6 -> mm5 + movq %mm1, %mm4 #B7G7R7B6 -> mm4 + +- pmaddwd UBG0B, %mm4 #ubB7+ugG7,ubB6 -> mm4 ++ pmaddwd MUNG(UBG0B), %mm4 #ubB7+ugG7,ubB6 -> mm4 + psrad $FIXPSHIFT, %mm0 #32-bit scaled U5U4 -> mm0 + + psrad $FIXPSHIFT, %mm2 #32-bit scaled Y5Y4 -> mm2 +@@ -310,25 +312,25 @@ rgbtoycb_mmx_loop: + paddd %mm5, %mm6 #Y7Y6 -> mm6 + movq %mm7, %mm5 #R7B6G6R6 -> mm5 + +- pmaddwd UR0GR, %mm7 #urR7,ugG6+ugR6 -> mm7 ++ pmaddwd MUNG(UR0GR), %mm7 #urR7,ugG6+ugR6 -> mm7 + psrad $FIXPSHIFT, %mm3 #32-bit scaled V5V4 -> mm3 + +- pmaddwd VBG0B, %mm1 #vbB7+vgG7,vbB6 -> mm1 ++ pmaddwd MUNG(VBG0B), %mm1 #vbB7+vgG7,vbB6 -> mm1 + psrad $FIXPSHIFT, %mm6 #32-bit scaled Y7Y6 -> mm6 + + packssdw %mm6, %mm2 #Y7Y6Y5Y4 -> mm2 + +- pmaddwd VR0GR, %mm5 #vrR7,vgG6+vrR6 -> mm5 ++ pmaddwd MUNG(VR0GR), %mm5 #vrR7,vgG6+vrR6 -> mm5 + paddd %mm4, %mm7 #U7U6 -> mm7 + + psrad $FIXPSHIFT, %mm7 #32-bit scaled U7U6 -> mm7 +- paddw OFFSETY, %mm2 ++ paddw MUNG(OFFSETY), %mm2 + movq %mm2, (%ebx) #store Y7Y6Y5Y4 + +- movq ALLONE, %mm6 ++ movq MUNG(ALLONE), %mm6 + packssdw %mm7, %mm0 #32-bit scaled U7U6U5U4 -> mm0 + +- movq TEMPU, %mm4 #32-bit scaled U3U2U1U0 -> mm4 ++ movq MUNG(TEMPU), %mm4 #32-bit scaled U3U2U1U0 -> mm4 + pmaddwd %mm6, %mm0 #U7U6U5U4 averaged -> (U7U6)(U5U4)=UU3 UU2->mm0 + + pmaddwd %mm6, %mm4 #U3U2U1U0 averaged -> (U3U2)(U1U0)=UU1 UU0->mm4 +@@ -338,8 +340,8 @@ rgbtoycb_mmx_loop: + + psrad $FIXPSHIFT, %mm1 #32-bit scaled V7V6 -> mm1 + psraw $1, %mm4 #divide UU3 UU2 UU1 UU0 by 2 -> mm4 +- +- movq TEMPV, %mm5 #32-bit scaled V3V2V1V0 -> mm5 ++ ++ movq MUNG(TEMPV), %mm5 #32-bit scaled V3V2V1V0 -> mm5 + + movq %mm4, (%ecx) # store U + +@@ -422,14 +426,15 @@ _dv_ppm_copy_y_block_mmx: + _dv_pgm_copy_y_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + pushl %edi +- +- movl 8(%ebp), %edi # dest +- movl 12(%ebp), %esi # src + +- movq OFFSETY, %mm7 ++ LOAD_PIC_REG(bp) ++ ++ movl 16(%esp), %edi # dest ++ movl 20(%esp), %esi # src ++ ++ movq MUNG(OFFSETY), %mm7 + pxor %mm6, %mm6 + + movq (%esi), %mm0 +@@ -564,14 +571,15 @@ _dv_pgm_copy_y_block_mmx: + _dv_video_copy_y_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + pushl %edi +- +- movl 8(%ebp), %edi # dest +- movl 12(%ebp), %esi # src + +- movq OFFSETBX, %mm7 ++ LOAD_PIC_REG(bp) ++ ++ movl 16(%esp), %edi # dest ++ movl 20(%esp), %esi # src ++ ++ movq MUNG(OFFSETBX), %mm7 + pxor %mm6, %mm6 + + movq (%esi), %mm0 +@@ -852,16 +864,16 @@ _dv_ppm_copy_pal_c_block_mmx: + _dv_pgm_copy_pal_c_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + pushl %edi + pushl %ebx +- +- movl 8(%ebp), %edi # dest +- movl 12(%ebp), %esi # src + ++ LOAD_PIC_REG(bp) ++ ++ movl 20(%esp), %edi # dest ++ movl 24(%esp), %esi # src + +- movq OFFSETBX, %mm7 ++ movq MUNG(OFFSETBX), %mm7 + pxor %mm6, %mm6 + + +@@ -1000,15 +1014,16 @@ _dv_pgm_copy_pal_c_block_mmx: + _dv_video_copy_pal_c_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + pushl %edi + pushl %ebx +- +- movl 8(%ebp), %edi # dest +- movl 12(%ebp), %esi # src + +- movq OFFSETBX, %mm7 ++ LOAD_PIC_REG(bp) ++ ++ movl 20(%esp), %edi # dest ++ movl 24(%esp), %esi # src ++ ++ movq MUNG(OFFSETBX), %mm7 + paddw %mm7, %mm7 + pxor %mm6, %mm6 + +@@ -1095,18 +1112,18 @@ video_copy_pal_c_block_mmx_loop: + _dv_ppm_copy_ntsc_c_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + pushl %edi + pushl %ebx +- +- movl 8(%ebp), %edi # dest +- movl 12(%ebp), %esi # src ++ ++ LOAD_PIC_REG(bp) ++ ++ movl 20(%esp), %edi # dest ++ movl 24(%esp), %esi # src + + movl $4, %ebx + +- movq ALLONE, %mm6 +- ++ movq MUNG(ALLONE), %mm6 + ppm_copy_ntsc_c_block_mmx_loop: + + movq (%esi), %mm0 +@@ -1168,14 +1187,15 @@ ppm_copy_ntsc_c_block_mmx_loop: + _dv_pgm_copy_ntsc_c_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + pushl %edi +- +- movl 8(%ebp), %edi # dest +- movl 12(%ebp), %esi # src + +- movq OFFSETBX, %mm7 ++ LOAD_PIC_REG(bp) ++ ++ movl 16(%esp), %edi # dest ++ movl 20(%esp), %esi # src ++ ++ movq MUNG(OFFSETBX), %mm7 + paddw %mm7, %mm7 + pxor %mm6, %mm6 + +@@ -1325,15 +1347,16 @@ _dv_pgm_copy_ntsc_c_block_mmx: + _dv_video_copy_ntsc_c_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + pushl %edi + pushl %ebx +- +- movl 8(%ebp), %edi # dest +- movl 12(%ebp), %esi # src + +- movq OFFSETBX, %mm7 ++ LOAD_PIC_REG(bp) ++ ++ movl 20(%esp), %edi # dest ++ movl 24(%esp), %esi # src ++ ++ movq MUNG(OFFSETBX), %mm7 + paddw %mm7, %mm7 + pxor %mm6, %mm6 + +--- libdv-0.104-old/libdv/rgbtoyuv_x86_64.S ++++ libdv-0.104/libdv/rgbtoyuv_x86_64.S +@@ -41,9 +41,6 @@ + #define DV_WIDTH_SHORT_HALF 720 + #define DV_WIDTH_BYTE_HALF 360 + +-.global _dv_rgbtoycb_mmx_x86_64 +-# .global yuvtoycb_mmx_x86_64 +- + .data + + .align 8 +--- libdv-0.104-old/libdv/vlc_x86.S ++++ libdv-0.104/libdv/vlc_x86.S +@@ -1,31 +1,39 @@ + #include "asmoff.h" + .section .note.GNU-stack, "", @progbits ++ #include "asm_common.S" + + .text + .align 4 + .globl dv_decode_vlc ++.globl asm_dv_decode_vlc ++.hidden asm_dv_decode_vlc ++asm_dv_decode_vlc = dv_decode_vlc ++ + .type dv_decode_vlc,@function + dv_decode_vlc: + pushl %ebx ++ pushl %ebp ++ ++ LOAD_PIC_REG(bp) + +- /* Args are at 8(%esp). */ +- movl 8(%esp),%eax /* %eax is bits */ +- movl 12(%esp),%ebx /* %ebx is maxbits */ ++ /* Args are at 12(%esp). */ ++ movl 12(%esp),%eax /* %eax is bits */ ++ movl 16(%esp),%ebx /* %ebx is maxbits */ + andl $0x3f,%ebx /* limit index range STL*/ + +- movl dv_vlc_class_index_mask(,%ebx,4),%edx ++ movl MUNG_ARR(dv_vlc_class_index_mask,%ebx,4),%edx + andl %eax,%edx +- movl dv_vlc_class_index_rshift(,%ebx,4),%ecx ++ movl MUNG_ARR(dv_vlc_class_index_rshift,%ebx,4),%ecx + sarl %cl,%edx +- movl dv_vlc_classes(,%ebx,4),%ecx ++ movl MUNG_ARR(dv_vlc_classes,%ebx,4),%ecx + movsbl (%ecx,%edx,1),%edx /* %edx is class */ + +- movl dv_vlc_index_mask(,%edx,4),%ebx +- movl dv_vlc_index_rshift(,%edx,4),%ecx ++ movl MUNG_ARR(dv_vlc_index_mask,%edx,4),%ebx ++ movl MUNG_ARR(dv_vlc_index_rshift,%edx,4),%ecx + andl %eax,%ebx + sarl %cl,%ebx + +- movl dv_vlc_lookups(,%edx,4),%edx ++ movl MUNG_ARR(dv_vlc_lookups,%edx,4),%edx + movl (%edx,%ebx,4),%edx + + /* Now %edx holds result, like this: +@@ -42,7 +51,7 @@ dv_decode_vlc: + movl %edx,%ecx + sarl $8,%ecx + andl $0xff,%ecx +- movl sign_mask(,%ecx,4),%ebx ++ movl MUNG_ARR(sign_mask,%ecx,4),%ebx + andl %ebx,%eax + negl %eax + sarl $31,%eax +@@ -63,14 +72,14 @@ dv_decode_vlc: + *result = broken; + Note that the 'broken' pattern is all ones (i.e. 0xffffffff) + */ +- movl 12(%esp),%ebx /* %ebx is maxbits */ ++ movl 16(%esp),%ebx /* %ebx is maxbits */ + subl %ecx,%ebx + sbbl %ebx,%ebx + orl %ebx,%edx + +- movl 16(%esp),%eax ++ movl 20(%esp),%eax + movl %edx,(%eax) +- ++ popl %ebp + popl %ebx + ret + +@@ -80,21 +89,28 @@ dv_decode_vlc: + .type __dv_decode_vlc,@function + __dv_decode_vlc: + pushl %ebx ++ pushl %ebp ++ ++ LOAD_PIC_REG(bp) + +- /* Args are at 8(%esp). */ +- movl 8(%esp),%eax /* %eax is bits */ ++ /* Args are at 12(%esp). */ ++ movl 12(%esp),%eax /* %eax is bits */ + + movl %eax,%edx /* %edx is class */ + andl $0xfe00,%edx + sarl $9,%edx ++#ifdef __PIC__ ++ movsbl dv_vlc_class_lookup5@GOTOFF(%ebp,%edx),%edx ++#else + movsbl dv_vlc_class_lookup5(%edx),%edx +- +- movl dv_vlc_index_mask(,%edx,4),%ebx +- movl dv_vlc_index_rshift(,%edx,4),%ecx ++#endif ++ ++ movl MUNG_ARR(dv_vlc_index_mask,%edx,4),%ebx ++ movl MUNG_ARR(dv_vlc_index_rshift,%edx,4),%ecx + andl %eax,%ebx + sarl %cl,%ebx + +- movl dv_vlc_lookups(,%edx,4),%edx ++ movl MUNG_ARR(dv_vlc_lookups,%edx,4),%edx + movl (%edx,%ebx,4),%edx + + /* Now %edx holds result, like this: +@@ -112,7 +128,7 @@ __dv_decode_vlc: + movl %edx,%ecx + sarl $8,%ecx + andl $0xff,%ecx +- movl sign_mask(,%ecx,4),%ecx ++ movl MUNG_ARR(sign_mask,%ecx,4),%ecx + andl %ecx,%eax + negl %eax + sarl $31,%eax +@@ -127,9 +143,9 @@ __dv_decode_vlc: + xorl %eax,%edx + subl %eax,%edx + +- movl 12(%esp),%eax ++ movl 16(%esp),%eax + movl %edx,(%eax) +- ++ popl %ebp + popl %ebx + ret + +@@ -140,14 +156,20 @@ void dv_parse_ac_coeffs_pass0(bitstream_ + */ + .text + .align 4 ++.globl asm_dv_parse_ac_coeffs_pass0 ++.hidden asm_dv_parse_ac_coeffs_pass0 ++ asm_dv_parse_ac_coeffs_pass0 = dv_parse_ac_coeffs_pass0 ++ + .globl dv_parse_ac_coeffs_pass0 + .type dv_parse_ac_coeffs_pass0,@function + dv_parse_ac_coeffs_pass0: + pushl %ebx + pushl %edi + pushl %esi + pushl %ebp + ++ LOAD_PIC_REG(si) ++ + #define ARGn(N) (20+(4*(N)))(%esp) + + /* +@@ -159,8 +182,10 @@ dv_parse_ac_coeffs_pass0: + ebp bl + */ + movl ARGn(2),%ebp ++#ifndef __PIC__ + movl ARGn(0),%esi + movl bitstream_t_buf(%esi),%esi ++#endif + movl dv_block_t_offset(%ebp),%edi + movl dv_block_t_reorder(%ebp),%ebx + +@@ -170,7 +195,11 @@ dv_parse_ac_coeffs_pass0: + + movq dv_block_t_coeffs(%ebp),%mm1 + pxor %mm0,%mm0 ++#ifdef __PIC__ ++ pand const_f_0_0_0@GOTOFF(%esi),%mm1 ++#else + pand const_f_0_0_0,%mm1 ++#endif + movq %mm1,dv_block_t_coeffs(%ebp) + movq %mm0,(dv_block_t_coeffs + 8)(%ebp) + movq %mm0,(dv_block_t_coeffs + 16)(%ebp) +@@ -191,9 +220,17 @@ dv_parse_ac_coeffs_pass0: + readloop: + movl %edi,%ecx + shrl $3,%ecx ++#ifdef __PIC__ ++ movl ARGn(0),%eax ++ addl bitstream_t_buf(%eax),%ecx ++ movzbl (%ecx),%eax ++ movzbl 1(%ecx),%edx ++ movzbl 2(%ecx),%ecx ++#else + movzbl (%esi,%ecx,1),%eax + movzbl 1(%esi,%ecx,1),%edx + movzbl 2(%esi,%ecx,1),%ecx ++#endif + shll $16,%eax + shll $8,%edx + orl %ecx,%eax +@@ -217,7 +254,11 @@ readloop: + + /* Attempt to use the shortcut first. If it hits, then + this vlc term has been decoded. */ ++#ifdef __PIC__ ++ movl dv_vlc_class1_shortcut@GOTOFF(%esi,%ecx,4),%edx ++#else + movl dv_vlc_class1_shortcut(,%ecx,4),%edx ++#endif + test $0x80,%edx + je done_decode + +@@ -228,12 +269,19 @@ readloop: + movl %ebx,dv_block_t_reorder(%ebp) + + /* %eax is bits */ +- ++#ifdef __PIC__ ++ movsbl dv_vlc_class_lookup5@GOTOFF(%esi,%ecx),%ecx ++ ++ movl dv_vlc_index_mask@GOTOFF(%esi,%ecx,4),%ebx ++ movl dv_vlc_lookups@GOTOFF(%esi,%ecx,4),%edx ++ movl dv_vlc_index_rshift@GOTOFF(%esi,%ecx,4),%ecx ++#else + movsbl dv_vlc_class_lookup5(%ecx),%ecx + + movl dv_vlc_index_mask(,%ecx,4),%ebx + movl dv_vlc_lookups(,%ecx,4),%edx + movl dv_vlc_index_rshift(,%ecx,4),%ecx ++#endif + andl %eax,%ebx + sarl %cl,%ebx + +@@ -256,7 +304,11 @@ readloop: + movl %edx,%ecx + sarl $8,%ecx + andl $0xff,%ecx ++#ifdef __PIC__ ++ movl sign_mask@GOTOFF(%esi,%ecx,4),%ecx ++#else + movl sign_mask(,%ecx,4),%ecx ++#endif + andl %ecx,%eax + negl %eax + sarl $31,%eax +@@ -326,10 +378,16 @@ alldone: + + slowpath: + /* slow path: use dv_decode_vlc */; ++#ifdef __PIC__ ++ pushl %esi ++ leal vlc@GOTOFF(%esi),%esi ++ xchgl %esi,(%esp) /* last parameter is &vlc */ ++#else + pushl $vlc /* last parameter is &vlc */ ++#endif + pushl %edx /* bits_left */ + pushl %eax /* bits */ +- call dv_decode_vlc ++ call asm_dv_decode_vlc + addl $12,%esp + test $0x80,%edx /* If (vlc.run < 0) break */ + jne escape +@@ -359,6 +417,8 @@ show16: + pushl %esi + pushl %ebp + ++ LOAD_PIC_REG(si) ++ + #define ARGn(N) (20+(4*(N)))(%esp) + + movl ARGn(1),%eax /* quality */ +@@ -373,7 +434,11 @@ dv_parse_video_segment: + jz its_mono + movl $6,%ebx + its_mono: ++#ifdef __PIC__ ++ movl %ebx,n_blocks@GOTOFF(%esi) ++#else + movl %ebx,n_blocks ++#endif + + /* + * ebx seg/b +@@ -384,15 +449,22 @@ its_mono: + * ebp bl + */ + movl ARGn(0),%ebx ++#ifndef __PIC__ + movl dv_videosegment_t_bs(%ebx),%esi + movl bitstream_t_buf(%esi),%esi ++#endif + leal dv_videosegment_t_mb(%ebx),%edi + + movl $0,%eax + movl $0,%ecx + macloop: ++#ifdef __PIC__ ++ movl %eax,m@GOTOFF(%esi) ++ movl %ecx,mb_start@GOTOFF(%esi) ++#else + movl %eax,m + movl %ecx,mb_start ++#endif + + movl ARGn(0),%ebx + +@@ -400,7 +472,13 @@ macloop: + /* mb->qno = bitstream_get(bs,4); */ + movl %ecx,%edx + shr $3,%edx ++#ifdef __PIC__ ++ movl dv_videosegment_t_bs(%ebx),%ecx ++ movl bitstream_t_buf(%ecx),%ecx ++ movzbl 3(%ecx,%edx,1),%edx ++#else + movzbl 3(%esi,%edx,1),%edx ++#endif + andl $0xf,%edx + movl %edx,dv_macroblock_t_qno(%edi) + +@@ -411,7 +489,11 @@ macloop: + movl %edx,dv_macroblock_t_eob_count(%edi) + + /* mb->i = (seg->i + dv_super_map_vertical[m]) % (seg->isPAL?12:10); */ ++#ifdef __PIC__ ++ movl dv_super_map_vertical@GOTOFF(%esi,%eax,4),%edx ++#else + movl dv_super_map_vertical(,%eax,4),%edx ++#endif + movl dv_videosegment_t_i(%ebx),%ecx + addl %ecx,%edx + +@@ -422,11 +504,20 @@ skarly: + andl $1,%ecx + shll $5,%ecx /* ecx = (isPAL ? 32 : 0) */ + ++#ifdef __PIC__ ++ leal mod_10@GOTOFF(%esi),%edx ++ movzbl (%edx,%ecx,1),%edx /* uses mod_12 for PAL */ ++#else + movzbl mod_10(%edx,%ecx,1),%edx /* uses mod_12 for PAL */ ++#endif + movl %edx,dv_macroblock_t_i(%edi) + + /* mb->j = dv_super_map_horizontal[m]; */ ++#ifdef __PIC__ ++ movl dv_super_map_horizontal@GOTOFF(%esi,%eax,4),%edx ++#else + movl dv_super_map_horizontal(,%eax,4),%edx ++#endif + movl %edx,dv_macroblock_t_j(%edi) + + /* mb->k = seg->k; */ +@@ -445,12 +536,28 @@ blkloop: + +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ + */ + /* dc = bitstream_get(bs,9); */ ++#ifdef __PIC__ ++ movl mb_start@GOTOFF(%esi),%ecx ++#else + movl mb_start,%ecx ++#endif + shr $3,%ecx ++#ifdef __PIC__ ++ movzbl blk_start@GOTOFF(%esi,%ebx),%edx ++#else + movzbl blk_start(%ebx),%edx ++#endif + addl %ecx,%edx ++#ifdef __PIC__ ++ movl ARGn(0),%ecx ++ movl dv_videosegment_t_bs(%ecx),%ecx ++ movl bitstream_t_buf(%ecx),%ecx ++ movzbl (%ecx,%edx,1),%eax /* hi byte */ ++ movzbl 1(%ecx,%edx,1),%ecx /* lo byte */ ++#else + movzbl (%esi,%edx,1),%eax /* hi byte */ + movzbl 1(%esi,%edx,1),%ecx /* lo byte */ ++#endif + shll $8,%eax + orl %ecx,%eax + +@@ -477,7 +584,11 @@ blkloop: + + /* bl->reorder = &dv_reorder[bl->dct_mode][1]; */ + shll $6,%eax ++#ifdef __PIC__ ++ leal dv_reorder@GOTOFF+1(%esi,%eax),%eax ++#else + addl $(dv_reorder+1),%eax ++#endif + movl %eax,dv_block_t_reorder(%ebp) + + /* bl->reorder_sentinel = bl->reorder + 63; */ +@@ -485,13 +596,22 @@ blkloop: + movl %eax,dv_block_t_reorder_sentinel(%ebp) + + /* bl->offset= mb_start + dv_parse_bit_start[b]; */ ++#ifdef __PIC__ ++ movl mb_start@GOTOFF(%esi),%ecx ++ movl dv_parse_bit_start@GOTOFF(%esi,%ebx,4),%eax ++#else + movl mb_start,%ecx + movl dv_parse_bit_start(,%ebx,4),%eax ++#endif + addl %ecx,%eax + movl %eax,dv_block_t_offset(%ebp) + + /* bl->end= mb_start + dv_parse_bit_end[b]; */ ++#ifdef __PIC__ ++ movl dv_parse_bit_end@GOTOFF(%esi,%ebx,4),%eax ++#else + movl dv_parse_bit_end(,%ebx,4),%eax ++#endif + addl %ecx,%eax + movl %eax,dv_block_t_end(%ebp) + +@@ -503,7 +623,11 @@ blkloop: + /* no AC pass. Just zero out the remaining coeffs */ + movq dv_block_t_coeffs(%ebp),%mm1 + pxor %mm0,%mm0 ++#ifdef __PIC__ ++ pand const_f_0_0_0@GOTOFF(%esi),%mm1 ++#else + pand const_f_0_0_0,%mm1 ++#endif + movq %mm1,dv_block_t_coeffs(%ebp) + movq %mm0,(dv_block_t_coeffs + 8)(%ebp) + movq %mm0,(dv_block_t_coeffs + 16)(%ebp) +@@ -528,18 +652,27 @@ do_ac_pass: + pushl %ebp + pushl %edi + pushl %eax +- call dv_parse_ac_coeffs_pass0 ++ call asm_dv_parse_ac_coeffs_pass0 + addl $12,%esp + done_ac: + ++#ifdef __PIC__ ++ movl n_blocks@GOTOFF(%esi),%eax ++#else + movl n_blocks,%eax ++#endif + addl $dv_block_t_size,%ebp + incl %ebx + cmpl %eax,%ebx + jnz blkloop + ++#ifdef __PIC__ ++ movl m@GOTOFF(%esi),%eax ++ movl mb_start@GOTOFF(%esi),%ecx ++#else + movl m,%eax + movl mb_start,%ecx ++#endif + addl $(8 * 80),%ecx + addl $dv_macroblock_t_size,%edi + incl %eax +@@ -557,7 +690,7 @@ done_ac: + + andl $DV_QUALITY_AC_MASK,%eax + cmpl $DV_QUALITY_AC_2,%eax +- jz dv_parse_ac_coeffs ++ jz asm_dv_parse_ac_coeffs + movl $0,%eax + ret + diff --git a/libdv-cvs-pic-fix.patch b/libdv-cvs-pic-fix.patch new file mode 100644 index 0000000..649188a --- /dev/null +++ b/libdv-cvs-pic-fix.patch @@ -0,0 +1,1958 @@ +--- libdv/dct_block_mmx.S 31 Jan 2005 13:27:54 -0000 1.4 ++++ libdv/dct_block_mmx.S 15 Dec 2005 06:45:38 -0000 +@@ -55,17 +55,22 @@ scratch4: .quad 0 + + .section .note.GNU-stack, "", @progbits + ++#include "asm_common.S" ++ + .text + + .align 8 + .global _dv_dct_88_block_mmx ++.hidden _dv_dct_88_block_mmx ++.type _dv_dct_88_block_mmx,@function + _dv_dct_88_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + +- movl 8(%ebp), %esi # source ++ LOAD_PIC_REG_BP() ++ ++ movl 12(%ebp), %esi # source + + # column 0 + movq 16*0(%esi), %mm0 # v0 +@@ -88,22 +93,22 @@ _dv_dct_88_block_mmx: + + movq 16*3(%esi), %mm5 # v3 + movq 16*4(%esi), %mm7 # v4 +- movq %mm7, scratch1 # scratch1: v4 ; ++ movq %mm7, MUNG(scratch1) # scratch1: v4 ; + movq %mm5, %mm7 # duplicate v3 +- paddw scratch1, %mm5 # v03: v3+v4 +- psubw scratch1, %mm7 # v04: v3-v4 +- movq %mm5, scratch2 # scratch2: v03 ++ paddw MUNG(scratch1), %mm5 # v03: v3+v4 ++ psubw MUNG(scratch1), %mm7 # v04: v3-v4 ++ movq %mm5, MUNG(scratch2) # scratch2: v03 + movq %mm0, %mm5 # mm5: v00 + +- paddw scratch2, %mm0 # v10: v00+v03 +- psubw scratch2, %mm5 # v13: v00-v03 +- movq %mm3, scratch3 # scratch3: v02 ++ paddw MUNG(scratch2), %mm0 # v10: v00+v03 ++ psubw MUNG(scratch2), %mm5 # v13: v00-v03 ++ movq %mm3, MUNG(scratch3) # scratch3: v02 + movq %mm1, %mm3 # duplicate v01 + +- paddw scratch3, %mm1 # v11: v01+v02 +- psubw scratch3, %mm3 # v12: v01-v02 ++ paddw MUNG(scratch3), %mm1 # v11: v01+v02 ++ psubw MUNG(scratch3), %mm3 # v12: v01-v02 + +- movq %mm6, scratch4 # scratch4: v05 ++ movq %mm6, MUNG(scratch4) # scratch4: v05 + movq %mm0, %mm6 # duplicate v10 + + paddw %mm1, %mm0 # v10+v11 +@@ -113,10 +118,10 @@ _dv_dct_88_block_mmx: + movq %mm6, 16*4(%esi) # out4: v10-v11 + + movq %mm4, %mm0 # mm0: v06 +- paddw scratch4, %mm4 # v15: v05+v06 ++ paddw MUNG(scratch4), %mm4 # v15: v05+v06 + paddw %mm2, %mm0 # v16: v07+v06 + +- pmulhw WA3, %mm4 # v35~: WA3*v15 ++ pmulhw MUNG(WA3), %mm4 # v35~: WA3*v15 + psllw $1, %mm4 # v35: compensate the coeefient scale + + movq %mm4, %mm6 # duplicate v35 +@@ -125,7 +130,7 @@ _dv_dct_88_block_mmx: + + paddw %mm5, %mm3 # v22: v12+v13 + +- pmulhw WA1, %mm3 # v32~: WA1*v22 ++ pmulhw MUNG(WA1), %mm3 # v32~: WA1*v22 + psllw $16-NSHIFT, %mm3 # v32: compensate the coeefient scale + movq %mm5, %mm6 # duplicate v13 + +@@ -136,13 +141,13 @@ _dv_dct_88_block_mmx: + movq %mm6, 16*6(%esi) # out6: v13-v32 + + +- paddw scratch4, %mm7 # v14n: v04+v05 ++ paddw MUNG(scratch4), %mm7 # v14n: v04+v05 + movq %mm0, %mm5 # duplicate v16 + + psubw %mm7, %mm0 # va1: v16-v14n +- pmulhw WA5, %mm0 # va0~: va1*WA5 +- pmulhw WA4, %mm5 # v36~~: v16*WA4 +- pmulhw WA2, %mm7 # v34~~: v14n*WA2 ++ pmulhw MUNG(WA5), %mm0 # va0~: va1*WA5 ++ pmulhw MUNG(WA4), %mm5 # v36~~: v16*WA4 ++ pmulhw MUNG(WA2), %mm7 # v34~~: v14n*WA2 + psllw $16-WA4_SHIFT, %mm5 # v36: compensate the coeefient scale + psllw $16-NSHIFT, %mm7 # v34: compensate the coeefient scale + +@@ -190,22 +195,22 @@ _dv_dct_88_block_mmx: + + movq 16*3(%esi), %mm5 # v3 + movq 16*4(%esi), %mm7 # v4 +- movq %mm7, scratch1 # scratch1: v4 ; ++ movq %mm7, MUNG(scratch1) # scratch1: v4 ; + movq %mm5, %mm7 # duplicate v3 +- paddw scratch1, %mm5 # v03: v3+v4 +- psubw scratch1, %mm7 # v04: v3-v4 +- movq %mm5, scratch2 # scratch2: v03 ++ paddw MUNG(scratch1), %mm5 # v03: v3+v4 ++ psubw MUNG(scratch1), %mm7 # v04: v3-v4 ++ movq %mm5, MUNG(scratch2) # scratch2: v03 + movq %mm0, %mm5 # mm5: v00 + +- paddw scratch2, %mm0 # v10: v00+v03 +- psubw scratch2, %mm5 # v13: v00-v03 +- movq %mm3, scratch3 # scratc3: v02 ++ paddw MUNG(scratch2), %mm0 # v10: v00+v03 ++ psubw MUNG(scratch2), %mm5 # v13: v00-v03 ++ movq %mm3, MUNG(scratch3) # scratc3: v02 + movq %mm1, %mm3 # duplicate v01 + +- paddw scratch3, %mm1 # v11: v01+v02 +- psubw scratch3, %mm3 # v12: v01-v02 ++ paddw MUNG(scratch3), %mm1 # v11: v01+v02 ++ psubw MUNG(scratch3), %mm3 # v12: v01-v02 + +- movq %mm6, scratch4 # scratc4: v05 ++ movq %mm6, MUNG(scratch4) # scratc4: v05 + movq %mm0, %mm6 # duplicate v10 + + paddw %mm1, %mm0 # v10+v11 +@@ -215,10 +220,10 @@ _dv_dct_88_block_mmx: + movq %mm6, 16*4(%esi) # out4: v10-v11 + + movq %mm4, %mm0 # mm0: v06 +- paddw scratch4, %mm4 # v15: v05+v06 ++ paddw MUNG(scratch4), %mm4 # v15: v05+v06 + paddw %mm2, %mm0 # v16: v07+v06 + +- pmulhw WA3, %mm4 # v35~: WA3*v15 ++ pmulhw MUNG(WA3), %mm4 # v35~: WA3*v15 + psllw $16-NSHIFT, %mm4 # v35: compensate the coeefient scale + + movq %mm4, %mm6 # duplicate v35 +@@ -227,7 +232,7 @@ _dv_dct_88_block_mmx: + + paddw %mm5, %mm3 # v22: v12+v13 + +- pmulhw WA1, %mm3 # v32~: WA3*v15 ++ pmulhw MUNG(WA1), %mm3 # v32~: WA3*v15 + psllw $16-NSHIFT, %mm3 # v32: compensate the coeefient scale + movq %mm5, %mm6 # duplicate v13 + +@@ -237,13 +242,13 @@ _dv_dct_88_block_mmx: + movq %mm5, 16*2(%esi) # out2: v13+v32 + movq %mm6, 16*6(%esi) # out6: v13-v32 + +- paddw scratch4, %mm7 # v14n: v04+v05 ++ paddw MUNG(scratch4), %mm7 # v14n: v04+v05 + movq %mm0, %mm5 # duplicate v16 + + psubw %mm7, %mm0 # va1: v16-v14n +- pmulhw WA2, %mm7 # v34~~: v14n*WA2 +- pmulhw WA5, %mm0 # va0~: va1*WA5 +- pmulhw WA4, %mm5 # v36~~: v16*WA4 ++ pmulhw MUNG(WA2), %mm7 # v34~~: v14n*WA2 ++ pmulhw MUNG(WA5), %mm0 # va0~: va1*WA5 ++ pmulhw MUNG(WA4), %mm5 # v36~~: v16*WA4 + psllw $16-NSHIFT, %mm7 + psllw $16-WA4_SHIFT, %mm5 # v36: compensate the coeffient + # scale note that WA4 is shifted 1 bit less than the others +@@ -274,6 +279,8 @@ _dv_dct_88_block_mmx: + + .align 8 + .global _dv_dct_block_mmx_postscale_88 ++.hidden _dv_dct_block_mmx_postscale_88 ++.type _dv_dct_block_mmx_postscale_88,@function + _dv_dct_block_mmx_postscale_88: + + pushl %ebp +@@ -750,14 +757,17 @@ _dv_dct_block_mmx_postscale_88: + + .align 8 + .global _dv_dct_248_block_mmx ++.hidden _dv_dct_248_block_mmx ++.type _dv_dct_248_block_mmx,@function + _dv_dct_248_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + pushl %edi + +- movl 8(%ebp), %esi # source ++ LOAD_PIC_REG_BP() ++ ++ movl 16(%ebp), %esi # source + + # column 0 + +@@ -781,7 +791,7 @@ _dv_dct_248_block_mmx: + paddw %mm1, %mm0 # v20: v10+v11 + psubw %mm1, %mm3 # v21: v10-v11 + +- pmulhw WA1, %mm5 # v32~: WA1*v22 ++ pmulhw MUNG(WA1), %mm5 # v32~: WA1*v22 + movq %mm4, %mm2 + psllw $16-NSHIFT, %mm5 # v32: compensate the coeffient scale + +@@ -820,7 +830,7 @@ _dv_dct_248_block_mmx: + paddw %mm1, %mm0 # v20: v10+v11 + psubw %mm1, %mm3 # v21: v10-v11 + +- pmulhw WA1, %mm5 # v32~: WA1*v22 ++ pmulhw MUNG(WA1), %mm5 # v32~: WA1*v22 + movq %mm4, %mm2 + psllw $16-NSHIFT, %mm5 # v32: compensate the coeffient scale + +@@ -857,7 +867,7 @@ _dv_dct_248_block_mmx: + paddw %mm1, %mm0 # v20: v10+v11 + psubw %mm1, %mm3 # v21: v10-v11 + +- pmulhw WA1, %mm5 # v32~: WA1*v22 ++ pmulhw MUNG(WA1), %mm5 # v32~: WA1*v22 + movq %mm4, %mm2 + psllw $16-NSHIFT, %mm5 # v32: compensate the coeffient scale + +@@ -894,7 +904,7 @@ _dv_dct_248_block_mmx: + paddw %mm1, %mm0 # v20: v10+v11 + psubw %mm1, %mm3 # v21: v10-v11 + +- pmulhw WA1, %mm5 # v32~: WA1*v22 ++ pmulhw MUNG(WA1), %mm5 # v32~: WA1*v22 + movq %mm4, %mm2 + psllw $16-NSHIFT, %mm5 # v32: compensate the coeffient scale + +@@ -914,6 +924,8 @@ _dv_dct_248_block_mmx: + + .align 8 + .global _dv_dct_248_block_mmx_post_sum ++.hidden _dv_dct_248_block_mmx_post_sum ++.type _dv_dct_248_block_mmx_post_sum,@function + _dv_dct_248_block_mmx_post_sum: + + pushl %ebp +@@ -994,6 +1006,8 @@ _dv_dct_248_block_mmx_post_sum: + + .align 8 + .global _dv_dct_block_mmx_postscale_248 ++.hidden _dv_dct_block_mmx_postscale_248 ++.type _dv_dct_block_mmx_postscale_248,@function + _dv_dct_block_mmx_postscale_248: + + pushl %ebp +--- libdv/dct_block_mmx_x86_64.S 31 Jan 2005 13:27:54 -0000 1.2 ++++ libdv/dct_block_mmx_x86_64.S 15 Dec 2005 06:45:38 -0000 +@@ -59,6 +59,8 @@ scratch4: .quad 0 + + .align 8 + .global _dv_dct_88_block_mmx_x86_64 ++.hidden _dv_dct_88_block_mmx_x86_64 ++.type _dv_dct_88_block_mmx_x86_64,@function + _dv_dct_88_block_mmx_x86_64: + + /* void _dv_dct_88_block_mmx_x86_64(int16_t* block); */ +@@ -271,6 +273,8 @@ _dv_dct_88_block_mmx_x86_64: + + .align 8 + .global _dv_dct_block_mmx_x86_64_postscale_88 ++.hidden _dv_dct_block_mmx_x86_64_postscale_88 ++.type _dv_dct_block_mmx_x86_64_postscale_88,@function + _dv_dct_block_mmx_x86_64_postscale_88: + + /* void _dv_dct_block_mmx_x86_64_postscale_88(int16_t* block, int16_t* postscale_matrix); */ +--- libdv/dv.c 20 Oct 2004 03:49:24 -0000 1.31 ++++ libdv/dv.c 15 Dec 2005 06:45:38 -0000 +@@ -205,6 +205,9 @@ dv_reconfigure(int clamp_luma, int clamp + } /* dv_reconfigure */ + + ++extern uint8_t dv_quant_offset[4]; ++extern uint8_t dv_quant_shifts[22][4]; ++ + static inline void + dv_decode_macroblock(dv_decoder_t *dv, dv_macroblock_t *mb, unsigned int quality) { + int i; +@@ -218,7 +221,7 @@ dv_decode_macroblock(dv_decoder_t *dv, d + dv_idct_248 (co248, mb->b[i].coeffs); + } else { + #if ARCH_X86 +- _dv_quant_88_inverse_x86(mb->b[i].coeffs,mb->qno,mb->b[i].class_no); ++ _dv_quant_88_inverse_x86(mb->b[i].coeffs,mb->qno,mb->b[i].class_no,dv_quant_offset,dv_quant_shifts); + _dv_idct_88(mb->b[i].coeffs); + #elif ARCH_X86_64 + _dv_quant_88_inverse_x86_64(mb->b[i].coeffs,mb->qno,mb->b[i].class_no); +@@ -250,7 +253,7 @@ dv_decode_video_segment(dv_decoder_t *dv + dv_idct_248 (co248, mb->b[b].coeffs); + } else { + #if ARCH_X86 +- _dv_quant_88_inverse_x86(bl->coeffs,mb->qno,bl->class_no); ++ _dv_quant_88_inverse_x86(bl->coeffs,mb->qno,bl->class_no,dv_quant_offset,dv_quant_shifts); + _dv_weight_88_inverse(bl->coeffs); + _dv_idct_88(bl->coeffs); + #elif ARCH_X86_64 +--- libdv/encode.c 17 Nov 2004 03:36:30 -0000 1.26 ++++ libdv/encode.c 15 Dec 2005 06:45:38 -0000 +@@ -521,7 +521,8 @@ static void reorder_block(dv_block_t *bl + } + + extern unsigned long _dv_vlc_encode_block_mmx(dv_coeff_t* coeffs, +- dv_vlc_entry_t ** out); ++ dv_vlc_entry_t ** out, ++ dv_vlc_entry_t * lookup); + + extern unsigned long _dv_vlc_encode_block_mmx_x86_64(dv_coeff_t* coeffs, + dv_vlc_entry_t ** out); +@@ -558,7 +559,7 @@ static unsigned long vlc_encode_block(dv + #elif ARCH_X86 + int num_bits; + +- num_bits = _dv_vlc_encode_block_mmx(coeffs, &o); ++ num_bits = _dv_vlc_encode_block_mmx(coeffs, &o, vlc_encode_lookup); + emms(); + #else + int num_bits; +@@ -574,7 +575,7 @@ static unsigned long vlc_encode_block(dv + return num_bits; + } + +-extern unsigned long _dv_vlc_num_bits_block_x86(dv_coeff_t* coeffs); ++extern unsigned long _dv_vlc_num_bits_block_x86(dv_coeff_t* coeffs, unsigned char* lookup); + extern unsigned long _dv_vlc_num_bits_block_x86_64(dv_coeff_t* coeffs); + + extern unsigned long _dv_vlc_num_bits_block(dv_coeff_t* coeffs) +@@ -600,7 +601,7 @@ extern unsigned long _dv_vlc_num_bits_bl + #elif ARCH_X86_64 + return _dv_vlc_num_bits_block_x86_64(coeffs); + #else +- return _dv_vlc_num_bits_block_x86(coeffs); ++ return _dv_vlc_num_bits_block_x86(coeffs, vlc_num_bits_lookup); + #endif + } + +--- libdv/encode_x86.S 31 Jan 2005 13:27:54 -0000 1.4 ++++ libdv/encode_x86.S 15 Dec 2005 06:45:38 -0000 +@@ -23,16 +23,13 @@ + * The libdv homepage is http://libdv.sourceforge.net/. + */ + +-.data +-ALLONE: .word 1,1,1,1 +-VLCADDMASK: .byte 255,0,0,0,255,0,0,0 +- +- + .section .note.GNU-stack, "", @progbits + + .text + + .global _dv_vlc_encode_block_mmx ++.hidden _dv_vlc_encode_block_mmx ++.type _dv_vlc_encode_block_mmx,@function + _dv_vlc_encode_block_mmx: + pushl %ebx + pushl %esi +@@ -48,11 +45,14 @@ _dv_vlc_encode_block_mmx: + + movl $63, %ecx + +- movl vlc_encode_lookup, %esi ++ movl 4+4*4+8(%esp), %esi # vlc_encode_lookup + + pxor %mm0, %mm0 + pxor %mm2, %mm2 +- movq VLCADDMASK, %mm1 ++ pushl $0x000000FF # these four lines ++ pushl $0x000000FF # load VLCADDMASK ++ movq (%esp), %mm1 # into %mm1 off the stack ++ addl $8, %esp # --> no TEXTRELs + xorl %ebp, %ebp + subl $8, %edx + vlc_encode_block_mmx_loop: +@@ -109,6 +109,8 @@ vlc_encode_block_out: + ret + + .global _dv_vlc_num_bits_block_x86 ++.hidden _dv_vlc_num_bits_block_x86 ++.type _dv_vlc_num_bits_block_x86,@function + _dv_vlc_num_bits_block_x86: + pushl %ebx + pushl %esi +@@ -124,7 +126,7 @@ _dv_vlc_num_bits_block_x86: + addl $2, %edi + + movl $63, %ecx +- movl vlc_num_bits_lookup, %esi ++ movl 4+4*4+4(%esp), %esi # vlc_num_bits_lookup + + vlc_num_bits_block_x86_loop: + movw (%edi), %ax +@@ -167,6 +169,8 @@ vlc_num_bits_block_out: + ret + + .global _dv_vlc_encode_block_pass_1_x86 ++.hidden _dv_vlc_encode_block_pass_1_x86 ++.type _dv_vlc_encode_block_pass_1_x86,@function + _dv_vlc_encode_block_pass_1_x86: + pushl %ebx + pushl %esi +@@ -243,6 +247,8 @@ vlc_encode_block_pass1_x86_out: + ret + + .global _dv_classify_mmx ++.hidden _dv_classify_mmx ++.type _dv_classify_mmx,@function + _dv_classify_mmx: + + pushl %ebp +@@ -348,6 +354,8 @@ _dv_classify_mmx: + don't know why... */ + + .global _dv_reorder_block_mmx ++.hidden _dv_reorder_block_mmx ++.type _dv_reorder_block_mmx,@function + _dv_reorder_block_mmx: + + pushl %ebp +@@ -463,6 +471,8 @@ reorder_loop: + ret + + .global _dv_need_dct_248_mmx_rows ++.hidden _dv_need_dct_248_mmx_rows ++.type _dv_need_dct_248_mmx_rows,@function + _dv_need_dct_248_mmx_rows: + + pushl %ebp +@@ -582,8 +592,11 @@ _dv_need_dct_248_mmx_rows: + paddw %mm5, %mm1 + + paddw %mm1, %mm0 +- +- pmaddwd ALLONE, %mm0 ++ ++ pushl $0x00010001 # these four lines ++ pushl $0x00010001 # load ALLONE ++ pmaddwd (%esp), %mm0 # into %mm0 off the stack ++ addl $8, %esp # --> no TEXTRELs + movq %mm0, %mm1 + psrlq $32, %mm1 + paddd %mm1, %mm0 +--- libdv/encode_x86_64.S 31 Jan 2005 13:27:54 -0000 1.4 ++++ libdv/encode_x86_64.S 15 Dec 2005 06:45:39 -0000 +@@ -32,6 +32,8 @@ VLCADDMASK: .byte 255,0,0,0,255,0,0,0 + .text + + .global _dv_vlc_encode_block_mmx_x86_64 ++.hidden _dv_vlc_encode_block_mmx_x86_64 ++.type _dv_vlc_encode_block_mmx_x86_64,@function + _dv_vlc_encode_block_mmx_x86_64: + + /* extern unsigned long _dv_vlc_encode_block_mmx(dv_coeff_t* coeffs, +@@ -115,6 +117,8 @@ vlc_encode_block_out: + ret + + .global _dv_vlc_num_bits_block_x86_64 ++.hidden _dv_vlc_num_bits_block_x86_64 ++.type _dv_vlc_num_bits_block_x86_64,@function + _dv_vlc_num_bits_block_x86_64: + + /* extern unsigned long _dv_vlc_num_bits_block_x86_64(dv_coeff_t* coeffs); */ +@@ -175,6 +179,8 @@ vlc_num_bits_block_out: + ret + + .global _dv_vlc_encode_block_pass_1_x86_64 ++.hidden _dv_vlc_encode_block_pass_1_x86_64 ++.type _dv_vlc_encode_block_pass_1_x86_64,@function + _dv_vlc_encode_block_pass_1_x86_64: + + /* +@@ -253,6 +259,8 @@ vlc_encode_block_pass1_x86_out: + ret + + .global _dv_classify_mmx_x86_64 ++.hidden _dv_classify_mmx_x86_64 ++.type _dv_classify_mmx_x86_64,@function + _dv_classify_mmx_x86_64: + + /* extern int _dv_classify_mmx_x86_64(dv_coeff_t * a, rdi +@@ -357,6 +365,8 @@ _dv_classify_mmx_x86_64: + don't know why... */ + + .global _dv_reorder_block_mmx_x86_64 ++.hidden _dv_reorder_block_mmx_x86_64 ++.type _dv_reorder_block_mmx_x86_64,@function + _dv_reorder_block_mmx_x86_64: + + /*extern int _dv_reorder_block_mmx_x86_64(dv_coeff_t * a, rdi +@@ -471,6 +481,8 @@ reorder_loop: + ret + + .global _dv_need_dct_248_mmx_x86_64_rows ++.hidden _dv_need_dct_248_mmx_x86_64_rows ++.type _dv_need_dct_248_mmx_x86_64_rows,@function + _dv_need_dct_248_mmx_x86_64_rows: + + /* extern int _dv_need_dct_248_mmx_x86_64_rows(dv_coeff_t * bl); rdi */ +--- libdv/idct_block_mmx.S 31 Jan 2005 13:27:54 -0000 1.3 ++++ libdv/idct_block_mmx.S 15 Dec 2005 06:45:39 -0000 +@@ -8,16 +8,22 @@ + + .section .note.GNU-stack, "", @progbits + ++#include "asm_common.S" ++ + .text ++ + .align 4 + .globl _dv_idct_block_mmx ++.hidden _dv_idct_block_mmx + .type _dv_idct_block_mmx,@function + _dv_idct_block_mmx: + pushl %ebp +- movl %esp,%ebp + pushl %esi +- leal preSC, %ecx +- movl 8(%ebp),%esi /* source matrix */ ++ ++ LOAD_PIC_REG_BP() ++ ++ leal MUNG(preSC), %ecx ++ movl 12(%esp),%esi /* source matrix */ + + /* + * column 0: even part +@@ -35,7 +41,7 @@ _dv_idct_block_mmx: + movq %mm1, %mm2 /* added 11/1/96 */ + pmulhw 8*8(%esi),%mm5 /* V8 */ + psubsw %mm0, %mm1 /* V16 */ +- pmulhw x5a825a825a825a82, %mm1 /* 23170 ->V18 */ ++ pmulhw MUNG(x5a825a825a825a82), %mm1 /* 23170 ->V18 */ + paddsw %mm0, %mm2 /* V17 */ + movq %mm2, %mm0 /* duplicate V17 */ + psraw $1, %mm2 /* t75=t82 */ +@@ -76,7 +82,7 @@ _dv_idct_block_mmx: + paddsw %mm0, %mm3 /* V29 ; free mm0 */ + movq %mm7, %mm1 /* duplicate V26 */ + psraw $1, %mm3 /* t91=t94 */ +- pmulhw x539f539f539f539f,%mm7 /* V33 */ ++ pmulhw MUNG(x539f539f539f539f),%mm7 /* V33 */ + psraw $1, %mm1 /* t96 */ + movq %mm5, %mm0 /* duplicate V2 */ + psraw $2, %mm4 /* t85=t87 */ +@@ -84,15 +90,15 @@ _dv_idct_block_mmx: + psubsw %mm4, %mm0 /* V28 ; free mm4 */ + movq %mm0, %mm2 /* duplicate V28 */ + psraw $1, %mm5 /* t90=t93 */ +- pmulhw x4546454645464546,%mm0 /* V35 */ ++ pmulhw MUNG(x4546454645464546),%mm0 /* V35 */ + psraw $1, %mm2 /* t97 */ + movq %mm5, %mm4 /* duplicate t90=t93 */ + psubsw %mm2, %mm1 /* V32 ; free mm2 */ +- pmulhw x61f861f861f861f8,%mm1 /* V36 */ ++ pmulhw MUNG(x61f861f861f861f8),%mm1 /* V36 */ + psllw $1, %mm7 /* t107 */ + paddsw %mm3, %mm5 /* V31 */ + psubsw %mm3, %mm4 /* V30 ; free mm3 */ +- pmulhw x5a825a825a825a82,%mm4 /* V34 */ ++ pmulhw MUNG(x5a825a825a825a82),%mm4 /* V34 */ + nop + psubsw %mm1, %mm0 /* V38 */ + psubsw %mm7, %mm1 /* V37 ; free mm7 */ +@@ -159,7 +165,7 @@ _dv_idct_block_mmx: + psubsw %mm7, %mm1 /* V50 */ + pmulhw 8*9(%esi), %mm5 /* V9 */ + paddsw %mm7, %mm2 /* V51 */ +- pmulhw x5a825a825a825a82, %mm1 /* 23170 ->V52 */ ++ pmulhw MUNG(x5a825a825a825a82), %mm1 /* 23170 ->V52 */ + movq %mm2, %mm6 /* duplicate V51 */ + psraw $1, %mm2 /* t138=t144 */ + movq %mm3, %mm4 /* duplicate V1 */ +@@ -200,11 +206,11 @@ _dv_idct_block_mmx: + * even more by doing the correction step in a later stage when the number + * is actually multiplied by 16 + */ +- paddw x0005000200010001, %mm4 ++ paddw MUNG(x0005000200010001), %mm4 + psubsw %mm6, %mm3 /* V60 ; free mm6 */ + psraw $1, %mm0 /* t154=t156 */ + movq %mm3, %mm1 /* duplicate V60 */ +- pmulhw x539f539f539f539f, %mm1 /* V67 */ ++ pmulhw MUNG(x539f539f539f539f), %mm1 /* V67 */ + movq %mm5, %mm6 /* duplicate V3 */ + psraw $2, %mm4 /* t148=t150 */ + paddsw %mm4, %mm5 /* V61 */ +@@ -213,13 +219,13 @@ _dv_idct_block_mmx: + psllw $1, %mm1 /* t169 */ + paddsw %mm0, %mm5 /* V65 -> result */ + psubsw %mm0, %mm4 /* V64 ; free mm0 */ +- pmulhw x5a825a825a825a82, %mm4 /* V68 */ ++ pmulhw MUNG(x5a825a825a825a82), %mm4 /* V68 */ + psraw $1, %mm3 /* t158 */ + psubsw %mm6, %mm3 /* V66 */ + movq %mm5, %mm2 /* duplicate V65 */ +- pmulhw x61f861f861f861f8, %mm3 /* V70 */ ++ pmulhw MUNG(x61f861f861f861f8), %mm3 /* V70 */ + psllw $1, %mm6 /* t165 */ +- pmulhw x4546454645464546, %mm6 /* V69 */ ++ pmulhw MUNG(x4546454645464546), %mm6 /* V69 */ + psraw $1, %mm2 /* t172 */ + /* moved from next block */ + movq 8*5(%esi), %mm0 /* V56 */ +@@ -344,7 +350,7 @@ _dv_idct_block_mmx: + * movq 8*13(%esi), %mm4 tmt13 + */ + psubsw %mm4, %mm3 /* V134 */ +- pmulhw x5a825a825a825a82, %mm3 /* 23170 ->V136 */ ++ pmulhw MUNG(x5a825a825a825a82), %mm3 /* 23170 ->V136 */ + movq 8*9(%esi), %mm6 /* tmt9 */ + paddsw %mm4, %mm5 /* V135 ; mm4 free */ + movq %mm0, %mm4 /* duplicate tmt1 */ +@@ -373,17 +379,17 @@ _dv_idct_block_mmx: + psubsw %mm7, %mm0 /* V144 */ + movq %mm0, %mm3 /* duplicate V144 */ + paddsw %mm7, %mm2 /* V147 ; free mm7 */ +- pmulhw x539f539f539f539f, %mm0 /* 21407-> V151 */ ++ pmulhw MUNG(x539f539f539f539f), %mm0 /* 21407-> V151 */ + movq %mm1, %mm7 /* duplicate tmt3 */ + paddsw %mm5, %mm7 /* V145 */ + psubsw %mm5, %mm1 /* V146 ; free mm5 */ + psubsw %mm1, %mm3 /* V150 */ + movq %mm7, %mm5 /* duplicate V145 */ +- pmulhw x4546454645464546, %mm1 /* 17734-> V153 */ ++ pmulhw MUNG(x4546454645464546), %mm1 /* 17734-> V153 */ + psubsw %mm2, %mm5 /* V148 */ +- pmulhw x61f861f861f861f8, %mm3 /* 25080-> V154 */ ++ pmulhw MUNG(x61f861f861f861f8), %mm3 /* 25080-> V154 */ + psllw $2, %mm0 /* t311 */ +- pmulhw x5a825a825a825a82, %mm5 /* 23170-> V152 */ ++ pmulhw MUNG(x5a825a825a825a82), %mm5 /* 23170-> V152 */ + paddsw %mm2, %mm7 /* V149 ; free mm2 */ + psllw $1, %mm1 /* t313 */ + nop /* without the nop - freeze here for one clock */ +@@ -409,7 +415,7 @@ _dv_idct_block_mmx: + paddsw %mm3, %mm6 /* V164 ; free mm3 */ + movq %mm4, %mm3 /* duplicate V142 */ + psubsw %mm5, %mm4 /* V165 ; free mm5 */ +- movq %mm2, scratch7 /* out7 */ ++ movq %mm2, MUNG(scratch7) /* out7 */ + psraw $4, %mm6 + psraw $4, %mm4 + paddsw %mm5, %mm3 /* V162 */ +@@ -420,11 +426,11 @@ _dv_idct_block_mmx: + */ + movq %mm6, 8*9(%esi) /* out9 */ + paddsw %mm1, %mm0 /* V161 */ +- movq %mm3, scratch5 /* out5 */ ++ movq %mm3, MUNG(scratch5) /* out5 */ + psubsw %mm1, %mm5 /* V166 ; free mm1 */ + movq %mm4, 8*11(%esi) /* out11 */ + psraw $4, %mm5 +- movq %mm0, scratch3 /* out3 */ ++ movq %mm0, MUNG(scratch3) /* out3 */ + movq %mm2, %mm4 /* duplicate V140 */ + movq %mm5, 8*13(%esi) /* out13 */ + paddsw %mm7, %mm2 /* V160 */ +@@ -434,7 +440,7 @@ _dv_idct_block_mmx: + /* moved from the next block */ + movq 8*3(%esi), %mm7 + psraw $4, %mm4 +- movq %mm2, scratch1 /* out1 */ ++ movq %mm2, MUNG(scratch1) /* out1 */ + /* moved from the next block */ + movq %mm0, %mm1 + movq %mm4, 8*15(%esi) /* out15 */ +@@ -491,15 +497,15 @@ _dv_idct_block_mmx: + paddsw %mm4, %mm3 /* V113 ; free mm4 */ + movq %mm0, %mm4 /* duplicate V110 */ + paddsw %mm1, %mm2 /* V111 */ +- pmulhw x539f539f539f539f, %mm0 /* 21407-> V117 */ ++ pmulhw MUNG(x539f539f539f539f), %mm0 /* 21407-> V117 */ + psubsw %mm1, %mm5 /* V112 ; free mm1 */ + psubsw %mm5, %mm4 /* V116 */ + movq %mm2, %mm1 /* duplicate V111 */ +- pmulhw x4546454645464546, %mm5 /* 17734-> V119 */ ++ pmulhw MUNG(x4546454645464546), %mm5 /* 17734-> V119 */ + psubsw %mm3, %mm2 /* V114 */ +- pmulhw x61f861f861f861f8, %mm4 /* 25080-> V120 */ ++ pmulhw MUNG(x61f861f861f861f8), %mm4 /* 25080-> V120 */ + paddsw %mm3, %mm1 /* V115 ; free mm3 */ +- pmulhw x5a825a825a825a82, %mm2 /* 23170-> V118 */ ++ pmulhw MUNG(x5a825a825a825a82), %mm2 /* 23170-> V118 */ + psllw $2, %mm0 /* t266 */ + movq %mm1, (%esi) /* save V115 */ + psllw $1, %mm5 /* t268 */ +@@ -517,7 +523,7 @@ _dv_idct_block_mmx: + movq %mm6, %mm3 /* duplicate tmt4 */ + psubsw %mm0, %mm6 /* V100 */ + paddsw %mm0, %mm3 /* V101 ; free mm0 */ +- pmulhw x5a825a825a825a82, %mm6 /* 23170 ->V102 */ ++ pmulhw MUNG(x5a825a825a825a82), %mm6 /* 23170 ->V102 */ + movq %mm7, %mm5 /* duplicate tmt0 */ + movq 8*8(%esi), %mm1 /* tmt8 */ + paddsw %mm1, %mm7 /* V103 */ +@@ -551,10 +557,10 @@ _dv_idct_block_mmx: + movq 8*2(%esi), %mm3 /* V123 */ + paddsw %mm4, %mm7 /* out0 */ + /* moved up from next block */ +- movq scratch3, %mm0 ++ movq MUNG(scratch3), %mm0 + psraw $4, %mm7 + /* moved up from next block */ +- movq scratch5, %mm6 ++ movq MUNG(scratch5), %mm6 + psubsw %mm4, %mm1 /* out14 ; free mm4 */ + paddsw %mm3, %mm5 /* out2 */ + psraw $4, %mm1 +@@ -565,7 +571,7 @@ _dv_idct_block_mmx: + movq %mm5, 8*2(%esi) /* out2 ; free mm5 */ + psraw $4, %mm2 + /* moved up to the prev block */ +- movq scratch7, %mm4 ++ movq MUNG(scratch7), %mm4 + /* moved up to the prev block */ + psraw $4, %mm0 + movq %mm2, 8*12(%esi) /* out12 ; free mm2 */ +@@ -579,7 +585,7 @@ _dv_idct_block_mmx: + * psraw $4, %mm0 + * psraw $4, %mm6 + */ +- movq scratch1, %mm1 ++ movq MUNG(scratch1), %mm1 + psraw $4, %mm4 + movq %mm0, 8*3(%esi) /* out3 */ + psraw $4, %mm1 +--- libdv/idct_block_mmx_x86_64.S 31 Jan 2005 13:27:54 -0000 1.3 ++++ libdv/idct_block_mmx_x86_64.S 15 Dec 2005 06:45:39 -0000 +@@ -18,6 +18,7 @@ + .text + .align 4 + .globl _dv_idct_block_mmx_x86_64 ++.hidden _dv_idct_block_mmx_x86_64 + .type _dv_idct_block_mmx_x86_64,@function + _dv_idct_block_mmx_x86_64: + /* void _dv_idct_88(dv_coeff_t *block) */ +--- libdv/parse.c 20 Oct 2004 03:49:24 -0000 1.13 ++++ libdv/parse.c 15 Dec 2005 06:45:39 -0000 +@@ -477,6 +477,13 @@ dv_parse_ac_coeffs(dv_videosegment_t *se + exit(0); + #endif + } /* dv_parse_ac_coeffs */ ++#if defined __GNUC__ && __ELF__ ++# define dv_strong_hidden_alias(name, aliasname) \ ++ extern __typeof (name) aliasname __attribute__ ((alias (#name), visibility ("hidden"))) ++dv_strong_hidden_alias(dv_parse_ac_coeffs, asm_dv_parse_ac_coeffs); ++#else ++int asm_dv_parse_ac_coeffs(dv_videosegment_t *seg) { return dv_parse_ac_coeffs(seg); } ++#endif + + /* --------------------------------------------------------------------------- + */ +--- libdv/quant.c 20 Oct 2004 03:49:24 -0000 1.9 ++++ libdv/quant.c 15 Dec 2005 06:45:39 -0000 +@@ -144,7 +144,7 @@ uint8_t dv_quant_offset[4] = { 6,3,0,1 + uint32_t dv_quant_248_mul_tab [2] [22] [64]; + uint32_t dv_quant_88_mul_tab [2] [22] [64]; + +-extern void _dv_quant_x86(dv_coeff_t *block,int qno,int klass); ++extern void _dv_quant_x86(dv_coeff_t *block,int qno,int klass,uint8_t dv_quant_offset[],uint8_t dv_quant_shifts[][]); + extern void _dv_quant_x86_64(dv_coeff_t *block,int qno,int klass); + static void quant_248_inverse_std(dv_coeff_t *block,int qno,int klass,dv_248_coeff_t *co); + static void quant_248_inverse_mmx(dv_coeff_t *block,int qno,int klass,dv_248_coeff_t *co); +@@ -210,7 +210,7 @@ void _dv_quant(dv_coeff_t *block,int qno + _dv_quant_x86_64(block, qno, klass); + emms(); + #else +- _dv_quant_x86(block, qno, klass); ++ _dv_quant_x86(block, qno, klass, dv_quant_offset, dv_quant_shifts); + emms(); + #endif + } +--- libdv/quant.h 20 Oct 2004 03:49:24 -0000 1.4 ++++ libdv/quant.h 15 Dec 2005 06:45:39 -0000 +@@ -27,7 +27,7 @@ extern void _dv_quant(dv_coeff_t *block, + extern void _dv_quant_88_inverse(dv_coeff_t *block,int qno,int klass); + extern void (*_dv_quant_248_inverse) (dv_coeff_t *block,int qno,int klass, + dv_248_coeff_t *co); +-extern void _dv_quant_88_inverse_x86(dv_coeff_t *block,int qno,int klass); ++extern void _dv_quant_88_inverse_x86(dv_coeff_t *block,int qno,int klass, uint8_t offset[], uint8_t shifts[][]); + extern void _dv_quant_88_inverse_x86_64(dv_coeff_t *block,int qno,int klass); + extern void dv_quant_init (void); + #ifdef __cplusplus +--- libdv/quant_x86.S 31 Jan 2005 13:27:54 -0000 1.4 ++++ libdv/quant_x86.S 15 Dec 2005 06:45:39 -0000 +@@ -57,6 +57,8 @@ void _dv_quant_88_inverse(dv_coeff_t *bl + .text + .align 4 + .globl _dv_quant_88_inverse_x86 ++.hidden _dv_quant_88_inverse_x86 ++.type _dv_quant_88_inverse_x86,@function + _dv_quant_88_inverse_x86: + pushl %ebx + pushl %esi +@@ -73,10 +75,13 @@ _dv_quant_88_inverse_x86: + + /* pq = dv_quant_shifts[qno + dv_quant_offset[class]]; */ + movl ARGn(1),%eax /* qno */ ++ movl ARGn(3),%ebx /* dv_quant_offset */ ++ addl ARGn(2),%ebx /* class */ ++ movzbl (%ebx),%ecx + movl ARGn(2),%ebx /* class */ +- movzbl dv_quant_offset(%ebx),%ecx + addl %ecx,%eax +- leal dv_quant_shifts(,%eax,4),%edx /* edx is pq */ ++ movl ARGn(4),%edx /* dv_quant_shifts */ ++ leal (%edx,%eax,4),%edx /* edx is pq */ + + /* extra = (class == 3); */ + /* 0 1 2 3 */ +@@ -195,6 +200,8 @@ _dv_quant_88_inverse_x86: + + .align 4 + .globl _dv_quant_x86 ++.hidden _dv_quant_x86 ++.type _dv_quant_x86,@function + _dv_quant_x86: + pushl %ebx + pushl %ecx +@@ -214,11 +221,13 @@ _dv_quant_x86: + + /* pq = dv_quant_shifts[qno + dv_quant_offset[class]]; */ + movl ARGn(1),%eax /* qno */ ++ movl ARGn(3),%ebx /* offset */ ++ addl ARGn(2),%ebx /* class */ ++ movzbl (%ebx),%ecx + movl ARGn(2),%ebx /* class */ +- +- movzbl dv_quant_offset(%ebx),%ecx ++ movl ARGn(4),%edx /* shifts */ + addl %ecx,%eax +- leal dv_quant_shifts(,%eax,4),%edx /* edx is pq */ ++ leal (%edx,%eax,4),%edx /* edx is pq */ + + /* extra = (class == 3); */ + /* 0 1 2 3 */ +--- libdv/quant_x86_64.S 31 Jan 2005 13:27:54 -0000 1.4 ++++ libdv/quant_x86_64.S 15 Dec 2005 06:45:39 -0000 +@@ -57,6 +57,8 @@ void _dv_quant_88_inverse(dv_coeff_t *bl + .text + .align 4 + .globl _dv_quant_88_inverse_x86_64 ++.hidden _dv_quant_88_inverse_x86_64 ++.type _dv_quant_88_inverse_x86_64,@function + _dv_quant_88_inverse_x86_64: + + /* Args are at block=rdi, qno=rsi, class=rdx */ +@@ -197,6 +199,8 @@ _dv_quant_88_inverse_x86_64: + + .align 4 + .globl _dv_quant_x86_64 ++.hidden _dv_quant_x86_64 ++.type _dv_quant_x86_64,@function + _dv_quant_x86_64: + + /* Args are at block=rdi, qno=rsi, class=rdx */ +--- libdv/rgbtoyuv.S 31 Jan 2005 13:27:54 -0000 1.6 ++++ libdv/rgbtoyuv.S 15 Dec 2005 06:45:39 -0000 +@@ -41,9 +41,6 @@ + #define DV_WIDTH_SHORT_HALF 720 + #define DV_WIDTH_BYTE_HALF 360 + +-.global _dv_rgbtoycb_mmx +-# .global yuvtoycb_mmx +- + .data + + .align 8 +@@ -110,22 +107,26 @@ VR0GR: .long 0,0 + VBG0B: .long 0,0 + + #endif +- ++ + .section .note.GNU-stack, "", @progbits + ++#include "asm_common.S" ++ + .text + +-#define _inPtr 8 +-#define _rows 12 +-#define _columns 16 +-#define _outyPtr 20 +-#define _outuPtr 24 +-#define _outvPtr 28 ++#define _inPtr 24+8 ++#define _rows 24+12 ++#define _columns 24+16 ++#define _outyPtr 24+20 ++#define _outuPtr 24+24 ++#define _outvPtr 24+28 + ++.global _dv_rgbtoycb_mmx ++.hidden _dv_rgbtoycb_mmx ++.type _dv_rgbtoycb_mmx,@function + _dv_rgbtoycb_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %eax + pushl %ebx + pushl %ecx +@@ -133,46 +134,47 @@ _dv_rgbtoycb_mmx: + pushl %esi + pushl %edi + +- leal ZEROSX, %eax #This section gets around a bug ++ LOAD_PIC_REG_BP() ++ ++ leal MUNG(ZEROSX), %eax #This section gets around a bug + movq (%eax), %mm0 #unlikely to persist +- movq %mm0, ZEROS +- leal OFFSETDX, %eax ++ movq %mm0, MUNG(ZEROS) ++ leal MUNG(OFFSETDX), %eax + movq (%eax), %mm0 +- movq %mm0, OFFSETD +- leal OFFSETWX, %eax ++ movq %mm0, MUNG(OFFSETD) ++ leal MUNG(OFFSETWX), %eax + movq (%eax), %mm0 +- movq %mm0, OFFSETW +- leal OFFSETBX, %eax ++ movq %mm0, MUNG(OFFSETW) ++ leal MUNG(OFFSETBX), %eax + movq (%eax), %mm0 +- movq %mm0, OFFSETB +- leal YR0GRX, %eax ++ movq %mm0, MUNG(OFFSETB) ++ leal MUNG(YR0GRX), %eax + movq (%eax), %mm0 +- movq %mm0, YR0GR +- leal YBG0BX, %eax ++ movq %mm0, MUNG(YR0GR) ++ leal MUNG(YBG0BX), %eax + movq (%eax), %mm0 +- movq %mm0, YBG0B +- leal UR0GRX, %eax ++ movq %mm0, MUNG(YBG0B) ++ leal MUNG(UR0GRX), %eax + movq (%eax), %mm0 +- movq %mm0, UR0GR +- leal UBG0BX, %eax ++ movq %mm0, MUNG(UR0GR) ++ leal MUNG(UBG0BX), %eax + movq (%eax), %mm0 +- movq %mm0, UBG0B +- leal VR0GRX, %eax ++ movq %mm0, MUNG(UBG0B) ++ leal MUNG(VR0GRX), %eax + movq (%eax), %mm0 +- movq %mm0, VR0GR +- leal VBG0BX, %eax ++ movq %mm0, MUNG(VR0GR) ++ leal MUNG(VBG0BX), %eax + movq (%eax), %mm0 +- movq %mm0, VBG0B +- +- movl _rows(%ebp), %eax +- movl _columns(%ebp), %ebx ++ movq %mm0, MUNG(VBG0B) ++ movl _rows(%esp), %eax ++ movl _columns(%esp), %ebx + mull %ebx #number pixels + shrl $3, %eax #number of loops + movl %eax, %edi #loop counter in edi +- movl _inPtr(%ebp), %eax +- movl _outyPtr(%ebp), %ebx +- movl _outuPtr(%ebp), %ecx +- movl _outvPtr(%ebp), %edx ++ movl _inPtr(%esp), %eax ++ movl _outyPtr(%esp), %ebx ++ movl _outuPtr(%esp), %ecx ++ movl _outvPtr(%esp), %edx + rgbtoycb_mmx_loop: + movq (%eax), %mm1 #load G2R2B1G1R1B0G0R0 + pxor %mm6, %mm6 #0 -> mm6 +@@ -186,29 +188,29 @@ rgbtoycb_mmx_loop: + punpcklbw %mm6, %mm1 #B1G1R1B0 -> mm1 + movq %mm0, %mm2 #R1B0G0R0 -> mm2 + +- pmaddwd YR0GR, %mm0 #yrR1,ygG0+yrR0 -> mm0 ++ pmaddwd MUNG(YR0GR), %mm0 #yrR1,ygG0+yrR0 -> mm0 + movq %mm1, %mm3 #B1G1R1B0 -> mm3 + +- pmaddwd YBG0B, %mm1 #ybB1+ygG1,ybB0 -> mm1 ++ pmaddwd MUNG(YBG0B), %mm1 #ybB1+ygG1,ybB0 -> mm1 + movq %mm2, %mm4 #R1B0G0R0 -> mm4 + +- pmaddwd UR0GR, %mm2 #urR1,ugG0+urR0 -> mm2 ++ pmaddwd MUNG(UR0GR), %mm2 #urR1,ugG0+urR0 -> mm2 + movq %mm3, %mm5 #B1G1R1B0 -> mm5 + +- pmaddwd UBG0B, %mm3 #ubB1+ugG1,ubB0 -> mm3 ++ pmaddwd MUNG(UBG0B), %mm3 #ubB1+ugG1,ubB0 -> mm3 + punpckhbw %mm6, %mm7 # 00G2R2 -> mm7 + +- pmaddwd VR0GR, %mm4 #vrR1,vgG0+vrR0 -> mm4 ++ pmaddwd MUNG(VR0GR), %mm4 #vrR1,vgG0+vrR0 -> mm4 + paddd %mm1, %mm0 #Y1Y0 -> mm0 + +- pmaddwd VBG0B, %mm5 #vbB1+vgG1,vbB0 -> mm5 ++ pmaddwd MUNG(VBG0B), %mm5 #vbB1+vgG1,vbB0 -> mm5 + + movq 8(%eax), %mm1 #R5B4G4R4B3G3R3B2 -> mm1 + paddd %mm3, %mm2 #U1U0 -> mm2 + + movq %mm1, %mm6 #R5B4G4R4B3G3R3B2 -> mm6 + +- punpcklbw ZEROS, %mm1 #B3G3R3B2 -> mm1 ++ punpcklbw MUNG(ZEROS), %mm1 #B3G3R3B2 -> mm1 + paddd %mm5, %mm4 #V1V0 -> mm4 + + movq %mm1, %mm5 #B3G3R3B2 -> mm5 +@@ -216,29 +218,29 @@ rgbtoycb_mmx_loop: + + paddd %mm7, %mm1 #R3B200+00G2R2=R3B2G2R2->mm1 + +- punpckhbw ZEROS, %mm6 #R5B4G4R3 -> mm6 ++ punpckhbw MUNG(ZEROS), %mm6 #R5B4G4R3 -> mm6 + movq %mm1, %mm3 #R3B2G2R2 -> mm3 + +- pmaddwd YR0GR, %mm1 #yrR3,ygG2+yrR2 -> mm1 ++ pmaddwd MUNG(YR0GR), %mm1 #yrR3,ygG2+yrR2 -> mm1 + movq %mm5, %mm7 #B3G3R3B2 -> mm7 + +- pmaddwd YBG0B, %mm5 #ybB3+ygG3,ybB2 -> mm5 ++ pmaddwd MUNG(YBG0B), %mm5 #ybB3+ygG3,ybB2 -> mm5 + psrad $FIXPSHIFT, %mm0 #32-bit scaled Y1Y0 -> mm0 + +- movq %mm6, TEMP0 #R5B4G4R4 -> TEMP0 ++ movq %mm6, MUNG(TEMP0) #R5B4G4R4 -> TEMP0 + movq %mm3, %mm6 #R3B2G2R2 -> mm6 +- pmaddwd UR0GR, %mm6 #urR3,ugG2+urR2 -> mm6 ++ pmaddwd MUNG(UR0GR), %mm6 #urR3,ugG2+urR2 -> mm6 + psrad $FIXPSHIFT, %mm2 #32-bit scaled U1U0 -> mm2 + + paddd %mm5, %mm1 #Y3Y2 -> mm1 + movq %mm7, %mm5 #B3G3R3B2 -> mm5 +- pmaddwd UBG0B, %mm7 #ubB3+ugG3,ubB2 ++ pmaddwd MUNG(UBG0B), %mm7 #ubB3+ugG3,ubB2 + psrad $FIXPSHIFT, %mm1 #32-bit scaled Y3Y2 -> mm1 + +- pmaddwd VR0GR, %mm3 #vrR3,vgG2+vgR2 ++ pmaddwd MUNG(VR0GR), %mm3 #vrR3,vgG2+vgR2 + packssdw %mm1, %mm0 #Y3Y2Y1Y0 -> mm0 + +- pmaddwd VBG0B, %mm5 #vbB3+vgG3,vbB2 -> mm5 ++ pmaddwd MUNG(VBG0B), %mm5 #vbB3+vgG3,vbB2 -> mm5 + psrad $FIXPSHIFT, %mm4 #32-bit scaled V1V0 -> mm4 + + movq 16(%eax), %mm1 #B7G7R7B6G6R6B5G5 -> mm7 +@@ -253,58 +255,58 @@ rgbtoycb_mmx_loop: + movq %mm7, %mm5 #R7B6G6R6B5G500 -> mm5 + psrad $FIXPSHIFT, %mm3 #32-bit scaled V3V2 -> mm3 + +- paddw OFFSETY, %mm0 ++ paddw MUNG(OFFSETY), %mm0 + movq %mm0, (%ebx) #store Y3Y2Y1Y0 + packssdw %mm6, %mm2 #32-bit scaled U3U2U1U0 -> mm2 + +- movq TEMP0, %mm0 #R5B4G4R4 -> mm0 ++ movq MUNG(TEMP0), %mm0 #R5B4G4R4 -> mm0 + addl $8, %ebx +- +- punpcklbw ZEROS, %mm7 #B5G500 -> mm7 ++ ++ punpcklbw MUNG(ZEROS), %mm7 #B5G500 -> mm7 + movq %mm0, %mm6 #R5B4G4R4 -> mm6 + +- movq %mm2, TEMPU #32-bit scaled U3U2U1U0 -> TEMPU ++ movq %mm2, MUNG(TEMPU) #32-bit scaled U3U2U1U0 -> TEMPU + psrlq $32, %mm0 #00R5B4 -> mm0 + + paddw %mm0, %mm7 #B5G5R5B4 -> mm7 + movq %mm6, %mm2 #B5B4G4R4 -> mm2 + +- pmaddwd YR0GR, %mm2 #yrR5,ygG4+yrR4 -> mm2 ++ pmaddwd MUNG(YR0GR), %mm2 #yrR5,ygG4+yrR4 -> mm2 + movq %mm7, %mm0 #B5G5R5B4 -> mm0 + +- pmaddwd YBG0B, %mm7 #ybB5+ygG5,ybB4 -> mm7 ++ pmaddwd MUNG(YBG0B), %mm7 #ybB5+ygG5,ybB4 -> mm7 + packssdw %mm3, %mm4 #32-bit scaled V3V2V1V0 -> mm4 + + addl $24, %eax #increment RGB count + +- movq %mm4, TEMPV #(V3V2V1V0)/256 -> mm4 ++ movq %mm4, MUNG(TEMPV) #(V3V2V1V0)/256 -> mm4 + movq %mm6, %mm4 #B5B4G4R4 -> mm4 + +- pmaddwd UR0GR, %mm6 #urR5,ugG4+urR4 ++ pmaddwd MUNG(UR0GR), %mm6 #urR5,ugG4+urR4 + movq %mm0, %mm3 #B5G5R5B4 -> mm0 + +- pmaddwd UBG0B, %mm0 #ubB5+ugG5,ubB4 ++ pmaddwd MUNG(UBG0B), %mm0 #ubB5+ugG5,ubB4 + paddd %mm7, %mm2 #Y5Y4 -> mm2 + +- pmaddwd VR0GR, %mm4 #vrR5,vgG4+vrR4 -> mm4 ++ pmaddwd MUNG(VR0GR), %mm4 #vrR5,vgG4+vrR4 -> mm4 + pxor %mm7, %mm7 #0 -> mm7 + +- pmaddwd VBG0B, %mm3 #vbB5+vgG5,vbB4 -> mm3 ++ pmaddwd MUNG(VBG0B), %mm3 #vbB5+vgG5,vbB4 -> mm3 + punpckhbw %mm7, %mm1 #B7G7R7B6 -> mm1 + + paddd %mm6, %mm0 #U5U4 -> mm0 + movq %mm1, %mm6 #B7G7R7B6 -> mm6 + +- pmaddwd YBG0B, %mm6 #ybB7+ygG7,ybB6 -> mm6 ++ pmaddwd MUNG(YBG0B), %mm6 #ybB7+ygG7,ybB6 -> mm6 + punpckhbw %mm7, %mm5 #R7B6G6R6 -> mm5 + + movq %mm5, %mm7 #R7B6G6R6 -> mm7 + paddd %mm4, %mm3 #V5V4 -> mm3 + +- pmaddwd YR0GR, %mm5 #yrR7,ygG6+yrR6 -> mm5 ++ pmaddwd MUNG(YR0GR), %mm5 #yrR7,ygG6+yrR6 -> mm5 + movq %mm1, %mm4 #B7G7R7B6 -> mm4 + +- pmaddwd UBG0B, %mm4 #ubB7+ugG7,ubB6 -> mm4 ++ pmaddwd MUNG(UBG0B), %mm4 #ubB7+ugG7,ubB6 -> mm4 + psrad $FIXPSHIFT, %mm0 #32-bit scaled U5U4 -> mm0 + + psrad $FIXPSHIFT, %mm2 #32-bit scaled Y5Y4 -> mm2 +@@ -312,25 +314,25 @@ rgbtoycb_mmx_loop: + paddd %mm5, %mm6 #Y7Y6 -> mm6 + movq %mm7, %mm5 #R7B6G6R6 -> mm5 + +- pmaddwd UR0GR, %mm7 #urR7,ugG6+ugR6 -> mm7 ++ pmaddwd MUNG(UR0GR), %mm7 #urR7,ugG6+ugR6 -> mm7 + psrad $FIXPSHIFT, %mm3 #32-bit scaled V5V4 -> mm3 + +- pmaddwd VBG0B, %mm1 #vbB7+vgG7,vbB6 -> mm1 ++ pmaddwd MUNG(VBG0B), %mm1 #vbB7+vgG7,vbB6 -> mm1 + psrad $FIXPSHIFT, %mm6 #32-bit scaled Y7Y6 -> mm6 + + packssdw %mm6, %mm2 #Y7Y6Y5Y4 -> mm2 + +- pmaddwd VR0GR, %mm5 #vrR7,vgG6+vrR6 -> mm5 ++ pmaddwd MUNG(VR0GR), %mm5 #vrR7,vgG6+vrR6 -> mm5 + paddd %mm4, %mm7 #U7U6 -> mm7 + + psrad $FIXPSHIFT, %mm7 #32-bit scaled U7U6 -> mm7 +- paddw OFFSETY, %mm2 ++ paddw MUNG(OFFSETY), %mm2 + movq %mm2, (%ebx) #store Y7Y6Y5Y4 + +- movq ALLONE, %mm6 ++ movq MUNG(ALLONE), %mm6 + packssdw %mm7, %mm0 #32-bit scaled U7U6U5U4 -> mm0 + +- movq TEMPU, %mm4 #32-bit scaled U3U2U1U0 -> mm4 ++ movq MUNG(TEMPU), %mm4 #32-bit scaled U3U2U1U0 -> mm4 + pmaddwd %mm6, %mm0 #U7U6U5U4 averaged -> (U7U6)(U5U4)=UU3 UU2->mm0 + + pmaddwd %mm6, %mm4 #U3U2U1U0 averaged -> (U3U2)(U1U0)=UU1 UU0->mm4 +@@ -340,8 +342,8 @@ rgbtoycb_mmx_loop: + + psrad $FIXPSHIFT, %mm1 #32-bit scaled V7V6 -> mm1 + psraw $1, %mm4 #divide UU3 UU2 UU1 UU0 by 2 -> mm4 +- +- movq TEMPV, %mm5 #32-bit scaled V3V2V1V0 -> mm5 ++ ++ movq MUNG(TEMPV), %mm5 #32-bit scaled V3V2V1V0 -> mm5 + + movq %mm4, (%ecx) # store U + +@@ -374,6 +376,8 @@ rgbtoycb_mmx_loop: + ret + + .global _dv_ppm_copy_y_block_mmx ++.hidden _dv_ppm_copy_y_block_mmx ++.type _dv_ppm_copy_y_block_mmx,@function + _dv_ppm_copy_y_block_mmx: + + pushl %ebp +@@ -424,17 +428,20 @@ _dv_ppm_copy_y_block_mmx: + ret + + .global _dv_pgm_copy_y_block_mmx ++.hidden _dv_pgm_copy_y_block_mmx ++.type _dv_ppm_copy_y_block_mmx,@function + _dv_pgm_copy_y_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + pushl %edi +- +- movl 8(%ebp), %edi # dest +- movl 12(%ebp), %esi # src + +- movq OFFSETY, %mm7 ++ LOAD_PIC_REG_BP() ++ ++ movl 16(%esp), %edi # dest ++ movl 20(%esp), %esi # src ++ ++ movq MUNG(OFFSETY), %mm7 + pxor %mm6, %mm6 + + movq (%esi), %mm0 +@@ -566,17 +573,20 @@ _dv_pgm_copy_y_block_mmx: + ret + + .global _dv_video_copy_y_block_mmx ++.hidden _dv_video_copy_y_block_mmx ++.type _dv_video_copy_y_block_mmx,@function + _dv_video_copy_y_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + pushl %edi +- +- movl 8(%ebp), %edi # dest +- movl 12(%ebp), %esi # src + +- movq OFFSETBX, %mm7 ++ LOAD_PIC_REG_BP() ++ ++ movl 16(%esp), %edi # dest ++ movl 20(%esp), %esi # src ++ ++ movq MUNG(OFFSETBX), %mm7 + pxor %mm6, %mm6 + + movq (%esi), %mm0 +@@ -711,6 +721,8 @@ _dv_video_copy_y_block_mmx: + + + .global _dv_ppm_copy_pal_c_block_mmx ++.hidden _dv_ppm_copy_pal_c_block_mmx ++.type _dv_ppm_copy_pal_c_block_mmx,@function + _dv_ppm_copy_pal_c_block_mmx: + + pushl %ebp +@@ -854,19 +866,21 @@ _dv_ppm_copy_pal_c_block_mmx: + ret + + .global _dv_pgm_copy_pal_c_block_mmx ++.hidden _dv_ppm_copy_pal_c_block_mmx ++.type _dv_pgm_copy_pal_c_block_mmx,@function + _dv_pgm_copy_pal_c_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + pushl %edi + pushl %ebx +- +- movl 8(%ebp), %edi # dest +- movl 12(%ebp), %esi # src + ++ LOAD_PIC_REG_BP() ++ ++ movl 20(%esp), %edi # dest ++ movl 24(%esp), %esi # src + +- movq OFFSETBX, %mm7 ++ movq MUNG(OFFSETBX), %mm7 + pxor %mm6, %mm6 + + +@@ -1002,18 +1016,21 @@ _dv_pgm_copy_pal_c_block_mmx: + ret + + .global _dv_video_copy_pal_c_block_mmx ++.hidden _dv_video_copy_pal_c_block_mmx ++.type _dv_video_copy_pal_c_block_mmx,@function + _dv_video_copy_pal_c_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + pushl %edi + pushl %ebx +- +- movl 8(%ebp), %edi # dest +- movl 12(%ebp), %esi # src + +- movq OFFSETBX, %mm7 ++ LOAD_PIC_REG_BP() ++ ++ movl 20(%esp), %edi # dest ++ movl 24(%esp), %esi # src ++ ++ movq MUNG(OFFSETBX), %mm7 + paddw %mm7, %mm7 + pxor %mm6, %mm6 + +@@ -1097,21 +1114,23 @@ video_copy_pal_c_block_mmx_loop: + ret + + .global _dv_ppm_copy_ntsc_c_block_mmx ++.hidden _dv_ppm_copy_ntsc_c_block_mmx ++.type _dv_ppm_copy_ntsc_c_block_mmx,@function + _dv_ppm_copy_ntsc_c_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + pushl %edi + pushl %ebx +- +- movl 8(%ebp), %edi # dest +- movl 12(%ebp), %esi # src ++ ++ LOAD_PIC_REG_BP() ++ ++ movl 20(%esp), %edi # dest ++ movl 24(%esp), %esi # src + + movl $4, %ebx + +- movq ALLONE, %mm6 +- ++ movq MUNG(ALLONE), %mm6 + ppm_copy_ntsc_c_block_mmx_loop: + + movq (%esi), %mm0 +@@ -1170,17 +1189,20 @@ ppm_copy_ntsc_c_block_mmx_loop: + ret + + .global _dv_pgm_copy_ntsc_c_block_mmx ++.hidden _dv_pgm_copy_ntsc_c_block_mmx ++.type _dv_pgm_copy_ntsc_c_block_mmx,@function + _dv_pgm_copy_ntsc_c_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + pushl %edi +- +- movl 8(%ebp), %edi # dest +- movl 12(%ebp), %esi # src + +- movq OFFSETBX, %mm7 ++ LOAD_PIC_REG_BP() ++ ++ movl 16(%esp), %edi # dest ++ movl 20(%esp), %esi # src ++ ++ movq MUNG(OFFSETBX), %mm7 + paddw %mm7, %mm7 + pxor %mm6, %mm6 + +@@ -1327,18 +1349,21 @@ _dv_pgm_copy_ntsc_c_block_mmx: + ret + + .global _dv_video_copy_ntsc_c_block_mmx ++.hidden _dv_video_copy_ntsc_c_block_mmx ++.type _dv_video_copy_ntsc_c_block_mmx,@function + _dv_video_copy_ntsc_c_block_mmx: + + pushl %ebp +- movl %esp, %ebp + pushl %esi + pushl %edi + pushl %ebx +- +- movl 8(%ebp), %edi # dest +- movl 12(%ebp), %esi # src + +- movq OFFSETBX, %mm7 ++ LOAD_PIC_REG_BP() ++ ++ movl 20(%esp), %edi # dest ++ movl 24(%esp), %esi # src ++ ++ movq MUNG(OFFSETBX), %mm7 + paddw %mm7, %mm7 + pxor %mm6, %mm6 + +--- libdv/rgbtoyuv_x86_64.S 31 Jan 2005 13:27:54 -0000 1.2 ++++ libdv/rgbtoyuv_x86_64.S 15 Dec 2005 06:45:39 -0000 +@@ -41,9 +41,6 @@ + #define DV_WIDTH_SHORT_HALF 720 + #define DV_WIDTH_BYTE_HALF 360 + +-.global _dv_rgbtoycb_mmx_x86_64 +-# .global yuvtoycb_mmx_x86_64 +- + .data + + .align 8 +--- libdv/transpose_x86.S 31 Jan 2005 13:27:54 -0000 1.3 ++++ libdv/transpose_x86.S 15 Dec 2005 06:45:39 -0000 +@@ -2,6 +2,8 @@ + + .text + .global _dv_transpose_mmx ++.hidden _dv_transpose_mmx ++.type _dv_transpose_mmx,@function + + _dv_transpose_mmx: + pushl %ebp +--- libdv/transpose_x86_64.S 31 Jan 2005 13:27:54 -0000 1.2 ++++ libdv/transpose_x86_64.S 15 Dec 2005 06:45:39 -0000 +@@ -2,6 +2,8 @@ + + .text + .global _dv_transpose_mmx_x86_64 ++.hidden _dv_transpose_mmx_x86_64 ++.type _dv_transpose_mmx_x86_64,@function + + _dv_transpose_mmx_x86_64: + +--- libdv/vlc_x86.S 31 Jan 2005 13:27:54 -0000 1.3 ++++ libdv/vlc_x86.S 15 Dec 2005 06:45:40 -0000 +@@ -1,31 +1,42 @@ + #include "asmoff.h" + .section .note.GNU-stack, "", @progbits + ++#include "asm_common.S" ++ + .text ++ + .align 4 ++ ++.hidden asm_dv_decode_vlc ++.globl asm_dv_decode_vlc ++ asm_dv_decode_vlc = dv_decode_vlc ++ + .globl dv_decode_vlc + .type dv_decode_vlc,@function + dv_decode_vlc: + pushl %ebx ++ pushl %ebp + +- /* Args are at 8(%esp). */ +- movl 8(%esp),%eax /* %eax is bits */ +- movl 12(%esp),%ebx /* %ebx is maxbits */ ++ LOAD_PIC_REG_BP() ++ ++ /* Args are at 12(%esp). */ ++ movl 12(%esp),%eax /* %eax is bits */ ++ movl 16(%esp),%ebx /* %ebx is maxbits */ + andl $0x3f,%ebx /* limit index range STL*/ + +- movl dv_vlc_class_index_mask(,%ebx,4),%edx ++ movl MUNG_ARR(dv_vlc_class_index_mask,%ebx,4),%edx + andl %eax,%edx +- movl dv_vlc_class_index_rshift(,%ebx,4),%ecx ++ movl MUNG_ARR(dv_vlc_class_index_rshift,%ebx,4),%ecx + sarl %cl,%edx +- movl dv_vlc_classes(,%ebx,4),%ecx ++ movl MUNG_ARR(dv_vlc_classes,%ebx,4),%ecx + movsbl (%ecx,%edx,1),%edx /* %edx is class */ +- +- movl dv_vlc_index_mask(,%edx,4),%ebx +- movl dv_vlc_index_rshift(,%edx,4),%ecx ++ ++ movl MUNG_ARR(dv_vlc_index_mask,%edx,4),%ebx ++ movl MUNG_ARR(dv_vlc_index_rshift,%edx,4),%ecx + andl %eax,%ebx + sarl %cl,%ebx + +- movl dv_vlc_lookups(,%edx,4),%edx ++ movl MUNG_ARR(dv_vlc_lookups,%edx,4),%edx + movl (%edx,%ebx,4),%edx + + /* Now %edx holds result, like this: +@@ -44,7 +55,7 @@ dv_decode_vlc: + movl %edx,%ecx + sarl $8,%ecx + andl $0xff,%ecx +- movl sign_mask(,%ecx,4),%ebx ++ movl MUNG_ARR(sign_mask,%ecx,4),%ebx + andl %ebx,%eax + negl %eax + sarl $31,%eax +@@ -65,14 +76,14 @@ dv_decode_vlc: + *result = broken; + Note that the 'broken' pattern is all ones (i.e. 0xffffffff) + */ +- movl 12(%esp),%ebx /* %ebx is maxbits */ ++ movl 16(%esp),%ebx /* %ebx is maxbits */ + subl %ecx,%ebx + sbbl %ebx,%ebx + orl %ebx,%edx + +- movl 16(%esp),%eax ++ movl 20(%esp),%eax + movl %edx,(%eax) +- ++ popl %ebp + popl %ebx + ret + +@@ -82,21 +93,28 @@ dv_decode_vlc: + .type __dv_decode_vlc,@function + __dv_decode_vlc: + pushl %ebx ++ pushl %ebp + +- /* Args are at 8(%esp). */ +- movl 8(%esp),%eax /* %eax is bits */ ++ LOAD_PIC_REG_BP() ++ ++ /* Args are at 12(%esp). */ ++ movl 12(%esp),%eax /* %eax is bits */ + + movl %eax,%edx /* %edx is class */ + andl $0xfe00,%edx + sarl $9,%edx ++#ifdef __PIC__ ++ movsbl dv_vlc_class_lookup5@GOTOFF(%ebp,%edx),%edx ++#else + movsbl dv_vlc_class_lookup5(%edx),%edx +- +- movl dv_vlc_index_mask(,%edx,4),%ebx +- movl dv_vlc_index_rshift(,%edx,4),%ecx ++#endif ++ ++ movl MUNG_ARR(dv_vlc_index_mask,%edx,4),%ebx ++ movl MUNG_ARR(dv_vlc_index_rshift,%edx,4),%ecx + andl %eax,%ebx + sarl %cl,%ebx + +- movl dv_vlc_lookups(,%edx,4),%edx ++ movl MUNG_ARR(dv_vlc_lookups,%edx,4),%edx + movl (%edx,%ebx,4),%edx + + /* Now %edx holds result, like this: +@@ -114,7 +132,7 @@ __dv_decode_vlc: + movl %edx,%ecx + sarl $8,%ecx + andl $0xff,%ecx +- movl sign_mask(,%ecx,4),%ecx ++ movl MUNG_ARR(sign_mask,%ecx,4),%ecx + andl %ecx,%eax + negl %eax + sarl $31,%eax +@@ -129,9 +147,9 @@ __dv_decode_vlc: + xorl %eax,%edx + subl %eax,%edx + +- movl 12(%esp),%eax ++ movl 16(%esp),%eax + movl %edx,(%eax) +- ++ popl %ebp + popl %ebx + ret + +@@ -142,13 +160,20 @@ void dv_parse_ac_coeffs_pass0(bitstream_ + */ + .text + .align 4 ++.hidden asm_dv_parse_ac_coeffs_pass0 ++.globl asm_dv_parse_ac_coeffs_pass0 ++ asm_dv_parse_ac_coeffs_pass0 = dv_parse_ac_coeffs_pass0 ++ + .globl dv_parse_ac_coeffs_pass0 ++.type dv_parse_ac_coeffs_pass0,@function + dv_parse_ac_coeffs_pass0: + pushl %ebx + pushl %edi + pushl %esi + pushl %ebp + ++ LOAD_PIC_REG_SI() ++ + #define ARGn(N) (20+(4*(N)))(%esp) + + /* +@@ -161,8 +186,10 @@ dv_parse_ac_coeffs_pass0: + ebp bl + */ + movl ARGn(2),%ebp ++#ifndef __PIC__ + movl ARGn(0),%esi + movl bitstream_t_buf(%esi),%esi ++#endif + movl dv_block_t_offset(%ebp),%edi + movl dv_block_t_reorder(%ebp),%ebx + +@@ -172,7 +199,11 @@ dv_parse_ac_coeffs_pass0: + + movq dv_block_t_coeffs(%ebp),%mm1 + pxor %mm0,%mm0 ++#ifdef __PIC__ ++ pand const_f_0_0_0@GOTOFF(%esi),%mm1 ++#else + pand const_f_0_0_0,%mm1 ++#endif + movq %mm1,dv_block_t_coeffs(%ebp) + movq %mm0,(dv_block_t_coeffs + 8)(%ebp) + movq %mm0,(dv_block_t_coeffs + 16)(%ebp) +@@ -193,9 +224,17 @@ dv_parse_ac_coeffs_pass0: + readloop: + movl %edi,%ecx + shrl $3,%ecx ++#ifdef __PIC__ ++ pushl %esi ++ movl ARGn(1),%esi ++ movl bitstream_t_buf(%esi),%esi ++#endif + movzbl (%esi,%ecx,1),%eax + movzbl 1(%esi,%ecx,1),%edx + movzbl 2(%esi,%ecx,1),%ecx ++#ifdef __PIC__ ++ popl %esi ++#endif + shll $16,%eax + shll $8,%edx + orl %ecx,%eax +@@ -219,7 +258,11 @@ readloop: + + /* Attempt to use the shortcut first. If it hits, then + this vlc term has been decoded. */ ++#ifdef __PIC__ ++ movl dv_vlc_class1_shortcut@GOTOFF(%esi,%ecx,4),%edx ++#else + movl dv_vlc_class1_shortcut(,%ecx,4),%edx ++#endif + test $0x80,%edx + je done_decode + +@@ -230,12 +273,19 @@ readloop: + movl %ebx,dv_block_t_reorder(%ebp) + + /* %eax is bits */ +- ++#ifdef __PIC__ ++ movsbl dv_vlc_class_lookup5@GOTOFF(%esi,%ecx),%ecx ++ ++ movl dv_vlc_index_mask@GOTOFF(%esi,%ecx,4),%ebx ++ movl dv_vlc_lookups@GOTOFF(%esi,%ecx,4),%edx ++ movl dv_vlc_index_rshift@GOTOFF(%esi,%ecx,4),%ecx ++#else + movsbl dv_vlc_class_lookup5(%ecx),%ecx + + movl dv_vlc_index_mask(,%ecx,4),%ebx + movl dv_vlc_lookups(,%ecx,4),%edx + movl dv_vlc_index_rshift(,%ecx,4),%ecx ++#endif + andl %eax,%ebx + sarl %cl,%ebx + +@@ -258,7 +308,11 @@ readloop: + movl %edx,%ecx + sarl $8,%ecx + andl $0xff,%ecx ++#ifdef __PIC__ ++ movl sign_mask@GOTOFF(%esi,%ecx,4),%ecx ++#else + movl sign_mask(,%ecx,4),%ecx ++#endif + andl %ecx,%eax + negl %eax + sarl $31,%eax +@@ -328,10 +382,16 @@ alldone: + + slowpath: + /* slow path: use dv_decode_vlc */; ++#ifdef __PIC__ ++ pushl %esi ++ leal vlc@GOTOFF(%esi),%esi ++ xchgl %esi,(%esp) /* last parameter is &vlc */ ++#else + pushl $vlc /* last parameter is &vlc */ ++#endif + pushl %edx /* bits_left */ + pushl %eax /* bits */ +- call dv_decode_vlc ++ call asm_dv_decode_vlc + addl $12,%esp + test $0x80,%edx /* If (vlc.run < 0) break */ + jne escape +@@ -361,12 +421,15 @@ show16: + gint dv_parse_video_segment(dv_videosegment_t *seg, guint quality) { + */ + .globl dv_parse_video_segment ++ .type dv_parse_video_segment,@function + dv_parse_video_segment: + pushl %ebx + pushl %edi + pushl %esi + pushl %ebp + ++ LOAD_PIC_REG_SI() ++ + #define ARGn(N) (20+(4*(N)))(%esp) + + movl ARGn(1),%eax /* quality */ +@@ -375,7 +438,11 @@ dv_parse_video_segment: + jz its_mono + movl $6,%ebx + its_mono: ++#ifdef __PIC__ ++ movl %ebx,n_blocks@GOTOFF(%esi) ++#else + movl %ebx,n_blocks ++#endif + + /* + * ebx seg/b +@@ -386,15 +453,22 @@ its_mono: + * ebp bl + */ + movl ARGn(0),%ebx ++#ifndef __PIC__ + movl dv_videosegment_t_bs(%ebx),%esi + movl bitstream_t_buf(%esi),%esi ++#endif + leal dv_videosegment_t_mb(%ebx),%edi + + movl $0,%eax + movl $0,%ecx + macloop: ++#ifdef __PIC__ ++ movl %eax,m@GOTOFF(%esi) ++ movl %ecx,mb_start@GOTOFF(%esi) ++#else + movl %eax,m + movl %ecx,mb_start ++#endif + + movl ARGn(0),%ebx + +@@ -402,7 +476,15 @@ macloop: + /* mb->qno = bitstream_get(bs,4); */ + movl %ecx,%edx + shr $3,%edx ++#ifdef __PIC__ ++ pushl %esi ++ movl dv_videosegment_t_bs(%ebx),%esi ++ movl bitstream_t_buf(%esi),%esi ++#endif + movzbl 3(%esi,%edx,1),%edx ++#ifdef __PIC__ ++ popl %esi ++#endif + andl $0xf,%edx + movl %edx,dv_macroblock_t_qno(%edi) + +@@ -413,7 +495,11 @@ macloop: + movl %edx,dv_macroblock_t_eob_count(%edi) + + /* mb->i = (seg->i + dv_super_map_vertical[m]) % (seg->isPAL?12:10); */ ++#ifdef __PIC__ ++ movl dv_super_map_vertical@GOTOFF(%esi,%eax,4),%edx ++#else + movl dv_super_map_vertical(,%eax,4),%edx ++#endif + movl dv_videosegment_t_i(%ebx),%ecx + addl %ecx,%edx + +@@ -424,11 +510,20 @@ skarly: + andl $1,%ecx + shll $5,%ecx /* ecx = (isPAL ? 32 : 0) */ + ++#ifdef __PIC__ ++ leal mod_10@GOTOFF(%esi,%edx),%edx ++ movzbl (%edx,%ecx,1),%edx /* uses mod_12 for PAL */ ++#else + movzbl mod_10(%edx,%ecx,1),%edx /* uses mod_12 for PAL */ ++#endif + movl %edx,dv_macroblock_t_i(%edi) + + /* mb->j = dv_super_map_horizontal[m]; */ ++#ifdef __PIC__ ++ movl dv_super_map_horizontal@GOTOFF(%esi,%eax,4),%edx ++#else + movl dv_super_map_horizontal(,%eax,4),%edx ++#endif + movl %edx,dv_macroblock_t_j(%edi) + + /* mb->k = seg->k; */ +@@ -447,12 +542,29 @@ blkloop: + +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ + */ + /* dc = bitstream_get(bs,9); */ ++#ifdef __PIC__ ++ movl mb_start@GOTOFF(%esi),%ecx ++#else + movl mb_start,%ecx ++#endif + shr $3,%ecx ++#ifdef __PIC__ ++ movzbl blk_start@GOTOFF(%esi,%ebx),%edx ++#else + movzbl blk_start(%ebx),%edx ++#endif + addl %ecx,%edx ++#ifdef __PIC__ ++ pushl %esi ++ movl ARGn(1),%esi ++ movl dv_videosegment_t_bs(%esi),%esi ++ movl bitstream_t_buf(%esi),%esi ++#endif + movzbl (%esi,%edx,1),%eax /* hi byte */ + movzbl 1(%esi,%edx,1),%ecx /* lo byte */ ++#ifdef __PIC__ ++ popl %esi ++#endif + shll $8,%eax + orl %ecx,%eax + +@@ -479,7 +591,11 @@ blkloop: + + /* bl->reorder = &dv_reorder[bl->dct_mode][1]; */ + shll $6,%eax ++#ifdef __PIC__ ++ addl dv_reorder@GOTOFF+1(%esi),%eax ++#else + addl $(dv_reorder+1),%eax ++#endif + movl %eax,dv_block_t_reorder(%ebp) + + /* bl->reorder_sentinel = bl->reorder + 63; */ +@@ -487,13 +603,22 @@ blkloop: + movl %eax,dv_block_t_reorder_sentinel(%ebp) + + /* bl->offset= mb_start + dv_parse_bit_start[b]; */ ++#ifdef __PIC__ ++ movl mb_start@GOTOFF(%esi),%ecx ++ movl dv_parse_bit_start@GOTOFF(%esi,%ebx,4),%eax ++#else + movl mb_start,%ecx + movl dv_parse_bit_start(,%ebx,4),%eax ++#endif + addl %ecx,%eax + movl %eax,dv_block_t_offset(%ebp) + + /* bl->end= mb_start + dv_parse_bit_end[b]; */ ++#ifdef __PIC__ ++ movl dv_parse_bit_end@GOTOFF(%esi,%ebx,4),%eax ++#else + movl dv_parse_bit_end(,%ebx,4),%eax ++#endif + addl %ecx,%eax + movl %eax,dv_block_t_end(%ebp) + +@@ -505,7 +630,11 @@ blkloop: + /* no AC pass. Just zero out the remaining coeffs */ + movq dv_block_t_coeffs(%ebp),%mm1 + pxor %mm0,%mm0 ++#ifdef __PIC__ ++ pand const_f_0_0_0@GOTOFF(%esi),%mm1 ++#else + pand const_f_0_0_0,%mm1 ++#endif + movq %mm1,dv_block_t_coeffs(%ebp) + movq %mm0,(dv_block_t_coeffs + 8)(%ebp) + movq %mm0,(dv_block_t_coeffs + 16)(%ebp) +@@ -530,18 +659,27 @@ do_ac_pass: + pushl %ebp + pushl %edi + pushl %eax +- call dv_parse_ac_coeffs_pass0 ++ call asm_dv_parse_ac_coeffs_pass0 + addl $12,%esp + done_ac: + ++#ifdef __PIC__ ++ movl n_blocks@GOTOFF(%esi),%eax ++#else + movl n_blocks,%eax ++#endif + addl $dv_block_t_size,%ebp + incl %ebx + cmpl %eax,%ebx + jnz blkloop + ++#ifdef __PIC__ ++ movl m@GOTOFF(%esi),%eax ++ movl mb_start@GOTOFF(%esi),%ecx ++#else + movl m,%eax + movl mb_start,%ecx ++#endif + addl $(8 * 80),%ecx + addl $dv_macroblock_t_size,%edi + incl %eax +@@ -559,7 +697,7 @@ done_ac: + + andl $DV_QUALITY_AC_MASK,%eax + cmpl $DV_QUALITY_AC_2,%eax +- jz dv_parse_ac_coeffs ++ jz asm_dv_parse_ac_coeffs + movl $0,%eax + ret + +--- libdv/vlc_x86_64.S 31 Jan 2005 13:27:54 -0000 1.3 ++++ libdv/vlc_x86_64.S 15 Dec 2005 06:45:40 -0000 +@@ -171,7 +171,8 @@ void dv_parse_ac_coeffs_pass0(bitstream_ + .text + .align 4 + .globl dv_parse_ac_coeffs_pass0 +- ++.type dv_parse_ac_coeffs_pass0,@function ++ + dv_parse_ac_coeffs_pass0: + + /* Args are at rdi=bs, rsi=mb, rdx=bl */ +@@ -424,6 +425,7 @@ show16: /* not u + gint dv_parse_video_segment(dv_videosegment_t *seg, guint quality) { + */ + .globl dv_parse_video_segment ++ .type dv_parse_video_segment,@function + dv_parse_video_segment: + + /* Args are at rdi=seg, rsi=quality */ +--- /dev/null 2005-12-15 06:00:01.513317500 +0000 ++++ libdv/asm_common.S 2005-12-14 19:57:06.000000000 +0000 +@@ -0,0 +1,37 @@ ++/* public domain, do what you want */ ++ ++#ifdef __PIC__ ++# define MUNG(sym) sym##@GOTOFF(%ebp) ++# define MUNG_ARR(sym, args...) sym##@GOTOFF(%ebp,##args) ++#else ++# define MUNG(sym) sym ++# define MUNG_ARR(sym, args...) sym(,##args) ++#endif ++ ++#ifdef __PIC__ ++# undef __i686 /* gcc define gets in our way */ ++ .section .gnu.linkonce.t.__i686.get_pc_thunk.bp,"ax",@progbits ++.globl __i686.get_pc_thunk.bp ++ .hidden __i686.get_pc_thunk.bp ++ .type __i686.get_pc_thunk.bp,@function ++__i686.get_pc_thunk.bp: ++ movl (%esp), %ebp ++ ret ++# define LOAD_PIC_REG_BP() \ ++ call __i686.get_pc_thunk.bp ; \ ++ addl $_GLOBAL_OFFSET_TABLE_, %ebp ++ ++ .section .gnu.linkonce.t.__i686.get_pc_thunk.si,"ax",@progbits ++.globl __i686.get_pc_thunk.si ++ .hidden __i686.get_pc_thunk.si ++ .type __i686.get_pc_thunk.si,@function ++__i686.get_pc_thunk.si: ++ movl (%esp), %esi ++ ret ++# define LOAD_PIC_REG_SI() \ ++ call __i686.get_pc_thunk.si ; \ ++ addl $_GLOBAL_OFFSET_TABLE_, %esi ++#else ++# define LOAD_PIC_REG_BP() ++# define LOAD_PIC_REG_SI() ++#endif diff --git a/libezv24.patch b/libezv24.patch new file mode 100644 index 0000000..b35bbdb --- /dev/null +++ b/libezv24.patch @@ -0,0 +1,272 @@ +Index: .cvsignore +=================================================================== +RCS file: /cvsroot/ezv24/libezv24/.cvsignore,v +retrieving revision 1.1 +diff -u -p -r1.1 .cvsignore +--- .cvsignore 9 May 2003 09:45:16 -0000 1.1 ++++ .cvsignore 26 Aug 2006 22:50:11 -0000 +@@ -1,5 +1,6 @@ + api-html + test-v24.exe + test-v24 +-libez*_s.a ++libez*.a + libez*.so* ++*.lo +Index: Makefile +=================================================================== +RCS file: /cvsroot/ezv24/libezv24/Makefile,v +retrieving revision 1.10 +diff -u -p -r1.10 Makefile +--- Makefile 3 Jun 2006 19:34:06 -0000 1.10 ++++ Makefile 26 Aug 2006 22:50:11 -0000 +@@ -19,9 +19,6 @@ PATCHLEVEL = 2 + # the base name of the library + SOBASE = ezV24 + +-# define the destination OS (currently only linux) +-PLATFORM=__LINUX__ +- + # the base path where the file should be installed to. + PREFIX = /usr/local + +@@ -31,66 +28,53 @@ DESTDIR = + + # generate the name of the output file in dependence of the development state. + # +-ifeq "${RELEASE}" "DEBUG" ++ifeq ($(RELEASE),DEBUG) + NAME = lib$(SOBASE).so.$(SORELEASE).dbg + else + NAME = lib$(SOBASE).so.$(VERSION) + endif + SONAME = lib$(SOBASE).so.$(SORELEASE) +-LIBNAME = lib$(SOBASE)-$(SORELEASE)_s.a ++LIBNAME = lib$(SOBASE).a + PLAINNAME = lib$(SOBASE).so + + # basename of the project + PROJECTNAME = libezV24-$(VERSION).$(PATCHLEVEL) + +-OBJS = ezV24.o snprintf.o ++STATIC_OBJS = ezV24.o snprintf.o ++SHARED_OBJS = $(patsubst %.o,%.lo,$(STATIC_OBJS)) + LIBS = + +- +-ifeq "${RELEASE}" "DEBUG" +-C_OPT = -O2 +-C_FLAG = -c -Wall -fPIC $(C_OPT) -D$(PLATFORM) $(INCDIR) +-C_DEFS = -DDEBUG -DBETA +-LFLAGS = $(LIBDIR) ++ifeq ($(RELEASE),DEBUG) ++CPPFLAGS += -DDEBUG -DBETA + else +-ifeq "${RELEASE}" "BETA" +-C_OPT = -O2 +-C_FLAG = -c -Wall -fPIC $(C_OPT) -D$(PLATFORM) $(INCDIR) +-C_DEFS = -DBETA +-LFLAGS = $(LIBDIR) ++ifeq ($(RELEASE),BETA) ++CPPFLAGS += -DBETA + else +-C_OPT = -O2 +-C_FLAG = -c -Wall -fPIC $(C_OPT) -D$(PLATFORM) $(INCDIR) +-C_DEFS = -DFINAL +-LFLAGS = -s $(LIBDIR) ++CPPFLAGS += -DFINAL + endif + endif + ++CPPFLAGS += -I. ++CFLAGS ?= -O2 ++CFLAGS += -Wall ++LDFLAGS ?= -s ++ + # tools to build the static library + ARFLAGS = cru +-AR = ar +-RANLIB = ranlib ++AR ?= ar ++RANLIB ?= ranlib + + # some distros have a messed up path when in su - +-LDCONFIG = /sbin/ldconfig +- +-# concatenate the compile flags +-CFLAGS = $(C_FLAG) $(C_DEFS) +- +- +- +-# ------------------------------------------------------------------------ +-# AUTOMATIC COMPILE INSTRUCTIONS +-# ------------------------------------------------------------------------ +- +-.c.o: +- gcc $(CFLAGS) $< ++LDCONFIG ?= /sbin/ldconfig + + + # -------------------------------------------------------------------------- + # DEPENDENCIES + # -------------------------------------------------------------------------- + ++%.lo: %.c ++ $(CC) -fPIC $(CFLAGS) $(CPPFLAGS) -c $< -o $@ ++ + all: shared static test-v24 + + shared: $(NAME) +@@ -98,13 +82,12 @@ shared: $(NAME) + static: $(LIBNAME) + + ++$(NAME): $(SHARED_OBJS) ++ $(CC) $(CFLAGS) -shared -Wl,-soname,$(SONAME) -o $@ $^ $(LDFLAGS) + +-$(NAME): $(OBJS) +- gcc -shared -W1,soname,$(SONAME) -o $(NAME) $(OBJS) +- +-$(LIBNAME): $(OBJS) +- $(AR) $(ARFLAGS) $(LIBNAME) $(OBJS) +- $(RANLIB) $(LIBNAME) ++$(LIBNAME): $(STATIC_OBJS) ++ $(AR) $(ARFLAGS) $@ $^ ++ $(RANLIB) $@ + + + # source dependencies, but doesn't do anything if the automatism above +@@ -121,14 +104,14 @@ snprintf.o: snprintf.c snprintf.h + # + + install: +- install -d -m 755 $(DESTDIR)$(PREFIX)/include/$(SOBASE)/ ++ install -d -m 755 $(DESTDIR)$(PREFIX)/include/ + install -d -m 755 $(DESTDIR)$(PREFIX)/lib/ +- install -m 644 ezV24.h $(DESTDIR)$(PREFIX)/include/$(SOBASE)/ +- install -m 644 -s $(LIBNAME) $(DESTDIR)$(PREFIX)/lib/$(LIBNAME) +- install -m 755 -s $(NAME) $(DESTDIR)$(PREFIX)/lib/$(NAME) ++ install -m 644 ezV24.h $(DESTDIR)$(PREFIX)/include/ ++ install -m 644 $(LIBNAME) $(DESTDIR)$(PREFIX)/lib/$(LIBNAME) ++ install -m 755 $(NAME) $(DESTDIR)$(PREFIX)/lib/$(NAME) + rm -f $(DESTDIR)$(PREFIX)/lib/$(SONAME) $(DESTDIR)$(PREFIX)/lib/$(PLAINNAME) +- ln -s $(PREFIX)/lib/$(NAME) $(DESTDIR)$(PREFIX)/lib/$(SONAME) +- ln -s $(PREFIX)/lib/$(SONAME) $(DESTDIR)$(PREFIX)/lib/$(PLAINNAME) ++ ln -s $(NAME) $(DESTDIR)$(PREFIX)/lib/$(SONAME) ++ ln -s $(SONAME) $(DESTDIR)$(PREFIX)/lib/$(PLAINNAME) + if [ -z $$NO_LDCONFIG ]; then \ + $(LDCONFIG); \ + fi +@@ -173,7 +156,7 @@ api-ref: doc++.conf manual.dxx ezV24.h + # gcc -o test-v24 -Wall test-v24.c -l$(SOBASE) + # + test-v24: test-v24.c ezV24.h $(LIBNAME) +- gcc -o test-v24 -Wall -DUNINSTALLED test-v24.c -L./ $(LIBNAME) ++ $(CC) -o test-v24 -Wall -DUNINSTALLED test-v24.c -L./ $(LIBNAME) + + + # -------------------------------------------------------------------------- +@@ -181,7 +164,7 @@ test-v24: test-v24.c ezV24.h $(LIBNAME) + # -------------------------------------------------------------------------- + + clean: +- rm -f *.o core ++ rm -f *.o *.lo core + + clean-all: + rm -f *.o core test-v24 $(NAME) $(LIBNAME) +Index: ezV24.c +=================================================================== +RCS file: /cvsroot/ezv24/libezv24/ezV24.c,v +retrieving revision 1.6 +diff -u -p -r1.6 ezV24.c +--- ezV24.c 3 Jun 2006 19:34:06 -0000 1.6 ++++ ezV24.c 26 Aug 2006 22:50:11 -0000 +@@ -128,7 +128,7 @@ int v24CountPorts ( unsigned long* BitMa + { + int count=-1; + +-#if defined(__LINUX__) && !defined(__CYGWIN__) ++#if defined(__linux__) && !defined(__CYGWIN__) + FILE* proc_fd=NULL; + char proc_line[80]; + int done=0; +@@ -194,7 +194,7 @@ const char* v24PortName ( int PortNo, ch + reportError(NULL,V24_E_NULL_POINTER,"v24PortName"); + return NULL; + } +-#if defined(__LINUX__) && !defined(__CYGWIN__) ++#if defined(__linux__) && !defined(__CYGWIN__) + v24_snprintf(PortName,V24_SZ_PORTNAME-1,"/dev/ttyS%d",PortNo); + PortName[V24_SZ_PORTNAME]='\0'; + #elif defined(__CYGWIN__) +@@ -737,7 +737,7 @@ int v24HaveData ( v24_port_t *port ) + reportError(port,V24_E_ILLHANDLE,"v24HaveData"); + return -1; + } +-#if defined(__LINUX__) && !defined(__CYGWIN__) ++#if defined(__linux__) && !defined(__CYGWIN__) + port->Errno=V24_E_OK; + ioctl(port->fd,FIONREAD,&CharsWaiting); + return CharsWaiting; +@@ -798,7 +798,7 @@ int v24SetDTR ( v24_port_t *port, int Ne + return V24_E_ILLHANDLE; + } + port->Errno=V24_E_OK; +-#if defined(__LINUX__) && !defined(__CYGWIN__) ++#if defined(__linux__) && !defined(__CYGWIN__) + ioctl(port->fd,TIOCMGET,&status); + if ( NewState ) + status |= TIOCM_DTR; +@@ -829,7 +829,7 @@ int v24SetRTS ( v24_port_t *port, int Ne + return port->Errno; + } + +-#if defined(__LINUX__) && !defined(__CYGWIN__) ++#if defined(__linux__) && !defined(__CYGWIN__) + ioctl(port->fd,TIOCMGET,&status); + if ( NewState ) + status |= TIOCM_RTS; +@@ -856,7 +856,7 @@ int v24GetDSR ( v24_port_t *port, int *C + return V24_E_ILLHANDLE; + } + port->Errno=V24_E_OK; +-#if defined(__LINUX__) && !defined(__CYGWIN__) ++#if defined(__linux__) && !defined(__CYGWIN__) + ioctl(port->fd,TIOCMGET,&status); + if ( status & TIOCM_DSR ) + *CurrState = V24_DSR_HIGH; +@@ -888,7 +888,7 @@ int v24GetCTS ( v24_port_t *port, int *C + return port->Errno; + } + +-#if defined(__LINUX__) && !defined(__CYGWIN__) ++#if defined(__linux__) && !defined(__CYGWIN__) + ioctl(port->fd,TIOCMGET,&status); + if ( status & TIOCM_CTS ) + *CurrState = V24_CTS_HIGH; +Index: ezV24_config.h +=================================================================== +RCS file: /cvsroot/ezv24/libezv24/ezV24_config.h,v +retrieving revision 1.2 +diff -u -p -r1.2 ezV24_config.h +--- ezV24_config.h 13 Oct 2003 07:50:26 -0000 1.2 ++++ ezV24_config.h 26 Aug 2006 22:50:11 -0000 +@@ -48,7 +48,7 @@ extern "C" { + /* This is set to 1 (TRUE), if we need support for lock-files to protect the + * opened device. + */ +-#ifdef __LINUX__ ++#ifdef __linux__ + # ifdef __CYGWIN__ + # define EZV24_WANT_LOCKFILE 1 + # else +@@ -62,7 +62,7 @@ extern "C" { + /* This is set 1 (TRUE), if we have POSIX complaint functions to access the + * serial port. + */ +-#ifdef __LINUX__ ++#ifdef __linux__ + #define EZV24_POSIX_STYLE 1 + #else + #define EZV24_POSIX_STYLE 0 diff --git a/libipod-build-cleanup.patch b/libipod-build-cleanup.patch new file mode 100644 index 0000000..7cbdb1d --- /dev/null +++ b/libipod-build-cleanup.patch @@ -0,0 +1,52 @@ +Index: examples/Makefile.am +=================================================================== +RCS file: /cvsroot/libipod/libipod/examples/Makefile.am,v +retrieving revision 1.1.1.1 +diff -u -p -r1.1.1.1 Makefile.am +--- examples/Makefile.am 14 Dec 2005 21:26:33 -0000 1.1.1.1 ++++ examples/Makefile.am 5 Mar 2007 21:58:24 -0000 +@@ -1,23 +1,15 @@ + noinst_PROGRAMS = dumptracks dumptracks_cpp readwritedb teststrings + +-INCLUDES = -I../src -I../include ++INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/include + + dumptracks_SOURCES = dumptracks.c +-dumptracks_LDFLAGS = -L../src -L../src/.libs +-dumptracks_LDADD = -lipod -lexpat +-dumptracks_DEPENDENCIES = ../src/.libs/libipod.a ++dumptracks_LDADD = $(top_builddir)/src/libipod.la + + dumptracks_cpp_SOURCES = dumptracks_cpp.cpp +-dumptracks_cpp_LDFLAGS = -L../src -L../src/.libs +-dumptracks_cpp_LDADD = -lipod +-dumptracks_cpp_DEPENDENCIES = ../src/.libs/libipod.a ++dumptracks_cpp_LDADD = $(top_builddir)/src/libipod.la + + readwritedb_SOURCES = readwritedb.c +-readwritedb_LDFLAGS = -L../src -L../src/.libs +-readwritedb_LDADD = -lipod +-readwritedb_DEPENDENCIES = ../src/.libs/libipod.a ++readwritedb_LDADD = $(top_builddir)/src/libipod.la + + teststrings_SOURCES = teststrings.c +-teststrings_LDFLAGS = -L../src -L../src/.libs +-teststrings_LDADD = -lipod +-teststrings_DEPENDENCIES = ../src/.libs/libipod.a ++teststrings_LDADD = $(top_builddir)/src/libipod.la +Index: src/Makefile.am +=================================================================== +RCS file: /cvsroot/libipod/libipod/src/Makefile.am,v +retrieving revision 1.1.1.1 +diff -u -p -r1.1.1.1 Makefile.am +--- src/Makefile.am 14 Dec 2005 21:26:33 -0000 1.1.1.1 ++++ src/Makefile.am 5 Mar 2007 21:58:24 -0000 +@@ -1,7 +1,7 @@ + #lib_LIBRARIES = libipod.a + #libipod_a_SOURCES = + +-INCLUDES = -I../include ++INCLUDES = -I$(top_srcdir)/include + lib_LTLIBRARIES = libipod.la + libipod_la_SOURCES = \ + plist.c \ diff --git a/libnfsidmap-optional-ldap.patch b/libnfsidmap-optional-ldap.patch new file mode 100644 index 0000000..a61286e --- /dev/null +++ b/libnfsidmap-optional-ldap.patch @@ -0,0 +1,71 @@ +--- libnfsidmap-0.17/configure.in ++++ libnfsidmap-0.17/configure.in +@@ -13,6 +13,21 @@ + + # Checks for libraries. + ++AC_ARG_ENABLE([ldap], ++ [AC_HELP_STRING([--disable-ldap],[Disable support for LDAP @<:@default=detect@:>@])]) ++if test "x$enable_ldap" != "xno" ; then ++ AC_CHECK_HEADER([ldap.h], ++ [AC_CHECK_LIB([ldap], [ldap_initialize], ++ [have_ldap="yes"],[have_ldap="no"])], ++ [have_ldap="no"]) ++ if test "x$have_ldap" = "xyes" ; then ++ AC_DEFINE([ENABLE_LDAP], 1, [Enable LDAP Support]) ++ LIBS="$LIBS -lldap" ++ elif test "x$enable_ldap$have_ldap" = "xyesno" ; then ++ AC_MSG_ERROR(LDAP support not found!) ++ fi ++fi ++ + # Checks for header files. + AC_HEADER_STDC + AC_CHECK_HEADERS([stdlib.h string.h unistd.h errno.h]) +--- libnfsidmap-0.17/Makefile.am ++++ libnfsidmap-0.17/Makefile.am +@@ -4,7 +4,6 @@ + libnfsidmap_la_LDFLAGS = -version-info 2:0:2 + include_HEADERS = nfsidmap.h + EXTRA_DIST = $(man_MANS) libtest.c idmapd.conf +-LIBS = -lldap + + # XXX: also exclude debian/files and debian/files.new ? do a clean?? + dist-hook: +--- libnfsidmap-0.17/libnfsidmap.c ++++ libnfsidmap-0.17/libnfsidmap.c +@@ -166,11 +166,13 @@ + extern struct trans_func nss_trans; + extern struct trans_func umichldap_trans; + +-#define TR_SIZE 2 +-static struct trans_func * t_array[TR_SIZE] = { +- [0] = &nss_trans, +- [1] = &umichldap_trans, ++static struct trans_func * t_array[] = { ++ &nss_trans, ++#ifdef ENABLE_LDAP ++ &umichldap_trans, ++#endif + }; ++#define TR_SIZE (sizeof(t_array)/sizeof(*t_array)) + + int + set_trans_method(char *method) +--- libnfsidmap-0.17/umich_ldap.c ++++ libnfsidmap-0.17/umich_ldap.c +@@ -32,6 +32,8 @@ + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + ++#ifdef ENABLE_LDAP ++ + #include + #include + #include +@@ -1019,3 +1021,5 @@ + .gid_to_name = umichldap_gid_to_name, + .gss_princ_to_grouplist = umichldap_gss_princ_to_grouplist, + }; ++ ++#endif diff --git a/libpcap-cross-linux.patch b/libpcap-cross-linux.patch new file mode 100644 index 0000000..f2daee9 --- /dev/null +++ b/libpcap-cross-linux.patch @@ -0,0 +1,26 @@ +--- configure.in ++++ configure.in +@@ -178,7 +178,10 @@ + dnl XXX This could be done for cross-compiling, but for now it's not. + dnl + if test -z "$with_pcap" && test "$cross_compiling" = yes; then +- AC_MSG_ERROR(pcap type not determined when cross-compiling; use --with-pcap=...) ++ case $host in ++ *-linux*) with_pcap="linux";; ++ *) AC_MSG_ERROR(pcap type not determined when cross-compiling; use --with-pcap=...);; ++ esac + fi + AC_ARG_WITH(pcap, [ --with-pcap=TYPE use packet capture TYPE]) + AC_MSG_CHECKING(packet capture type) +@@ -347,8 +350,10 @@ + linux) + AC_MSG_CHECKING(Linux kernel version) + if test "$cross_compiling" = yes; then ++ dnl we could check linux/version.h here, but who runs ++ dnl versions of linux older than 2.0.x anymore to bother ? + AC_CACHE_VAL(ac_cv_linux_vers, +- ac_cv_linux_vers=unknown) ++ ac_cv_linux_vers=2) + else + AC_CACHE_VAL(ac_cv_linux_vers, + ac_cv_linux_vers=`uname -r 2>&1 | \ diff --git a/libperl.patch b/libperl.patch new file mode 100644 index 0000000..0120920 --- /dev/null +++ b/libperl.patch @@ -0,0 +1,409 @@ +--- Configure.orig 2007-04-08 22:19:09.000000000 -0400 ++++ Configure 2007-04-09 02:34:02.000000000 -0400 +@@ -1263,6 +1263,7 @@ + : Possible local library directories to search. + loclibpth="/usr/local/lib /opt/local/lib /usr/gnu/lib" + loclibpth="$loclibpth /opt/gnu/lib /usr/GNU/lib /opt/GNU/lib" ++loclibpth="" + + : general looking path for locating libraries + glibpth="/lib /usr/lib $xlibpth" +@@ -1981,6 +1982,30 @@ + esac;; + esac" + ++: figure out sizes of things with just compile tests ++: based on AC_CHECK_SIZEOF from autoconf ++cat <mysizeof ++$startsh ++size=0 ++while true; do ++ echo "$sizeincludes" > try.c ++ echo "typedef \$type ac__type_sizeof_;" > try.c ++ echo "int main() {" >> try.c ++ echo "static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= \$size)];" >> try.c ++ echo "test_array [0] = 0; return 0;}" >> try.c ++ if \$cc $cflags -c try.c >/dev/null 2>&1; then ++ break ++ fi ++ : sanity check ++ if test \$size -gt 20; then ++ size="" ++ break ++ fi ++ size=\`expr \$size + 1\` ++done ++\$rm -f try.* ++EOSC ++ + : now set up to do reads with possible shell escape and default assignment + cat <myread + $startsh +@@ -4617,7 +4642,18 @@ + for thisdir in $libpth $xlibpth; do + test -d $thisdir && libspath="$libspath $thisdir" + done ++echo 'main(){}' > try.c + for thislib in $libswanted; do ++ printf "Checking for -l$thislib ... " >&4 ++ if $cc $cflags $ldflags -l$thislib try.c >/dev/null 2>&1; then ++ echo "OK" >&4 ++ dflt="$dflt -l$thislib" ++ libsfiles="$libsfiles lib${thislib}.so" ++ libsfound="$libsfound /usr/lib/lib${thislib}.so" ++ else ++ echo "nope" >&4 ++ fi ++ continue + for thisdir in $libspath; do + xxx='' + if $test ! -f "$xxx" -a "X$ignore_versioned_solibs" = "X"; then +@@ -5025,6 +5061,8 @@ + rp="You have a problem. Shall I abort Configure" + dflt=y + fi ++ # we dont care how it executed, just that it compiled ++ dflt=n + else + echo "I can't compile the test program." >>try.msg + rp="You have a BIG problem. Shall I abort Configure" +@@ -5182,23 +5220,20 @@ + case "$intsize" in + '') + echo "Checking to see how big your integers are..." >&4 +- $cat >try.c < +-#$i_stdlib I_STDLIB +-#ifdef I_STDLIB +-#include +-#endif +-int main() +-{ +- printf("intsize=%d;\n", (int)sizeof(int)); +- printf("longsize=%d;\n", (int)sizeof(long)); +- printf("shortsize=%d;\n", (int)sizeof(short)); +- exit(0); +-} +-EOCP +- set try +- if eval $compile_ok && $run ./try > /dev/null; then +- eval `$run ./try` ++ ++ type="int" ++ . ./mysizeof ++ intsize="$size" ++ ++ type="long" ++ . ./mysizeof ++ longsize="$size" ++ ++ type="short" ++ . ./mysizeof ++ shortsize="$size" ++ ++ if test "X$intsize" != X -a "X$longsize" != X -a "X$shortsize" != X; then + echo "Your integers are $intsize bytes long." + echo "Your long integers are $longsize bytes long." + echo "Your short integers are $shortsize bytes long." +@@ -5225,7 +5260,6 @@ + fi + ;; + esac +-$rm -f try try.* + + : check for long long + echo " " +@@ -5246,19 +5280,11 @@ + : check for length of long long + case "${d_longlong}${longlongsize}" in + $define) +- echo " " +- echo "Checking to see how big your long longs are..." >&4 +- $cat >try.c <<'EOCP' +-#include +-int main() +-{ +- printf("%d\n", (int)sizeof(long long)); +- return(0); +-} +-EOCP +- set try +- if eval $compile_ok; then +- longlongsize=`$run ./try` ++ type="long long" ++ . ./mysizeof ++ longlongsize="$size" ++ ++ if test "X$longlongsize" != X; then + echo "Your long longs are $longlongsize bytes long." + else + dflt='8' +@@ -5572,21 +5598,10 @@ + case "$doublesize" in + '') + echo "Checking to see how big your double precision numbers are..." >&4 +- $cat >try.c < +-#$i_stdlib I_STDLIB +-#ifdef I_STDLIB +-#include +-#endif +-int main() +-{ +- printf("%d\n", (int)sizeof(double)); +- exit(0); +-} +-EOCP +- set try +- if eval $compile_ok; then +- doublesize=`$run ./try` ++ type="double" ++ . ./mysizeof ++ doublesize="$size" ++ if test "X$doublesize" != X; then + echo "Your double is $doublesize bytes long." + else + dflt='8' +@@ -5620,17 +5635,10 @@ + $define) + echo " " + echo "Checking to see how big your long doubles are..." >&4 +- $cat >try.c <<'EOCP' +-#include +-int main() +-{ +- printf("%d\n", sizeof(long double)); +-} +-EOCP +- set try +- set try +- if eval $compile; then +- longdblsize=`$run ./try` ++ type="long double" ++ . ./mysizeof ++ longdblsize="$size" ++ if test "X$longdblsize" != X; then + echo "Your long doubles are $longdblsize bytes long." + else + dflt='8' +@@ -6268,25 +6276,13 @@ + '') + echo "Checking to see how big your pointers are..." >&4 + if test "$voidflags" -gt 7; then +- echo '#define VOID_PTR char *' > try.c ++ type="char *" + else +- echo '#define VOID_PTR void *' > try.c ++ type="void *" + fi +- $cat >>try.c < +-#$i_stdlib I_STDLIB +-#ifdef I_STDLIB +-#include +-#endif +-int main() +-{ +- printf("%d\n", (int)sizeof(VOID_PTR)); +- exit(0); +-} +-EOCP +- set try +- if eval $compile_ok; then +- ptrsize=`$run ./try` ++ . ./mysizeof ++ ptrsize="$size" ++ if test "X$ptrsize" != X; then + echo "Your pointers are $ptrsize bytes long." + else + dflt='4' +@@ -8837,18 +8833,10 @@ + + echo " " + echo "Checking to see how big your file offsets are..." >&4 +-$cat >try.c < +-#include +-int main() +-{ +- printf("%d\n", (int)sizeof($lseektype)); +- return(0); +-} +-EOCP +-set try +-if eval $compile_ok; then +- lseeksize=`$run ./try` ++type="$lseektype" ++. ./mysizeof ++lseeksize="$size" ++if test "X$lseeksize" != X; then + echo "Your file offsets are $lseeksize bytes long." + else + dflt=$longsize +@@ -8871,21 +8859,10 @@ + *) zzz="fpos_t" ;; + esac + echo "Checking the size of $zzz..." >&4 +-cat > try.c < +-#include +-#$i_stdlib I_STDLIB +-#ifdef I_STDLIB +-#include +-#endif +-int main() { +- printf("%d\n", (int)sizeof($fpostype)); +- exit(0); +-} +-EOCP +-set try +-if eval $compile_ok; then +- yyy=`$run ./try` ++type="$zzz" ++. ./mysizeof ++yyy="$size" ++if test "X$yyy" != X; then + case "$yyy" in + '') fpossize=4 + echo "(I can't execute the test program--guessing $fpossize.)" >&4 +@@ -8953,18 +8930,10 @@ + if $test -f uselargefiles.cbu; then + echo " " + echo "Rechecking to see how big your file offsets are..." >&4 +- $cat >try.c < +-#include +-int main() +-{ +- printf("%d\n", (int)sizeof($lseektype)); +- return(0); +-} +-EOCP +- set try +- if eval $compile_ok; then +- lseeksize=`$run ./try` ++ type="$lseektype" ++ . ./mysizeof ++ lseeksize="$size" ++ if test "X$lseeksize" != X; then + $echo "Your file offsets are now $lseeksize bytes long." + else + dflt="$lseeksize" +@@ -14590,22 +14559,10 @@ + case "$charsize" in + '') + echo "Checking to see how big your characters are (hey, you never know)..." >&4 +- $cat >try.c < +-#$i_stdlib I_STDLIB +-#ifdef I_STDLIB +-#include +-#endif +-int main() +-{ +- printf("%d\n", (int)sizeof(char)); +- exit(0); +-} +-EOCP +- set try +- if eval $compile_ok; then +- dflt=`$run ./try` +- else ++ type="char" ++ . ./mysizeof ++ dflt="$size" ++ if test "X$dflt" = X; then + dflt='1' + echo "(I can't seem to compile the test program. Guessing...)" + fi +@@ -17430,6 +17387,24 @@ + esac + else + dflt='4321' ++$cat >try.c </dev/null; then ++ dflt='4321' ++ else ++ if grep LiTTleEnDian try.o >/dev/null; then ++ dflt='1234' ++ fi ++ fi ++ fi + cat <<'EOM' + (I can't seem to compile the test program. Guessing big-endian...) + EOM +@@ -17753,6 +17728,13 @@ + set try + if eval $compile_ok; then + dflt=`$run ./try` ++ if test "X$dflt" = X; then ++ if $test "X$uselongdouble" = Xdefine -a "X$d_longdbl" = Xdefine; then ++ dflt='__alignof__(long double)' ++ else ++ dflt='__alignof__(double)' ++ fi ++ fi + else + dflt='8' + echo "(I can't seem to compile the test program...)" +@@ -18475,21 +18457,10 @@ + *) zzz="gid" ;; + esac + echo "Checking the size of $zzz..." >&4 +-cat > try.c < +-#include +-#$i_stdlib I_STDLIB +-#ifdef I_STDLIB +-#include +-#endif +-int main() { +- printf("%d\n", (int)sizeof($gidtype)); +- exit(0); +-} +-EOCP +-set try +-if eval $compile_ok; then +- yyy=`$run ./try` ++type="$zzz" ++. ./mysizeof ++yyy="$type" ++if test "X$yyy" != X; then + case "$yyy" in + '') gidsize=4 + echo "(I can't execute the test program--guessing $gidsize.)" >&4 +@@ -19659,21 +19630,10 @@ + *) zzz="filesize" ;; + esac + echo "Checking the size of $zzz..." >&4 +-cat > try.c < +-#include +-#$i_stdlib I_STDLIB +-#ifdef I_STDLIB +-#include +-#endif +-int main() { +- printf("%d\n", (int)sizeof($sizetype)); +- exit(0); +-} +-EOCP +-set try +-if eval $compile_ok; then +- yyy=`$run ./try` ++type="$sizetype" ++. ./mysizeof ++yyy="$size" ++if test "X$yyy" != X; then + case "$yyy" in + '') sizesize=4 + echo "(I can't execute the test program--guessing $sizesize.)" >&4 diff --git a/libsdl-fbcon-no-mmu-mmap.patch b/libsdl-fbcon-no-mmu-mmap.patch new file mode 100644 index 0000000..a76cc7b --- /dev/null +++ b/libsdl-fbcon-no-mmu-mmap.patch @@ -0,0 +1,42 @@ +Index: src/video/fbcon/SDL_fbvideo.c +=================================================================== +--- src/video/fbcon/SDL_fbvideo.c (revision 2363) ++++ src/video/fbcon/SDL_fbvideo.c (working copy) +@@ -149,6 +149,19 @@ static void FB_SavePalette(_THIS, struct + struct fb_var_screeninfo *vinfo); + static void FB_RestorePalette(_THIS); + ++/* Small wrapper for mmap() so we can play nicely with no-mmu hosts ++ * (non-mmu hosts disallow the MAP_SHARED flag) */ ++ ++static void *do_mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset) ++{ ++ void *ret; ++ ret = mmap(start, length, prot, flags, fd, offset); ++ if ( ret == (char *)-1 && flags != (flags & ~MAP_SHARED) ) { ++ ret = mmap(start, length, prot, ++ (flags & ~MAP_SHARED) | MAP_PRIVATE, fd, offset); ++ } ++} ++ + /* FB driver bootstrap functions */ + + static int FB_Available(void) +@@ -535,7 +548,7 @@ static int FB_VideoInit(_THIS, SDL_Pixel + mapped_offset = (((long)finfo.smem_start) - + (((long)finfo.smem_start)&~(PAGE_SIZE-1))); + mapped_memlen = finfo.smem_len+mapped_offset; +- mapped_mem = mmap(NULL, mapped_memlen, ++ mapped_mem = do_mmap(NULL, mapped_memlen, + PROT_READ|PROT_WRITE, MAP_SHARED, console_fd, 0); + if ( mapped_mem == (char *)-1 ) { + SDL_SetError("Unable to memory map the video hardware"); +@@ -579,7 +592,7 @@ static int FB_VideoInit(_THIS, SDL_Pixel + ioctl(console_fd, FBIOPUT_VSCREENINFO, &vinfo); + if ( finfo.accel && finfo.mmio_len ) { + mapped_iolen = finfo.mmio_len; +- mapped_io = mmap(NULL, mapped_iolen, PROT_READ|PROT_WRITE, ++ mapped_io = do_mmap(NULL, mapped_iolen, PROT_READ|PROT_WRITE, + MAP_SHARED, console_fd, mapped_memlen); + if ( mapped_io == (char *)-1 ) { + /* Hmm, failed to memory map I/O registers */ diff --git a/libsdl-remove-joystick-limits-hack.patch b/libsdl-remove-joystick-limits-hack.patch new file mode 100644 index 0000000..db27df9 --- /dev/null +++ b/libsdl-remove-joystick-limits-hack.patch @@ -0,0 +1,12 @@ +--- src/joystick/linux/SDL_sysjoystick.c ++++ src/joystick/linux/SDL_sysjoystick.c +@@ -30,9 +30,6 @@ + #include + #include + #include /* For the definition of PATH_MAX */ +-#ifdef __arm__ +-#include /* Arm cross-compiler needs this */ +-#endif + #include + #if SDL_INPUT_LINUXEV + #include diff --git a/libsdl-uclinux-support.patch b/libsdl-uclinux-support.patch new file mode 100644 index 0000000..feebf59 --- /dev/null +++ b/libsdl-uclinux-support.patch @@ -0,0 +1,23 @@ +--- configure.in ++++ configure.in +@@ -1608,7 +1608,7 @@ AC_HELP_STRING([--enable-pthreads], [use + AC_HELP_STRING([--enable-pthread-sem], [use pthread semaphores [[default=yes]]]), + , enable_pthread_sem=yes) + case "$host" in +- *-*-linux*) ++ *-*-linux*|*-*-uclinux*) + pthread_cflags="-D_REENTRANT" + pthread_lib="-lpthread" + ;; +@@ -2059,9 +2059,10 @@ case "$host" in + have_timers=yes + fi + ;; +- *-*-linux*|*-*-gnu*|*-*-k*bsd*-gnu|*-*-bsdi*|*-*-freebsd*|*-*-dragonfly*|*-*-netbsd*|*-*-openbsd*|*-*-sysv5*|*-*-solaris*|*-*-hpux*|*-*-irix*|*-*-aix*|*-*-osf*) ++ *-*-linux*|*-*-uclinux*|*-*-gnu*|*-*-k*bsd*-gnu|*-*-bsdi*|*-*-freebsd*|*-*-dragonfly*|*-*-netbsd*|*-*-openbsd*|*-*-sysv5*|*-*-solaris*|*-*-hpux*|*-*-irix*|*-*-aix*|*-*-osf*) + case "$host" in + *-*-linux*) ARCH=linux ;; ++ *-*-uclinux*) ARCH=linux ;; + *-*-kfreebsd*-gnu) ARCH=kfreebsd-gnu ;; + *-*-knetbsd*-gnu) ARCH=knetbsd-gnu ;; + *-*-kopenbsd*-gnu) ARCH=kopenbsd-gnu ;; diff --git a/libstdf-init-header-state.patch b/libstdf-init-header-state.patch new file mode 100644 index 0000000..ff01b3f --- /dev/null +++ b/libstdf-init-header-state.patch @@ -0,0 +1,13 @@ +Index: include/libstdf_types.h +=================================================================== +--- include/libstdf_types.h (revision 276) ++++ include/libstdf_types.h (working copy) +@@ -69,7 +69,7 @@ typedef enum { + #define MAKE_REC(typ,sub) ((typ << 8) + sub) + #define BREAK_REC(h,t) do { h.REC_TYP = (stdf_rec_typ)(t >> 8); h.REC_SUB = (stdf_rec_sub)(t & 0xFF); } while (0) + #define SET_HEADER(h,t,l) do { BREAK_REC(h, t); h.REC_LEN = l; } while (0) +-#define INIT_HEADER(h,t) SET_HEADER(h,t,0) ++#define INIT_HEADER(h,t) do { SET_HEADER(h, t, 0); h.state = REC_STATE_PARSED; } while (0) + #define HEAD_TO_REC(h) MAKE_REC(h.REC_TYP,h.REC_SUB) + #define STDF_REC_FAR MAKE_REC(STDF_REC_TYP_INFO, STDF_REC_SUB_FAR) + #define STDF_REC_ATR MAKE_REC(STDF_REC_TYP_INFO, STDF_REC_SUB_ATR) diff --git a/libtool-1.5.23-tagdemo-c++.patch b/libtool-1.5.23-tagdemo-c++.patch new file mode 100644 index 0000000..f0c5c1f --- /dev/null +++ b/libtool-1.5.23-tagdemo-c++.patch @@ -0,0 +1,35 @@ +2005-09-12 Ralf Wildenhues + + Make tagdemo work smoothly with both pre- and ISO C++ compilers, + and remove all use of libstdc from other tests. + + * tests/tagdemo/configure.ac (HAVE_NAMESPACES, HAVE_IOSTREAM): + New tests for ISO C++ features. Reimplementation of similar + macros from the autoconf archive. + * tests/tagdemo/foo.cpp, tests/tagdemo/main.cpp: Adjusted. + * tests/am-subdir.at, tests/template.at: Do not use iostream. + +Index: tagdemo/foo.cpp +=================================================================== +RCS file: /sources/libtool/libtool/tests/tagdemo/foo.cpp,v +retrieving revision 1.2 +retrieving revision 1.3 +diff -u -p -r1.2 -r1.3 +--- tagdemo/foo.cpp 22 Apr 2005 10:10:31 -0000 1.2 ++++ tagdemo/foo.cpp 12 Sep 2005 16:24:38 -0000 1.3 +@@ -20,7 +20,14 @@ + // USA. + + #include "foo.h" +-#include ++#ifdef HAVE_IOSTREAM ++# include ++#else ++# include ++#endif ++#ifdef HAVE_NAMESPACES ++using namespace std; ++#endif + + #ifdef HAVE_MATH_H + #include diff --git a/libtool-blackfin-linux.patch b/libtool-blackfin-linux.patch new file mode 100644 index 0000000..81a366a --- /dev/null +++ b/libtool-blackfin-linux.patch @@ -0,0 +1,63 @@ +Index: libltdl/m4/libtool.m4 +=================================================================== +RCS file: /cvsroot/libtool/libtool/libltdl/m4/libtool.m4,v +retrieving revision 1.86 +diff -u -p -r1.86 libtool.m4 +--- libltdl/m4/libtool.m4 19 Oct 2006 05:06:14 -0000 1.86 ++++ libltdl/m4/libtool.m4 12 Jan 2007 22:42:08 -0000 +@@ -2301,7 +2301,7 @@ linux*oldld* | linux*aout* | linux*coff* + ;; + + # This must be Linux ELF. +-linux* | k*bsd*-gnu) ++linux* | uclinux* | k*bsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no +@@ -2914,7 +2914,7 @@ irix5* | irix6* | nonstopux*) + ;; + + # This must be Linux ELF. +-linux* | k*bsd*-gnu) ++linux* | uclinux* | k*bsd*-gnu) + lt_cv_deplibs_check_method=pass_all + ;; + +@@ -3444,6 +3444,18 @@ m4_if([$1], [CXX], [ + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; ++ linux*) ++ # Handle ports that support FDPIC ELF instead of plain ELF ++ case $host_cpu in ++ bfin) ++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-mfdpic' ++ CFLAGS="$CFLAGS -mfdpic" ++ ;; ++ *) ++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ++ ;; ++ esac ++ ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; +@@ -3750,6 +3762,18 @@ m4_if([$1], [CXX], [ + fi + ;; + ++ linux*) ++ # Handle ports that support FDPIC ELF instead of plain ELF ++ case $host_cpu in ++ bfin) ++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-mfdpic' ++ CFLAGS="$CFLAGS -mfdpic" ++ ;; ++ *) ++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ++ ;; ++ esac ++ ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; diff --git a/libtool-more-gcc-profile-linker-flags.patch b/libtool-more-gcc-profile-linker-flags.patch new file mode 100644 index 0000000..0e1de1f --- /dev/null +++ b/libtool-more-gcc-profile-linker-flags.patch @@ -0,0 +1,26 @@ +2006-12-30 Mike Frysinger + + * libltdl/config/ltmain.m4sh (func_mode_link): Pass through + `-p', `-fprofile-arcs', and `-fprofile-generate' for GCC. + +Index: libltdl/config/ltmain.m4sh +=================================================================== +RCS file: /cvsroot/libtool/libtool/libltdl/config/ltmain.m4sh,v +retrieving revision 1.56 +diff -u -p -r1.56 ltmain.m4sh +--- libltdl/config/ltmain.m4sh 22 Oct 2006 14:10:33 -0000 1.56 ++++ libltdl/config/ltmain.m4sh 30 Dec 2006 15:37:08 -0000 +@@ -2902,10 +2902,11 @@ func_mode_link () + # -m*, -t[45]*, -txscale* pass through architecture-specific + # compiler args for GCC + # -F/path gives path to uninstalled frameworks, gcc on darwin +- # -pg, --coverage pass through profiling flag for GCC ++ # -p, -pg, --coverage, -fprofile-arcs, -fprofile-generate pass ++ # through profiling flag for GCC + # @file GCC response files + -64|-mips[[0-9]]|-r[[0-9]][[0-9]]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ +- -t[[45]]*|-txscale*|-pg|--coverage|-F*|@*) ++ -t[[45]]*|-txscale*|-p|-pg|--coverage|-fprofile-arcs|-fprofile-generate|-F*|@*) + func_quote_for_eval "$arg" + arg="$func_quote_for_eval_result" + func_append compile_command " $arg" diff --git a/libtool-use-AC_MSG_RESULT.patch b/libtool-use-AC_MSG_RESULT.patch new file mode 100644 index 0000000..46afff8 --- /dev/null +++ b/libtool-use-AC_MSG_RESULT.patch @@ -0,0 +1,20 @@ +2007-08-19 Mike Frysinger + + * libtool.m4 (_LT_AC_TAGCONFIG): Use AC_MSG_RESULT rather than echo. + +Index: libtool.m4 +=================================================================== +RCS file: /cvsroot/libtool/libtool/Attic/libtool.m4,v +retrieving revision 1.314.2.187 +diff -u -p -r1.314.2.187 libtool.m4 +--- libtool.m4 16 Aug 2007 18:23:24 -0000 1.314.2.187 ++++ libtool.m4 20 Aug 2007 03:03:33 -0000 +@@ -1871,7 +1871,7 @@ if test -f "$ltmain" && test -n "$tagnam + + # Update the list of available tags. + if test -n "$tagname"; then +- echo appending configuration tag \"$tagname\" to $ofile ++ AC_MSG_RESULT([appending configuration tag \"$tagname\" to $ofile]) + + case $tagname in + CXX) diff --git a/linux-alpha-epoll-sysnums.patch b/linux-alpha-epoll-sysnums.patch new file mode 100644 index 0000000..bbf5653 --- /dev/null +++ b/linux-alpha-epoll-sysnums.patch @@ -0,0 +1,22 @@ +diff --git a/include/asm-alpha/unistd.h b/include/asm-alpha/unistd.h +index 84313d1..e58a427 100644 +--- a/include/asm-alpha/unistd.h ++++ b/include/asm-alpha/unistd.h +@@ -342,9 +342,14 @@ + #define __NR_io_cancel 402 + #define __NR_exit_group 405 + #define __NR_lookup_dcookie 406 +-#define __NR_sys_epoll_create 407 +-#define __NR_sys_epoll_ctl 408 +-#define __NR_sys_epoll_wait 409 ++#define __NR_epoll_create 407 ++#define __NR_epoll_ctl 408 ++#define __NR_epoll_wait 409 ++/* Feb 2007: These three sys_epoll defines shouldn't be here but culling ++ * them would break userspace apps ... we'll kill them off in 2010 :) */ ++#define __NR_sys_epoll_create __NR_epoll_create ++#define __NR_sys_epoll_ctl __NR_epoll_ctl ++#define __NR_sys_epoll_wait __NR_epoll_wait + #define __NR_remap_file_pages 410 + #define __NR_set_tid_address 411 + #define __NR_restart_syscall 412 diff --git a/linux-blackfin-checkstack.patch b/linux-blackfin-checkstack.patch new file mode 100644 index 0000000..0415d9c --- /dev/null +++ b/linux-blackfin-checkstack.patch @@ -0,0 +1,14 @@ +diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl +index f7844f6..9226381 100755 +--- a/scripts/checkstack.pl ++++ b/scripts/checkstack.pl +@@ -73,6 +73,9 @@ my (@stack, $re, $x, $xs); + # pair for larger users. -- PFM. + #a00048e0: d4fc40f0 addi.l r15,-240,r15 + $re = qr/.*addi\.l.*r15,-(([0-9]{2}|[3-9])[0-9]{2}),r15/o; ++ } elsif ($arch =~ /^blackfin$/) { ++ # 0: 00 e8 38 01 LINK 0x4e0; ++ $re = qr/.*[[:space:]]LINK[[:space:]]*(0x$x{1,8})/o; + } else { + print("wrong or unknown architecture\n"); + exit diff --git a/linux-check-headers-for-asm.patch b/linux-check-headers-for-asm.patch new file mode 100644 index 0000000..9bcb6e3 --- /dev/null +++ b/linux-check-headers-for-asm.patch @@ -0,0 +1,21 @@ +diff --git a/scripts/hdrcheck.sh b/scripts/hdrcheck.sh +index 3159858..33d17cc 100755 +--- a/scripts/hdrcheck.sh ++++ b/scripts/hdrcheck.sh +@@ -6,5 +6,16 @@ for FILE in `grep '^[ \t]*#[ \t]*include[ \t]*<' $2 | cut -f2 -d\< | cut -f1 -d\ + exit 1 + fi + done ++ ++# make sure we export __asm__(), not asm() ++lines=$(grep -n -E \ ++ -e '\ + +diff --git a/arch/x86_64/kernel/cpufreq/Kconfig b/arch/x86_64/kernel/cpufreq/Kconfig +index 40acb67..c0749d2 100644 +--- a/arch/x86_64/kernel/cpufreq/Kconfig ++++ b/arch/x86_64/kernel/cpufreq/Kconfig +@@ -16,6 +16,9 @@ config X86_POWERNOW_K8 + help + This adds the CPUFreq driver for mobile AMD Opteron/Athlon64 processors. + ++ To compile this driver as a module, choose M here: the ++ module will be called powernow-k8. ++ + For details, take a look at . + + If in doubt, say N. +@@ -38,6 +41,9 @@ config X86_SPEEDSTEP_CENTRINO + mobile CPUs. This means Intel Pentium M (Centrino) CPUs + or 64bit enabled Intel Xeons. + ++ To compile this driver as a module, choose M here: the ++ module will be called speedstep-centrino. ++ + For details, take a look at . + + If in doubt, say N. +@@ -55,6 +61,9 @@ config X86_ACPI_CPUFREQ + Processor Performance States. + This driver also supports Intel Enhanced Speedstep. + ++ To compile this driver as a module, choose M here: the ++ module will be called acpi-cpufreq. ++ + For details, take a look at . + + If in doubt, say N. +@@ -62,7 +71,7 @@ config X86_ACPI_CPUFREQ + comment "shared options" + + config X86_ACPI_CPUFREQ_PROC_INTF +- bool "/proc/acpi/processor/../performance interface (deprecated)" ++ bool "/proc/acpi/processor/../performance interface (deprecated)" + depends on PROC_FS + depends on X86_ACPI_CPUFREQ || X86_SPEEDSTEP_CENTRINO_ACPI || X86_POWERNOW_K8_ACPI + help +@@ -86,16 +95,18 @@ config X86_P4_CLOCKMOD + slowdowns and noticeable latencies. Normally Speedstep should be used + instead. + ++ To compile this driver as a module, choose M here: the ++ module will be called p4-clockmod. ++ + For details, take a look at . + + Unless you are absolutely sure say N. + + + config X86_SPEEDSTEP_LIB +- tristate +- default X86_P4_CLOCKMOD ++ tristate ++ default X86_P4_CLOCKMOD + + endif + + endmenu +- +diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig +index d155e81..993fa7b 100644 +--- a/drivers/cpufreq/Kconfig ++++ b/drivers/cpufreq/Kconfig +@@ -9,6 +9,9 @@ config CPU_FREQ + clock speed, you need to either enable a dynamic cpufreq governor + (see below) after boot, or use a userspace tool. + ++ To compile this driver as a module, choose M here: the ++ module will be called cpufreq. ++ + For details, take a look at . + + If in doubt, say N. +@@ -16,7 +19,7 @@ config CPU_FREQ + if CPU_FREQ + + config CPU_FREQ_TABLE +- tristate ++ tristate + + config CPU_FREQ_DEBUG + bool "Enable CPUfreq debugging" +@@ -32,19 +35,26 @@ config CPU_FREQ_DEBUG + 4 to activate CPUfreq governor debugging + + config CPU_FREQ_STAT +- tristate "CPU frequency translation statistics" +- select CPU_FREQ_TABLE +- default y +- help +- This driver exports CPU frequency statistics information through sysfs +- file system ++ tristate "CPU frequency translation statistics" ++ select CPU_FREQ_TABLE ++ default y ++ help ++ This driver exports CPU frequency statistics information through sysfs ++ file system. ++ ++ To compile this driver as a module, choose M here: the ++ module will be called cpufreq_stats. ++ ++ If in doubt, say N. + + config CPU_FREQ_STAT_DETAILS +- bool "CPU frequency translation statistics details" +- depends on CPU_FREQ_STAT +- help +- This will show detail CPU frequency translation table in sysfs file +- system ++ bool "CPU frequency translation statistics details" ++ depends on CPU_FREQ_STAT ++ help ++ This will show detail CPU frequency translation table in sysfs file ++ system. ++ ++ If in doubt, say N. + + # Note that it is not currently possible to set the other governors (such as ondemand) + # as the default, since if they fail to initialise, cpufreq will be +@@ -78,29 +88,38 @@ config CPU_FREQ_DEFAULT_GOV_USERSPACE + endchoice + + config CPU_FREQ_GOV_PERFORMANCE +- tristate "'performance' governor" +- help ++ tristate "'performance' governor" ++ help + This cpufreq governor sets the frequency statically to the + highest available CPU frequency. + ++ To compile this driver as a module, choose M here: the ++ module will be called cpufreq_performance. ++ + If in doubt, say Y. + + config CPU_FREQ_GOV_POWERSAVE +- tristate "'powersave' governor" +- help ++ tristate "'powersave' governor" ++ help + This cpufreq governor sets the frequency statically to the + lowest available CPU frequency. + ++ To compile this driver as a module, choose M here: the ++ module will be called cpufreq_powersave. ++ + If in doubt, say Y. + + config CPU_FREQ_GOV_USERSPACE +- tristate "'userspace' governor for userspace frequency scaling" +- help ++ tristate "'userspace' governor for userspace frequency scaling" ++ help + Enable this cpufreq governor when you either want to set the + CPU frequency manually or when an userspace program shall + be able to set the CPU dynamically, like on LART + . + ++ To compile this driver as a module, choose M here: the ++ module will be called cpufreq_userspace. ++ + For details, take a look at . + + If in doubt, say Y. +@@ -116,6 +135,9 @@ config CPU_FREQ_GOV_ONDEMAND + do fast frequency switching (i.e, very low latency frequency + transitions). + ++ To compile this driver as a module, choose M here: the ++ module will be called cpufreq_ondemand. ++ + For details, take a look at linux/Documentation/cpu-freq. + + If in doubt, say N. +@@ -136,6 +158,9 @@ config CPU_FREQ_GOV_CONSERVATIVE + step-by-step latency issues between the minimum and maximum frequency + transitions in the CPU) you will probably want to use this governor. + ++ To compile this driver as a module, choose M here: the ++ module will be called cpufreq_conservative. ++ + For details, take a look at linux/Documentation/cpu-freq. + + If in doubt, say N. diff --git a/linux-dirent-types.patch b/linux-dirent-types.patch new file mode 100644 index 0000000..908c824 --- /dev/null +++ b/linux-dirent-types.patch @@ -0,0 +1,13 @@ +diff --git a/include/linux/dirent.h b/include/linux/dirent.h +index 5d6023b..d5b642d 100644 +--- a/include/linux/dirent.h ++++ b/include/linux/dirent.h +@@ -1,6 +1,8 @@ + #ifndef _LINUX_DIRENT_H + #define _LINUX_DIRENT_H + ++#include ++ + struct dirent { + long d_ino; + __kernel_off_t d_off; diff --git a/linux-docbook-trees.patch b/linux-docbook-trees.patch new file mode 100644 index 0000000..93891d6 --- /dev/null +++ b/linux-docbook-trees.patch @@ -0,0 +1,19 @@ +have KERNELDOC use $(srctree) and DOCPROC use $(objtree) + +Signed-off-by: Mike Frysinger + +diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile +index 36526a1..867608a 100644 +--- a/Documentation/DocBook/Makefile ++++ b/Documentation/DocBook/Makefile +@@ -53,8 +53,8 @@ installmandocs: mandocs + + ### + #External programs used +-KERNELDOC = scripts/kernel-doc +-DOCPROC = scripts/basic/docproc ++KERNELDOC = $(srctree)/scripts/kernel-doc ++DOCPROC = $(objtree)/scripts/basic/docproc + + XMLTOFLAGS = -m $(srctree)/Documentation/DocBook/stylesheet.xsl + #XMLTOFLAGS += --skip-validation diff --git a/linux-dont-export-asm-page.patch b/linux-dont-export-asm-page.patch new file mode 100644 index 0000000..5dd7bd9 --- /dev/null +++ b/linux-dont-export-asm-page.patch @@ -0,0 +1,9 @@ +diff --git a/include/asm-generic/Kbuild.asm b/include/asm-generic/Kbuild.asm +index a37e95f..642d277 100644 +--- a/include/asm-generic/Kbuild.asm ++++ b/include/asm-generic/Kbuild.asm +@@ -32,4 +32,3 @@ unifdef-y += user.h + # These probably shouldn't be exported + unifdef-y += shmparam.h + unifdef-y += elf.h +-unifdef-y += page.h diff --git a/linux-dont-force-enable-rts.patch b/linux-dont-force-enable-rts.patch new file mode 100644 index 0000000..1a6bec7 --- /dev/null +++ b/linux-dont-force-enable-rts.patch @@ -0,0 +1,13 @@ +diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c +index 0422c0f..838331d 100644 +--- a/drivers/serial/serial_core.c ++++ b/drivers/serial/serial_core.c +@@ -189,7 +189,7 @@ static int uart_startup(struct uart_state *state, int init_hw) + * port is open and ready to respond. + */ + if (info->tty->termios->c_cflag & CBAUD) +- uart_set_mctrl(port, TIOCM_RTS | TIOCM_DTR); ++ uart_set_mctrl(port, (info->flags & UIF_CTS_FLOW ? TIOCM_RTS : 0) | TIOCM_DTR); + } + + if (info->flags & UIF_CTS_FLOW) { diff --git a/linux-export-ufs-fs-header.patch b/linux-export-ufs-fs-header.patch new file mode 100644 index 0000000..fe749ba --- /dev/null +++ b/linux-export-ufs-fs-header.patch @@ -0,0 +1,52 @@ +Touchup ufs_fs.h so we can export it to userspace. + +Signed-off-by: Mike Frysinger + +diff --git a/include/linux/Kbuild b/include/linux/Kbuild +index 862e483..fde20b0 100644 +--- a/include/linux/Kbuild ++++ b/include/linux/Kbuild +@@ -324,6 +324,7 @@ unifdef-y += tty.h + unifdef-y += types.h + unifdef-y += udf_fs_i.h + unifdef-y += udp.h ++unifdef-y += ufs_fs.h + unifdef-y += uinput.h + unifdef-y += uio.h + unifdef-y += unistd.h +diff --git a/include/linux/ufs_fs.h b/include/linux/ufs_fs.h +index 28967ed..0497738 100644 +--- a/include/linux/ufs_fs.h ++++ b/include/linux/ufs_fs.h +@@ -45,8 +45,10 @@ typedef __u32 __bitwise __fs32; + typedef __u16 __bitwise __fs16; + #endif + ++#ifdef __KERNEL__ + #include + #include ++#endif + + #define UFS_BBLOCK 0 + #define UFS_BBSIZE 8192 +@@ -303,7 +305,7 @@ typedef __u16 __bitwise __fs16; + #define UFS_MAXMNTLEN 512 + #define UFS2_MAXMNTLEN 468 + #define UFS2_MAXVOLLEN 32 +-/* #define UFS_MAXCSBUFS 31 */ ++#define UFS_MAXCSBUFS 31 + #define UFS_LINK_MAX 32000 + /* + #define UFS2_NOCSPTRS ((128 / sizeof(void *)) - 4) +diff --git a/include/linux/ufs_fs_sb.h b/include/linux/ufs_fs_sb.h +index 8ff13c1..e114c93 100644 +--- a/include/linux/ufs_fs_sb.h ++++ b/include/linux/ufs_fs_sb.h +@@ -21,7 +21,6 @@ + struct ufs_sb_private_info; + struct ufs_cg_private_info; + struct ufs_csum; +-#define UFS_MAXCSBUFS 31 + + struct ufs_sb_info { + struct ufs_sb_private_info * s_uspi; diff --git a/linux-gen-init-cpio-stdin.patch b/linux-gen-init-cpio-stdin.patch new file mode 100644 index 0000000..dfe597e --- /dev/null +++ b/linux-gen-init-cpio-stdin.patch @@ -0,0 +1,15 @@ +diff --git a/usr/gen_init_cpio.c b/usr/gen_init_cpio.c +index 8365db6..7abc07f 100644 +--- a/usr/gen_init_cpio.c ++++ b/usr/gen_init_cpio.c +@@ -498,7 +498,9 @@ int main (int argc, char *argv[]) + exit(1); + } + +- if (! (cpio_list = fopen(argv[1], "r"))) { ++ if (!strcmp(argv[1], "-")) ++ cpio_list = stdin; ++ else if (! (cpio_list = fopen(argv[1], "r"))) { + fprintf(stderr, "ERROR: unable to open '%s': %s\n\n", + argv[1], strerror(errno)); + usage(argv[0]); diff --git a/linux-get-unaligned-__val.patch b/linux-get-unaligned-__val.patch new file mode 100644 index 0000000..963a5f3 --- /dev/null +++ b/linux-get-unaligned-__val.patch @@ -0,0 +1,35 @@ +diff --git a/include/asm-generic/unaligned.h b/include/asm-generic/unaligned.h +index 16a466e..2fe1b2e 100644 +--- a/include/asm-generic/unaligned.h ++++ b/include/asm-generic/unaligned.h +@@ -79,24 +79,24 @@ static inline void __ustw(__u16 val, __u16 *addr) + + #define __get_unaligned(ptr, size) ({ \ + const void *__gu_p = ptr; \ +- __u64 val; \ ++ __u64 __val; \ + switch (size) { \ + case 1: \ +- val = *(const __u8 *)__gu_p; \ ++ __val = *(const __u8 *)__gu_p; \ + break; \ + case 2: \ +- val = __uldw(__gu_p); \ ++ __val = __uldw(__gu_p); \ + break; \ + case 4: \ +- val = __uldl(__gu_p); \ ++ __val = __uldl(__gu_p); \ + break; \ + case 8: \ +- val = __uldq(__gu_p); \ ++ __val = __uldq(__gu_p); \ + break; \ + default: \ + bad_unaligned_access_length(); \ + }; \ +- (__force __typeof__(*(ptr)))val; \ ++ (__force __typeof__(*(ptr)))__val; \ + }) + + #define __put_unaligned(val, ptr, size) \ diff --git a/linux-headers-check-all.patch b/linux-headers-check-all.patch new file mode 100644 index 0000000..88ce3ec --- /dev/null +++ b/linux-headers-check-all.patch @@ -0,0 +1,19 @@ +Add new headers_check_all target for checking all arches in one go. + +Signed-off-by: Mike Frysinger + +--- a/Makefile ++++ b/Makefile +@@ -936,6 +936,12 @@ headers_install: include/linux/version.h scripts_basic FORCE + $(Q)$(MAKE) $(build)=scripts scripts/unifdef + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.headersinst obj=include + ++PHONY += headers_check_all ++headers_check_all: headers_install_all ++ $(Q)for arch in $(HDRARCHES); do \ ++ $(MAKE) ARCH=$$arch -f $(srctree)/scripts/Makefile.headersinst obj=include BIASMDIR=-bi-$$arch HDRCHECK=1 ;\ ++ done ++ + PHONY += headers_check + headers_check: headers_install + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.headersinst obj=include HDRCHECK=1 diff --git a/linux-headersinst-translate-dash.patch b/linux-headersinst-translate-dash.patch new file mode 100644 index 0000000..7480dc7 --- /dev/null +++ b/linux-headersinst-translate-dash.patch @@ -0,0 +1,15 @@ +Make sure we translate dashes in file names to underscores for use as defines. + +Signed-off-by: Mike Frysinger + +--- a/scripts/Makefile.headersinst ++++ b/scripts/Makefile.headersinst +@@ -109,7 +109,7 @@ quiet_cmd_mkdir = MKDIR $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) + quiet_cmd_gen = GEN $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) + cmd_gen = \ + FNAME=$(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$@) \ +-STUBDEF=__ASM_STUB_`echo $$FNAME | tr a-z. A-Z_`; \ ++STUBDEF=__ASM_STUB_`echo $$FNAME | tr a-z.- A-Z__`; \ + (echo "/* File autogenerated by 'make headers_install' */" ; \ + echo "\#ifndef $$STUBDEF" ; \ + echo "\#define $$STUBDEF" ; \ diff --git a/linux-i2c-smbus-doc-typo.patch b/linux-i2c-smbus-doc-typo.patch new file mode 100644 index 0000000..742a3b0 --- /dev/null +++ b/linux-i2c-smbus-doc-typo.patch @@ -0,0 +1,17 @@ +Fix typo in SMBus Write Word Data description (write data, dont read it). + +Signed-off-by: Mike Frysinger + +diff --git a/Documentation/i2c/smbus-protocol b/Documentation/i2c/smbus-protocol +index 09f5e5c..3baedec 100644 +--- a/Documentation/i2c/smbus-protocol ++++ b/Documentation/i2c/smbus-protocol +@@ -97,7 +97,7 @@ SMBus Write Word Data + ===================== + + This is the opposite operation of the Read Word Data command. 16 bits +-of data is read from a device, from a designated register that is ++of data is written to a device to the designated register that is + specified through the Comm byte. + + S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A] P diff --git a/linux-ia64-asm-volatile-gcc-intrin.patch b/linux-ia64-asm-volatile-gcc-intrin.patch new file mode 100644 index 0000000..6923d5b --- /dev/null +++ b/linux-ia64-asm-volatile-gcc-intrin.patch @@ -0,0 +1,667 @@ +diff --git a/include/asm-ia64/gcc_intrin.h b/include/asm-ia64/gcc_intrin.h +index 4fb4e43..0bb24df 100644 +--- a/include/asm-ia64/gcc_intrin.h ++++ b/include/asm-ia64/gcc_intrin.h +@@ -13,41 +13,41 @@ + + /* Optimization barrier */ + /* The "volatile" is due to gcc bugs */ +-#define ia64_barrier() asm volatile ("":::"memory") ++#define ia64_barrier() __asm__ __volatile__ ("":::"memory") + +-#define ia64_stop() asm volatile (";;"::) ++#define ia64_stop() __asm__ __volatile__ (";;"::) + +-#define ia64_invala_gr(regnum) asm volatile ("invala.e r%0" :: "i"(regnum)) ++#define ia64_invala_gr(regnum) __asm__ __volatile__ ("invala.e r%0" :: "i"(regnum)) + +-#define ia64_invala_fr(regnum) asm volatile ("invala.e f%0" :: "i"(regnum)) ++#define ia64_invala_fr(regnum) __asm__ __volatile__ ("invala.e f%0" :: "i"(regnum)) + + extern void ia64_bad_param_for_setreg (void); + extern void ia64_bad_param_for_getreg (void); + +-register unsigned long ia64_r13 asm ("r13") __attribute_used__; ++register unsigned long ia64_r13 __asm__ ("r13") __attribute_used__; + + #define ia64_setreg(regnum, val) \ + ({ \ + switch (regnum) { \ + case _IA64_REG_PSR_L: \ +- asm volatile ("mov psr.l=%0" :: "r"(val) : "memory"); \ ++ __asm__ __volatile__ ("mov psr.l=%0" :: "r"(val) : "memory"); \ + break; \ + case _IA64_REG_AR_KR0 ... _IA64_REG_AR_EC: \ +- asm volatile ("mov ar%0=%1" :: \ ++ __asm__ __volatile__ ("mov ar%0=%1" :: \ + "i" (regnum - _IA64_REG_AR_KR0), \ + "r"(val): "memory"); \ + break; \ + case _IA64_REG_CR_DCR ... _IA64_REG_CR_LRR1: \ +- asm volatile ("mov cr%0=%1" :: \ ++ __asm__ __volatile__ ("mov cr%0=%1" :: \ + "i" (regnum - _IA64_REG_CR_DCR), \ + "r"(val): "memory" ); \ + break; \ + case _IA64_REG_SP: \ +- asm volatile ("mov r12=%0" :: \ ++ __asm__ __volatile__ ("mov r12=%0" :: \ + "r"(val): "memory"); \ + break; \ + case _IA64_REG_GP: \ +- asm volatile ("mov gp=%0" :: "r"(val) : "memory"); \ ++ __asm__ __volatile__ ("mov gp=%0" :: "r"(val) : "memory"); \ + break; \ + default: \ + ia64_bad_param_for_setreg(); \ +@@ -61,27 +61,27 @@ register unsigned long ia64_r13 asm ("r13") __attribute_used__; + \ + switch (regnum) { \ + case _IA64_REG_GP: \ +- asm volatile ("mov %0=gp" : "=r"(ia64_intri_res)); \ ++ __asm__ __volatile__ ("mov %0=gp" : "=r"(ia64_intri_res)); \ + break; \ + case _IA64_REG_IP: \ +- asm volatile ("mov %0=ip" : "=r"(ia64_intri_res)); \ ++ __asm__ __volatile__ ("mov %0=ip" : "=r"(ia64_intri_res)); \ + break; \ + case _IA64_REG_PSR: \ +- asm volatile ("mov %0=psr" : "=r"(ia64_intri_res)); \ ++ __asm__ __volatile__ ("mov %0=psr" : "=r"(ia64_intri_res)); \ + break; \ + case _IA64_REG_TP: /* for current() */ \ + ia64_intri_res = ia64_r13; \ + break; \ + case _IA64_REG_AR_KR0 ... _IA64_REG_AR_EC: \ +- asm volatile ("mov %0=ar%1" : "=r" (ia64_intri_res) \ ++ __asm__ __volatile__ ("mov %0=ar%1" : "=r" (ia64_intri_res) \ + : "i"(regnum - _IA64_REG_AR_KR0)); \ + break; \ + case _IA64_REG_CR_DCR ... _IA64_REG_CR_LRR1: \ +- asm volatile ("mov %0=cr%1" : "=r" (ia64_intri_res) \ ++ __asm__ __volatile__ ("mov %0=cr%1" : "=r" (ia64_intri_res) \ + : "i" (regnum - _IA64_REG_CR_DCR)); \ + break; \ + case _IA64_REG_SP: \ +- asm volatile ("mov %0=sp" : "=r" (ia64_intri_res)); \ ++ __asm__ __volatile__ ("mov %0=sp" : "=r" (ia64_intri_res)); \ + break; \ + default: \ + ia64_bad_param_for_getreg(); \ +@@ -96,7 +96,7 @@ register unsigned long ia64_r13 asm ("r13") __attribute_used__; + ({ \ + switch (mode) { \ + case ia64_hint_pause: \ +- asm volatile ("hint @pause" ::: "memory"); \ ++ __asm__ __volatile__ ("hint @pause" ::: "memory"); \ + break; \ + } \ + }) +@@ -115,19 +115,19 @@ register unsigned long ia64_r13 asm ("r13") __attribute_used__; + \ + switch (mode) { \ + case ia64_mux1_brcst: \ +- asm ("mux1 %0=%1,@brcst" : "=r" (ia64_intri_res) : "r" (x)); \ ++ __asm__ ("mux1 %0=%1,@brcst" : "=r" (ia64_intri_res) : "r" (x)); \ + break; \ + case ia64_mux1_mix: \ +- asm ("mux1 %0=%1,@mix" : "=r" (ia64_intri_res) : "r" (x)); \ ++ __asm__ ("mux1 %0=%1,@mix" : "=r" (ia64_intri_res) : "r" (x)); \ + break; \ + case ia64_mux1_shuf: \ +- asm ("mux1 %0=%1,@shuf" : "=r" (ia64_intri_res) : "r" (x)); \ ++ __asm__ ("mux1 %0=%1,@shuf" : "=r" (ia64_intri_res) : "r" (x)); \ + break; \ + case ia64_mux1_alt: \ +- asm ("mux1 %0=%1,@alt" : "=r" (ia64_intri_res) : "r" (x)); \ ++ __asm__ ("mux1 %0=%1,@alt" : "=r" (ia64_intri_res) : "r" (x)); \ + break; \ + case ia64_mux1_rev: \ +- asm ("mux1 %0=%1,@rev" : "=r" (ia64_intri_res) : "r" (x)); \ ++ __asm__ ("mux1 %0=%1,@rev" : "=r" (ia64_intri_res) : "r" (x)); \ + break; \ + } \ + ia64_intri_res; \ +@@ -139,7 +139,7 @@ register unsigned long ia64_r13 asm ("r13") __attribute_used__; + # define ia64_popcnt(x) \ + ({ \ + __u64 ia64_intri_res; \ +- asm ("popcnt %0=%1" : "=r" (ia64_intri_res) : "r" (x)); \ ++ __asm__ ("popcnt %0=%1" : "=r" (ia64_intri_res) : "r" (x)); \ + \ + ia64_intri_res; \ + }) +@@ -149,7 +149,7 @@ register unsigned long ia64_r13 asm ("r13") __attribute_used__; + ({ \ + long ia64_intri_res; \ + \ +- asm ("getf.exp %0=%1" : "=r"(ia64_intri_res) : "f"(x)); \ ++ __asm__ ("getf.exp %0=%1" : "=r"(ia64_intri_res) : "f"(x)); \ + \ + ia64_intri_res; \ + }) +@@ -157,75 +157,75 @@ register unsigned long ia64_r13 asm ("r13") __attribute_used__; + #define ia64_shrp(a, b, count) \ + ({ \ + __u64 ia64_intri_res; \ +- asm ("shrp %0=%1,%2,%3" : "=r"(ia64_intri_res) : "r"(a), "r"(b), "i"(count)); \ ++ __asm__ ("shrp %0=%1,%2,%3" : "=r"(ia64_intri_res) : "r"(a), "r"(b), "i"(count)); \ + ia64_intri_res; \ + }) + + #define ia64_ldfs(regnum, x) \ + ({ \ +- register double __f__ asm ("f"#regnum); \ +- asm volatile ("ldfs %0=[%1]" :"=f"(__f__): "r"(x)); \ ++ register double __f__ __asm__ ("f"#regnum); \ ++ __asm__ __volatile__ ("ldfs %0=[%1]" :"=f"(__f__): "r"(x)); \ + }) + + #define ia64_ldfd(regnum, x) \ + ({ \ +- register double __f__ asm ("f"#regnum); \ +- asm volatile ("ldfd %0=[%1]" :"=f"(__f__): "r"(x)); \ ++ register double __f__ __asm__ ("f"#regnum); \ ++ __asm__ __volatile__ ("ldfd %0=[%1]" :"=f"(__f__): "r"(x)); \ + }) + + #define ia64_ldfe(regnum, x) \ + ({ \ +- register double __f__ asm ("f"#regnum); \ +- asm volatile ("ldfe %0=[%1]" :"=f"(__f__): "r"(x)); \ ++ register double __f__ __asm__ ("f"#regnum); \ ++ __asm__ __volatile__ ("ldfe %0=[%1]" :"=f"(__f__): "r"(x)); \ + }) + + #define ia64_ldf8(regnum, x) \ + ({ \ +- register double __f__ asm ("f"#regnum); \ +- asm volatile ("ldf8 %0=[%1]" :"=f"(__f__): "r"(x)); \ ++ register double __f__ __asm__ ("f"#regnum); \ ++ __asm__ __volatile__ ("ldf8 %0=[%1]" :"=f"(__f__): "r"(x)); \ + }) + + #define ia64_ldf_fill(regnum, x) \ + ({ \ +- register double __f__ asm ("f"#regnum); \ +- asm volatile ("ldf.fill %0=[%1]" :"=f"(__f__): "r"(x)); \ ++ register double __f__ __asm__ ("f"#regnum); \ ++ __asm__ __volatile__ ("ldf.fill %0=[%1]" :"=f"(__f__): "r"(x)); \ + }) + + #define ia64_stfs(x, regnum) \ + ({ \ +- register double __f__ asm ("f"#regnum); \ +- asm volatile ("stfs [%0]=%1" :: "r"(x), "f"(__f__) : "memory"); \ ++ register double __f__ __asm__ ("f"#regnum); \ ++ __asm__ __volatile__ ("stfs [%0]=%1" :: "r"(x), "f"(__f__) : "memory"); \ + }) + + #define ia64_stfd(x, regnum) \ + ({ \ +- register double __f__ asm ("f"#regnum); \ +- asm volatile ("stfd [%0]=%1" :: "r"(x), "f"(__f__) : "memory"); \ ++ register double __f__ __asm__ ("f"#regnum); \ ++ __asm__ __volatile__ ("stfd [%0]=%1" :: "r"(x), "f"(__f__) : "memory"); \ + }) + + #define ia64_stfe(x, regnum) \ + ({ \ +- register double __f__ asm ("f"#regnum); \ +- asm volatile ("stfe [%0]=%1" :: "r"(x), "f"(__f__) : "memory"); \ ++ register double __f__ __asm__ ("f"#regnum); \ ++ __asm__ __volatile__ ("stfe [%0]=%1" :: "r"(x), "f"(__f__) : "memory"); \ + }) + + #define ia64_stf8(x, regnum) \ + ({ \ +- register double __f__ asm ("f"#regnum); \ +- asm volatile ("stf8 [%0]=%1" :: "r"(x), "f"(__f__) : "memory"); \ ++ register double __f__ __asm__ ("f"#regnum); \ ++ __asm__ __volatile__ ("stf8 [%0]=%1" :: "r"(x), "f"(__f__) : "memory"); \ + }) + + #define ia64_stf_spill(x, regnum) \ + ({ \ +- register double __f__ asm ("f"#regnum); \ +- asm volatile ("stf.spill [%0]=%1" :: "r"(x), "f"(__f__) : "memory"); \ ++ register double __f__ __asm__ ("f"#regnum); \ ++ __asm__ __volatile__ ("stf.spill [%0]=%1" :: "r"(x), "f"(__f__) : "memory"); \ + }) + + #define ia64_fetchadd4_acq(p, inc) \ + ({ \ + \ + __u64 ia64_intri_res; \ +- asm volatile ("fetchadd4.acq %0=[%1],%2" \ ++ __asm__ __volatile__ ("fetchadd4.acq %0=[%1],%2" \ + : "=r"(ia64_intri_res) : "r"(p), "i" (inc) \ + : "memory"); \ + \ +@@ -235,7 +235,7 @@ register unsigned long ia64_r13 asm ("r13") __attribute_used__; + #define ia64_fetchadd4_rel(p, inc) \ + ({ \ + __u64 ia64_intri_res; \ +- asm volatile ("fetchadd4.rel %0=[%1],%2" \ ++ __asm__ __volatile__ ("fetchadd4.rel %0=[%1],%2" \ + : "=r"(ia64_intri_res) : "r"(p), "i" (inc) \ + : "memory"); \ + \ +@@ -246,7 +246,7 @@ register unsigned long ia64_r13 asm ("r13") __attribute_used__; + ({ \ + \ + __u64 ia64_intri_res; \ +- asm volatile ("fetchadd8.acq %0=[%1],%2" \ ++ __asm__ __volatile__ ("fetchadd8.acq %0=[%1],%2" \ + : "=r"(ia64_intri_res) : "r"(p), "i" (inc) \ + : "memory"); \ + \ +@@ -256,7 +256,7 @@ register unsigned long ia64_r13 asm ("r13") __attribute_used__; + #define ia64_fetchadd8_rel(p, inc) \ + ({ \ + __u64 ia64_intri_res; \ +- asm volatile ("fetchadd8.rel %0=[%1],%2" \ ++ __asm__ __volatile__ ("fetchadd8.rel %0=[%1],%2" \ + : "=r"(ia64_intri_res) : "r"(p), "i" (inc) \ + : "memory"); \ + \ +@@ -266,7 +266,7 @@ register unsigned long ia64_r13 asm ("r13") __attribute_used__; + #define ia64_xchg1(ptr,x) \ + ({ \ + __u64 ia64_intri_res; \ +- asm volatile ("xchg1 %0=[%1],%2" \ ++ __asm__ __volatile__ ("xchg1 %0=[%1],%2" \ + : "=r" (ia64_intri_res) : "r" (ptr), "r" (x) : "memory"); \ + ia64_intri_res; \ + }) +@@ -274,7 +274,7 @@ register unsigned long ia64_r13 asm ("r13") __attribute_used__; + #define ia64_xchg2(ptr,x) \ + ({ \ + __u64 ia64_intri_res; \ +- asm volatile ("xchg2 %0=[%1],%2" : "=r" (ia64_intri_res) \ ++ __asm__ __volatile__ ("xchg2 %0=[%1],%2" : "=r" (ia64_intri_res) \ + : "r" (ptr), "r" (x) : "memory"); \ + ia64_intri_res; \ + }) +@@ -282,7 +282,7 @@ register unsigned long ia64_r13 asm ("r13") __attribute_used__; + #define ia64_xchg4(ptr,x) \ + ({ \ + __u64 ia64_intri_res; \ +- asm volatile ("xchg4 %0=[%1],%2" : "=r" (ia64_intri_res) \ ++ __asm__ __volatile__ ("xchg4 %0=[%1],%2" : "=r" (ia64_intri_res) \ + : "r" (ptr), "r" (x) : "memory"); \ + ia64_intri_res; \ + }) +@@ -290,7 +290,7 @@ register unsigned long ia64_r13 asm ("r13") __attribute_used__; + #define ia64_xchg8(ptr,x) \ + ({ \ + __u64 ia64_intri_res; \ +- asm volatile ("xchg8 %0=[%1],%2" : "=r" (ia64_intri_res) \ ++ __asm__ __volatile__ ("xchg8 %0=[%1],%2" : "=r" (ia64_intri_res) \ + : "r" (ptr), "r" (x) : "memory"); \ + ia64_intri_res; \ + }) +@@ -298,8 +298,8 @@ register unsigned long ia64_r13 asm ("r13") __attribute_used__; + #define ia64_cmpxchg1_acq(ptr, new, old) \ + ({ \ + __u64 ia64_intri_res; \ +- asm volatile ("mov ar.ccv=%0;;" :: "rO"(old)); \ +- asm volatile ("cmpxchg1.acq %0=[%1],%2,ar.ccv": \ ++ __asm__ __volatile__ ("mov ar.ccv=%0;;" :: "rO"(old)); \ ++ __asm__ __volatile__ ("cmpxchg1.acq %0=[%1],%2,ar.ccv": \ + "=r"(ia64_intri_res) : "r"(ptr), "r"(new) : "memory"); \ + ia64_intri_res; \ + }) +@@ -307,8 +307,8 @@ register unsigned long ia64_r13 asm ("r13") __attribute_used__; + #define ia64_cmpxchg1_rel(ptr, new, old) \ + ({ \ + __u64 ia64_intri_res; \ +- asm volatile ("mov ar.ccv=%0;;" :: "rO"(old)); \ +- asm volatile ("cmpxchg1.rel %0=[%1],%2,ar.ccv": \ ++ __asm__ __volatile__ ("mov ar.ccv=%0;;" :: "rO"(old)); \ ++ __asm__ __volatile__ ("cmpxchg1.rel %0=[%1],%2,ar.ccv": \ + "=r"(ia64_intri_res) : "r"(ptr), "r"(new) : "memory"); \ + ia64_intri_res; \ + }) +@@ -316,8 +316,8 @@ register unsigned long ia64_r13 asm ("r13") __attribute_used__; + #define ia64_cmpxchg2_acq(ptr, new, old) \ + ({ \ + __u64 ia64_intri_res; \ +- asm volatile ("mov ar.ccv=%0;;" :: "rO"(old)); \ +- asm volatile ("cmpxchg2.acq %0=[%1],%2,ar.ccv": \ ++ __asm__ __volatile__ ("mov ar.ccv=%0;;" :: "rO"(old)); \ ++ __asm__ __volatile__ ("cmpxchg2.acq %0=[%1],%2,ar.ccv": \ + "=r"(ia64_intri_res) : "r"(ptr), "r"(new) : "memory"); \ + ia64_intri_res; \ + }) +@@ -325,9 +325,9 @@ register unsigned long ia64_r13 asm ("r13") __attribute_used__; + #define ia64_cmpxchg2_rel(ptr, new, old) \ + ({ \ + __u64 ia64_intri_res; \ +- asm volatile ("mov ar.ccv=%0;;" :: "rO"(old)); \ ++ __asm__ __volatile__ ("mov ar.ccv=%0;;" :: "rO"(old)); \ + \ +- asm volatile ("cmpxchg2.rel %0=[%1],%2,ar.ccv": \ ++ __asm__ __volatile__ ("cmpxchg2.rel %0=[%1],%2,ar.ccv": \ + "=r"(ia64_intri_res) : "r"(ptr), "r"(new) : "memory"); \ + ia64_intri_res; \ + }) +@@ -335,8 +335,8 @@ register unsigned long ia64_r13 asm ("r13") __attribute_used__; + #define ia64_cmpxchg4_acq(ptr, new, old) \ + ({ \ + __u64 ia64_intri_res; \ +- asm volatile ("mov ar.ccv=%0;;" :: "rO"(old)); \ +- asm volatile ("cmpxchg4.acq %0=[%1],%2,ar.ccv": \ ++ __asm__ __volatile__ ("mov ar.ccv=%0;;" :: "rO"(old)); \ ++ __asm__ __volatile__ ("cmpxchg4.acq %0=[%1],%2,ar.ccv": \ + "=r"(ia64_intri_res) : "r"(ptr), "r"(new) : "memory"); \ + ia64_intri_res; \ + }) +@@ -344,8 +344,8 @@ register unsigned long ia64_r13 asm ("r13") __attribute_used__; + #define ia64_cmpxchg4_rel(ptr, new, old) \ + ({ \ + __u64 ia64_intri_res; \ +- asm volatile ("mov ar.ccv=%0;;" :: "rO"(old)); \ +- asm volatile ("cmpxchg4.rel %0=[%1],%2,ar.ccv": \ ++ __asm__ __volatile__ ("mov ar.ccv=%0;;" :: "rO"(old)); \ ++ __asm__ __volatile__ ("cmpxchg4.rel %0=[%1],%2,ar.ccv": \ + "=r"(ia64_intri_res) : "r"(ptr), "r"(new) : "memory"); \ + ia64_intri_res; \ + }) +@@ -353,8 +353,8 @@ register unsigned long ia64_r13 asm ("r13") __attribute_used__; + #define ia64_cmpxchg8_acq(ptr, new, old) \ + ({ \ + __u64 ia64_intri_res; \ +- asm volatile ("mov ar.ccv=%0;;" :: "rO"(old)); \ +- asm volatile ("cmpxchg8.acq %0=[%1],%2,ar.ccv": \ ++ __asm__ __volatile__ ("mov ar.ccv=%0;;" :: "rO"(old)); \ ++ __asm__ __volatile__ ("cmpxchg8.acq %0=[%1],%2,ar.ccv": \ + "=r"(ia64_intri_res) : "r"(ptr), "r"(new) : "memory"); \ + ia64_intri_res; \ + }) +@@ -362,106 +362,106 @@ register unsigned long ia64_r13 asm ("r13") __attribute_used__; + #define ia64_cmpxchg8_rel(ptr, new, old) \ + ({ \ + __u64 ia64_intri_res; \ +- asm volatile ("mov ar.ccv=%0;;" :: "rO"(old)); \ ++ __asm__ __volatile__ ("mov ar.ccv=%0;;" :: "rO"(old)); \ + \ +- asm volatile ("cmpxchg8.rel %0=[%1],%2,ar.ccv": \ ++ __asm__ __volatile__ ("cmpxchg8.rel %0=[%1],%2,ar.ccv": \ + "=r"(ia64_intri_res) : "r"(ptr), "r"(new) : "memory"); \ + ia64_intri_res; \ + }) + +-#define ia64_mf() asm volatile ("mf" ::: "memory") +-#define ia64_mfa() asm volatile ("mf.a" ::: "memory") ++#define ia64_mf() __asm__ __volatile__ ("mf" ::: "memory") ++#define ia64_mfa() __asm__ __volatile__ ("mf.a" ::: "memory") + +-#define ia64_invala() asm volatile ("invala" ::: "memory") ++#define ia64_invala() __asm__ __volatile__ ("invala" ::: "memory") + + #define ia64_thash(addr) \ + ({ \ + __u64 ia64_intri_res; \ +- asm volatile ("thash %0=%1" : "=r"(ia64_intri_res) : "r" (addr)); \ ++ __asm__ __volatile__ ("thash %0=%1" : "=r"(ia64_intri_res) : "r" (addr)); \ + ia64_intri_res; \ + }) + +-#define ia64_srlz_i() asm volatile (";; srlz.i ;;" ::: "memory") +-#define ia64_srlz_d() asm volatile (";; srlz.d" ::: "memory"); ++#define ia64_srlz_i() __asm__ __volatile__ (";; srlz.i ;;" ::: "memory") ++#define ia64_srlz_d() __asm__ __volatile__ (";; srlz.d" ::: "memory"); + + #ifdef HAVE_SERIALIZE_DIRECTIVE +-# define ia64_dv_serialize_data() asm volatile (".serialize.data"); +-# define ia64_dv_serialize_instruction() asm volatile (".serialize.instruction"); ++# define ia64_dv_serialize_data() __asm__ __volatile__ (".serialize.data"); ++# define ia64_dv_serialize_instruction() __asm__ __volatile__ (".serialize.instruction"); + #else + # define ia64_dv_serialize_data() + # define ia64_dv_serialize_instruction() + #endif + +-#define ia64_nop(x) asm volatile ("nop %0"::"i"(x)); ++#define ia64_nop(x) __asm__ __volatile__ ("nop %0"::"i"(x)); + +-#define ia64_itci(addr) asm volatile ("itc.i %0;;" :: "r"(addr) : "memory") ++#define ia64_itci(addr) __asm__ __volatile__ ("itc.i %0;;" :: "r"(addr) : "memory") + +-#define ia64_itcd(addr) asm volatile ("itc.d %0;;" :: "r"(addr) : "memory") ++#define ia64_itcd(addr) __asm__ __volatile__ ("itc.d %0;;" :: "r"(addr) : "memory") + + +-#define ia64_itri(trnum, addr) asm volatile ("itr.i itr[%0]=%1" \ ++#define ia64_itri(trnum, addr) __asm__ __volatile__ ("itr.i itr[%0]=%1" \ + :: "r"(trnum), "r"(addr) : "memory") + +-#define ia64_itrd(trnum, addr) asm volatile ("itr.d dtr[%0]=%1" \ ++#define ia64_itrd(trnum, addr) __asm__ __volatile__ ("itr.d dtr[%0]=%1" \ + :: "r"(trnum), "r"(addr) : "memory") + + #define ia64_tpa(addr) \ + ({ \ + __u64 ia64_pa; \ +- asm volatile ("tpa %0 = %1" : "=r"(ia64_pa) : "r"(addr) : "memory"); \ ++ __asm__ __volatile__ ("tpa %0 = %1" : "=r"(ia64_pa) : "r"(addr) : "memory"); \ + ia64_pa; \ + }) + + #define __ia64_set_dbr(index, val) \ +- asm volatile ("mov dbr[%0]=%1" :: "r"(index), "r"(val) : "memory") ++ __asm__ __volatile__ ("mov dbr[%0]=%1" :: "r"(index), "r"(val) : "memory") + + #define ia64_set_ibr(index, val) \ +- asm volatile ("mov ibr[%0]=%1" :: "r"(index), "r"(val) : "memory") ++ __asm__ __volatile__ ("mov ibr[%0]=%1" :: "r"(index), "r"(val) : "memory") + + #define ia64_set_pkr(index, val) \ +- asm volatile ("mov pkr[%0]=%1" :: "r"(index), "r"(val) : "memory") ++ __asm__ __volatile__ ("mov pkr[%0]=%1" :: "r"(index), "r"(val) : "memory") + + #define ia64_set_pmc(index, val) \ +- asm volatile ("mov pmc[%0]=%1" :: "r"(index), "r"(val) : "memory") ++ __asm__ __volatile__ ("mov pmc[%0]=%1" :: "r"(index), "r"(val) : "memory") + + #define ia64_set_pmd(index, val) \ +- asm volatile ("mov pmd[%0]=%1" :: "r"(index), "r"(val) : "memory") ++ __asm__ __volatile__ ("mov pmd[%0]=%1" :: "r"(index), "r"(val) : "memory") + + #define ia64_set_rr(index, val) \ +- asm volatile ("mov rr[%0]=%1" :: "r"(index), "r"(val) : "memory"); ++ __asm__ __volatile__ ("mov rr[%0]=%1" :: "r"(index), "r"(val) : "memory"); + + #define ia64_get_cpuid(index) \ + ({ \ + __u64 ia64_intri_res; \ +- asm volatile ("mov %0=cpuid[%r1]" : "=r"(ia64_intri_res) : "rO"(index)); \ ++ __asm__ __volatile__ ("mov %0=cpuid[%r1]" : "=r"(ia64_intri_res) : "rO"(index)); \ + ia64_intri_res; \ + }) + + #define __ia64_get_dbr(index) \ + ({ \ + __u64 ia64_intri_res; \ +- asm volatile ("mov %0=dbr[%1]" : "=r"(ia64_intri_res) : "r"(index)); \ ++ __asm__ __volatile__ ("mov %0=dbr[%1]" : "=r"(ia64_intri_res) : "r"(index)); \ + ia64_intri_res; \ + }) + + #define ia64_get_ibr(index) \ + ({ \ + __u64 ia64_intri_res; \ +- asm volatile ("mov %0=ibr[%1]" : "=r"(ia64_intri_res) : "r"(index)); \ ++ __asm__ __volatile__ ("mov %0=ibr[%1]" : "=r"(ia64_intri_res) : "r"(index)); \ + ia64_intri_res; \ + }) + + #define ia64_get_pkr(index) \ + ({ \ + __u64 ia64_intri_res; \ +- asm volatile ("mov %0=pkr[%1]" : "=r"(ia64_intri_res) : "r"(index)); \ ++ __asm__ __volatile__ ("mov %0=pkr[%1]" : "=r"(ia64_intri_res) : "r"(index)); \ + ia64_intri_res; \ + }) + + #define ia64_get_pmc(index) \ + ({ \ + __u64 ia64_intri_res; \ +- asm volatile ("mov %0=pmc[%1]" : "=r"(ia64_intri_res) : "r"(index)); \ ++ __asm__ __volatile__ ("mov %0=pmc[%1]" : "=r"(ia64_intri_res) : "r"(index)); \ + ia64_intri_res; \ + }) + +@@ -469,46 +469,46 @@ register unsigned long ia64_r13 asm ("r13") __attribute_used__; + #define ia64_get_pmd(index) \ + ({ \ + __u64 ia64_intri_res; \ +- asm volatile ("mov %0=pmd[%1]" : "=r"(ia64_intri_res) : "r"(index)); \ ++ __asm__ __volatile__ ("mov %0=pmd[%1]" : "=r"(ia64_intri_res) : "r"(index)); \ + ia64_intri_res; \ + }) + + #define ia64_get_rr(index) \ + ({ \ + __u64 ia64_intri_res; \ +- asm volatile ("mov %0=rr[%1]" : "=r"(ia64_intri_res) : "r" (index)); \ ++ __asm__ __volatile__ ("mov %0=rr[%1]" : "=r"(ia64_intri_res) : "r" (index)); \ + ia64_intri_res; \ + }) + +-#define ia64_fc(addr) asm volatile ("fc %0" :: "r"(addr) : "memory") ++#define ia64_fc(addr) __asm__ __volatile__ ("fc %0" :: "r"(addr) : "memory") + + +-#define ia64_sync_i() asm volatile (";; sync.i" ::: "memory") ++#define ia64_sync_i() __asm__ __volatile__ (";; sync.i" ::: "memory") + +-#define ia64_ssm(mask) asm volatile ("ssm %0":: "i"((mask)) : "memory") +-#define ia64_rsm(mask) asm volatile ("rsm %0":: "i"((mask)) : "memory") +-#define ia64_sum(mask) asm volatile ("sum %0":: "i"((mask)) : "memory") +-#define ia64_rum(mask) asm volatile ("rum %0":: "i"((mask)) : "memory") ++#define ia64_ssm(mask) __asm__ __volatile__ ("ssm %0":: "i"((mask)) : "memory") ++#define ia64_rsm(mask) __asm__ __volatile__ ("rsm %0":: "i"((mask)) : "memory") ++#define ia64_sum(mask) __asm__ __volatile__ ("sum %0":: "i"((mask)) : "memory") ++#define ia64_rum(mask) __asm__ __volatile__ ("rum %0":: "i"((mask)) : "memory") + +-#define ia64_ptce(addr) asm volatile ("ptc.e %0" :: "r"(addr)) ++#define ia64_ptce(addr) __asm__ __volatile__ ("ptc.e %0" :: "r"(addr)) + + #define ia64_ptcga(addr, size) \ + do { \ +- asm volatile ("ptc.ga %0,%1" :: "r"(addr), "r"(size) : "memory"); \ ++ __asm__ __volatile__ ("ptc.ga %0,%1" :: "r"(addr), "r"(size) : "memory"); \ + ia64_dv_serialize_data(); \ + } while (0) + + #define ia64_ptcl(addr, size) \ + do { \ +- asm volatile ("ptc.l %0,%1" :: "r"(addr), "r"(size) : "memory"); \ ++ __asm__ __volatile__ ("ptc.l %0,%1" :: "r"(addr), "r"(size) : "memory"); \ + ia64_dv_serialize_data(); \ + } while (0) + + #define ia64_ptri(addr, size) \ +- asm volatile ("ptr.i %0,%1" :: "r"(addr), "r"(size) : "memory") ++ __asm__ __volatile__ ("ptr.i %0,%1" :: "r"(addr), "r"(size) : "memory") + + #define ia64_ptrd(addr, size) \ +- asm volatile ("ptr.d %0,%1" :: "r"(addr), "r"(size) : "memory") ++ __asm__ __volatile__ ("ptr.d %0,%1" :: "r"(addr), "r"(size) : "memory") + + /* Values for lfhint in ia64_lfetch and ia64_lfetch_fault */ + +@@ -521,16 +521,16 @@ do { \ + ({ \ + switch (lfhint) { \ + case ia64_lfhint_none: \ +- asm volatile ("lfetch [%0]" : : "r"(y)); \ ++ __asm__ __volatile__ ("lfetch [%0]" : : "r"(y)); \ + break; \ + case ia64_lfhint_nt1: \ +- asm volatile ("lfetch.nt1 [%0]" : : "r"(y)); \ ++ __asm__ __volatile__ ("lfetch.nt1 [%0]" : : "r"(y)); \ + break; \ + case ia64_lfhint_nt2: \ +- asm volatile ("lfetch.nt2 [%0]" : : "r"(y)); \ ++ __asm__ __volatile__ ("lfetch.nt2 [%0]" : : "r"(y)); \ + break; \ + case ia64_lfhint_nta: \ +- asm volatile ("lfetch.nta [%0]" : : "r"(y)); \ ++ __asm__ __volatile__ ("lfetch.nta [%0]" : : "r"(y)); \ + break; \ + } \ + }) +@@ -539,16 +539,16 @@ do { \ + ({ \ + switch (lfhint) { \ + case ia64_lfhint_none: \ +- asm volatile ("lfetch.excl [%0]" :: "r"(y)); \ ++ __asm__ __volatile__ ("lfetch.excl [%0]" :: "r"(y)); \ + break; \ + case ia64_lfhint_nt1: \ +- asm volatile ("lfetch.excl.nt1 [%0]" :: "r"(y)); \ ++ __asm__ __volatile__ ("lfetch.excl.nt1 [%0]" :: "r"(y)); \ + break; \ + case ia64_lfhint_nt2: \ +- asm volatile ("lfetch.excl.nt2 [%0]" :: "r"(y)); \ ++ __asm__ __volatile__ ("lfetch.excl.nt2 [%0]" :: "r"(y)); \ + break; \ + case ia64_lfhint_nta: \ +- asm volatile ("lfetch.excl.nta [%0]" :: "r"(y)); \ ++ __asm__ __volatile__ ("lfetch.excl.nta [%0]" :: "r"(y)); \ + break; \ + } \ + }) +@@ -557,16 +557,16 @@ do { \ + ({ \ + switch (lfhint) { \ + case ia64_lfhint_none: \ +- asm volatile ("lfetch.fault [%0]" : : "r"(y)); \ ++ __asm__ __volatile__ ("lfetch.fault [%0]" : : "r"(y)); \ + break; \ + case ia64_lfhint_nt1: \ +- asm volatile ("lfetch.fault.nt1 [%0]" : : "r"(y)); \ ++ __asm__ __volatile__ ("lfetch.fault.nt1 [%0]" : : "r"(y)); \ + break; \ + case ia64_lfhint_nt2: \ +- asm volatile ("lfetch.fault.nt2 [%0]" : : "r"(y)); \ ++ __asm__ __volatile__ ("lfetch.fault.nt2 [%0]" : : "r"(y)); \ + break; \ + case ia64_lfhint_nta: \ +- asm volatile ("lfetch.fault.nta [%0]" : : "r"(y)); \ ++ __asm__ __volatile__ ("lfetch.fault.nta [%0]" : : "r"(y)); \ + break; \ + } \ + }) +@@ -575,23 +575,23 @@ do { \ + ({ \ + switch (lfhint) { \ + case ia64_lfhint_none: \ +- asm volatile ("lfetch.fault.excl [%0]" :: "r"(y)); \ ++ __asm__ __volatile__ ("lfetch.fault.excl [%0]" :: "r"(y)); \ + break; \ + case ia64_lfhint_nt1: \ +- asm volatile ("lfetch.fault.excl.nt1 [%0]" :: "r"(y)); \ ++ __asm__ __volatile__ ("lfetch.fault.excl.nt1 [%0]" :: "r"(y)); \ + break; \ + case ia64_lfhint_nt2: \ +- asm volatile ("lfetch.fault.excl.nt2 [%0]" :: "r"(y)); \ ++ __asm__ __volatile__ ("lfetch.fault.excl.nt2 [%0]" :: "r"(y)); \ + break; \ + case ia64_lfhint_nta: \ +- asm volatile ("lfetch.fault.excl.nta [%0]" :: "r"(y)); \ ++ __asm__ __volatile__ ("lfetch.fault.excl.nta [%0]" :: "r"(y)); \ + break; \ + } \ + }) + + #define ia64_intrin_local_irq_restore(x) \ + do { \ +- asm volatile (";; cmp.ne p6,p7=%0,r0;;" \ ++ __asm__ __volatile__ (";; cmp.ne p6,p7=%0,r0;;" \ + "(p6) ssm psr.i;" \ + "(p7) rsm psr.i;;" \ + "(p6) srlz.d" \ diff --git a/linux-ia64-hide-intrin-headers.patch b/linux-ia64-hide-intrin-headers.patch new file mode 100644 index 0000000..a968a67 --- /dev/null +++ b/linux-ia64-hide-intrin-headers.patch @@ -0,0 +1,38 @@ +diff --git a/include/asm-ia64/Kbuild b/include/asm-ia64/Kbuild +index 4a1e48b..fc03b88 100644 +--- a/include/asm-ia64/Kbuild ++++ b/include/asm-ia64/Kbuild +@@ -3,10 +3,7 @@ include include/asm-generic/Kbuild.asm + header-y += break.h + header-y += fpu.h + header-y += fpswa.h +-header-y += gcc_intrin.h + header-y += ia64regs.h +-header-y += intel_intrin.h +-header-y += intrinsics.h + header-y += perfmon_default_smpl.h + header-y += ptrace_offsets.h + header-y += rse.h +diff --git a/include/asm-ia64/byteorder.h b/include/asm-ia64/byteorder.h +index 69bd41d..783e272 100644 +--- a/include/asm-ia64/byteorder.h ++++ b/include/asm-ia64/byteorder.h +@@ -7,6 +7,9 @@ + */ + + #include ++ ++#ifdef __KERNEL__ ++ + #include + #include + +@@ -35,6 +38,8 @@ __ia64_swab16(__u16 x) + #define __arch__swab32(x) __ia64_swab32(x) + #define __arch__swab16(x) __ia64_swab16(x) + ++#endif ++ + #define __BYTEORDER_HAS_U64__ + + #include diff --git a/linux-include-types-header.patch b/linux-include-types-header.patch new file mode 100644 index 0000000..e1fb0d3 --- /dev/null +++ b/linux-include-types-header.patch @@ -0,0 +1,599 @@ +Pull in the linux/types.h header where needed (and sneak in some other +minor header additions as well). + +Signed-off-by: Mike Frysinger + +diff --git a/linux-2.6/include/linux/atm.h b/linux-2.6/include/linux/atm.h +index 6013668..5e12916 100644 +--- a/linux-2.6/include/linux/atm.h ++++ b/linux-2.6/include/linux/atm.h +@@ -16,10 +16,8 @@ + * documentation. Do not change them. + */ + +-#ifdef __KERNEL__ + #include + #include +-#endif + #include + #include + #include +diff --git a/linux-2.6/include/linux/atm_tcp.h b/linux-2.6/include/linux/atm_tcp.h +index 18787f9..e1eba63 100644 +--- a/linux-2.6/include/linux/atm_tcp.h ++++ b/linux-2.6/include/linux/atm_tcp.h +@@ -8,10 +8,8 @@ + #define LINUX_ATM_TCP_H + + #include +- +-#ifdef __KERNEL__ + #include +-#endif ++#include + #include + + +diff --git a/linux-2.6/include/linux/atmarp.h b/linux-2.6/include/linux/atmarp.h +index ee108f9..231f4bd 100644 +--- a/linux-2.6/include/linux/atmarp.h ++++ b/linux-2.6/include/linux/atmarp.h +@@ -6,9 +6,7 @@ + #ifndef _LINUX_ATMARP_H + #define _LINUX_ATMARP_H + +-#ifdef __KERNEL__ + #include +-#endif + #include + #include + +diff --git a/linux-2.6/include/linux/audit.h b/linux-2.6/include/linux/audit.h +index 0e07db6..97da74b 100644 +--- a/linux-2.6/include/linux/audit.h ++++ b/linux-2.6/include/linux/audit.h +@@ -25,6 +25,7 @@ + #define _LINUX_AUDIT_H_ + + #include ++#include + + /* The netlink messages for the audit system is divided into blocks: + * 1000 - 1099 are for commanding the audit system +diff --git a/linux-2.6/include/linux/auto_fs.h b/linux-2.6/include/linux/auto_fs.h +index c21e597..9a5c539 100644 +--- a/linux-2.6/include/linux/auto_fs.h ++++ b/linux-2.6/include/linux/auto_fs.h +@@ -16,10 +16,10 @@ + + #ifdef __KERNEL__ + #include +-#include + #include + #endif /* __KERNEL__ */ + ++#include + #include + + /* This file describes autofs v3 */ +diff --git a/linux-2.6/include/linux/auto_fs4.h b/linux-2.6/include/linux/auto_fs4.h +index 0a6bc52..ce9c79c 100644 +--- a/linux-2.6/include/linux/auto_fs4.h ++++ b/linux-2.6/include/linux/auto_fs4.h +@@ -11,6 +11,8 @@ + #ifndef _LINUX_AUTO_FS4_H + #define _LINUX_AUTO_FS4_H + ++#include ++ + /* Include common v3 definitions */ + #include + +diff --git a/linux-2.6/include/linux/bfs_fs.h b/linux-2.6/include/linux/bfs_fs.h +index 8ed6dfd..2ca3e8f 100644 +--- a/linux-2.6/include/linux/bfs_fs.h ++++ b/linux-2.6/include/linux/bfs_fs.h +@@ -6,6 +6,8 @@ + #ifndef _LINUX_BFS_FS_H + #define _LINUX_BFS_FS_H + ++#include ++ + #define BFS_BSIZE_BITS 9 + #define BFS_BSIZE (1< + #include + + /* casts are necessary for constants, because we never know how for sure +diff --git a/linux-2.6/include/linux/byteorder/swabb.h b/linux-2.6/include/linux/byteorder/swabb.h +index ae5e5f9..b582ff5 100644 +--- a/linux-2.6/include/linux/byteorder/swabb.h ++++ b/linux-2.6/include/linux/byteorder/swabb.h +@@ -13,6 +13,8 @@ + * + */ + ++#include ++ + /* + * Meaning of the names I chose (vaxlinux people feel free to correct them): + * swahw32 swap 16-bit half-words in a 32-bit word +diff --git a/linux-2.6/include/linux/cm4000_cs.h b/linux-2.6/include/linux/cm4000_cs.h +index 605ebe2..8d95b2f 100644 +--- a/linux-2.6/include/linux/cm4000_cs.h ++++ b/linux-2.6/include/linux/cm4000_cs.h +@@ -1,6 +1,9 @@ + #ifndef _CM4000_H_ + #define _CM4000_H_ + ++#include ++#include ++ + #define MAX_ATR 33 + + #define CM4000_MAX_DEV 4 +diff --git a/linux-2.6/include/linux/dirent.h b/linux-2.6/include/linux/dirent.h +index 5d6023b..d5b642d 100644 +--- a/linux-2.6/include/linux/dirent.h ++++ b/linux-2.6/include/linux/dirent.h +@@ -1,6 +1,8 @@ + #ifndef _LINUX_DIRENT_H + #define _LINUX_DIRENT_H + ++#include ++ + struct dirent { + long d_ino; + __kernel_off_t d_off; +diff --git a/linux-2.6/include/linux/dlm.h b/linux-2.6/include/linux/dlm.h +index 1b1dcb9..415c400 100644 +--- a/linux-2.6/include/linux/dlm.h ++++ b/linux-2.6/include/linux/dlm.h +@@ -19,6 +19,8 @@ + * routines and structures to use DLM lockspaces + */ + ++#include ++ + /* + * Lock Modes + */ +diff --git a/linux-2.6/include/linux/dlm_device.h b/linux-2.6/include/linux/dlm_device.h +index 2a2dd18..52544a0 100644 +--- a/linux-2.6/include/linux/dlm_device.h ++++ b/linux-2.6/include/linux/dlm_device.h +@@ -11,10 +11,16 @@ + ******************************************************************************* + ******************************************************************************/ + ++#ifndef _LINUX_DLM_DEVICE_H ++#define _LINUX_DLM_DEVICE_H ++ + /* This is the device interface for dlm, most users will use a library + * interface. + */ + ++#include ++#include ++ + #define DLM_USER_LVB_LEN 32 + + /* Version of the device interface */ +@@ -84,3 +90,4 @@ struct dlm_lock_result { + #define DLM_USER_LSFLG_AUTOFREE 1 + #define DLM_USER_LSFLG_FORCEFREE 2 + ++#endif +diff --git a/linux-2.6/include/linux/dn.h b/linux-2.6/include/linux/dn.h +index 10b6a6f..9a13dd6 100644 +--- a/linux-2.6/include/linux/dn.h ++++ b/linux-2.6/include/linux/dn.h +@@ -7,6 +7,9 @@ + + */ + ++#include ++#include ++ + /* + * DNPROTO_NSP can't be the same as SOL_SOCKET, + * so increment each by one (compared to ULTRIX) +diff --git a/linux-2.6/include/linux/efs_fs_sb.h b/linux-2.6/include/linux/efs_fs_sb.h +index ff1945e..a742b29 100644 +--- a/linux-2.6/include/linux/efs_fs_sb.h ++++ b/linux-2.6/include/linux/efs_fs_sb.h +@@ -10,6 +10,7 @@ + #define __EFS_FS_SB_H__ + + #include ++#include + + /* EFS superblock magic numbers */ + #define EFS_MAGIC 0x072959 +diff --git a/linux-2.6/include/linux/errqueue.h b/linux-2.6/include/linux/errqueue.h +index 92f8d4f..ceb1454 100644 +--- a/linux-2.6/include/linux/errqueue.h ++++ b/linux-2.6/include/linux/errqueue.h +@@ -1,6 +1,8 @@ + #ifndef _LINUX_ERRQUEUE_H + #define _LINUX_ERRQUEUE_H 1 + ++#include ++ + struct sock_extended_err + { + __u32 ee_errno; +diff --git a/linux-2.6/include/linux/ethtool.h b/linux-2.6/include/linux/ethtool.h +index c6310ae..f6fd474 100644 +--- a/linux-2.6/include/linux/ethtool.h ++++ b/linux-2.6/include/linux/ethtool.h +@@ -12,6 +12,7 @@ + #ifndef _LINUX_ETHTOOL_H + #define _LINUX_ETHTOOL_H + ++#include + + /* This should work for both 32 and 64 bit userland. */ + struct ethtool_cmd { +diff --git a/linux-2.6/include/linux/gfs2_ondisk.h b/linux-2.6/include/linux/gfs2_ondisk.h +index 8b7e4c1..e707cb5 100644 +--- a/linux-2.6/include/linux/gfs2_ondisk.h ++++ b/linux-2.6/include/linux/gfs2_ondisk.h +@@ -10,6 +10,8 @@ + #ifndef __GFS2_ONDISK_DOT_H__ + #define __GFS2_ONDISK_DOT_H__ + ++#include ++ + #define GFS2_MAGIC 0x01161970 + #define GFS2_BASIC_BLOCK 512 + #define GFS2_BASIC_BLOCK_SHIFT 9 +diff --git a/linux-2.6/include/linux/hiddev.h b/linux-2.6/include/linux/hiddev.h +index acbdae6..3b35f72 100644 +--- a/linux-2.6/include/linux/hiddev.h ++++ b/linux-2.6/include/linux/hiddev.h +@@ -29,6 +29,8 @@ + * Vojtech Pavlik, Ucitelska 1576, Prague 8, 182 00 Czech Republic + */ + ++#include ++ + /* + * The event structure itself + */ +diff --git a/linux-2.6/include/linux/i2o-dev.h b/linux-2.6/include/linux/i2o-dev.h +index c2519df..1697662 100644 +--- a/linux-2.6/include/linux/i2o-dev.h ++++ b/linux-2.6/include/linux/i2o-dev.h +@@ -24,6 +24,7 @@ + #define MAX_I2O_CONTROLLERS 32 + + #include ++#include + + /* + * I2O Control IOCTLs and structures +diff --git a/linux-2.6/include/linux/if_fc.h b/linux-2.6/include/linux/if_fc.h +index 376a34e..6ed7f1b 100644 +--- a/linux-2.6/include/linux/if_fc.h ++++ b/linux-2.6/include/linux/if_fc.h +@@ -20,6 +20,7 @@ + #ifndef _LINUX_IF_FC_H + #define _LINUX_IF_FC_H + ++#include + + #define FC_ALEN 6 /* Octets in one ethernet addr */ + #define FC_HLEN (sizeof(struct fch_hdr)+sizeof(struct fcllc)) +diff --git a/linux-2.6/include/linux/if_fddi.h b/linux-2.6/include/linux/if_fddi.h +index e0a1500..58ada1f 100644 +--- a/linux-2.6/include/linux/if_fddi.h ++++ b/linux-2.6/include/linux/if_fddi.h +@@ -24,6 +24,8 @@ + #ifndef _LINUX_IF_FDDI_H + #define _LINUX_IF_FDDI_H + ++#include ++ + /* + * Define max and min legal sizes. The frame sizes do not include + * 4 byte FCS/CRC (frame check sequence). +diff --git a/linux-2.6/include/linux/if_ppp.h b/linux-2.6/include/linux/if_ppp.h +index 768372f..ad859a2 100644 +--- a/linux-2.6/include/linux/if_ppp.h ++++ b/linux-2.6/include/linux/if_ppp.h +@@ -36,6 +36,8 @@ + #define _IF_PPP_H_ + + #include ++#include ++#include + + /* + * Packet sizes +diff --git a/linux-2.6/include/linux/if_shaper.h b/linux-2.6/include/linux/if_shaper.h +index 68c896a..6d5038e 100644 +--- a/linux-2.6/include/linux/if_shaper.h ++++ b/linux-2.6/include/linux/if_shaper.h +@@ -1,6 +1,8 @@ + #ifndef __LINUX_SHAPER_H + #define __LINUX_SHAPER_H + ++#include ++ + #ifdef __KERNEL__ + + #define SHAPER_QLEN 10 +diff --git a/linux-2.6/include/linux/if_strip.h b/linux-2.6/include/linux/if_strip.h +index fb5c5c9..6526a62 100644 +--- a/linux-2.6/include/linux/if_strip.h ++++ b/linux-2.6/include/linux/if_strip.h +@@ -18,6 +18,8 @@ + #ifndef __LINUX_STRIP_H + #define __LINUX_STRIP_H + ++#include ++ + typedef struct { + __u8 c[6]; + } MetricomAddress; +diff --git a/linux-2.6/include/linux/inet_diag.h b/linux-2.6/include/linux/inet_diag.h +index 6e8bc54..bc8c490 100644 +--- a/linux-2.6/include/linux/inet_diag.h ++++ b/linux-2.6/include/linux/inet_diag.h +@@ -1,6 +1,8 @@ + #ifndef _INET_DIAG_H_ + #define _INET_DIAG_H_ 1 + ++#include ++ + /* Just some random number */ + #define TCPDIAG_GETSOCK 18 + #define DCCPDIAG_GETSOCK 19 +diff --git a/linux-2.6/include/linux/ipx.h b/linux-2.6/include/linux/ipx.h +index eb19b4e..22d379f 100644 +--- a/linux-2.6/include/linux/ipx.h ++++ b/linux-2.6/include/linux/ipx.h +@@ -2,6 +2,7 @@ + #define _IPX_H_ + #include + #include ++#include + #define IPX_NODE_LEN 6 + #define IPX_MTU 576 + +diff --git a/linux-2.6/include/linux/irda.h b/linux-2.6/include/linux/irda.h +index 09d8f10..b41984f 100644 +--- a/linux-2.6/include/linux/irda.h ++++ b/linux-2.6/include/linux/irda.h +@@ -31,6 +31,9 @@ + * this one, or preferably to include instead. + * Jean II */ + ++#include ++#include ++ + /* Hint bit positions for first hint byte */ + #define HINT_PNP 0x01 + #define HINT_PDA 0x02 +diff --git a/linux-2.6/include/linux/lock_dlm_plock.h b/linux-2.6/include/linux/lock_dlm_plock.h +index fc34151..d3c2a54 100644 +--- a/linux-2.6/include/linux/lock_dlm_plock.h ++++ b/linux-2.6/include/linux/lock_dlm_plock.h +@@ -9,6 +9,8 @@ + #ifndef __LOCK_DLM_PLOCK_DOT_H__ + #define __LOCK_DLM_PLOCK_DOT_H__ + ++#include ++ + #define GDLM_PLOCK_MISC_NAME "lock_dlm_plock" + + #define GDLM_PLOCK_VERSION_MAJOR 1 +diff --git a/linux-2.6/include/linux/minix_fs.h b/linux-2.6/include/linux/minix_fs.h +index 916e8f7..bb33d11 100644 +--- a/linux-2.6/include/linux/minix_fs.h ++++ b/linux-2.6/include/linux/minix_fs.h +@@ -2,6 +2,7 @@ + #define _LINUX_MINIX_FS_H + + #include ++#include + + /* + * The minix filesystem constants/structures +diff --git a/linux-2.6/include/linux/netfilter/x_tables.h b/linux-2.6/include/linux/netfilter/x_tables.h +index 022edfa..175741c 100644 +--- a/linux-2.6/include/linux/netfilter/x_tables.h ++++ b/linux-2.6/include/linux/netfilter/x_tables.h +@@ -1,6 +1,8 @@ + #ifndef _X_TABLES_H + #define _X_TABLES_H + ++#include ++ + #define XT_FUNCTION_MAXNAMELEN 30 + #define XT_TABLE_MAXNAMELEN 32 + +diff --git a/linux-2.6/include/linux/netrom.h b/linux-2.6/include/linux/netrom.h +index 6939b32..af7313c 100644 +--- a/linux-2.6/include/linux/netrom.h ++++ b/linux-2.6/include/linux/netrom.h +@@ -7,6 +7,8 @@ + #ifndef NETROM_KERNEL_H + #define NETROM_KERNEL_H + ++#include ++ + #define NETROM_MTU 236 + + #define NETROM_T1 1 +diff --git a/linux-2.6/include/linux/nfs_idmap.h b/linux-2.6/include/linux/nfs_idmap.h +index 15a9f3b..91a1c24 100644 +--- a/linux-2.6/include/linux/nfs_idmap.h ++++ b/linux-2.6/include/linux/nfs_idmap.h +@@ -37,6 +37,8 @@ + #ifndef NFS_IDMAP_H + #define NFS_IDMAP_H + ++#include ++ + /* XXX from bits/utmp.h */ + #define IDMAP_NAMESZ 128 + +diff --git a/linux-2.6/include/linux/nubus.h b/linux-2.6/include/linux/nubus.h +index 870e66a..72c8774 100644 +--- a/linux-2.6/include/linux/nubus.h ++++ b/linux-2.6/include/linux/nubus.h +@@ -12,6 +12,8 @@ + #ifndef LINUX_NUBUS_H + #define LINUX_NUBUS_H + ++#include ++ + #ifdef __KERNEL__ + #include + #endif +diff --git a/linux-2.6/include/linux/pkt_cls.h b/linux-2.6/include/linux/pkt_cls.h +index c3f01b3..762f048 100644 +--- a/linux-2.6/include/linux/pkt_cls.h ++++ b/linux-2.6/include/linux/pkt_cls.h +@@ -2,6 +2,7 @@ + #define __LINUX_PKT_CLS_H + + #include ++#include + + /* I think i could have done better macros ; for now this is stolen from + * some arch/mips code - jhs +diff --git a/linux-2.6/include/linux/pkt_sched.h b/linux-2.6/include/linux/pkt_sched.h +index d10f353..2169d79 100644 +--- a/linux-2.6/include/linux/pkt_sched.h ++++ b/linux-2.6/include/linux/pkt_sched.h +@@ -1,6 +1,8 @@ + #ifndef __LINUX_PKT_SCHED_H + #define __LINUX_PKT_SCHED_H + ++#include ++ + /* Logical priority bands not depending on specific packet scheduler. + Every scheduler will map them to real traffic classes, if it has + no more precise mechanism to classify packets. +diff --git a/linux-2.6/include/linux/ppp_defs.h b/linux-2.6/include/linux/ppp_defs.h +index c6b13ff..a71510a 100644 +--- a/linux-2.6/include/linux/ppp_defs.h ++++ b/linux-2.6/include/linux/ppp_defs.h +@@ -42,6 +42,8 @@ + #ifndef _PPP_DEFS_H_ + #define _PPP_DEFS_H_ + ++#include ++ + /* + * The basic PPP frame. + */ +diff --git a/linux-2.6/include/linux/random.h b/linux-2.6/include/linux/random.h +index 01ad710..57195d0 100644 +--- a/linux-2.6/include/linux/random.h ++++ b/linux-2.6/include/linux/random.h +@@ -8,6 +8,7 @@ + #define _LINUX_RANDOM_H + + #include ++#include + + /* ioctl()'s for the random number generator */ + +diff --git a/linux-2.6/include/linux/romfs_fs.h b/linux-2.6/include/linux/romfs_fs.h +index e20bbf9..1404f8d 100644 +--- a/linux-2.6/include/linux/romfs_fs.h ++++ b/linux-2.6/include/linux/romfs_fs.h +@@ -1,6 +1,8 @@ + #ifndef __LINUX_ROMFS_FS_H + #define __LINUX_ROMFS_FS_H + ++#include ++ + /* The basic structures of the romfs filesystem */ + + #define ROMBSIZE BLOCK_SIZE +diff --git a/linux-2.6/include/linux/selinux_netlink.h b/linux-2.6/include/linux/selinux_netlink.h +index bbf489d..faf9675 100644 +--- a/linux-2.6/include/linux/selinux_netlink.h ++++ b/linux-2.6/include/linux/selinux_netlink.h +@@ -12,6 +12,8 @@ + #ifndef _LINUX_SELINUX_NETLINK_H + #define _LINUX_SELINUX_NETLINK_H + ++#include ++ + /* Message types. */ + #define SELNL_MSG_BASE 0x10 + enum { +diff --git a/linux-2.6/include/linux/socket.h b/linux-2.6/include/linux/socket.h +index 92cd38e..545c041 100644 +diff --git a/linux-2.6/include/linux/synclink.h b/linux-2.6/include/linux/synclink.h +index c8b0426..ba59b6d 100644 +--- a/linux-2.6/include/linux/synclink.h ++++ b/linux-2.6/include/linux/synclink.h +@@ -11,6 +11,9 @@ + + #ifndef _SYNCLINK_H_ + #define _SYNCLINK_H_ ++ ++#include ++ + #define SYNCLINK_H_VERSION 3.6 + + #define BOOLEAN int +diff --git a/linux-2.6/include/linux/video_decoder.h b/linux-2.6/include/linux/video_decoder.h +index 121e26d..e26c0c8 100644 +--- a/linux-2.6/include/linux/video_decoder.h ++++ b/linux-2.6/include/linux/video_decoder.h +@@ -1,6 +1,8 @@ + #ifndef _LINUX_VIDEO_DECODER_H + #define _LINUX_VIDEO_DECODER_H + ++#include ++ + #define HAVE_VIDEO_DECODER 1 + + struct video_decoder_capability { /* this name is too long */ +diff --git a/linux-2.6/include/linux/video_encoder.h b/linux-2.6/include/linux/video_encoder.h +index 4b0e690..b7b6423 100644 +--- a/linux-2.6/include/linux/video_encoder.h ++++ b/linux-2.6/include/linux/video_encoder.h +@@ -1,6 +1,8 @@ + #ifndef _LINUX_VIDEO_ENCODER_H + #define _LINUX_VIDEO_ENCODER_H + ++#include ++ + struct video_encoder_capability { /* this name is too long */ + __u32 flags; + #define VIDEO_ENCODER_PAL 1 /* can encode PAL signal */ +diff --git a/linux-2.6/include/linux/videodev2.h b/linux-2.6/include/linux/videodev2.h +diff --git a/linux-2.6/include/linux/wireless.h b/linux-2.6/include/linux/wireless.h +index 7c269f4..9ba6355 100644 +--- a/linux-2.6/include/linux/wireless.h ++++ b/linux-2.6/include/linux/wireless.h +@@ -72,11 +72,9 @@ + /* This header is used in user-space, therefore need to be sanitised + * for that purpose. Those includes are usually not compatible with glibc. + * To know which includes to use in user-space, check iwlib.h. */ +-#ifdef __KERNEL__ + #include /* for "caddr_t" et al */ + #include /* for "struct sockaddr" et al */ + #include /* for IFNAMSIZ and co... */ +-#endif /* __KERNEL__ */ + + /***************************** VERSION *****************************/ + /* diff --git a/linux-isdn-divertif.patch b/linux-isdn-divertif.patch new file mode 100644 index 0000000..0152070 --- /dev/null +++ b/linux-isdn-divertif.patch @@ -0,0 +1,40 @@ +diff --git a/include/linux/Kbuild b/include/linux/Kbuild +index 4ff0f57..ab2aaa2 100644 +--- a/include/linux/Kbuild ++++ b/include/linux/Kbuild +@@ -91,7 +91,6 @@ header-y += ip_mp_alg.h + header-y += ipsec.h + header-y += ipx.h + header-y += irda.h +-header-y += isdn_divertif.h + header-y += iso_fs.h + header-y += ixjuser.h + header-y += jffs2.h +@@ -238,6 +237,7 @@ unifdef-y += ipv6.h + unifdef-y += ipv6_route.h + unifdef-y += isdn.h + unifdef-y += isdnif.h ++unifdef-y += isdn_divertif.h + unifdef-y += isdn_ppp.h + unifdef-y += isicom.h + unifdef-y += jbd.h +diff --git a/include/linux/isdn_divertif.h b/include/linux/isdn_divertif.h +index 0e7e44c..0df24b2 100644 +--- a/include/linux/isdn_divertif.h ++++ b/include/linux/isdn_divertif.h +@@ -24,6 +24,10 @@ + #define DIVERT_REL_ERR 0x04 /* module not registered */ + #define DIVERT_REG_NAME isdn_register_divert + ++#ifdef __KERNEL__ ++#include ++#include ++ + /***************************************************************/ + /* structure exchanging data between isdn hl and divert module */ + /***************************************************************/ +@@ -40,3 +43,4 @@ typedef struct + /* function register */ + /*********************/ + extern int DIVERT_REG_NAME(isdn_divert_if *); ++#endif diff --git a/linux-kallsyms-no-memmove.patch b/linux-kallsyms-no-memmove.patch new file mode 100644 index 0000000..8b5c3af --- /dev/null +++ b/linux-kallsyms-no-memmove.patch @@ -0,0 +1,51 @@ +Index: scripts/kallsyms.c +=================================================================== +--- scripts/kallsyms.c (revision 3266) ++++ scripts/kallsyms.c (working copy) +@@ -26,8 +26,6 @@ + * + */ + +-#define _GNU_SOURCE +- + #include + #include + #include +@@ -56,6 +54,37 @@ int token_profit[0x10000]; + unsigned char best_table[256][2]; + unsigned char best_table_len[256]; + ++/* memmem(), while useful, is not in POSIX, so create a local version ++ * so we can compile on non-GNU systems (Darwin, *BSD, etc...) ++ */ ++void *memmem(const void *haystack, size_t haystack_len, ++ const void *needle, size_t needle_len) ++{ ++ const char *begin; ++ const char *const last_possible = ++ (const char *)haystack + haystack_len - needle_len; ++ ++ /* The first occurrence of the empty string is deemed to occur at ++ * the beginning of the string. ++ */ ++ if (needle_len == 0) ++ return (void *)haystack; ++ ++ /* Sanity check, otherwise the loop might search through the whole ++ * memory. ++ */ ++ if (haystack_len < needle_len) ++ return NULL; ++ ++ for (begin = (const char *)haystack; begin <= last_possible; ++begin) ++ if (begin[0] == ((const char *)needle)[0] && ++ !memcmp((const void *)&begin[1], ++ (const void *)((const char *)needle + 1), ++ needle_len - 1)) ++ return (void *)begin; ++ ++ return NULL; ++} + + static void usage(void) + { diff --git a/linux-kconfig-libintl.patch b/linux-kconfig-libintl.patch new file mode 100644 index 0000000..a205c9d --- /dev/null +++ b/linux-kconfig-libintl.patch @@ -0,0 +1,21 @@ +diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile +index fb2bb30..a7304ec 100644 +--- a/scripts/kconfig/Makefile ++++ b/scripts/kconfig/Makefile +@@ -151,6 +151,16 @@ ifeq ($(KBUILD_HAVE_NLS),no) + HOSTCFLAGS += -DKBUILD_NO_NLS + endif + ++# Needed for systems with separate libintl ++KBUILD_NEED_LIBINTL := $(shell \ ++ if echo 'int main() { return gettext(); }' \ ++ | $(HOSTCC) $(HOSTCFLAGS) -x c - -o /dev/null > /dev/null 2>&1 ; \ ++ then echo yes ; \ ++ else echo no ; fi) ++ifeq ($(KBUILD_NEED_LIBINTL),yes) ++HOSTLOADLIBES += -lintl ++endif ++ + # generated files seem to need this to find local include files + HOSTCFLAGS_lex.zconf.o := -I$(src) + HOSTCFLAGS_zconf.tab.o := -I$(src) diff --git a/linux-kconfig-project-customize.patch b/linux-kconfig-project-customize.patch new file mode 100644 index 0000000..94e23f2 --- /dev/null +++ b/linux-kconfig-project-customize.patch @@ -0,0 +1,160 @@ +diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c +index 1199baf..a5f5102 100644 +--- a/scripts/kconfig/conf.c ++++ b/scripts/kconfig/conf.c +@@ -557,8 +557,8 @@ int main(int ac, char **av) + case ask_silent: + if (stat(".config", &tmpstat)) { + printf(_("***\n" +- "*** You have not yet configured your kernel!\n" +- "*** (missing kernel .config file)\n" ++ "*** You have not yet configured your " PROJECT_INFORMAL "!\n" ++ "*** (missing " PROJECT_INFORMAL " .config file)\n" + "***\n" + "*** Please run some configurator (e.g. \"make oldconfig\" or\n" + "*** \"make menuconfig\" or \"make xconfig\").\n" +@@ -604,7 +604,7 @@ int main(int ac, char **av) + } else if (conf_get_changed()) { + name = getenv("KCONFIG_NOSILENTUPDATE"); + if (name && *name) { +- fprintf(stderr, _("\n*** Kernel configuration requires explicit update.\n\n")); ++ fprintf(stderr, _("\n*** " PROJECT " configuration requires explicit update.\n\n")); + return 1; + } + } else +@@ -615,12 +615,12 @@ int main(int ac, char **av) + check_conf(&rootmenu); + } while (conf_cnt); + if (conf_write(NULL)) { +- fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n")); ++ fprintf(stderr, _("\n*** Error during writing of the " PROJECT_INFORMAL " configuration.\n\n")); + return 1; + } + skip_check: + if (input_mode == ask_silent && conf_write_autoconf()) { +- fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n")); ++ fprintf(stderr, _("\n*** Error during writing of the " PROJECT_INFORMAL " configuration.\n\n")); + return 1; + } + +diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c +index 664fe29..06366ed 100644 +--- a/scripts/kconfig/confdata.c ++++ b/scripts/kconfig/confdata.c +@@ -416,7 +416,7 @@ int conf_write(const char *name) + if (!out) + return 1; + +- sym = sym_lookup("KERNELVERSION", 0); ++ sym = sym_lookup(VERSION_SYMBOL, 0); + sym_calc_value(sym); + time(&now); + env = getenv("KCONFIG_NOTIMESTAMP"); +@@ -425,7 +425,7 @@ int conf_write(const char *name) + + fprintf(out, _("#\n" + "# Automatically generated make config: don't edit\n" +- "# Linux kernel version: %s\n" ++ "# " PROJECT " version: %s\n" + "%s%s" + "#\n"), + sym_get_string_value(sym), +@@ -672,21 +672,21 @@ int conf_write_autoconf(void) + return 1; + } + +- sym = sym_lookup("KERNELVERSION", 0); ++ sym = sym_lookup(VERSION_SYMBOL, 0); + sym_calc_value(sym); + time(&now); + fprintf(out, "#\n" + "# Automatically generated make config: don't edit\n" +- "# Linux kernel version: %s\n" ++ "# " PROJECT " version: %s\n" + "# %s" + "#\n", + sym_get_string_value(sym), ctime(&now)); + fprintf(out_h, "/*\n" + " * Automatically generated C config: don't edit\n" +- " * Linux kernel version: %s\n" ++ " * " PROJECT " version: %s\n" + " * %s" + " */\n" +- "#define AUTOCONF_INCLUDED\n", ++ "#define " AUTOCONF_DEFINE "\n", + sym_get_string_value(sym), ctime(&now)); + + for_all_symbols(i, sym) { +diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c +index 61d8166..ba62d64 100644 +--- a/scripts/kconfig/gconf.c ++++ b/scripts/kconfig/gconf.c +@@ -271,8 +271,8 @@ void init_main_window(const gchar * glade_file) + /*"style", PANGO_STYLE_OBLIQUE, */ + NULL); + +- sprintf(title, _("Linux Kernel v%s Configuration"), +- getenv("KERNELVERSION")); ++ sprintf(title, _(PROJECT " v%s Configuration"), ++ getenv(VERSION_SYMBOL)); + gtk_window_set_title(GTK_WINDOW(main_wnd), title); + + gtk_widget_show(main_wnd); +diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h +index 8a07ee4..e694cda 100644 +--- a/scripts/kconfig/lkc.h ++++ b/scripts/kconfig/lkc.h +@@ -6,6 +6,8 @@ + #ifndef LKC_H + #define LKC_H + ++#include "lkc_local.h" ++ + #include "expr.h" + + #ifndef KBUILD_NO_NLS +diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c +index d0e4fa5..344f777 100644 +--- a/scripts/kconfig/mconf.c ++++ b/scripts/kconfig/mconf.c +@@ -400,10 +400,10 @@ static void set_config_filename(const char *config_filename) + int size; + struct symbol *sym; + +- sym = sym_lookup("KERNELVERSION", 0); ++ sym = sym_lookup(VERSION_SYMBOL, 0); + sym_calc_value(sym); + size = snprintf(menu_backtitle, sizeof(menu_backtitle), +- _("%s - Linux Kernel v%s Configuration"), ++ _("%s - " PROJECT " v%s Configuration"), + config_filename, sym_get_string_value(sym)); + if (size >= sizeof(menu_backtitle)) + menu_backtitle[sizeof(menu_backtitle)-1] = '\0'; +@@ -931,8 +931,8 @@ int main(int ac, char **av) + } + case -1: + printf(_("\n\n" +- "*** End of Linux kernel configuration.\n" +- "*** Execute 'make' to build the kernel or try 'make help'." ++ "*** End of " PROJECT " configuration.\n" ++ "*** Execute 'make' to build the " PROJECT_INFORMAL " or try 'make help'." + "\n\n")); + break; + default: +diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c +index c35dcc5..004b7df 100644 +--- a/scripts/kconfig/symbol.c ++++ b/scripts/kconfig/symbol.c +@@ -61,10 +61,10 @@ void sym_init(void) + if (p) + sym_add_default(sym, p); + +- sym = sym_lookup("KERNELVERSION", 0); ++ sym = sym_lookup(VERSION_SYMBOL, 0); + sym->type = S_STRING; + sym->flags |= SYMBOL_AUTO; +- p = getenv("KERNELVERSION"); ++ p = getenv(VERSION_SYMBOL); + if (p) + sym_add_default(sym, p); + diff --git a/linux-log_buf_read.patch b/linux-log_buf_read.patch new file mode 100644 index 0000000..c47c036 --- /dev/null +++ b/linux-log_buf_read.patch @@ -0,0 +1,91 @@ +Add two new functions for reading the kernel log buffer. Their intention +is to be used by recovery/dump/debug code so the kernel log can be easily +retrieved/parsed in a crash scenario, but they are generic enough for other +people to dream up other fun uses. + +Signed-off-by: Mike Frysinger +--- +diff --git a/include/linux/kernel.h b/include/linux/kernel.h +index 4300bb4..8d5b6c7 100644 +--- a/include/linux/kernel.h ++++ b/include/linux/kernel.h +@@ -156,6 +156,9 @@ asmlinkage int vprintk(const char *fmt, va_list args) + __attribute__ ((format (printf, 1, 0))); + asmlinkage int printk(const char * fmt, ...) + __attribute__ ((format (printf, 1, 2))) __cold; ++extern int log_buf_get_len(void); ++extern int log_buf_read(int idx); ++extern int log_buf_copy(char *dest, int idx, int len); + #else + static inline int vprintk(const char *s, va_list args) + __attribute__ ((format (printf, 1, 0))); +@@ -163,6 +166,9 @@ static inline int vprintk(const char *s, va_list args) { return 0; } + static inline int printk(const char *s, ...) + __attribute__ ((format (printf, 1, 2))); + static inline int __cold printk(const char *s, ...) { return 0; } ++static inline int log_buf_get_len(void) { return 0; } ++static inline int log_buf_read(int idx); { return 0; } ++static inline int log_buf_copy(char *dest, int idx, int len) { return 0; } + #endif + + unsigned long int_sqrt(unsigned long); +diff --git a/kernel/printk.c b/kernel/printk.c +index 051d27e..35b231a 100644 +--- a/kernel/printk.c ++++ b/kernel/printk.c +@@ -163,6 +163,55 @@ out: + __setup("log_buf_len=", log_buf_len_setup); + + /* ++ * Return the number of unread characters in the log buffer. ++ */ ++int log_buf_get_len(void) ++{ ++ return log_end - log_start; ++} ++ ++/* ++ * Copy a range of characters from the log buffer. ++ */ ++int log_buf_copy(char *dest, int idx, int len) ++{ ++ int ret, max; ++ ++ if (!oops_in_progress) ++ spin_lock_irq(&logbuf_lock); ++ ++ max = log_buf_get_len(); ++ if (idx < 0 || idx >= max) ++ ret = -1; ++ else { ++ if (len > max) ++ len = max; ++ ret = len; ++ while (len-- > 0) { ++ *dest = LOG_BUF(idx++); ++ ++dest; ++ } ++ } ++ ++ if (!oops_in_progress) ++ spin_unlock_irq(&logbuf_lock); ++ ++ return ret; ++} ++ ++/* ++ * Extract a single character from the log buffer. ++ */ ++int log_buf_read(int idx) ++{ ++ char ret; ++ if (log_buf_copy(&ret, idx, 1) == 1) ++ return ret; ++ else ++ return -1; ++} ++ ++/* + * Commands to do_syslog: + * + * 0 -- Close the log. Currently a NOP. diff --git a/linux-lxdialog-curses-search.patch b/linux-lxdialog-curses-search.patch new file mode 100644 index 0000000..ee632c5 --- /dev/null +++ b/linux-lxdialog-curses-search.patch @@ -0,0 +1,35 @@ +diff --git a/scripts/kconfig/lxdialog/check-lxdialog.sh b/scripts/kconfig/lxdialog/check-lxdialog.sh +index 120d624..cdca738 100644 +--- a/scripts/kconfig/lxdialog/check-lxdialog.sh ++++ b/scripts/kconfig/lxdialog/check-lxdialog.sh +@@ -4,21 +4,15 @@ + # What library to link + ldflags() + { +- $cc -print-file-name=libncursesw.so | grep -q / +- if [ $? -eq 0 ]; then +- echo '-lncursesw' +- exit +- fi +- $cc -print-file-name=libncurses.so | grep -q / +- if [ $? -eq 0 ]; then +- echo '-lncurses' +- exit +- fi +- $cc -print-file-name=libcurses.so | grep -q / +- if [ $? -eq 0 ]; then +- echo '-lcurses' +- exit +- fi ++ for ext in so a dylib ; do ++ for lib in ncursesw ncurses curses ; do ++ $cc -print-file-name=lib${lib}.${ext} | grep -q / ++ if [ $? -eq 0 ]; then ++ echo "-l${lib}" ++ exit ++ fi ++ done ++ done + exit 1 + } + diff --git a/linux-lxdialog-dont-use-index-func.patch b/linux-lxdialog-dont-use-index-func.patch new file mode 100644 index 0000000..84718c8 --- /dev/null +++ b/linux-lxdialog-dont-use-index-func.patch @@ -0,0 +1,24 @@ +The index() function is obsolete, use strchr() instead. + +Signed-off-by: Mike Frysinger + +--- a/scripts/kconfig/lxdialog/util.c ++++ b/scripts/kconfig/lxdialog/util.c +@@ -336,7 +336,7 @@ + newl = 1; + word = tempstr; + while (word && *word) { +- sp = index(word, ' '); ++ sp = strchr(word, ' '); + if (sp) + *sp++ = 0; + +@@ -348,7 +348,7 @@ + if (wlen > room || + (newl && wlen < 4 && sp + && wlen + 1 + strlen(sp) > room +- && (!(sp2 = index(sp, ' ')) ++ && (!(sp2 = strchr(sp, ' ')) + || wlen + 1 + (sp2 - sp) > room))) { + cur_y++; + cur_x = x; diff --git a/linux-lxdialog-posix-eq.patch b/linux-lxdialog-posix-eq.patch new file mode 100644 index 0000000..78fcf10 --- /dev/null +++ b/linux-lxdialog-posix-eq.patch @@ -0,0 +1,13 @@ +diff --git a/scripts/kconfig/lxdialog/check-lxdialog.sh b/scripts/kconfig/lxdialog/check-lxdialog.sh +index cdca738..9681476 100644 +--- a/scripts/kconfig/lxdialog/check-lxdialog.sh ++++ b/scripts/kconfig/lxdialog/check-lxdialog.sh +@@ -51,7 +51,7 @@ usage() { + printf "Usage: $0 [-check compiler options|-header|-library]\n" + } + +-if [ $# == 0 ]; then ++if [ $# -eq 0 ]; then + usage + exit 1 + fi diff --git a/linux-m68k-remove-page-from-user-header.patch b/linux-m68k-remove-page-from-user-header.patch new file mode 100644 index 0000000..aeb79d8 --- /dev/null +++ b/linux-m68k-remove-page-from-user-header.patch @@ -0,0 +1,20 @@ +M: geert@linux-m68k.org +M: zippel@linux-m68k.org +L: linux-m68k@lists.linux-m68k.org + +We don't actually use anything from asm-m68k/page.h in asm-m68k/user.h, so +don't bother including it. + +Signed-off-by: Mike Frysinger + +--- a/include/asm-m68k/user.h ++++ b/include/asm-m68k/user.h +@@ -1,8 +1,6 @@ + #ifndef _M68K_USER_H + #define _M68K_USER_H + +-#include +- + /* 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 diff --git a/linux-move-cond-syscall-to-kernel.patch b/linux-move-cond-syscall-to-kernel.patch new file mode 100644 index 0000000..6f19fe4 --- /dev/null +++ b/linux-move-cond-syscall-to-kernel.patch @@ -0,0 +1,38 @@ +diff --git a/include/asm-blackfin/unistd.h b/include/asm-blackfin/unistd.h +index 4df8790..0df9f2d 100644 +--- a/include/asm-blackfin/unistd.h ++++ b/include/asm-blackfin/unistd.h +@@ -369,7 +369,6 @@ + #define __ARCH_WANT_SYS_NICE + #define __ARCH_WANT_SYS_RT_SIGACTION + #define __ARCH_WANT_SYS_RT_SIGSUSPEND +-#endif + + /* + * "Conditional" syscalls +@@ -379,4 +378,6 @@ + */ + #define cond_syscall(x) asm(".weak\t_" #x "\n\t.set\t_" #x ",_sys_ni_syscall"); + ++#endif /* __KERNEL__ */ ++ + #endif /* __ASM_BFIN_UNISTD_H */ +diff --git a/include/asm-x86_64/unistd.h b/include/asm-x86_64/unistd.h +index ae1ed05..f5d627c 100644 +--- a/include/asm-x86_64/unistd.h ++++ b/include/asm-x86_64/unistd.h +@@ -674,6 +674,7 @@ asmlinkage long sys_rt_sigaction(int sig, + #endif /* __KERNEL__ */ + #endif /* __NO_STUBS */ + ++#ifdef __KERNEL__ + /* + * "Conditional" syscalls + * +@@ -681,5 +682,6 @@ asmlinkage long sys_rt_sigaction(int sig, + * 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_X86_64_UNISTD_H_ */ diff --git a/linux-netfilter-dont-use-type-names.patch b/linux-netfilter-dont-use-type-names.patch new file mode 100644 index 0000000..9dc2149 --- /dev/null +++ b/linux-netfilter-dont-use-type-names.patch @@ -0,0 +1,22 @@ +Use diff variable names than the standard type so we can run automated script +checks on the code to easily pull out export violations. + +Signed-off-by: Mike Frysinger + +--- a/include/linux/netfilter/x_tables.h ++++ b/include/linux/netfilter/x_tables.h +@@ -82,10 +84,10 @@ struct xt_get_revision + */ + struct _xt_align + { +- u_int8_t u8; +- u_int16_t u16; +- u_int32_t u32; +- u_int64_t u64; ++ u_int8_t align_u8; ++ u_int16_t align_u16; ++ u_int32_t align_u32; ++ u_int64_t align_u64; + }; + + #define XT_ALIGN(s) (((s) + (__alignof__(struct _xt_align)-1)) \ diff --git a/linux-powerpc-use-__attribute__.patch b/linux-powerpc-use-__attribute__.patch new file mode 100644 index 0000000..475c3b1 --- /dev/null +++ b/linux-powerpc-use-__attribute__.patch @@ -0,0 +1,29 @@ +diff --git a/include/asm-powerpc/processor.h b/include/asm-powerpc/processor.h +index d947b16..2ce6ea6 100644 +--- a/include/asm-powerpc/processor.h ++++ b/include/asm-powerpc/processor.h +@@ -153,9 +153,9 @@ struct thread_struct { + unsigned long dabr; /* Data address breakpoint register */ + #ifdef CONFIG_ALTIVEC + /* Complete AltiVec register set */ +- vector128 vr[32] __attribute((aligned(16))); ++ vector128 vr[32] __attribute__((aligned(16))); + /* AltiVec status */ +- vector128 vscr __attribute((aligned(16))); ++ vector128 vscr __attribute__((aligned(16))); + unsigned long vrsave; + int used_vr; /* set if process has used altivec */ + #endif /* CONFIG_ALTIVEC */ +diff --git a/include/asm-powerpc/types.h b/include/asm-powerpc/types.h +index 3b36375..a584341 100644 +--- a/include/asm-powerpc/types.h ++++ b/include/asm-powerpc/types.h +@@ -48,7 +48,7 @@ typedef unsigned long long __u64; + + typedef struct { + __u32 u[4]; +-} __attribute((aligned(16))) __vector128; ++} __attribute__((aligned(16))) __vector128; + + #endif /* __ASSEMBLY__ */ + diff --git a/linux-ppc-defconfig.patch b/linux-ppc-defconfig.patch new file mode 100644 index 0000000..dd9d034 --- /dev/null +++ b/linux-ppc-defconfig.patch @@ -0,0 +1,16 @@ +--- arch/powerpc/Makefile.orig 2006-08-05 14:22:50.000000000 -0400 ++++ arch/powerpc/Makefile 2006-08-05 14:22:35.000000000 -0400 +@@ -34,6 +34,13 @@ + export CROSS32CC CROSS32AS CROSS32LD CROSS32OBJCOPY + + KBUILD_DEFCONFIG := $(shell uname -m)_defconfig ++ifeq ($(wildcard $(srctree)/arch/powerpc/configs/$(KBUILD_DEFCONFIG)),) ++ifeq ($(CONFIG_PPC64),y) ++KBUILD_DEFCONFIG := ppc64_defconfig ++else ++KBUILD_DEFCONFIG := pmac32_defconfig ++endif ++endif + + ifeq ($(CONFIG_PPC64),y) + OLDARCH := ppc64 diff --git a/linux-quota-header-spinlock.patch b/linux-quota-header-spinlock.patch new file mode 100644 index 0000000..0fb6f00 --- /dev/null +++ b/linux-quota-header-spinlock.patch @@ -0,0 +1,22 @@ +diff --git a/include/linux/quota.h b/include/linux/quota.h +index 77db80a..6243982 100644 +--- a/include/linux/quota.h ++++ b/include/linux/quota.h +@@ -44,8 +44,6 @@ + typedef __kernel_uid32_t qid_t; /* Type in which we store ids in memory */ + typedef __u64 qsize_t; /* Type in which we store sizes */ + +-extern spinlock_t dq_data_lock; +- + /* Size of blocks in which are counted size limits */ + #define QUOTABLOCK_BITS 10 + #define QUOTABLOCK_SIZE (1 << QUOTABLOCK_BITS) +@@ -139,6 +137,8 @@ struct if_dqinfo { + #include + #include + ++extern spinlock_t dq_data_lock; ++ + /* Maximal numbers of writes for quota operation (insert/delete/update) + * (over VFS all formats) */ + #define DQUOT_INIT_ALLOC max(V1_INIT_ALLOC, V2_INIT_ALLOC) diff --git a/linux-rename-val-in-get_unaligned.patch b/linux-rename-val-in-get_unaligned.patch new file mode 100644 index 0000000..b581577 --- /dev/null +++ b/linux-rename-val-in-get_unaligned.patch @@ -0,0 +1,35 @@ +diff --git a/include/asm-generic/unaligned.h b/include/asm-generic/unaligned.h +index 09ec447..50189d1 100644 +--- a/include/asm-generic/unaligned.h ++++ b/include/asm-generic/unaligned.h +@@ -78,24 +78,24 @@ static inline void __ustw(__u16 val, __u16 *addr) + + #define __get_unaligned(ptr, size) ({ \ + const void *__gu_p = ptr; \ +- __u64 val; \ ++ __u64 __val; \ + switch (size) { \ + case 1: \ +- val = *(const __u8 *)__gu_p; \ ++ __val = *(const __u8 *)__gu_p; \ + break; \ + case 2: \ +- val = __uldw(__gu_p); \ ++ __val = __uldw(__gu_p); \ + break; \ + case 4: \ +- val = __uldl(__gu_p); \ ++ __val = __uldl(__gu_p); \ + break; \ + case 8: \ +- val = __uldq(__gu_p); \ ++ __val = __uldq(__gu_p); \ + break; \ + default: \ + bad_unaligned_access_length(); \ + }; \ +- (__typeof__(*(ptr)))val; \ ++ (__typeof__(*(ptr)))__val; \ + }) + + #define __put_unaligned(val, ptr, size) \ diff --git a/linux-rtc-doc-update.patch b/linux-rtc-doc-update.patch new file mode 100644 index 0000000..980c615 --- /dev/null +++ b/linux-rtc-doc-update.patch @@ -0,0 +1,146 @@ +Fix typo when describing RTC_WKALM. Add some helpful pointers to people +developing their own RTC driver. Change a bunch of the error messages in the +test program to be a bit more helpful. + +Signed-off-by: Mike Frysinger + +diff --git a/Documentation/rtc.txt b/Documentation/rtc.txt +index 7cf1ec5..1ef6bb8 100644 +--- a/Documentation/rtc.txt ++++ b/Documentation/rtc.txt +@@ -149,7 +149,7 @@ RTC class framework, but can't be supported by the older driver. + is connected to an IRQ line, it can often issue an alarm IRQ up to + 24 hours in the future. + +- * RTC_WKALM_SET, RTC_WKALM_READ ... RTCs that can issue alarms beyond ++ * RTC_WKALM_SET, RTC_WKALM_RD ... RTCs that can issue alarms beyond + the next 24 hours use a slightly more powerful API, which supports + setting the longer alarm time and enabling its IRQ using a single + request (using the same model as EFI firmware). +@@ -167,6 +167,28 @@ Linux out of a low power sleep state (or hibernation) back to a fully + operational state. For example, a system could enter a deep power saving + state until it's time to execute some scheduled tasks. + ++Note that many of these ioctls need not actually be implemented by your ++driver. The common rtc-dev interface handles many of these nicely if your ++driver returns ENOIOCTLCMD. Some common examples: ++ ++ * RTC_RD_TIME, RTC_SET_TIME: the read_time/set_time functions will be ++ called with appropriate values. ++ ++ * RTC_ALM_SET, RTC_ALM_READ, RTC_WKALM_SET, RTC_WKALM_RD: the ++ set_alarm/read_alarm functions will be called. To differentiate ++ between the ALM and WKALM, check the larger fields of the rtc_wkalrm ++ struct (like tm_year). These will be set to -1 when using ALM and ++ will be set to proper values when using WKALM. ++ ++ * RTC_IRQP_SET, RTC_IRQP_READ: the irq_set_freq function will be called ++ to set the frequency while the framework will handle the read for you ++ since the frequency is stored in the irq_freq member of the rtc_device ++ structure. Also make sure you set the max_user_freq member in your ++ initialization routines so the framework can sanity check the user ++ input for you. ++ ++If all else fails, check out the rtc-test.c driver! ++ + + -------------------- 8< ---------------- 8< ----------------------------- + +@@ -237,7 +259,7 @@ int main(int argc, char **argv) + "\n...Update IRQs not supported.\n"); + goto test_READ; + } +- perror("ioctl"); ++ perror("RTC_UIE_ON ioctl"); + exit(errno); + } + +@@ -284,7 +306,7 @@ int main(int argc, char **argv) + /* Turn off update interrupts */ + retval = ioctl(fd, RTC_UIE_OFF, 0); + if (retval == -1) { +- perror("ioctl"); ++ perror("RTC_UIE_OFF ioctl"); + exit(errno); + } + +@@ -292,7 +314,7 @@ test_READ: + /* Read the RTC time/date */ + retval = ioctl(fd, RTC_RD_TIME, &rtc_tm); + if (retval == -1) { +- perror("ioctl"); ++ perror("RTC_RD_TIME ioctl"); + exit(errno); + } + +@@ -320,14 +342,14 @@ test_READ: + "\n...Alarm IRQs not supported.\n"); + goto test_PIE; + } +- perror("ioctl"); ++ perror("RTC_ALM_SET ioctl"); + exit(errno); + } + + /* Read the current alarm settings */ + retval = ioctl(fd, RTC_ALM_READ, &rtc_tm); + if (retval == -1) { +- perror("ioctl"); ++ perror("RTC_ALM_READ ioctl"); + exit(errno); + } + +@@ -337,7 +359,7 @@ test_READ: + /* Enable alarm interrupts */ + retval = ioctl(fd, RTC_AIE_ON, 0); + if (retval == -1) { +- perror("ioctl"); ++ perror("RTC_AIE_ON ioctl"); + exit(errno); + } + +@@ -355,7 +377,7 @@ test_READ: + /* Disable alarm interrupts */ + retval = ioctl(fd, RTC_AIE_OFF, 0); + if (retval == -1) { +- perror("ioctl"); ++ perror("RTC_AIE_OFF ioctl"); + exit(errno); + } + +@@ -368,7 +390,7 @@ test_PIE: + fprintf(stderr, "\nNo periodic IRQ support\n"); + return 0; + } +- perror("ioctl"); ++ perror("RTC_IRQP_READ ioctl"); + exit(errno); + } + fprintf(stderr, "\nPeriodic IRQ rate is %ldHz.\n", tmp); +@@ -387,7 +409,7 @@ test_PIE: + "\n...Periodic IRQ rate is fixed\n"); + goto done; + } +- perror("ioctl"); ++ perror("RTC_IRQP_SET ioctl"); + exit(errno); + } + +@@ -397,7 +419,7 @@ test_PIE: + /* Enable periodic interrupts */ + retval = ioctl(fd, RTC_PIE_ON, 0); + if (retval == -1) { +- perror("ioctl"); ++ perror("RTC_PIE_ON ioctl"); + exit(errno); + } + +@@ -416,7 +438,7 @@ test_PIE: + /* Disable periodic interrupts */ + retval = ioctl(fd, RTC_PIE_OFF, 0); + if (retval == -1) { +- perror("ioctl"); ++ perror("RTC_PIE_OFF ioctl"); + exit(errno); + } + } diff --git a/linux-rtc-sysfs-no-devinit-add.patch b/linux-rtc-sysfs-no-devinit-add.patch new file mode 100644 index 0000000..6936dda --- /dev/null +++ b/linux-rtc-sysfs-no-devinit-add.patch @@ -0,0 +1,17 @@ +rtc_sysfs_add_device is needed even after dev initialization, so drop __devinit. + +Signed-off-by: Mike Frysinger + +diff --git a/drivers/rtc/rtc-sysfs.c b/drivers/rtc/rtc-sysfs.c +index 9418a59..2ddd0cf 100644 +--- a/drivers/rtc/rtc-sysfs.c ++++ b/drivers/rtc/rtc-sysfs.c +@@ -78,7 +78,7 @@ static struct attribute_group rtc_attr_group = { + .attrs = rtc_attrs, + }; + +-static int __devinit rtc_sysfs_add_device(struct class_device *class_dev, ++static int rtc_sysfs_add_device(struct class_device *class_dev, + struct class_interface *class_intf) + { + int err; diff --git a/linux-s390-use-asm-ptrace.patch b/linux-s390-use-asm-ptrace.patch new file mode 100644 index 0000000..07c7ca4 --- /dev/null +++ b/linux-s390-use-asm-ptrace.patch @@ -0,0 +1,13 @@ +diff --git a/include/asm-s390/ptrace.h b/include/asm-s390/ptrace.h +index fa6ca87..4add355 100644 +--- a/include/asm-s390/ptrace.h ++++ b/include/asm-s390/ptrace.h +@@ -475,7 +475,7 @@ extern void show_regs(struct pt_regs * regs); + static inline void + psw_set_key(unsigned int key) + { +- asm volatile("spka 0(%0)" : : "d" (key)); ++ __asm__ __volatile__("spka 0(%0)" : : "d" (key)); + } + + #endif /* __ASSEMBLY__ */ diff --git a/linux-scrub-GLIBC-ifdefs.patch b/linux-scrub-GLIBC-ifdefs.patch new file mode 100644 index 0000000..f224ebd --- /dev/null +++ b/linux-scrub-GLIBC-ifdefs.patch @@ -0,0 +1,24 @@ +index 92cd38e..545c041 100644 +--- a/include/linux/socket.h ++++ b/include/linux/socket.h +@@ -16,7 +16,7 @@ struct __kernel_sockaddr_storage { + /* _SS_MAXSIZE value minus size of ss_family */ + } __attribute__ ((aligned(_K_SS_ALIGNSIZE))); /* force desired alignment */ + +-#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) ++#ifdef __KERNEL__ + + #include /* arch-dependent defines */ + #include /* the SIOCxxx I/O controls */ +index 679ef0d..59e6ba3 100644 +--- a/include/linux/stat.h ++++ b/include/linux/stat.h +@@ -7,7 +7,7 @@ + + #endif + +-#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) ++#ifdef __KERNEL__ + + #define S_IFMT 00170000 + #define S_IFSOCK 0140000 diff --git a/linux-sh-delete-PTRACE_O_TRACESYSGOOD.patch b/linux-sh-delete-PTRACE_O_TRACESYSGOOD.patch new file mode 100644 index 0000000..be9e14b --- /dev/null +++ b/linux-sh-delete-PTRACE_O_TRACESYSGOOD.patch @@ -0,0 +1,25 @@ +diff --git a/include/asm-sh/ptrace.h b/include/asm-sh/ptrace.h +index ed358a3..b9789c8 100644 +--- a/include/asm-sh/ptrace.h ++++ b/include/asm-sh/ptrace.h +@@ -42,9 +42,6 @@ + #define REG_FPSCR 55 + #define REG_FPUL 56 + +-/* options set using PTRACE_SETOPTIONS */ +-#define PTRACE_O_TRACESYSGOOD 0x00000001 +- + /* + * This struct defines the way the registers are stored on the + * kernel stack during a system call or other kernel entry. +diff --git a/include/asm-sh64/ptrace.h b/include/asm-sh64/ptrace.h +index a6d4da5..c424f80 100644 +--- a/include/asm-sh64/ptrace.h ++++ b/include/asm-sh64/ptrace.h +@@ -32,6 +32,4 @@ struct pt_regs { + extern void show_regs(struct pt_regs *); + #endif + +-#define PTRACE_O_TRACESYSGOOD 0x00000001 +- + #endif /* __ASM_SH64_PTRACE_H */ diff --git a/linux-sh-ioctls.patch b/linux-sh-ioctls.patch new file mode 100644 index 0000000..e7ad6ea --- /dev/null +++ b/linux-sh-ioctls.patch @@ -0,0 +1,55 @@ +diff --git a/include/asm-sh/ioctls.h b/include/asm-sh/ioctls.h +index 9d84a2d..35805df 100644 +--- a/include/asm-sh/ioctls.h ++++ b/include/asm-sh/ioctls.h +@@ -16,17 +16,17 @@ + #define TCSETSW 0x5403 + #define TCSETSF 0x5404 + +-#define TCGETA _IOR('t', 23, struct termio) +-#define TCSETA _IOW('t', 24, struct termio) +-#define TCSETAW _IOW('t', 25, struct termio) +-#define TCSETAF _IOW('t', 28, struct termio) ++#define TCGETA 0x80127417 /* _IOR('t', 23, struct termio) */ ++#define TCSETA 0x40127418 /* _IOW('t', 24, struct termio) */ ++#define TCSETAW 0x40127419 /* _IOW('t', 25, struct termio) */ ++#define TCSETAF 0x4012741C /* _IOW('t', 28, struct termio) */ + + #define TCSBRK _IO('t', 29) + #define TCXONC _IO('t', 30) + #define TCFLSH _IO('t', 31) + +-#define TIOCSWINSZ _IOW('t', 103, struct winsize) +-#define TIOCGWINSZ _IOR('t', 104, struct winsize) ++#define TIOCSWINSZ 0x40087467 /* _IOW('t', 103, struct winsize) */ ++#define TIOCGWINSZ 0x80087468 /* _IOR('t', 104, struct winsize) */ + #define TIOCSTART _IO('t', 110) /* start output, like ^Q */ + #define TIOCSTOP _IO('t', 111) /* stop output, like ^S */ + #define TIOCOUTQ _IOR('t', 115, int) /* output queue size */ +@@ -59,8 +59,8 @@ + #define TIOCSSOFTCAR _IOW('T', 26, unsigned int) /* 0x541A */ + #define TIOCLINUX _IOW('T', 28, char) /* 0x541C */ + #define TIOCCONS _IO('T', 29) /* 0x541D */ +-#define TIOCGSERIAL _IOR('T', 30, struct serial_struct) /* 0x541E */ +-#define TIOCSSERIAL _IOW('T', 31, struct serial_struct) /* 0x541F */ ++#define TIOCGSERIAL 0x803C541E /* _IOR('T', 30, struct serial_struct) 0x541E */ ++#define TIOCSSERIAL 0x403C541F /* _IOW('T', 31, struct serial_struct) 0x541F */ + #define TIOCPKT _IOW('T', 32, int) /* 0x5420 */ + # define TIOCPKT_DATA 0 + # define TIOCPKT_FLUSHREAD 1 +@@ -86,12 +86,12 @@ + #define TIOCSERSWILD _IOW('T', 85, int) /* 0x5455 */ + #define TIOCGLCKTRMIOS 0x5456 + #define TIOCSLCKTRMIOS 0x5457 +-#define TIOCSERGSTRUCT _IOR('T', 88, struct async_struct) /* 0x5458 */ /* For debugging only */ ++#define TIOCSERGSTRUCT 0x80d85458 /* _IOR('T', 88, struct async_struct) 0x5458 */ /* For debugging only */ + #define TIOCSERGETLSR _IOR('T', 89, unsigned int) /* 0x5459 */ /* Get line status register */ + /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */ + # define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ +-#define TIOCSERGETMULTI _IOR('T', 90, struct serial_multiport_struct) /* 0x545A */ /* Get multiport config */ +-#define TIOCSERSETMULTI _IOW('T', 91, struct serial_multiport_struct) /* 0x545B */ /* Set multiport config */ ++#define TIOCSERGETMULTI 0x80A8545A /* _IOR('T', 90, struct serial_multiport_struct) 0x545A */ /* Get multiport config */ ++#define TIOCSERSETMULTI 0x40A8545B /* _IOW('T', 91, struct serial_multiport_struct) 0x545B */ /* Set multiport config */ + + #define TIOCMIWAIT _IO('T', 92) /* 0x545C */ /* wait for a change on serial input line(s) */ + #define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ diff --git a/linux-squash-initramfs-owners.patch b/linux-squash-initramfs-owners.patch new file mode 100644 index 0000000..f4a5ee2 --- /dev/null +++ b/linux-squash-initramfs-owners.patch @@ -0,0 +1,31 @@ +diff --git a/scripts/gen_initramfs_list.sh b/scripts/gen_initramfs_list.sh +index 683eb12..684fb9c 100644 +--- a/scripts/gen_initramfs_list.sh ++++ b/scripts/gen_initramfs_list.sh +@@ -19,11 +19,11 @@ $0 [-o ] [-u ] [-g ] {-d | } ... + -o Create gzipped initramfs file named using + gen_init_cpio and gzip + -u User ID to map to user ID 0 (root). +- is only meaningful if +- is a directory. ++ is only meaningful if is a ++ directory. "squash" forces all files to uid 0. + -g Group ID to map to group ID 0 (root). +- is only meaningful if +- is a directory. ++ is only meaningful if is a ++ directory. "squash" forces all files to gid 0. + File list or directory for cpio archive. + If is a .cpio file it will be used + as direct input to initramfs. +@@ -113,8 +113,8 @@ parse() { + 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 ++ [ "$root_uid" = "squash" ] && uid=0 || [ "$uid" -eq "$root_uid" ] && uid=0 ++ [ "$root_gid" = "squash" ] && gid=0 || [ "$gid" -eq "$root_gid" ] && gid=0 + local str="${mode} ${uid} ${gid}" + + [ "${ftype}" == "invalid" ] && return 0 diff --git a/linux-sumversion-limits.patch b/linux-sumversion-limits.patch new file mode 100644 index 0000000..86f7d7a --- /dev/null +++ b/linux-sumversion-limits.patch @@ -0,0 +1,12 @@ +diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c +index 6873d5a..d9cc690 100644 +--- a/scripts/mod/sumversion.c ++++ b/scripts/mod/sumversion.c +@@ -7,6 +7,7 @@ + #include + #include + #include ++#include + #include "modpost.h" + + /* diff --git a/linux-uclinux-dont-force-root-dev.patch b/linux-uclinux-dont-force-root-dev.patch new file mode 100644 index 0000000..fd0da76 --- /dev/null +++ b/linux-uclinux-dont-force-root-dev.patch @@ -0,0 +1,23 @@ +diff --git a/drivers/mtd/maps/uclinux.c b/drivers/mtd/maps/uclinux.c +index 389fea2..14ffb1a 100644 +--- a/drivers/mtd/maps/uclinux.c ++++ b/drivers/mtd/maps/uclinux.c +@@ -16,7 +16,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -89,10 +88,6 @@ int __init uclinux_mtd_init(void) + uclinux_ram_mtdinfo = mtd; + add_mtd_partitions(mtd, uclinux_romfs, NUM_PARTITIONS); + +- printk("uclinux[mtd]: set %s to be root filesystem\n", +- uclinux_romfs[0].name); +- ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, 0); +- + return(0); + } + diff --git a/linux-uinput-header.patch b/linux-uinput-header.patch new file mode 100644 index 0000000..888b723 --- /dev/null +++ b/linux-uinput-header.patch @@ -0,0 +1,13 @@ +diff --git a/include/linux/uinput.h b/include/linux/uinput.h +index 1fd61ee..a6c1e8e 100644 +--- a/include/linux/uinput.h ++++ b/include/linux/uinput.h +@@ -32,6 +32,8 @@ + * - first public version + */ + ++#include ++ + #define UINPUT_VERSION 3 + + #ifdef __KERNEL__ diff --git a/linux-use-__-types-in-hdreg-header.patch b/linux-use-__-types-in-hdreg-header.patch new file mode 100644 index 0000000..3e66095 --- /dev/null +++ b/linux-use-__-types-in-hdreg-header.patch @@ -0,0 +1,25 @@ +Use __u8 rather than u8 in SIZE defines exported to userspace. + +Signed-off-by: Mike Frysinger + +--- a/include/linux/hdreg.h ++++ b/include/linux/hdreg.h +@@ -60,13 +60,15 @@ + #define TAG_MASK 0xf8 + #endif /* __KERNEL__ */ + ++#include ++ + /* + * Command Header sizes for IOCTL commands + */ + +-#define HDIO_DRIVE_CMD_HDR_SIZE (4 * sizeof(u8)) +-#define HDIO_DRIVE_HOB_HDR_SIZE (8 * sizeof(u8)) +-#define HDIO_DRIVE_TASK_HDR_SIZE (8 * sizeof(u8)) ++#define HDIO_DRIVE_CMD_HDR_SIZE (4 * sizeof(__u8)) ++#define HDIO_DRIVE_HOB_HDR_SIZE (8 * sizeof(__u8)) ++#define HDIO_DRIVE_TASK_HDR_SIZE (8 * sizeof(__u8)) + + #define IDE_DRIVE_TASK_INVALID -1 + #define IDE_DRIVE_TASK_NO_DATA 0 diff --git a/linux-use-__-types-in-i2o-header.patch b/linux-use-__-types-in-i2o-header.patch new file mode 100644 index 0000000..c1a5974 --- /dev/null +++ b/linux-use-__-types-in-i2o-header.patch @@ -0,0 +1,30 @@ +Make sure exported I2O ioctls utilize userspace safe types. + +Signed-off-by: Mike Frysinger + +--- a/include/linux/i2o-dev.h ++++ b/include/linux/i2o-dev.h +@@ -24,12 +24,13 @@ + #define MAX_I2O_CONTROLLERS 32 + + #include ++#include + + /* + * 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 +38,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) diff --git a/linux-use-__-types-in-parisc-statfs.patch b/linux-use-__-types-in-parisc-statfs.patch new file mode 100644 index 0000000..d365cd1 --- /dev/null +++ b/linux-use-__-types-in-parisc-statfs.patch @@ -0,0 +1,23 @@ +Use __u64 rather than u64 in the struct statfs64 exported to userspace. + +Signed-off-by: Mike Frysinger + +--- a/include/asm-parisc/statfs.h ++++ b/include/asm-parisc/statfs.h +@@ -30,11 +30,11 @@ struct statfs { + struct statfs64 { + long f_type; + long f_bsize; +- u64 f_blocks; +- u64 f_bfree; +- u64 f_bavail; +- u64 f_files; +- u64 f_ffree; ++ __u64 f_blocks; ++ __u64 f_bfree; ++ __u64 f_bavail; ++ __u64 f_files; ++ __u64 f_ffree; + __kernel_fsid_t f_fsid; + long f_namelen; + long f_frsize; diff --git a/linux-use-__-types-in-usbdevice-fs-header.patch b/linux-use-__-types-in-usbdevice-fs-header.patch new file mode 100644 index 0000000..0c774af --- /dev/null +++ b/linux-use-__-types-in-usbdevice-fs-header.patch @@ -0,0 +1,18 @@ +Use __u32 rather than u32 in userspace ioctl defines. + +Signed-off-by: Mike Frysinger + +--- a/include/linux/usbdevice_fs.h ++++ b/include/linux/usbdevice_fs.h +@@ -159,9 +159,9 @@ struct usbdevfs_ioctl32 { + #define USBDEVFS_SUBMITURB32 _IOR('U', 10, struct usbdevfs_urb32) + #define USBDEVFS_DISCARDURB _IO('U', 11) + #define USBDEVFS_REAPURB _IOW('U', 12, void *) +-#define USBDEVFS_REAPURB32 _IOW('U', 12, u32) ++#define USBDEVFS_REAPURB32 _IOW('U', 12, __u32) + #define USBDEVFS_REAPURBNDELAY _IOW('U', 13, void *) +-#define USBDEVFS_REAPURBNDELAY32 _IOW('U', 13, u32) ++#define USBDEVFS_REAPURBNDELAY32 _IOW('U', 13, __u32) + #define USBDEVFS_DISCSIGNAL _IOR('U', 14, struct usbdevfs_disconnectsignal) + #define USBDEVFS_CLAIMINTERFACE _IOR('U', 15, unsigned int) + #define USBDEVFS_RELEASEINTERFACE _IOR('U', 16, unsigned int) diff --git a/linux-use-__-types-in-x86-64-msr.patch b/linux-use-__-types-in-x86-64-msr.patch new file mode 100644 index 0000000..397f47f --- /dev/null +++ b/linux-use-__-types-in-x86-64-msr.patch @@ -0,0 +1,25 @@ +Use __u32 rather than u32 in checking_wrmsrl() exported to userspace. + +Signed-off-by: Mike Frysinger + +--- a/include/asm-x86_64/msr.h ++++ b/include/asm-x86_64/msr.h +@@ -2,6 +2,9 @@ + #define X86_64_MSR_H 1 + + #ifndef __ASSEMBLY__ ++ ++#include ++ + /* + * Access to machine-specific registers (available on 586 and better only) + * Note: the rd* operations modify the parameters directly (without using +@@ -43,7 +46,7 @@ + : "c" (msr), "0" (a), "d" (b), "i" (-EFAULT)); \ + ret__; }) + +-#define checking_wrmsrl(msr,val) wrmsr_safe(msr,(u32)(val),(u32)((val)>>32)) ++#define checking_wrmsrl(msr,val) wrmsr_safe(msr,(__u32)(val),(__u32)((val)>>32)) + + #define rdmsr_safe(msr,a,b) \ + ({ int ret__; \ diff --git a/linux-use-__asm__.patch b/linux-use-__asm__.patch new file mode 100644 index 0000000..fe7aa02 --- /dev/null +++ b/linux-use-__asm__.patch @@ -0,0 +1,84 @@ +diff --git a/include/asm-arm/byteorder.h b/include/asm-arm/byteorder.h +index e6f7fcd..39105dc 100644 +--- a/include/asm-arm/byteorder.h ++++ b/include/asm-arm/byteorder.h +@@ -29,7 +29,7 @@ static inline __attribute_const__ __u32 ___arch__swab32(__u32 x) + * right thing and not screw it up to different degrees + * depending on the gcc version. + */ +- asm ("eor\t%0, %1, %1, ror #16" : "=r" (t) : "r" (x)); ++ __asm__ ("eor\t%0, %1, %1, ror #16" : "=r" (t) : "r" (x)); + } else + #endif + t = x ^ ((x << 16) | (x >> 16)); /* eor r1,r0,r0,ror #16 */ +diff --git a/include/asm-i386/byteorder.h b/include/asm-i386/byteorder.h +index a45470a..4ead40b 100644 +--- a/include/asm-i386/byteorder.h ++++ b/include/asm-i386/byteorder.h +@@ -32,13 +32,13 @@ static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 val) + } v; + v.u = val; + #ifdef CONFIG_X86_BSWAP +- asm("bswapl %0 ; bswapl %1 ; xchgl %0,%1" +- : "=r" (v.s.a), "=r" (v.s.b) +- : "0" (v.s.a), "1" (v.s.b)); ++ __asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1" ++ : "=r" (v.s.a), "=r" (v.s.b) ++ : "0" (v.s.a), "1" (v.s.b)); + #else + v.s.a = ___arch__swab32(v.s.a); + v.s.b = ___arch__swab32(v.s.b); +- asm("xchgl %0,%1" : "=r" (v.s.a), "=r" (v.s.b) : "0" (v.s.a), "1" (v.s.b)); ++ __asm__("xchgl %0,%1" : "=r" (v.s.a), "=r" (v.s.b) : "0" (v.s.a), "1" (v.s.b)); + #endif + return v.u; + } +diff --git a/include/asm-s390/byteorder.h b/include/asm-s390/byteorder.h +index 1fe2492..07230f6 100644 +--- a/include/asm-s390/byteorder.h ++++ b/include/asm-s390/byteorder.h +@@ -18,7 +18,7 @@ static inline __u64 ___arch__swab64p(const __u64 *x) + { + __u64 result; + +- asm volatile("lrvg %0,%1" : "=d" (result) : "m" (*x)); ++ __asm__ __volatile__("lrvg %0,%1" : "=d" (result) : "m" (*x)); + return result; + } + +@@ -26,7 +26,7 @@ static inline __u64 ___arch__swab64(__u64 x) + { + __u64 result; + +- asm volatile("lrvgr %0,%1" : "=d" (result) : "d" (x)); ++ __asm__ __volatile__("lrvgr %0,%1" : "=d" (result) : "d" (x)); + return result; + } + +@@ -40,7 +40,7 @@ static inline __u32 ___arch__swab32p(const __u32 *x) + { + __u32 result; + +- asm volatile( ++ __asm__ __volatile__( + #ifndef __s390x__ + " icm %0,8,3(%1)\n" + " icm %0,4,2(%1)\n" +@@ -61,7 +61,7 @@ static inline __u32 ___arch__swab32(__u32 x) + #else /* __s390x__ */ + __u32 result; + +- asm volatile("lrvr %0,%1" : "=d" (result) : "d" (x)); ++ __asm__ __volatile__("lrvr %0,%1" : "=d" (result) : "d" (x)); + return result; + #endif /* __s390x__ */ + } +@@ -75,7 +75,7 @@ static __inline__ __u16 ___arch__swab16p(const __u16 *x) + { + __u16 result; + +- asm volatile( ++ __asm__ __volatile__( + #ifndef __s390x__ + " icm %0,2,1(%1)\n" + " ic %0,0(%1)\n" diff --git a/linux-use-posix-sed-in-headersinst.patch b/linux-use-posix-sed-in-headersinst.patch new file mode 100644 index 0000000..bdb52ff --- /dev/null +++ b/linux-use-posix-sed-in-headersinst.patch @@ -0,0 +1,25 @@ +diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst +index 8cd6301..fb6726b 100644 +--- a/scripts/Makefile.headersinst ++++ b/scripts/Makefile.headersinst +@@ -11,13 +11,13 @@ UNIFDEF := scripts/unifdef -U__KERNEL__ + + # Eliminate the contents of (and inclusions of) compiler.h + HDRSED := sed -e "s/ inline / __inline__ /g" \ +- -e "s/[[:space:]]__user[[:space:]]\+/ /g" \ +- -e "s/(__user[[:space:]]\+/ (/g" \ +- -e "s/[[:space:]]__force[[:space:]]\+/ /g" \ +- -e "s/(__force[[:space:]]\+/ (/g" \ +- -e "s/[[:space:]]__iomem[[:space:]]\+/ /g" \ +- -e "s/(__iomem[[:space:]]\+/ (/g" \ +- -e "s/[[:space:]]__attribute_const__[[:space:]]\+/\ /g" \ ++ -e "s/[[:space:]]__user[[:space:]]\{1,\}/ /g" \ ++ -e "s/(__user[[:space:]]\{1,\}/ (/g" \ ++ -e "s/[[:space:]]__force[[:space:]]\{1,\}/ /g" \ ++ -e "s/(__force[[:space:]]\{1,\}/ (/g" \ ++ -e "s/[[:space:]]__iomem[[:space:]]\{1,\}/ /g" \ ++ -e "s/(__iomem[[:space:]]\{1,\}/ (/g" \ ++ -e "s/[[:space:]]__attribute_const__[[:space:]]\{1,\}/\ /g" \ + -e "s/[[:space:]]__attribute_const__$$//" \ + -e "/^\#include /d" + diff --git a/linux-x86_64-msr-asm-volatile.patch b/linux-x86_64-msr-asm-volatile.patch new file mode 100644 index 0000000..cad901e --- /dev/null +++ b/linux-x86_64-msr-asm-volatile.patch @@ -0,0 +1,43 @@ +diff --git a/include/asm-x86_64/msr.h b/include/asm-x86_64/msr.h +index d5c55b8..ed15d2b 100644 +--- a/include/asm-x86_64/msr.h ++++ b/include/asm-x86_64/msr.h +@@ -33,7 +33,7 @@ + + /* wrmsr with exception handling */ + #define wrmsr_safe(msr,a,b) ({ int ret__; \ +- asm volatile("2: wrmsr ; xorl %0,%0\n" \ ++ __asm__ __volatile__("2: wrmsr ; xorl %0,%0\n" \ + "1:\n\t" \ + ".section .fixup,\"ax\"\n\t" \ + "3: movl %4,%0 ; jmp 1b\n\t" \ +@@ -50,7 +50,7 @@ + + #define rdmsr_safe(msr,a,b) \ + ({ int ret__; \ +- asm volatile ("1: rdmsr\n" \ ++ __asm__ __volatile__ ("1: rdmsr\n" \ + "2:\n" \ + ".section .fixup,\"ax\"\n" \ + "3: movl %4,%0\n" \ +@@ -70,17 +70,17 @@ + __asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx") + + #define rdtscp(low,high,aux) \ +- asm volatile (".byte 0x0f,0x01,0xf9" : "=a" (low), "=d" (high), "=c" (aux)) ++ __asm__ __volatile__ (".byte 0x0f,0x01,0xf9" : "=a" (low), "=d" (high), "=c" (aux)) + + #define rdtscll(val) do { \ + unsigned int __a,__d; \ +- asm volatile("rdtsc" : "=a" (__a), "=d" (__d)); \ ++ __asm__ __volatile__("rdtsc" : "=a" (__a), "=d" (__d)); \ + (val) = ((unsigned long)__a) | (((unsigned long)__d)<<32); \ + } while(0) + + #define rdtscpll(val, aux) do { \ + unsigned long __a, __d; \ +- asm volatile (".byte 0x0f,0x01,0xf9" : "=a" (__a), "=d" (__d), "=c" (aux)); \ ++ __asm__ __volatile__ (".byte 0x0f,0x01,0xf9" : "=a" (__a), "=d" (__d), "=c" (aux)); \ + (val) = (__d << 32) | __a; \ + } while (0) + diff --git a/linuxthreads-ia64-tcb-typo.patch b/linuxthreads-ia64-tcb-typo.patch new file mode 100644 index 0000000..ac8a2df --- /dev/null +++ b/linuxthreads-ia64-tcb-typo.patch @@ -0,0 +1,16 @@ +2006-10-19 Mike Frysinger + + * sysdeps/ia64/tcb-offsets.sym (MULTIPLE_THREADS_OFFSET): + Fix typo TLS_PRE_TCB_SIZE. + +--- sysdeps/ia64/tcb-offsets.sym ++++ sysdeps/ia64/tcb-offsets.sym +@@ -3,7 +3,7 @@ + + -- + #ifdef USE_TLS +-MULTIPLE_THREADS_OFFSET offsetof (struct _pthread_descr_struct, p_multiple_threads) - TCB_PRE_SIZE ++MULTIPLE_THREADS_OFFSET offsetof (struct _pthread_descr_struct, p_multiple_threads) - TLS_PRE_TCB_SIZE + #else + MULTIPLE_THREADS_OFFSET offsetof (tcbhead_t, multiple_threads) + #endif diff --git a/lirc-0.8.2-out-of-tree-build-drivers.patch b/lirc-0.8.2-out-of-tree-build-drivers.patch new file mode 100644 index 0000000..03d7788 --- /dev/null +++ b/lirc-0.8.2-out-of-tree-build-drivers.patch @@ -0,0 +1,14 @@ +--- vanilla-0.8.2/drivers/Makefile.common ++++ lirc-0.8.2/drivers/Makefile.common +@@ -14,9 +14,9 @@ + -I$(KERNEL_LOCATION)/drivers/media/video/ + export LIRC_EXTRA_CFLAGS KERNEL_LOCATION module_DATA + +-$(module_DATA): $(automake_dummy_SOURCES) $(top_srcdir)/config.h ../lirc.h ++$(module_DATA): $(automake_dummy_SOURCES) $(top_builddir)/config.h ../lirc.h + mv Makefile Makefile.automake +- cp ../Makefile.kernel Makefile ++ cp $(srcdir)/../Makefile.kernel Makefile + $(MAKE) -C $(KERNEL_LOCATION) SUBDIRS=$(LIRC_DEVDIR) modules \ + KBUILD_VERBOSE=$(KBUILD_VERBOSE) + mv Makefile.automake Makefile diff --git a/lirc-0.8.2-out-of-tree-build.patch b/lirc-0.8.2-out-of-tree-build.patch new file mode 100644 index 0000000..f743d5d --- /dev/null +++ b/lirc-0.8.2-out-of-tree-build.patch @@ -0,0 +1,22 @@ +--- vanilla-0.8.2/daemons/Makefile.am ++++ lirc-0.8.2/daemons/Makefile.am +@@ -5,6 +5,8 @@ + ## these are used by programs in the tools directory, but not by + ## programs in this directory. So we must make sure they get distributed + ++INCLUDES = -I$(top_srcdir) ++ + EXTRA_DIST = dump_config.c dump_config.h + + sbin_PROGRAMS = lircd lircmd +--- vanilla-0.8.2/tools/Makefile.am ++++ lirc-0.8.2/tools/Makefile.am +@@ -2,6 +2,8 @@ + + ## Process this file with automake to produce Makefile.in + ++INCLUDES = -I$(top_srcdir) ++ + EXTRA_PROGRAMS = smode2 xmode2 irxevent + bin_PROGRAMS = irw irpty irexec ircat mode2 irsend \ + lircrcd \ diff --git a/lirc-0.8.2-out-of-tree-build3.patch b/lirc-0.8.2-out-of-tree-build3.patch new file mode 100644 index 0000000..5cfbedf --- /dev/null +++ b/lirc-0.8.2-out-of-tree-build3.patch @@ -0,0 +1,22 @@ +--- lirc/drivers/Makefile.common ++++ lirc/drivers/Makefile.common +@@ -9,14 +9,18 @@ + # when compiling module(s) + KBUILD_VERBOSE = 1 + LIRC_EXTRA_CFLAGS = -DIRCTL_DEV_MAJOR=$(lirc_major) -DEXPORT_SYMTAB $(DEFS) \ +- $(DEFAULT_INCLUDES) -I$(LIRC_DEVDIR)/../.. \ ++ $(DEFAULT_INCLUDES) -I$(LIRC_DEVDIR)/$(srcdir) -I$(LIRC_DEVDIR)/$(builddir) \ ++ -I$(LIRC_DEVDIR)/$(top_srcdir) -I$(LIRC_DEVDIR)/$(top_builddir) \ + -I$(KERNEL_LOCATION)/include/ \ + -I$(KERNEL_LOCATION)/drivers/media/video/ + export LIRC_EXTRA_CFLAGS KERNEL_LOCATION module_DATA + + $(module_DATA): $(automake_dummy_SOURCES) $(top_builddir)/config.h ../lirc.h ++ test "$(srcdir)" != "$(builddir)" && \ ++ for f in $(automake_dummy_SOURCES) ; do [ -e $$f ] || ln -s $(srcdir)/$$f $$f || exit $$? ; done + mv Makefile Makefile.automake + cp $(srcdir)/../Makefile.kernel Makefile ++ CPPFLAGS="" CFLAGS="" LDFLAGS="" \ + $(MAKE) -C $(KERNEL_LOCATION) SUBDIRS=$(LIRC_DEVDIR) modules \ + KBUILD_VERBOSE=$(KBUILD_VERBOSE) + mv Makefile.automake Makefile diff --git a/lirc-cvs-control-daemonize.patch b/lirc-cvs-control-daemonize.patch new file mode 100644 index 0000000..fbc01e3 --- /dev/null +++ b/lirc-cvs-control-daemonize.patch @@ -0,0 +1,167 @@ +Index: configure.ac +=================================================================== +RCS file: /cvsroot/lirc/lirc/configure.ac,v +retrieving revision 1.2 +diff -u -p -r1.2 configure.ac +--- configure.ac 22 Jul 2007 07:30:25 -0000 1.2 ++++ configure.ac 24 Oct 2007 01:29:16 -0000 +@@ -42,15 +42,6 @@ AC_FUNC_VPRINTF + AC_CHECK_FUNCS(gethostname gettimeofday mkfifo select socket strdup \ + strerror strtoul snprintf strsep vsyslog) + +-daemon="" +-AC_CHECK_FUNCS(daemon) +-if test "$ac_cv_func_daemon" != yes; then +- AC_CHECK_LIB(bsd,daemon,daemon="-lbsd") +- if test "$daemon" = ""; then +- AC_MSG_ERROR([*** daemon() function not available on this system]) +- fi +-fi +- + forkpty="" + AC_CHECK_FUNCS(forkpty) + if test "$ac_cv_func_forkpty" != yes; then +@@ -1468,7 +1459,17 @@ test x${enableval} = xyes && AC_DEFINE(D + AC_ARG_ENABLE(daemonize, + [ --disable-daemonize disable daemons from daemonizing], + test x${enableval} = xyes && AC_DEFINE(DAEMONIZE), +-AC_DEFINE(DAEMONIZE)) ++[ ++AC_CHECK_FUNCS(daemon) ++if test "$ac_cv_func_daemon" != yes; then ++ daemon="" ++ AC_CHECK_LIB(bsd,daemon,daemon="-lbsd") ++ if test "$daemon" = ""; then ++ AC_MSG_ERROR([*** daemon() function not available on this system and --disable-daemonize not specified]) ++ fi ++fi ++AC_DEFINE(DAEMONIZE) ++]) + + AC_ARG_WITH(syslog, + [ --with-syslog=facility use syslog instead of logfile], +Index: tools/irexec.c +=================================================================== +RCS file: /cvsroot/lirc/lirc/tools/irexec.c,v +retrieving revision 5.6 +diff -u -p -r5.6 irexec.c +--- tools/irexec.c 7 Jun 2003 22:12:52 -0000 5.6 ++++ tools/irexec.c 24 Oct 2007 01:29:16 -0000 +@@ -25,11 +25,26 @@ + #include "lirc_client.h" + + char *progname; ++struct lirc_config *config; ++ ++void daemonize(void) ++{ ++#ifdef DAEMONIZE ++ if(daemon(0,0)==-1) ++#endif ++ { ++ fprintf(stderr,"%s: can't daemonize\n", ++ progname); ++ perror(progname); ++ lirc_freeconfig(config); ++ lirc_deinit(); ++ exit(EXIT_FAILURE); ++ } ++} + + int main(int argc, char *argv[]) + { +- struct lirc_config *config; +- int daemonize=0; ++ int do_daemon=0; + char* program="irexec"; + + progname="irexec " VERSION; +@@ -60,7 +75,7 @@ int main(int argc, char *argv[]) + printf("%s\n",progname); + return(EXIT_SUCCESS); + case 'd': +- daemonize=1; ++ do_daemon=1; + break; + case 'n': + program=optarg; +@@ -76,7 +91,7 @@ int main(int argc, char *argv[]) + return(EXIT_FAILURE); + } + +- if(lirc_init(program, daemonize ? 0:1)==-1) exit(EXIT_FAILURE); ++ if(lirc_init(program, do_daemon ? 0:1)==-1) exit(EXIT_FAILURE); + + if(lirc_readconfig(optind!=argc ? argv[optind]:NULL,&config,NULL)==0) + { +@@ -84,18 +99,7 @@ int main(int argc, char *argv[]) + char *c; + int ret; + +- if(daemonize) +- { +- if(daemon(0,0)==-1) +- { +- fprintf(stderr,"%s: can't daemonize\n", +- progname); +- perror(progname); +- lirc_freeconfig(config); +- lirc_deinit(); +- exit(EXIT_FAILURE); +- } +- } ++ if(do_daemon) daemonize(); + while(lirc_nextcode(&code)==0) + { + if(code==NULL) continue; +@@ -103,7 +107,7 @@ int main(int argc, char *argv[]) + c!=NULL) + { + #ifdef DEBUG +- if(!daemonize) ++ if(!do_daemon) + { + printf("Execing command \"%s\"\n",c); + } +Index: tools/lircrcd.c +=================================================================== +RCS file: /cvsroot/lirc/lirc/tools/lircrcd.c,v +retrieving revision 5.3 +diff -u -p -r5.3 lircrcd.c +--- tools/lircrcd.c 6 May 2006 09:40:07 -0000 5.3 ++++ tools/lircrcd.c 24 Oct 2007 01:29:17 -0000 +@@ -128,8 +128,6 @@ static int termsig; + static int clin=0; + static struct client_data clis[MAX_CLIENTS]; + +-static int daemonized=0; +- + static struct lirc_config *config; + + static int send_error(int fd,char *message,char *format_str, ...); +@@ -313,7 +311,7 @@ static void remove_client(int i) + void add_client(int sock) + { + int fd; +- int clilen; ++ socklen_t clilen; + struct sockaddr client_addr; + int flags; + +@@ -989,6 +987,7 @@ int main(int argc, char **argv) + + /* fork */ + getcwd(dir, sizeof(dir)); ++#ifdef DAEMONIZE + if(daemon(0,0)==-1) + { + fprintf(stderr, "%s: daemon() failed\n", progname); +@@ -998,7 +997,7 @@ int main(int argc, char **argv) + lirc_freeconfig(config); + return -1; + } +- daemonized=1; ++#endif + + openlog(progname, LOG_CONS|LOG_PID, LOG_USER); + umask(0); diff --git a/man-1.6d-headers.patch b/man-1.6d-headers.patch new file mode 100644 index 0000000..7c5bf83 --- /dev/null +++ b/man-1.6d-headers.patch @@ -0,0 +1,57 @@ +--- src/makemsg.c ++++ src/makemsg.c +@@ -18,6 +18,7 @@ + * makemsg -c input message_catalog + */ + #include ++#include + #include + #ifdef __QNX__ + #include +--- gencat/gencat.c ++++ gencat/gencat.c +@@ -41,6 +41,7 @@ + */ + + #include ++#include + #include + #ifdef SYSV + #include +@@ -48,6 +49,10 @@ + #else + #include + #endif ++#ifdef __linux__ ++#include ++#include ++#endif + #include + #include + #include "gencat.h" +--- gencat/genlib.c ++++ gencat/genlib.c +@@ -48,9 +48,11 @@ + */ + + #include ++#include + #ifdef SYSV + #include + #include ++#endif + + #ifndef __linux__ + #include +@@ -66,9 +68,10 @@ + { + memset(b, '\0', length); + } ++#else ++#include + #endif + +-#endif + #include + #include + #include "msgcat.h" diff --git a/man-1.6e-readonly-whatis.patch b/man-1.6e-readonly-whatis.patch new file mode 100644 index 0000000..d0f8ce1 --- /dev/null +++ b/man-1.6e-readonly-whatis.patch @@ -0,0 +1,56 @@ +Dont update makewhatis files if they're on readonly filesystems + +http://bugs.gentoo.org/163932 + +--- src/makewhatis.sh ++++ src/makewhatis.sh +@@ -184,6 +188,34 @@ + if [ x$verbose != x ]; then + echo "about to enter $mandir" > /dev/stderr + fi ++ ++ # kludge for Slackware's /usr/man/preformat ++ if [ $mandir = /usr/man/preformat ] ++ then ++ mandir1=/usr/man ++ else ++ mandir1=$mandir ++ fi ++ ++ # if $mandir is on a readonly partition, and the whatis file ++ # is not a symlink, then let's skip trying to update it ++ if [ ! -L ${mandir1}/whatis ] ++ then ++ if [ -e ${mandir1}/whatis ] && [ ! -w ${mandir1}/whatis ] ++ then ++ if [ x$verbose != x ]; then ++ echo skipping $mandir - whatis file is readonly > /dev/stderr ++ fi ++ continue ++ elif [ ! -e ${mandir1}/whatis ] && [ ! -w ${mandir1} ] ++ then ++ if [ x$verbose != x ]; then ++ echo skipping $mandir - directory is readonly > /dev/stderr ++ fi ++ continue ++ fi ++ fi ++ + if [ -s ${mandir}/whatis -a $pages = man -a x$update = x ]; then + if [ x$verbose != x ]; then + echo skipping $mandir - we did it already > /dev/stderr +@@ -407,14 +439,6 @@ + + cd $here + +- # kludge for Slackware's /usr/man/preformat +- if [ $mandir = /usr/man/preformat ] +- then +- mandir1=/usr/man +- else +- mandir1=$mandir +- fi +- + if [ -f ${mandir1}/whatis ] + then + cat ${mandir1}/whatis >> $TMPFILE diff --git a/man-1.6e-readonly-whatis2.patch b/man-1.6e-readonly-whatis2.patch new file mode 100644 index 0000000..92e37d0 --- /dev/null +++ b/man-1.6e-readonly-whatis2.patch @@ -0,0 +1,47 @@ +Dont update makewhatis files if they're on readonly filesystems + +http://bugs.gentoo.org/163932 + +--- src/makewhatis.sh ++++ src/makewhatis.sh +@@ -184,6 +188,25 @@ + if [ x$verbose != x ]; then + echo "about to enter $mandir" > /dev/stderr + fi ++ ++ # kludge for Slackware's /usr/man/preformat ++ if [ $mandir = /usr/man/preformat ] ++ then ++ mandir1=/usr/man ++ else ++ mandir1=$mandir ++ fi ++ ++ # if $mandir is on a readonly partition and we cannot update the whatis ++ # file, then let's simply skip it ++ if ! touch ${mandir1}/whatis 2> /dev/null ++ then ++ if [ x$verbose != x ]; then ++ echo skipping $mandir - whatis file is readonly > /dev/stderr ++ fi ++ continue ++ fi ++ + if [ -s ${mandir}/whatis -a $pages = man -a x$update = x ]; then + if [ x$verbose != x ]; then + echo skipping $mandir - we did it already > /dev/stderr +@@ -407,14 +430,6 @@ + + cd $here + +- # kludge for Slackware's /usr/man/preformat +- if [ $mandir = /usr/man/preformat ] +- then +- mandir1=/usr/man +- else +- mandir1=$mandir +- fi +- + if [ -f ${mandir1}/whatis ] + then + cat ${mandir1}/whatis >> $TMPFILE diff --git a/man-dont-kill-shebangs.patch b/man-dont-kill-shebangs.patch new file mode 100644 index 0000000..f900f13 --- /dev/null +++ b/man-dont-kill-shebangs.patch @@ -0,0 +1,23 @@ +--- configure ++++ configure +@@ -1250,6 +1250,7 @@ + allargs='$@' + infiles='$infiles' + infile='$infile' ++shebang='`sed -n -e 1p $infile.in`' + cb='$cb' + cs='$cs' + ce='$ce' +@@ -1273,7 +1274,11 @@ + *.1|*.5|*.8|*.man) + cb=$mancomment; cs=$mancomment; ce=$mancomment;; + *) +- cb="#"; cs="#"; ce="#";; ++ case "$shebang" in ++ '#!'*) cb="$shebang";; ++ *) cb="#";; ++ esac ++ cs="#"; ce="#";; + esac + echo "$cb" > $infile + echo "$cs Generated automatically from $infile.in by the" >> $infile diff --git a/man-pages-fopen-e-flag.patch b/man-pages-fopen-e-flag.patch new file mode 100644 index 0000000..5f4c375 --- /dev/null +++ b/man-pages-fopen-e-flag.patch @@ -0,0 +1,16 @@ +--- man3/fopen.3.orig 2007-10-23 19:52:39.000000000 -0400 ++++ man3/fopen.3 2007-10-23 19:56:01.000000000 -0400 +@@ -257,6 +257,13 @@ + or subsequent read and write operations, + thread cancellation points. + .TP ++.BR e " (since glibc 2.7)" ++Open the file with the ++.B O_CLOEXEC ++flag. See ++.BR open (2) ++for more information. ++.TP + .BR m " (since glibc 2.3)" + Attempt to access the file using + .BR mmap (2), diff --git a/mbuffer-makefile-cleanup.patch b/mbuffer-makefile-cleanup.patch new file mode 100644 index 0000000..98baa73 --- /dev/null +++ b/mbuffer-makefile-cleanup.patch @@ -0,0 +1,17 @@ +--- Makefile.in ++++ Makefile.in +@@ -1,6 +1,7 @@ + CC = @CC@ + DEFS = @DEFS@ +-CFLAGS = @CFLAGS@ -O $(DEFS) ++CFLAGS = @CFLAGS@ $(DEFS) ++CPPFLAGS = @CPPFLAGS@ + LDFLAGS = @LDFLAGS@ + LIBS = @LIBS@ + +@@ -33,4 +34,5 @@ + install: $(TARGET) + -$(INSTALL) -d $(DESTDIR)$(bindir) + $(INSTALL) $(TARGET) $(DESTDIR)$(bindir) ++ -$(INSTALL) -d $(DESTDIR)$(mandir) + $(INSTALL) mbuffer.1 $(DESTDIR)$(mandir) diff --git a/mdev.patch b/mdev.patch new file mode 100644 index 0000000..81bad1d --- /dev/null +++ b/mdev.patch @@ -0,0 +1,130 @@ +diff -Naur busybox.orig/util-linux/Config.in busybox/util-linux/Config.in +--- busybox.orig/util-linux/Config.in 2008-03-22 09:11:36 +0000 ++++ busybox/util-linux/Config.in 2008-03-22 15:25:22 +0000 +@@ -321,6 +321,13 @@ + + For more information, please see docs/mdev.txt + ++config FEATURE_MDEV_RENAME_REGEXP ++ bool "Support regular expressions substitutions when renaming device" ++ default n ++ depends on FEATURE_MDEV_RENAME ++ help ++ Add support for regular expressions substitutions when renaming device. ++ + config FEATURE_MDEV_EXEC + bool "Support command execution at device addition/removal" + default n +diff -Naur busybox.orig/util-linux/mdev.c busybox/util-linux/mdev.c +--- busybox.orig/util-linux/mdev.c 2008-03-17 18:23:37 +0000 ++++ busybox/util-linux/mdev.c 2008-03-22 19:15:10 +0000 +@@ -21,6 +21,25 @@ + + #define MAX_SYSFS_DEPTH 3 /* prevent infinite loops in /sys symlinks */ + ++#if ENABLE_FEATURE_MDEV_RENAME_REGEXP ++static char *strsubst(const char *s, const char *str, regmatch_t *vals) ++{ ++ char *buf = xzalloc(PATH_MAX), *p = buf; ++ while (*s) { ++ if ('%' == *s) { ++ int i = (*++s-'0'); ++ int n = vals[i].rm_eo-vals[i].rm_so; ++ strncpy(p, str+vals[i].rm_so, n); ++ p += n; ++ } else { ++ *p++ = *s; ++ } ++ s++; ++ } ++ return buf; ++} ++#endif ++ + /* mknod in /dev based on a path like "/sys/block/hda/hda1" */ + static void make_device(char *path, int delete) + { +@@ -70,6 +89,9 @@ + + while ((vline = line = xmalloc_getline(fp)) != NULL) { + int field; ++#if ENABLE_FEATURE_MDEV_RENAME_REGEXP ++ regmatch_t off[10]; ++#endif + + /* A pristine copy for command execution. */ + char *orig_line; +@@ -98,16 +120,26 @@ + + /* Regex to match this device */ + regex_t match; ++#if !ENABLE_FEATURE_MDEV_RENAME_REGEXP + regmatch_t off; ++#endif + int result; + + /* Is this it? */ + xregcomp(&match, val, REG_EXTENDED); ++#if ENABLE_FEATURE_MDEV_RENAME_REGEXP ++ result = regexec(&match, device_name, 10, off, 0); ++#else + result = regexec(&match, device_name, 1, &off, 0); ++#endif + regfree(&match); + + /* If not this device, skip rest of line */ ++#if ENABLE_FEATURE_MDEV_RENAME_REGEXP ++ if (result || off[0].rm_so || off[0].rm_eo != strlen(device_name)) ++#else + if (result || off.rm_so || off.rm_eo != strlen(device_name)) ++#endif + goto next_line; + + } else if (field == 1) { +@@ -144,8 +176,14 @@ + + if (*val != '>') + ++field; +- else ++ else { ++#if ENABLE_FEATURE_MDEV_RENAME_REGEXP ++ // substitute %1..9 with off[1..9], if any ++ alias = strsubst(val + 1, device_name, off); ++#else + alias = xstrdup(val + 1); ++#endif ++ } + + } + +@@ -209,6 +247,21 @@ + char *dest; + + temp = strrchr(alias, '/'); ++#if ENABLE_FEATURE_MDEV_RENAME_REGEXP ++ // directory given -> ++ if (temp && temp[1] == '\0') { ++ // make it ++ bb_make_directory(alias, 0755, FILEUTILS_RECUR); ++ // compose device new location ++ dest = concat_path_file(alias, device_name); ++ // filename given -> ++ } else { ++ // save it ++ dest = xstrdup(alias); ++ // create parent directories ++ bb_make_directory(dirname(alias), 0755, FILEUTILS_RECUR); ++ } ++#else + if (temp) { + if (temp[1] != '\0') + /* given a file name, so rename it */ +@@ -217,7 +270,7 @@ + dest = concat_path_file(alias, device_name); + } else + dest = alias; +- ++#endif + rename(device_name, dest); // TODO: xrename? + symlink(dest, device_name); + diff --git a/metalog-0.7beta-ext2attr.patch b/metalog-0.7beta-ext2attr.patch new file mode 100644 index 0000000..43d805e --- /dev/null +++ b/metalog-0.7beta-ext2attr.patch @@ -0,0 +1,200 @@ +diff -uwr metalog-0.7beta/configure.in metalog-0.7beta-ext2attr/configure.in +--- metalog-0.7beta/configure.in 2002-04-29 23:30:00.000000000 +0200 ++++ metalog-0.7beta-ext2attr/configure.in 2002-10-30 00:35:28.000000000 +0100 +@@ -30,6 +30,7 @@ + AC_CHECK_HEADERS(unistd.h) + AC_CHECK_HEADERS(sys/time.h sys/wait.h fcntl.h sys/fcntl.h) + AC_CHECK_HEADERS(getopt.h stddef.h sys/klog.h) ++AC_CHECK_HEADERS(linux/ext2_fs.h) + + dnl Checks for types + +diff -uwr metalog-0.7beta/src/metalog.h metalog-0.7beta-ext2attr/src/metalog.h +--- metalog-0.7beta/src/metalog.h 2002-04-29 23:35:16.000000000 +0200 ++++ metalog-0.7beta-ext2attr/src/metalog.h 2002-10-30 00:44:53.000000000 +0100 +@@ -79,6 +79,16 @@ + #endif + #include + ++ ++/* PinG's ext2 patch */ ++/* Include headers if needed */ ++#if defined(__linux__) && defined(HAVE_LINUX_EXT2_FS_H) ++# define USE_EXT2 ++# include ++# include ++#endif ++ ++ + #ifdef HAVE_ALLOCA + # ifdef HAVE_ALLOCA_H + # include + +diff -uwr metalog-0.7beta/src/metalog.c metalog-0.7beta-ext2attr/src/metalogch +--- metalog-0.7beta/src/metalog.c 2002-04-29 23:35:16.000000000 +0200 ++++ metalog-0.7beta-ext2attr/src/metalog.c 2002-10-30 01:13:57.000000000 +0100 +@@ -700,6 +700,13 @@ + + static int rotateLogFiles(const char * const directory, const int maxfiles) + { ++ ++/* PinG's ext2 patch. I need a file descriptor 'n a long :op */ ++#ifdef USE_EXT2 ++ int fd; ++ long flags; ++#endif ++ + char path[PATH_MAX]; + char old_name[PATH_MAX]; + const char *name; +@@ -710,6 +717,7 @@ + int older_year, older_mon = INT_MAX, older_mday = INT_MAX, + older_hour = INT_MAX, older_min = INT_MAX, older_sec = INT_MAX; + ++ + rescan: + foundlogs = 0; + *old_name = 0; +@@ -754,6 +762,15 @@ + directory, old_name); + return -4; + } ++ ++ /* PinG's ext2 patch. Un-immutate file before unlink it ;) */ ++#ifdef USE_EXT2 ++ if ((fd = open(path,O_RDONLY))>0){ ++ flags = 0; ++ ioctl(fd,EXT2_IOC_SETFLAGS,&flags); ++ close(fd); ++ } ++#endif + if (unlink(path) < 0) { + return -2; + } +@@ -769,6 +786,14 @@ + static int writeLogLine(Output * const output, const char * const date, + const char * const prg, const char * const info) + { ++/* PinG's ext2 patch. */ ++#ifdef USE_EXT2 ++ int fd; ++ long flags; ++#endif ++ ++ ++ + time_t now = time(NULL); + + if (output == NULL || output->directory == NULL) { +@@ -787,7 +812,25 @@ + fprintf(stderr, "Can't create [%s]\n", output->directory); + return -1; + } ++ /* PinG's ext2 patch. Set noatime flag */ ++#ifdef USE_EXT2 ++ if ((fd = open(output->directory,O_RDONLY))>0){ ++ flags = EXT2_NOATIME_FL; ++ ioctl(fd,EXT2_IOC_SETFLAGS,&flags); ++ close(fd); ++ } ++#endif ++ + } else if (!S_ISDIR(st.st_mode)) { ++ /* PinG's ext2 patch. Blank flags */ ++#ifdef USE_EXT2 ++ if ((fd = open(output->directory,O_RDONLY))>0){ ++ flags = 0; ++ ioctl(fd,EXT2_IOC_SETFLAGS,&flags); ++ close(fd); ++ } ++#endif ++ + if (unlink(output->directory) < 0) { + fprintf(stderr, "Can't unlink [%s]\n", output->directory); + return -1; +@@ -800,6 +843,17 @@ + output->directory); + return -2; + } ++ ++/* PinG's ext2 patch. Set append-only & noatime flags */ ++#ifdef USE_EXT2 ++ if ((fd = open(path,O_RDONLY|O_CREAT))>0){ ++ flags = EXT2_APPEND_FL | EXT2_NOATIME_FL; ++ ioctl(fd,EXT2_IOC_SETFLAGS,&flags); ++ close(fd); ++ } ++#endif ++ ++ + if ((fp = fopen(path, "at")) == NULL) { + fprintf(stderr, "Unable to access [%s]\n", path); + return -3; +@@ -811,6 +865,15 @@ + fclose(fp); + return -2; + } ++ /* PinG's ext2 patch. */ ++#ifdef USE_EXT2 ++ if ((fd = open(path,O_RDONLY|O_CREAT))>0){ ++ flags = 0; ++ ioctl(fd,EXT2_IOC_SETFLAGS,&flags); ++ close(fd); ++ } ++#endif ++ + if ((fp_ts = fopen(path, "rt")) == NULL) { + recreate_ts: + creatime = time(NULL); +@@ -833,6 +896,15 @@ + fprintf(stderr, "Unable to close [%s]\n", path); + return -3; + } ++ /* PinG's ext2 patch. */ ++#ifdef USE_EXT2 ++ if ((fd = open(path,O_RDONLY|O_CREAT))>0){ ++ flags = EXT2_IMMUTABLE_FL | EXT2_NOATIME_FL; ++ ioctl(fd,EXT2_IOC_SETFLAGS,&flags); ++ close(fd); ++ } ++#endif ++ + output->creatime = creatime; + output->size = (off_t) ftell(fp); + output->fp = fp; +@@ -871,11 +943,33 @@ + rotateLogFiles(output->directory, output->maxfiles); + fclose(output->fp); + output->fp = NULL; ++ ++ ++/* PinG's ext2 patch. */ ++#ifdef USE_EXT2 ++ if ((fd = open(path,O_RDONLY))>0){ ++ flags = 0; ++ ioctl(fd,EXT2_IOC_SETFLAGS,&flags); ++ close(fd); ++ } ++#endif ++ ++ + if (rename(path, newpath) < 0 && unlink(path) < 0) { + fprintf(stderr, "Unable to rename [%s] to [%s]\n", + path, newpath); + return -5; + } ++ ++/* PinG's ext2 patch. Set immutable & noatime flags */ ++#ifdef USE_EXT2 ++ if ((fd = open(newpath,O_RDONLY))>0){ ++ flags = EXT2_IMMUTABLE_FL | EXT2_NOATIME_FL; ++ ioctl(fd,EXT2_IOC_SETFLAGS,&flags); ++ close(fd); ++ } ++#endif ++ + if (snprintf(path, sizeof path, "%s/" OUTPUT_DIR_TIMESTAMP, + output->directory) < 0) { + fprintf(stderr, "Path name too long for timestamp in [%s]\n", + + diff --git a/minised-build.patch b/minised-build.patch new file mode 100644 index 0000000..4881e4d --- /dev/null +++ b/minised-build.patch @@ -0,0 +1,37 @@ +Index: Makefile +=================================================================== +--- Makefile (revision 104) ++++ Makefile (working copy) +@@ -2,19 +2,23 @@ + + # If your compiler does not support this flags, just remove them. + # They only ensure that no new warning regressions make it into the source. +-CFLAGS = -Wall -Wwrite-strings ++CFLAGS += -Wall -Wwrite-strings + ++DESTDIR= + PREFIX=/usr ++BINDIR=$(PREFIX)/bin ++MANDIR=$(PREFIX)/share/man/man1 + + minised: sedcomp.o sedexec.o +- $(CC) $(LFLAGS) sedcomp.o sedexec.o -o minised ++ $(CC) $(LDFLAGS) sedcomp.o sedexec.o -o minised + + sedcomp.o: sedcomp.c sed.h + sedexec.o: sedexec.c sed.h + + install: +- install minised $(PREFIX)/bin/ +- install minised.1 $(PREFIX)/man/man1/ ++ install -d -m 755 $(DESTDIR)$(BINDIR) $(DESTDIR)$(MANDIR) ++ install -m 755 minised $(DESTDIR)$(BINDIR) ++ install -m 644 minised.1 $(DESTDIR)$(MANDIR) + + clean: + rm -f minised sedcomp.o sedexec.o +@@ -22,3 +26,4 @@ clean: + check: minised + cd tests; ./run ../minised + ++.PHONY: install clean check diff --git a/mit-krb5-no-static-USE-flag.patch b/mit-krb5-no-static-USE-flag.patch new file mode 100644 index 0000000..0aed70b --- /dev/null +++ b/mit-krb5-no-static-USE-flag.patch @@ -0,0 +1,25 @@ +Index: mit-krb5-1.5.1.ebuild +=================================================================== +RCS file: /var/cvsroot/gentoo-x86/app-crypt/mit-krb5/mit-krb5-1.5.1.ebuild,v +retrieving revision 1.3 +diff -u -p -r1.3 mit-krb5-1.5.1.ebuild +--- mit-krb5-1.5.1.ebuild 7 Nov 2006 02:45:30 -0000 1.3 ++++ mit-krb5-1.5.1.ebuild 28 Dec 2006 19:56:32 -0000 +@@ -14,7 +14,7 @@ SRC_URI="http://web.mit.edu/kerberos/dis + LICENSE="as-is" + SLOT="0" + KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86" +-IUSE="krb4 static tcl ipv6 doc" ++IUSE="krb4 tcl ipv6 doc" + + RDEPEND="!virtual/krb5 + sys-libs/com_err +@@ -41,7 +41,7 @@ src_compile() { + $(use_with krb4) \ + $(use_with tcl) \ + $(use_enable ipv6) \ +- $(use_enable static) \ ++ --enable-static \ + --enable-shared \ + --with-system-et --with-system-ss \ + --enable-dns-for-realm || die diff --git a/module-init-tools-3.2.2-handle-dupliate-aliases.patch b/module-init-tools-3.2.2-handle-dupliate-aliases.patch new file mode 100644 index 0000000..e119ce6 --- /dev/null +++ b/module-init-tools-3.2.2-handle-dupliate-aliases.patch @@ -0,0 +1,68 @@ +http://bugs.gentoo.org/149426 + +keep from blowing up when people have duplicate aliases ... the grep +ends up including new lines and with certain formed comments, hits an +infinite loop ... + +for example, the following inputs illustrates the problem: +---------------------------------------------- +# Old nvidia support ... +alias char-major-195 NVdriver +alias /dev/nvidiactl char-major-195 +alias char-major-195 nvidia +alias /dev/nvidiactl char-major-195 +# To enable Side Band Adressing: NVreg_EnableAGPSBA=1 +#options nvidia NVreg_EnableAGPSBA=1 NVreg_EnableAGPFW=1 +#options nvidia NVreg_SoftEDIDs=0 NVreg_Mobile=3 +---------------------------------------------- +alias a b +alias b a +---------------------------------------------- + +fixes from Martin Väth + +--- generate-modprobe.conf ++++ generate-modprobe.conf +@@ -65,19 +65,29 @@ + # Resolve (possibly recursive) alias: args filename alias + resolve_alias() + { +- RA_RESOLVE=`grep "^alias[ ][ ]*$2[ ]" -- $1 | awk '{ print $3 }'` ++ if [ 0$3 -gt 99 ]; then ++ echo "Infinite recursion detected; aborting after $3 tries (alias '$2')" 1>&2 ++ return 1 ++ fi ++ ++ _RA_RESOLVE=`grep "^alias[ ][ ]*$2[ ]" -- $1 | awk '{ print $3 }'` ++ RA_RESOLVE=`echo "$_RA_RESOLVE" | head -n 1` ++ if [ x"$_RA_RESOLVE" != x"$RA_RESOLVE" ]; then ++ echo "Invalid dupliate alias found for '$2' (results: `echo $_RA_RESOLVE`)" 1>&2 ++ return 1 ++ fi + if [ x"$RA_RESOLVE" = x ]; then + echo $2 + return + fi + # Recurse. +- (resolve_alias $1 "$RA_RESOLVE") ++ (resolve_alias $1 "$RA_RESOLVE" $(($3 + 1))) + } + + # Parse alias: args filename modulename aliasto. + parse_alias() + { +- PA_ALIAS=`resolve_alias $1 $3` ++ PA_ALIAS=`resolve_alias $1 $3` || exit 1 + NAME=`echo $2|sed -e 's/\(block\|char\)-major-\([0-9]\+\)$/\1-major-\2-*/'` + + echo "alias $NAME $PA_ALIAS" +@@ -180,7 +190,8 @@ + parse_options $MODULE `grab_noninstall_options $REST` + INSTALL_OPTIONS=`grab_install_options $REST` + INSTALL_COMMANDS="$INSTALL_COMMANDS $MODULE" +- eval install_$MODNAME=\"/sbin/modprobe $INSTALL_OPTIONS --ignore-install `resolve_alias $MODPROBECONF $MODULE`\" ++ INSTALL_ALIAS=`resolve_alias $MODPROBECONF "$MODULE"` || exit 1 ++ eval install_$MODNAME=\"/sbin/modprobe $INSTALL_OPTIONS --ignore-install $INSTALL_ALIAS\" + ;; + *) + parse_options $MODULE "$REST" diff --git a/module-init-tools-3.2.2-try-more-tmpdirs.patch b/module-init-tools-3.2.2-try-more-tmpdirs.patch new file mode 100644 index 0000000..df6310f --- /dev/null +++ b/module-init-tools-3.2.2-try-more-tmpdirs.patch @@ -0,0 +1,18 @@ +If /tmp is readonly, try other places instead + +http://bugs.gentoo.org/117212 + +--- module-init-tools-3.2.2/generate-modprobe.conf ++++ module-init-tools-3.2.2/generate-modprobe.conf +@@ -32,7 +32,10 @@ + # Set up output if specified. + if [ $# -eq 1 ]; then exec > $1; fi + +-MODPROBECONF=`mktemp /tmp/modprobe.XXXXXX || tempfile || echo /tmp/modprobe.$$` ++for d in $TMPDIR /tmp / ; do ++ MODPROBECONF=`mktemp $d/modprobe.XXXXXX || tempfile -d $d || $d/modprobe.$$` ++ touch $d && break ++done + trap "rm -f $MODPROBECONF" 0 + + modprobe_abort() diff --git a/module-init-tools-generate-modprobe-abort.patch b/module-init-tools-generate-modprobe-abort.patch new file mode 100644 index 0000000..f548be8 --- /dev/null +++ b/module-init-tools-generate-modprobe-abort.patch @@ -0,0 +1,40 @@ +--- generate-modprobe.conf ++++ generate-modprobe.conf +@@ -22,24 +22,30 @@ + MODPROBECONF=`mktemp /tmp/modprobe.XXXXXX || tempfile || echo /tmp/modprobe.$$` + trap "rm -f $MODPROBECONF" 0 + ++modprobe_abort() ++{ ++ echo Failed to to run modprobe. Giving up. 1>&2 ++ exit 1 ++} ++ + if [ x"$TESTING_MODPROBE_CONF" != x ]; then +- cp $TESTING_MODPROBE_CONF $MODPROBECONF ++ cp $TESTING_MODPROBE_CONF $MODPROBECONF || modprobe_abort + elif [ "$STDIN" = "1" ]; then +- cat > $MODPROBECONF ++ cat > $MODPROBECONF || modprobe_abort + elif [ -x /sbin/modprobe.old ]; then + # In sbin. +- /sbin/modprobe.old -c > $MODPROBECONF ++ /sbin/modprobe.old -c > $MODPROBECONF || modprobe_abort + elif modprobe.old -c >/dev/null 2>&1; then + # Somewhere in path. +- modprobe.old -c > $MODPROBECONF ++ modprobe.old -c > $MODPROBECONF || modprobe_abort + elif /sbin/modprobe -V 2>/dev/null | grep -q 'modprobe version'; then + # Running /sbin/modprobe gives old version. +- /sbin/modprobe -c > $MODPROBECONF ++ /sbin/modprobe -c > $MODPROBECONF || modprobe_abort + elif modprobe -V 2>/dev/null | grep -q 'modprobe version'; then + # Running modprobe gives old version. +- modprobe -c > $MODPROBECONF ++ modprobe -c > $MODPROBECONF || modprobe_abort + else +- echo Cannot find old version of modprobe. Giving up. 2>&1 ++ echo Cannot find old version of modprobe. Giving up. 1>&2 + exit 1 + fi + diff --git a/msh-pipes.patch b/msh-pipes.patch new file mode 100644 index 0000000..39b0a18 --- /dev/null +++ b/msh-pipes.patch @@ -0,0 +1,16 @@ +Index: shell/msh.c +=================================================================== +--- shell/msh.c (revision 15014) ++++ shell/msh.c (working copy) +@@ -2956,7 +2957,10 @@ forkexec(REGISTER struct op *t, int *pin + if (pin != NULL) + closepipe(pin); + +- return (pout == NULL ? setstatus(waitfor(newpid, 0)) : 0); ++ if (pout != NULL) ++ closepipe(pout); ++ ++ return (interactive ? setstatus(waitfor(newpid, 0)) : 0); + } + + /* Must be the child process, pid should be 0 */ diff --git a/nano-python-string-hilite.patch b/nano-python-string-hilite.patch new file mode 100644 index 0000000..b76090c --- /dev/null +++ b/nano-python-string-hilite.patch @@ -0,0 +1,16 @@ +Index: doc/syntax/python.nanorc +=================================================================== +RCS file: /cvsroot/nano/nano/doc/syntax/python.nanorc,v +retrieving revision 1.1 +diff -u -p -r1.1 python.nanorc +--- doc/syntax/python.nanorc 1 Jun 2006 17:23:28 -0000 1.1 ++++ doc/syntax/python.nanorc 24 Dec 2006 11:37:31 -0000 +@@ -3,6 +3,7 @@ + syntax "python" "\.py$" + icolor brightblue "def [0-9A-Z_]+" + color brightcyan "\<(and|assert|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|map|not|or|pass|print|raise|return|try|while)\>" +-color brightgreen "["'].*[^\\]["']" "["']{3}.*[^\\]["']{3}" ++color brightgreen "['][^']*[^\\][']" "[']{3}.*[^\\][']{3}" ++color brightgreen "["][^"]*[^\\]["]" "["]{3}.*[^\\]["]{3}" + color brightgreen start=""""[^"]" end=""""" start="'''[^']" end="'''" + color brightred "#.*$" diff --git a/nano-trailing-space.patch b/nano-trailing-space.patch new file mode 100644 index 0000000..cc462c2 --- /dev/null +++ b/nano-trailing-space.patch @@ -0,0 +1,39 @@ +Index: doc/syntax/asm.nanorc +=================================================================== +RCS file: /cvsroot/nano/nano/doc/syntax/asm.nanorc,v +retrieving revision 1.1 +diff -u -p -r1.1 asm.nanorc +--- doc/syntax/asm.nanorc 1 Jun 2006 17:23:28 -0000 1.1 ++++ doc/syntax/asm.nanorc 11 Apr 2007 11:20:31 -0000 +@@ -13,3 +13,5 @@ color brightyellow start=""(\\.|[^"])*\\ + ## Highlight comments + color brightblue "//.*" + color brightblue start="/\*" end="\*/" ++## Trailing space ++color ,green "[[:space:]]+$" +Index: doc/syntax/c.nanorc +=================================================================== +RCS file: /cvsroot/nano/nano/doc/syntax/c.nanorc,v +retrieving revision 1.7 +diff -u -p -r1.7 c.nanorc +--- doc/syntax/c.nanorc 2 Oct 2006 17:01:58 -0000 1.7 ++++ doc/syntax/c.nanorc 11 Apr 2007 11:20:31 -0000 +@@ -25,3 +25,6 @@ color brightyellow start=""(\\.|[^"])*\\ + ## Comment highlighting + color brightblue "//.*" + color brightblue start="/\*" end="\*/" ++ ++## Trailing space ++color ,green "[[:space:]]+$" +Index: doc/syntax/sh.nanorc +=================================================================== +RCS file: /cvsroot/nano/nano/doc/syntax/sh.nanorc,v +retrieving revision 1.3 +diff -u -p -r1.3 sh.nanorc +--- doc/syntax/sh.nanorc 8 Jun 2006 12:49:57 -0000 1.3 ++++ doc/syntax/sh.nanorc 11 Apr 2007 11:20:31 -0000 +@@ -10,3 +10,4 @@ color brightblue "\<(cat|cd|chmod|chown| + icolor brightred "\$\{?[0-9A-Z_!@#$*?-]+\}?" + color cyan "(^|[[:space:]])#.*$" + color brightyellow ""(\\.|[^"])*"" "'(\\.|[^'])*'" ++color ,green "[[:space:]]+$" diff --git a/nasm-elf-visibility.patch b/nasm-elf-visibility.patch new file mode 100644 index 0000000..dcec476 --- /dev/null +++ b/nasm-elf-visibility.patch @@ -0,0 +1,221 @@ +Index: output/outelf32.c +=================================================================== +RCS file: /cvsroot/nasm/nasm/output/outelf32.c,v +retrieving revision 1.3 +diff -u -p -r1.3 outelf32.c +--- output/outelf32.c 29 Apr 2007 20:57:53 -0000 1.3 ++++ output/outelf32.c 6 Jul 2007 05:33:12 -0000 +@@ -51,6 +51,7 @@ struct Symbol { + int32_t strpos; /* string table position of name */ + int32_t section; /* section ID of the symbol */ + int type; /* symbol type */ ++ int other; /* symbol visibility */ + int32_t value; /* address, or COMMON variable align */ + int32_t size; /* size of symbol */ + int32_t globnum; /* symbol table offset if global */ +@@ -115,9 +116,15 @@ extern struct ofmt of_elf; + + #define SYM_SECTION 0x04 + #define SYM_GLOBAL 0x10 ++#define SYM_NOTYPE 0x00 + #define SYM_DATA 0x01 + #define SYM_FUNCTION 0x02 + ++#define STV_DEFAULT 0 ++#define STV_INTERNAL 1 ++#define STV_HIDDEN 2 ++#define STV_PROTECTED 3 ++ + #define GLOBAL_TEMP_BASE 16 /* bigger than any constant sym id */ + + #define SEG_ALIGN 16 /* alignment of sections in file */ +@@ -495,6 +502,7 @@ static void elf_deflabel(char *name, int + + sym->strpos = pos; + sym->type = is_global ? SYM_GLOBAL : 0; ++ sym->other = STV_DEFAULT; + sym->size = 0; + if (segment == NO_SEG) + sym->section = SHN_ABS; +@@ -566,17 +574,38 @@ static void elf_deflabel(char *name, int + sects[sym->section - 1]->gsyms = sym; + + if (special) { +- int n = strcspn(special, " "); ++ int n = strcspn(special, " \t"); + + if (!nasm_strnicmp(special, "function", n)) + sym->type |= SYM_FUNCTION; + else if (!nasm_strnicmp(special, "data", n) || + !nasm_strnicmp(special, "object", n)) + sym->type |= SYM_DATA; ++ else if (!nasm_strnicmp(special, "notype", n)) ++ sym->type |= SYM_NOTYPE; + else + error(ERR_NONFATAL, "unrecognised symbol type `%.*s'", + n, special); +- if (special[n]) { ++ special += n; ++ ++ while (isspace(*special)) ++ ++special; ++ if (*special) { ++ n = strcspn(special, " \t"); ++ if (!nasm_strnicmp(special, "default", n)) ++ sym->other = STV_DEFAULT; ++ else if (!nasm_strnicmp(special, "internal", n)) ++ sym->other = STV_INTERNAL; ++ else if (!nasm_strnicmp(special, "hidden", n)) ++ sym->other = STV_HIDDEN; ++ else if (!nasm_strnicmp(special, "protected", n)) ++ sym->other = STV_PROTECTED; ++ else ++ n = 0; ++ special += n; ++ } ++ ++ if (*special) { + struct tokenval tokval; + expr *e; + int fwd = FALSE; +@@ -1115,7 +1144,8 @@ static struct SAA *elf_build_symtab(int3 + WRITELONG(p, sym->strpos); + WRITELONG(p, sym->value); + WRITELONG(p, sym->size); +- WRITESHORT(p, sym->type); /* local non-typed thing */ ++ WRITECHAR(p, sym->type); /* local non-typed thing */ ++ WRITECHAR(p, sym->other); + WRITESHORT(p, sym->section); + saa_wbytes(s, entry, 16L); + *len += 16; +@@ -1133,7 +1163,8 @@ static struct SAA *elf_build_symtab(int3 + WRITELONG(p, sym->strpos); + WRITELONG(p, sym->value); + WRITELONG(p, sym->size); +- WRITESHORT(p, sym->type); /* global non-typed thing */ ++ WRITECHAR(p, sym->type); /* global non-typed thing */ ++ WRITECHAR(p, sym->other); + WRITESHORT(p, sym->section); + saa_wbytes(s, entry, 16L); + *len += 16; +Index: output/outelf64.c +=================================================================== +RCS file: /cvsroot/nasm/nasm/output/outelf64.c,v +retrieving revision 1.4 +diff -u -p -r1.4 outelf64.c +--- output/outelf64.c 4 May 2007 18:47:16 -0000 1.4 ++++ output/outelf64.c 6 Jul 2007 05:33:13 -0000 +@@ -71,6 +71,7 @@ struct Symbol { + int32_t strpos; /* string table position of name */ + int32_t section; /* section ID of the symbol */ + int type; /* symbol type */ ++ int other; /* symbol visibility */ + int32_t value; /* address, or COMMON variable align */ + int32_t size; /* size of symbol */ + int32_t globnum; /* symbol table offset if global */ +@@ -126,9 +127,15 @@ extern struct ofmt of_elf64; + + #define SYM_SECTION 0x04 + #define SYM_GLOBAL 0x10 ++#define SYM_NOTYPE 0x00 + #define SYM_DATA 0x01 + #define SYM_FUNCTION 0x02 + ++#define STV_DEFAULT 0 ++#define STV_INTERNAL 1 ++#define STV_HIDDEN 2 ++#define STV_PROTECTED 3 ++ + #define GLOBAL_TEMP_BASE 16 /* bigger than any constant sym id */ + + #define SEG_ALIGN 16 /* alignment of sections in file */ +@@ -507,6 +514,7 @@ static void elf_deflabel(char *name, int + + sym->strpos = pos; + sym->type = is_global ? SYM_GLOBAL : 0; ++ sym->other = STV_DEFAULT; + sym->size = 0; + if (segment == NO_SEG) + sym->section = SHN_ABS; +@@ -578,17 +586,38 @@ static void elf_deflabel(char *name, int + sects[sym->section - 1]->gsyms = sym; + + if (special) { +- int n = strcspn(special, " "); ++ int n = strcspn(special, " \t"); + + if (!nasm_strnicmp(special, "function", n)) + sym->type |= SYM_FUNCTION; + else if (!nasm_strnicmp(special, "data", n) || + !nasm_strnicmp(special, "object", n)) + sym->type |= SYM_DATA; ++ else if (!nasm_strnicmp(special, "notype", n)) ++ sym->type |= SYM_NOTYPE; + else + error(ERR_NONFATAL, "unrecognised symbol type `%.*s'", + n, special); +- if (special[n]) { ++ special += n; ++ ++ while (isspace(*special)) ++ ++special; ++ if (*special) { ++ n = strcspn(special, " \t"); ++ if (!nasm_strnicmp(special, "default", n)) ++ sym->other = STV_DEFAULT; ++ else if (!nasm_strnicmp(special, "internal", n)) ++ sym->other = STV_INTERNAL; ++ else if (!nasm_strnicmp(special, "hidden", n)) ++ sym->other = STV_HIDDEN; ++ else if (!nasm_strnicmp(special, "protected", n)) ++ sym->other = STV_PROTECTED; ++ else ++ n = 0; ++ special += n; ++ } ++ ++ if (*special) { + struct tokenval tokval; + expr *e; + int fwd = FALSE; +@@ -1127,7 +1156,8 @@ static struct SAA *elf_build_symtab(int3 + continue; + p = entry; + WRITELONG(p, sym->strpos); +- WRITESHORT(p, sym->type); /* local non-typed thing */ ++ WRITECHAR(p, sym->type); /* local non-typed thing */ ++ WRITECHAR(p, sym->other); + WRITESHORT(p, sym->section); + WRITEDLONG(p, (int64_t)sym->value); + WRITEDLONG(p, (int64_t)sym->size); +@@ -1145,7 +1175,8 @@ static struct SAA *elf_build_symtab(int3 + continue; + p = entry; + WRITELONG(p, sym->strpos); +- WRITESHORT(p, sym->type); /* global non-typed thing */ ++ WRITECHAR(p, sym->type); /* global non-typed thing */ ++ WRITECHAR(p, sym->other); + WRITESHORT(p, sym->section); + WRITEDLONG(p, (int64_t)sym->value); + WRITEDLONG(p, (int64_t)sym->size); +Index: doc/nasmdoc.src +=================================================================== +RCS file: /cvsroot/nasm/nasm/doc/nasmdoc.src,v +retrieving revision 1.83 +diff -u -p -r1.83 nasmdoc.src +--- doc/nasmdoc.src 4 May 2007 02:16:08 -0000 1.83 ++++ doc/nasmdoc.src 6 Jul 2007 18:35:30 -0000 +@@ -4408,6 +4408,13 @@ object by suffixing the name with a colo + exports the global symbol \c{hashlookup} as a function and + \c{hashtable} as a data object. + ++Optionally, you can control the ELF visibility of the symbol. Just ++add one of the visibility keywords: \i\c{default}, \i\c{internal}, ++\i\c{hidden}, or \i\c{protected}. The default is \i\c{default} of ++course. For example, to make \c{hashlookup} hidden: ++ ++\c global hashlookup:function hidden ++ + You can also specify the size of the data associated with the + symbol, as a numeric expression (which may involve labels, and even + forward references) after the type specifier. Like this: diff --git a/nasm-underquoted-AC_PROG_MAKE_VPATHOK.patch b/nasm-underquoted-AC_PROG_MAKE_VPATHOK.patch new file mode 100644 index 0000000..a84a604 --- /dev/null +++ b/nasm-underquoted-AC_PROG_MAKE_VPATHOK.patch @@ -0,0 +1,16 @@ +Index: configure.in +=================================================================== +RCS file: /cvsroot/nasm/nasm/configure.in,v +retrieving revision 1.14 +diff -u -p -r1.14 configure.in +--- configure.in 21 Jun 2007 19:00:13 -0000 1.14 ++++ configure.in 6 Jul 2007 05:22:30 -0000 +@@ -6,7 +6,7 @@ AC_INIT(config.h.in) + AC_CONFIG_HEADERS(config.h) + + dnl Check for broken VPATH handling on older NetBSD makes. +-AC_DEFUN(AC_PROG_MAKE_VPATHOK, ++AC_DEFUN([AC_PROG_MAKE_VPATHOK], + [AC_MSG_CHECKING(whether ${MAKE-make} has sane VPATH handling) + set dummy ${MAKE-make}; ac_make=`echo "[$]2" | sed 'y%./+-%__p_%'` + AC_CACHE_VAL(ac_cv_prog_make_vpathok, diff --git a/nbd-configure-cross-compile.patch b/nbd-configure-cross-compile.patch new file mode 100644 index 0000000..433a600 --- /dev/null +++ b/nbd-configure-cross-compile.patch @@ -0,0 +1,25 @@ +Index: configure.ac +=================================================================== +--- configure.ac (revision 227) ++++ configure.ac (working copy) +@@ -49,6 +49,7 @@ fi + AC_PROG_CC + AC_PROG_CPP + AC_PROG_INSTALL ++AC_CANONICAL_HOST + AC_C_BIGENDIAN + AC_C_INLINE + AC_C_CONST +@@ -60,9 +61,9 @@ AC_CHECK_FUNCS([llseek alarm gethostbyna + AC_FUNC_FORK + AC_FUNC_SETVBUF_REVERSED + AC_MSG_CHECKING(whether client should be built) +-case "`uname`" in +- *Linux*) sbin_PROGRAMS=nbd-client +- AC_MSG_RESULT(yes) ++case $host_os in ++ linux*) sbin_PROGRAMS=nbd-client ++ AC_MSG_RESULT(yes) + ;; + *) AC_MSG_RESULT(no) ;; + esac diff --git a/nbd-configure-no-linux-types.patch b/nbd-configure-no-linux-types.patch new file mode 100644 index 0000000..799df1b --- /dev/null +++ b/nbd-configure-no-linux-types.patch @@ -0,0 +1,18 @@ +Index: configure.ac +=================================================================== +--- configure.ac (revision 227) ++++ configure.ac (working copy) +@@ -85,7 +85,13 @@ AC_TRY_COMPILE([#define u32 int + [int foo=NBD_CMD_DISC], + [AC_DEFINE(NBD_H_LINUX, 1, Set to 1 if a (2.6) nbd.h can be found in the linux directory in the search path) + NBD_H=''], ++ AC_TRY_COMPILE([#include ++ ], ++[int foo=NBD_CMD_DISC], ++ [AC_DEFINE(NBD_H_LINUX, 1, Set to 1 if a (2.6) nbd.h can be found in the linux directory in the search path) ++ NBD_H=''], + AC_MSG_ERROR(Could not find an nbd.h from 2.6 or above.) ++ ) + ) + ) + if test -f nbd.h diff --git a/nbd-gznbd-makefile-cleanup.patch b/nbd-gznbd-makefile-cleanup.patch new file mode 100644 index 0000000..d7ef1cb --- /dev/null +++ b/nbd-gznbd-makefile-cleanup.patch @@ -0,0 +1,14 @@ +Index: gznbd/Makefile +=================================================================== +--- gznbd/Makefile (revision 227) ++++ gznbd/Makefile (working copy) +@@ -1,2 +1,7 @@ +-gznbd: gznbd.c +- gcc -s -Wall -O2 -DTRACE gznbd.c -o gznbd -lz ++CC ?= gcc ++CFLAGS ?= -s -O2 ++CFLAGS += -Wall ++CPPFLAGS += -DTRACE ++LDLIBS += -lz ++ ++all: gznbd diff --git a/nbd-needs-linux-types.patch b/nbd-needs-linux-types.patch new file mode 100644 index 0000000..88838d2 --- /dev/null +++ b/nbd-needs-linux-types.patch @@ -0,0 +1,18 @@ +the nbd header uses __be32 and such types but doesnt actually include the +header that defines these things (linux/types.h); so lets include it + +Signed-off-by: Mike Frysinger + +diff --git a/include/linux/nbd.h b/include/linux/nbd.h +index e712e7d..d6b6dc0 100644 +--- a/include/linux/nbd.h ++++ b/include/linux/nbd.h +@@ -15,6 +15,8 @@ + #ifndef LINUX_NBD_H + #define LINUX_NBD_H + ++#include ++ + #define NBD_SET_SOCK _IO( 0xab, 0 ) + #define NBD_SET_BLKSIZE _IO( 0xab, 1 ) + #define NBD_SET_SIZE _IO( 0xab, 2 ) diff --git a/nbd-no-page-header.patch b/nbd-no-page-header.patch new file mode 100644 index 0000000..8e1717f --- /dev/null +++ b/nbd-no-page-header.patch @@ -0,0 +1,10 @@ +--- nbd-client.c ++++ nbd-client.c +@@ -16,7 +16,6 @@ + #include "config.h" + #include "lfs.h" + +-#include + #include + #include + #include diff --git a/netflash-cleanup.patch b/netflash-cleanup.patch new file mode 100644 index 0000000..1e4374b --- /dev/null +++ b/netflash-cleanup.patch @@ -0,0 +1,411 @@ +--- user/netflash/netflash.c ++++ user/netflash/netflash.c +@@ -80,6 +80,7 @@ + #include "fileblock.h" + #include "exit_codes.h" + #include "versioning.h" ++#include "netflash.h" + + /****************************************************************************/ + +@@ -969,9 +970,7 @@ int local_write(int fd, char *buf, int c + + /****************************************************************************/ + +-extern int tftpmain(int argc, char *argv[]); +-extern int tftpsetbinary(int argc, char *argv[]); +-extern int tftpget(int argc, char *argv[]); ++#include "tftp.h" + + /* + * Call to tftp. This will initialize tftp and do a get operation. +--- user/netflash/netflash.h ++++ user/netflash/netflash.h +@@ -0,0 +1,8 @@ ++#include ++ ++int local_creat(char *name, int flags); ++int local_fclose(FILE *fp); ++int local_fseek(FILE *fp, int offset, int whence); ++int local_putc(int ch, FILE *fp); ++int local_write(int fd, char *buf, int count); ++FILE *local_fdopen(int fd, char *flags); +--- user/netflash/tftp.c ++++ user/netflash/tftp.c +@@ -34,12 +34,22 @@ static char sccsid[] = "@(#)tftp.c 5.7 ( + + #include + #include ++#include ++#include + #include + #include ++#include + + #include "exit_codes.h" ++#include "netflash.h" ++#include "tftp.h" + +-extern int errno; ++static int tftpmakerequest(int request, char *name, struct tftphdr *tp, char *mode); ++static void tftpnak(int error); ++static void tftpstartclock(void); ++static void tftptpacket(char *s, struct tftphdr *tp, int n); ++static void tftpstopclock(void); ++static void tftpprintstats(char *direction, unsigned long amount, char *join, char *name); + + extern struct sockaddr_in tftpsin; /* filled in by main */ + extern int tftpf; /* the opened socket */ +@@ -49,7 +59,6 @@ extern int tftprexmtval; + extern int tftpmaxtimeout; + + extern struct tftphdr *tftpw_init(void); +-extern FILE *local_fdopen(int fd, char *flags); + + #define PKTSIZE SEGSIZE+4 + char tftpackbuf[PKTSIZE]; +@@ -84,7 +93,7 @@ tftpsendfile(fd, name, mode) + register int block = 0, size, n; + register unsigned long amount = 0; + struct sockaddr_in from; +- int fromlen; ++ socklen_t fromlen; + int convert; /* true if doing nl->crlf conversion */ + FILE *file; + +@@ -181,6 +190,7 @@ abort: + /* + * Receive a file. + */ ++void + tftprecvfile(fd, name, mode) + int fd; + char *name; +@@ -192,7 +202,8 @@ tftprecvfile(fd, name, mode) + u_short block = 1; + unsigned long amount = 0; + struct sockaddr_in from; +- int fromlen, firsttrip = 1; ++ socklen_t fromlen; ++ int firsttrip = 1; + FILE *file; + int convert; /* true if converting crlf -> lf */ + +@@ -288,6 +299,7 @@ abort: + tftpprintstats("Received", amount, "from", name); + } + ++static int + tftpmakerequest(request, name, tp, mode) + int request; + char *name, *mode; +@@ -327,13 +339,13 @@ struct errmsg { + * standard TFTP codes, or a UNIX errno + * offset by 100. + */ ++static void + tftpnak(error) + int error; + { + register struct tftphdr *tp; + int length; + register struct errmsg *pe; +-/* extern char *sys_errlist[]; */ + + tp = (struct tftphdr *)tftpackbuf; + tp->th_opcode = htons((u_short)ERROR); +@@ -345,7 +357,7 @@ tftpnak(error) + #ifdef EMBED + pe->e_msg = "error"; + #else +- pe->e_msg = sys_errlist[error - 100]; ++ pe->e_msg = strerror(error - 100); + #endif + tp->th_code = EUNDEF; + } +@@ -358,6 +370,7 @@ tftpnak(error) + perror("nak"); + } + ++static void + tftptpacket(s, tp, n) + char *s; + struct tftphdr *tp; +@@ -401,14 +414,17 @@ struct timeval tftptstart; + struct timeval tftptstop; + struct timezone tftpzone; + ++static void + tftpstartclock() { + gettimeofday(&tftptstart, &tftpzone); + } + ++static void + tftpstopclock() { + gettimeofday(&tftptstop, &tftpzone); + } + ++static void + tftpprintstats(direction, amount, join, name) + char *direction; + unsigned long amount; +--- user/netflash/http.c ++++ user/netflash/http.c +@@ -13,9 +13,11 @@ + #include + #include + #include ++#include + #include + #include + #include ++#include + + /****************************************************************************/ + +@@ -47,7 +49,7 @@ int openhttp(char *url) + char urlfile[256]; + char buf[256]; + char relocurl[512]; +- int fd, portnr, n, relocated; ++ int fd, portnr, relocated; + + fd = -1; + portnr = 80; +--- user/netflash/tftp.h ++++ user/netflash/tftp.h +@@ -0,0 +1,16 @@ ++/* TFTP prototypes */ ++ ++#include ++#include ++ ++int tftpsynchnet(int f); ++int tftpwriteit(FILE *file, struct tftphdr **dpp, int ct, int convert); ++int tftpwrite_behind(FILE *file, int convert); ++void tftprecvfile(int fd, char *name, char *mode); ++ ++void tftpget(int argc, char *argv[]); ++void tftpmain(int argc, char *argv[]); ++void tftpmodecmd(int argc, char *argv[]); ++void tftpsetascii(int argc, char *argv[]); ++void tftpsetbinary(int argc, char *argv[]); ++void tftpsetpeer(int argc, char *argv[]); +--- user/netflash/Makefile ++++ user/netflash/Makefile +@@ -1,3 +1,4 @@ ++CFLAGS += -Wall + + EXEC = netflash + OBJS = tftpmain.o tftp.o tftpsubs.o http.o +--- user/netflash/tftpsubs.c ++++ user/netflash/tftpsubs.c +@@ -37,6 +37,9 @@ static char sccsid[] = "@(#)tftpsubs.c 5 + #include + #include + ++#include "netflash.h" ++#include "tftp.h" ++ + #define PKTSIZE SEGSIZE+4 /* should be moved to tftp.h */ + + static struct bf { +@@ -92,7 +95,7 @@ tftpreadit(file, dpp, convert) + b = &bfs[current]; /* look at new buffer */ + if (b->counter == BF_FREE) /* if it's empty */ + read_ahead(file, convert); /* fill it */ +-/* assert(b->counter != BF_FREE); /* check */ ++// assert(b->counter != BF_FREE); /* check */ + *dpp = (struct tftphdr *)b->buf; /* set caller's ptr */ + return b->counter; + } +@@ -150,6 +153,7 @@ tftpread_ahead(file, convert) + from the queue. Calls write_behind only if next buffer not + available. + */ ++int + tftpwriteit(file, dpp, ct, convert) + FILE *file; + struct tftphdr **dpp; +@@ -170,6 +174,7 @@ tftpwriteit(file, dpp, ct, convert) + * Note spec is undefined if we get CR as last byte of file or a + * CR followed by anything else. In this case we leave it alone. + */ ++int + tftpwrite_behind(file, convert) + FILE *file; + int convert; +@@ -235,7 +240,7 @@ int f; /* socket to flush */ + int i, j = 0; + char rbuf[PKTSIZE]; + struct sockaddr_in from; +- int fromlen; ++ socklen_t fromlen; + + while (1) { + (void) ioctl(f, FIONREAD, &i); +--- user/netflash/tftpmain.c ++++ user/netflash/tftpmain.c +@@ -35,6 +35,7 @@ static char sccsid[] = "@(#)main.c 5.8 ( + #include + + #include ++#include + + #include + #include +@@ -44,8 +45,11 @@ static char sccsid[] = "@(#)main.c 5.8 ( + #include + #include + #include ++#include + + #include "exit_codes.h" ++#include "netflash.h" ++#include "tftp.h" + + #define TIMEOUT 5 /* secs between rexmt's */ + +@@ -63,19 +67,24 @@ char *tftpprompt = "tftp"; + jmp_buf tftptoplevel; + static void tftpintr(int signo); + #ifndef EMBED +-struct servent *tftpsp; ++struct servent *sp; + #endif + +-int tftpquit(), tftphelp(), tftpsetverbose(), tftpsettrace(), tftpstatus(); +-int tftpget(), tftpput(), tftpsetpeer(), tftpmodecmd(), tftpsetrexmt(), tftpsettimeout(); +-int tftpsetbinary(), tftpsetascii(); ++static void tftpgetusage(char *s); ++static void tftpmakeargv(void); ++static void tftpsetmode(char *newmode); ++#if 0 ++static void tftpquit(void); ++static void tftpsettrace(void); ++static void tftpsetverbose(void); ++#endif + + #define HELPINDENT (sizeof("connect")) + + struct cmd { + char *name; + char *help; +- int (*handler)(); ++ void (*handler)(int argc, char *argv[]); + }; + + #if 0 +@@ -115,13 +124,14 @@ struct cmd tftpcmdtab[] = { + { "timeout", tftpihelp, tftpsettimeout }, + { "?", tftphhelp, tftphelp }, + #endif +- 0 ++ { 0 } + }; + struct cmd *tftpgetcmd(); + char *tftptail(); + char *strchr(); + char *strrchr(); + ++void + tftpmain(argc, argv) + char *argv[]; + { +@@ -174,6 +184,7 @@ tftpmain(argc, argv) + + char tftphostname[100]; + ++void + tftpsetpeer(argc, argv) + int argc; + char *argv[]; +@@ -237,6 +248,7 @@ struct modes { + { 0, 0 } + }; + ++void + tftpmodecmd(argc, argv) + char *argv[]; + { +@@ -270,16 +282,19 @@ tftpmodecmd(argc, argv) + return; + } + ++void + tftpsetbinary(argc, argv) + char *argv[]; + { tftpsetmode("octet"); + } + ++void + tftpsetascii(argc, argv) + char *argv[]; + { tftpsetmode("netascii"); + } + ++static void + tftpsetmode(newmode) + char *newmode; + { +@@ -384,6 +399,7 @@ tftpputusage(s) + /* + * Receive file(s). + */ ++void + tftpget(argc, argv) + char *argv[]; + { +@@ -466,6 +482,7 @@ tftpget(argc, argv) + } + } + ++static void + tftpgetusage(s) + char * s; + { +@@ -636,6 +653,7 @@ tftpgetcmd(name) + /* + * Slice a string up into argc/argv. + */ ++static void + tftpmakeargv() + { + register char *cp; +@@ -658,13 +676,14 @@ tftpmakeargv() + *argp++ = 0; + } + ++#if 0 + /*VARARGS*/ ++static void + tftpquit() + { + exit(0); + } + +-#if 0 + /* + * Help command. + */ +@@ -694,7 +713,9 @@ tftphelp(argc, argv) + } + #endif + ++#if 0 + /*VARARGS*/ ++void + tftpsettrace() + { + tftptrace = !tftptrace; +@@ -702,8 +723,10 @@ tftpsettrace() + } + + /*VARARGS*/ ++void + tftpsetverbose() + { + tftpverbose = !tftpverbose; + printf("Verbose mode %s.\n", tftpverbose ? "on" : "off"); + } ++#endif diff --git a/netstress.patch b/netstress.patch new file mode 100644 index 0000000..3c420b3 --- /dev/null +++ b/netstress.patch @@ -0,0 +1,155 @@ +From rdunlap@xenotime.net Fri Jul 13 16:59:16 2007 +Delivered-To: vapierfilter@gmail.com +Received: by 10.114.59.18 with SMTP id h18cs257122waa; + Fri, 13 Jul 2007 13:55:32 -0700 (PDT) +Received: by 10.65.251.17 with SMTP id d17mr3739065qbs.1184360131897; + Fri, 13 Jul 2007 13:55:31 -0700 (PDT) +Return-Path: +Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) + by mx.google.com with ESMTP id e10si7683747qbe.2007.07.13.13.55.31; + Fri, 13 Jul 2007 13:55:31 -0700 (PDT) +Received-SPF: neutral (google.com: 140.211.166.183 is neither permitted nor denied by domain of ltp-list-bounces@lists.sourceforge.net) +Received: by smtp.gentoo.org (Postfix) + id BDFED64FA3; Fri, 13 Jul 2007 20:55:30 +0000 (UTC) +Delivered-To: vapier@gentoo.org +Received: from localhost (localhost [127.0.0.1]) + by smtp.gentoo.org (Postfix) with ESMTP id 8F4B364E53 + for ; Fri, 13 Jul 2007 20:55:30 +0000 (UTC) +X-Virus-Scanned: amavisd-new at gentoo.org +X-Spam-Score: -2.409 +X-Spam-Level: +X-Spam-Status: No, score=-2.409 required=5.5 tests=[AWL=0.055, + BAYES_00=-2.599, FORGED_RCVD_HELO=0.135] +Received: from smtp.gentoo.org ([127.0.0.1]) + by localhost (smtp.gentoo.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id D8grg5fy0MsY for ; + Fri, 13 Jul 2007 20:55:25 +0000 (UTC) +Received: from lists-outbound.sourceforge.net (lists-outbound.sourceforge.net [66.35.250.225]) + by smtp.gentoo.org (Postfix) with ESMTP id BCA3B64FA3 + for ; Fri, 13 Jul 2007 20:55:25 +0000 (UTC) +Received: from sc8-sf-list1-new.sourceforge.net (sc8-sf-list1-new-b.sourceforge.net [10.3.1.93]) + by sc8-sf-spam2.sourceforge.net (Postfix) with ESMTP + id 85D7C130C5; Fri, 13 Jul 2007 13:55:25 -0700 (PDT) +Received: from sc8-sf-mx1-b.sourceforge.net ([10.3.1.91] + helo=mail.sourceforge.net) + by sc8-sf-list1-new.sourceforge.net with esmtp (Exim 4.43) + id 1I9SAa-0000tB-V2 + for ltp-list@lists.sourceforge.net; Fri, 13 Jul 2007 13:55:22 -0700 +Received: from xenotime.net ([66.160.160.81]) + by mail.sourceforge.net with smtp (Exim 4.44) id 1I9SAa-0005N5-Mv + for ltp-list@lists.sourceforge.net; Fri, 13 Jul 2007 13:55:20 -0700 +Received: from midway.site ([71.117.236.25]) by xenotime.net for + ; Fri, 13 Jul 2007 13:55:16 -0700 +Date: Fri, 13 Jul 2007 13:59:16 -0700 +From: Randy Dunlap +To: ltp-list@lists.sourceforge.net +Message-Id: <20070713135916.ded7073e.rdunlap@xenotime.net> +Organization: YPO4 +X-Mailer: Sylpheed 2.4.2 (GTK+ 2.8.10; x86_64-unknown-linux-gnu) +Mime-Version: 1.0 +Subject: [LTP] [patch] fix net-stress printf format warnings +X-BeenThere: ltp-list@lists.sourceforge.net +X-Mailman-Version: 2.1.8 +Precedence: list +List-Id: Linux Test Project General Discussions + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +Sender: ltp-list-bounces@lists.sourceforge.net +Errors-To: ltp-list-bounces@lists.sourceforge.net +Status: R +X-Status: NC +X-KMail-EncryptionState: +X-KMail-SignatureState: +X-KMail-MDN-Sent: + +Fix printf format warnings: + +ns-tcpserver.c:194: warning: format '%d' expects type 'int', but argument 3 has type 'size_t' +ns-tcpserver.c:496: warning: format '%d' expects type 'int', but argument 3 has type 'size_t' + +ns-mcast_receiver.c:417: warning: format '%d' expects type 'int', but argument 3 has type 'ssize_t' + +ns-igmp_querier.c:440: warning: format '%u' expects type 'unsigned int', but argument 3 has type 'size_t' + +ns-mcast_join.c:404: warning: format '%u' expects type 'unsigned int', but argument 3 has type 'size_t' + +--- + testcases/network/stress/ns-tools/ns-igmp_querier.c | 2 +- + testcases/network/stress/ns-tools/ns-mcast_join.c | 2 +- + testcases/network/stress/ns-tools/ns-mcast_receiver.c | 2 +- + testcases/network/stress/ns-tools/ns-tcpserver.c | 4 ++-- + 4 files changed, 5 insertions(+), 5 deletions(-) + +--- ltp-full-20070630.orig/testcases/network/stress/ns-tools/ns-tcpserver.c ++++ ltp-full-20070630/testcases/network/stress/ns-tools/ns-tcpserver.c +@@ -190,7 +190,7 @@ delete_zombies(struct server_info *info_ + if (status != EXIT_SUCCESS) { + ++info_p->lost_connection; + if (debug) +- fprintf (stderr, "The number of lost conncections is %d\n", ++ fprintf (stderr, "The number of lost conncections is %zu\n", + info_p->lost_connection); + } + } +@@ -493,7 +493,7 @@ handle_client(struct server_info *info_p + if (info_p->max_connection < info_p->current_connection) { + info_p->max_connection = info_p->current_connection; + if (debug) +- fprintf (stderr, "The maximum connection is updated. The number is %d.\n", info_p->max_connection); ++ fprintf (stderr, "The maximum connection is updated. The number is %zu.\n", info_p->max_connection); + } + delete_zombies(info_p); + } +--- ltp-full-20070630.orig/testcases/network/stress/ns-tools/ns-igmp_querier.c ++++ ltp-full-20070630/testcases/network/stress/ns-tools/ns-igmp_querier.c +@@ -437,7 +437,7 @@ send_query(struct igmp_info *info_p) + start_time = time(NULL); + query_size = MY_IGMPV3_QUERY_SIZE(ntohs(info_p->query->nsrcs)); + if (debug) +- fprintf (stderr, "query size is %u\n", query_size); ++ fprintf (stderr, "query size is %zu\n", query_size); + + for(;;) { + retval = sendto(sd, info_p->query, query_size, 0, +--- ltp-full-20070630.orig/testcases/network/stress/ns-tools/ns-mcast_join.c ++++ ltp-full-20070630/testcases/network/stress/ns-tools/ns-mcast_join.c +@@ -401,7 +401,7 @@ join_group(void) + freeaddrinfo(maddr_info); + } + +- fprintf(stdout, "%u groups\n", num_group); ++ fprintf(stdout, "%zu groups\n", num_group); + fflush(stdout); + + /* Become a daemon for the next step in shell script */ +--- ltp-full-20070630.orig/testcases/network/stress/ns-tools/ns-mcast_receiver.c ++++ ltp-full-20070630/testcases/network/stress/ns-tools/ns-mcast_receiver.c +@@ -414,7 +414,7 @@ receive_mcast(struct mcast_rcv_info *inf + if (errno != EAGAIN) + fatal_error("recvfrom()"); + } else if (debug) +- fprintf(stderr, "received %d byte message\n", msglen); ++ fprintf(stderr, "received %zd byte message\n", msglen); + + if (info_p->timeout) + if (info_p->timeout < difftime(time(NULL), start_time)) + +------------------------------------------------------------------------- +This SF.net email is sponsored by DB2 Express +Download DB2 Express C - the FREE version of DB2 express and take +control of your XML. No limits. Just data. Click to get it now. +http://sourceforge.net/powerbar/db2/ +_______________________________________________ +Ltp-list mailing list +Ltp-list@lists.sourceforge.net +https://lists.sourceforge.net/lists/listinfo/ltp-list + diff --git a/newlib-ebuild-cleanup.patch b/newlib-ebuild-cleanup.patch new file mode 100644 index 0000000..0560ae2 --- /dev/null +++ b/newlib-ebuild-cleanup.patch @@ -0,0 +1,122 @@ +Index: newlib-1.14.0.ebuild +=================================================================== +RCS file: /var/cvsroot/gentoo-x86/sys-libs/newlib/newlib-1.14.0.ebuild,v +retrieving revision 1.2 +diff -u -p -r1.2 newlib-1.14.0.ebuild +--- newlib-1.14.0.ebuild 23 Aug 2006 08:55:02 -0000 1.2 ++++ newlib-1.14.0.ebuild 5 Nov 2006 23:07:17 -0000 +@@ -2,7 +2,9 @@ + # Distributed under the terms of the GNU General Public License v2 + # $Header: /var/cvsroot/gentoo-x86/sys-libs/newlib/newlib-1.14.0.ebuild,v 1.2 2006/08/23 08:55:02 mr_bones_ Exp $ + +-inherit eutils flag-o-matic gnuconfig autotools ++WANT_AUTOCONF="latest" ++WANT_AUTOMAKE="latest" ++inherit eutils autotools flag-o-matic + + export CBUILD=${CBUILD:-${CHOST}} + export CTARGET=${CTARGET:-${CHOST}} +@@ -20,7 +22,7 @@ fi + DESCRIPTION="Newlib is a C library intended for use on embedded systems" + HOMEPAGE="http://sourceware.org/newlib/" + SRC_URI="ftp://sources.redhat.com/pub/newlib/${P}.tar.gz +- mirror://gentoo/${P}-spu.patch.gz" ++ mirror://gentoo/${P}-spu.patch.gz" + + LICENSE="NEWLIB LIBGLOSS GPL-2" + [[ ${CTARGET} != ${CHOST} ]] \ +@@ -28,71 +30,51 @@ LICENSE="NEWLIB LIBGLOSS GPL-2" + || SLOT="0" + KEYWORDS="-* ~ppc64 ~ppc" + IUSE="nls threads unicode multilib" ++RESTRICT="strip" + +-DEPEND="sys-devel/gnuconfig" ++DEPEND="" + RDEPEND="" + +-RESTRICT="nostrip" +- + NEWLIBBUILD="${WORKDIR}/build" + +-alt_build_kprefix() { +- if [[ ${CBUILD} == ${CHOST} && ${CTARGET} == ${CHOST} ]] \ +- || [[ -n ${UCLIBC_AND_GLIBC} ]] +- then +- echo /usr +- else +- echo /usr/${CTARGET}/usr +- fi +-} +- + src_unpack() { + unpack ${A} +- epatch ${WORKDIR}/${P}-spu.patch +- einfo "Updating configure scripts" +- cd ${S} +- gnuconfig_update +- export WANT_AUTOCONF=2.1 +- # ugly workaround +- for a in libgloss libgloss/doc libgloss/libnosys +- do +- pushd ${S}/${a} >/dev/null +- aclocal 2>/dev/null +- autoconf 2>/dev/null +- popd >/dev/null +- done +- mkdir ${NEWLIBBUILD} ++ epatch "${WORKDIR}"/${P}-spu.patch ++ cd "${S}" ++ eautoreconf ++ mkdir -p "${NEWLIBBUILD}" + } + + src_compile() { ++ unset LDFLAGS ++ CHOST=${CTARGET} strip-unsupported-flags ++ + local myconf="" +-#hardwired to avoid breakages ++ # hardwired to avoid breakages + [[ ${CTARGET} == *-softfloat-* ]] \ + && myconf="--disable-newlib-hw-fp" \ + || myconf="--enable-newlib-hw-fp" +- +-#to the user discretion +- myconf="${myconf} `use_enable unicode newlib-mb`" +- myconf="${myconf} `use_enable nls`" +- myconf="${myconf} `use_enable multilib`" + [[ ${CTARGET} == "spu" ]] \ + && myconf="${myconf} --disable-threads" \ +- || myconf="${myconf} `use_enable threads`" ++ || myconf="${myconf} $(use_enable threads)" + +- cd ${NEWLIBBUILD} ++ cd "${NEWLIBBUILD}" + +- ../${P}/configure \ +- --host=${CHOST} \ +- --target=${CTARGET} \ +- --prefix=/usr \ +- ${myconf} || die "econf failed" ++ ECONF_SOURCE=${S} \ ++ econf \ ++ --host=${CTARGET} \ ++ $(use_enable unicode newlib-mb) \ ++ $(use_enable nls) \ ++ $(use_enable multilib) \ ++ ${myconf} \ ++ || die "econf failed" + emake || die "emake failed" + } + + src_install() { +- cd ${NEWLIBBUILD} +- emake -j1 DESTDIR=${D} install ++ cd "${NEWLIBBUILD}" ++ emake -j1 DESTDIR="${D}" install + env -uRESTRICT CHOST=${CTARGET} prepallstrip + # minor hack to keep things clean +- rm -fR ${D}/usr/info ++ rm -fR "${D}"/usr/info + } diff --git a/nfs-utils-1.1.2-rpcgen-ioctl.patch b/nfs-utils-1.1.2-rpcgen-ioctl.patch new file mode 100644 index 0000000..d948ccc --- /dev/null +++ b/nfs-utils-1.1.2-rpcgen-ioctl.patch @@ -0,0 +1,12 @@ +--- tools/rpcgen/rpc_main.c ++++ tools/rpcgen/rpc_main.c +@@ -548,6 +548,9 @@ + #ifndef linux + if( !tirpcflag && inetdflag ) + f_print(fout, "#include /* TIOCNOTTY */\n"); ++#else ++ if( !tirpcflag ) ++ f_print(fout, "#include /* TIOCNOTTY */\n"); + #endif + if( Cflag && (inetdflag || pmflag ) ) { + f_print(fout, "#ifdef __cplusplus\n"); diff --git a/nfs-utils-autotools.patch b/nfs-utils-autotools.patch new file mode 100644 index 0000000..71bc763 --- /dev/null +++ b/nfs-utils-autotools.patch @@ -0,0 +1,42 @@ +--- autogen.sh ++++ autogen.sh +@@ -1,4 +1,4 @@ +-#!/bin/sh ++#!/bin/sh -e + + echo -n cleaning up . + +--- Makefile.am ++++ Makefile.am +@@ -35,10 +35,13 @@ EXTRA_DIST = \ + debian/nhfsstone.prerm \ + debian/rules \ + \ ++ aclocal/bsdsignals.m4 \ + aclocal/nfs-utils.m4 \ + aclocal/kerberos5.m4 \ + aclocal/tcp-wrappers.m4 + ++ACLOCAL_AMFLAGS = -I aclocal ++ + install-data-hook: + if [ ! -d $(DESTDIR)$(statedir) ]; then mkdir -p $(DESTDIR)$(statedir); fi + touch $(DESTDIR)$(statedir)/xtab; chmod 644 $(DESTDIR)$(statedir)/xtab +--- aclocal/bsdsignals.m4 ++++ aclocal/bsdsignals.m4 +@@ -23,7 +23,14 @@ AC_DEFUN([AC_BSD_SIGNALS], [ + kill(getpid(), SIGHUP); kill(getpid(), SIGHUP); + return (counter == 2)? 0 : 1; + } +- ], knfsd_cv_bsd_signals=yes, knfsd_cv_bsd_signals=no)]) dnl ++ ], knfsd_cv_bsd_signals=yes, knfsd_cv_bsd_signals=no, ++ [ ++ case "$host_os" in ++ *linux*) knfsd_cv_bsd_signals=no;; ++ *bsd*) knfsd_cv_bsd_signals=yes;; ++ *) AC_MSG_ERROR([unable to guess signal semantics for $host_os; please set knfsd_cv_bsd_signals]);; ++ esac ++ ])]) dnl + AC_MSG_RESULT($knfsd_cv_bsd_signals) + test $knfsd_cv_bsd_signals = yes && AC_DEFINE(HAVE_BSD_SIGNALS, 1, [Define this if you want to use BSD signal semantics]) + ])dnl diff --git a/nfsd-man-see-also-exports.patch b/nfsd-man-see-also-exports.patch new file mode 100644 index 0000000..1f084cf --- /dev/null +++ b/nfsd-man-see-also-exports.patch @@ -0,0 +1,10 @@ +--- utils/nfsd/nfsd.man ++++ utils/nfsd/nfsd.man +@@ -38,6 +38,7 @@ the + program. + .SH SEE ALSO + .BR rpc.mountd (8), ++.BR exports (5), + .BR exportfs (8), + .BR rpc.rquotad (8), + .BR nfsstat (8). diff --git a/nommu-map-list-debug.patch b/nommu-map-list-debug.patch new file mode 100644 index 0000000..7c23af2 --- /dev/null +++ b/nommu-map-list-debug.patch @@ -0,0 +1,94 @@ +--- fs/proc/task_nommu.c ++++ fs/proc/task_nommu.c.old +@@ -145,6 +145,8 @@ + seq_printf(m, "%*c", len, ' '); + } + ++#define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s:%i: " fmt "\n", __FUNCTION__, __LINE__, ## args) ++ + static int show_map(struct seq_file *m, void *v) + { + struct vm_list_struct *vml = v; +@@ -157,6 +159,8 @@ + dev_t dev = 0; + int len; + ++DPRINTK("!!! BOOYA"); ++ + if (file) { + struct inode *inode = vma->vm_file->f_dentry->d_inode; + dev = inode->i_sb->s_dev; +@@ -209,12 +213,15 @@ + struct mm_struct *mm; + struct vm_list_struct *vml; + loff_t l = *pos; ++DPRINTK("!!! BOOYA l=%i", (int)l); + + mm = get_task_mm(task); + if (!mm) + return NULL; + ++DPRINTK("!!! BOOYA down_read(sem)"); + down_read(&mm->mmap_sem); ++DPRINTK("!!! BOOYA"); + + /* + * Check the vml index is within the range and do +@@ -228,38 +235,57 @@ + } + + if (vml) ++{ ++DPRINTK("!!! BOOYA <-- exit"); + return vml; ++} + + /* End of vmls has been reached */ ++DPRINTK("!!! BOOYA up_read(sem)"); + up_read(&mm->mmap_sem); ++DPRINTK("!!! BOOYA mmput(mm)"); + mmput(mm); + ++DPRINTK("!!! BOOYA <-- exit"); + return NULL; + } + static void m_stop(struct seq_file *m, void *v) + { + struct task_struct *task = m->private; + struct mm_struct *mm; ++DPRINTK("!!! BOOYA --> enter"); + + if (!v) + return; + + mm = get_task_mm(task); + if (!mm) ++{ ++DPRINTK("!!! BOOYA <-- exit"); + return; ++} + ++DPRINTK("!!! BOOYA up_read(sem)"); + up_read(&mm->mmap_sem); ++DPRINTK("!!! BOOYA mmput(mm)"); + mmput(mm); ++DPRINTK("!!! BOOYA <-- exit"); + } + static void *m_next(struct seq_file *m, void *v, loff_t *pos) + { + struct vm_list_struct *vml = v; ++DPRINTK("!!! BOOYA"); + + (*pos)++; + if (vml && vml->next) ++{ ++DPRINTK("!!! BOOYA"); + return vml->next; ++} + ++DPRINTK("!!! BOOYA"); + m_stop(m, vml); ++DPRINTK("!!! BOOYA"); + return NULL; + } + struct seq_operations proc_pid_maps_op = { diff --git a/nommu-map-list.patch b/nommu-map-list.patch new file mode 100644 index 0000000..d6b5b2b --- /dev/null +++ b/nommu-map-list.patch @@ -0,0 +1,165 @@ +--- linux-2.6.x/mm/nommu.c ++++ linux-2.6.x/mm/nommu.c +@@ -421,6 +421,10 @@ static int validate_mmap_request(struct + if ((pgoff + (len >> PAGE_SHIFT)) < pgoff) + return -EOVERFLOW; + ++ /* Too many mappings? */ ++ if (current->mm->map_count > sysctl_max_map_count) ++ return -ENOMEM; ++ + if (file) { + /* validate file mapping requests */ + struct address_space *mapping; +@@ -853,6 +857,7 @@ unsigned long do_mmap_pgoff(struct file + + vml->next = current->mm->context.vmlist; + current->mm->context.vmlist = vml; ++ current->mm->map_count++; + + up_write(&nommu_vma_sem); + +@@ -961,6 +966,7 @@ int do_munmap(struct mm_struct *mm, unsi + + update_hiwater_vm(mm); + mm->total_vm -= len >> PAGE_SHIFT; ++ mm->map_count--; + + #ifdef DEBUG + show_process_blocks(); +--- linux-2.6.x/fs/proc/task_nommu.c ++++ linux-2.6.x/fs/proc/task_nommu.c +@@ -137,23 +137,129 @@ out: + return result; + } + +-/* +- * Albert D. Cahalan suggested to fake entries for the traditional +- * sections here. This might be worth investigating. +- */ ++static void pad_len_spaces(struct seq_file *m, int len) ++{ ++ len = 25 + sizeof(void*) * 6 - len; ++ if (len < 1) ++ len = 1; ++ seq_printf(m, "%*c", len, ' '); ++} ++ + static int show_map(struct seq_file *m, void *v) + { ++ struct vm_list_struct *vml = v; ++ struct vm_area_struct *vma = vml->vma; ++ struct task_struct *task = m->private; ++ struct mm_struct *mm = get_task_mm(task); ++ struct file *file = vma->vm_file; ++ int flags = vma->vm_flags; ++ unsigned long ino = 0; ++ dev_t dev = 0; ++ int len; ++ ++ if (file) { ++ struct inode *inode = vma->vm_file->f_dentry->d_inode; ++ dev = inode->i_sb->s_dev; ++ ino = inode->i_ino; ++ } ++ ++ seq_printf(m, "%08lx-%08lx %c%c%c%c %08lx %02x:%02x %lu %n", ++ vma->vm_start, ++ vma->vm_end, ++ flags & VM_READ ? 'r' : '-', ++ flags & VM_WRITE ? 'w' : '-', ++ flags & VM_EXEC ? 'x' : '-', ++ flags & VM_MAYSHARE ? 's' : 'p', ++ vma->vm_pgoff << PAGE_SHIFT, ++ MAJOR(dev), MINOR(dev), ino, &len); ++ ++ /* ++ * Print the dentry name for named mappings, and a ++ * special [heap] marker for the heap: ++ */ ++ if (file) { ++ pad_len_spaces(m, len); ++ seq_path(m, file->f_vfsmnt, file->f_dentry, "\n"); ++ } else { ++ if (mm) { ++ if (vma->vm_start <= mm->start_brk && ++ vma->vm_end >= mm->brk) { ++ pad_len_spaces(m, len); ++ seq_puts(m, "[heap]"); ++ } else { ++ if (vma->vm_start <= mm->start_stack && ++ vma->vm_end >= mm->start_stack) { ++ ++ pad_len_spaces(m, len); ++ seq_puts(m, "[stack]"); ++ } ++ } ++ } else { ++ pad_len_spaces(m, len); ++ seq_puts(m, "[vdso]"); ++ } ++ } ++ seq_putc(m, '\n'); ++ + return 0; + } + static void *m_start(struct seq_file *m, loff_t *pos) + { ++ struct task_struct *task = m->private; ++ struct mm_struct *mm; ++ struct vm_list_struct *vml; ++ loff_t l = *pos; ++ ++ mm = get_task_mm(task); ++ if (!mm) ++ return NULL; ++ ++ down_read(&mm->mmap_sem); ++ ++ /* ++ * Check the vml index is within the range and do ++ * sequential scan until m_index. ++ */ ++ vml = NULL; ++ if ((unsigned long)l < mm->map_count) { ++ vml = mm->context.vmlist; ++ while (l-- && vml) ++ vml = vml->next; ++ } ++ ++ if (vml) ++ return vml; ++ ++ /* End of vmls has been reached */ ++ up_read(&mm->mmap_sem); ++ mmput(mm); ++ + return NULL; + } + static void m_stop(struct seq_file *m, void *v) + { ++ struct task_struct *task = m->private; ++ struct mm_struct *mm; ++ ++ if (!v) ++ return; ++ ++ mm = get_task_mm(task); ++ if (!mm) ++ return; ++ ++ up_read(&mm->mmap_sem); ++ mmput(mm); + } + static void *m_next(struct seq_file *m, void *v, loff_t *pos) + { ++ struct vm_list_struct *vml = v; ++ ++ (*pos)++; ++ if (vml && vml->next) ++ return vml->next; ++ ++ m_stop(m, vml); + return NULL; + } + struct seq_operations proc_pid_maps_op = { diff --git a/nommu-process-vm.patch b/nommu-process-vm.patch new file mode 100644 index 0000000..b782318 --- /dev/null +++ b/nommu-process-vm.patch @@ -0,0 +1,176 @@ +--- kernel/ptrace.c ++++ kernel/ptrace.c +@@ -207,60 +207,6 @@ int ptrace_detach(struct task_struct *ch + return 0; + } + +-/* +- * Access another process' address space. +- * Source/target buffer must be kernel space, +- * Do not walk the page table directly, use get_user_pages +- */ +- +-int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write) +-{ +- struct mm_struct *mm; +- struct vm_area_struct *vma; +- struct page *page; +- void *old_buf = buf; +- +- mm = get_task_mm(tsk); +- if (!mm) +- return 0; +- +- down_read(&mm->mmap_sem); +- /* ignore errors, just check how much was sucessfully transfered */ +- while (len) { +- int bytes, ret, offset; +- void *maddr; +- +- ret = get_user_pages(tsk, mm, addr, 1, +- write, 1, &page, &vma); +- if (ret <= 0) +- break; +- +- bytes = len; +- offset = addr & (PAGE_SIZE-1); +- if (bytes > PAGE_SIZE-offset) +- bytes = PAGE_SIZE-offset; +- +- maddr = kmap(page); +- if (write) { +- copy_to_user_page(vma, page, addr, +- maddr + offset, buf, bytes); +- set_page_dirty_lock(page); +- } else { +- copy_from_user_page(vma, page, addr, +- buf, maddr + offset, bytes); +- } +- kunmap(page); +- page_cache_release(page); +- len -= bytes; +- buf += bytes; +- addr += bytes; +- } +- up_read(&mm->mmap_sem); +- mmput(mm); +- +- return buf - old_buf; +-} +- + int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst, int len) + { + int copied = 0; +--- mm/memory.c ++++ mm/memory.c +@@ -2445,3 +2445,56 @@ int in_gate_area_no_task(unsigned long a + } + + #endif /* __HAVE_ARCH_GATE_AREA */ ++ ++/* ++ * Access another process' address space. ++ * Source/target buffer must be kernel space, ++ * Do not walk the page table directly, use get_user_pages ++ */ ++int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write) ++{ ++ struct mm_struct *mm; ++ struct vm_area_struct *vma; ++ struct page *page; ++ void *old_buf = buf; ++ ++ mm = get_task_mm(tsk); ++ if (!mm) ++ return 0; ++ ++ down_read(&mm->mmap_sem); ++ /* ignore errors, just check how much was sucessfully transfered */ ++ while (len) { ++ int bytes, ret, offset; ++ void *maddr; ++ ++ ret = get_user_pages(tsk, mm, addr, 1, ++ write, 1, &page, &vma); ++ if (ret <= 0) ++ break; ++ ++ bytes = len; ++ offset = addr & (PAGE_SIZE-1); ++ if (bytes > PAGE_SIZE-offset) ++ bytes = PAGE_SIZE-offset; ++ ++ maddr = kmap(page); ++ if (write) { ++ copy_to_user_page(vma, page, addr, ++ maddr + offset, buf, bytes); ++ set_page_dirty_lock(page); ++ } else { ++ copy_from_user_page(vma, page, addr, ++ buf, maddr + offset, bytes); ++ } ++ kunmap(page); ++ page_cache_release(page); ++ len -= bytes; ++ buf += bytes; ++ addr += bytes; ++ } ++ up_read(&mm->mmap_sem); ++ mmput(mm); ++ ++ return buf - old_buf; ++} +--- mm/nommu.c ++++ mm/nommu.c +@@ -1213,3 +1213,51 @@ struct page *filemap_nopage(struct vm_ar + BUG(); + return NULL; + } ++ ++/* ++ * Access another process' address space. ++ * - source/target buffer must be kernel space ++ */ ++int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write) ++{ ++ struct vm_list_struct *vml; ++ struct vm_area_struct *vma; ++ struct mm_struct *mm; ++ ++ if (addr + len < addr) ++ return 0; ++ ++ mm = get_task_mm(tsk); ++ if (!mm) ++ return 0; ++ ++ down_read(&mm->mmap_sem); ++ ++ /* the access must start within one of the target process's mappings */ ++ for (vml = mm->context.vmlist; vml; vml = vml->next) { ++ if (addr >= vml->vma->vm_start && addr < vml->vma->vm_end) ++ break; ++ } ++ ++ if (vml) { ++ vma = vml->vma; ++ ++ /* don't overrun this mapping */ ++ if (addr + len >= vma->vm_end) ++ len = vma->vm_end - addr; ++ ++ /* only read or write mappings where it is permitted */ ++ if (write && vma->vm_flags & VM_WRITE) ++ len -= copy_to_user((void *) addr, buf, len); ++ else if (!write && vma->vm_flags & VM_READ) ++ len -= copy_from_user(buf, (void *) addr, len); ++ else ++ len = 0; ++ } else { ++ len = 0; ++ } ++ ++ up_read(&mm->mmap_sem); ++ mmput(mm); ++ return len; ++} diff --git a/ode-autogen-sanity.patch b/ode-autogen-sanity.patch new file mode 100644 index 0000000..63f4302 --- /dev/null +++ b/ode-autogen-sanity.patch @@ -0,0 +1,22 @@ +Index: autogen.sh +=================================================================== +--- autogen.sh (revision 987) ++++ autogen.sh (working copy) +@@ -29,13 +29,13 @@ echo "Please make sure that you use auto + echo "Warnings about underquoted definitions are harmless" + + echo "Running aclocal" +-aclocal -I . ++aclocal -I . || exit 1 + echo "Running autoheader" +-autoheader ++autoheader || exit 1 + echo "Running automake" +-automake --foreign --include-deps --add-missing --copy ++automake --foreign --include-deps --add-missing --copy || exit 1 + echo "Running autoconf" +-autoconf ++autoconf || exit 1 + + #./configure $* + diff --git a/ode-configure-touchups.patch b/ode-configure-touchups.patch new file mode 100644 index 0000000..7237f14 --- /dev/null +++ b/ode-configure-touchups.patch @@ -0,0 +1,48 @@ +Index: configure.in +=================================================================== +--- configure.in (revision 987) ++++ configure.in (working copy) +@@ -33,9 +33,10 @@ AC_HEADER_STDBOOL + AC_PROG_RANLIB + AC_TYPE_SIZE_T + +-AC_ARG_WITH(arch, +-[ --with-arch=[arch] build for $arch, where arch is any of the -march flags passed to gcc, without the -march, for example --with-arch=pentium3], ++AC_ARG_WITH(arch,AC_HELP_STRING([--with-arch=[arch]], ++[build for $arch, where arch is any of the -march flags passed to gcc, without the -march, for example --with-arch=pentium3]), + arch=$withval,arch=no) ++ARCHFLAGS="" + if test "x$arch" != xno + then + ARCHFLAGS="-march=$arch" +@@ -241,12 +242,21 @@ then + CPPFLAGS="-fomit-frame-pointer -ffast-math" + CXXFLAGS="-fomit-frame-pointer -ffast-math" + AC_DEFINE(dNODEBUG,,[Disable debug output]) +-else ++fi ++AC_MSG_RESULT($release) ++ ++AC_MSG_CHECKING(if building a debug library) ++AC_ARG_ENABLE(debug,AC_HELP_STRING([--enable-debug], ++[build a debug library with -g]), ++debug=$enableval,debug=no) ++if test "x$debug" == xyes ++then + CFLAGS="-g" + CPPFLAGS="-g" + CXXFLAGS="-g" + fi +-AC_MSG_RESULT($release) ++AC_MSG_RESULT($debug) ++ + + dnl Check variable type sizes + AC_CHECK_SIZEOF(char) +@@ -477,5 +487,6 @@ echo " Use gyroscopic term: $gyrosc + echo " Is this a Pentium: $pentium" + echo " Is the CPU x86-64: $cpu64" + echo " Is this a release build: $release" ++echo " Is this a debug build: $debug" + echo " Headers will be installed in $prefix/include/ode" + echo " Libraries will be installed in $prefix/lib" diff --git a/ode-empty-x-flags.patch b/ode-empty-x-flags.patch new file mode 100644 index 0000000..2059f36 --- /dev/null +++ b/ode-empty-x-flags.patch @@ -0,0 +1,17 @@ +Index: configure.in +=================================================================== +--- configure.in (revision 1360) ++++ configure.in (working copy) +@@ -333,10 +333,10 @@ AC_SUBST(SHARED_LDFLAGS) + dnl Check for AC_PATH_X variables + XINCLUDES= + XLIBRARIES= +-if test "X$x_includes" != "XNONE" || "X$x_includes" != "X"; then ++if test "X$x_includes" != "XNONE" -a "X$x_includes" != "X"; then + XINCLUDES="-I$x_includes" + fi +-if test "X$x_libraries" != "XNONE" || "X$x_libraries" != "X"; then ++if test "X$x_libraries" != "XNONE" -a "X$x_libraries" != "X"; then + XLIBRARIES="-L$x_libraries" + fi + AC_SUBST(XINCLUDES) diff --git a/openobex-check-for-EOF.patch b/openobex-check-for-EOF.patch new file mode 100644 index 0000000..c271e87 --- /dev/null +++ b/openobex-check-for-EOF.patch @@ -0,0 +1,16 @@ +Index: apps/obex_test.c +=================================================================== +RCS file: /cvsroot/openobex/openobex/apps/obex_test.c,v +retrieving revision 1.34 +diff -u -p -r1.34 obex_test.c +--- apps/obex_test.c 2 Jun 2007 05:25:32 -0000 1.34 ++++ apps/obex_test.c 22 Jun 2007 09:12:21 -0000 +@@ -345,6 +345,8 @@ int main (int argc, char *argv[]) + while (!end) { + printf("> "); + num = scanf("%s", cmd); ++ if (num == EOF) ++ break; + switch (cmd[0] | 0x20) { + case 'q': + end=1; diff --git a/openobex-test-usage.patch b/openobex-test-usage.patch new file mode 100644 index 0000000..324540e --- /dev/null +++ b/openobex-test-usage.patch @@ -0,0 +1,50 @@ +Index: apps/obex_test.c +=================================================================== +RCS file: /cvsroot/openobex/openobex/apps/obex_test.c,v +retrieving revision 1.34 +diff -u -p -r1.34 obex_test.c +--- apps/obex_test.c 2 Jun 2007 05:25:32 -0000 1.34 ++++ apps/obex_test.c 22 Jun 2007 10:44:35 -0000 +@@ -191,6 +191,22 @@ int main (int argc, char *argv[]) + char *port; + obex_ctrans_t custfunc; + ++ if( (argc == 2) && (strcmp(argv[1], "-h") == 0 ) ) { ++ printf( ++ "Usage: obex_test [options]\n" ++ "\n" ++ "Options:\n" ++ " -s [tty] Use Cable Transport (Sony-Ericsson phones/DCU-11 cable)\n" ++ " -r [tty] Use Cable Transport for R320\n" ++ " -i Use TCP transport\n" ++ " -b [addr] [chan] Use BFB Cable Obex transport\n" ++ " -u [interface] Use USB transport\n" ++ "\n" ++ "If no transport is selected, IrDA is used.\n" ++ ); ++ return 0; ++ } ++ + if( (argc == 2 || argc ==3) && (strcmp(argv[1], "-s") == 0 ) ) + cobex = TRUE; + if( (argc == 2 || argc ==3) && (strcmp(argv[1], "-r") == 0 ) ) { +@@ -346,6 +362,19 @@ int main (int argc, char *argv[]) + printf("> "); + num = scanf("%s", cmd); + switch (cmd[0] | 0x20) { ++ case 'h': ++ printf( ++ "Commands:\n" ++ " c - connect\n" ++ " d - disconnect\n" ++ " g - get\n" ++ " p - put\n" ++ " q - quit\n" ++ " s - server\n" ++ " t - set path\n" ++ " x - push\n" ++ ); ++ break; + case 'q': + end=1; + break; diff --git a/openocd-9999.ebuild.diff b/openocd-9999.ebuild.diff new file mode 100644 index 0000000..3af3865 --- /dev/null +++ b/openocd-9999.ebuild.diff @@ -0,0 +1,16 @@ +--- /usr/portage/dev-embedded/openocd/openocd-9999.ebuild 2008-06-04 13:05:41.000000000 -0400 ++++ /usr/local/portage/dev-embedded/openocd/openocd-9999.ebuild 2008-10-26 11:12:02.000000000 -0400 +@@ -24,6 +24,13 @@ + ewarn "You enabled libftdi but not ft2232!" + ewarn "libftdi is only used for ft2232, so this is meaningless!" + fi ++ ++ if use ft2232 && has_multilib_profile ; then ++ ABI="x86" ++ if use ftdi ; then ++ die "ft2232 is x86 and ftdi is amd64, choose one or the other!" ++ fi ++ fi + } + + src_unpack() { diff --git a/openssh-4.4p1pkcs11-0.17.patch b/openssh-4.4p1pkcs11-0.17.patch new file mode 100644 index 0000000..f78030c --- /dev/null +++ b/openssh-4.4p1pkcs11-0.17.patch @@ -0,0 +1,17956 @@ +diff -urNp openssh-4.4p1/authfd.c openssh-4.4p1+pkcs11-0.17/authfd.c +--- openssh-4.4p1/authfd.c 2006-09-01 08:38:36.000000000 +0300 ++++ openssh-4.4p1+pkcs11-0.17/authfd.c 2006-10-12 13:59:59.000000000 +0200 +@@ -669,3 +669,79 @@ decode_reply(int type) + /* NOTREACHED */ + return 0; + } ++ ++#ifndef SSH_PKCS11_DISABLED ++ ++int ++ssh_pkcs11_add_provider (AuthenticationConnection *auth, const char *provider, ++ int protected_authentication, const char *sign_mode, int cert_private) ++{ ++ Buffer msg; ++ int type; ++ int code; ++ ++ code = SSH_AGENTC_PKCS11_ADD_PROVIDER; ++ ++ buffer_init(&msg); ++ buffer_put_char(&msg, code); ++ buffer_put_cstring(&msg, provider); ++ buffer_put_int(&msg, protected_authentication); ++ buffer_put_cstring(&msg, sign_mode == NULL ? "auto" : sign_mode); ++ buffer_put_int(&msg, cert_private); ++ ++ if (ssh_request_reply(auth, &msg, &msg) == 0) { ++ buffer_free(&msg); ++ return 0; ++ } ++ type = buffer_get_char(&msg); ++ buffer_free(&msg); ++ return decode_reply(type); ++} ++ ++int ++ssh_pkcs11_id (AuthenticationConnection *auth, const pkcs11_identity *id, int remove) ++{ ++ Buffer msg; ++ int type; ++ int code; ++ ++ code = remove ? SSH_AGENTC_PKCS11_REMOVE_ID : SSH_AGENTC_PKCS11_ADD_ID; ++ ++ buffer_init(&msg); ++ buffer_put_char(&msg, code); ++ buffer_put_cstring(&msg, id->id); ++ buffer_put_int(&msg, id->pin_cache_period); ++ buffer_put_cstring(&msg, id->cert_file == NULL ? "" : id->cert_file); ++ ++ if (ssh_request_reply(auth, &msg, &msg) == 0) { ++ buffer_free(&msg); ++ return 0; ++ } ++ type = buffer_get_char(&msg); ++ buffer_free(&msg); ++ return decode_reply(type); ++} ++ ++int ++ssh_pkcs11_set_ask_pin (AuthenticationConnection *auth, const char *pin_prog) ++{ ++ Buffer msg; ++ int type; ++ int code; ++ ++ code = SSH_AGENTC_PKCS11_SET_ASK_PIN; ++ ++ buffer_init(&msg); ++ buffer_put_char(&msg, code); ++ buffer_put_cstring(&msg, pin_prog); ++ ++ if (ssh_request_reply(auth, &msg, &msg) == 0) { ++ buffer_free(&msg); ++ return 0; ++ } ++ type = buffer_get_char(&msg); ++ buffer_free(&msg); ++ return decode_reply(type); ++} ++ ++#endif /* SSH_PKCS11_DISABLED */ +diff -urNp openssh-4.4p1/authfd.h openssh-4.4p1+pkcs11-0.17/authfd.h +--- openssh-4.4p1/authfd.h 2006-08-05 05:39:39.000000000 +0300 ++++ openssh-4.4p1+pkcs11-0.17/authfd.h 2006-10-12 13:57:49.000000000 +0200 +@@ -16,6 +16,8 @@ + #ifndef AUTHFD_H + #define AUTHFD_H + ++#include "pkcs11.h" ++ + /* Messages for the authentication agent connection. */ + #define SSH_AGENTC_REQUEST_RSA_IDENTITIES 1 + #define SSH_AGENT_RSA_IDENTITIES_ANSWER 2 +@@ -49,6 +51,11 @@ + #define SSH2_AGENTC_ADD_ID_CONSTRAINED 25 + #define SSH_AGENTC_ADD_SMARTCARD_KEY_CONSTRAINED 26 + ++#define SSH_AGENTC_PKCS11_ADD_PROVIDER 27 ++#define SSH_AGENTC_PKCS11_ADD_ID 28 ++#define SSH_AGENTC_PKCS11_REMOVE_ID 29 ++#define SSH_AGENTC_PKCS11_SET_ASK_PIN 30 ++ + #define SSH_AGENT_CONSTRAIN_LIFETIME 1 + #define SSH_AGENT_CONSTRAIN_CONFIRM 2 + +@@ -92,4 +99,11 @@ int + ssh_agent_sign(AuthenticationConnection *, Key *, u_char **, u_int *, u_char *, + u_int); + ++#ifndef SSH_PKCS11_DISABLED ++int ssh_pkcs11_add_provider (AuthenticationConnection *, const char *, ++ int, const char *, int); ++int ssh_pkcs11_id (AuthenticationConnection *, const pkcs11_identity *, int remove); ++int ssh_pkcs11_set_ask_pin (AuthenticationConnection *, const char *); ++#endif /* SSH_PKCS11_DISABLED */ ++ + #endif /* AUTHFD_H */ +diff -urNp openssh-4.4p1/ChangeLog.pkcs11 openssh-4.4p1+pkcs11-0.17/ChangeLog.pkcs11 +--- openssh-4.4p1/ChangeLog.pkcs11 1970-01-01 02:00:00.000000000 +0200 ++++ openssh-4.4p1+pkcs11-0.17/ChangeLog.pkcs11 2006-10-23 17:36:52.000000000 +0200 +@@ -0,0 +1,49 @@ ++20061023 ++ - (alonbl) Removed logit from ssh-agent, thanks to Denniston, Todd. ++ - (alonbl) Release 0.17 ++ ++20061020 ++ - (alonbl) Major modification of ssh-add command-line parameters. ++ Now, a complete serialized certificate needs to be specified, this ++ in order to allow people to add id without forcing card to be available. ++ But to allow complete silent addition a certificate file also needed. ++ --pkcs11-show-ids is used in order to get a list of resources. ++ --pkcs11-add-id --pkcs11-id \ ++ [--pkcs11-cert-file ] ++ - (alonbl) PKCS#11 release 0.16 ++ ++20061012 ++ - (alonbl) OpenSC bug workaround. ++ - (alonbl) PKCS#11 release 0.15 ++ ++20060930 ++ - (alonbl) Some pkcs11-helper updates. ++ - (alonbl) Rebase against 4.4p1. ++ - (alonbl) PKCS#11 release 0.14 ++ ++20060709 ++ - (alonbl) PKCS#11 fixed handling multiproviders. ++ - (alonbl) PKCS#11 release 0.13 ++ ++20060608 ++ - (alonbl) PKCS#11 modifed to match X.509-5.5 patch, works OK with focing ++ ssh-rsa id. ++ - (alonbl) PKCS#11 removed --pkcs11-x509-force-ssh argument. ++ - (alonbl) PKCS#11 release 0.12 ++ ++20060527 ++ - (alonbl) PKCS#11 fix issues with gcc-2 ++ - (alonbl) PKCS#11 fix issues with openssl-0.9.6 (first) version. ++ - (alonbl) PKCS#11 modified to match X.509-5.4 patch. ++ - (alonbl) PKCS#11 add --pkcs11-x509-force-ssh argument to force ssh id out ++ of X.509 certificate. ++ - (alonbl) PKCS#11 release 0.11 ++ ++20060419 ++ - (alonbl) PKCS#11 fix handling empty attributes. ++ - (alonbl) PKCS#11 release 0.10 ++ ++20060404 ++ - (alonbl) PKCS#11 code sync. ++ - (alonbl) PKCS#11 release 0.09 ++ +diff -urNp openssh-4.4p1/config.h.in openssh-4.4p1+pkcs11-0.17/config.h.in +--- openssh-4.4p1/config.h.in 2006-09-26 14:03:33.000000000 +0300 ++++ openssh-4.4p1+pkcs11-0.17/config.h.in 2006-09-28 16:31:03.000000000 +0300 +@@ -1217,6 +1217,12 @@ + /* Use audit debugging module */ + #undef SSH_AUDIT_EVENTS + ++/* Define if you don't want use PKCS#11 */ ++#undef SSH_PKCS11_DISABLED ++ ++/* Define if you don't want use X509 with PKCS#11 */ ++#undef SSH_PKCS11_X509_DISABLED ++ + /* non-privileged user for privilege separation */ + #undef SSH_PRIVSEP_USER + +diff -urNp openssh-4.4p1/configure openssh-4.4p1+pkcs11-0.17/configure +--- openssh-4.4p1/configure 2006-09-26 14:03:41.000000000 +0300 ++++ openssh-4.4p1+pkcs11-0.17/configure 2006-09-28 16:33:53.000000000 +0300 +@@ -1307,6 +1307,7 @@ Optional Features: + --disable-libutil disable use of libutil (login() etc.) no + --disable-pututline disable use of pututline() etc. (uwtmp) no + --disable-pututxline disable use of pututxline() etc. (uwtmpx) no ++ --disable-pkcs11 Disable PKCS#11 support + + Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] +@@ -32163,6 +32164,33 @@ if test ! -z "$blibpath" ; then + echo "$as_me: WARNING: Please check and edit blibpath in LDFLAGS in Makefile" >&2;} + fi + ++ssh_pkcs11="yes" ++ssh_pkcs11_x509="yes" ++# Check whether --enable-pkcs11 was given. ++if test "${enable_pkcs11+set}" = set; then ++ enableval=$enable_pkcs11; ++ if test "x$enableval" = "xno"; then ++ ssh_pkcs11="no" ++ fi ++ ++ ++fi ++ ++if test "x$ssh_pkcs11" = "xno"; then ++ ++cat >>confdefs.h <<_ACEOF ++#define SSH_PKCS11_DISABLED 1 ++_ACEOF ++ ++fi ++if test "x$ssh_x509" = "x"; then ++ ++cat >>confdefs.h <<_ACEOF ++#define SSH_PKCS11_X509_DISABLED 1 ++_ACEOF ++ ++fi ++ + CFLAGS="$CFLAGS $werror_flags" + + +@@ -33415,6 +33443,7 @@ echo " IP address in \$DISPLAY hac + echo " Translate v4 in v6 hack: $IPV4_IN6_HACK_MSG" + echo " BSD Auth support: $BSD_AUTH_MSG" + echo " Random number source: $RAND_MSG" ++echo " PKCS#11 support: $ssh_pkcs11" + if test ! -z "$USE_RAND_HELPER" ; then + echo " ssh-rand-helper collects from: $RAND_HELPER_MSG" + fi +diff -urNp openssh-4.4p1/configure.ac openssh-4.4p1+pkcs11-0.17/configure.ac +--- openssh-4.4p1/configure.ac 2006-09-24 22:08:59.000000000 +0300 ++++ openssh-4.4p1+pkcs11-0.17/configure.ac 2006-09-28 08:05:35.000000000 +0300 +@@ -3912,6 +3912,27 @@ if test ! -z "$blibpath" ; then + AC_MSG_WARN([Please check and edit blibpath in LDFLAGS in Makefile]) + fi + ++ssh_pkcs11="yes" ++ssh_pkcs11_x509="yes" ++AC_ARG_ENABLE(pkcs11, ++ [ --disable-pkcs11 Disable PKCS#11 support], ++ [ ++ if test "x$enableval" = "xno"; then ++ ssh_pkcs11="no" ++ fi ++ ] ++) ++if test "x$ssh_pkcs11" = "xno"; then ++ AC_DEFINE_UNQUOTED( ++ SSH_PKCS11_DISABLED, 1, ++ [Define if you don't want use PKCS#11]) ++fi ++if test "x$ssh_x509" = "x"; then ++ AC_DEFINE_UNQUOTED( ++ SSH_PKCS11_X509_DISABLED, 1, ++ [Define if you don't want use X509 with PKCS#11]) ++fi ++ + dnl Adding -Werror to CFLAGS early prevents configure tests from running. + dnl Add now. + CFLAGS="$CFLAGS $werror_flags" +@@ -3973,6 +3994,7 @@ echo " IP address in \$DISPLAY hac + echo " Translate v4 in v6 hack: $IPV4_IN6_HACK_MSG" + echo " BSD Auth support: $BSD_AUTH_MSG" + echo " Random number source: $RAND_MSG" ++echo " PKCS#11 support: $ssh_pkcs11" + if test ! -z "$USE_RAND_HELPER" ; then + echo " ssh-rand-helper collects from: $RAND_HELPER_MSG" + fi +diff -urNp openssh-4.4p1/cryptoki.h openssh-4.4p1+pkcs11-0.17/cryptoki.h +--- openssh-4.4p1/cryptoki.h 1970-01-01 02:00:00.000000000 +0200 ++++ openssh-4.4p1+pkcs11-0.17/cryptoki.h 2006-09-28 08:05:35.000000000 +0300 +@@ -0,0 +1,35 @@ ++/* cryptoki.h include file for PKCS #11. */ ++/* $Revision: 1.4 $ */ ++ ++/* License to copy and use this software is granted provided that it is ++ * identified as "RSA Security Inc. PKCS #11 Cryptographic Token Interface ++ * (Cryptoki)" in all material mentioning or referencing this software. ++ ++ * License is also granted to make and use derivative works provided that ++ * such works are identified as "derived from the RSA Security Inc. PKCS #11 ++ * Cryptographic Token Interface (Cryptoki)" in all material mentioning or ++ * referencing the derived work. ++ ++ * RSA Security Inc. makes no representations concerning either the ++ * merchantability of this software or the suitability of this software for ++ * any particular purpose. It is provided "as is" without express or implied ++ * warranty of any kind. ++ */ ++ ++#ifndef ___CRYPTOKI_H_INC___ ++#define ___CRYPTOKI_H_INC___ ++ ++#define CK_PTR * ++ ++#define CK_DEFINE_FUNCTION(returnType, name) returnType name ++#define CK_DECLARE_FUNCTION(returnType, name) returnType name ++#define CK_DECLARE_FUNCTION_POINTER(returnType, name) returnType (* name) ++#define CK_CALLBACK_FUNCTION(returnType, name) returnType (* name) ++ ++#ifndef NULL_PTR ++#define NULL_PTR 0 ++#endif ++ ++#include "pkcs11-headers/pkcs11.h" ++ ++#endif /* ___CRYPTOKI_H_INC___ */ +diff -urNp openssh-4.4p1/cryptoki-win32.h openssh-4.4p1+pkcs11-0.17/cryptoki-win32.h +--- openssh-4.4p1/cryptoki-win32.h 1970-01-01 02:00:00.000000000 +0200 ++++ openssh-4.4p1+pkcs11-0.17/cryptoki-win32.h 2006-09-28 08:05:35.000000000 +0300 +@@ -0,0 +1,66 @@ ++/* cryptoki.h include file for PKCS #11. */ ++/* $Revision: 1.4 $ */ ++ ++/* License to copy and use this software is granted provided that it is ++ * identified as "RSA Security Inc. PKCS #11 Cryptographic Token Interface ++ * (Cryptoki)" in all material mentioning or referencing this software. ++ ++ * License is also granted to make and use derivative works provided that ++ * such works are identified as "derived from the RSA Security Inc. PKCS #11 ++ * Cryptographic Token Interface (Cryptoki)" in all material mentioning or ++ * referencing the derived work. ++ ++ * RSA Security Inc. makes no representations concerning either the ++ * merchantability of this software or the suitability of this software for ++ * any particular purpose. It is provided "as is" without express or implied ++ * warranty of any kind. ++ */ ++ ++/* This is a sample file containing the top level include directives ++ * for building Win32 Cryptoki libraries and applications. ++ */ ++ ++#ifndef ___CRYPTOKI_H_INC___ ++#define ___CRYPTOKI_H_INC___ ++ ++#pragma pack(push, cryptoki, 1) ++ ++/* Specifies that the function is a DLL entry point. */ ++#define CK_IMPORT_SPEC __declspec(dllimport) ++ ++/* Define CRYPTOKI_EXPORTS during the build of cryptoki libraries. Do ++ * not define it in applications. ++ */ ++#ifdef CRYPTOKI_EXPORTS ++/* Specified that the function is an exported DLL entry point. */ ++#define CK_EXPORT_SPEC __declspec(dllexport) ++#else ++#define CK_EXPORT_SPEC CK_IMPORT_SPEC ++#endif ++ ++/* Ensures the calling convention for Win32 builds */ ++#define CK_CALL_SPEC __cdecl ++ ++#define CK_PTR * ++ ++#define CK_DEFINE_FUNCTION(returnType, name) \ ++ returnType CK_EXPORT_SPEC CK_CALL_SPEC name ++ ++#define CK_DECLARE_FUNCTION(returnType, name) \ ++ returnType CK_EXPORT_SPEC CK_CALL_SPEC name ++ ++#define CK_DECLARE_FUNCTION_POINTER(returnType, name) \ ++ returnType CK_IMPORT_SPEC (CK_CALL_SPEC CK_PTR name) ++ ++#define CK_CALLBACK_FUNCTION(returnType, name) \ ++ returnType (CK_CALL_SPEC CK_PTR name) ++ ++#ifndef NULL_PTR ++#define NULL_PTR 0 ++#endif ++ ++#include "pkcs11-headers/pkcs11.h" ++ ++#pragma pack(pop, cryptoki) ++ ++#endif /* ___CRYPTOKI_H_INC___ */ +diff -urNp openssh-4.4p1/LICENCE openssh-4.4p1+pkcs11-0.17/LICENCE +--- openssh-4.4p1/LICENCE 2006-08-30 20:24:41.000000000 +0300 ++++ openssh-4.4p1+pkcs11-0.17/LICENCE 2006-09-28 08:05:35.000000000 +0300 +@@ -332,6 +332,9 @@ OpenSSH contains no GPL code. + * authorization. * + ****************************************************************************/ + ++ d) PKCS #11: Cryptographic Token Interface Standard ++ ++ This software uses RSA Security Inc. PKCS #11 Cryptographic Token Interface (Cryptoki). + + ------ + $OpenBSD: LICENCE,v 1.19 2004/08/30 09:18:08 markus Exp $ +diff -urNp openssh-4.4p1/Makefile.in openssh-4.4p1+pkcs11-0.17/Makefile.in +--- openssh-4.4p1/Makefile.in 2006-09-12 14:54:10.000000000 +0300 ++++ openssh-4.4p1+pkcs11-0.17/Makefile.in 2006-09-28 08:05:35.000000000 +0300 +@@ -66,6 +66,7 @@ TARGETS=ssh$(EXEEXT) sshd$(EXEEXT) ssh-a + + LIBSSH_OBJS=acss.o authfd.o authfile.o bufaux.o bufbn.o buffer.o \ + canohost.o channels.o cipher.o cipher-acss.o cipher-aes.o \ ++ pkcs11.o pkcs11-helper.o \ + cipher-bf1.o cipher-ctr.o cipher-3des1.o cleanup.o \ + compat.o compress.o crc32.o deattack.o fatal.o hostfile.o \ + log.o match.o md-sha256.o moduli.o nchan.o packet.o \ +diff -urNp openssh-4.4p1/pkcs11.c openssh-4.4p1+pkcs11-0.17/pkcs11.c +--- openssh-4.4p1/pkcs11.c 1970-01-01 02:00:00.000000000 +0200 ++++ openssh-4.4p1+pkcs11-0.17/pkcs11.c 2006-10-23 17:35:54.000000000 +0200 +@@ -0,0 +1,1139 @@ ++/* ++ * Copyright (c) 2005-2006 Alon Bar-Lev. 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. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. ++ */ ++ ++/* ++ * The routines in this file deal with providing private key cryptography ++ * using RSA Security Inc. PKCS #11 Cryptographic Token Interface (Cryptoki). ++ * ++ */ ++ ++#include "includes.h" ++#include ++#include ++ ++#if !defined(SSH_PKCS11_DISABLED) ++ ++#include "pkcs11-helper.h" ++#include "pkcs11.h" ++#include "openssl/pem.h" ++#include "misc.h" ++ ++static ++char * ++ssh_from_x509 (X509 *x509); ++ ++static char *s_szSetPINProg = NULL; ++ ++static ++unsigned ++_pkcs11_msg_pkcs112openssh ( ++ IN const unsigned flags ++) { ++ unsigned openssh_flags; ++ ++ switch (flags) { ++ case PKCS11H_LOG_DEBUG2: ++ openssh_flags = SYSLOG_LEVEL_DEBUG3; ++ break; ++ case PKCS11H_LOG_DEBUG1: ++ openssh_flags = SYSLOG_LEVEL_DEBUG2; ++ break; ++ case PKCS11H_LOG_INFO: ++ openssh_flags = SYSLOG_LEVEL_INFO; ++ break; ++ case PKCS11H_LOG_WARN: ++ openssh_flags = SYSLOG_LEVEL_ERROR; ++ break; ++ case PKCS11H_LOG_ERROR: ++ openssh_flags = SYSLOG_LEVEL_FATAL; ++ break; ++ default: ++ openssh_flags = SYSLOG_LEVEL_FATAL; ++ break; ++ } ++ ++ return openssh_flags; ++} ++ ++static ++unsigned ++_pkcs11_msg_openssh2pkcs11 ( ++ IN const unsigned flags ++) { ++ unsigned pkcs11_flags; ++ ++ switch (flags) { ++ case SYSLOG_LEVEL_DEBUG3: ++ pkcs11_flags = PKCS11H_LOG_DEBUG2; ++ break; ++ case SYSLOG_LEVEL_DEBUG2: ++ pkcs11_flags = PKCS11H_LOG_DEBUG1; ++ break; ++ case SYSLOG_LEVEL_INFO: ++ pkcs11_flags = PKCS11H_LOG_INFO; ++ break; ++ case SYSLOG_LEVEL_ERROR: ++ pkcs11_flags = PKCS11H_LOG_WARN; ++ break; ++ case SYSLOG_LEVEL_FATAL: ++ pkcs11_flags = PKCS11H_LOG_ERROR; ++ break; ++ default: ++ pkcs11_flags = PKCS11H_LOG_ERROR; ++ break; ++ } ++ ++ return pkcs11_flags; ++} ++ ++static ++void ++_pkcs11_openssh_log ( ++ IN void * const pData, ++ IN unsigned flags, ++ IN const char * const szFormat, ++ IN va_list args ++) { ++ do_log (_pkcs11_msg_pkcs112openssh (flags), szFormat, args); ++} ++ ++static ++int ++_pkcs11_ssh_prompt ( ++ IN const char * const szType, ++ IN const char * const szPrompt, ++ OUT char * const szInput, ++ IN const int nMaxInput ++) { ++ pid_t pid = -1; ++ int fds[2] = {-1, -1}; ++ int fOK = TRUE; ++ ++ /* ++ * Make sure we don't reuse PIN ++ */ ++ if (fOK) { ++ memset (szInput, 0, nMaxInput); ++ } ++ ++ if (fOK && s_szSetPINProg == NULL) { ++ fOK = FALSE; ++ } ++ ++ if (fOK && pipe (fds) == -1) { ++ fOK = FALSE; ++ } ++ ++ if (fOK && (pid = fork ()) == -1) { ++ fOK = FALSE; ++ } ++ ++ if (fOK) { ++ if (pid == 0) { ++ close (fds[0]); ++ fds[0] = -1; ++ ++ if (fOK && dup2 (fds[1], 1) == -1) { ++ fOK = FALSE; ++ } ++ if (fOK) { ++ close (fds[1]); ++ fds[1] = -1; ++ } ++ ++ if (fOK) { ++ execl ( ++ s_szSetPINProg, ++ s_szSetPINProg, ++ "-t", ++ szType, ++ szPrompt, ++ NULL ++ ); ++ } ++ ++ exit (1); ++ } ++ else { ++ int status; ++ int r = 0; ++ ++ close (fds[1]); ++ fds[1] = -1; ++ ++ if (fOK) { ++ while ( ++ (r=waitpid (pid, &status, 0)) == 0 || ++ (r == -1 && errno == EINTR) ++ ); ++ ++ if (r == -1) { ++ fOK = FALSE; ++ } ++ } ++ ++ if (fOK && !WIFEXITED (status)) { ++ fOK = FALSE; ++ } ++ ++ if (fOK && WEXITSTATUS (status) != 0) { ++ fOK = FALSE; ++ } ++ ++ if (fOK) { ++ if (!strcmp (szType, "password")) { ++ if ((r = read (fds[0], szInput, nMaxInput)) == -1) { ++ fOK = FALSE; ++ r = 0; ++ } ++ } ++ else { ++ r = 0; ++ } ++ szInput[r] = '\0'; ++ } ++ ++ if (fOK) { ++ if (strlen (szInput) > 0 && szInput[strlen (szInput)-1] == '\n') { ++ szInput[strlen (szInput)-1] = '\0'; ++ } ++ /* ++ * for DOS compatability ++ */ ++ if (strlen (szInput) > 0 && szInput[strlen (szInput)-1] == '\r') { ++ szInput[strlen (szInput)-1] = '\0'; ++ } ++ } ++ } ++ } ++ ++ if (fds[0] != -1) { ++ close (fds[0]); ++ fds[0] = -1; ++ } ++ ++ if (fds[1] != -1) { ++ close (fds[1]); ++ fds[1] = -1; ++ } ++ ++ return fOK; ++} ++ ++static ++void ++_pkcs11_ssh_print ( ++ IN void * const pData, ++ IN const char * const szFormat, ++ IN ... ++) { ++ va_list args; ++ ++ va_start (args, szFormat); ++ vprintf (szFormat, args); ++ va_end (args); ++} ++ ++static ++PKCS11H_BOOL ++_pkcs11_ssh_token_prompt ( ++ IN void * const pData1, ++ IN void * const pData2, ++ IN const pkcs11h_token_id_t token, ++ IN const unsigned retry ++) { ++ char szPrompt[1024]; ++ char szPIN[1024]; ++ ++ snprintf (szPrompt, sizeof (szPrompt), "Please insert token '%s' or cancel", token->display); ++ return _pkcs11_ssh_prompt ("okcancel", szPrompt, szPIN, sizeof (szPIN)); ++} ++ ++static ++PKCS11H_BOOL ++_pkcs11_ssh_pin_prompt ( ++ IN void * const pData1, ++ IN void * const pData2, ++ IN const pkcs11h_token_id_t token, ++ IN const unsigned retry, ++ OUT char * const szPIN, ++ IN const size_t nMaxPIN ++) { ++ char szPrompt[1024]; ++ ++ snprintf (szPrompt, sizeof (szPrompt), "Please enter PIN for token '%s'", token->display); ++ return _pkcs11_ssh_prompt ("password", szPrompt, szPIN, nMaxPIN); ++} ++ ++static ++PKCS11H_BOOL ++_pkcs11_ssh_pin_prompt_cli ( ++ IN void * const pData1, ++ IN void * const pData2, ++ IN const pkcs11h_token_id_t token, ++ IN const unsigned retry, ++ OUT char * const szPIN, ++ IN const size_t nMaxPIN ++) { ++ char szPrompt[1024]; ++ snprintf (szPrompt, sizeof (szPrompt), "Please enter '%s' PIN or 'cancel': ", token->display); ++ char *p = getpass (szPrompt); ++ ++ strncpy (szPIN, p, nMaxPIN); ++ szPIN[nMaxPIN-1] = '\0'; ++ ++ return strcmp (szPIN, "cancel") != 0; ++} ++ ++void ++_pkcs11_do_log ( ++ IN LogLevel l, ++ IN const char *f, ++ IN ... ++) { ++ va_list args; ++ va_start (args, f); ++ do_log (l, f, args); ++ va_end (args); ++} ++ ++int ++pkcs11_initialize ( ++ const int fProtectedAuthentication, ++ const int nPINCachePeriod ++) { ++ CK_RV rv = CKR_OK; ++ ++ debug3 ( ++ "PKCS#11: pkcs11_initialize - entered fProtectedAuthentication=%d, nPINCachePeriod=%d", ++ fProtectedAuthentication, ++ nPINCachePeriod ++ ); ++ ++ if ( ++ rv == CKR_OK && ++ (rv = pkcs11h_initialize ()) != CKR_OK ++ ) { ++ error ("PKCS#11: Cannot initialize %ld-'%s'", rv, pkcs11h_getMessage (rv)); ++ } ++ ++ if ( ++ rv == CKR_OK && ++ (rv = pkcs11h_setLogHook (_pkcs11_openssh_log, NULL)) != CKR_OK ++ ) { ++ error ("PKCS#11: Cannot set hooks %ld-'%s'", rv, pkcs11h_getMessage (rv)); ++ } ++ ++ /* ++ * WARNING!!! ++ * There is no way to get log level, ++ * so set to minimum. ++ * After fix in log.c it can be fixed. ++ */ ++ if (rv == CKR_OK) { ++ pkcs11h_setLogLevel (_pkcs11_msg_openssh2pkcs11 (SYSLOG_LEVEL_DEBUG3)); ++ } ++ ++ if ( ++ rv == CKR_OK && ++ (rv = pkcs11h_setTokenPromptHook (_pkcs11_ssh_token_prompt, NULL)) != CKR_OK ++ ) { ++ error ("PKCS#11: Cannot set hooks %ld-'%s'", rv, pkcs11h_getMessage (rv)); ++ } ++ ++ if ( ++ rv == CKR_OK && ++ (rv = pkcs11h_setPINPromptHook (_pkcs11_ssh_pin_prompt, NULL)) != CKR_OK ++ ) { ++ error ("PKCS#11: Cannot set hooks %ld-'%s'", rv, pkcs11h_getMessage (rv)); ++ } ++ ++ if ( ++ rv == CKR_OK && ++ (rv = pkcs11h_setProtectedAuthentication (fProtectedAuthentication)) != CKR_OK ++ ) { ++ error ("PKCS#11: Cannot set protected authentication mode %ld-'%s'", rv, pkcs11h_getMessage (rv)); ++ } ++ ++ if ( ++ rv == CKR_OK && ++ (rv = pkcs11h_setPINCachePeriod (nPINCachePeriod)) != CKR_OK ++ ) { ++ error ("PKCS#11: Cannot set PIN cache period %ld-'%s'", rv, pkcs11h_getMessage (rv)); ++ } ++ ++ debug3 ( ++ "PKCS#11: pkcs11_initialize - return rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ return rv == CKR_OK; ++} ++ ++void ++pkcs11_terminate () { ++ debug3 ("PKCS#11: pkcs11_terminate - entered"); ++ ++ pkcs11h_terminate (); ++ ++ debug3 ("PKCS#11: pkcs11_terminate - return"); ++} ++ ++void ++pkcs11_forkFix () { ++ pkcs11h_forkFixup (); ++} ++ ++int ++pkcs11_setAskPIN ( ++ const char * const pin_prog ++) { ++ if (pin_prog != NULL) { ++ if (s_szSetPINProg != NULL) { ++ xfree (s_szSetPINProg); ++ s_szSetPINProg = NULL; ++ } ++ ++ s_szSetPINProg = xstrdup (pin_prog); ++ } ++ ++ return 1; ++} ++ ++int ++pkcs11_addProvider ( ++ const char * const provider, ++ const int fProtectedAuthentication, ++ const char * const sign_mode, ++ const int fCertIsPrivate ++) { ++ unsigned maskSignMode = 0; ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (provider != NULL); ++ PKCS11H_ASSERT (sign_mode != NULL); ++ ++ debug3 ( ++ "PKCS#11: pkcs11_addProvider - entered - provider='%s', fProtectedAuthentication=%d, sign_mode='%s', fCertIsPrivate=%d", ++ provider, ++ fProtectedAuthentication ? 1 : 0, ++ sign_mode == NULL ? "default" : sign_mode, ++ fCertIsPrivate ? 1 : 0 ++ ); ++ ++ debug ( ++ "PKCS#11: Adding PKCS#11 provider '%s'", ++ provider ++ ); ++ ++ if (rv == CKR_OK) { ++ if (sign_mode == NULL || !strcmp (sign_mode, "auto")) { ++ maskSignMode = 0; ++ } ++ else if (!strcmp (sign_mode, "sign")) { ++ maskSignMode = PKCS11H_SIGNMODE_MASK_SIGN; ++ } ++ else if (!strcmp (sign_mode, "recover")) { ++ maskSignMode = PKCS11H_SIGNMODE_MASK_RECOVER; ++ } ++ else if (!strcmp (sign_mode, "any")) { ++ maskSignMode = ( ++ PKCS11H_SIGNMODE_MASK_SIGN | ++ PKCS11H_SIGNMODE_MASK_RECOVER ++ ); ++ } ++ else { ++ error ("PKCS#11: Invalid sign mode '%s'", sign_mode); ++ rv = CKR_ARGUMENTS_BAD; ++ } ++ } ++ ++ if ( ++ rv == CKR_OK && ++ (rv = pkcs11h_addProvider ( ++ provider, ++ provider, ++ fProtectedAuthentication, ++ maskSignMode, ++ PKCS11H_SLOTEVENT_METHOD_AUTO, ++ 0, ++ fCertIsPrivate ++ )) != CKR_OK ++ ) { ++ error ("PKCS#11: Cannot initialize provider '%s' %ld-'%s'", provider, rv, pkcs11h_getMessage (rv)); ++ } ++ ++ debug3 ( ++ "PKCS#11: pkcs11_addProvider - return rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ return rv == CKR_OK; ++} ++ ++pkcs11_identity * ++pkcs11_identity_new () { ++ pkcs11_identity *id = xmalloc (sizeof (struct pkcs11_identity_s)); ++ if (id != NULL) { ++ memset (id, 0, sizeof (struct pkcs11_identity_s)); ++ } ++ return id; ++} ++ ++void ++pkcs11_identity_free ( ++ const pkcs11_identity * const id ++) { ++ if (id != NULL) { ++ xfree ((void *)id); ++ } ++} ++ ++void ++pkcs11_getKey ( ++ IN const pkcs11_identity * const id, ++ OUT Key ** const sshkey, ++ OUT char * const szComment, ++ IN const int nCommentMax ++) { ++ X509 *x509 = NULL; ++ RSA *rsa = NULL; ++ pkcs11h_certificate_id_t certificate_id = NULL; ++ pkcs11h_certificate_t certificate = NULL; ++ pkcs11h_openssl_session_t openssl_session = NULL; ++ size_t temp; ++ CK_RV rv = CKR_OK; ++ ++ int fOK = TRUE; ++ ++ debug3 ( ++ "PKCS#11: pkcs11_getKey - entered - id=%p, sshkey=%p, szComment=%p, nCommentMax=%d", ++ (void *)id, ++ (void *)sshkey, ++ (void *)szComment, ++ nCommentMax ++ ); ++ ++ PKCS11H_ASSERT (id != NULL); ++ PKCS11H_ASSERT (sshkey!=NULL); ++ PKCS11H_ASSERT (szComment!=NULL); ++ ++ debug3 ( ++ "PKCS#11: pkcs11_getKey - id - id=%s, pin_cache_period=%d, cert_file=%s", ++ id->id, ++ id->pin_cache_period, ++ id->cert_file ++ ); ++ ++ PKCS11H_ASSERT (id->id); ++ ++ if ( ++ fOK && ++ pkcs11h_certificate_deserializeCertificateId (&certificate_id, id->id) ++ ) { ++ fOK = FALSE; ++ error ("PKCS#11: Cannot deserialize id %ld-'%s'", rv, pkcs11h_getMessage (rv)); ++ } ++ ++ if ( ++ fOK && ++ id->cert_file != NULL && ++ id->cert_file[0] != '\x0' ++ ) { ++ X509 *x509 = NULL; ++ unsigned char *p = NULL; ++ unsigned char *certificate_blob = NULL; ++ size_t certificate_blob_size = 0; ++ FILE *fp = NULL; ++ ++ if ( ++ fOK && ++ (fp = fopen (id->cert_file, "r")) == NULL ++ ) { ++ fOK = FALSE; ++ error ("PKCS#11: Cannot open file '%s'", id->cert_file); ++ } ++ ++ if ( ++ fOK && ++ !PEM_read_X509 ( ++ fp, ++ &x509, ++ NULL, ++ 0 ++ ) ++ ) { ++ x509 = NULL; ++ fOK = FALSE; ++ error ("PKCS#11: Cannot read PEM from file '%s'", id->cert_file); ++ } ++ ++ if ( ++ fOK && ++ (certificate_blob_size = i2d_X509 (x509, NULL)) < 0 ++ ) { ++ fOK = FALSE; ++ error ("PKCS#11: Cannot read decode certificate"); ++ } ++ ++ if ( ++ fOK && ++ (certificate_blob = (unsigned char *)xmalloc (certificate_blob_size)) == NULL ++ ) { ++ fOK = FALSE; ++ error ("PKCS#11: Cannot allocate memory"); ++ } ++ ++ /* ++ * i2d_X509 increments p!!! ++ */ ++ p = certificate_blob; ++ ++ if ( ++ fOK && ++ (certificate_blob_size = i2d_X509 (x509, &p)) < 0 ++ ) { ++ fOK = FALSE; ++ error ("PKCS#11: Cannot read decode certificate"); ++ } ++ ++ if ( ++ fOK && ++ pkcs11h_certificate_setCertificateIdCertificateBlob ( ++ certificate_id, ++ certificate_blob, ++ certificate_blob_size ++ ) != CKR_OK ++ ) { ++ fOK = FALSE; ++ error ("PKCS#11: Cannot set certificate blob %ld-'%s'", rv, pkcs11h_getMessage (rv)); ++ } ++ ++ if (x509 != NULL) { ++ X509_free (x509); ++ x509 = NULL; ++ } ++ ++ if (certificate_blob != NULL) { ++ xfree (certificate_blob); ++ certificate_blob = NULL; ++ } ++ ++ if (fp != NULL) { ++ fclose (fp); ++ fp = NULL; ++ } ++ } ++ ++ if ( ++ fOK && ++ (rv = pkcs11h_certificate_create ( ++ certificate_id, ++ NULL, ++ PKCS11H_PROMPT_MASK_ALLOW_ALL, ++ id->pin_cache_period, ++ &certificate ++ )) != CKR_OK ++ ) { ++ fOK = FALSE; ++ error ("PKCS#11: Cannot get certificate %ld-'%s'", rv, pkcs11h_getMessage (rv)); ++ } ++ ++ if (certificate_id != NULL){ ++ pkcs11h_certificate_freeCertificateId (certificate_id); ++ certificate_id = NULL; ++ } ++ ++ /* ++ * Is called so next certificate_id will ++ * contain a proper description ++ */ ++ if ( ++ fOK && ++ (rv = pkcs11h_certificate_getCertificateBlob ( ++ certificate, ++ NULL, ++ &temp ++ )) != CKR_OK ++ ) { ++ fOK = FALSE; ++ error ("PKCS#11: Cannot get certificate blob %ld-'%s'", rv, pkcs11h_getMessage (rv)); ++ } ++ ++ if ( ++ fOK && ++ (rv = pkcs11h_certificate_getCertificateId ( ++ certificate, ++ &certificate_id ++ )) != CKR_OK ++ ) { ++ fOK = FALSE; ++ error ("PKCS#11: Cannot get certificate_id %ld-'%s'", rv, pkcs11h_getMessage (rv)); ++ } ++ ++ if (fOK) { ++ strncpy (szComment, certificate_id->displayName, nCommentMax); ++ szComment[nCommentMax - 1] = '\0'; ++ } ++ ++ if ( ++ fOK && ++ (openssl_session = pkcs11h_openssl_createSession (certificate)) == NULL ++ ) { ++ fOK = FALSE; ++ error ("PKCS#11: Cannot initialize openssl session"); ++ } ++ ++ if (fOK) { ++ /* ++ * will be release by openssl_session ++ */ ++ certificate = NULL; ++ } ++ ++ if ( ++ fOK && ++ (rsa = pkcs11h_openssl_session_getRSA (openssl_session)) == NULL ++ ) { ++ fOK = FALSE; ++ error ("PKCS#11: Unable get rsa object"); ++ } ++ ++ if ( ++ fOK && ++ (x509 = pkcs11h_openssl_session_getX509 (openssl_session)) == NULL ++ ) { ++ fOK = FALSE; ++ error ("PKCS#11: Unable get certificate object"); ++ } ++ ++ if (fOK) { ++ *sshkey = key_new_private (KEY_UNSPEC); ++ (*sshkey)->rsa = rsa; ++ rsa = NULL; ++#if defined(SSH_PKCS11_X509_DISABLED) ++ (*sshkey)->type = KEY_RSA; ++#else ++ (*sshkey)->type = KEY_X509_RSA; ++ (*sshkey)->x509 = x509; ++ x509 = NULL; ++#endif ++ } ++ ++ if (x509 != NULL) { ++ X509_free (x509); ++ x509 = NULL; ++ } ++ ++ if (openssl_session != NULL) { ++ pkcs11h_openssl_freeSession (openssl_session); ++ openssl_session = NULL; ++ } ++ ++ if (certificate != NULL) { ++ pkcs11h_certificate_freeCertificate (certificate); ++ certificate = NULL; ++ } ++ ++ if (certificate_id != NULL) { ++ pkcs11h_certificate_freeCertificateId (certificate_id); ++ certificate_id = NULL; ++ } ++ ++ debug3 ( ++ "PKCS#11: pkcs11_getKey - return fOK=%d, rv=%ld", ++ fOK ? 1 : 0, ++ rv ++ ); ++} ++ ++void ++pkcs11_show_ids ( ++ const char * const provider, ++ int allow_protected_auth, ++ int cert_is_private ++) { ++ pkcs11h_certificate_id_list_t user_certificates = NULL; ++ pkcs11h_certificate_id_list_t current = NULL; ++ CK_RV rv = CKR_OK; ++ ++ if (rv == CKR_OK) { ++ rv = pkcs11h_initialize (); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = pkcs11h_setLogHook (_pkcs11_openssh_log, NULL); ++ } ++ ++ if (rv == CKR_OK) { ++ pkcs11h_setLogLevel (_pkcs11_msg_openssh2pkcs11 (SYSLOG_LEVEL_DEBUG3)); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = pkcs11h_setPINPromptHook (_pkcs11_ssh_pin_prompt_cli, NULL); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = pkcs11h_setProtectedAuthentication (TRUE); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = pkcs11h_addProvider ( ++ provider, ++ provider, ++ allow_protected_auth ? TRUE : FALSE, ++ 0, ++ FALSE, ++ 0, ++ cert_is_private ? TRUE : FALSE ++ ); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = pkcs11h_certificate_enumCertificateIds ( ++ PKCS11H_ENUM_METHOD_CACHE_EXIST, ++ NULL, ++ PKCS11H_PROMPT_MASK_ALLOW_ALL, ++ NULL, ++ &user_certificates ++ ); ++ } ++ ++ for (current = user_certificates; rv == CKR_OK && current != NULL; current = current->next) { ++ pkcs11h_certificate_t certificate = NULL; ++ X509 *x509 = NULL; ++ char dn[1024] = {0}; ++ char *ser = NULL; ++ char *ssh_key = NULL; ++ size_t ser_len = 0; ++ ++ if (rv == CKR_OK) { ++ rv = pkcs11h_certificate_serializeCertificateId (NULL, &ser_len, current->certificate_id); ++ } ++ ++ if ( ++ rv == CKR_OK && ++ (ser = (char *)xmalloc (ser_len)) == NULL ++ ) { ++ rv = CKR_HOST_MEMORY; ++ } ++ ++ if (rv == CKR_OK) { ++ rv = pkcs11h_certificate_serializeCertificateId (ser, &ser_len, current->certificate_id); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = pkcs11h_certificate_create ( ++ current->certificate_id, ++ NULL, ++ PKCS11H_PROMPT_MASK_ALLOW_ALL, ++ PKCS11H_PIN_CACHE_INFINITE, ++ &certificate ++ ); ++ } ++ ++ if ( ++ rv == CKR_OK && ++ (x509 = pkcs11h_openssl_getX509 (certificate)) == NULL ++ ) { ++ rv = CKR_FUNCTION_FAILED; ++ } ++ ++ if (rv == CKR_OK) { ++ X509_NAME_oneline ( ++ X509_get_subject_name (x509), ++ dn, ++ sizeof (dn) ++ ); ++ printf ( ++ ( ++ "\n" ++ "********************************************\n" ++ "IDENTITY:\n" ++ " DN: %s\n" ++ " Serialized id: %s\n" ++ "\n" ++ " Certificate:\n" ++ ), ++ dn, ++ ser ++ ); ++ PEM_write_X509 (stdout, x509); ++ } ++ ++ if ( ++ rv == CKR_OK && ++ (ssh_key = ssh_from_x509 (x509)) != NULL ++ ) { ++ printf ( ++ ( ++ "\n" ++ " SSH:\n" ++ "%s\n" ++ ), ++ ssh_key ++ ); ++ ++ xfree (ssh_key); ++ } ++ ++ if (x509 != NULL) { ++ X509_free (x509); ++ x509 = NULL; ++ } ++ ++ if (certificate != NULL) { ++ pkcs11h_certificate_freeCertificate (certificate); ++ certificate = NULL; ++ } ++ ++ if (ser != NULL) { ++ xfree (ser); ++ ser = NULL; ++ } ++ ++ /* ++ * Ignore error ++ */ ++ if (rv != CKR_OK) { ++ error ("PKCS#11: Failed to get id %ld-'%s'", rv, pkcs11h_getMessage (rv)); ++ rv = CKR_OK; ++ } ++ } ++ ++ if (user_certificates != NULL) { ++ pkcs11h_certificate_freeCertificateIdList (user_certificates); ++ user_certificates = NULL; ++ } ++ ++ pkcs11h_terminate (); ++} ++ ++void ++pkcs11_dump_slots ( ++ const char * const provider ++) { ++ pkcs11h_standalone_dump_slots ( ++ _pkcs11_ssh_print, ++ NULL, ++ provider ++ ); ++} ++ ++void ++pkcs11_dump_objects ( ++ const char * const provider, ++ const char * const slot, ++ const char * const pin ++) { ++ pkcs11h_standalone_dump_objects ( ++ _pkcs11_ssh_print, ++ NULL, ++ provider, ++ slot, ++ pin ++ ); ++} ++ ++/* ++ * The ssh_from_x509 is dirived of Tatu and Markus work. ++ * ++ * Copyright (c) 2006 Alon bar-Lev . All rights reserved. ++ * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. ++ * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland ++ */ ++ ++#define PUT_32BIT(cp, value) ( \ ++ (cp)[0] = (value) >> 24, \ ++ (cp)[1] = (value) >> 16, \ ++ (cp)[2] = (value) >> 8, \ ++ (cp)[3] = (value) ) ++ ++static ++char * ++ssh_from_x509 (X509 *x509) { ++ ++ EVP_PKEY *pubkey = NULL; ++ BIO *bio = NULL, *bio2 = NULL, *bio64 = NULL; ++ unsigned char *blob = NULL, *buffer = NULL; ++ char *ret = NULL; ++ int blobsize = 0, retsize = 0; ++ int bytes_name = 0, bytes_exponent = 0, bytes_modulus = 0; ++ unsigned char *bp; ++ char *p; ++ int n; ++ const char *keyname = NULL; ++ int ok = 1; ++ ++ if (ok && (pubkey = X509_get_pubkey (x509)) == NULL) { ++ ok = 0; ++ } ++ ++ if (ok && (bio64 = BIO_new (BIO_f_base64 ())) == NULL) { ++ ok = 0; ++ } ++ ++ if (ok && (bio = BIO_new (BIO_s_mem ())) == NULL) { ++ ok = 0; ++ } ++ ++ if (ok && (bio2 = BIO_push (bio64, bio)) == NULL) { ++ ok = 0; ++ } ++ ++ if (ok && pubkey->type != EVP_PKEY_RSA) { ++ ok = 0; ++ } ++ ++ if (ok) { ++ keyname = "ssh-rsa"; ++ } ++ ++ if (ok) { ++ bytes_name = strlen (keyname); ++ bytes_exponent = BN_num_bytes (pubkey->pkey.rsa->e); ++ bytes_modulus = BN_num_bytes (pubkey->pkey.rsa->n); ++ ++ blobsize = ( ++ 4 + bytes_name + ++ 4 + (bytes_exponent + 1) + ++ 4 + (bytes_modulus + 1) + ++ 1 ++ ); ++ } ++ ++ if (ok && (blob = (unsigned char *)xmalloc (blobsize)) == NULL) { ++ ok = 0; ++ } ++ ++ if (ok && (buffer = (unsigned char *)xmalloc (blobsize)) == NULL) { ++ ok = 0; ++ } ++ ++ if (ok) { ++ bp = blob; ++ ++ PUT_32BIT (bp, bytes_name), bp += 4; ++ memcpy (bp, keyname, bytes_name), bp += bytes_name; ++ ++ BN_bn2bin (pubkey->pkey.rsa->e, buffer); ++ if (buffer[0] & 0x80) { ++ // highest bit set would indicate a negative number. ++ // to avoid this, we have to spend an extra byte: ++ PUT_32BIT (bp, bytes_exponent+1), bp += 4; ++ *(bp++) = 0; ++ } else { ++ PUT_32BIT (bp, bytes_exponent), bp += 4; ++ } ++ memcpy (bp, buffer, bytes_exponent), bp += bytes_exponent; ++ ++ BN_bn2bin (pubkey->pkey.rsa->n, buffer); ++ if (buffer[0] & 0x80) { ++ PUT_32BIT (bp, bytes_modulus+1), bp += 4; ++ *(bp++) = 0; ++ } else { ++ PUT_32BIT( bp, bytes_modulus ), bp += 4; ++ } ++ memcpy (bp, buffer, bytes_modulus), bp += bytes_modulus; ++ } ++ ++ ++ if (ok && BIO_write (bio2, blob, bp-blob) == -1) { ++ ok = 0; ++ } ++ ++ if (ok && BIO_flush (bio2) == -1) { ++ ok = 0; ++ } ++ ++ /* ++ * Allocate the newline too... We will remove them later ++ * For MS, allocate return as well. ++ */ ++ if (ok) { ++ retsize = strlen (keyname) + 1 + (blobsize * 4 / 3) + (blobsize * 2 / 50) + 10 + 1; ++ } ++ ++ if (ok && (ret = xmalloc (retsize)) == NULL) { ++ ok = 0; ++ } ++ ++ if (ok) { ++ strcpy (ret, keyname); ++ strcat (ret, " "); ++ } ++ ++ if (ok && (n = BIO_read (bio, ret + strlen (ret), retsize - strlen (ret) - 1)) == -1) { ++ ok = 0; ++ } ++ ++ if (ok) { ++ ret[strlen (keyname) + 1 + n] = '\x0'; ++ } ++ ++ if (ok) { ++ while ((p = strchr (ret, '\n')) != NULL) { ++ memmove (p, p+1, strlen (p)+1); ++ } ++ while ((p = strchr (ret, '\r')) != NULL) { ++ memmove (p, p+1, strlen (p)+1); ++ } ++ ++ } ++ ++ if (bio != NULL) { ++ BIO_free_all (bio); ++ bio = NULL; ++ } ++ ++ if (pubkey != NULL) { ++ EVP_PKEY_free (pubkey); ++ pubkey = NULL; ++ } ++ ++ if (buffer != NULL) { ++ xfree (buffer); ++ buffer = NULL; ++ } ++ ++ if (blob != NULL) { ++ xfree (blob); ++ blob = NULL; ++ } ++ ++ if (!ok) { ++ if (ret != NULL) { ++ xfree (ret); ++ ret = NULL; ++ } ++ } ++ ++ return ret; ++} ++ ++#else ++static void dummy (void) {} ++#endif /* SSH_PKCS11_DISABLED */ +diff -urNp openssh-4.4p1/pkcs11.h openssh-4.4p1+pkcs11-0.17/pkcs11.h +--- openssh-4.4p1/pkcs11.h 1970-01-01 02:00:00.000000000 +0200 ++++ openssh-4.4p1+pkcs11-0.17/pkcs11.h 2006-10-12 13:55:28.000000000 +0200 +@@ -0,0 +1,100 @@ ++/* ++ * Copyright (c) 2005-2006 Alon Bar-Lev. 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. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. ++ */ ++ ++#ifndef SSH_PKCS11_H ++#define SSH_PKCS11_H ++ ++#if !defined(SSH_PKCS11_DISABLED) ++ ++#include "key.h" ++ ++typedef struct pkcs11_identity_s { ++ char *id; ++ int pin_cache_period; ++ char *cert_file; ++} pkcs11_identity; ++ ++int ++pkcs11_initialize ( ++ const int fProtectedAuthentication, ++ const int nPINCachePeriod ++); ++ ++void ++pkcs11_terminate (); ++ ++void ++pkcs11_forkFix (); ++ ++int ++pkcs11_setAskPIN ( ++ const char * const pin_prog ++); ++ ++int ++pkcs11_addProvider ( ++ const char * const provider, ++ const int fProtectedAuthentication, ++ const char * const sign_mode, ++ const int fCertIsPrivate ++); ++ ++pkcs11_identity * ++pkcs11_identity_new (); ++ ++void ++pkcs11_identity_free ( ++ const pkcs11_identity * const id ++); ++ ++void ++pkcs11_getKey ( ++ const pkcs11_identity * const id, ++ Key ** const sshkey, ++ char * const szComment, ++ const int nCommentMax ++); ++ ++void ++pkcs11_show_ids ( ++ const char * const provider, ++ int allow_protected_auth, ++ int cert_is_private ++); ++ ++void ++pkcs11_dump_slots ( ++ const char * const provider ++); ++ ++void ++pkcs11_dump_objects ( ++ const char * const provider, ++ const char * const slot, ++ const char * const pin ++); ++ ++#endif /* SSH_PKCS11_DISABLED */ ++ ++#endif /* OPENSSH_PKCS11_H */ +diff -urNp openssh-4.4p1/pkcs11-headers/pkcs11f.h openssh-4.4p1+pkcs11-0.17/pkcs11-headers/pkcs11f.h +--- openssh-4.4p1/pkcs11-headers/pkcs11f.h 1970-01-01 02:00:00.000000000 +0200 ++++ openssh-4.4p1+pkcs11-0.17/pkcs11-headers/pkcs11f.h 2006-09-28 08:05:35.000000000 +0300 +@@ -0,0 +1,912 @@ ++/* pkcs11f.h include file for PKCS #11. */ ++/* $Revision: 1.4 $ */ ++ ++/* License to copy and use this software is granted provided that it is ++ * identified as "RSA Security Inc. PKCS #11 Cryptographic Token Interface ++ * (Cryptoki)" in all material mentioning or referencing this software. ++ ++ * License is also granted to make and use derivative works provided that ++ * such works are identified as "derived from the RSA Security Inc. PKCS #11 ++ * Cryptographic Token Interface (Cryptoki)" in all material mentioning or ++ * referencing the derived work. ++ ++ * RSA Security Inc. makes no representations concerning either the ++ * merchantability of this software or the suitability of this software for ++ * any particular purpose. It is provided "as is" without express or implied ++ * warranty of any kind. ++ */ ++ ++/* This header file contains pretty much everything about all the */ ++/* Cryptoki function prototypes. Because this information is */ ++/* used for more than just declaring function prototypes, the */ ++/* order of the functions appearing herein is important, and */ ++/* should not be altered. */ ++ ++/* General-purpose */ ++ ++/* C_Initialize initializes the Cryptoki library. */ ++CK_PKCS11_FUNCTION_INFO(C_Initialize) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_VOID_PTR pInitArgs /* if this is not NULL_PTR, it gets ++ * cast to CK_C_INITIALIZE_ARGS_PTR ++ * and dereferenced */ ++); ++#endif ++ ++ ++/* C_Finalize indicates that an application is done with the ++ * Cryptoki library. */ ++CK_PKCS11_FUNCTION_INFO(C_Finalize) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_VOID_PTR pReserved /* reserved. Should be NULL_PTR */ ++); ++#endif ++ ++ ++/* C_GetInfo returns general information about Cryptoki. */ ++CK_PKCS11_FUNCTION_INFO(C_GetInfo) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_INFO_PTR pInfo /* location that receives information */ ++); ++#endif ++ ++ ++/* C_GetFunctionList returns the function list. */ ++CK_PKCS11_FUNCTION_INFO(C_GetFunctionList) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_FUNCTION_LIST_PTR_PTR ppFunctionList /* receives pointer to ++ * function list */ ++); ++#endif ++ ++ ++ ++/* Slot and token management */ ++ ++/* C_GetSlotList obtains a list of slots in the system. */ ++CK_PKCS11_FUNCTION_INFO(C_GetSlotList) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_BBOOL tokenPresent, /* only slots with tokens? */ ++ CK_SLOT_ID_PTR pSlotList, /* receives array of slot IDs */ ++ CK_ULONG_PTR pulCount /* receives number of slots */ ++); ++#endif ++ ++ ++/* C_GetSlotInfo obtains information about a particular slot in ++ * the system. */ ++CK_PKCS11_FUNCTION_INFO(C_GetSlotInfo) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SLOT_ID slotID, /* the ID of the slot */ ++ CK_SLOT_INFO_PTR pInfo /* receives the slot information */ ++); ++#endif ++ ++ ++/* C_GetTokenInfo obtains information about a particular token ++ * in the system. */ ++CK_PKCS11_FUNCTION_INFO(C_GetTokenInfo) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SLOT_ID slotID, /* ID of the token's slot */ ++ CK_TOKEN_INFO_PTR pInfo /* receives the token information */ ++); ++#endif ++ ++ ++/* C_GetMechanismList obtains a list of mechanism types ++ * supported by a token. */ ++CK_PKCS11_FUNCTION_INFO(C_GetMechanismList) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SLOT_ID slotID, /* ID of token's slot */ ++ CK_MECHANISM_TYPE_PTR pMechanismList, /* gets mech. array */ ++ CK_ULONG_PTR pulCount /* gets # of mechs. */ ++); ++#endif ++ ++ ++/* C_GetMechanismInfo obtains information about a particular ++ * mechanism possibly supported by a token. */ ++CK_PKCS11_FUNCTION_INFO(C_GetMechanismInfo) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SLOT_ID slotID, /* ID of the token's slot */ ++ CK_MECHANISM_TYPE type, /* type of mechanism */ ++ CK_MECHANISM_INFO_PTR pInfo /* receives mechanism info */ ++); ++#endif ++ ++ ++/* C_InitToken initializes a token. */ ++CK_PKCS11_FUNCTION_INFO(C_InitToken) ++#ifdef CK_NEED_ARG_LIST ++/* pLabel changed from CK_CHAR_PTR to CK_UTF8CHAR_PTR for v2.10 */ ++( ++ CK_SLOT_ID slotID, /* ID of the token's slot */ ++ CK_UTF8CHAR_PTR pPin, /* the SO's initial PIN */ ++ CK_ULONG ulPinLen, /* length in bytes of the PIN */ ++ CK_UTF8CHAR_PTR pLabel /* 32-byte token label (blank padded) */ ++); ++#endif ++ ++ ++/* C_InitPIN initializes the normal user's PIN. */ ++CK_PKCS11_FUNCTION_INFO(C_InitPIN) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_UTF8CHAR_PTR pPin, /* the normal user's PIN */ ++ CK_ULONG ulPinLen /* length in bytes of the PIN */ ++); ++#endif ++ ++ ++/* C_SetPIN modifies the PIN of the user who is logged in. */ ++CK_PKCS11_FUNCTION_INFO(C_SetPIN) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_UTF8CHAR_PTR pOldPin, /* the old PIN */ ++ CK_ULONG ulOldLen, /* length of the old PIN */ ++ CK_UTF8CHAR_PTR pNewPin, /* the new PIN */ ++ CK_ULONG ulNewLen /* length of the new PIN */ ++); ++#endif ++ ++ ++ ++/* Session management */ ++ ++/* C_OpenSession opens a session between an application and a ++ * token. */ ++CK_PKCS11_FUNCTION_INFO(C_OpenSession) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SLOT_ID slotID, /* the slot's ID */ ++ CK_FLAGS flags, /* from CK_SESSION_INFO */ ++ CK_VOID_PTR pApplication, /* passed to callback */ ++ CK_NOTIFY Notify, /* callback function */ ++ CK_SESSION_HANDLE_PTR phSession /* gets session handle */ ++); ++#endif ++ ++ ++/* C_CloseSession closes a session between an application and a ++ * token. */ ++CK_PKCS11_FUNCTION_INFO(C_CloseSession) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession /* the session's handle */ ++); ++#endif ++ ++ ++/* C_CloseAllSessions closes all sessions with a token. */ ++CK_PKCS11_FUNCTION_INFO(C_CloseAllSessions) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SLOT_ID slotID /* the token's slot */ ++); ++#endif ++ ++ ++/* C_GetSessionInfo obtains information about the session. */ ++CK_PKCS11_FUNCTION_INFO(C_GetSessionInfo) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_SESSION_INFO_PTR pInfo /* receives session info */ ++); ++#endif ++ ++ ++/* C_GetOperationState obtains the state of the cryptographic operation ++ * in a session. */ ++CK_PKCS11_FUNCTION_INFO(C_GetOperationState) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* session's handle */ ++ CK_BYTE_PTR pOperationState, /* gets state */ ++ CK_ULONG_PTR pulOperationStateLen /* gets state length */ ++); ++#endif ++ ++ ++/* C_SetOperationState restores the state of the cryptographic ++ * operation in a session. */ ++CK_PKCS11_FUNCTION_INFO(C_SetOperationState) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* session's handle */ ++ CK_BYTE_PTR pOperationState, /* holds state */ ++ CK_ULONG ulOperationStateLen, /* holds state length */ ++ CK_OBJECT_HANDLE hEncryptionKey, /* en/decryption key */ ++ CK_OBJECT_HANDLE hAuthenticationKey /* sign/verify key */ ++); ++#endif ++ ++ ++/* C_Login logs a user into a token. */ ++CK_PKCS11_FUNCTION_INFO(C_Login) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_USER_TYPE userType, /* the user type */ ++ CK_UTF8CHAR_PTR pPin, /* the user's PIN */ ++ CK_ULONG ulPinLen /* the length of the PIN */ ++); ++#endif ++ ++ ++/* C_Logout logs a user out from a token. */ ++CK_PKCS11_FUNCTION_INFO(C_Logout) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession /* the session's handle */ ++); ++#endif ++ ++ ++ ++/* Object management */ ++ ++/* C_CreateObject creates a new object. */ ++CK_PKCS11_FUNCTION_INFO(C_CreateObject) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_ATTRIBUTE_PTR pTemplate, /* the object's template */ ++ CK_ULONG ulCount, /* attributes in template */ ++ CK_OBJECT_HANDLE_PTR phObject /* gets new object's handle. */ ++); ++#endif ++ ++ ++/* C_CopyObject copies an object, creating a new object for the ++ * copy. */ ++CK_PKCS11_FUNCTION_INFO(C_CopyObject) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_OBJECT_HANDLE hObject, /* the object's handle */ ++ CK_ATTRIBUTE_PTR pTemplate, /* template for new object */ ++ CK_ULONG ulCount, /* attributes in template */ ++ CK_OBJECT_HANDLE_PTR phNewObject /* receives handle of copy */ ++); ++#endif ++ ++ ++/* C_DestroyObject destroys an object. */ ++CK_PKCS11_FUNCTION_INFO(C_DestroyObject) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_OBJECT_HANDLE hObject /* the object's handle */ ++); ++#endif ++ ++ ++/* C_GetObjectSize gets the size of an object in bytes. */ ++CK_PKCS11_FUNCTION_INFO(C_GetObjectSize) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_OBJECT_HANDLE hObject, /* the object's handle */ ++ CK_ULONG_PTR pulSize /* receives size of object */ ++); ++#endif ++ ++ ++/* C_GetAttributeValue obtains the value of one or more object ++ * attributes. */ ++CK_PKCS11_FUNCTION_INFO(C_GetAttributeValue) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_OBJECT_HANDLE hObject, /* the object's handle */ ++ CK_ATTRIBUTE_PTR pTemplate, /* specifies attrs; gets vals */ ++ CK_ULONG ulCount /* attributes in template */ ++); ++#endif ++ ++ ++/* C_SetAttributeValue modifies the value of one or more object ++ * attributes */ ++CK_PKCS11_FUNCTION_INFO(C_SetAttributeValue) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_OBJECT_HANDLE hObject, /* the object's handle */ ++ CK_ATTRIBUTE_PTR pTemplate, /* specifies attrs and values */ ++ CK_ULONG ulCount /* attributes in template */ ++); ++#endif ++ ++ ++/* C_FindObjectsInit initializes a search for token and session ++ * objects that match a template. */ ++CK_PKCS11_FUNCTION_INFO(C_FindObjectsInit) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_ATTRIBUTE_PTR pTemplate, /* attribute values to match */ ++ CK_ULONG ulCount /* attrs in search template */ ++); ++#endif ++ ++ ++/* C_FindObjects continues a search for token and session ++ * objects that match a template, obtaining additional object ++ * handles. */ ++CK_PKCS11_FUNCTION_INFO(C_FindObjects) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* session's handle */ ++ CK_OBJECT_HANDLE_PTR phObject, /* gets obj. handles */ ++ CK_ULONG ulMaxObjectCount, /* max handles to get */ ++ CK_ULONG_PTR pulObjectCount /* actual # returned */ ++); ++#endif ++ ++ ++/* C_FindObjectsFinal finishes a search for token and session ++ * objects. */ ++CK_PKCS11_FUNCTION_INFO(C_FindObjectsFinal) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession /* the session's handle */ ++); ++#endif ++ ++ ++ ++/* Encryption and decryption */ ++ ++/* C_EncryptInit initializes an encryption operation. */ ++CK_PKCS11_FUNCTION_INFO(C_EncryptInit) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_MECHANISM_PTR pMechanism, /* the encryption mechanism */ ++ CK_OBJECT_HANDLE hKey /* handle of encryption key */ ++); ++#endif ++ ++ ++/* C_Encrypt encrypts single-part data. */ ++CK_PKCS11_FUNCTION_INFO(C_Encrypt) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* session's handle */ ++ CK_BYTE_PTR pData, /* the plaintext data */ ++ CK_ULONG ulDataLen, /* bytes of plaintext */ ++ CK_BYTE_PTR pEncryptedData, /* gets ciphertext */ ++ CK_ULONG_PTR pulEncryptedDataLen /* gets c-text size */ ++); ++#endif ++ ++ ++/* C_EncryptUpdate continues a multiple-part encryption ++ * operation. */ ++CK_PKCS11_FUNCTION_INFO(C_EncryptUpdate) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* session's handle */ ++ CK_BYTE_PTR pPart, /* the plaintext data */ ++ CK_ULONG ulPartLen, /* plaintext data len */ ++ CK_BYTE_PTR pEncryptedPart, /* gets ciphertext */ ++ CK_ULONG_PTR pulEncryptedPartLen /* gets c-text size */ ++); ++#endif ++ ++ ++/* C_EncryptFinal finishes a multiple-part encryption ++ * operation. */ ++CK_PKCS11_FUNCTION_INFO(C_EncryptFinal) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* session handle */ ++ CK_BYTE_PTR pLastEncryptedPart, /* last c-text */ ++ CK_ULONG_PTR pulLastEncryptedPartLen /* gets last size */ ++); ++#endif ++ ++ ++/* C_DecryptInit initializes a decryption operation. */ ++CK_PKCS11_FUNCTION_INFO(C_DecryptInit) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_MECHANISM_PTR pMechanism, /* the decryption mechanism */ ++ CK_OBJECT_HANDLE hKey /* handle of decryption key */ ++); ++#endif ++ ++ ++/* C_Decrypt decrypts encrypted data in a single part. */ ++CK_PKCS11_FUNCTION_INFO(C_Decrypt) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* session's handle */ ++ CK_BYTE_PTR pEncryptedData, /* ciphertext */ ++ CK_ULONG ulEncryptedDataLen, /* ciphertext length */ ++ CK_BYTE_PTR pData, /* gets plaintext */ ++ CK_ULONG_PTR pulDataLen /* gets p-text size */ ++); ++#endif ++ ++ ++/* C_DecryptUpdate continues a multiple-part decryption ++ * operation. */ ++CK_PKCS11_FUNCTION_INFO(C_DecryptUpdate) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* session's handle */ ++ CK_BYTE_PTR pEncryptedPart, /* encrypted data */ ++ CK_ULONG ulEncryptedPartLen, /* input length */ ++ CK_BYTE_PTR pPart, /* gets plaintext */ ++ CK_ULONG_PTR pulPartLen /* p-text size */ ++); ++#endif ++ ++ ++/* C_DecryptFinal finishes a multiple-part decryption ++ * operation. */ ++CK_PKCS11_FUNCTION_INFO(C_DecryptFinal) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_BYTE_PTR pLastPart, /* gets plaintext */ ++ CK_ULONG_PTR pulLastPartLen /* p-text size */ ++); ++#endif ++ ++ ++ ++/* Message digesting */ ++ ++/* C_DigestInit initializes a message-digesting operation. */ ++CK_PKCS11_FUNCTION_INFO(C_DigestInit) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_MECHANISM_PTR pMechanism /* the digesting mechanism */ ++); ++#endif ++ ++ ++/* C_Digest digests data in a single part. */ ++CK_PKCS11_FUNCTION_INFO(C_Digest) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_BYTE_PTR pData, /* data to be digested */ ++ CK_ULONG ulDataLen, /* bytes of data to digest */ ++ CK_BYTE_PTR pDigest, /* gets the message digest */ ++ CK_ULONG_PTR pulDigestLen /* gets digest length */ ++); ++#endif ++ ++ ++/* C_DigestUpdate continues a multiple-part message-digesting ++ * operation. */ ++CK_PKCS11_FUNCTION_INFO(C_DigestUpdate) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_BYTE_PTR pPart, /* data to be digested */ ++ CK_ULONG ulPartLen /* bytes of data to be digested */ ++); ++#endif ++ ++ ++/* C_DigestKey continues a multi-part message-digesting ++ * operation, by digesting the value of a secret key as part of ++ * the data already digested. */ ++CK_PKCS11_FUNCTION_INFO(C_DigestKey) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_OBJECT_HANDLE hKey /* secret key to digest */ ++); ++#endif ++ ++ ++/* C_DigestFinal finishes a multiple-part message-digesting ++ * operation. */ ++CK_PKCS11_FUNCTION_INFO(C_DigestFinal) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_BYTE_PTR pDigest, /* gets the message digest */ ++ CK_ULONG_PTR pulDigestLen /* gets byte count of digest */ ++); ++#endif ++ ++ ++ ++/* Signing and MACing */ ++ ++/* C_SignInit initializes a signature (private key encryption) ++ * operation, where the signature is (will be) an appendix to ++ * the data, and plaintext cannot be recovered from the ++ *signature. */ ++CK_PKCS11_FUNCTION_INFO(C_SignInit) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_MECHANISM_PTR pMechanism, /* the signature mechanism */ ++ CK_OBJECT_HANDLE hKey /* handle of signature key */ ++); ++#endif ++ ++ ++/* C_Sign signs (encrypts with private key) data in a single ++ * part, where the signature is (will be) an appendix to the ++ * data, and plaintext cannot be recovered from the signature. */ ++CK_PKCS11_FUNCTION_INFO(C_Sign) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_BYTE_PTR pData, /* the data to sign */ ++ CK_ULONG ulDataLen, /* count of bytes to sign */ ++ CK_BYTE_PTR pSignature, /* gets the signature */ ++ CK_ULONG_PTR pulSignatureLen /* gets signature length */ ++); ++#endif ++ ++ ++/* C_SignUpdate continues a multiple-part signature operation, ++ * where the signature is (will be) an appendix to the data, ++ * and plaintext cannot be recovered from the signature. */ ++CK_PKCS11_FUNCTION_INFO(C_SignUpdate) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_BYTE_PTR pPart, /* the data to sign */ ++ CK_ULONG ulPartLen /* count of bytes to sign */ ++); ++#endif ++ ++ ++/* C_SignFinal finishes a multiple-part signature operation, ++ * returning the signature. */ ++CK_PKCS11_FUNCTION_INFO(C_SignFinal) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_BYTE_PTR pSignature, /* gets the signature */ ++ CK_ULONG_PTR pulSignatureLen /* gets signature length */ ++); ++#endif ++ ++ ++/* C_SignRecoverInit initializes a signature operation, where ++ * the data can be recovered from the signature. */ ++CK_PKCS11_FUNCTION_INFO(C_SignRecoverInit) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_MECHANISM_PTR pMechanism, /* the signature mechanism */ ++ CK_OBJECT_HANDLE hKey /* handle of the signature key */ ++); ++#endif ++ ++ ++/* C_SignRecover signs data in a single operation, where the ++ * data can be recovered from the signature. */ ++CK_PKCS11_FUNCTION_INFO(C_SignRecover) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_BYTE_PTR pData, /* the data to sign */ ++ CK_ULONG ulDataLen, /* count of bytes to sign */ ++ CK_BYTE_PTR pSignature, /* gets the signature */ ++ CK_ULONG_PTR pulSignatureLen /* gets signature length */ ++); ++#endif ++ ++ ++ ++/* Verifying signatures and MACs */ ++ ++/* C_VerifyInit initializes a verification operation, where the ++ * signature is an appendix to the data, and plaintext cannot ++ * cannot be recovered from the signature (e.g. DSA). */ ++CK_PKCS11_FUNCTION_INFO(C_VerifyInit) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_MECHANISM_PTR pMechanism, /* the verification mechanism */ ++ CK_OBJECT_HANDLE hKey /* verification key */ ++); ++#endif ++ ++ ++/* C_Verify verifies a signature in a single-part operation, ++ * where the signature is an appendix to the data, and plaintext ++ * cannot be recovered from the signature. */ ++CK_PKCS11_FUNCTION_INFO(C_Verify) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_BYTE_PTR pData, /* signed data */ ++ CK_ULONG ulDataLen, /* length of signed data */ ++ CK_BYTE_PTR pSignature, /* signature */ ++ CK_ULONG ulSignatureLen /* signature length*/ ++); ++#endif ++ ++ ++/* C_VerifyUpdate continues a multiple-part verification ++ * operation, where the signature is an appendix to the data, ++ * and plaintext cannot be recovered from the signature. */ ++CK_PKCS11_FUNCTION_INFO(C_VerifyUpdate) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_BYTE_PTR pPart, /* signed data */ ++ CK_ULONG ulPartLen /* length of signed data */ ++); ++#endif ++ ++ ++/* C_VerifyFinal finishes a multiple-part verification ++ * operation, checking the signature. */ ++CK_PKCS11_FUNCTION_INFO(C_VerifyFinal) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_BYTE_PTR pSignature, /* signature to verify */ ++ CK_ULONG ulSignatureLen /* signature length */ ++); ++#endif ++ ++ ++/* C_VerifyRecoverInit initializes a signature verification ++ * operation, where the data is recovered from the signature. */ ++CK_PKCS11_FUNCTION_INFO(C_VerifyRecoverInit) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_MECHANISM_PTR pMechanism, /* the verification mechanism */ ++ CK_OBJECT_HANDLE hKey /* verification key */ ++); ++#endif ++ ++ ++/* C_VerifyRecover verifies a signature in a single-part ++ * operation, where the data is recovered from the signature. */ ++CK_PKCS11_FUNCTION_INFO(C_VerifyRecover) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_BYTE_PTR pSignature, /* signature to verify */ ++ CK_ULONG ulSignatureLen, /* signature length */ ++ CK_BYTE_PTR pData, /* gets signed data */ ++ CK_ULONG_PTR pulDataLen /* gets signed data len */ ++); ++#endif ++ ++ ++ ++/* Dual-function cryptographic operations */ ++ ++/* C_DigestEncryptUpdate continues a multiple-part digesting ++ * and encryption operation. */ ++CK_PKCS11_FUNCTION_INFO(C_DigestEncryptUpdate) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* session's handle */ ++ CK_BYTE_PTR pPart, /* the plaintext data */ ++ CK_ULONG ulPartLen, /* plaintext length */ ++ CK_BYTE_PTR pEncryptedPart, /* gets ciphertext */ ++ CK_ULONG_PTR pulEncryptedPartLen /* gets c-text length */ ++); ++#endif ++ ++ ++/* C_DecryptDigestUpdate continues a multiple-part decryption and ++ * digesting operation. */ ++CK_PKCS11_FUNCTION_INFO(C_DecryptDigestUpdate) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* session's handle */ ++ CK_BYTE_PTR pEncryptedPart, /* ciphertext */ ++ CK_ULONG ulEncryptedPartLen, /* ciphertext length */ ++ CK_BYTE_PTR pPart, /* gets plaintext */ ++ CK_ULONG_PTR pulPartLen /* gets plaintext len */ ++); ++#endif ++ ++ ++/* C_SignEncryptUpdate continues a multiple-part signing and ++ * encryption operation. */ ++CK_PKCS11_FUNCTION_INFO(C_SignEncryptUpdate) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* session's handle */ ++ CK_BYTE_PTR pPart, /* the plaintext data */ ++ CK_ULONG ulPartLen, /* plaintext length */ ++ CK_BYTE_PTR pEncryptedPart, /* gets ciphertext */ ++ CK_ULONG_PTR pulEncryptedPartLen /* gets c-text length */ ++); ++#endif ++ ++ ++/* C_DecryptVerifyUpdate continues a multiple-part decryption and ++ * verify operation. */ ++CK_PKCS11_FUNCTION_INFO(C_DecryptVerifyUpdate) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* session's handle */ ++ CK_BYTE_PTR pEncryptedPart, /* ciphertext */ ++ CK_ULONG ulEncryptedPartLen, /* ciphertext length */ ++ CK_BYTE_PTR pPart, /* gets plaintext */ ++ CK_ULONG_PTR pulPartLen /* gets p-text length */ ++); ++#endif ++ ++ ++ ++/* Key management */ ++ ++/* C_GenerateKey generates a secret key, creating a new key ++ * object. */ ++CK_PKCS11_FUNCTION_INFO(C_GenerateKey) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_MECHANISM_PTR pMechanism, /* key generation mech. */ ++ CK_ATTRIBUTE_PTR pTemplate, /* template for new key */ ++ CK_ULONG ulCount, /* # of attrs in template */ ++ CK_OBJECT_HANDLE_PTR phKey /* gets handle of new key */ ++); ++#endif ++ ++ ++/* C_GenerateKeyPair generates a public-key/private-key pair, ++ * creating new key objects. */ ++CK_PKCS11_FUNCTION_INFO(C_GenerateKeyPair) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* session ++ * handle */ ++ CK_MECHANISM_PTR pMechanism, /* key-gen ++ * mech. */ ++ CK_ATTRIBUTE_PTR pPublicKeyTemplate, /* template ++ * for pub. ++ * key */ ++ CK_ULONG ulPublicKeyAttributeCount, /* # pub. ++ * attrs. */ ++ CK_ATTRIBUTE_PTR pPrivateKeyTemplate, /* template ++ * for priv. ++ * key */ ++ CK_ULONG ulPrivateKeyAttributeCount, /* # priv. ++ * attrs. */ ++ CK_OBJECT_HANDLE_PTR phPublicKey, /* gets pub. ++ * key ++ * handle */ ++ CK_OBJECT_HANDLE_PTR phPrivateKey /* gets ++ * priv. key ++ * handle */ ++); ++#endif ++ ++ ++/* C_WrapKey wraps (i.e., encrypts) a key. */ ++CK_PKCS11_FUNCTION_INFO(C_WrapKey) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_MECHANISM_PTR pMechanism, /* the wrapping mechanism */ ++ CK_OBJECT_HANDLE hWrappingKey, /* wrapping key */ ++ CK_OBJECT_HANDLE hKey, /* key to be wrapped */ ++ CK_BYTE_PTR pWrappedKey, /* gets wrapped key */ ++ CK_ULONG_PTR pulWrappedKeyLen /* gets wrapped key size */ ++); ++#endif ++ ++ ++/* C_UnwrapKey unwraps (decrypts) a wrapped key, creating a new ++ * key object. */ ++CK_PKCS11_FUNCTION_INFO(C_UnwrapKey) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* session's handle */ ++ CK_MECHANISM_PTR pMechanism, /* unwrapping mech. */ ++ CK_OBJECT_HANDLE hUnwrappingKey, /* unwrapping key */ ++ CK_BYTE_PTR pWrappedKey, /* the wrapped key */ ++ CK_ULONG ulWrappedKeyLen, /* wrapped key len */ ++ CK_ATTRIBUTE_PTR pTemplate, /* new key template */ ++ CK_ULONG ulAttributeCount, /* template length */ ++ CK_OBJECT_HANDLE_PTR phKey /* gets new handle */ ++); ++#endif ++ ++ ++/* C_DeriveKey derives a key from a base key, creating a new key ++ * object. */ ++CK_PKCS11_FUNCTION_INFO(C_DeriveKey) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* session's handle */ ++ CK_MECHANISM_PTR pMechanism, /* key deriv. mech. */ ++ CK_OBJECT_HANDLE hBaseKey, /* base key */ ++ CK_ATTRIBUTE_PTR pTemplate, /* new key template */ ++ CK_ULONG ulAttributeCount, /* template length */ ++ CK_OBJECT_HANDLE_PTR phKey /* gets new handle */ ++); ++#endif ++ ++ ++ ++/* Random number generation */ ++ ++/* C_SeedRandom mixes additional seed material into the token's ++ * random number generator. */ ++CK_PKCS11_FUNCTION_INFO(C_SeedRandom) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_BYTE_PTR pSeed, /* the seed material */ ++ CK_ULONG ulSeedLen /* length of seed material */ ++); ++#endif ++ ++ ++/* C_GenerateRandom generates random data. */ ++CK_PKCS11_FUNCTION_INFO(C_GenerateRandom) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_BYTE_PTR RandomData, /* receives the random data */ ++ CK_ULONG ulRandomLen /* # of bytes to generate */ ++); ++#endif ++ ++ ++ ++/* Parallel function management */ ++ ++/* C_GetFunctionStatus is a legacy function; it obtains an ++ * updated status of a function running in parallel with an ++ * application. */ ++CK_PKCS11_FUNCTION_INFO(C_GetFunctionStatus) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession /* the session's handle */ ++); ++#endif ++ ++ ++/* C_CancelFunction is a legacy function; it cancels a function ++ * running in parallel. */ ++CK_PKCS11_FUNCTION_INFO(C_CancelFunction) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_SESSION_HANDLE hSession /* the session's handle */ ++); ++#endif ++ ++ ++ ++/* Functions added in for Cryptoki Version 2.01 or later */ ++ ++/* C_WaitForSlotEvent waits for a slot event (token insertion, ++ * removal, etc.) to occur. */ ++CK_PKCS11_FUNCTION_INFO(C_WaitForSlotEvent) ++#ifdef CK_NEED_ARG_LIST ++( ++ CK_FLAGS flags, /* blocking/nonblocking flag */ ++ CK_SLOT_ID_PTR pSlot, /* location that receives the slot ID */ ++ CK_VOID_PTR pRserved /* reserved. Should be NULL_PTR */ ++); ++#endif +diff -urNp openssh-4.4p1/pkcs11-headers/pkcs11.h openssh-4.4p1+pkcs11-0.17/pkcs11-headers/pkcs11.h +--- openssh-4.4p1/pkcs11-headers/pkcs11.h 1970-01-01 02:00:00.000000000 +0200 ++++ openssh-4.4p1+pkcs11-0.17/pkcs11-headers/pkcs11.h 2006-09-28 08:05:35.000000000 +0300 +@@ -0,0 +1,299 @@ ++/* pkcs11.h include file for PKCS #11. */ ++/* $Revision: 1.4 $ */ ++ ++/* License to copy and use this software is granted provided that it is ++ * identified as "RSA Security Inc. PKCS #11 Cryptographic Token Interface ++ * (Cryptoki)" in all material mentioning or referencing this software. ++ ++ * License is also granted to make and use derivative works provided that ++ * such works are identified as "derived from the RSA Security Inc. PKCS #11 ++ * Cryptographic Token Interface (Cryptoki)" in all material mentioning or ++ * referencing the derived work. ++ ++ * RSA Security Inc. makes no representations concerning either the ++ * merchantability of this software or the suitability of this software for ++ * any particular purpose. It is provided "as is" without express or implied ++ * warranty of any kind. ++ */ ++ ++#ifndef _PKCS11_H_ ++#define _PKCS11_H_ 1 ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++/* Before including this file (pkcs11.h) (or pkcs11t.h by ++ * itself), 6 platform-specific macros must be defined. These ++ * macros are described below, and typical definitions for them ++ * are also given. Be advised that these definitions can depend ++ * on both the platform and the compiler used (and possibly also ++ * on whether a Cryptoki library is linked statically or ++ * dynamically). ++ * ++ * In addition to defining these 6 macros, the packing convention ++ * for Cryptoki structures should be set. The Cryptoki ++ * convention on packing is that structures should be 1-byte ++ * aligned. ++ * ++ * If you're using Microsoft Developer Studio 5.0 to produce ++ * Win32 stuff, this might be done by using the following ++ * preprocessor directive before including pkcs11.h or pkcs11t.h: ++ * ++ * #pragma pack(push, cryptoki, 1) ++ * ++ * and using the following preprocessor directive after including ++ * pkcs11.h or pkcs11t.h: ++ * ++ * #pragma pack(pop, cryptoki) ++ * ++ * If you're using an earlier version of Microsoft Developer ++ * Studio to produce Win16 stuff, this might be done by using ++ * the following preprocessor directive before including ++ * pkcs11.h or pkcs11t.h: ++ * ++ * #pragma pack(1) ++ * ++ * In a UNIX environment, you're on your own for this. You might ++ * not need to do (or be able to do!) anything. ++ * ++ * ++ * Now for the macros: ++ * ++ * ++ * 1. CK_PTR: The indirection string for making a pointer to an ++ * object. It can be used like this: ++ * ++ * typedef CK_BYTE CK_PTR CK_BYTE_PTR; ++ * ++ * If you're using Microsoft Developer Studio 5.0 to produce ++ * Win32 stuff, it might be defined by: ++ * ++ * #define CK_PTR * ++ * ++ * If you're using an earlier version of Microsoft Developer ++ * Studio to produce Win16 stuff, it might be defined by: ++ * ++ * #define CK_PTR far * ++ * ++ * In a typical UNIX environment, it might be defined by: ++ * ++ * #define CK_PTR * ++ * ++ * ++ * 2. CK_DEFINE_FUNCTION(returnType, name): A macro which makes ++ * an exportable Cryptoki library function definition out of a ++ * return type and a function name. It should be used in the ++ * following fashion to define the exposed Cryptoki functions in ++ * a Cryptoki library: ++ * ++ * CK_DEFINE_FUNCTION(CK_RV, C_Initialize)( ++ * CK_VOID_PTR pReserved ++ * ) ++ * { ++ * ... ++ * } ++ * ++ * If you're using Microsoft Developer Studio 5.0 to define a ++ * function in a Win32 Cryptoki .dll, it might be defined by: ++ * ++ * #define CK_DEFINE_FUNCTION(returnType, name) \ ++ * returnType __declspec(dllexport) name ++ * ++ * If you're using an earlier version of Microsoft Developer ++ * Studio to define a function in a Win16 Cryptoki .dll, it ++ * might be defined by: ++ * ++ * #define CK_DEFINE_FUNCTION(returnType, name) \ ++ * returnType __export _far _pascal name ++ * ++ * In a UNIX environment, it might be defined by: ++ * ++ * #define CK_DEFINE_FUNCTION(returnType, name) \ ++ * returnType name ++ * ++ * ++ * 3. CK_DECLARE_FUNCTION(returnType, name): A macro which makes ++ * an importable Cryptoki library function declaration out of a ++ * return type and a function name. It should be used in the ++ * following fashion: ++ * ++ * extern CK_DECLARE_FUNCTION(CK_RV, C_Initialize)( ++ * CK_VOID_PTR pReserved ++ * ); ++ * ++ * If you're using Microsoft Developer Studio 5.0 to declare a ++ * function in a Win32 Cryptoki .dll, it might be defined by: ++ * ++ * #define CK_DECLARE_FUNCTION(returnType, name) \ ++ * returnType __declspec(dllimport) name ++ * ++ * If you're using an earlier version of Microsoft Developer ++ * Studio to declare a function in a Win16 Cryptoki .dll, it ++ * might be defined by: ++ * ++ * #define CK_DECLARE_FUNCTION(returnType, name) \ ++ * returnType __export _far _pascal name ++ * ++ * In a UNIX environment, it might be defined by: ++ * ++ * #define CK_DECLARE_FUNCTION(returnType, name) \ ++ * returnType name ++ * ++ * ++ * 4. CK_DECLARE_FUNCTION_POINTER(returnType, name): A macro ++ * which makes a Cryptoki API function pointer declaration or ++ * function pointer type declaration out of a return type and a ++ * function name. It should be used in the following fashion: ++ * ++ * // Define funcPtr to be a pointer to a Cryptoki API function ++ * // taking arguments args and returning CK_RV. ++ * CK_DECLARE_FUNCTION_POINTER(CK_RV, funcPtr)(args); ++ * ++ * or ++ * ++ * // Define funcPtrType to be the type of a pointer to a ++ * // Cryptoki API function taking arguments args and returning ++ * // CK_RV, and then define funcPtr to be a variable of type ++ * // funcPtrType. ++ * typedef CK_DECLARE_FUNCTION_POINTER(CK_RV, funcPtrType)(args); ++ * funcPtrType funcPtr; ++ * ++ * If you're using Microsoft Developer Studio 5.0 to access ++ * functions in a Win32 Cryptoki .dll, in might be defined by: ++ * ++ * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \ ++ * returnType __declspec(dllimport) (* name) ++ * ++ * If you're using an earlier version of Microsoft Developer ++ * Studio to access functions in a Win16 Cryptoki .dll, it might ++ * be defined by: ++ * ++ * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \ ++ * returnType __export _far _pascal (* name) ++ * ++ * In a UNIX environment, it might be defined by: ++ * ++ * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \ ++ * returnType (* name) ++ * ++ * ++ * 5. CK_CALLBACK_FUNCTION(returnType, name): A macro which makes ++ * a function pointer type for an application callback out of ++ * a return type for the callback and a name for the callback. ++ * It should be used in the following fashion: ++ * ++ * CK_CALLBACK_FUNCTION(CK_RV, myCallback)(args); ++ * ++ * to declare a function pointer, myCallback, to a callback ++ * which takes arguments args and returns a CK_RV. It can also ++ * be used like this: ++ * ++ * typedef CK_CALLBACK_FUNCTION(CK_RV, myCallbackType)(args); ++ * myCallbackType myCallback; ++ * ++ * If you're using Microsoft Developer Studio 5.0 to do Win32 ++ * Cryptoki development, it might be defined by: ++ * ++ * #define CK_CALLBACK_FUNCTION(returnType, name) \ ++ * returnType (* name) ++ * ++ * If you're using an earlier version of Microsoft Developer ++ * Studio to do Win16 development, it might be defined by: ++ * ++ * #define CK_CALLBACK_FUNCTION(returnType, name) \ ++ * returnType _far _pascal (* name) ++ * ++ * In a UNIX environment, it might be defined by: ++ * ++ * #define CK_CALLBACK_FUNCTION(returnType, name) \ ++ * returnType (* name) ++ * ++ * ++ * 6. NULL_PTR: This macro is the value of a NULL pointer. ++ * ++ * In any ANSI/ISO C environment (and in many others as well), ++ * this should best be defined by ++ * ++ * #ifndef NULL_PTR ++ * #define NULL_PTR 0 ++ * #endif ++ */ ++ ++ ++/* All the various Cryptoki types and #define'd values are in the ++ * file pkcs11t.h. */ ++#include "pkcs11t.h" ++ ++#define __PASTE(x,y) x##y ++ ++ ++/* ============================================================== ++ * Define the "extern" form of all the entry points. ++ * ============================================================== ++ */ ++ ++#define CK_NEED_ARG_LIST 1 ++#define CK_PKCS11_FUNCTION_INFO(name) \ ++ extern CK_DECLARE_FUNCTION(CK_RV, name) ++ ++/* pkcs11f.h has all the information about the Cryptoki ++ * function prototypes. */ ++#include "pkcs11f.h" ++ ++#undef CK_NEED_ARG_LIST ++#undef CK_PKCS11_FUNCTION_INFO ++ ++ ++/* ============================================================== ++ * Define the typedef form of all the entry points. That is, for ++ * each Cryptoki function C_XXX, define a type CK_C_XXX which is ++ * a pointer to that kind of function. ++ * ============================================================== ++ */ ++ ++#define CK_NEED_ARG_LIST 1 ++#define CK_PKCS11_FUNCTION_INFO(name) \ ++ typedef CK_DECLARE_FUNCTION_POINTER(CK_RV, __PASTE(CK_,name)) ++ ++/* pkcs11f.h has all the information about the Cryptoki ++ * function prototypes. */ ++#include "pkcs11f.h" ++ ++#undef CK_NEED_ARG_LIST ++#undef CK_PKCS11_FUNCTION_INFO ++ ++ ++/* ============================================================== ++ * Define structed vector of entry points. A CK_FUNCTION_LIST ++ * contains a CK_VERSION indicating a library's Cryptoki version ++ * and then a whole slew of function pointers to the routines in ++ * the library. This type was declared, but not defined, in ++ * pkcs11t.h. ++ * ============================================================== ++ */ ++ ++#define CK_PKCS11_FUNCTION_INFO(name) \ ++ __PASTE(CK_,name) name; ++ ++struct CK_FUNCTION_LIST { ++ ++ CK_VERSION version; /* Cryptoki version */ ++ ++/* Pile all the function pointers into the CK_FUNCTION_LIST. */ ++/* pkcs11f.h has all the information about the Cryptoki ++ * function prototypes. */ ++#include "pkcs11f.h" ++ ++}; ++ ++#undef CK_PKCS11_FUNCTION_INFO ++ ++ ++#undef __PASTE ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -urNp openssh-4.4p1/pkcs11-headers/pkcs11t.h openssh-4.4p1+pkcs11-0.17/pkcs11-headers/pkcs11t.h +--- openssh-4.4p1/pkcs11-headers/pkcs11t.h 1970-01-01 02:00:00.000000000 +0200 ++++ openssh-4.4p1+pkcs11-0.17/pkcs11-headers/pkcs11t.h 2006-09-28 08:05:35.000000000 +0300 +@@ -0,0 +1,1685 @@ ++/* pkcs11t.h include file for PKCS #11. */ ++/* $Revision: 1.6 $ */ ++ ++/* License to copy and use this software is granted provided that it is ++ * identified as "RSA Security Inc. PKCS #11 Cryptographic Token Interface ++ * (Cryptoki)" in all material mentioning or referencing this software. ++ ++ * License is also granted to make and use derivative works provided that ++ * such works are identified as "derived from the RSA Security Inc. PKCS #11 ++ * Cryptographic Token Interface (Cryptoki)" in all material mentioning or ++ * referencing the derived work. ++ ++ * RSA Security Inc. makes no representations concerning either the ++ * merchantability of this software or the suitability of this software for ++ * any particular purpose. It is provided "as is" without express or implied ++ * warranty of any kind. ++ */ ++ ++/* See top of pkcs11.h for information about the macros that ++ * must be defined and the structure-packing conventions that ++ * must be set before including this file. */ ++ ++#ifndef _PKCS11T_H_ ++#define _PKCS11T_H_ 1 ++ ++#define CK_TRUE 1 ++#define CK_FALSE 0 ++ ++#ifndef CK_DISABLE_TRUE_FALSE ++#ifndef FALSE ++#define FALSE CK_FALSE ++#endif ++ ++#ifndef TRUE ++#define TRUE CK_TRUE ++#endif ++#endif ++ ++/* an unsigned 8-bit value */ ++typedef unsigned char CK_BYTE; ++ ++/* an unsigned 8-bit character */ ++typedef CK_BYTE CK_CHAR; ++ ++/* an 8-bit UTF-8 character */ ++typedef CK_BYTE CK_UTF8CHAR; ++ ++/* a BYTE-sized Boolean flag */ ++typedef CK_BYTE CK_BBOOL; ++ ++/* an unsigned value, at least 32 bits long */ ++typedef unsigned long int CK_ULONG; ++ ++/* a signed value, the same size as a CK_ULONG */ ++/* CK_LONG is new for v2.0 */ ++typedef long int CK_LONG; ++ ++/* at least 32 bits; each bit is a Boolean flag */ ++typedef CK_ULONG CK_FLAGS; ++ ++ ++/* some special values for certain CK_ULONG variables */ ++#define CK_UNAVAILABLE_INFORMATION (~0UL) ++#define CK_EFFECTIVELY_INFINITE 0 ++ ++ ++typedef CK_BYTE CK_PTR CK_BYTE_PTR; ++typedef CK_CHAR CK_PTR CK_CHAR_PTR; ++typedef CK_UTF8CHAR CK_PTR CK_UTF8CHAR_PTR; ++typedef CK_ULONG CK_PTR CK_ULONG_PTR; ++typedef void CK_PTR CK_VOID_PTR; ++ ++/* Pointer to a CK_VOID_PTR-- i.e., pointer to pointer to void */ ++typedef CK_VOID_PTR CK_PTR CK_VOID_PTR_PTR; ++ ++ ++/* The following value is always invalid if used as a session */ ++/* handle or object handle */ ++#define CK_INVALID_HANDLE 0 ++ ++ ++typedef struct CK_VERSION { ++ CK_BYTE major; /* integer portion of version number */ ++ CK_BYTE minor; /* 1/100ths portion of version number */ ++} CK_VERSION; ++ ++typedef CK_VERSION CK_PTR CK_VERSION_PTR; ++ ++ ++typedef struct CK_INFO { ++ /* manufacturerID and libraryDecription have been changed from ++ * CK_CHAR to CK_UTF8CHAR for v2.10 */ ++ CK_VERSION cryptokiVersion; /* Cryptoki interface ver */ ++ CK_UTF8CHAR manufacturerID[32]; /* blank padded */ ++ CK_FLAGS flags; /* must be zero */ ++ ++ /* libraryDescription and libraryVersion are new for v2.0 */ ++ CK_UTF8CHAR libraryDescription[32]; /* blank padded */ ++ CK_VERSION libraryVersion; /* version of library */ ++} CK_INFO; ++ ++typedef CK_INFO CK_PTR CK_INFO_PTR; ++ ++ ++/* CK_NOTIFICATION enumerates the types of notifications that ++ * Cryptoki provides to an application */ ++/* CK_NOTIFICATION has been changed from an enum to a CK_ULONG ++ * for v2.0 */ ++typedef CK_ULONG CK_NOTIFICATION; ++#define CKN_SURRENDER 0 ++ ++ ++typedef CK_ULONG CK_SLOT_ID; ++ ++typedef CK_SLOT_ID CK_PTR CK_SLOT_ID_PTR; ++ ++ ++/* CK_SLOT_INFO provides information about a slot */ ++typedef struct CK_SLOT_INFO { ++ /* slotDescription and manufacturerID have been changed from ++ * CK_CHAR to CK_UTF8CHAR for v2.10 */ ++ CK_UTF8CHAR slotDescription[64]; /* blank padded */ ++ CK_UTF8CHAR manufacturerID[32]; /* blank padded */ ++ CK_FLAGS flags; ++ ++ /* hardwareVersion and firmwareVersion are new for v2.0 */ ++ CK_VERSION hardwareVersion; /* version of hardware */ ++ CK_VERSION firmwareVersion; /* version of firmware */ ++} CK_SLOT_INFO; ++ ++/* flags: bit flags that provide capabilities of the slot ++ * Bit Flag Mask Meaning ++ */ ++#define CKF_TOKEN_PRESENT 0x00000001 /* a token is there */ ++#define CKF_REMOVABLE_DEVICE 0x00000002 /* removable devices*/ ++#define CKF_HW_SLOT 0x00000004 /* hardware slot */ ++ ++typedef CK_SLOT_INFO CK_PTR CK_SLOT_INFO_PTR; ++ ++ ++/* CK_TOKEN_INFO provides information about a token */ ++typedef struct CK_TOKEN_INFO { ++ /* label, manufacturerID, and model have been changed from ++ * CK_CHAR to CK_UTF8CHAR for v2.10 */ ++ CK_UTF8CHAR label[32]; /* blank padded */ ++ CK_UTF8CHAR manufacturerID[32]; /* blank padded */ ++ CK_UTF8CHAR model[16]; /* blank padded */ ++ CK_CHAR serialNumber[16]; /* blank padded */ ++ CK_FLAGS flags; /* see below */ ++ ++ /* ulMaxSessionCount, ulSessionCount, ulMaxRwSessionCount, ++ * ulRwSessionCount, ulMaxPinLen, and ulMinPinLen have all been ++ * changed from CK_USHORT to CK_ULONG for v2.0 */ ++ CK_ULONG ulMaxSessionCount; /* max open sessions */ ++ CK_ULONG ulSessionCount; /* sess. now open */ ++ CK_ULONG ulMaxRwSessionCount; /* max R/W sessions */ ++ CK_ULONG ulRwSessionCount; /* R/W sess. now open */ ++ CK_ULONG ulMaxPinLen; /* in bytes */ ++ CK_ULONG ulMinPinLen; /* in bytes */ ++ CK_ULONG ulTotalPublicMemory; /* in bytes */ ++ CK_ULONG ulFreePublicMemory; /* in bytes */ ++ CK_ULONG ulTotalPrivateMemory; /* in bytes */ ++ CK_ULONG ulFreePrivateMemory; /* in bytes */ ++ ++ /* hardwareVersion, firmwareVersion, and time are new for ++ * v2.0 */ ++ CK_VERSION hardwareVersion; /* version of hardware */ ++ CK_VERSION firmwareVersion; /* version of firmware */ ++ CK_CHAR utcTime[16]; /* time */ ++} CK_TOKEN_INFO; ++ ++/* The flags parameter is defined as follows: ++ * Bit Flag Mask Meaning ++ */ ++#define CKF_RNG 0x00000001 /* has random # ++ * generator */ ++#define CKF_WRITE_PROTECTED 0x00000002 /* token is ++ * write- ++ * protected */ ++#define CKF_LOGIN_REQUIRED 0x00000004 /* user must ++ * login */ ++#define CKF_USER_PIN_INITIALIZED 0x00000008 /* normal user's ++ * PIN is set */ ++ ++/* CKF_RESTORE_KEY_NOT_NEEDED is new for v2.0. If it is set, ++ * that means that *every* time the state of cryptographic ++ * operations of a session is successfully saved, all keys ++ * needed to continue those operations are stored in the state */ ++#define CKF_RESTORE_KEY_NOT_NEEDED 0x00000020 ++ ++/* CKF_CLOCK_ON_TOKEN is new for v2.0. If it is set, that means ++ * that the token has some sort of clock. The time on that ++ * clock is returned in the token info structure */ ++#define CKF_CLOCK_ON_TOKEN 0x00000040 ++ ++/* CKF_PROTECTED_AUTHENTICATION_PATH is new for v2.0. If it is ++ * set, that means that there is some way for the user to login ++ * without sending a PIN through the Cryptoki library itself */ ++#define CKF_PROTECTED_AUTHENTICATION_PATH 0x00000100 ++ ++/* CKF_DUAL_CRYPTO_OPERATIONS is new for v2.0. If it is true, ++ * that means that a single session with the token can perform ++ * dual simultaneous cryptographic operations (digest and ++ * encrypt; decrypt and digest; sign and encrypt; and decrypt ++ * and sign) */ ++#define CKF_DUAL_CRYPTO_OPERATIONS 0x00000200 ++ ++/* CKF_TOKEN_INITIALIZED if new for v2.10. If it is true, the ++ * token has been initialized using C_InitializeToken or an ++ * equivalent mechanism outside the scope of PKCS #11. ++ * Calling C_InitializeToken when this flag is set will cause ++ * the token to be reinitialized. */ ++#define CKF_TOKEN_INITIALIZED 0x00000400 ++ ++/* CKF_SECONDARY_AUTHENTICATION if new for v2.10. If it is ++ * true, the token supports secondary authentication for ++ * private key objects. This flag is deprecated in v2.11 and ++ onwards. */ ++#define CKF_SECONDARY_AUTHENTICATION 0x00000800 ++ ++/* CKF_USER_PIN_COUNT_LOW if new for v2.10. If it is true, an ++ * incorrect user login PIN has been entered at least once ++ * since the last successful authentication. */ ++#define CKF_USER_PIN_COUNT_LOW 0x00010000 ++ ++/* CKF_USER_PIN_FINAL_TRY if new for v2.10. If it is true, ++ * supplying an incorrect user PIN will it to become locked. */ ++#define CKF_USER_PIN_FINAL_TRY 0x00020000 ++ ++/* CKF_USER_PIN_LOCKED if new for v2.10. If it is true, the ++ * user PIN has been locked. User login to the token is not ++ * possible. */ ++#define CKF_USER_PIN_LOCKED 0x00040000 ++ ++/* CKF_USER_PIN_TO_BE_CHANGED if new for v2.10. If it is true, ++ * the user PIN value is the default value set by token ++ * initialization or manufacturing, or the PIN has been ++ * expired by the card. */ ++#define CKF_USER_PIN_TO_BE_CHANGED 0x00080000 ++ ++/* CKF_SO_PIN_COUNT_LOW if new for v2.10. If it is true, an ++ * incorrect SO login PIN has been entered at least once since ++ * the last successful authentication. */ ++#define CKF_SO_PIN_COUNT_LOW 0x00100000 ++ ++/* CKF_SO_PIN_FINAL_TRY if new for v2.10. If it is true, ++ * supplying an incorrect SO PIN will it to become locked. */ ++#define CKF_SO_PIN_FINAL_TRY 0x00200000 ++ ++/* CKF_SO_PIN_LOCKED if new for v2.10. If it is true, the SO ++ * PIN has been locked. SO login to the token is not possible. ++ */ ++#define CKF_SO_PIN_LOCKED 0x00400000 ++ ++/* CKF_SO_PIN_TO_BE_CHANGED if new for v2.10. If it is true, ++ * the SO PIN value is the default value set by token ++ * initialization or manufacturing, or the PIN has been ++ * expired by the card. */ ++#define CKF_SO_PIN_TO_BE_CHANGED 0x00800000 ++ ++typedef CK_TOKEN_INFO CK_PTR CK_TOKEN_INFO_PTR; ++ ++ ++/* CK_SESSION_HANDLE is a Cryptoki-assigned value that ++ * identifies a session */ ++typedef CK_ULONG CK_SESSION_HANDLE; ++ ++typedef CK_SESSION_HANDLE CK_PTR CK_SESSION_HANDLE_PTR; ++ ++ ++/* CK_USER_TYPE enumerates the types of Cryptoki users */ ++/* CK_USER_TYPE has been changed from an enum to a CK_ULONG for ++ * v2.0 */ ++typedef CK_ULONG CK_USER_TYPE; ++/* Security Officer */ ++#define CKU_SO 0 ++/* Normal user */ ++#define CKU_USER 1 ++/* Context specific (added in v2.20) */ ++#define CKU_CONTEXT_SPECIFIC 2 ++ ++/* CK_STATE enumerates the session states */ ++/* CK_STATE has been changed from an enum to a CK_ULONG for ++ * v2.0 */ ++typedef CK_ULONG CK_STATE; ++#define CKS_RO_PUBLIC_SESSION 0 ++#define CKS_RO_USER_FUNCTIONS 1 ++#define CKS_RW_PUBLIC_SESSION 2 ++#define CKS_RW_USER_FUNCTIONS 3 ++#define CKS_RW_SO_FUNCTIONS 4 ++ ++ ++/* CK_SESSION_INFO provides information about a session */ ++typedef struct CK_SESSION_INFO { ++ CK_SLOT_ID slotID; ++ CK_STATE state; ++ CK_FLAGS flags; /* see below */ ++ ++ /* ulDeviceError was changed from CK_USHORT to CK_ULONG for ++ * v2.0 */ ++ CK_ULONG ulDeviceError; /* device-dependent error code */ ++} CK_SESSION_INFO; ++ ++/* The flags are defined in the following table: ++ * Bit Flag Mask Meaning ++ */ ++#define CKF_RW_SESSION 0x00000002 /* session is r/w */ ++#define CKF_SERIAL_SESSION 0x00000004 /* no parallel */ ++ ++typedef CK_SESSION_INFO CK_PTR CK_SESSION_INFO_PTR; ++ ++ ++/* CK_OBJECT_HANDLE is a token-specific identifier for an ++ * object */ ++typedef CK_ULONG CK_OBJECT_HANDLE; ++ ++typedef CK_OBJECT_HANDLE CK_PTR CK_OBJECT_HANDLE_PTR; ++ ++ ++/* CK_OBJECT_CLASS is a value that identifies the classes (or ++ * types) of objects that Cryptoki recognizes. It is defined ++ * as follows: */ ++/* CK_OBJECT_CLASS was changed from CK_USHORT to CK_ULONG for ++ * v2.0 */ ++typedef CK_ULONG CK_OBJECT_CLASS; ++ ++/* The following classes of objects are defined: */ ++/* CKO_HW_FEATURE is new for v2.10 */ ++/* CKO_DOMAIN_PARAMETERS is new for v2.11 */ ++/* CKO_MECHANISM is new for v2.20 */ ++#define CKO_DATA 0x00000000 ++#define CKO_CERTIFICATE 0x00000001 ++#define CKO_PUBLIC_KEY 0x00000002 ++#define CKO_PRIVATE_KEY 0x00000003 ++#define CKO_SECRET_KEY 0x00000004 ++#define CKO_HW_FEATURE 0x00000005 ++#define CKO_DOMAIN_PARAMETERS 0x00000006 ++#define CKO_MECHANISM 0x00000007 ++#define CKO_VENDOR_DEFINED 0x80000000 ++ ++typedef CK_OBJECT_CLASS CK_PTR CK_OBJECT_CLASS_PTR; ++ ++/* CK_HW_FEATURE_TYPE is new for v2.10. CK_HW_FEATURE_TYPE is a ++ * value that identifies the hardware feature type of an object ++ * with CK_OBJECT_CLASS equal to CKO_HW_FEATURE. */ ++typedef CK_ULONG CK_HW_FEATURE_TYPE; ++ ++/* The following hardware feature types are defined */ ++/* CKH_USER_INTERFACE is new for v2.20 */ ++#define CKH_MONOTONIC_COUNTER 0x00000001 ++#define CKH_CLOCK 0x00000002 ++#define CKH_USER_INTERFACE 0x00000003 ++#define CKH_VENDOR_DEFINED 0x80000000 ++ ++/* CK_KEY_TYPE is a value that identifies a key type */ ++/* CK_KEY_TYPE was changed from CK_USHORT to CK_ULONG for v2.0 */ ++typedef CK_ULONG CK_KEY_TYPE; ++ ++/* the following key types are defined: */ ++#define CKK_RSA 0x00000000 ++#define CKK_DSA 0x00000001 ++#define CKK_DH 0x00000002 ++ ++/* CKK_ECDSA and CKK_KEA are new for v2.0 */ ++/* CKK_ECDSA is deprecated in v2.11, CKK_EC is preferred. */ ++#define CKK_ECDSA 0x00000003 ++#define CKK_EC 0x00000003 ++#define CKK_X9_42_DH 0x00000004 ++#define CKK_KEA 0x00000005 ++ ++#define CKK_GENERIC_SECRET 0x00000010 ++#define CKK_RC2 0x00000011 ++#define CKK_RC4 0x00000012 ++#define CKK_DES 0x00000013 ++#define CKK_DES2 0x00000014 ++#define CKK_DES3 0x00000015 ++ ++/* all these key types are new for v2.0 */ ++#define CKK_CAST 0x00000016 ++#define CKK_CAST3 0x00000017 ++/* CKK_CAST5 is deprecated in v2.11, CKK_CAST128 is preferred. */ ++#define CKK_CAST5 0x00000018 ++#define CKK_CAST128 0x00000018 ++#define CKK_RC5 0x00000019 ++#define CKK_IDEA 0x0000001A ++#define CKK_SKIPJACK 0x0000001B ++#define CKK_BATON 0x0000001C ++#define CKK_JUNIPER 0x0000001D ++#define CKK_CDMF 0x0000001E ++#define CKK_AES 0x0000001F ++ ++/* BlowFish and TwoFish are new for v2.20 */ ++#define CKK_BLOWFISH 0x00000020 ++#define CKK_TWOFISH 0x00000021 ++ ++#define CKK_VENDOR_DEFINED 0x80000000 ++ ++ ++/* CK_CERTIFICATE_TYPE is a value that identifies a certificate ++ * type */ ++/* CK_CERTIFICATE_TYPE was changed from CK_USHORT to CK_ULONG ++ * for v2.0 */ ++typedef CK_ULONG CK_CERTIFICATE_TYPE; ++ ++/* The following certificate types are defined: */ ++/* CKC_X_509_ATTR_CERT is new for v2.10 */ ++/* CKC_WTLS is new for v2.20 */ ++#define CKC_X_509 0x00000000 ++#define CKC_X_509_ATTR_CERT 0x00000001 ++#define CKC_WTLS 0x00000002 ++#define CKC_VENDOR_DEFINED 0x80000000 ++ ++ ++/* CK_ATTRIBUTE_TYPE is a value that identifies an attribute ++ * type */ ++/* CK_ATTRIBUTE_TYPE was changed from CK_USHORT to CK_ULONG for ++ * v2.0 */ ++typedef CK_ULONG CK_ATTRIBUTE_TYPE; ++ ++/* The CKF_ARRAY_ATTRIBUTE flag identifies an attribute which ++ consists of an array of values. */ ++#define CKF_ARRAY_ATTRIBUTE 0x40000000 ++ ++/* The following attribute types are defined: */ ++#define CKA_CLASS 0x00000000 ++#define CKA_TOKEN 0x00000001 ++#define CKA_PRIVATE 0x00000002 ++#define CKA_LABEL 0x00000003 ++#define CKA_APPLICATION 0x00000010 ++#define CKA_VALUE 0x00000011 ++ ++/* CKA_OBJECT_ID is new for v2.10 */ ++#define CKA_OBJECT_ID 0x00000012 ++ ++#define CKA_CERTIFICATE_TYPE 0x00000080 ++#define CKA_ISSUER 0x00000081 ++#define CKA_SERIAL_NUMBER 0x00000082 ++ ++/* CKA_AC_ISSUER, CKA_OWNER, and CKA_ATTR_TYPES are new ++ * for v2.10 */ ++#define CKA_AC_ISSUER 0x00000083 ++#define CKA_OWNER 0x00000084 ++#define CKA_ATTR_TYPES 0x00000085 ++ ++/* CKA_TRUSTED is new for v2.11 */ ++#define CKA_TRUSTED 0x00000086 ++ ++/* CKA_CERTIFICATE_CATEGORY ... ++ * CKA_CHECK_VALUE are new for v2.20 */ ++#define CKA_CERTIFICATE_CATEGORY 0x00000087 ++#define CKA_JAVA_MIDP_SECURITY_DOMAIN 0x00000088 ++#define CKA_URL 0x00000089 ++#define CKA_HASH_OF_SUBJECT_PUBLIC_KEY 0x0000008A ++#define CKA_HASH_OF_ISSUER_PUBLIC_KEY 0x0000008B ++#define CKA_CHECK_VALUE 0x00000090 ++ ++#define CKA_KEY_TYPE 0x00000100 ++#define CKA_SUBJECT 0x00000101 ++#define CKA_ID 0x00000102 ++#define CKA_SENSITIVE 0x00000103 ++#define CKA_ENCRYPT 0x00000104 ++#define CKA_DECRYPT 0x00000105 ++#define CKA_WRAP 0x00000106 ++#define CKA_UNWRAP 0x00000107 ++#define CKA_SIGN 0x00000108 ++#define CKA_SIGN_RECOVER 0x00000109 ++#define CKA_VERIFY 0x0000010A ++#define CKA_VERIFY_RECOVER 0x0000010B ++#define CKA_DERIVE 0x0000010C ++#define CKA_START_DATE 0x00000110 ++#define CKA_END_DATE 0x00000111 ++#define CKA_MODULUS 0x00000120 ++#define CKA_MODULUS_BITS 0x00000121 ++#define CKA_PUBLIC_EXPONENT 0x00000122 ++#define CKA_PRIVATE_EXPONENT 0x00000123 ++#define CKA_PRIME_1 0x00000124 ++#define CKA_PRIME_2 0x00000125 ++#define CKA_EXPONENT_1 0x00000126 ++#define CKA_EXPONENT_2 0x00000127 ++#define CKA_COEFFICIENT 0x00000128 ++#define CKA_PRIME 0x00000130 ++#define CKA_SUBPRIME 0x00000131 ++#define CKA_BASE 0x00000132 ++ ++/* CKA_PRIME_BITS and CKA_SUB_PRIME_BITS are new for v2.11 */ ++#define CKA_PRIME_BITS 0x00000133 ++#define CKA_SUBPRIME_BITS 0x00000134 ++#define CKA_SUB_PRIME_BITS CKA_SUBPRIME_BITS ++/* (To retain backwards-compatibility) */ ++ ++#define CKA_VALUE_BITS 0x00000160 ++#define CKA_VALUE_LEN 0x00000161 ++ ++/* CKA_EXTRACTABLE, CKA_LOCAL, CKA_NEVER_EXTRACTABLE, ++ * CKA_ALWAYS_SENSITIVE, CKA_MODIFIABLE, CKA_ECDSA_PARAMS, ++ * and CKA_EC_POINT are new for v2.0 */ ++#define CKA_EXTRACTABLE 0x00000162 ++#define CKA_LOCAL 0x00000163 ++#define CKA_NEVER_EXTRACTABLE 0x00000164 ++#define CKA_ALWAYS_SENSITIVE 0x00000165 ++ ++/* CKA_KEY_GEN_MECHANISM is new for v2.11 */ ++#define CKA_KEY_GEN_MECHANISM 0x00000166 ++ ++#define CKA_MODIFIABLE 0x00000170 ++ ++/* CKA_ECDSA_PARAMS is deprecated in v2.11, ++ * CKA_EC_PARAMS is preferred. */ ++#define CKA_ECDSA_PARAMS 0x00000180 ++#define CKA_EC_PARAMS 0x00000180 ++ ++#define CKA_EC_POINT 0x00000181 ++ ++/* CKA_SECONDARY_AUTH, CKA_AUTH_PIN_FLAGS, ++ * are new for v2.10. Deprecated in v2.11 and onwards. */ ++#define CKA_SECONDARY_AUTH 0x00000200 ++#define CKA_AUTH_PIN_FLAGS 0x00000201 ++ ++/* CKA_ALWAYS_AUTHENTICATE ... ++ * CKA_UNWRAP_TEMPLATE are new for v2.20 */ ++#define CKA_ALWAYS_AUTHENTICATE 0x00000202 ++ ++#define CKA_WRAP_WITH_TRUSTED 0x00000210 ++#define CKA_WRAP_TEMPLATE (CKF_ARRAY_ATTRIBUTE|0x00000211) ++#define CKA_UNWRAP_TEMPLATE (CKF_ARRAY_ATTRIBUTE|0x00000212) ++ ++/* CKA_HW_FEATURE_TYPE, CKA_RESET_ON_INIT, and CKA_HAS_RESET ++ * are new for v2.10 */ ++#define CKA_HW_FEATURE_TYPE 0x00000300 ++#define CKA_RESET_ON_INIT 0x00000301 ++#define CKA_HAS_RESET 0x00000302 ++ ++/* The following attributes are new for v2.20 */ ++#define CKA_PIXEL_X 0x00000400 ++#define CKA_PIXEL_Y 0x00000401 ++#define CKA_RESOLUTION 0x00000402 ++#define CKA_CHAR_ROWS 0x00000403 ++#define CKA_CHAR_COLUMNS 0x00000404 ++#define CKA_COLOR 0x00000405 ++#define CKA_BITS_PER_PIXEL 0x00000406 ++#define CKA_CHAR_SETS 0x00000480 ++#define CKA_ENCODING_METHODS 0x00000481 ++#define CKA_MIME_TYPES 0x00000482 ++#define CKA_MECHANISM_TYPE 0x00000500 ++#define CKA_REQUIRED_CMS_ATTRIBUTES 0x00000501 ++#define CKA_DEFAULT_CMS_ATTRIBUTES 0x00000502 ++#define CKA_SUPPORTED_CMS_ATTRIBUTES 0x00000503 ++#define CKA_ALLOWED_MECHANISMS (CKF_ARRAY_ATTRIBUTE|0x00000600) ++ ++#define CKA_VENDOR_DEFINED 0x80000000 ++ ++ ++/* CK_ATTRIBUTE is a structure that includes the type, length ++ * and value of an attribute */ ++typedef struct CK_ATTRIBUTE { ++ CK_ATTRIBUTE_TYPE type; ++ CK_VOID_PTR pValue; ++ ++ /* ulValueLen went from CK_USHORT to CK_ULONG for v2.0 */ ++ CK_ULONG ulValueLen; /* in bytes */ ++} CK_ATTRIBUTE; ++ ++typedef CK_ATTRIBUTE CK_PTR CK_ATTRIBUTE_PTR; ++ ++ ++/* CK_DATE is a structure that defines a date */ ++typedef struct CK_DATE{ ++ CK_CHAR year[4]; /* the year ("1900" - "9999") */ ++ CK_CHAR month[2]; /* the month ("01" - "12") */ ++ CK_CHAR day[2]; /* the day ("01" - "31") */ ++} CK_DATE; ++ ++ ++/* CK_MECHANISM_TYPE is a value that identifies a mechanism ++ * type */ ++/* CK_MECHANISM_TYPE was changed from CK_USHORT to CK_ULONG for ++ * v2.0 */ ++typedef CK_ULONG CK_MECHANISM_TYPE; ++ ++/* the following mechanism types are defined: */ ++#define CKM_RSA_PKCS_KEY_PAIR_GEN 0x00000000 ++#define CKM_RSA_PKCS 0x00000001 ++#define CKM_RSA_9796 0x00000002 ++#define CKM_RSA_X_509 0x00000003 ++ ++/* CKM_MD2_RSA_PKCS, CKM_MD5_RSA_PKCS, and CKM_SHA1_RSA_PKCS ++ * are new for v2.0. They are mechanisms which hash and sign */ ++#define CKM_MD2_RSA_PKCS 0x00000004 ++#define CKM_MD5_RSA_PKCS 0x00000005 ++#define CKM_SHA1_RSA_PKCS 0x00000006 ++ ++/* CKM_RIPEMD128_RSA_PKCS, CKM_RIPEMD160_RSA_PKCS, and ++ * CKM_RSA_PKCS_OAEP are new for v2.10 */ ++#define CKM_RIPEMD128_RSA_PKCS 0x00000007 ++#define CKM_RIPEMD160_RSA_PKCS 0x00000008 ++#define CKM_RSA_PKCS_OAEP 0x00000009 ++ ++/* CKM_RSA_X9_31_KEY_PAIR_GEN, CKM_RSA_X9_31, CKM_SHA1_RSA_X9_31, ++ * CKM_RSA_PKCS_PSS, and CKM_SHA1_RSA_PKCS_PSS are new for v2.11 */ ++#define CKM_RSA_X9_31_KEY_PAIR_GEN 0x0000000A ++#define CKM_RSA_X9_31 0x0000000B ++#define CKM_SHA1_RSA_X9_31 0x0000000C ++#define CKM_RSA_PKCS_PSS 0x0000000D ++#define CKM_SHA1_RSA_PKCS_PSS 0x0000000E ++ ++#define CKM_DSA_KEY_PAIR_GEN 0x00000010 ++#define CKM_DSA 0x00000011 ++#define CKM_DSA_SHA1 0x00000012 ++#define CKM_DH_PKCS_KEY_PAIR_GEN 0x00000020 ++#define CKM_DH_PKCS_DERIVE 0x00000021 ++ ++/* CKM_X9_42_DH_KEY_PAIR_GEN, CKM_X9_42_DH_DERIVE, ++ * CKM_X9_42_DH_HYBRID_DERIVE, and CKM_X9_42_MQV_DERIVE are new for ++ * v2.11 */ ++#define CKM_X9_42_DH_KEY_PAIR_GEN 0x00000030 ++#define CKM_X9_42_DH_DERIVE 0x00000031 ++#define CKM_X9_42_DH_HYBRID_DERIVE 0x00000032 ++#define CKM_X9_42_MQV_DERIVE 0x00000033 ++ ++/* CKM_SHA256/384/512 are new for v2.20 */ ++#define CKM_SHA256_RSA_PKCS 0x00000040 ++#define CKM_SHA384_RSA_PKCS 0x00000041 ++#define CKM_SHA512_RSA_PKCS 0x00000042 ++#define CKM_SHA256_RSA_PKCS_PSS 0x00000043 ++#define CKM_SHA384_RSA_PKCS_PSS 0x00000044 ++#define CKM_SHA512_RSA_PKCS_PSS 0x00000045 ++ ++#define CKM_RC2_KEY_GEN 0x00000100 ++#define CKM_RC2_ECB 0x00000101 ++#define CKM_RC2_CBC 0x00000102 ++#define CKM_RC2_MAC 0x00000103 ++ ++/* CKM_RC2_MAC_GENERAL and CKM_RC2_CBC_PAD are new for v2.0 */ ++#define CKM_RC2_MAC_GENERAL 0x00000104 ++#define CKM_RC2_CBC_PAD 0x00000105 ++ ++#define CKM_RC4_KEY_GEN 0x00000110 ++#define CKM_RC4 0x00000111 ++#define CKM_DES_KEY_GEN 0x00000120 ++#define CKM_DES_ECB 0x00000121 ++#define CKM_DES_CBC 0x00000122 ++#define CKM_DES_MAC 0x00000123 ++ ++/* CKM_DES_MAC_GENERAL and CKM_DES_CBC_PAD are new for v2.0 */ ++#define CKM_DES_MAC_GENERAL 0x00000124 ++#define CKM_DES_CBC_PAD 0x00000125 ++ ++#define CKM_DES2_KEY_GEN 0x00000130 ++#define CKM_DES3_KEY_GEN 0x00000131 ++#define CKM_DES3_ECB 0x00000132 ++#define CKM_DES3_CBC 0x00000133 ++#define CKM_DES3_MAC 0x00000134 ++ ++/* CKM_DES3_MAC_GENERAL, CKM_DES3_CBC_PAD, CKM_CDMF_KEY_GEN, ++ * CKM_CDMF_ECB, CKM_CDMF_CBC, CKM_CDMF_MAC, ++ * CKM_CDMF_MAC_GENERAL, and CKM_CDMF_CBC_PAD are new for v2.0 */ ++#define CKM_DES3_MAC_GENERAL 0x00000135 ++#define CKM_DES3_CBC_PAD 0x00000136 ++#define CKM_CDMF_KEY_GEN 0x00000140 ++#define CKM_CDMF_ECB 0x00000141 ++#define CKM_CDMF_CBC 0x00000142 ++#define CKM_CDMF_MAC 0x00000143 ++#define CKM_CDMF_MAC_GENERAL 0x00000144 ++#define CKM_CDMF_CBC_PAD 0x00000145 ++ ++/* the following four DES mechanisms are new for v2.20 */ ++#define CKM_DES_OFB64 0x00000150 ++#define CKM_DES_OFB8 0x00000151 ++#define CKM_DES_CFB64 0x00000152 ++#define CKM_DES_CFB8 0x00000153 ++ ++#define CKM_MD2 0x00000200 ++ ++/* CKM_MD2_HMAC and CKM_MD2_HMAC_GENERAL are new for v2.0 */ ++#define CKM_MD2_HMAC 0x00000201 ++#define CKM_MD2_HMAC_GENERAL 0x00000202 ++ ++#define CKM_MD5 0x00000210 ++ ++/* CKM_MD5_HMAC and CKM_MD5_HMAC_GENERAL are new for v2.0 */ ++#define CKM_MD5_HMAC 0x00000211 ++#define CKM_MD5_HMAC_GENERAL 0x00000212 ++ ++#define CKM_SHA_1 0x00000220 ++ ++/* CKM_SHA_1_HMAC and CKM_SHA_1_HMAC_GENERAL are new for v2.0 */ ++#define CKM_SHA_1_HMAC 0x00000221 ++#define CKM_SHA_1_HMAC_GENERAL 0x00000222 ++ ++/* CKM_RIPEMD128, CKM_RIPEMD128_HMAC, ++ * CKM_RIPEMD128_HMAC_GENERAL, CKM_RIPEMD160, CKM_RIPEMD160_HMAC, ++ * and CKM_RIPEMD160_HMAC_GENERAL are new for v2.10 */ ++#define CKM_RIPEMD128 0x00000230 ++#define CKM_RIPEMD128_HMAC 0x00000231 ++#define CKM_RIPEMD128_HMAC_GENERAL 0x00000232 ++#define CKM_RIPEMD160 0x00000240 ++#define CKM_RIPEMD160_HMAC 0x00000241 ++#define CKM_RIPEMD160_HMAC_GENERAL 0x00000242 ++ ++/* CKM_SHA256/384/512 are new for v2.20 */ ++#define CKM_SHA256 0x00000250 ++#define CKM_SHA256_HMAC 0x00000251 ++#define CKM_SHA256_HMAC_GENERAL 0x00000252 ++#define CKM_SHA384 0x00000260 ++#define CKM_SHA384_HMAC 0x00000261 ++#define CKM_SHA384_HMAC_GENERAL 0x00000262 ++#define CKM_SHA512 0x00000270 ++#define CKM_SHA512_HMAC 0x00000271 ++#define CKM_SHA512_HMAC_GENERAL 0x00000272 ++ ++/* All of the following mechanisms are new for v2.0 */ ++/* Note that CAST128 and CAST5 are the same algorithm */ ++#define CKM_CAST_KEY_GEN 0x00000300 ++#define CKM_CAST_ECB 0x00000301 ++#define CKM_CAST_CBC 0x00000302 ++#define CKM_CAST_MAC 0x00000303 ++#define CKM_CAST_MAC_GENERAL 0x00000304 ++#define CKM_CAST_CBC_PAD 0x00000305 ++#define CKM_CAST3_KEY_GEN 0x00000310 ++#define CKM_CAST3_ECB 0x00000311 ++#define CKM_CAST3_CBC 0x00000312 ++#define CKM_CAST3_MAC 0x00000313 ++#define CKM_CAST3_MAC_GENERAL 0x00000314 ++#define CKM_CAST3_CBC_PAD 0x00000315 ++#define CKM_CAST5_KEY_GEN 0x00000320 ++#define CKM_CAST128_KEY_GEN 0x00000320 ++#define CKM_CAST5_ECB 0x00000321 ++#define CKM_CAST128_ECB 0x00000321 ++#define CKM_CAST5_CBC 0x00000322 ++#define CKM_CAST128_CBC 0x00000322 ++#define CKM_CAST5_MAC 0x00000323 ++#define CKM_CAST128_MAC 0x00000323 ++#define CKM_CAST5_MAC_GENERAL 0x00000324 ++#define CKM_CAST128_MAC_GENERAL 0x00000324 ++#define CKM_CAST5_CBC_PAD 0x00000325 ++#define CKM_CAST128_CBC_PAD 0x00000325 ++#define CKM_RC5_KEY_GEN 0x00000330 ++#define CKM_RC5_ECB 0x00000331 ++#define CKM_RC5_CBC 0x00000332 ++#define CKM_RC5_MAC 0x00000333 ++#define CKM_RC5_MAC_GENERAL 0x00000334 ++#define CKM_RC5_CBC_PAD 0x00000335 ++#define CKM_IDEA_KEY_GEN 0x00000340 ++#define CKM_IDEA_ECB 0x00000341 ++#define CKM_IDEA_CBC 0x00000342 ++#define CKM_IDEA_MAC 0x00000343 ++#define CKM_IDEA_MAC_GENERAL 0x00000344 ++#define CKM_IDEA_CBC_PAD 0x00000345 ++#define CKM_GENERIC_SECRET_KEY_GEN 0x00000350 ++#define CKM_CONCATENATE_BASE_AND_KEY 0x00000360 ++#define CKM_CONCATENATE_BASE_AND_DATA 0x00000362 ++#define CKM_CONCATENATE_DATA_AND_BASE 0x00000363 ++#define CKM_XOR_BASE_AND_DATA 0x00000364 ++#define CKM_EXTRACT_KEY_FROM_KEY 0x00000365 ++#define CKM_SSL3_PRE_MASTER_KEY_GEN 0x00000370 ++#define CKM_SSL3_MASTER_KEY_DERIVE 0x00000371 ++#define CKM_SSL3_KEY_AND_MAC_DERIVE 0x00000372 ++ ++/* CKM_SSL3_MASTER_KEY_DERIVE_DH, CKM_TLS_PRE_MASTER_KEY_GEN, ++ * CKM_TLS_MASTER_KEY_DERIVE, CKM_TLS_KEY_AND_MAC_DERIVE, and ++ * CKM_TLS_MASTER_KEY_DERIVE_DH are new for v2.11 */ ++#define CKM_SSL3_MASTER_KEY_DERIVE_DH 0x00000373 ++#define CKM_TLS_PRE_MASTER_KEY_GEN 0x00000374 ++#define CKM_TLS_MASTER_KEY_DERIVE 0x00000375 ++#define CKM_TLS_KEY_AND_MAC_DERIVE 0x00000376 ++#define CKM_TLS_MASTER_KEY_DERIVE_DH 0x00000377 ++ ++/* CKM_TLS_PRF is new for v2.20 */ ++#define CKM_TLS_PRF 0x00000378 ++ ++#define CKM_SSL3_MD5_MAC 0x00000380 ++#define CKM_SSL3_SHA1_MAC 0x00000381 ++#define CKM_MD5_KEY_DERIVATION 0x00000390 ++#define CKM_MD2_KEY_DERIVATION 0x00000391 ++#define CKM_SHA1_KEY_DERIVATION 0x00000392 ++ ++/* CKM_SHA256/384/512 are new for v2.20 */ ++#define CKM_SHA256_KEY_DERIVATION 0x00000393 ++#define CKM_SHA384_KEY_DERIVATION 0x00000394 ++#define CKM_SHA512_KEY_DERIVATION 0x00000395 ++ ++#define CKM_PBE_MD2_DES_CBC 0x000003A0 ++#define CKM_PBE_MD5_DES_CBC 0x000003A1 ++#define CKM_PBE_MD5_CAST_CBC 0x000003A2 ++#define CKM_PBE_MD5_CAST3_CBC 0x000003A3 ++#define CKM_PBE_MD5_CAST5_CBC 0x000003A4 ++#define CKM_PBE_MD5_CAST128_CBC 0x000003A4 ++#define CKM_PBE_SHA1_CAST5_CBC 0x000003A5 ++#define CKM_PBE_SHA1_CAST128_CBC 0x000003A5 ++#define CKM_PBE_SHA1_RC4_128 0x000003A6 ++#define CKM_PBE_SHA1_RC4_40 0x000003A7 ++#define CKM_PBE_SHA1_DES3_EDE_CBC 0x000003A8 ++#define CKM_PBE_SHA1_DES2_EDE_CBC 0x000003A9 ++#define CKM_PBE_SHA1_RC2_128_CBC 0x000003AA ++#define CKM_PBE_SHA1_RC2_40_CBC 0x000003AB ++ ++/* CKM_PKCS5_PBKD2 is new for v2.10 */ ++#define CKM_PKCS5_PBKD2 0x000003B0 ++ ++#define CKM_PBA_SHA1_WITH_SHA1_HMAC 0x000003C0 ++ ++/* WTLS mechanisms are new for v2.20 */ ++#define CKM_WTLS_PRE_MASTER_KEY_GEN 0x000003D0 ++#define CKM_WTLS_MASTER_KEY_DERIVE 0x000003D1 ++#define CKM_WTLS_MASTER_KEY_DERIVE_DH_ECC 0x000003D2 ++#define CKM_WTLS_PRF 0x000003D3 ++#define CKM_WTLS_SERVER_KEY_AND_MAC_DERIVE 0x000003D4 ++#define CKM_WTLS_CLIENT_KEY_AND_MAC_DERIVE 0x000003D5 ++ ++#define CKM_KEY_WRAP_LYNKS 0x00000400 ++#define CKM_KEY_WRAP_SET_OAEP 0x00000401 ++ ++/* CKM_CMS_SIG is new for v2.20 */ ++#define CKM_CMS_SIG 0x00000500 ++ ++/* Fortezza mechanisms */ ++#define CKM_SKIPJACK_KEY_GEN 0x00001000 ++#define CKM_SKIPJACK_ECB64 0x00001001 ++#define CKM_SKIPJACK_CBC64 0x00001002 ++#define CKM_SKIPJACK_OFB64 0x00001003 ++#define CKM_SKIPJACK_CFB64 0x00001004 ++#define CKM_SKIPJACK_CFB32 0x00001005 ++#define CKM_SKIPJACK_CFB16 0x00001006 ++#define CKM_SKIPJACK_CFB8 0x00001007 ++#define CKM_SKIPJACK_WRAP 0x00001008 ++#define CKM_SKIPJACK_PRIVATE_WRAP 0x00001009 ++#define CKM_SKIPJACK_RELAYX 0x0000100a ++#define CKM_KEA_KEY_PAIR_GEN 0x00001010 ++#define CKM_KEA_KEY_DERIVE 0x00001011 ++#define CKM_FORTEZZA_TIMESTAMP 0x00001020 ++#define CKM_BATON_KEY_GEN 0x00001030 ++#define CKM_BATON_ECB128 0x00001031 ++#define CKM_BATON_ECB96 0x00001032 ++#define CKM_BATON_CBC128 0x00001033 ++#define CKM_BATON_COUNTER 0x00001034 ++#define CKM_BATON_SHUFFLE 0x00001035 ++#define CKM_BATON_WRAP 0x00001036 ++ ++/* CKM_ECDSA_KEY_PAIR_GEN is deprecated in v2.11, ++ * CKM_EC_KEY_PAIR_GEN is preferred */ ++#define CKM_ECDSA_KEY_PAIR_GEN 0x00001040 ++#define CKM_EC_KEY_PAIR_GEN 0x00001040 ++ ++#define CKM_ECDSA 0x00001041 ++#define CKM_ECDSA_SHA1 0x00001042 ++ ++/* CKM_ECDH1_DERIVE, CKM_ECDH1_COFACTOR_DERIVE, and CKM_ECMQV_DERIVE ++ * are new for v2.11 */ ++#define CKM_ECDH1_DERIVE 0x00001050 ++#define CKM_ECDH1_COFACTOR_DERIVE 0x00001051 ++#define CKM_ECMQV_DERIVE 0x00001052 ++ ++#define CKM_JUNIPER_KEY_GEN 0x00001060 ++#define CKM_JUNIPER_ECB128 0x00001061 ++#define CKM_JUNIPER_CBC128 0x00001062 ++#define CKM_JUNIPER_COUNTER 0x00001063 ++#define CKM_JUNIPER_SHUFFLE 0x00001064 ++#define CKM_JUNIPER_WRAP 0x00001065 ++#define CKM_FASTHASH 0x00001070 ++ ++/* CKM_AES_KEY_GEN, CKM_AES_ECB, CKM_AES_CBC, CKM_AES_MAC, ++ * CKM_AES_MAC_GENERAL, CKM_AES_CBC_PAD, CKM_DSA_PARAMETER_GEN, ++ * CKM_DH_PKCS_PARAMETER_GEN, and CKM_X9_42_DH_PARAMETER_GEN are ++ * new for v2.11 */ ++#define CKM_AES_KEY_GEN 0x00001080 ++#define CKM_AES_ECB 0x00001081 ++#define CKM_AES_CBC 0x00001082 ++#define CKM_AES_MAC 0x00001083 ++#define CKM_AES_MAC_GENERAL 0x00001084 ++#define CKM_AES_CBC_PAD 0x00001085 ++ ++/* BlowFish and TwoFish are new for v2.20 */ ++#define CKM_BLOWFISH_KEY_GEN 0x00001090 ++#define CKM_BLOWFISH_CBC 0x00001091 ++#define CKM_TWOFISH_KEY_GEN 0x00001092 ++#define CKM_TWOFISH_CBC 0x00001093 ++ ++ ++/* CKM_xxx_ENCRYPT_DATA mechanisms are new for v2.20 */ ++#define CKM_DES_ECB_ENCRYPT_DATA 0x00001100 ++#define CKM_DES_CBC_ENCRYPT_DATA 0x00001101 ++#define CKM_DES3_ECB_ENCRYPT_DATA 0x00001102 ++#define CKM_DES3_CBC_ENCRYPT_DATA 0x00001103 ++#define CKM_AES_ECB_ENCRYPT_DATA 0x00001104 ++#define CKM_AES_CBC_ENCRYPT_DATA 0x00001105 ++ ++#define CKM_DSA_PARAMETER_GEN 0x00002000 ++#define CKM_DH_PKCS_PARAMETER_GEN 0x00002001 ++#define CKM_X9_42_DH_PARAMETER_GEN 0x00002002 ++ ++#define CKM_VENDOR_DEFINED 0x80000000 ++ ++typedef CK_MECHANISM_TYPE CK_PTR CK_MECHANISM_TYPE_PTR; ++ ++ ++/* CK_MECHANISM is a structure that specifies a particular ++ * mechanism */ ++typedef struct CK_MECHANISM { ++ CK_MECHANISM_TYPE mechanism; ++ CK_VOID_PTR pParameter; ++ ++ /* ulParameterLen was changed from CK_USHORT to CK_ULONG for ++ * v2.0 */ ++ CK_ULONG ulParameterLen; /* in bytes */ ++} CK_MECHANISM; ++ ++typedef CK_MECHANISM CK_PTR CK_MECHANISM_PTR; ++ ++ ++/* CK_MECHANISM_INFO provides information about a particular ++ * mechanism */ ++typedef struct CK_MECHANISM_INFO { ++ CK_ULONG ulMinKeySize; ++ CK_ULONG ulMaxKeySize; ++ CK_FLAGS flags; ++} CK_MECHANISM_INFO; ++ ++/* The flags are defined as follows: ++ * Bit Flag Mask Meaning */ ++#define CKF_HW 0x00000001 /* performed by HW */ ++ ++/* The flags CKF_ENCRYPT, CKF_DECRYPT, CKF_DIGEST, CKF_SIGN, ++ * CKG_SIGN_RECOVER, CKF_VERIFY, CKF_VERIFY_RECOVER, ++ * CKF_GENERATE, CKF_GENERATE_KEY_PAIR, CKF_WRAP, CKF_UNWRAP, ++ * and CKF_DERIVE are new for v2.0. They specify whether or not ++ * a mechanism can be used for a particular task */ ++#define CKF_ENCRYPT 0x00000100 ++#define CKF_DECRYPT 0x00000200 ++#define CKF_DIGEST 0x00000400 ++#define CKF_SIGN 0x00000800 ++#define CKF_SIGN_RECOVER 0x00001000 ++#define CKF_VERIFY 0x00002000 ++#define CKF_VERIFY_RECOVER 0x00004000 ++#define CKF_GENERATE 0x00008000 ++#define CKF_GENERATE_KEY_PAIR 0x00010000 ++#define CKF_WRAP 0x00020000 ++#define CKF_UNWRAP 0x00040000 ++#define CKF_DERIVE 0x00080000 ++ ++/* CKF_EC_F_P, CKF_EC_F_2M, CKF_EC_ECPARAMETERS, CKF_EC_NAMEDCURVE, ++ * CKF_EC_UNCOMPRESS, and CKF_EC_COMPRESS are new for v2.11. They ++ * describe a token's EC capabilities not available in mechanism ++ * information. */ ++#define CKF_EC_F_P 0x00100000 ++#define CKF_EC_F_2M 0x00200000 ++#define CKF_EC_ECPARAMETERS 0x00400000 ++#define CKF_EC_NAMEDCURVE 0x00800000 ++#define CKF_EC_UNCOMPRESS 0x01000000 ++#define CKF_EC_COMPRESS 0x02000000 ++ ++#define CKF_EXTENSION 0x80000000 /* FALSE for this version */ ++ ++typedef CK_MECHANISM_INFO CK_PTR CK_MECHANISM_INFO_PTR; ++ ++ ++/* CK_RV is a value that identifies the return value of a ++ * Cryptoki function */ ++/* CK_RV was changed from CK_USHORT to CK_ULONG for v2.0 */ ++typedef CK_ULONG CK_RV; ++ ++#define CKR_OK 0x00000000 ++#define CKR_CANCEL 0x00000001 ++#define CKR_HOST_MEMORY 0x00000002 ++#define CKR_SLOT_ID_INVALID 0x00000003 ++ ++/* CKR_FLAGS_INVALID was removed for v2.0 */ ++ ++/* CKR_GENERAL_ERROR and CKR_FUNCTION_FAILED are new for v2.0 */ ++#define CKR_GENERAL_ERROR 0x00000005 ++#define CKR_FUNCTION_FAILED 0x00000006 ++ ++/* CKR_ARGUMENTS_BAD, CKR_NO_EVENT, CKR_NEED_TO_CREATE_THREADS, ++ * and CKR_CANT_LOCK are new for v2.01 */ ++#define CKR_ARGUMENTS_BAD 0x00000007 ++#define CKR_NO_EVENT 0x00000008 ++#define CKR_NEED_TO_CREATE_THREADS 0x00000009 ++#define CKR_CANT_LOCK 0x0000000A ++ ++#define CKR_ATTRIBUTE_READ_ONLY 0x00000010 ++#define CKR_ATTRIBUTE_SENSITIVE 0x00000011 ++#define CKR_ATTRIBUTE_TYPE_INVALID 0x00000012 ++#define CKR_ATTRIBUTE_VALUE_INVALID 0x00000013 ++#define CKR_DATA_INVALID 0x00000020 ++#define CKR_DATA_LEN_RANGE 0x00000021 ++#define CKR_DEVICE_ERROR 0x00000030 ++#define CKR_DEVICE_MEMORY 0x00000031 ++#define CKR_DEVICE_REMOVED 0x00000032 ++#define CKR_ENCRYPTED_DATA_INVALID 0x00000040 ++#define CKR_ENCRYPTED_DATA_LEN_RANGE 0x00000041 ++#define CKR_FUNCTION_CANCELED 0x00000050 ++#define CKR_FUNCTION_NOT_PARALLEL 0x00000051 ++ ++/* CKR_FUNCTION_NOT_SUPPORTED is new for v2.0 */ ++#define CKR_FUNCTION_NOT_SUPPORTED 0x00000054 ++ ++#define CKR_KEY_HANDLE_INVALID 0x00000060 ++ ++/* CKR_KEY_SENSITIVE was removed for v2.0 */ ++ ++#define CKR_KEY_SIZE_RANGE 0x00000062 ++#define CKR_KEY_TYPE_INCONSISTENT 0x00000063 ++ ++/* CKR_KEY_NOT_NEEDED, CKR_KEY_CHANGED, CKR_KEY_NEEDED, ++ * CKR_KEY_INDIGESTIBLE, CKR_KEY_FUNCTION_NOT_PERMITTED, ++ * CKR_KEY_NOT_WRAPPABLE, and CKR_KEY_UNEXTRACTABLE are new for ++ * v2.0 */ ++#define CKR_KEY_NOT_NEEDED 0x00000064 ++#define CKR_KEY_CHANGED 0x00000065 ++#define CKR_KEY_NEEDED 0x00000066 ++#define CKR_KEY_INDIGESTIBLE 0x00000067 ++#define CKR_KEY_FUNCTION_NOT_PERMITTED 0x00000068 ++#define CKR_KEY_NOT_WRAPPABLE 0x00000069 ++#define CKR_KEY_UNEXTRACTABLE 0x0000006A ++ ++#define CKR_MECHANISM_INVALID 0x00000070 ++#define CKR_MECHANISM_PARAM_INVALID 0x00000071 ++ ++/* CKR_OBJECT_CLASS_INCONSISTENT and CKR_OBJECT_CLASS_INVALID ++ * were removed for v2.0 */ ++#define CKR_OBJECT_HANDLE_INVALID 0x00000082 ++#define CKR_OPERATION_ACTIVE 0x00000090 ++#define CKR_OPERATION_NOT_INITIALIZED 0x00000091 ++#define CKR_PIN_INCORRECT 0x000000A0 ++#define CKR_PIN_INVALID 0x000000A1 ++#define CKR_PIN_LEN_RANGE 0x000000A2 ++ ++/* CKR_PIN_EXPIRED and CKR_PIN_LOCKED are new for v2.0 */ ++#define CKR_PIN_EXPIRED 0x000000A3 ++#define CKR_PIN_LOCKED 0x000000A4 ++ ++#define CKR_SESSION_CLOSED 0x000000B0 ++#define CKR_SESSION_COUNT 0x000000B1 ++#define CKR_SESSION_HANDLE_INVALID 0x000000B3 ++#define CKR_SESSION_PARALLEL_NOT_SUPPORTED 0x000000B4 ++#define CKR_SESSION_READ_ONLY 0x000000B5 ++#define CKR_SESSION_EXISTS 0x000000B6 ++ ++/* CKR_SESSION_READ_ONLY_EXISTS and ++ * CKR_SESSION_READ_WRITE_SO_EXISTS are new for v2.0 */ ++#define CKR_SESSION_READ_ONLY_EXISTS 0x000000B7 ++#define CKR_SESSION_READ_WRITE_SO_EXISTS 0x000000B8 ++ ++#define CKR_SIGNATURE_INVALID 0x000000C0 ++#define CKR_SIGNATURE_LEN_RANGE 0x000000C1 ++#define CKR_TEMPLATE_INCOMPLETE 0x000000D0 ++#define CKR_TEMPLATE_INCONSISTENT 0x000000D1 ++#define CKR_TOKEN_NOT_PRESENT 0x000000E0 ++#define CKR_TOKEN_NOT_RECOGNIZED 0x000000E1 ++#define CKR_TOKEN_WRITE_PROTECTED 0x000000E2 ++#define CKR_UNWRAPPING_KEY_HANDLE_INVALID 0x000000F0 ++#define CKR_UNWRAPPING_KEY_SIZE_RANGE 0x000000F1 ++#define CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT 0x000000F2 ++#define CKR_USER_ALREADY_LOGGED_IN 0x00000100 ++#define CKR_USER_NOT_LOGGED_IN 0x00000101 ++#define CKR_USER_PIN_NOT_INITIALIZED 0x00000102 ++#define CKR_USER_TYPE_INVALID 0x00000103 ++ ++/* CKR_USER_ANOTHER_ALREADY_LOGGED_IN and CKR_USER_TOO_MANY_TYPES ++ * are new to v2.01 */ ++#define CKR_USER_ANOTHER_ALREADY_LOGGED_IN 0x00000104 ++#define CKR_USER_TOO_MANY_TYPES 0x00000105 ++ ++#define CKR_WRAPPED_KEY_INVALID 0x00000110 ++#define CKR_WRAPPED_KEY_LEN_RANGE 0x00000112 ++#define CKR_WRAPPING_KEY_HANDLE_INVALID 0x00000113 ++#define CKR_WRAPPING_KEY_SIZE_RANGE 0x00000114 ++#define CKR_WRAPPING_KEY_TYPE_INCONSISTENT 0x00000115 ++#define CKR_RANDOM_SEED_NOT_SUPPORTED 0x00000120 ++ ++/* These are new to v2.0 */ ++#define CKR_RANDOM_NO_RNG 0x00000121 ++ ++/* These are new to v2.11 */ ++#define CKR_DOMAIN_PARAMS_INVALID 0x00000130 ++ ++/* These are new to v2.0 */ ++#define CKR_BUFFER_TOO_SMALL 0x00000150 ++#define CKR_SAVED_STATE_INVALID 0x00000160 ++#define CKR_INFORMATION_SENSITIVE 0x00000170 ++#define CKR_STATE_UNSAVEABLE 0x00000180 ++ ++/* These are new to v2.01 */ ++#define CKR_CRYPTOKI_NOT_INITIALIZED 0x00000190 ++#define CKR_CRYPTOKI_ALREADY_INITIALIZED 0x00000191 ++#define CKR_MUTEX_BAD 0x000001A0 ++#define CKR_MUTEX_NOT_LOCKED 0x000001A1 ++ ++/* This is new to v2.20 */ ++#define CKR_FUNCTION_REJECTED 0x00000200 ++ ++#define CKR_VENDOR_DEFINED 0x80000000 ++ ++ ++/* CK_NOTIFY is an application callback that processes events */ ++typedef CK_CALLBACK_FUNCTION(CK_RV, CK_NOTIFY)( ++ CK_SESSION_HANDLE hSession, /* the session's handle */ ++ CK_NOTIFICATION event, ++ CK_VOID_PTR pApplication /* passed to C_OpenSession */ ++); ++ ++ ++/* CK_FUNCTION_LIST is a structure holding a Cryptoki spec ++ * version and pointers of appropriate types to all the ++ * Cryptoki functions */ ++/* CK_FUNCTION_LIST is new for v2.0 */ ++typedef struct CK_FUNCTION_LIST CK_FUNCTION_LIST; ++ ++typedef CK_FUNCTION_LIST CK_PTR CK_FUNCTION_LIST_PTR; ++ ++typedef CK_FUNCTION_LIST_PTR CK_PTR CK_FUNCTION_LIST_PTR_PTR; ++ ++ ++/* CK_CREATEMUTEX is an application callback for creating a ++ * mutex object */ ++typedef CK_CALLBACK_FUNCTION(CK_RV, CK_CREATEMUTEX)( ++ CK_VOID_PTR_PTR ppMutex /* location to receive ptr to mutex */ ++); ++ ++ ++/* CK_DESTROYMUTEX is an application callback for destroying a ++ * mutex object */ ++typedef CK_CALLBACK_FUNCTION(CK_RV, CK_DESTROYMUTEX)( ++ CK_VOID_PTR pMutex /* pointer to mutex */ ++); ++ ++ ++/* CK_LOCKMUTEX is an application callback for locking a mutex */ ++typedef CK_CALLBACK_FUNCTION(CK_RV, CK_LOCKMUTEX)( ++ CK_VOID_PTR pMutex /* pointer to mutex */ ++); ++ ++ ++/* CK_UNLOCKMUTEX is an application callback for unlocking a ++ * mutex */ ++typedef CK_CALLBACK_FUNCTION(CK_RV, CK_UNLOCKMUTEX)( ++ CK_VOID_PTR pMutex /* pointer to mutex */ ++); ++ ++ ++/* CK_C_INITIALIZE_ARGS provides the optional arguments to ++ * C_Initialize */ ++typedef struct CK_C_INITIALIZE_ARGS { ++ CK_CREATEMUTEX CreateMutex; ++ CK_DESTROYMUTEX DestroyMutex; ++ CK_LOCKMUTEX LockMutex; ++ CK_UNLOCKMUTEX UnlockMutex; ++ CK_FLAGS flags; ++ CK_VOID_PTR pReserved; ++} CK_C_INITIALIZE_ARGS; ++ ++/* flags: bit flags that provide capabilities of the slot ++ * Bit Flag Mask Meaning ++ */ ++#define CKF_LIBRARY_CANT_CREATE_OS_THREADS 0x00000001 ++#define CKF_OS_LOCKING_OK 0x00000002 ++ ++typedef CK_C_INITIALIZE_ARGS CK_PTR CK_C_INITIALIZE_ARGS_PTR; ++ ++ ++/* additional flags for parameters to functions */ ++ ++/* CKF_DONT_BLOCK is for the function C_WaitForSlotEvent */ ++#define CKF_DONT_BLOCK 1 ++ ++/* CK_RSA_PKCS_OAEP_MGF_TYPE is new for v2.10. ++ * CK_RSA_PKCS_OAEP_MGF_TYPE is used to indicate the Message ++ * Generation Function (MGF) applied to a message block when ++ * formatting a message block for the PKCS #1 OAEP encryption ++ * scheme. */ ++typedef CK_ULONG CK_RSA_PKCS_MGF_TYPE; ++ ++typedef CK_RSA_PKCS_MGF_TYPE CK_PTR CK_RSA_PKCS_MGF_TYPE_PTR; ++ ++/* The following MGFs are defined */ ++/* CKG_MGF1_SHA256, CKG_MGF1_SHA384, and CKG_MGF1_SHA512 ++ * are new for v2.20 */ ++#define CKG_MGF1_SHA1 0x00000001 ++#define CKG_MGF1_SHA256 0x00000002 ++#define CKG_MGF1_SHA384 0x00000003 ++#define CKG_MGF1_SHA512 0x00000004 ++ ++/* CK_RSA_PKCS_OAEP_SOURCE_TYPE is new for v2.10. ++ * CK_RSA_PKCS_OAEP_SOURCE_TYPE is used to indicate the source ++ * of the encoding parameter when formatting a message block ++ * for the PKCS #1 OAEP encryption scheme. */ ++typedef CK_ULONG CK_RSA_PKCS_OAEP_SOURCE_TYPE; ++ ++typedef CK_RSA_PKCS_OAEP_SOURCE_TYPE CK_PTR CK_RSA_PKCS_OAEP_SOURCE_TYPE_PTR; ++ ++/* The following encoding parameter sources are defined */ ++#define CKZ_DATA_SPECIFIED 0x00000001 ++ ++/* CK_RSA_PKCS_OAEP_PARAMS is new for v2.10. ++ * CK_RSA_PKCS_OAEP_PARAMS provides the parameters to the ++ * CKM_RSA_PKCS_OAEP mechanism. */ ++typedef struct CK_RSA_PKCS_OAEP_PARAMS { ++ CK_MECHANISM_TYPE hashAlg; ++ CK_RSA_PKCS_MGF_TYPE mgf; ++ CK_RSA_PKCS_OAEP_SOURCE_TYPE source; ++ CK_VOID_PTR pSourceData; ++ CK_ULONG ulSourceDataLen; ++} CK_RSA_PKCS_OAEP_PARAMS; ++ ++typedef CK_RSA_PKCS_OAEP_PARAMS CK_PTR CK_RSA_PKCS_OAEP_PARAMS_PTR; ++ ++/* CK_RSA_PKCS_PSS_PARAMS is new for v2.11. ++ * CK_RSA_PKCS_PSS_PARAMS provides the parameters to the ++ * CKM_RSA_PKCS_PSS mechanism(s). */ ++typedef struct CK_RSA_PKCS_PSS_PARAMS { ++ CK_MECHANISM_TYPE hashAlg; ++ CK_RSA_PKCS_MGF_TYPE mgf; ++ CK_ULONG sLen; ++} CK_RSA_PKCS_PSS_PARAMS; ++ ++typedef CK_RSA_PKCS_PSS_PARAMS CK_PTR CK_RSA_PKCS_PSS_PARAMS_PTR; ++ ++/* CK_EC_KDF_TYPE is new for v2.11. */ ++typedef CK_ULONG CK_EC_KDF_TYPE; ++ ++/* The following EC Key Derivation Functions are defined */ ++#define CKD_NULL 0x00000001 ++#define CKD_SHA1_KDF 0x00000002 ++ ++/* CK_ECDH1_DERIVE_PARAMS is new for v2.11. ++ * CK_ECDH1_DERIVE_PARAMS provides the parameters to the ++ * CKM_ECDH1_DERIVE and CKM_ECDH1_COFACTOR_DERIVE mechanisms, ++ * where each party contributes one key pair. ++ */ ++typedef struct CK_ECDH1_DERIVE_PARAMS { ++ CK_EC_KDF_TYPE kdf; ++ CK_ULONG ulSharedDataLen; ++ CK_BYTE_PTR pSharedData; ++ CK_ULONG ulPublicDataLen; ++ CK_BYTE_PTR pPublicData; ++} CK_ECDH1_DERIVE_PARAMS; ++ ++typedef CK_ECDH1_DERIVE_PARAMS CK_PTR CK_ECDH1_DERIVE_PARAMS_PTR; ++ ++ ++/* CK_ECDH2_DERIVE_PARAMS is new for v2.11. ++ * CK_ECDH2_DERIVE_PARAMS provides the parameters to the ++ * CKM_ECMQV_DERIVE mechanism, where each party contributes two key pairs. */ ++typedef struct CK_ECDH2_DERIVE_PARAMS { ++ CK_EC_KDF_TYPE kdf; ++ CK_ULONG ulSharedDataLen; ++ CK_BYTE_PTR pSharedData; ++ CK_ULONG ulPublicDataLen; ++ CK_BYTE_PTR pPublicData; ++ CK_ULONG ulPrivateDataLen; ++ CK_OBJECT_HANDLE hPrivateData; ++ CK_ULONG ulPublicDataLen2; ++ CK_BYTE_PTR pPublicData2; ++} CK_ECDH2_DERIVE_PARAMS; ++ ++typedef CK_ECDH2_DERIVE_PARAMS CK_PTR CK_ECDH2_DERIVE_PARAMS_PTR; ++ ++typedef struct CK_ECMQV_DERIVE_PARAMS { ++ CK_EC_KDF_TYPE kdf; ++ CK_ULONG ulSharedDataLen; ++ CK_BYTE_PTR pSharedData; ++ CK_ULONG ulPublicDataLen; ++ CK_BYTE_PTR pPublicData; ++ CK_ULONG ulPrivateDataLen; ++ CK_OBJECT_HANDLE hPrivateData; ++ CK_ULONG ulPublicDataLen2; ++ CK_BYTE_PTR pPublicData2; ++ CK_OBJECT_HANDLE publicKey; ++} CK_ECMQV_DERIVE_PARAMS; ++ ++typedef CK_ECMQV_DERIVE_PARAMS CK_PTR CK_ECMQV_DERIVE_PARAMS_PTR; ++ ++/* Typedefs and defines for the CKM_X9_42_DH_KEY_PAIR_GEN and the ++ * CKM_X9_42_DH_PARAMETER_GEN mechanisms (new for PKCS #11 v2.11) */ ++typedef CK_ULONG CK_X9_42_DH_KDF_TYPE; ++typedef CK_X9_42_DH_KDF_TYPE CK_PTR CK_X9_42_DH_KDF_TYPE_PTR; ++ ++/* The following X9.42 DH key derivation functions are defined ++ (besides CKD_NULL already defined : */ ++#define CKD_SHA1_KDF_ASN1 0x00000003 ++#define CKD_SHA1_KDF_CONCATENATE 0x00000004 ++ ++/* CK_X9_42_DH1_DERIVE_PARAMS is new for v2.11. ++ * CK_X9_42_DH1_DERIVE_PARAMS provides the parameters to the ++ * CKM_X9_42_DH_DERIVE key derivation mechanism, where each party ++ * contributes one key pair */ ++typedef struct CK_X9_42_DH1_DERIVE_PARAMS { ++ CK_X9_42_DH_KDF_TYPE kdf; ++ CK_ULONG ulOtherInfoLen; ++ CK_BYTE_PTR pOtherInfo; ++ CK_ULONG ulPublicDataLen; ++ CK_BYTE_PTR pPublicData; ++} CK_X9_42_DH1_DERIVE_PARAMS; ++ ++typedef struct CK_X9_42_DH1_DERIVE_PARAMS CK_PTR CK_X9_42_DH1_DERIVE_PARAMS_PTR; ++ ++/* CK_X9_42_DH2_DERIVE_PARAMS is new for v2.11. ++ * CK_X9_42_DH2_DERIVE_PARAMS provides the parameters to the ++ * CKM_X9_42_DH_HYBRID_DERIVE and CKM_X9_42_MQV_DERIVE key derivation ++ * mechanisms, where each party contributes two key pairs */ ++typedef struct CK_X9_42_DH2_DERIVE_PARAMS { ++ CK_X9_42_DH_KDF_TYPE kdf; ++ CK_ULONG ulOtherInfoLen; ++ CK_BYTE_PTR pOtherInfo; ++ CK_ULONG ulPublicDataLen; ++ CK_BYTE_PTR pPublicData; ++ CK_ULONG ulPrivateDataLen; ++ CK_OBJECT_HANDLE hPrivateData; ++ CK_ULONG ulPublicDataLen2; ++ CK_BYTE_PTR pPublicData2; ++} CK_X9_42_DH2_DERIVE_PARAMS; ++ ++typedef CK_X9_42_DH2_DERIVE_PARAMS CK_PTR CK_X9_42_DH2_DERIVE_PARAMS_PTR; ++ ++typedef struct CK_X9_42_MQV_DERIVE_PARAMS { ++ CK_X9_42_DH_KDF_TYPE kdf; ++ CK_ULONG ulOtherInfoLen; ++ CK_BYTE_PTR pOtherInfo; ++ CK_ULONG ulPublicDataLen; ++ CK_BYTE_PTR pPublicData; ++ CK_ULONG ulPrivateDataLen; ++ CK_OBJECT_HANDLE hPrivateData; ++ CK_ULONG ulPublicDataLen2; ++ CK_BYTE_PTR pPublicData2; ++ CK_OBJECT_HANDLE publicKey; ++} CK_X9_42_MQV_DERIVE_PARAMS; ++ ++typedef CK_X9_42_MQV_DERIVE_PARAMS CK_PTR CK_X9_42_MQV_DERIVE_PARAMS_PTR; ++ ++/* CK_KEA_DERIVE_PARAMS provides the parameters to the ++ * CKM_KEA_DERIVE mechanism */ ++/* CK_KEA_DERIVE_PARAMS is new for v2.0 */ ++typedef struct CK_KEA_DERIVE_PARAMS { ++ CK_BBOOL isSender; ++ CK_ULONG ulRandomLen; ++ CK_BYTE_PTR pRandomA; ++ CK_BYTE_PTR pRandomB; ++ CK_ULONG ulPublicDataLen; ++ CK_BYTE_PTR pPublicData; ++} CK_KEA_DERIVE_PARAMS; ++ ++typedef CK_KEA_DERIVE_PARAMS CK_PTR CK_KEA_DERIVE_PARAMS_PTR; ++ ++ ++/* CK_RC2_PARAMS provides the parameters to the CKM_RC2_ECB and ++ * CKM_RC2_MAC mechanisms. An instance of CK_RC2_PARAMS just ++ * holds the effective keysize */ ++typedef CK_ULONG CK_RC2_PARAMS; ++ ++typedef CK_RC2_PARAMS CK_PTR CK_RC2_PARAMS_PTR; ++ ++ ++/* CK_RC2_CBC_PARAMS provides the parameters to the CKM_RC2_CBC ++ * mechanism */ ++typedef struct CK_RC2_CBC_PARAMS { ++ /* ulEffectiveBits was changed from CK_USHORT to CK_ULONG for ++ * v2.0 */ ++ CK_ULONG ulEffectiveBits; /* effective bits (1-1024) */ ++ ++ CK_BYTE iv[8]; /* IV for CBC mode */ ++} CK_RC2_CBC_PARAMS; ++ ++typedef CK_RC2_CBC_PARAMS CK_PTR CK_RC2_CBC_PARAMS_PTR; ++ ++ ++/* CK_RC2_MAC_GENERAL_PARAMS provides the parameters for the ++ * CKM_RC2_MAC_GENERAL mechanism */ ++/* CK_RC2_MAC_GENERAL_PARAMS is new for v2.0 */ ++typedef struct CK_RC2_MAC_GENERAL_PARAMS { ++ CK_ULONG ulEffectiveBits; /* effective bits (1-1024) */ ++ CK_ULONG ulMacLength; /* Length of MAC in bytes */ ++} CK_RC2_MAC_GENERAL_PARAMS; ++ ++typedef CK_RC2_MAC_GENERAL_PARAMS CK_PTR \ ++ CK_RC2_MAC_GENERAL_PARAMS_PTR; ++ ++ ++/* CK_RC5_PARAMS provides the parameters to the CKM_RC5_ECB and ++ * CKM_RC5_MAC mechanisms */ ++/* CK_RC5_PARAMS is new for v2.0 */ ++typedef struct CK_RC5_PARAMS { ++ CK_ULONG ulWordsize; /* wordsize in bits */ ++ CK_ULONG ulRounds; /* number of rounds */ ++} CK_RC5_PARAMS; ++ ++typedef CK_RC5_PARAMS CK_PTR CK_RC5_PARAMS_PTR; ++ ++ ++/* CK_RC5_CBC_PARAMS provides the parameters to the CKM_RC5_CBC ++ * mechanism */ ++/* CK_RC5_CBC_PARAMS is new for v2.0 */ ++typedef struct CK_RC5_CBC_PARAMS { ++ CK_ULONG ulWordsize; /* wordsize in bits */ ++ CK_ULONG ulRounds; /* number of rounds */ ++ CK_BYTE_PTR pIv; /* pointer to IV */ ++ CK_ULONG ulIvLen; /* length of IV in bytes */ ++} CK_RC5_CBC_PARAMS; ++ ++typedef CK_RC5_CBC_PARAMS CK_PTR CK_RC5_CBC_PARAMS_PTR; ++ ++ ++/* CK_RC5_MAC_GENERAL_PARAMS provides the parameters for the ++ * CKM_RC5_MAC_GENERAL mechanism */ ++/* CK_RC5_MAC_GENERAL_PARAMS is new for v2.0 */ ++typedef struct CK_RC5_MAC_GENERAL_PARAMS { ++ CK_ULONG ulWordsize; /* wordsize in bits */ ++ CK_ULONG ulRounds; /* number of rounds */ ++ CK_ULONG ulMacLength; /* Length of MAC in bytes */ ++} CK_RC5_MAC_GENERAL_PARAMS; ++ ++typedef CK_RC5_MAC_GENERAL_PARAMS CK_PTR \ ++ CK_RC5_MAC_GENERAL_PARAMS_PTR; ++ ++ ++/* CK_MAC_GENERAL_PARAMS provides the parameters to most block ++ * ciphers' MAC_GENERAL mechanisms. Its value is the length of ++ * the MAC */ ++/* CK_MAC_GENERAL_PARAMS is new for v2.0 */ ++typedef CK_ULONG CK_MAC_GENERAL_PARAMS; ++ ++typedef CK_MAC_GENERAL_PARAMS CK_PTR CK_MAC_GENERAL_PARAMS_PTR; ++ ++/* CK_DES/AES_ECB/CBC_ENCRYPT_DATA_PARAMS are new for v2.20 */ ++typedef struct CK_DES_CBC_ENCRYPT_DATA_PARAMS { ++ CK_BYTE iv[8]; ++ CK_BYTE_PTR pData; ++ CK_ULONG length; ++} CK_DES_CBC_ENCRYPT_DATA_PARAMS; ++ ++typedef CK_DES_CBC_ENCRYPT_DATA_PARAMS CK_PTR CK_DES_CBC_ENCRYPT_DATA_PARAMS_PTR; ++ ++typedef struct CK_AES_CBC_ENCRYPT_DATA_PARAMS { ++ CK_BYTE iv[16]; ++ CK_BYTE_PTR pData; ++ CK_ULONG length; ++} CK_AES_CBC_ENCRYPT_DATA_PARAMS; ++ ++typedef CK_AES_CBC_ENCRYPT_DATA_PARAMS CK_PTR CK_AES_CBC_ENCRYPT_DATA_PARAMS_PTR; ++ ++/* CK_SKIPJACK_PRIVATE_WRAP_PARAMS provides the parameters to the ++ * CKM_SKIPJACK_PRIVATE_WRAP mechanism */ ++/* CK_SKIPJACK_PRIVATE_WRAP_PARAMS is new for v2.0 */ ++typedef struct CK_SKIPJACK_PRIVATE_WRAP_PARAMS { ++ CK_ULONG ulPasswordLen; ++ CK_BYTE_PTR pPassword; ++ CK_ULONG ulPublicDataLen; ++ CK_BYTE_PTR pPublicData; ++ CK_ULONG ulPAndGLen; ++ CK_ULONG ulQLen; ++ CK_ULONG ulRandomLen; ++ CK_BYTE_PTR pRandomA; ++ CK_BYTE_PTR pPrimeP; ++ CK_BYTE_PTR pBaseG; ++ CK_BYTE_PTR pSubprimeQ; ++} CK_SKIPJACK_PRIVATE_WRAP_PARAMS; ++ ++typedef CK_SKIPJACK_PRIVATE_WRAP_PARAMS CK_PTR \ ++ CK_SKIPJACK_PRIVATE_WRAP_PTR; ++ ++ ++/* CK_SKIPJACK_RELAYX_PARAMS provides the parameters to the ++ * CKM_SKIPJACK_RELAYX mechanism */ ++/* CK_SKIPJACK_RELAYX_PARAMS is new for v2.0 */ ++typedef struct CK_SKIPJACK_RELAYX_PARAMS { ++ CK_ULONG ulOldWrappedXLen; ++ CK_BYTE_PTR pOldWrappedX; ++ CK_ULONG ulOldPasswordLen; ++ CK_BYTE_PTR pOldPassword; ++ CK_ULONG ulOldPublicDataLen; ++ CK_BYTE_PTR pOldPublicData; ++ CK_ULONG ulOldRandomLen; ++ CK_BYTE_PTR pOldRandomA; ++ CK_ULONG ulNewPasswordLen; ++ CK_BYTE_PTR pNewPassword; ++ CK_ULONG ulNewPublicDataLen; ++ CK_BYTE_PTR pNewPublicData; ++ CK_ULONG ulNewRandomLen; ++ CK_BYTE_PTR pNewRandomA; ++} CK_SKIPJACK_RELAYX_PARAMS; ++ ++typedef CK_SKIPJACK_RELAYX_PARAMS CK_PTR \ ++ CK_SKIPJACK_RELAYX_PARAMS_PTR; ++ ++ ++typedef struct CK_PBE_PARAMS { ++ CK_BYTE_PTR pInitVector; ++ CK_UTF8CHAR_PTR pPassword; ++ CK_ULONG ulPasswordLen; ++ CK_BYTE_PTR pSalt; ++ CK_ULONG ulSaltLen; ++ CK_ULONG ulIteration; ++} CK_PBE_PARAMS; ++ ++typedef CK_PBE_PARAMS CK_PTR CK_PBE_PARAMS_PTR; ++ ++ ++/* CK_KEY_WRAP_SET_OAEP_PARAMS provides the parameters to the ++ * CKM_KEY_WRAP_SET_OAEP mechanism */ ++/* CK_KEY_WRAP_SET_OAEP_PARAMS is new for v2.0 */ ++typedef struct CK_KEY_WRAP_SET_OAEP_PARAMS { ++ CK_BYTE bBC; /* block contents byte */ ++ CK_BYTE_PTR pX; /* extra data */ ++ CK_ULONG ulXLen; /* length of extra data in bytes */ ++} CK_KEY_WRAP_SET_OAEP_PARAMS; ++ ++typedef CK_KEY_WRAP_SET_OAEP_PARAMS CK_PTR \ ++ CK_KEY_WRAP_SET_OAEP_PARAMS_PTR; ++ ++ ++typedef struct CK_SSL3_RANDOM_DATA { ++ CK_BYTE_PTR pClientRandom; ++ CK_ULONG ulClientRandomLen; ++ CK_BYTE_PTR pServerRandom; ++ CK_ULONG ulServerRandomLen; ++} CK_SSL3_RANDOM_DATA; ++ ++ ++typedef struct CK_SSL3_MASTER_KEY_DERIVE_PARAMS { ++ CK_SSL3_RANDOM_DATA RandomInfo; ++ CK_VERSION_PTR pVersion; ++} CK_SSL3_MASTER_KEY_DERIVE_PARAMS; ++ ++typedef struct CK_SSL3_MASTER_KEY_DERIVE_PARAMS CK_PTR \ ++ CK_SSL3_MASTER_KEY_DERIVE_PARAMS_PTR; ++ ++ ++typedef struct CK_SSL3_KEY_MAT_OUT { ++ CK_OBJECT_HANDLE hClientMacSecret; ++ CK_OBJECT_HANDLE hServerMacSecret; ++ CK_OBJECT_HANDLE hClientKey; ++ CK_OBJECT_HANDLE hServerKey; ++ CK_BYTE_PTR pIVClient; ++ CK_BYTE_PTR pIVServer; ++} CK_SSL3_KEY_MAT_OUT; ++ ++typedef CK_SSL3_KEY_MAT_OUT CK_PTR CK_SSL3_KEY_MAT_OUT_PTR; ++ ++ ++typedef struct CK_SSL3_KEY_MAT_PARAMS { ++ CK_ULONG ulMacSizeInBits; ++ CK_ULONG ulKeySizeInBits; ++ CK_ULONG ulIVSizeInBits; ++ CK_BBOOL bIsExport; ++ CK_SSL3_RANDOM_DATA RandomInfo; ++ CK_SSL3_KEY_MAT_OUT_PTR pReturnedKeyMaterial; ++} CK_SSL3_KEY_MAT_PARAMS; ++ ++typedef CK_SSL3_KEY_MAT_PARAMS CK_PTR CK_SSL3_KEY_MAT_PARAMS_PTR; ++ ++/* CK_TLS_PRF_PARAMS is new for version 2.20 */ ++typedef struct CK_TLS_PRF_PARAMS { ++ CK_BYTE_PTR pSeed; ++ CK_ULONG ulSeedLen; ++ CK_BYTE_PTR pLabel; ++ CK_ULONG ulLabelLen; ++ CK_BYTE_PTR pOutput; ++ CK_ULONG_PTR pulOutputLen; ++} CK_TLS_PRF_PARAMS; ++ ++typedef CK_TLS_PRF_PARAMS CK_PTR CK_TLS_PRF_PARAMS_PTR; ++ ++/* WTLS is new for version 2.20 */ ++typedef struct CK_WTLS_RANDOM_DATA { ++ CK_BYTE_PTR pClientRandom; ++ CK_ULONG ulClientRandomLen; ++ CK_BYTE_PTR pServerRandom; ++ CK_ULONG ulServerRandomLen; ++} CK_WTLS_RANDOM_DATA; ++ ++typedef CK_WTLS_RANDOM_DATA CK_PTR CK_WTLS_RANDOM_DATA_PTR; ++ ++typedef struct CK_WTLS_MASTER_KEY_DERIVE_PARAMS { ++ CK_MECHANISM_TYPE DigestMechanism; ++ CK_WTLS_RANDOM_DATA RandomInfo; ++ CK_BYTE_PTR pVersion; ++} CK_WTLS_MASTER_KEY_DERIVE_PARAMS; ++ ++typedef CK_WTLS_MASTER_KEY_DERIVE_PARAMS CK_PTR \ ++ CK_WTLS_MASTER_KEY_DERIVE_PARAMS_PTR; ++ ++typedef struct CK_WTLS_PRF_PARAMS { ++ CK_MECHANISM_TYPE DigestMechanism; ++ CK_BYTE_PTR pSeed; ++ CK_ULONG ulSeedLen; ++ CK_BYTE_PTR pLabel; ++ CK_ULONG ulLabelLen; ++ CK_BYTE_PTR pOutput; ++ CK_ULONG_PTR pulOutputLen; ++} CK_WTLS_PRF_PARAMS; ++ ++typedef CK_WTLS_PRF_PARAMS CK_PTR CK_WTLS_PRF_PARAMS_PTR; ++ ++typedef struct CK_WTLS_KEY_MAT_OUT { ++ CK_OBJECT_HANDLE hMacSecret; ++ CK_OBJECT_HANDLE hKey; ++ CK_BYTE_PTR pIV; ++} CK_WTLS_KEY_MAT_OUT; ++ ++typedef CK_WTLS_KEY_MAT_OUT CK_PTR CK_WTLS_KEY_MAT_OUT_PTR; ++ ++typedef struct CK_WTLS_KEY_MAT_PARAMS { ++ CK_MECHANISM_TYPE DigestMechanism; ++ CK_ULONG ulMacSizeInBits; ++ CK_ULONG ulKeySizeInBits; ++ CK_ULONG ulIVSizeInBits; ++ CK_ULONG ulSequenceNumber; ++ CK_BBOOL bIsExport; ++ CK_WTLS_RANDOM_DATA RandomInfo; ++ CK_WTLS_KEY_MAT_OUT_PTR pReturnedKeyMaterial; ++} CK_WTLS_KEY_MAT_PARAMS; ++ ++typedef CK_WTLS_KEY_MAT_PARAMS CK_PTR CK_WTLS_KEY_MAT_PARAMS_PTR; ++ ++/* CMS is new for version 2.20 */ ++typedef struct CK_CMS_SIG_PARAMS { ++ CK_OBJECT_HANDLE certificateHandle; ++ CK_MECHANISM_PTR pSigningMechanism; ++ CK_MECHANISM_PTR pDigestMechanism; ++ CK_UTF8CHAR_PTR pContentType; ++ CK_BYTE_PTR pRequestedAttributes; ++ CK_ULONG ulRequestedAttributesLen; ++ CK_BYTE_PTR pRequiredAttributes; ++ CK_ULONG ulRequiredAttributesLen; ++} CK_CMS_SIG_PARAMS; ++ ++typedef CK_CMS_SIG_PARAMS CK_PTR CK_CMS_SIG_PARAMS_PTR; ++ ++typedef struct CK_KEY_DERIVATION_STRING_DATA { ++ CK_BYTE_PTR pData; ++ CK_ULONG ulLen; ++} CK_KEY_DERIVATION_STRING_DATA; ++ ++typedef CK_KEY_DERIVATION_STRING_DATA CK_PTR \ ++ CK_KEY_DERIVATION_STRING_DATA_PTR; ++ ++ ++/* The CK_EXTRACT_PARAMS is used for the ++ * CKM_EXTRACT_KEY_FROM_KEY mechanism. It specifies which bit ++ * of the base key should be used as the first bit of the ++ * derived key */ ++/* CK_EXTRACT_PARAMS is new for v2.0 */ ++typedef CK_ULONG CK_EXTRACT_PARAMS; ++ ++typedef CK_EXTRACT_PARAMS CK_PTR CK_EXTRACT_PARAMS_PTR; ++ ++/* CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE is new for v2.10. ++ * CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE is used to ++ * indicate the Pseudo-Random Function (PRF) used to generate ++ * key bits using PKCS #5 PBKDF2. */ ++typedef CK_ULONG CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE; ++ ++typedef CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE CK_PTR CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE_PTR; ++ ++/* The following PRFs are defined in PKCS #5 v2.0. */ ++#define CKP_PKCS5_PBKD2_HMAC_SHA1 0x00000001 ++ ++ ++/* CK_PKCS5_PBKDF2_SALT_SOURCE_TYPE is new for v2.10. ++ * CK_PKCS5_PBKDF2_SALT_SOURCE_TYPE is used to indicate the ++ * source of the salt value when deriving a key using PKCS #5 ++ * PBKDF2. */ ++typedef CK_ULONG CK_PKCS5_PBKDF2_SALT_SOURCE_TYPE; ++ ++typedef CK_PKCS5_PBKDF2_SALT_SOURCE_TYPE CK_PTR CK_PKCS5_PBKDF2_SALT_SOURCE_TYPE_PTR; ++ ++/* The following salt value sources are defined in PKCS #5 v2.0. */ ++#define CKZ_SALT_SPECIFIED 0x00000001 ++ ++/* CK_PKCS5_PBKD2_PARAMS is new for v2.10. ++ * CK_PKCS5_PBKD2_PARAMS is a structure that provides the ++ * parameters to the CKM_PKCS5_PBKD2 mechanism. */ ++typedef struct CK_PKCS5_PBKD2_PARAMS { ++ CK_PKCS5_PBKDF2_SALT_SOURCE_TYPE saltSource; ++ CK_VOID_PTR pSaltSourceData; ++ CK_ULONG ulSaltSourceDataLen; ++ CK_ULONG iterations; ++ CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE prf; ++ CK_VOID_PTR pPrfData; ++ CK_ULONG ulPrfDataLen; ++ CK_UTF8CHAR_PTR pPassword; ++ CK_ULONG_PTR ulPasswordLen; ++} CK_PKCS5_PBKD2_PARAMS; ++ ++typedef CK_PKCS5_PBKD2_PARAMS CK_PTR CK_PKCS5_PBKD2_PARAMS_PTR; ++ ++#endif +diff -urNp openssh-4.4p1/pkcs11-helper.c openssh-4.4p1+pkcs11-0.17/pkcs11-helper.c +--- openssh-4.4p1/pkcs11-helper.c 1970-01-01 02:00:00.000000000 +0200 ++++ openssh-4.4p1+pkcs11-0.17/pkcs11-helper.c 2006-10-22 17:11:50.000000000 +0200 +@@ -0,0 +1,11337 @@ ++/* ++ * Copyright (c) 2005-2006 Alon Bar-Lev ++ * All rights reserved. ++ * ++ * This software is available to you under a choice of one of two ++ * licenses. You may choose to be licensed under the terms of the GNU ++ * General Public License (GPL) Version 2, or the OpenIB.org BSD license. ++ * ++ * GNU General Public License (GPL) Version 2 ++ * =========================================== ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License version 2 ++ * as published by the Free Software Foundation. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT 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[.GPL2] included with this ++ * distribution); if not, write to the Free Software Foundation, Inc., ++ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ * ++ * OpenIB.org BSD license ++ * ======================= ++ * Redistribution and use in source and binary forms, with or without modifi- ++ * cation, are permitted provided that the following conditions are met: ++ * ++ * o Redistributions of source code must retain the above copyright notice, ++ * this list of conditions and the following disclaimer. ++ * ++ * o Redistributions in binary form must reproduce the above copyright no- ++ * tice, this list of conditions and the following disclaimer in the do- ++ * cumentation and/or other materials provided with the distribution. ++ * ++ * o The names of the 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 COPYRIGHT HOLDERS AND 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 REGENTS OR CONTRIBUTORS BE LI- ++ * ABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUEN- ++ * TIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEV- ++ * ER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABI- ++ * LITY, 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. ++ */ ++ ++/* ++ * The routines in this file deal with providing private key cryptography ++ * using RSA Security Inc. PKCS #11 Cryptographic Token Interface (Cryptoki). ++ * ++ */ ++ ++/* ++ * Changelog ++ * ++ * 2006.09.24 ++ * - (alonbl) Fix invalid certificate max size handling (Zeljko Vrba). ++ * - (alonbl) Added object serialization. ++ * - (alonbl) Added user data to hooks. ++ * - (alonbl) Added a force login method. ++ * - (alonbl) Added support for gnutls in addition to openssl. ++ * - (alonbl) Fixup threading lock issues. ++ * - (alonbl) Added support for duplicate serial tokens, based on label. ++ * - (alonbl) Added workaround for OpenSC cards, OpenSC bug#108, thanks to Kaupo Arulo. ++ * - (alonbl) Added a methods to lock session between two sign/decrypt operations. ++ * - (alonbl) Modified openssl interface. ++ * - (alonbl) Release 01.02. ++ * ++ * 2006.06.26 ++ * - (alonbl) Fix handling mutiple providers. ++ * - (alonbl) Release 01.01. ++ * ++ * 2006.05.14 ++ * - (alonbl) First stable release. ++ * - (alonbl) Release 01.00. ++ * ++ */ ++ ++#include "pkcs11-helper-config.h" ++ ++#if defined(ENABLE_PKCS11H_HELPER) ++ ++#include "pkcs11-helper.h" ++ ++/*=========================================== ++ * Constants ++ */ ++ ++#if defined(USE_PKCS11H_OPENSSL) ++ ++#if OPENSSL_VERSION_NUMBER < 0x00907000L && defined(CRYPTO_LOCK_ENGINE) ++# define RSA_get_default_method RSA_get_default_openssl_method ++#else ++# ifdef HAVE_ENGINE_GET_DEFAULT_RSA ++# include ++# if OPENSSL_VERSION_NUMBER < 0x0090704fL ++# define BROKEN_OPENSSL_ENGINE ++# endif ++# endif ++#endif ++ ++#if OPENSSL_VERSION_NUMBER < 0x00907000L ++#if !defined(RSA_PKCS1_PADDING_SIZE) ++#define RSA_PKCS1_PADDING_SIZE 11 ++#endif ++#endif ++ ++#endif ++ ++#define PKCS11H_INVALID_SLOT_ID ((CK_SLOT_ID)-1) ++#define PKCS11H_INVALID_SESSION_HANDLE ((CK_SESSION_HANDLE)-1) ++#define PKCS11H_INVALID_OBJECT_HANDLE ((CK_OBJECT_HANDLE)-1) ++ ++#define PKCS11H_DEFAULT_SLOTEVENT_POLL 5000 ++#define PKCS11H_DEFAULT_MAX_LOGIN_RETRY 3 ++#define PKCS11H_DEFAULT_PIN_CACHE_PERIOD PKCS11H_PIN_CACHE_INFINITE ++ ++#define PKCS11H_SERIALIZE_INVALID_CHARS "\\/\"'%&#@!?$* <>{}[]()`|" ++ ++enum _pkcs11h_private_op_e { ++ _pkcs11h_private_op_sign=0, ++ _pkcs11h_private_op_sign_recover, ++ _pkcs11h_private_op_decrypt ++}; ++ ++/*=========================================== ++ * Macros ++ */ ++ ++#define PKCS11H_MSG_LEVEL_TEST(flags) (((unsigned int)flags) <= s_pkcs11h_loglevel) ++ ++#if defined(HAVE_CPP_VARARG_MACRO_ISO) && !defined(__LCLINT__) ++# define PKCS11H_LOG(flags, ...) do { if (PKCS11H_MSG_LEVEL_TEST(flags)) _pkcs11h_log((flags), __VA_ARGS__); } while (FALSE) ++# ifdef ENABLE_PKCS11H_DEBUG ++# define PKCS11H_DEBUG(flags, ...) do { if (PKCS11H_MSG_LEVEL_TEST(flags)) _pkcs11h_log((flags), __VA_ARGS__); } while (FALSE) ++# else ++# define PKCS11H_DEBUG(flags, ...) ++# endif ++#elif defined(HAVE_CPP_VARARG_MACRO_GCC) && !defined(__LCLINT__) ++# define PKCS11H_LOG(flags, args...) do { if (PKCS11H_MSG_LEVEL_TEST(flags)) _pkcs11h_log((flags), args); } while (FALSE) ++# ifdef ENABLE_PKCS11H_DEBUG ++# define PKCS11H_DEBUG(flags, args...) do { if (PKCS11H_MSG_LEVEL_TEST(flags)) _pkcs11h_log((flags), args); } while (FALSE) ++# else ++# define PKCS11H_DEBUG(flags, args...) ++# endif ++#else ++# define PKCS11H_LOG _pkcs11h_log ++# define PKCS11H_DEBUG _pkcs11h_log ++#endif ++ ++/*=========================================== ++ * Types ++ */ ++ ++struct pkcs11h_provider_s; ++struct pkcs11h_session_s; ++struct pkcs11h_data_s; ++typedef struct pkcs11h_provider_s *pkcs11h_provider_t; ++typedef struct pkcs11h_session_s *pkcs11h_session_t; ++typedef struct pkcs11h_data_s *pkcs11h_data_t; ++ ++#if defined(USE_PKCS11H_OPENSSL) ++ ++#if OPENSSL_VERSION_NUMBER < 0x00908000L ++typedef unsigned char *pkcs11_openssl_d2i_t; ++#else ++typedef const unsigned char *pkcs11_openssl_d2i_t; ++#endif ++ ++#endif ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ ++#define PKCS11H_COND_INFINITE 0xffffffff ++ ++#if defined(WIN32) ++#define PKCS11H_THREAD_NULL NULL ++typedef HANDLE pkcs11h_cond_t; ++typedef HANDLE pkcs11h_mutex_t; ++typedef HANDLE pkcs11h_thread_t; ++#else ++#define PKCS11H_THREAD_NULL 0l ++typedef pthread_mutex_t pkcs11h_mutex_t; ++typedef pthread_t pkcs11h_thread_t; ++ ++typedef struct { ++ pthread_cond_t cond; ++ pthread_mutex_t mut; ++} pkcs11h_cond_t; ++ ++typedef struct __pkcs11h_threading_mutex_entry_s { ++ struct __pkcs11h_threading_mutex_entry_s *next; ++ pkcs11h_mutex_t *p_mutex; ++ PKCS11H_BOOL locked; ++} *__pkcs11h_threading_mutex_entry_t; ++#endif ++ ++typedef void * (*pkcs11h_thread_start_t)(void *); ++ ++typedef struct { ++ pkcs11h_thread_start_t start; ++ void *data; ++} __pkcs11h_thread_data_t; ++ ++#endif /* ENABLE_PKCS11H_THREADING */ ++ ++struct pkcs11h_provider_s { ++ pkcs11h_provider_t next; ++ ++ PKCS11H_BOOL enabled; ++ char reference[1024]; ++ char manufacturerID[sizeof (((CK_TOKEN_INFO *)NULL)->manufacturerID)+1]; ++ ++#if defined(WIN32) ++ HANDLE handle; ++#else ++ void *handle; ++#endif ++ ++ CK_FUNCTION_LIST_PTR f; ++ PKCS11H_BOOL should_finalize; ++ PKCS11H_BOOL allow_protected_auth; ++ PKCS11H_BOOL cert_is_private; ++ unsigned mask_sign_mode; ++ int slot_event_method; ++ int slot_poll_interval; ++ ++#if defined(ENABLE_PKCS11H_SLOTEVENT) ++ pkcs11h_thread_t slotevent_thread; ++#endif ++}; ++ ++struct pkcs11h_session_s { ++ pkcs11h_session_t next; ++ ++ int reference_count; ++ PKCS11H_BOOL valid; ++ ++ pkcs11h_provider_t provider; ++ ++ pkcs11h_token_id_t token_id; ++ ++ CK_SESSION_HANDLE session_handle; ++ ++ PKCS11H_BOOL allow_protected_auth_supported; ++ int pin_cache_period; ++ time_t pin_expire_time; ++ ++#if defined(ENABLE_PKCS11H_ENUM) ++#if defined(ENABLE_PKCS11H_CERTIFICATE) ++ pkcs11h_certificate_id_list_t cached_certs; ++ PKCS11H_BOOL touch; ++#endif ++#endif ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ pkcs11h_mutex_t mutex; ++#endif ++}; ++ ++#if defined (ENABLE_PKCS11H_CERTIFICATE) ++ ++struct pkcs11h_certificate_s { ++ ++ pkcs11h_certificate_id_t id; ++ int pin_cache_period; ++ PKCS11H_BOOL pin_cache_populated_to_session; ++ ++ unsigned mask_sign_mode; ++ ++ pkcs11h_session_t session; ++ CK_OBJECT_HANDLE key_handle; ++ ++ PKCS11H_BOOL operation_active; ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ pkcs11h_mutex_t mutex; ++#endif ++ ++ unsigned mask_prompt; ++ void * user_data; ++}; ++ ++#endif /* ENABLE_PKCS11H_CERTIFICATE */ ++ ++struct pkcs11h_data_s { ++ PKCS11H_BOOL initialized; ++ int pin_cache_period; ++ ++ pkcs11h_provider_t providers; ++ pkcs11h_session_t sessions; ++ ++ struct { ++ void * log_data; ++ void * slotevent_data; ++ void * token_prompt_data; ++ void * pin_prompt_data; ++ pkcs11h_hook_log_t log; ++ pkcs11h_hook_slotevent_t slotevent; ++ pkcs11h_hook_token_prompt_t token_prompt; ++ pkcs11h_hook_pin_prompt_t pin_prompt; ++ } hooks; ++ ++ PKCS11H_BOOL allow_protected_auth; ++ unsigned max_retries; ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ struct { ++ pkcs11h_mutex_t global; ++ pkcs11h_mutex_t session; ++ pkcs11h_mutex_t cache; ++ } mutexes; ++#endif ++ ++#if defined(ENABLE_PKCS11H_SLOTEVENT) ++ struct { ++ PKCS11H_BOOL initialized; ++ PKCS11H_BOOL should_terminate; ++ PKCS11H_BOOL skip_event; ++ pkcs11h_cond_t cond_event; ++ pkcs11h_thread_t thread; ++ } slotevent; ++#endif ++}; ++ ++#if defined(ENABLE_PKCS11H_OPENSSL) ++struct pkcs11h_openssl_session_s { ++ int reference_count; ++ PKCS11H_BOOL initialized; ++ X509 *x509; ++ RSA_METHOD smart_rsa; ++ int (*orig_finish)(RSA *rsa); ++ pkcs11h_certificate_t certificate; ++ pkcs11h_hook_openssl_cleanup_t cleanup_hook; ++}; ++#endif ++ ++/*======================================================================* ++ * MEMORY INTERFACE ++ *======================================================================*/ ++ ++static ++CK_RV ++_pkcs11h_mem_malloc ( ++ OUT const void * * const p, ++ IN const size_t s ++); ++static ++CK_RV ++_pkcs11h_mem_free ( ++ IN const void * * const p ++); ++static ++CK_RV ++_pkcs11h_mem_strdup ( ++ OUT const char * * const dest, ++ IN const char * const src ++); ++static ++CK_RV ++_pkcs11h_mem_duplicate ( ++ OUT const void * * const dest, ++ OUT size_t * const dest_size, ++ IN const void * const src, ++ IN const size_t mem_size ++); ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++/*======================================================================* ++ * THREADING INTERFACE ++ *======================================================================*/ ++ ++static ++void ++_pkcs11h_threading_sleep ( ++ IN const unsigned milli ++); ++static ++CK_RV ++_pkcs11h_threading_mutexInit ( ++ OUT pkcs11h_mutex_t * const mutex ++); ++static ++CK_RV ++_pkcs11h_threading_mutexLock ( ++ IN OUT pkcs11h_mutex_t *const mutex ++); ++static ++CK_RV ++_pkcs11h_threading_mutexRelease ( ++ IN OUT pkcs11h_mutex_t *const mutex ++); ++static ++CK_RV ++_pkcs11h_threading_mutexFree ( ++ IN OUT pkcs11h_mutex_t *const mutex ++); ++#if !defined(WIN32) ++static ++void ++__pkcs1h_threading_mutexLockAll (); ++static ++void ++__pkcs1h_threading_mutexReleaseAll (); ++#endif ++static ++CK_RV ++_pkcs11h_threading_condSignal ( ++ IN OUT pkcs11h_cond_t *const cond ++); ++static ++CK_RV ++_pkcs11h_threading_condInit ( ++ OUT pkcs11h_cond_t * const cond ++); ++static ++CK_RV ++_pkcs11h_threading_condWait ( ++ IN OUT pkcs11h_cond_t *const cond, ++ IN const unsigned milli ++); ++static ++CK_RV ++_pkcs11h_threading_condFree ( ++ IN OUT pkcs11h_cond_t *const cond ++); ++static ++CK_RV ++_pkcs11h_threading_threadStart ( ++ OUT pkcs11h_thread_t * const thread, ++ IN pkcs11h_thread_start_t const start, ++ IN void * data ++); ++static ++CK_RV ++_pkcs11h_threading_threadJoin ( ++ IN pkcs11h_thread_t * const thread ++); ++#endif /* ENABLE_PKCS11H_THREADING */ ++ ++/*======================================================================* ++ * COMMON INTERNAL INTERFACE ++ *======================================================================*/ ++ ++static ++void ++_pkcs11h_util_fixupFixedString ( ++ OUT char * const target, /* MUST BE >= length+1 */ ++ IN const char * const source, ++ IN const size_t length /* FIXED STRING LENGTH */ ++); ++static ++CK_RV ++_pkcs11h_util_hexToBinary ( ++ OUT unsigned char * const target, ++ IN const char * const source, ++ IN OUT size_t * const p_target_size ++); ++static ++CK_RV ++_pkcs11h_util_binaryToHex ( ++ OUT char * const target, ++ IN const size_t target_size, ++ IN const unsigned char * const source, ++ IN const size_t source_size ++); ++CK_RV ++_pkcs11h_util_escapeString ( ++ IN OUT char * const target, ++ IN const char * const source, ++ IN size_t * const max, ++ IN const char * const invalid_chars ++); ++static ++CK_RV ++_pkcs11h_util_unescapeString ( ++ IN OUT char * const target, ++ IN const char * const source, ++ IN size_t * const max ++); ++static ++void ++_pkcs11h_log ( ++ IN const unsigned flags, ++ IN const char * const format, ++ IN ... ++) ++#ifdef __GNUC__ ++ __attribute__ ((format (printf, 2, 3))) ++#endif ++ ; ++ ++static ++CK_RV ++_pkcs11h_session_getSlotList ( ++ IN const pkcs11h_provider_t provider, ++ IN const CK_BBOOL token_present, ++ OUT CK_SLOT_ID_PTR * const pSlotList, ++ OUT CK_ULONG_PTR pulCount ++); ++static ++CK_RV ++_pkcs11h_session_getObjectAttributes ( ++ IN const pkcs11h_session_t session, ++ IN const CK_OBJECT_HANDLE object, ++ IN OUT const CK_ATTRIBUTE_PTR attrs, ++ IN const unsigned count ++); ++static ++CK_RV ++_pkcs11h_session_freeObjectAttributes ( ++ IN OUT const CK_ATTRIBUTE_PTR attrs, ++ IN const unsigned count ++); ++static ++CK_RV ++_pkcs11h_session_findObjects ( ++ IN const pkcs11h_session_t session, ++ IN const CK_ATTRIBUTE * const filter, ++ IN const CK_ULONG filter_attrs, ++ OUT CK_OBJECT_HANDLE **const p_objects, ++ OUT CK_ULONG *p_objects_found ++); ++static ++CK_RV ++_pkcs11h_token_getTokenId ( ++ IN const CK_TOKEN_INFO_PTR info, ++ OUT pkcs11h_token_id_t * const p_token_id ++); ++static ++CK_RV ++_pkcs11h_token_newTokenId ( ++ OUT pkcs11h_token_id_t * const token_id ++); ++static ++CK_RV ++_pkcs11h_session_getSessionByTokenId ( ++ IN const pkcs11h_token_id_t token_id, ++ OUT pkcs11h_session_t * const p_session ++); ++static ++CK_RV ++_pkcs11h_session_release ( ++ IN const pkcs11h_session_t session ++); ++static ++CK_RV ++_pkcs11h_session_reset ( ++ IN const pkcs11h_session_t session, ++ IN void * const user_data, ++ IN const unsigned mask_prompt, ++ OUT CK_SLOT_ID * const p_slot ++); ++static ++CK_RV ++_pkcs11h_session_getObjectById ( ++ IN const pkcs11h_session_t session, ++ IN const CK_OBJECT_CLASS class, ++ IN const CK_BYTE_PTR id, ++ IN const size_t id_size, ++ OUT CK_OBJECT_HANDLE * const p_handle ++); ++static ++CK_RV ++_pkcs11h_session_validate ( ++ IN const pkcs11h_session_t session ++); ++static ++CK_RV ++_pkcs11h_session_touch ( ++ IN const pkcs11h_session_t session ++); ++static ++CK_RV ++_pkcs11h_session_login ( ++ IN const pkcs11h_session_t session, ++ IN const PKCS11H_BOOL public_only, ++ IN const PKCS11H_BOOL readonly, ++ IN void * const user_data, ++ IN const unsigned mask_prompt ++); ++static ++CK_RV ++_pkcs11h_session_logout ( ++ IN const pkcs11h_session_t session ++); ++ ++static ++void ++_pkcs11h_hooks_default_log ( ++ IN void * const global_data, ++ IN const unsigned flags, ++ IN const char * const format, ++ IN va_list args ++); ++ ++static ++PKCS11H_BOOL ++_pkcs11h_hooks_default_token_prompt ( ++ IN void * const global_data, ++ IN void * const user_data, ++ IN const pkcs11h_token_id_t token, ++ IN const unsigned retry ++); ++ ++static ++PKCS11H_BOOL ++_pkcs11h_hooks_default_pin_prompt ( ++ IN void * const global_data, ++ IN void * const user_data, ++ IN const pkcs11h_token_id_t token, ++ IN const unsigned retry, ++ OUT char * const pin, ++ IN const size_t pin_max ++); ++ ++#if !defined(WIN32) ++#if defined(ENABLE_PKCS11H_THREADING) ++static ++void ++__pkcs11h_threading_atfork_prepare (); ++static ++void ++__pkcs11h_threading_atfork_parent (); ++static ++void ++__pkcs11h_threading_atfork_child (); ++#endif ++static ++CK_RV ++_pkcs11h_forkFixup (); ++#endif ++ ++#if defined(ENABLE_PKCS11H_CERTIFICATE) ++/*======================================================================* ++ * CERTIFICATE INTERFACE ++ *======================================================================*/ ++ ++static ++time_t ++_pkcs11h_certificate_getExpiration ( ++ IN const unsigned char * const certificate, ++ IN const size_t certificate_size ++); ++static ++PKCS11H_BOOL ++_pkcs11h_certificate_isBetterCertificate ( ++ IN const unsigned char * const current, ++ IN const size_t current_size, ++ IN const unsigned char * const newone, ++ IN const size_t newone_size ++); ++static ++CK_RV ++_pkcs11h_certificate_newCertificateId ( ++ OUT pkcs11h_certificate_id_t * const certificate_id ++); ++static ++CK_RV ++_pkcs11h_certificate_getDN ( ++ IN const unsigned char * const blob, ++ IN const size_t blob_size, ++ OUT char * const dn, ++ IN const size_t dn_size ++); ++static ++CK_RV ++_pkcs11h_certificate_loadCertificate ( ++ IN const pkcs11h_certificate_t certificate ++); ++static ++CK_RV ++_pkcs11h_certificate_updateCertificateIdDescription ( ++ IN OUT pkcs11h_certificate_id_t certificate_id ++); ++static ++CK_RV ++_pkcs11h_certificate_getKeyAttributes ( ++ IN const pkcs11h_certificate_t certificate ++); ++static ++CK_RV ++_pkcs11h_certificate_validateSession ( ++ IN const pkcs11h_certificate_t certificate ++); ++static ++CK_RV ++_pkcs11h_certificate_resetSession ( ++ IN const pkcs11h_certificate_t certificate, ++ IN const PKCS11H_BOOL public_only, ++ IN const PKCS11H_BOOL session_mutex_locked ++); ++static ++CK_RV ++_pkcs11h_certificate_doPrivateOperation ( ++ IN const pkcs11h_certificate_t certificate, ++ IN const enum _pkcs11h_private_op_e op, ++ IN const CK_MECHANISM_TYPE mech_type, ++ IN const unsigned char * const source, ++ IN const size_t source_size, ++ OUT unsigned char * const target, ++ IN OUT size_t * const p_target_size ++); ++#endif /* ENABLE_PKCS11H_CERTIFICATE */ ++ ++#if defined(ENABLE_PKCS11H_LOCATE) ++/*======================================================================* ++ * LOCATE INTERFACE ++ *======================================================================*/ ++ ++static ++CK_RV ++_pkcs11h_locate_getTokenIdBySlotId ( ++ IN const char * const slot, ++ OUT pkcs11h_token_id_t * const p_token_id ++); ++static ++CK_RV ++_pkcs11h_locate_getTokenIdBySlotName ( ++ IN const char * const name, ++ OUT pkcs11h_token_id_t * const p_token_id ++); ++static ++CK_RV ++_pkcs11h_locate_getTokenIdByLabel ( ++ IN const char * const label, ++ OUT pkcs11h_token_id_t * const p_token_id ++); ++ ++#if defined(ENABLE_PKCS11H_CERTIFICATE) ++ ++static ++CK_RV ++_pkcs11h_locate_getCertificateIdByLabel ( ++ IN const pkcs11h_session_t session, ++ IN OUT const pkcs11h_certificate_id_t certificate_id, ++ IN const char * const label ++); ++static ++CK_RV ++_pkcs11h_locate_getCertificateIdBySubject ( ++ IN const pkcs11h_session_t session, ++ IN OUT const pkcs11h_certificate_id_t certificate_id, ++ IN const char * const subject ++); ++ ++#endif /* ENABLE_PKCS11H_CERTIFICATE */ ++#endif /* ENABLE_PKCS11H_LOCATE */ ++ ++#if defined(ENABLE_PKCS11H_ENUM) ++/*======================================================================* ++ * ENUM INTERFACE ++ *======================================================================*/ ++ ++#if defined(ENABLE_PKCS11H_CERTIFICATE) ++ ++static ++CK_RV ++_pkcs11h_certificate_enumSessionCertificates ( ++ IN const pkcs11h_session_t session, ++ IN void * const user_data, ++ IN const unsigned mask_prompt ++); ++static ++CK_RV ++_pkcs11h_certificate_splitCertificateIdList ( ++ IN const pkcs11h_certificate_id_list_t cert_id_all, ++ OUT pkcs11h_certificate_id_list_t * const p_cert_id_issuers_list, ++ OUT pkcs11h_certificate_id_list_t * const p_cert_id_end_list ++); ++ ++#endif /* ENABLE_PKCS11H_CERTIFICATE */ ++ ++#endif /* ENABLE_PKCS11H_ENUM */ ++ ++#if defined(ENABLE_PKCS11H_SLOTEVENT) ++/*======================================================================* ++ * SLOTEVENT INTERFACE ++ *======================================================================*/ ++ ++static ++unsigned long ++_pkcs11h_slotevent_checksum ( ++ IN const unsigned char * const p, ++ IN const size_t s ++); ++static ++void * ++_pkcs11h_slotevent_provider ( ++ IN void *p ++); ++static ++void * ++_pkcs11h_slotevent_manager ( ++ IN void *p ++); ++static ++CK_RV ++_pkcs11h_slotevent_init (); ++static ++CK_RV ++_pkcs11h_slotevent_notify (); ++static ++CK_RV ++_pkcs11h_slotevent_terminate (); ++ ++#endif /* ENABLE_PKCS11H_SLOTEVENT */ ++ ++#if defined(ENABLE_PKCS11H_OPENSSL) ++/*======================================================================* ++ * OPENSSL INTERFACE ++ *======================================================================*/ ++ ++static ++int ++_pkcs11h_openssl_finish ( ++ IN OUT RSA *rsa ++); ++#if OPENSSL_VERSION_NUMBER < 0x00907000L ++static ++int ++_pkcs11h_openssl_dec ( ++ IN int flen, ++ IN unsigned char *from, ++ OUT unsigned char *to, ++ IN OUT RSA *rsa, ++ IN int padding ++); ++static ++int ++_pkcs11h_openssl_sign ( ++ IN int type, ++ IN unsigned char *m, ++ IN unsigned int m_len, ++ OUT unsigned char *sigret, ++ OUT unsigned int *siglen, ++ IN OUT RSA *rsa ++); ++#else ++static ++int ++_pkcs11h_openssl_dec ( ++ IN int flen, ++ IN const unsigned char *from, ++ OUT unsigned char *to, ++ IN OUT RSA *rsa, ++ IN int padding ++); ++static ++int ++_pkcs11h_openssl_sign ( ++ IN int type, ++ IN const unsigned char *m, ++ IN unsigned int m_len, ++ OUT unsigned char *sigret, ++ OUT unsigned int *siglen, ++ IN OUT const RSA *rsa ++); ++#endif ++static ++pkcs11h_openssl_session_t ++_pkcs11h_openssl_get_openssl_session ( ++ IN OUT const RSA *rsa ++); ++static ++pkcs11h_certificate_t ++_pkcs11h_openssl_get_pkcs11h_certificate ( ++ IN OUT const RSA *rsa ++); ++#endif /* ENABLE_PKCS11H_OPENSSL */ ++ ++/*========================================== ++ * Static data ++ */ ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++#if !defined(WIN32) ++static struct { ++ pkcs11h_mutex_t mutex; ++ __pkcs11h_threading_mutex_entry_t head; ++} __s_pkcs11h_threading_mutex_list = { ++ PTHREAD_MUTEX_INITIALIZER, ++ NULL ++}; ++#endif ++#endif ++ ++pkcs11h_data_t s_pkcs11h_data = NULL; ++unsigned int s_pkcs11h_loglevel = PKCS11H_LOG_INFO; ++ ++/*======================================================================* ++ * PUBLIC INTERFACE ++ *======================================================================*/ ++ ++const char * ++pkcs11h_getMessage ( ++ IN const CK_RV rv ++) { ++ switch (rv) { ++ case CKR_OK: return "CKR_OK"; ++ case CKR_CANCEL: return "CKR_CANCEL"; ++ case CKR_HOST_MEMORY: return "CKR_HOST_MEMORY"; ++ case CKR_SLOT_ID_INVALID: return "CKR_SLOT_ID_INVALID"; ++ case CKR_GENERAL_ERROR: return "CKR_GENERAL_ERROR"; ++ case CKR_FUNCTION_FAILED: return "CKR_FUNCTION_FAILED"; ++ case CKR_ARGUMENTS_BAD: return "CKR_ARGUMENTS_BAD"; ++ case CKR_NO_EVENT: return "CKR_NO_EVENT"; ++ case CKR_NEED_TO_CREATE_THREADS: return "CKR_NEED_TO_CREATE_THREADS"; ++ case CKR_CANT_LOCK: return "CKR_CANT_LOCK"; ++ case CKR_ATTRIBUTE_READ_ONLY: return "CKR_ATTRIBUTE_READ_ONLY"; ++ case CKR_ATTRIBUTE_SENSITIVE: return "CKR_ATTRIBUTE_SENSITIVE"; ++ case CKR_ATTRIBUTE_TYPE_INVALID: return "CKR_ATTRIBUTE_TYPE_INVALID"; ++ case CKR_ATTRIBUTE_VALUE_INVALID: return "CKR_ATTRIBUTE_VALUE_INVALID"; ++ case CKR_DATA_INVALID: return "CKR_DATA_INVALID"; ++ case CKR_DATA_LEN_RANGE: return "CKR_DATA_LEN_RANGE"; ++ case CKR_DEVICE_ERROR: return "CKR_DEVICE_ERROR"; ++ case CKR_DEVICE_MEMORY: return "CKR_DEVICE_MEMORY"; ++ case CKR_DEVICE_REMOVED: return "CKR_DEVICE_REMOVED"; ++ case CKR_ENCRYPTED_DATA_INVALID: return "CKR_ENCRYPTED_DATA_INVALID"; ++ case CKR_ENCRYPTED_DATA_LEN_RANGE: return "CKR_ENCRYPTED_DATA_LEN_RANGE"; ++ case CKR_FUNCTION_CANCELED: return "CKR_FUNCTION_CANCELED"; ++ case CKR_FUNCTION_NOT_PARALLEL: return "CKR_FUNCTION_NOT_PARALLEL"; ++ case CKR_FUNCTION_NOT_SUPPORTED: return "CKR_FUNCTION_NOT_SUPPORTED"; ++ case CKR_KEY_HANDLE_INVALID: return "CKR_KEY_HANDLE_INVALID"; ++ case CKR_KEY_SIZE_RANGE: return "CKR_KEY_SIZE_RANGE"; ++ case CKR_KEY_TYPE_INCONSISTENT: return "CKR_KEY_TYPE_INCONSISTENT"; ++ case CKR_KEY_NOT_NEEDED: return "CKR_KEY_NOT_NEEDED"; ++ case CKR_KEY_CHANGED: return "CKR_KEY_CHANGED"; ++ case CKR_KEY_NEEDED: return "CKR_KEY_NEEDED"; ++ case CKR_KEY_INDIGESTIBLE: return "CKR_KEY_INDIGESTIBLE"; ++ case CKR_KEY_FUNCTION_NOT_PERMITTED: return "CKR_KEY_FUNCTION_NOT_PERMITTED"; ++ case CKR_KEY_NOT_WRAPPABLE: return "CKR_KEY_NOT_WRAPPABLE"; ++ case CKR_KEY_UNEXTRACTABLE: return "CKR_KEY_UNEXTRACTABLE"; ++ case CKR_MECHANISM_INVALID: return "CKR_MECHANISM_INVALID"; ++ case CKR_MECHANISM_PARAM_INVALID: return "CKR_MECHANISM_PARAM_INVALID"; ++ case CKR_OBJECT_HANDLE_INVALID: return "CKR_OBJECT_HANDLE_INVALID"; ++ case CKR_OPERATION_ACTIVE: return "CKR_OPERATION_ACTIVE"; ++ case CKR_OPERATION_NOT_INITIALIZED: return "CKR_OPERATION_NOT_INITIALIZED"; ++ case CKR_PIN_INCORRECT: return "CKR_PIN_INCORRECT"; ++ case CKR_PIN_INVALID: return "CKR_PIN_INVALID"; ++ case CKR_PIN_LEN_RANGE: return "CKR_PIN_LEN_RANGE"; ++ case CKR_PIN_EXPIRED: return "CKR_PIN_EXPIRED"; ++ case CKR_PIN_LOCKED: return "CKR_PIN_LOCKED"; ++ case CKR_SESSION_CLOSED: return "CKR_SESSION_CLOSED"; ++ case CKR_SESSION_COUNT: return "CKR_SESSION_COUNT"; ++ case CKR_SESSION_HANDLE_INVALID: return "CKR_SESSION_HANDLE_INVALID"; ++ case CKR_SESSION_PARALLEL_NOT_SUPPORTED: return "CKR_SESSION_PARALLEL_NOT_SUPPORTED"; ++ case CKR_SESSION_READ_ONLY: return "CKR_SESSION_READ_ONLY"; ++ case CKR_SESSION_EXISTS: return "CKR_SESSION_EXISTS"; ++ case CKR_SESSION_READ_ONLY_EXISTS: return "CKR_SESSION_READ_ONLY_EXISTS"; ++ case CKR_SESSION_READ_WRITE_SO_EXISTS: return "CKR_SESSION_READ_WRITE_SO_EXISTS"; ++ case CKR_SIGNATURE_INVALID: return "CKR_SIGNATURE_INVALID"; ++ case CKR_SIGNATURE_LEN_RANGE: return "CKR_SIGNATURE_LEN_RANGE"; ++ case CKR_TEMPLATE_INCOMPLETE: return "CKR_TEMPLATE_INCOMPLETE"; ++ case CKR_TEMPLATE_INCONSISTENT: return "CKR_TEMPLATE_INCONSISTENT"; ++ case CKR_TOKEN_NOT_PRESENT: return "CKR_TOKEN_NOT_PRESENT"; ++ case CKR_TOKEN_NOT_RECOGNIZED: return "CKR_TOKEN_NOT_RECOGNIZED"; ++ case CKR_TOKEN_WRITE_PROTECTED: return "CKR_TOKEN_WRITE_PROTECTED"; ++ case CKR_UNWRAPPING_KEY_HANDLE_INVALID: return "CKR_UNWRAPPING_KEY_HANDLE_INVALID"; ++ case CKR_UNWRAPPING_KEY_SIZE_RANGE: return "CKR_UNWRAPPING_KEY_SIZE_RANGE"; ++ case CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT: return "CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT"; ++ case CKR_USER_ALREADY_LOGGED_IN: return "CKR_USER_ALREADY_LOGGED_IN"; ++ case CKR_USER_NOT_LOGGED_IN: return "CKR_USER_NOT_LOGGED_IN"; ++ case CKR_USER_PIN_NOT_INITIALIZED: return "CKR_USER_PIN_NOT_INITIALIZED"; ++ case CKR_USER_TYPE_INVALID: return "CKR_USER_TYPE_INVALID"; ++ case CKR_USER_ANOTHER_ALREADY_LOGGED_IN: return "CKR_USER_ANOTHER_ALREADY_LOGGED_IN"; ++ case CKR_USER_TOO_MANY_TYPES: return "CKR_USER_TOO_MANY_TYPES"; ++ case CKR_WRAPPED_KEY_INVALID: return "CKR_WRAPPED_KEY_INVALID"; ++ case CKR_WRAPPED_KEY_LEN_RANGE: return "CKR_WRAPPED_KEY_LEN_RANGE"; ++ case CKR_WRAPPING_KEY_HANDLE_INVALID: return "CKR_WRAPPING_KEY_HANDLE_INVALID"; ++ case CKR_WRAPPING_KEY_SIZE_RANGE: return "CKR_WRAPPING_KEY_SIZE_RANGE"; ++ case CKR_WRAPPING_KEY_TYPE_INCONSISTENT: return "CKR_WRAPPING_KEY_TYPE_INCONSISTENT"; ++ case CKR_RANDOM_SEED_NOT_SUPPORTED: return "CKR_RANDOM_SEED_NOT_SUPPORTED"; ++ case CKR_RANDOM_NO_RNG: return "CKR_RANDOM_NO_RNG"; ++ case CKR_DOMAIN_PARAMS_INVALID: return "CKR_DOMAIN_PARAMS_INVALID"; ++ case CKR_BUFFER_TOO_SMALL: return "CKR_BUFFER_TOO_SMALL"; ++ case CKR_SAVED_STATE_INVALID: return "CKR_SAVED_STATE_INVALID"; ++ case CKR_INFORMATION_SENSITIVE: return "CKR_INFORMATION_SENSITIVE"; ++ case CKR_STATE_UNSAVEABLE: return "CKR_STATE_UNSAVEABLE"; ++ case CKR_CRYPTOKI_NOT_INITIALIZED: return "CKR_CRYPTOKI_NOT_INITIALIZED"; ++ case CKR_CRYPTOKI_ALREADY_INITIALIZED: return "CKR_CRYPTOKI_ALREADY_INITIALIZED"; ++ case CKR_MUTEX_BAD: return "CKR_MUTEX_BAD"; ++ case CKR_MUTEX_NOT_LOCKED: return "CKR_MUTEX_NOT_LOCKED"; ++ case CKR_FUNCTION_REJECTED: return "CKR_FUNCTION_REJECTED"; ++ case CKR_VENDOR_DEFINED: return "CKR_VENDOR_DEFINED"; ++ default: return "Unknown PKCS#11 error"; ++ } ++} ++ ++CK_RV ++pkcs11h_initialize () { ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ PKCS11H_BOOL mutex_locked = FALSE; ++#endif ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_initialize entry" ++ ); ++ ++ pkcs11h_terminate (); ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_mem_malloc ((void*)&s_pkcs11h_data, sizeof (struct pkcs11h_data_s)); ++ } ++ ++#if defined(USE_PKCS11H_OPENSSL) || defined(ENABLE_PKCS11H_OPENSSL) ++ OpenSSL_add_all_digests (); ++#endif ++#if defined(USE_PKCS11H_GNUTLS) ++ if ( ++ rv == CKR_OK && ++ gnutls_global_init () != GNUTLS_E_SUCCESS ++ ) { ++ rv = CKR_FUNCTION_FAILED; ++ } ++#endif ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_threading_mutexInit (&s_pkcs11h_data->mutexes.global); ++ } ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_threading_mutexInit (&s_pkcs11h_data->mutexes.session); ++ } ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_threading_mutexInit (&s_pkcs11h_data->mutexes.cache); ++ } ++#if !defined(WIN32) ++ if ( ++ rv == CKR_OK && ++ pthread_atfork ( ++ __pkcs11h_threading_atfork_prepare, ++ __pkcs11h_threading_atfork_parent, ++ __pkcs11h_threading_atfork_child ++ ) ++ ) { ++ rv = CKR_FUNCTION_FAILED; ++ } ++#endif ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_threading_mutexLock (&s_pkcs11h_data->mutexes.global)) == CKR_OK ++ ) { ++ mutex_locked = TRUE; ++ } ++#endif ++ ++ if (rv == CKR_OK) { ++ s_pkcs11h_data->max_retries = PKCS11H_DEFAULT_MAX_LOGIN_RETRY; ++ s_pkcs11h_data->allow_protected_auth = TRUE; ++ s_pkcs11h_data->pin_cache_period = PKCS11H_DEFAULT_PIN_CACHE_PERIOD; ++ s_pkcs11h_data->initialized = TRUE; ++ } ++ ++ if (rv == CKR_OK) { ++ pkcs11h_setLogHook (_pkcs11h_hooks_default_log, NULL); ++ pkcs11h_setTokenPromptHook (_pkcs11h_hooks_default_token_prompt, NULL); ++ pkcs11h_setPINPromptHook (_pkcs11h_hooks_default_pin_prompt, NULL); ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if (mutex_locked) { ++ _pkcs11h_threading_mutexRelease (&s_pkcs11h_data->mutexes.global); ++ mutex_locked = FALSE; ++ } ++#endif ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_initialize return rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ return rv; ++} ++ ++CK_RV ++pkcs11h_terminate () { ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_terminate entry" ++ ); ++ ++ if (s_pkcs11h_data != NULL) { ++ pkcs11h_provider_t current_provider = NULL; ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Removing providers" ++ ); ++ ++ for ( ++ current_provider = s_pkcs11h_data->providers; ++ current_provider != NULL; ++ current_provider = current_provider->next ++ ) { ++ pkcs11h_removeProvider (current_provider->reference); ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ _pkcs11h_threading_mutexLock (&s_pkcs11h_data->mutexes.cache); ++ _pkcs11h_threading_mutexLock (&s_pkcs11h_data->mutexes.session); ++ _pkcs11h_threading_mutexLock (&s_pkcs11h_data->mutexes.global); ++#endif ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Releasing sessions" ++ ); ++ ++ while (s_pkcs11h_data->sessions != NULL) { ++ pkcs11h_session_t current = s_pkcs11h_data->sessions; ++ s_pkcs11h_data->sessions = s_pkcs11h_data->sessions->next; ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ _pkcs11h_threading_mutexLock (¤t->mutex); ++#endif ++ ++ current->valid = FALSE; ++ ++ if (current->reference_count != 0) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Warning: Found session with references" ++ ); ++ } ++ ++ if (current->token_id != NULL) { ++ pkcs11h_token_freeTokenId (current->token_id); ++ current->token_id = NULL; ++ } ++ ++#if defined(ENABLE_PKCS11H_ENUM) ++#if defined(ENABLE_PKCS11H_CERTIFICATE) ++ pkcs11h_certificate_freeCertificateIdList (current->cached_certs); ++#endif ++#endif ++ ++ current->provider = NULL; ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ _pkcs11h_threading_mutexFree (¤t->mutex); ++#endif ++ ++ _pkcs11h_mem_free ((void *)¤t); ++ } ++ ++#if defined(ENABLE_PKCS11H_SLOTEVENT) ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Terminating slotevent" ++ ); ++ ++ _pkcs11h_slotevent_terminate (); ++#endif ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Marking as uninitialized" ++ ); ++ ++ s_pkcs11h_data->initialized = FALSE; ++ ++ while (s_pkcs11h_data->providers != NULL) { ++ pkcs11h_provider_t current = s_pkcs11h_data->providers; ++ s_pkcs11h_data->providers = s_pkcs11h_data->providers->next; ++ ++ _pkcs11h_mem_free ((void *)¤t); ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ _pkcs11h_threading_mutexFree (&s_pkcs11h_data->mutexes.cache); ++ _pkcs11h_threading_mutexFree (&s_pkcs11h_data->mutexes.global); ++ _pkcs11h_threading_mutexFree (&s_pkcs11h_data->mutexes.session); ++#endif ++ ++#if defined(USE_PKCS11H_GNUTLS) ++ gnutls_global_deinit (); ++#endif ++ ++ _pkcs11h_mem_free ((void *)&s_pkcs11h_data); ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_terminate return" ++ ); ++ ++ return CKR_OK; ++} ++ ++void ++pkcs11h_setLogLevel ( ++ IN const unsigned flags ++) { ++ s_pkcs11h_loglevel = flags; ++} ++ ++unsigned ++pkcs11h_getLogLevel () { ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ ++ return s_pkcs11h_loglevel; ++} ++ ++CK_RV ++pkcs11h_setLogHook ( ++ IN const pkcs11h_hook_log_t hook, ++ IN void * const global_data ++) { ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ PKCS11H_ASSERT (hook!=NULL); ++ ++ s_pkcs11h_data->hooks.log = hook; ++ s_pkcs11h_data->hooks.log_data = global_data; ++ ++ return CKR_OK; ++} ++ ++CK_RV ++pkcs11h_setSlotEventHook ( ++ IN const pkcs11h_hook_slotevent_t hook, ++ IN void * const global_data ++) { ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ PKCS11H_ASSERT (hook!=NULL); ++ ++#if defined(ENABLE_PKCS11H_SLOTEVENT) ++ s_pkcs11h_data->hooks.slotevent = hook; ++ s_pkcs11h_data->hooks.slotevent_data = global_data; ++ ++ return _pkcs11h_slotevent_init (); ++#else ++ (void)global_data; ++ ++ return CKR_FUNCTION_NOT_SUPPORTED; ++#endif ++} ++ ++CK_RV ++pkcs11h_setPINPromptHook ( ++ IN const pkcs11h_hook_pin_prompt_t hook, ++ IN void * const global_data ++) { ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ PKCS11H_ASSERT (hook!=NULL); ++ ++ s_pkcs11h_data->hooks.pin_prompt = hook; ++ s_pkcs11h_data->hooks.pin_prompt_data = global_data; ++ ++ return CKR_OK; ++} ++ ++CK_RV ++pkcs11h_setTokenPromptHook ( ++ IN const pkcs11h_hook_token_prompt_t hook, ++ IN void * const global_data ++) { ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ PKCS11H_ASSERT (hook!=NULL); ++ ++ s_pkcs11h_data->hooks.token_prompt = hook; ++ s_pkcs11h_data->hooks.token_prompt_data = global_data; ++ ++ return CKR_OK; ++} ++ ++CK_RV ++pkcs11h_setPINCachePeriod ( ++ IN const int pin_cache_period ++) { ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ ++ s_pkcs11h_data->pin_cache_period = pin_cache_period; ++ ++ return CKR_OK; ++} ++ ++CK_RV ++pkcs11h_setMaxLoginRetries ( ++ IN const unsigned max_retries ++) { ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ ++ s_pkcs11h_data->max_retries = max_retries; ++ ++ return CKR_OK; ++} ++ ++CK_RV ++pkcs11h_setProtectedAuthentication ( ++ IN const PKCS11H_BOOL allow_protected_auth ++) { ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ ++ s_pkcs11h_data->allow_protected_auth = allow_protected_auth; ++ ++ return CKR_OK; ++} ++ ++CK_RV ++pkcs11h_addProvider ( ++ IN const char * const reference, ++ IN const char * const provider_location, ++ IN const PKCS11H_BOOL allow_protected_auth, ++ IN const unsigned mask_sign_mode, ++ IN const int slot_event_method, ++ IN const int slot_poll_interval, ++ IN const PKCS11H_BOOL cert_is_private ++) { ++#if defined(ENABLE_PKCS11H_THREADING) ++ PKCS11H_BOOL mutex_locked = FALSE; ++#endif ++#if defined(WIN32) ++ int mypid = 0; ++#else ++ pid_t mypid = getpid (); ++#endif ++ pkcs11h_provider_t provider = NULL; ++ CK_C_GetFunctionList gfl = NULL; ++ CK_INFO info; ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ PKCS11H_ASSERT (provider_location!=NULL); ++ /*PKCS11H_ASSERT (szSignMode!=NULL); NOT NEEDED*/ ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_addProvider entry pid=%d, reference='%s', provider_location='%s', allow_protected_auth=%d, mask_sign_mode=%08x, cert_is_private=%d", ++ mypid, ++ reference, ++ provider_location, ++ allow_protected_auth ? 1 : 0, ++ mask_sign_mode, ++ cert_is_private ? 1 : 0 ++ ); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Adding provider '%s'-'%s'", ++ reference, ++ provider_location ++ ); ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_threading_mutexLock (&s_pkcs11h_data->mutexes.global)) == CKR_OK ++ ) { ++ mutex_locked = TRUE; ++ } ++#endif ++ ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_mem_malloc ((void *)&provider, sizeof (struct pkcs11h_provider_s))) == CKR_OK ++ ) { ++ strncpy ( ++ provider->reference, ++ reference, ++ sizeof (provider->reference)-1 ++ ); ++ provider->reference[sizeof (provider->reference)-1] = '\x0'; ++ strncpy ( ++ provider->manufacturerID, ++ ( ++ strlen (provider_location) < sizeof (provider->manufacturerID) ? ++ provider_location : ++ provider_location+strlen (provider_location)-sizeof (provider->manufacturerID)+1 ++ ), ++ sizeof (provider->manufacturerID)-1 ++ ); ++ provider->manufacturerID[sizeof (provider->manufacturerID)-1] = '\x0'; ++ provider->allow_protected_auth = allow_protected_auth; ++ provider->mask_sign_mode = mask_sign_mode; ++ provider->slot_event_method = slot_event_method; ++ provider->slot_poll_interval = slot_poll_interval; ++ provider->cert_is_private = cert_is_private; ++ } ++ ++ if (rv == CKR_OK) { ++#if defined(WIN32) ++ provider->handle = LoadLibraryA (provider_location); ++#else ++ provider->handle = dlopen (provider_location, RTLD_NOW); ++#endif ++ if (provider->handle == NULL) { ++ rv = CKR_FUNCTION_FAILED; ++ } ++ } ++ ++ if (rv == CKR_OK) { ++#if defined(WIN32) ++ gfl = (CK_C_GetFunctionList)GetProcAddress ( ++ provider->handle, ++ "C_GetFunctionList" ++ ); ++#else ++ /* ++ * Make compiler happy! ++ */ ++ void *p = dlsym ( ++ provider->handle, ++ "C_GetFunctionList" ++ ); ++ memmove ( ++ &gfl, ++ &p, ++ sizeof (void *) ++ ); ++#endif ++ if (gfl == NULL) { ++ rv = CKR_FUNCTION_FAILED; ++ } ++ } ++ ++ if (rv == CKR_OK) { ++ rv = gfl (&provider->f); ++ } ++ ++ if (rv == CKR_OK) { ++ if ((rv = provider->f->C_Initialize (NULL)) != CKR_OK) { ++ if (rv == CKR_CRYPTOKI_ALREADY_INITIALIZED) { ++ rv = CKR_OK; ++ } ++ } ++ else { ++ provider->should_finalize = TRUE; ++ } ++ } ++ ++ if ( ++ rv == CKR_OK && ++ (rv = provider->f->C_GetInfo (&info)) == CKR_OK ++ ) { ++ _pkcs11h_util_fixupFixedString ( ++ provider->manufacturerID, ++ (char *)info.manufacturerID, ++ sizeof (info.manufacturerID) ++ ); ++ } ++ ++ if (rv == CKR_OK) { ++ provider->enabled = TRUE; ++ } ++ ++ if (provider != NULL) { ++ if (s_pkcs11h_data->providers == NULL) { ++ s_pkcs11h_data->providers = provider; ++ } ++ else { ++ pkcs11h_provider_t last = NULL; ++ ++ for ( ++ last = s_pkcs11h_data->providers; ++ last->next != NULL; ++ last = last->next ++ ); ++ last->next = provider; ++ } ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if (mutex_locked) { ++ _pkcs11h_threading_mutexRelease (&s_pkcs11h_data->mutexes.global); ++ mutex_locked = FALSE; ++ } ++#endif ++ ++#if defined(ENABLE_PKCS11H_SLOTEVENT) ++ _pkcs11h_slotevent_notify (); ++#endif ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Provider '%s' added rv=%ld-'%s'", ++ reference, ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_addProvider return rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ return rv; ++} ++ ++CK_RV ++pkcs11h_removeProvider ( ++ IN const char * const reference ++) { ++#if defined(ENABLE_PKCS11H_THREADING) ++ pkcs11h_session_t current_session = NULL; ++#endif ++ pkcs11h_provider_t provider = NULL; ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (reference!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_removeProvider entry reference='%s'", ++ reference ++ ); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Removing provider '%s'", ++ reference ++ ); ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ _pkcs11h_threading_mutexLock (&s_pkcs11h_data->mutexes.cache); ++ _pkcs11h_threading_mutexLock (&s_pkcs11h_data->mutexes.session); ++ _pkcs11h_threading_mutexLock (&s_pkcs11h_data->mutexes.global); ++ ++ for ( ++ current_session = s_pkcs11h_data->sessions; ++ current_session != NULL; ++ current_session = current_session->next ++ ) { ++ _pkcs11h_threading_mutexLock (¤t_session->mutex); ++ } ++#endif ++ ++ provider = s_pkcs11h_data->providers; ++ while ( ++ rv == CKR_OK && ++ provider != NULL && ++ strcmp (reference, provider->reference) ++ ) { ++ provider = provider->next; ++ } ++ ++ if (rv == CKR_OK && provider == NULL) { ++ rv = CKR_OBJECT_HANDLE_INVALID; ++ } ++ ++ if (rv == CKR_OK) { ++ provider->enabled = FALSE; ++ provider->reference[0] = '\0'; ++ ++ if (provider->should_finalize) { ++ provider->f->C_Finalize (NULL); ++ provider->should_finalize = FALSE; ++ } ++ ++#if defined(ENABLE_PKCS11H_SLOTEVENT) ++ _pkcs11h_slotevent_notify (); ++ ++ /* ++ * Wait until manager join this thread ++ * this happens saldom so I can poll ++ */ ++ while (provider->slotevent_thread != PKCS11H_THREAD_NULL) { ++ _pkcs11h_threading_sleep (500); ++ } ++#endif ++ ++ if (provider->f != NULL) { ++ provider->f = NULL; ++ } ++ ++ if (provider->handle != NULL) { ++#if defined(WIN32) ++ FreeLibrary (provider->handle); ++#else ++ dlclose (provider->handle); ++#endif ++ provider->handle = NULL; ++ } ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ for ( ++ current_session = s_pkcs11h_data->sessions; ++ current_session != NULL; ++ current_session = current_session->next ++ ) { ++ _pkcs11h_threading_mutexRelease (¤t_session->mutex); ++ } ++ ++ _pkcs11h_threading_mutexRelease (&s_pkcs11h_data->mutexes.cache); ++ _pkcs11h_threading_mutexRelease (&s_pkcs11h_data->mutexes.session); ++ _pkcs11h_threading_mutexRelease (&s_pkcs11h_data->mutexes.global); ++#endif ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_removeProvider return rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ return rv; ++} ++ ++CK_RV ++pkcs11h_forkFixup () { ++#if defined(WIN32) ++ return CKR_OK; ++#else ++#if defined(ENABLE_PKCS11H_THREADING) ++ return CKR_OK; ++#else ++ return _pkcs11h_forkFixup (); ++#endif ++#endif ++} ++ ++CK_RV ++pkcs11h_plugAndPlay () { ++#if defined(WIN32) ++ int mypid = 0; ++#else ++ pid_t mypid = getpid (); ++#endif ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_forkFixup entry pid=%d", ++ mypid ++ ); ++ ++ if (s_pkcs11h_data != NULL && s_pkcs11h_data->initialized) { ++ pkcs11h_provider_t current; ++#if defined(ENABLE_PKCS11H_SLOTEVENT) ++ PKCS11H_BOOL slot_event_active = FALSE; ++#endif ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ _pkcs11h_threading_mutexLock (&s_pkcs11h_data->mutexes.global); ++#endif ++ for ( ++ current = s_pkcs11h_data->providers; ++ current != NULL; ++ current = current->next ++ ) { ++ if (current->enabled) { ++ current->f->C_Finalize (NULL); ++ } ++ } ++ ++#if defined(ENABLE_PKCS11H_SLOTEVENT) ++ if (s_pkcs11h_data->slotevent.initialized) { ++ slot_event_active = TRUE; ++ _pkcs11h_slotevent_terminate (); ++ } ++#endif ++ ++ for ( ++ current = s_pkcs11h_data->providers; ++ current != NULL; ++ current = current->next ++ ) { ++ if (current->enabled) { ++ current->f->C_Initialize (NULL); ++ } ++ } ++ ++#if defined(ENABLE_PKCS11H_SLOTEVENT) ++ if (slot_event_active) { ++ _pkcs11h_slotevent_init (); ++ } ++#endif ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ _pkcs11h_threading_mutexRelease (&s_pkcs11h_data->mutexes.global); ++#endif ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_forkFixup return" ++ ); ++ ++ return CKR_OK; ++} ++ ++CK_RV ++pkcs11h_token_freeTokenId ( ++ IN pkcs11h_token_id_t token_id ++) { ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ PKCS11H_ASSERT (token_id!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_token_freeTokenId entry certificate_id=%p", ++ (void *)token_id ++ ); ++ ++ _pkcs11h_mem_free ((void *)&token_id); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_token_freeTokenId return" ++ ); ++ ++ return CKR_OK; ++} ++ ++CK_RV ++pkcs11h_token_duplicateTokenId ( ++ OUT pkcs11h_token_id_t * const to, ++ IN const pkcs11h_token_id_t from ++) { ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ PKCS11H_ASSERT (to!=NULL); ++ PKCS11H_ASSERT (from!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_token_duplicateTokenId entry to=%p form=%p", ++ (void *)to, ++ (void *)from ++ ); ++ ++ *to = NULL; ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_mem_duplicate ( ++ (void*)to, ++ NULL, ++ from, ++ sizeof (struct pkcs11h_token_id_s) ++ ); ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_token_duplicateTokenId return rv=%ld-'%s', *to=%p", ++ rv, ++ pkcs11h_getMessage (rv), ++ (void *)*to ++ ); ++ ++ return rv; ++} ++ ++PKCS11H_BOOL ++pkcs11h_token_sameTokenId ( ++ IN const pkcs11h_token_id_t a, ++ IN const pkcs11h_token_id_t b ++) { ++ PKCS11H_ASSERT (a!=NULL); ++ PKCS11H_ASSERT (b!=NULL); ++ ++ return ( ++ !strcmp (a->manufacturerID, b->manufacturerID) && ++ !strcmp (a->model, b->model) && ++ !strcmp (a->serialNumber, b->serialNumber) && ++ !strcmp (a->label, b->label) ++ ); ++} ++ ++#if defined(ENABLE_PKCS11H_SERIALIZATION) ++ ++CK_RV ++pkcs11h_token_serializeTokenId ( ++ OUT char * const sz, ++ IN OUT size_t *max, ++ IN const pkcs11h_token_id_t token_id ++) { ++ const char *sources[5]; ++ CK_RV rv = CKR_OK; ++ size_t n; ++ int e; ++ ++ /*PKCS11H_ASSERT (sz!=NULL); Not required*/ ++ PKCS11H_ASSERT (max!=NULL); ++ PKCS11H_ASSERT (token_id!=NULL); ++ ++ { /* Must be after assert */ ++ sources[0] = token_id->manufacturerID; ++ sources[1] = token_id->model; ++ sources[2] = token_id->serialNumber; ++ sources[3] = token_id->label; ++ sources[4] = NULL; ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_token_serializeTokenId entry sz=%p, *max=%u, token_id=%p", ++ sz, ++ sz != NULL ? *max : 0, ++ (void *)token_id ++ ); ++ ++ n = 0; ++ for (e=0;rv == CKR_OK && sources[e] != NULL;e++) { ++ size_t t; ++ rv = _pkcs11h_util_escapeString (NULL, sources[e], &t, PKCS11H_SERIALIZE_INVALID_CHARS); ++ n+=t; ++ } ++ ++ if (sz != NULL) { ++ if (*max < n) { ++ rv = CKR_ATTRIBUTE_VALUE_INVALID; ++ } ++ else { ++ n = 0; ++ for (e=0;sources[e] != NULL;e++) { ++ size_t t = *max-n; ++ _pkcs11h_util_escapeString (sz+n, sources[e], &t, PKCS11H_SERIALIZE_INVALID_CHARS); ++ n+=t; ++ sz[n-1] = '/'; ++ } ++ sz[n-1] = '\x0'; ++ } ++ } ++ ++ *max = n; ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_token_serializeTokenId return rv=%ld-'%s', *max=%u, sz='%s'", ++ rv, ++ pkcs11h_getMessage (rv), ++ *max, ++ sz ++ ); ++ ++ return rv; ++} ++ ++CK_RV ++pkcs11h_token_deserializeTokenId ( ++ OUT pkcs11h_token_id_t *p_token_id, ++ IN const char * const sz ++) { ++#define __PKCS11H_TARGETS_NUMBER 4 ++ struct { ++ char *p; ++ size_t s; ++ } targets[__PKCS11H_TARGETS_NUMBER]; ++ ++ pkcs11h_token_id_t token_id = NULL; ++ char *p1 = NULL; ++ char *_sz = NULL; ++ int e; ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (p_token_id!=NULL); ++ PKCS11H_ASSERT (sz!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_token_deserializeTokenId entry p_token_id=%p, sz='%s'", ++ (void *)p_token_id, ++ sz ++ ); ++ ++ *p_token_id = NULL; ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_mem_strdup ( ++ (void *)&_sz, ++ sz ++ ); ++ } ++ ++ if (rv == CKR_OK) { ++ p1 = _sz; ++ } ++ ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_token_newTokenId (&token_id)) == CKR_OK ++ ) { ++ targets[0].p = token_id->manufacturerID; ++ targets[0].s = sizeof (token_id->manufacturerID); ++ targets[1].p = token_id->model; ++ targets[1].s = sizeof (token_id->model); ++ targets[2].p = token_id->serialNumber; ++ targets[2].s = sizeof (token_id->serialNumber); ++ targets[3].p = token_id->label; ++ targets[3].s = sizeof (token_id->label); ++ } ++ ++ for (e=0;rv == CKR_OK && e < __PKCS11H_TARGETS_NUMBER;e++) { ++ size_t l; ++ char *p2 = NULL; ++ ++ /* ++ * Don't search for last ++ * separator ++ */ ++ if (rv == CKR_OK) { ++ if (e != __PKCS11H_TARGETS_NUMBER-1) { ++ p2 = strchr (p1, '/'); ++ if (p2 == NULL) { ++ rv = CKR_ATTRIBUTE_VALUE_INVALID; ++ } ++ else { ++ *p2 = '\x0'; ++ } ++ } ++ } ++ ++ if (rv == CKR_OK) { ++ _pkcs11h_util_unescapeString ( ++ NULL, ++ p1, ++ &l ++ ); ++ } ++ ++ if (rv == CKR_OK) { ++ if (l > targets[e].s) { ++ rv = CKR_ATTRIBUTE_VALUE_INVALID; ++ } ++ } ++ ++ if (rv == CKR_OK) { ++ l = targets[e].s; ++ _pkcs11h_util_unescapeString ( ++ targets[e].p, ++ p1, ++ &l ++ ); ++ } ++ ++ if (rv == CKR_OK) { ++ p1 = p2+1; ++ } ++ } ++ ++ if (rv == CKR_OK) { ++ strncpy ( ++ token_id->display, ++ token_id->label, ++ sizeof (token_id->display) ++ ); ++ } ++ ++ if (rv == CKR_OK) { ++ *p_token_id = token_id; ++ token_id = NULL; ++ } ++ ++ if (_sz != NULL) { ++ _pkcs11h_mem_free ((void *)&_sz); ++ } ++ ++ if (token_id != NULL) { ++ pkcs11h_token_freeTokenId (token_id); ++ } ++ ++ return rv; ++#undef __PKCS11H_TARGETS_NUMBER ++} ++ ++#endif /* ENABLE_PKCS11H_SERIALIZATION */ ++ ++/*======================================================================* ++ * MEMORY INTERFACE ++ *======================================================================*/ ++ ++static ++CK_RV ++_pkcs11h_mem_malloc ( ++ OUT const void * * const p, ++ IN const size_t s ++) { ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (p!=NULL); ++ PKCS11H_ASSERT (s!=0); ++ ++ *p = NULL; ++ ++ if (s > 0) { ++ if ( ++ (*p = (void *)PKCS11H_MALLOC (s)) == NULL ++ ) { ++ rv = CKR_HOST_MEMORY; ++ } ++ else { ++ memset ((void *)*p, 0, s); ++ } ++ } ++ ++ return rv; ++} ++ ++static ++CK_RV ++_pkcs11h_mem_free ( ++ IN const void * * const p ++) { ++ PKCS11H_ASSERT (p!=NULL); ++ ++ PKCS11H_FREE ((void *)*p); ++ *p = NULL; ++ ++ return CKR_OK; ++} ++ ++static ++CK_RV ++_pkcs11h_mem_strdup ( ++ OUT const char * * const dest, ++ IN const char * const src ++) { ++ return _pkcs11h_mem_duplicate ( ++ (void *)dest, ++ NULL, ++ src, ++ strlen (src)+1 ++ ); ++} ++ ++static ++CK_RV ++_pkcs11h_mem_duplicate ( ++ OUT const void * * const dest, ++ OUT size_t * const p_dest_size, ++ IN const void * const src, ++ IN const size_t mem_size ++) { ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (dest!=NULL); ++ /*PKCS11H_ASSERT (dest_size!=NULL); NOT NEEDED*/ ++ PKCS11H_ASSERT (!(mem_size!=0&&src==NULL)); ++ ++ *dest = NULL; ++ if (p_dest_size != NULL) { ++ *p_dest_size = 0; ++ } ++ ++ if (src != NULL) { ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_mem_malloc (dest, mem_size)) == CKR_OK ++ ) { ++ if (p_dest_size != NULL) { ++ *p_dest_size = mem_size; ++ } ++ memmove ((void*)*dest, src, mem_size); ++ } ++ } ++ ++ return rv; ++} ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++/*======================================================================* ++ * THREADING INTERFACE ++ *======================================================================*/ ++ ++static ++void ++_pkcs11h_threading_sleep ( ++ IN const unsigned milli ++) { ++#if defined(WIN32) ++ Sleep (milli); ++#else ++ usleep (milli*1000); ++#endif ++} ++ ++static ++CK_RV ++_pkcs11h_threading_mutexInit ( ++ OUT pkcs11h_mutex_t * const mutex ++) { ++ CK_RV rv = CKR_OK; ++#if defined(WIN32) ++ if ( ++ rv == CKR_OK && ++ (*mutex = CreateMutex (NULL, FALSE, NULL)) == NULL ++ ) { ++ rv = CKR_FUNCTION_FAILED; ++ } ++#else ++ { ++ __pkcs11h_threading_mutex_entry_t entry = NULL; ++ PKCS11H_BOOL mutex_locked = FALSE; ++ ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_threading_mutexLock (&__s_pkcs11h_threading_mutex_list.mutex)) == CKR_OK ++ ) { ++ mutex_locked = TRUE; ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_mem_malloc ( ++ (void *)&entry, ++ sizeof (struct __pkcs11h_threading_mutex_entry_s) ++ ); ++ } ++ ++ if ( ++ rv == CKR_OK && ++ pthread_mutex_init (mutex, NULL) ++ ) { ++ rv = CKR_FUNCTION_FAILED; ++ } ++ ++ if (rv == CKR_OK) { ++ entry->p_mutex = mutex; ++ entry->next = __s_pkcs11h_threading_mutex_list.head; ++ __s_pkcs11h_threading_mutex_list.head = entry; ++ entry = NULL; ++ } ++ ++ if (entry != NULL) { ++ _pkcs11h_mem_free ((void *)&entry); ++ } ++ ++ if (mutex_locked) { ++ _pkcs11h_threading_mutexRelease (&__s_pkcs11h_threading_mutex_list.mutex); ++ mutex_locked = FALSE; ++ } ++ } ++#endif ++ return rv; ++} ++ ++static ++CK_RV ++_pkcs11h_threading_mutexLock ( ++ IN OUT pkcs11h_mutex_t *const mutex ++) { ++ CK_RV rv = CKR_OK; ++#if defined(WIN32) ++ if ( ++ rv == CKR_OK && ++ WaitForSingleObject (*mutex, INFINITE) == WAIT_FAILED ++ ) { ++ rv = CKR_FUNCTION_FAILED; ++ } ++#else ++ if ( ++ rv == CKR_OK && ++ pthread_mutex_lock (mutex) ++ ) { ++ rv = CKR_FUNCTION_FAILED; ++ } ++#endif ++ return rv; ++} ++ ++static ++CK_RV ++_pkcs11h_threading_mutexRelease ( ++ IN OUT pkcs11h_mutex_t *const mutex ++) { ++ CK_RV rv = CKR_OK; ++#if defined(WIN32) ++ if ( ++ rv == CKR_OK && ++ !ReleaseMutex (*mutex) ++ ) { ++ rv = CKR_FUNCTION_FAILED; ++ } ++#else ++ if ( ++ rv == CKR_OK && ++ pthread_mutex_unlock (mutex) ++ ) { ++ rv = CKR_FUNCTION_FAILED; ++ } ++#endif ++ return rv; ++} ++ ++static ++CK_RV ++_pkcs11h_threading_mutexFree ( ++ IN OUT pkcs11h_mutex_t *const mutex ++) { ++#if defined(WIN32) ++ if (*mutex != NULL) { ++ CloseHandle (*mutex); ++ *mutex = NULL; ++ } ++#else ++ { ++ __pkcs11h_threading_mutex_entry_t last = NULL; ++ __pkcs11h_threading_mutex_entry_t entry = NULL; ++ PKCS11H_BOOL mutex_locked = FALSE; ++ ++ if (_pkcs11h_threading_mutexLock (&__s_pkcs11h_threading_mutex_list.mutex) == CKR_OK) { ++ mutex_locked = TRUE; ++ } ++ ++ entry = __s_pkcs11h_threading_mutex_list.head; ++ while ( ++ entry != NULL && ++ entry->p_mutex != mutex ++ ) { ++ last = entry; ++ entry = entry->next; ++ } ++ ++ if (entry != NULL) { ++ if (last == NULL) { ++ __s_pkcs11h_threading_mutex_list.head = entry->next; ++ } ++ else { ++ last->next = entry->next; ++ } ++ _pkcs11h_mem_free ((void *)&entry); ++ } ++ ++ pthread_mutex_destroy (mutex); ++ ++ if (mutex_locked) { ++ _pkcs11h_threading_mutexRelease (&__s_pkcs11h_threading_mutex_list.mutex); ++ mutex_locked = FALSE; ++ } ++ } ++#endif ++ return CKR_OK; ++} ++ ++#if !defined(WIN32) ++/* ++ * This function is required in order ++ * to lock all mutexes before fork is called, ++ * and to avoid dedlocks. ++ * The loop is required because there is no ++ * way to lock all mutex in one system call... ++ */ ++static ++void ++__pkcs1h_threading_mutexLockAll () { ++ __pkcs11h_threading_mutex_entry_t entry = NULL; ++ PKCS11H_BOOL mutex_locked = FALSE; ++ PKCS11H_BOOL all_mutexes_locked = FALSE; ++ ++ if (_pkcs11h_threading_mutexLock (&__s_pkcs11h_threading_mutex_list.mutex) == CKR_OK) { ++ mutex_locked = TRUE; ++ } ++ ++ for ( ++ entry = __s_pkcs11h_threading_mutex_list.head; ++ entry != NULL; ++ entry = entry->next ++ ) { ++ entry->locked = FALSE; ++ } ++ ++ while (!all_mutexes_locked) { ++ PKCS11H_BOOL ok = TRUE; ++ ++ for ( ++ entry = __s_pkcs11h_threading_mutex_list.head; ++ entry != NULL && ok; ++ entry = entry->next ++ ) { ++ if (!pthread_mutex_trylock (entry->p_mutex)) { ++ entry->locked = TRUE; ++ } ++ else { ++ ok = FALSE; ++ } ++ } ++ ++ if (!ok) { ++ for ( ++ entry = __s_pkcs11h_threading_mutex_list.head; ++ entry != NULL; ++ entry = entry->next ++ ) { ++ if (entry->locked == TRUE) { ++ pthread_mutex_unlock (entry->p_mutex); ++ entry->locked = FALSE; ++ } ++ } ++ ++ _pkcs11h_threading_mutexRelease (&__s_pkcs11h_threading_mutex_list.mutex); ++ _pkcs11h_threading_sleep (1000); ++ _pkcs11h_threading_mutexLock (&__s_pkcs11h_threading_mutex_list.mutex); ++ } ++ else { ++ all_mutexes_locked = TRUE; ++ } ++ } ++ ++ if (mutex_locked) { ++ _pkcs11h_threading_mutexRelease (&__s_pkcs11h_threading_mutex_list.mutex); ++ mutex_locked = FALSE; ++ } ++} ++ ++static ++void ++__pkcs1h_threading_mutexReleaseAll () { ++ __pkcs11h_threading_mutex_entry_t entry = NULL; ++ PKCS11H_BOOL mutex_locked = FALSE; ++ ++ if (_pkcs11h_threading_mutexLock (&__s_pkcs11h_threading_mutex_list.mutex) == CKR_OK) { ++ mutex_locked = TRUE; ++ } ++ ++ for ( ++ entry = __s_pkcs11h_threading_mutex_list.head; ++ entry != NULL; ++ entry = entry->next ++ ) { ++ pthread_mutex_unlock (entry->p_mutex); ++ entry->locked = FALSE; ++ } ++ ++ if (mutex_locked) { ++ _pkcs11h_threading_mutexRelease (&__s_pkcs11h_threading_mutex_list.mutex); ++ mutex_locked = FALSE; ++ } ++} ++#endif ++ ++CK_RV ++_pkcs11h_threading_condSignal ( ++ IN OUT pkcs11h_cond_t *const cond ++) { ++ CK_RV rv = CKR_OK; ++#if defined(WIN32) ++ if ( ++ rv == CKR_OK && ++ !SetEvent (*cond) ++ ) { ++ rv = CKR_FUNCTION_FAILED; ++ } ++#else ++ if ( ++ rv == CKR_OK && ++ ( ++ pthread_mutex_lock (&cond->mut) || ++ pthread_cond_signal (&cond->cond) || ++ pthread_mutex_unlock (&cond->mut) ++ ) ++ ) { ++ rv = CKR_FUNCTION_FAILED; ++ } ++#endif ++ ++ return rv; ++} ++ ++static ++CK_RV ++_pkcs11h_threading_condInit ( ++ OUT pkcs11h_cond_t * const cond ++) { ++ CK_RV rv = CKR_OK; ++#if defined(WIN32) ++ if ( ++ rv == CKR_OK && ++ (*cond = CreateEvent (NULL, FALSE, FALSE, NULL)) == NULL ++ ) { ++ rv = CKR_FUNCTION_FAILED; ++ } ++#else ++ if ( ++ rv == CKR_OK && ++ ( ++ pthread_mutex_init (&cond->mut, NULL) || ++ pthread_cond_init (&cond->cond, NULL) || ++ pthread_mutex_lock (&cond->mut) ++ ) ++ ) { ++ rv = CKR_FUNCTION_FAILED; ++ } ++#endif ++ return rv; ++} ++ ++static ++CK_RV ++_pkcs11h_threading_condWait ( ++ IN OUT pkcs11h_cond_t *const cond, ++ IN const unsigned milli ++) { ++ CK_RV rv = CKR_OK; ++ ++#if defined(WIN32) ++ DWORD dwMilli; ++ ++ if (milli == PKCS11H_COND_INFINITE) { ++ dwMilli = INFINITE; ++ } ++ else { ++ dwMilli = milli; ++ } ++ ++ if ( ++ rv == CKR_OK && ++ WaitForSingleObject (*cond, dwMilli) == WAIT_FAILED ++ ) { ++ rv = CKR_FUNCTION_FAILED; ++ } ++#else ++ if (milli == PKCS11H_COND_INFINITE) { ++ if ( ++ rv == CKR_OK && ++ pthread_cond_wait (&cond->cond, &cond->mut) ++ ) { ++ rv = CKR_FUNCTION_FAILED; ++ } ++ } ++ else { ++ struct timeval now; ++ struct timespec timeout; ++ ++ if ( ++ rv == CKR_OK && ++ gettimeofday (&now, NULL) ++ ) { ++ rv = CKR_FUNCTION_FAILED; ++ } ++ ++ if (rv == CKR_OK) { ++ timeout.tv_sec = now.tv_sec + milli/1000; ++ timeout.tv_nsec = now.tv_usec*1000 + milli%1000; ++ } ++ ++ if ( ++ rv == CKR_OK && ++ pthread_cond_timedwait (&cond->cond, &cond->mut, &timeout) ++ ) { ++ rv = CKR_FUNCTION_FAILED; ++ } ++ } ++#endif ++ return rv; ++} ++ ++static ++CK_RV ++_pkcs11h_threading_condFree ( ++ IN OUT pkcs11h_cond_t *const cond ++) { ++#if defined(WIN32) ++ CloseHandle (*cond); ++ *cond = NULL; ++#else ++ pthread_mutex_unlock (&cond->mut); ++#endif ++ return CKR_OK; ++} ++ ++#if defined(WIN32) ++static ++unsigned ++__stdcall ++__pkcs11h_thread_start (void *p) { ++ __pkcs11h_thread_data_t *_data = (__pkcs11h_thread_data_t *)p; ++ unsigned ret; ++ ++ ret = (unsigned)_data->start (_data->data); ++ ++ _pkcs11h_mem_free ((void *)&_data); ++ ++ return ret; ++} ++#else ++static ++void * ++__pkcs11h_thread_start (void *p) { ++ __pkcs11h_thread_data_t *_data = (__pkcs11h_thread_data_t *)p; ++ void *ret; ++ int i; ++ ++ /* ++ * Ignore any signal in ++ * this thread ++ */ ++ for (i=1;i<16;i++) { ++ signal (i, SIG_IGN); ++ } ++ ++ ret = _data->start (_data->data); ++ ++ _pkcs11h_mem_free ((void *)&_data); ++ ++ return ret; ++} ++#endif ++ ++static ++CK_RV ++_pkcs11h_threading_threadStart ( ++ OUT pkcs11h_thread_t * const thread, ++ IN pkcs11h_thread_start_t const start, ++ IN void * data ++) { ++ __pkcs11h_thread_data_t *_data = NULL; ++ CK_RV rv = CKR_OK; ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_mem_malloc ( ++ (void *)&_data, ++ sizeof (__pkcs11h_thread_data_t) ++ ); ++ } ++ ++ if (rv == CKR_OK) { ++ _data->start = start; ++ _data->data = data; ++ } ++ ++#if defined(WIN32) ++ { ++ unsigned tmp; ++ ++ if ( ++ rv == CKR_OK && ++ (*thread = (HANDLE)_beginthreadex ( ++ NULL, ++ 0, ++ __pkcs11h_thread_start, ++ _data, ++ 0, ++ &tmp ++ )) == NULL ++ ) { ++ rv = CKR_FUNCTION_FAILED; ++ } ++ } ++#else ++ if ( ++ rv == CKR_OK && ++ pthread_create (thread, NULL, __pkcs11h_thread_start, _data) ++ ) { ++ rv = CKR_FUNCTION_FAILED; ++ } ++#endif ++ return rv; ++} ++ ++static ++CK_RV ++_pkcs11h_threading_threadJoin ( ++ IN pkcs11h_thread_t * const thread ++) { ++#if defined(WIN32) ++ WaitForSingleObject (*thread, INFINITE); ++ CloseHandle (*thread); ++ *thread = NULL; ++#else ++ pthread_join (*thread, NULL); ++ *thread = 0l; ++#endif ++ return CKR_OK; ++} ++ ++#endif /* ENABLE_PKCS11H_THREADING */ ++ ++/*======================================================================* ++ * COMMON INTERNAL INTERFACE ++ *======================================================================*/ ++ ++static ++void ++_pkcs11h_util_fixupFixedString ( ++ OUT char * const target, /* MUST BE >= length+1 */ ++ IN const char * const source, ++ IN const size_t length /* FIXED STRING LENGTH */ ++) { ++ char *p; ++ ++ PKCS11H_ASSERT (source!=NULL); ++ PKCS11H_ASSERT (target!=NULL); ++ ++ p = target+length; ++ memmove (target, source, length); ++ *p = '\0'; ++ p--; ++ while (p >= target && *p == ' ') { ++ *p = '\0'; ++ p--; ++ } ++} ++ ++static ++CK_RV ++_pkcs11h_util_hexToBinary ( ++ OUT unsigned char * const target, ++ IN const char * const source, ++ IN OUT size_t * const p_target_size ++) { ++ size_t target_max_size; ++ const char *p; ++ char buf[3] = {'\0', '\0', '\0'}; ++ int i = 0; ++ ++ PKCS11H_ASSERT (source!=NULL); ++ PKCS11H_ASSERT (target!=NULL); ++ PKCS11H_ASSERT (p_target_size!=NULL); ++ ++ target_max_size = *p_target_size; ++ p = source; ++ *p_target_size = 0; ++ ++ while (*p != '\x0' && *p_target_size < target_max_size) { ++ if (isxdigit ((unsigned char)*p)) { ++ buf[i%2] = *p; ++ ++ if ((i%2) == 1) { ++ unsigned v; ++ if (sscanf (buf, "%x", &v) != 1) { ++ v = 0; ++ } ++ target[*p_target_size] = v & 0xff; ++ (*p_target_size)++; ++ } ++ ++ i++; ++ } ++ p++; ++ } ++ ++ if (*p != '\x0') { ++ return CKR_ATTRIBUTE_VALUE_INVALID; ++ } ++ else { ++ return CKR_OK; ++ } ++} ++ ++static ++CK_RV ++_pkcs11h_util_binaryToHex ( ++ OUT char * const target, ++ IN const size_t target_size, ++ IN const unsigned char * const source, ++ IN const size_t source_size ++) { ++ static const char *x = "0123456789ABCDEF"; ++ size_t i; ++ ++ PKCS11H_ASSERT (target!=NULL); ++ PKCS11H_ASSERT (source!=NULL); ++ ++ if (target_size < source_size * 2 + 1) { ++ return CKR_ATTRIBUTE_VALUE_INVALID; ++ } ++ ++ for (i=0;i>4]; ++ target[i*2+1] = x[(source[i]&0x0f)>>0]; ++ } ++ target[source_size*2] = '\x0'; ++ ++ return CKR_OK; ++} ++ ++CK_RV ++_pkcs11h_util_escapeString ( ++ IN OUT char * const target, ++ IN const char * const source, ++ IN size_t * const max, ++ IN const char * const invalid_chars ++) { ++ static const char *x = "0123456789ABCDEF"; ++ CK_RV rv = CKR_OK; ++ const char *s = source; ++ char *t = target; ++ size_t n = 0; ++ ++ /*PKCS11H_ASSERT (target!=NULL); Not required*/ ++ PKCS11H_ASSERT (source!=NULL); ++ PKCS11H_ASSERT (max!=NULL); ++ ++ while (rv == CKR_OK && *s != '\x0') { ++ ++ if (*s == '\\' || strchr (invalid_chars, *s) || !isgraph (*s)) { ++ if (t != NULL) { ++ if (n+4 > *max) { ++ rv = CKR_ATTRIBUTE_VALUE_INVALID; ++ } ++ else { ++ t[0] = '\\'; ++ t[1] = 'x'; ++ t[2] = x[(*s&0xf0)>>4]; ++ t[3] = x[(*s&0x0f)>>0]; ++ t+=4; ++ } ++ } ++ n+=4; ++ } ++ else { ++ if (t != NULL) { ++ if (n+1 > *max) { ++ rv = CKR_ATTRIBUTE_VALUE_INVALID; ++ } ++ else { ++ *t = *s; ++ t++; ++ } ++ } ++ n+=1; ++ } ++ ++ s++; ++ } ++ ++ if (t != NULL) { ++ if (n+1 > *max) { ++ rv = CKR_ATTRIBUTE_VALUE_INVALID; ++ } ++ else { ++ *t = '\x0'; ++ t++; ++ } ++ } ++ n++; ++ ++ *max = n; ++ ++ return rv; ++} ++ ++static ++CK_RV ++_pkcs11h_util_unescapeString ( ++ IN OUT char * const target, ++ IN const char * const source, ++ IN size_t * const max ++) { ++ CK_RV rv = CKR_OK; ++ const char *s = source; ++ char *t = target; ++ size_t n = 0; ++ ++ /*PKCS11H_ASSERT (target!=NULL); Not required*/ ++ PKCS11H_ASSERT (source!=NULL); ++ PKCS11H_ASSERT (max!=NULL); ++ ++ while (rv == CKR_OK && *s != '\x0') { ++ if (*s == '\\') { ++ if (t != NULL) { ++ if (n+1 > *max) { ++ rv = CKR_ATTRIBUTE_VALUE_INVALID; ++ } ++ else { ++ char b[3]; ++ unsigned u; ++ b[0] = s[2]; ++ b[1] = s[3]; ++ b[2] = '\x0'; ++ sscanf (b, "%08x", &u); ++ *t = u&0xff; ++ t++; ++ } ++ } ++ s+=4; ++ } ++ else { ++ if (t != NULL) { ++ if (n+1 > *max) { ++ rv = CKR_ATTRIBUTE_VALUE_INVALID; ++ } ++ else { ++ *t = *s; ++ t++; ++ } ++ } ++ s++; ++ } ++ ++ n+=1; ++ } ++ ++ if (t != NULL) { ++ if (n+1 > *max) { ++ rv = CKR_ATTRIBUTE_VALUE_INVALID; ++ } ++ else { ++ *t = '\x0'; ++ t++; ++ } ++ } ++ n++; ++ ++ *max = n; ++ ++ return rv; ++} ++ ++static ++void ++_pkcs11h_log ( ++ IN const unsigned flags, ++ IN const char * const format, ++ IN ... ++) { ++ va_list args; ++ ++ PKCS11H_ASSERT (format!=NULL); ++ ++ va_start (args, format); ++ ++ if ( ++ s_pkcs11h_data != NULL && ++ s_pkcs11h_data->initialized ++ ) { ++ if (PKCS11H_MSG_LEVEL_TEST (flags)) { ++ if (s_pkcs11h_data->hooks.log == NULL) { ++ _pkcs11h_hooks_default_log ( ++ NULL, ++ flags, ++ format, ++ args ++ ); ++ } ++ else { ++ s_pkcs11h_data->hooks.log ( ++ s_pkcs11h_data->hooks.log_data, ++ flags, ++ format, ++ args ++ ); ++ } ++ } ++ } ++ ++ va_end (args); ++} ++ ++static ++CK_RV ++_pkcs11h_session_getSlotList ( ++ IN const pkcs11h_provider_t provider, ++ IN const CK_BBOOL token_present, ++ OUT CK_SLOT_ID_PTR * const pSlotList, ++ OUT CK_ULONG_PTR pulCount ++) { ++ CK_SLOT_ID_PTR _slots = NULL; ++ CK_ULONG _slotnum = 0; ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (provider!=NULL); ++ PKCS11H_ASSERT (pSlotList!=NULL); ++ PKCS11H_ASSERT (pulCount!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_session_getSlotList entry provider=%p, token_present=%d, pSlotList=%p, pulCount=%p", ++ (void *)provider, ++ token_present, ++ (void *)pSlotList, ++ (void *)pulCount ++ ); ++ ++ *pSlotList = NULL; ++ *pulCount = 0; ++ ++ if ( ++ rv == CKR_OK && ++ !provider->enabled ++ ) { ++ rv = CKR_CRYPTOKI_NOT_INITIALIZED; ++ } ++ ++ if (rv == CKR_OK) { ++ rv = provider->f->C_GetSlotList ( ++ token_present, ++ NULL_PTR, ++ &_slotnum ++ ); ++ } ++ ++ if (rv == CKR_OK && _slotnum > 0) { ++ rv = _pkcs11h_mem_malloc ((void *)&_slots, _slotnum * sizeof (CK_SLOT_ID)); ++ } ++ ++ if (rv == CKR_OK && _slotnum > 0) { ++ rv = provider->f->C_GetSlotList ( ++ token_present, ++ _slots, ++ &_slotnum ++ ); ++ } ++ ++ if (rv == CKR_OK) { ++ *pSlotList = _slots; ++ _slots = NULL; ++ *pulCount = _slotnum; ++ } ++ ++ if (_slots != NULL) { ++ _pkcs11h_mem_free ((void *)&_slots); ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_session_getSlotList return rv=%ld-'%s' *pulCount=%ld", ++ rv, ++ pkcs11h_getMessage (rv), ++ *pulCount ++ ); ++ ++ return rv; ++} ++ ++static ++CK_RV ++_pkcs11h_session_getObjectAttributes ( ++ IN const pkcs11h_session_t session, ++ IN const CK_OBJECT_HANDLE object, ++ IN OUT const CK_ATTRIBUTE_PTR attrs, ++ IN const unsigned count ++) { ++ /* ++ * THREADING: ++ * session->mutex must be locked ++ */ ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (session!=NULL); ++ PKCS11H_ASSERT (attrs!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_session_getObjectAttributes entry session=%p, object=%ld, attrs=%p, count=%u", ++ (void *)session, ++ object, ++ (void *)attrs, ++ count ++ ); ++ ++ if ( ++ rv == CKR_OK && ++ (rv = session->provider->f->C_GetAttributeValue ( ++ session->session_handle, ++ object, ++ attrs, ++ count ++ )) == CKR_OK ++ ) { ++ unsigned i; ++ for (i=0;rv == CKR_OK && iprovider->f->C_GetAttributeValue ( ++ session->session_handle, ++ object, ++ attrs, ++ count ++ ); ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_session_getObjectAttributes return rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ return rv; ++} ++ ++static ++CK_RV ++_pkcs11h_session_freeObjectAttributes ( ++ IN OUT const CK_ATTRIBUTE_PTR attrs, ++ IN const unsigned count ++) { ++ unsigned i; ++ ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (attrs!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_session_freeObjectAttributes entry attrs=%p, count=%u", ++ (void *)attrs, ++ count ++ ); ++ ++ for (i=0;imutex must be locked ++ */ ++ PKCS11H_BOOL should_FindObjectsFinal = FALSE; ++ ++ CK_OBJECT_HANDLE *objects = NULL; ++ CK_ULONG objects_size = 0; ++ CK_OBJECT_HANDLE objects_buffer[100]; ++ CK_ULONG objects_found; ++ CK_OBJECT_HANDLE oLast = PKCS11H_INVALID_OBJECT_HANDLE; ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (session!=NULL); ++ PKCS11H_ASSERT (!(filter==NULL && filter_attrs!=0) || filter!=NULL); ++ PKCS11H_ASSERT (p_objects!=NULL); ++ PKCS11H_ASSERT (p_objects_found!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_session_findObjects entry session=%p, filter=%p, filter_attrs=%ld, p_objects=%p, p_objects_found=%p", ++ (void *)session, ++ (void *)filter, ++ filter_attrs, ++ (void *)p_objects, ++ (void *)p_objects_found ++ ); ++ ++ *p_objects = NULL; ++ *p_objects_found = 0; ++ ++ if ( ++ rv == CKR_OK && ++ (rv = session->provider->f->C_FindObjectsInit ( ++ session->session_handle, ++ (CK_ATTRIBUTE *)filter, ++ filter_attrs ++ )) == CKR_OK ++ ) { ++ should_FindObjectsFinal = TRUE; ++ } ++ ++ while ( ++ rv == CKR_OK && ++ (rv = session->provider->f->C_FindObjects ( ++ session->session_handle, ++ objects_buffer, ++ sizeof (objects_buffer) / sizeof (CK_OBJECT_HANDLE), ++ &objects_found ++ )) == CKR_OK && ++ objects_found > 0 ++ ) { ++ CK_OBJECT_HANDLE *temp = NULL; ++ ++ /* ++ * Begin workaround ++ * ++ * Workaround iKey bug ++ * It returns the same objects over and over ++ */ ++ if (oLast == objects_buffer[0]) { ++ PKCS11H_LOG ( ++ PKCS11H_LOG_WARN, ++ "PKCS#11: Bad PKCS#11 C_FindObjects implementation detected, workaround applied" ++ ); ++ break; ++ } ++ oLast = objects_buffer[0]; ++ /* End workaround */ ++ ++ if ( ++ (rv = _pkcs11h_mem_malloc ( ++ (void *)&temp, ++ (objects_size+objects_found) * sizeof (CK_OBJECT_HANDLE) ++ )) == CKR_OK ++ ) { ++ if (objects != NULL) { ++ memmove ( ++ temp, ++ objects, ++ objects_size * sizeof (CK_OBJECT_HANDLE) ++ ); ++ } ++ memmove ( ++ temp + objects_size, ++ objects_buffer, ++ objects_found * sizeof (CK_OBJECT_HANDLE) ++ ); ++ } ++ ++ if (objects != NULL) { ++ _pkcs11h_mem_free ((void *)&objects); ++ objects = NULL; ++ } ++ ++ if (rv == CKR_OK) { ++ objects = temp; ++ objects_size += objects_found; ++ temp = NULL; ++ } ++ ++ if (temp != NULL) { ++ _pkcs11h_mem_free ((void *)&temp); ++ temp = NULL; ++ } ++ } ++ ++ if (should_FindObjectsFinal) { ++ session->provider->f->C_FindObjectsFinal ( ++ session->session_handle ++ ); ++ should_FindObjectsFinal = FALSE; ++ } ++ ++ if (rv == CKR_OK) { ++ *p_objects = objects; ++ *p_objects_found = objects_size; ++ objects = NULL; ++ objects_size = 0; ++ } ++ ++ if (objects != NULL) { ++ _pkcs11h_mem_free ((void *)&objects); ++ objects = NULL; ++ objects_size = 0; ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_session_findObjects return rv=%ld-'%s', *p_objects_found=%ld", ++ rv, ++ pkcs11h_getMessage (rv), ++ *p_objects_found ++ ); ++ ++ return rv; ++} ++ ++static ++CK_RV ++_pkcs11h_token_getTokenId ( ++ IN const CK_TOKEN_INFO_PTR info, ++ OUT pkcs11h_token_id_t * const p_token_id ++) { ++ pkcs11h_token_id_t token_id; ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (info!=NULL); ++ PKCS11H_ASSERT (p_token_id!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_token_getTokenId entry p_token_id=%p", ++ (void *)p_token_id ++ ); ++ ++ *p_token_id = NULL; ++ ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_token_newTokenId (&token_id)) == CKR_OK ++ ) { ++ _pkcs11h_util_fixupFixedString ( ++ token_id->label, ++ (char *)info->label, ++ sizeof (info->label) ++ ); ++ _pkcs11h_util_fixupFixedString ( ++ token_id->manufacturerID, ++ (char *)info->manufacturerID, ++ sizeof (info->manufacturerID) ++ ); ++ _pkcs11h_util_fixupFixedString ( ++ token_id->model, ++ (char *)info->model, ++ sizeof (info->model) ++ ); ++ _pkcs11h_util_fixupFixedString ( ++ token_id->serialNumber, ++ (char *)info->serialNumber, ++ sizeof (info->serialNumber) ++ ); ++ strncpy ( ++ token_id->display, ++ token_id->label, ++ sizeof (token_id->display) ++ ); ++ } ++ ++ if (rv == CKR_OK) { ++ *p_token_id = token_id; ++ token_id = NULL; ++ } ++ ++ if (token_id != NULL) { ++ _pkcs11h_mem_free ((void *)&token_id); ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_token_getTokenId return rv=%ld-'%s', *p_token_id=%p", ++ rv, ++ pkcs11h_getMessage (rv), ++ (void *)*p_token_id ++ ); ++ ++ return rv; ++} ++ ++static ++CK_RV ++_pkcs11h_token_newTokenId ( ++ OUT pkcs11h_token_id_t * const p_token_id ++) { ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ PKCS11H_ASSERT (p_token_id!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_token_newTokenId entry p_token_id=%p", ++ (void *)p_token_id ++ ); ++ ++ *p_token_id = NULL; ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_mem_malloc ((void *)p_token_id, sizeof (struct pkcs11h_token_id_s)); ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_token_newTokenId return rv=%ld-'%s', *p_token_id=%p", ++ rv, ++ pkcs11h_getMessage (rv), ++ (void *)*p_token_id ++ ); ++ ++ return rv; ++} ++ ++static ++CK_RV ++_pkcs11h_session_getSessionByTokenId ( ++ IN const pkcs11h_token_id_t token_id, ++ OUT pkcs11h_session_t * const p_session ++) { ++#if defined(ENABLE_PKCS11H_THREADING) ++ PKCS11H_BOOL mutex_locked = FALSE; ++#endif ++ pkcs11h_session_t session = NULL; ++ PKCS11H_BOOL is_new_session = FALSE; ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (token_id!=NULL); ++ PKCS11H_ASSERT (p_session!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_session_getSessionByTokenId entry token_id=%p, p_session=%p", ++ (void *)token_id, ++ (void *)p_session ++ ); ++ ++ *p_session = NULL; ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_threading_mutexLock (&s_pkcs11h_data->mutexes.session)) == CKR_OK ++ ) { ++ mutex_locked = TRUE; ++ } ++#endif ++ ++ if (rv == CKR_OK) { ++ pkcs11h_session_t current_session; ++ ++ for ( ++ current_session = s_pkcs11h_data->sessions; ++ current_session != NULL && session == NULL; ++ current_session = current_session->next ++ ) { ++ if ( ++ pkcs11h_token_sameTokenId ( ++ current_session->token_id, ++ token_id ++ ) ++ ) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Using cached session" ++ ); ++ session = current_session; ++ session->reference_count++; ++ } ++ } ++ } ++ ++ if ( ++ rv == CKR_OK && ++ session == NULL ++ ) { ++ is_new_session = TRUE; ++ } ++ ++ if (is_new_session) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Creating a new session" ++ ); ++ ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_mem_malloc ((void *)&session, sizeof (struct pkcs11h_session_s))) == CKR_OK ++ ) { ++ session->reference_count = 1; ++ session->session_handle = PKCS11H_INVALID_SESSION_HANDLE; ++ ++ session->pin_cache_period = s_pkcs11h_data->pin_cache_period; ++ ++ } ++ ++ if (rv == CKR_OK) { ++ rv = pkcs11h_token_duplicateTokenId ( ++ &session->token_id, ++ token_id ++ ); ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_threading_mutexInit (&session->mutex); ++ } ++#endif ++ ++ if (rv == CKR_OK) { ++ session->valid = TRUE; ++ session->next = s_pkcs11h_data->sessions; ++ s_pkcs11h_data->sessions = session; ++ } ++ else { ++#if defined(ENABLE_PKCS11H_THREADING) ++ _pkcs11h_threading_mutexFree (&session->mutex); ++#endif ++ _pkcs11h_mem_free ((void *)&session); ++ } ++ } ++ ++ if (rv == CKR_OK) { ++ *p_session = session; ++ session = NULL; ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if (mutex_locked) { ++ _pkcs11h_threading_mutexRelease (&s_pkcs11h_data->mutexes.session); ++ mutex_locked = FALSE; ++ } ++#endif ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_session_getSessionByTokenId return rv=%ld-'%s', *p_session=%p", ++ rv, ++ pkcs11h_getMessage (rv), ++ (void *)*p_session ++ ); ++ ++ return rv; ++} ++ ++static ++CK_RV ++_pkcs11h_session_release ( ++ IN const pkcs11h_session_t session ++) { ++#if defined(ENABLE_PKCS11H_THREADING) ++ PKCS11H_BOOL mutex_locked = FALSE; ++#endif ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (session!=NULL); ++ PKCS11H_ASSERT (session->reference_count>=0); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_session_release entry session=%p", ++ (void *)session ++ ); ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_threading_mutexLock (&session->mutex)) == CKR_OK ++ ) { ++ mutex_locked = TRUE; ++ } ++#endif ++ ++ /* ++ * Never logout for now ++ */ ++ if (rv == CKR_OK) { ++ if (session->reference_count > 0) { ++ session->reference_count--; ++ } ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if (mutex_locked) { ++ _pkcs11h_threading_mutexRelease (&session->mutex); ++ mutex_locked = FALSE; ++ } ++#endif ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_session_release return rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ return rv; ++} ++ ++static ++CK_RV ++_pkcs11h_session_reset ( ++ IN const pkcs11h_session_t session, ++ IN void * const user_data, ++ IN const unsigned mask_prompt, ++ OUT CK_SLOT_ID * const p_slot ++) { ++ PKCS11H_BOOL found = FALSE; ++ ++ CK_RV rv = CKR_OK; ++ ++ unsigned nRetry = 0; ++ ++ PKCS11H_ASSERT (session!=NULL); ++ /*PKCS11H_ASSERT (user_data) NOT NEEDED */ ++ PKCS11H_ASSERT (p_slot!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_session_reset entry session=%p, user_data=%p, mask_prompt=%08x, p_slot=%p", ++ (void *)session, ++ user_data, ++ mask_prompt, ++ (void *)p_slot ++ ); ++ ++ *p_slot = PKCS11H_INVALID_SLOT_ID; ++ ++ while ( ++ rv == CKR_OK && ++ !found ++ ) { ++ pkcs11h_provider_t current_provider = NULL; ++ ++ for ( ++ current_provider = s_pkcs11h_data->providers; ++ ( ++ rv == CKR_OK && ++ current_provider != NULL && ++ !found ++ ); ++ current_provider = current_provider->next ++ ) { ++ CK_SLOT_ID_PTR slots = NULL; ++ CK_ULONG slotnum; ++ CK_SLOT_ID slot_index; ++ ++ /* ++ * Skip all other providers, ++ * if one was set in the past ++ */ ++ if ( ++ session->provider != NULL && ++ session->provider != current_provider ++ ) { ++ rv = CKR_CANCEL; ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_getSlotList ( ++ current_provider, ++ CK_TRUE, ++ &slots, ++ &slotnum ++ ); ++ } ++ ++ for ( ++ slot_index=0; ++ ( ++ slot_index < slotnum && ++ rv == CKR_OK && ++ !found ++ ); ++ slot_index++ ++ ) { ++ pkcs11h_token_id_t token_id = NULL; ++ CK_TOKEN_INFO info; ++ ++ if (rv == CKR_OK) { ++ rv = current_provider->f->C_GetTokenInfo ( ++ slots[slot_index], ++ &info ++ ); ++ } ++ ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_token_getTokenId ( ++ &info, ++ &token_id ++ )) == CKR_OK && ++ pkcs11h_token_sameTokenId ( ++ session->token_id, ++ token_id ++ ) ++ ) { ++ found = TRUE; ++ *p_slot = slots[slot_index]; ++ if (session->provider == NULL) { ++ session->provider = current_provider; ++ session->allow_protected_auth_supported = (info.flags & CKF_PROTECTED_AUTHENTICATION_PATH) != 0; ++ } ++ } ++ ++ if (rv != CKR_OK) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Cannot get token information for provider '%s' slot %ld rv=%ld-'%s'", ++ current_provider->manufacturerID, ++ slots[slot_index], ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ /* ++ * Ignore error ++ */ ++ rv = CKR_OK; ++ } ++ ++ if (token_id != NULL) { ++ pkcs11h_token_freeTokenId (token_id); ++ } ++ } ++ ++ if (rv != CKR_OK) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Cannot get slot list for provider '%s' rv=%ld-'%s'", ++ current_provider->manufacturerID, ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ /* ++ * Ignore error ++ */ ++ rv = CKR_OK; ++ } ++ ++ if (slots != NULL) { ++ _pkcs11h_mem_free ((void *)&slots); ++ slots = NULL; ++ } ++ } ++ ++ if (rv == CKR_OK && !found && (mask_prompt & PKCS11H_PROMPT_MAST_ALLOW_CARD_PROMPT) == 0) { ++ rv = CKR_TOKEN_NOT_PRESENT; ++ } ++ ++ if ( ++ rv == CKR_OK && ++ !found ++ ) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Calling token_prompt hook for '%s'", ++ session->token_id->display ++ ); ++ ++ if ( ++ !s_pkcs11h_data->hooks.token_prompt ( ++ s_pkcs11h_data->hooks.token_prompt_data, ++ user_data, ++ session->token_id, ++ nRetry++ ++ ) ++ ) { ++ rv = CKR_CANCEL; ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: token_prompt returned %ld", ++ rv ++ ); ++ } ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_session_reset return rv=%ld-'%s', *p_slot=%ld", ++ rv, ++ pkcs11h_getMessage (rv), ++ *p_slot ++ ); ++ ++ return rv; ++} ++ ++static ++CK_RV ++_pkcs11h_session_getObjectById ( ++ IN const pkcs11h_session_t session, ++ IN const CK_OBJECT_CLASS class, ++ IN const CK_BYTE_PTR id, ++ IN const size_t id_size, ++ OUT CK_OBJECT_HANDLE * const p_handle ++) { ++ /* ++ * THREADING: ++ * session->mutex must be locked ++ */ ++ CK_ATTRIBUTE filter[] = { ++ {CKA_CLASS, (void *)&class, sizeof (class)}, ++ {CKA_ID, (void *)id, id_size} ++ }; ++ CK_OBJECT_HANDLE *objects = NULL; ++ CK_ULONG objects_found = 0; ++ CK_RV rv = CKR_OK; ++ ++ /*PKCS11H_ASSERT (session!=NULL); NOT NEEDED*/ ++ PKCS11H_ASSERT (id!=NULL); ++ PKCS11H_ASSERT (p_handle!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_session_getObjectById entry session=%p, class=%ld, id=%p, id_size=%u, p_handle=%p", ++ (void *)session, ++ class, ++ id, ++ id_size, ++ (void *)p_handle ++ ); ++ ++ *p_handle = PKCS11H_INVALID_OBJECT_HANDLE; ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_validate (session); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_findObjects ( ++ session, ++ filter, ++ sizeof (filter) / sizeof (CK_ATTRIBUTE), ++ &objects, ++ &objects_found ++ ); ++ } ++ ++ if ( ++ rv == CKR_OK && ++ objects_found == 0 ++ ) { ++ rv = CKR_FUNCTION_REJECTED; ++ } ++ ++ if (rv == CKR_OK) { ++ *p_handle = objects[0]; ++ } ++ ++ if (objects != NULL) { ++ _pkcs11h_mem_free ((void *)&objects); ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_session_getObjectById return rv=%ld-'%s', *p_handle=%p", ++ rv, ++ pkcs11h_getMessage (rv), ++ (void *)*p_handle ++ ); ++ ++ return rv; ++} ++ ++static ++CK_RV ++_pkcs11h_session_validate ( ++ IN const pkcs11h_session_t session ++) { ++ CK_RV rv = CKR_OK; ++ ++ /*PKCS11H_ASSERT (session!=NULL); NOT NEEDED*/ ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_session_validate entry session=%p", ++ (void *)session ++ ); ++ ++ if ( ++ rv == CKR_OK && ++ session == NULL ++ ) { ++ rv = CKR_SESSION_HANDLE_INVALID; ++ } ++ ++ if ( ++ rv == CKR_OK && ++ ( ++ session->provider == NULL || ++ !session->provider->enabled || ++ session->session_handle == PKCS11H_INVALID_SESSION_HANDLE ++ ) ++ ) { ++ rv = CKR_SESSION_HANDLE_INVALID; ++ } ++ ++ if ( ++ rv == CKR_OK && ++ session->pin_expire_time != (time_t)0 && ++ session->pin_expire_time < PKCS11H_TIME (NULL) ++ ) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Forcing logout due to pin timeout" ++ ); ++ _pkcs11h_session_logout (session); ++ rv = CKR_SESSION_HANDLE_INVALID; ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_session_validate return rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ return rv; ++} ++ ++static ++CK_RV ++_pkcs11h_session_touch ( ++ IN const pkcs11h_session_t session ++) { ++ /* ++ * THREADING: ++ * session->mutex must be locked ++ */ ++ PKCS11H_ASSERT (session!=NULL); ++ ++ if (session->pin_cache_period == PKCS11H_PIN_CACHE_INFINITE) { ++ session->pin_expire_time = 0; ++ } ++ else { ++ session->pin_expire_time = ( ++ PKCS11H_TIME (NULL) + ++ (time_t)session->pin_cache_period ++ ); ++ } ++ ++ return CKR_OK; ++} ++ ++CK_RV ++pkcs11h_token_login ( ++ IN const pkcs11h_token_id_t token_id, ++ IN const PKCS11H_BOOL readonly, ++ IN const char * const pin ++) { ++#if defined(ENABLE_PKCS11H_THREADING) ++ PKCS11H_BOOL mutex_locked = FALSE; ++#endif ++ CK_SLOT_ID slot = PKCS11H_INVALID_SLOT_ID; ++ CK_ULONG pin_size = 0; ++ CK_RV rv = CKR_OK; ++ ++ pkcs11h_session_t session = NULL; ++ ++ PKCS11H_ASSERT (token_id!=NULL); ++ /*PKCS11H_ASSERT (pin!=NULL); NOT NEEDED*/ ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_token_login entry token_id=%p, readonly=%d\n", ++ (void *)token_id, ++ readonly ? 1 : 0 ++ ); ++ ++ if (pin != NULL) { ++ pin_size = strlen (pin); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_getSessionByTokenId ( ++ token_id, ++ &session ++ ); ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_threading_mutexLock (&session->mutex)) == CKR_OK ++ ) { ++ mutex_locked = TRUE; ++ } ++#endif ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_logout (session); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_reset (session, NULL, 0, &slot); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_touch (session); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = session->provider->f->C_OpenSession ( ++ slot, ++ ( ++ CKF_SERIAL_SESSION | ++ (readonly ? 0 : CKF_RW_SESSION) ++ ), ++ NULL_PTR, ++ NULL_PTR, ++ &session->session_handle ++ ); ++ } ++ ++ if ( ++ rv == CKR_OK && ++ (rv = session->provider->f->C_Login ( ++ session->session_handle, ++ CKU_USER, ++ (CK_UTF8CHAR_PTR)pin, ++ pin_size ++ )) != CKR_OK ++ ) { ++ if (rv == CKR_USER_ALREADY_LOGGED_IN) { ++ rv = CKR_OK; ++ } ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if (mutex_locked) { ++ _pkcs11h_threading_mutexRelease (&session->mutex); ++ mutex_locked = FALSE; ++ } ++#endif ++ ++ if (session != NULL) { ++ _pkcs11h_session_release (session); ++ session = NULL; ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_token_login return rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ return rv; ++} ++ ++static ++CK_RV ++_pkcs11h_session_login ( ++ IN const pkcs11h_session_t session, ++ IN const PKCS11H_BOOL is_publicOnly, ++ IN const PKCS11H_BOOL readonly, ++ IN void * const user_data, ++ IN const unsigned mask_prompt ++) { ++ /* ++ * THREADING: ++ * session->mutex must be locked ++ */ ++ CK_SLOT_ID slot = PKCS11H_INVALID_SLOT_ID; ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (session!=NULL); ++ /*PKCS11H_ASSERT (user_data) NOT NEEDED */ ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_session_login entry session=%p, is_publicOnly=%d, readonly=%d, user_data=%p, mask_prompt=%08x", ++ (void *)session, ++ is_publicOnly ? 1 : 0, ++ readonly ? 1 : 0, ++ user_data, ++ mask_prompt ++ ); ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_logout (session); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_reset (session, user_data, mask_prompt, &slot); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = session->provider->f->C_OpenSession ( ++ slot, ++ ( ++ CKF_SERIAL_SESSION | ++ (readonly ? 0 : CKF_RW_SESSION) ++ ), ++ NULL_PTR, ++ NULL_PTR, ++ &session->session_handle ++ ); ++ } ++ ++ if ( ++ rv == CKR_OK && ++ ( ++ !is_publicOnly || ++ session->provider->cert_is_private ++ ) ++ ) { ++ PKCS11H_BOOL login_succeeded = FALSE; ++ unsigned nRetryCount = 0; ++ ++ if ((mask_prompt & PKCS11H_PROMPT_MASK_ALLOW_PIN_PROMPT) == 0) { ++ rv = CKR_USER_NOT_LOGGED_IN; ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Calling pin_prompt hook denied because of prompt mask" ++ ); ++ } ++ ++ while ( ++ rv == CKR_OK && ++ !login_succeeded && ++ nRetryCount < s_pkcs11h_data->max_retries ++ ) { ++ CK_UTF8CHAR_PTR utfPIN = NULL; ++ CK_ULONG lPINLength = 0; ++ char pin[1024]; ++ ++ if ( ++ rv == CKR_OK && ++ !( ++ s_pkcs11h_data->allow_protected_auth && ++ session->provider->allow_protected_auth && ++ session->allow_protected_auth_supported ++ ) ++ ) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Calling pin_prompt hook for '%s'", ++ session->token_id->display ++ ); ++ ++ if ( ++ !s_pkcs11h_data->hooks.pin_prompt ( ++ s_pkcs11h_data->hooks.pin_prompt_data, ++ user_data, ++ session->token_id, ++ nRetryCount, ++ pin, ++ sizeof (pin) ++ ) ++ ) { ++ rv = CKR_CANCEL; ++ } ++ else { ++ utfPIN = (CK_UTF8CHAR_PTR)pin; ++ lPINLength = strlen (pin); ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: pin_prompt hook return rv=%ld", ++ rv ++ ); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_touch (session); ++ } ++ ++ if ( ++ rv == CKR_OK && ++ (rv = session->provider->f->C_Login ( ++ session->session_handle, ++ CKU_USER, ++ utfPIN, ++ lPINLength ++ )) != CKR_OK ++ ) { ++ if (rv == CKR_USER_ALREADY_LOGGED_IN) { ++ rv = CKR_OK; ++ } ++ } ++ ++ /* ++ * Clean PIN buffer ++ */ ++ memset (pin, 0, sizeof (pin)); ++ ++ if (rv == CKR_OK) { ++ login_succeeded = TRUE; ++ } ++ else if ( ++ rv == CKR_PIN_INCORRECT || ++ rv == CKR_PIN_INVALID ++ ) { ++ /* ++ * Ignore these errors ++ * so retry can be performed ++ */ ++ rv = CKR_OK; ++ } ++ ++ nRetryCount++; ++ } ++ ++ /* ++ * Retry limit ++ */ ++ if (!login_succeeded && rv == CKR_OK) { ++ rv = CKR_PIN_INCORRECT; ++ } ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_session_login return rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ return rv; ++} ++ ++static ++CK_RV ++_pkcs11h_session_logout ( ++ IN const pkcs11h_session_t session ++) { ++ /* ++ * THREADING: ++ * session->mutex must be locked ++ */ ++ /*PKCS11H_ASSERT (session!=NULL); NOT NEEDED*/ ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_session_logout entry session=%p", ++ (void *)session ++ ); ++ ++ if ( ++ session != NULL && ++ session->session_handle != PKCS11H_INVALID_SESSION_HANDLE ++ ) { ++ CK_RV rv = CKR_OK; ++ ++ if (rv == CKR_OK) { ++ if (session->provider != NULL) { ++ session->provider->f->C_Logout (session->session_handle); ++ session->provider->f->C_CloseSession (session->session_handle); ++ } ++ session->session_handle = PKCS11H_INVALID_SESSION_HANDLE; ++ } ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_session_logout return" ++ ); ++ ++ return CKR_OK; ++} ++ ++static ++void ++_pkcs11h_hooks_default_log ( ++ IN void * const global_data, ++ IN const unsigned flags, ++ IN const char * const format, ++ IN va_list args ++) { ++ (void)global_data; ++ (void)flags; ++ (void)format; ++ (void)args; ++} ++ ++static ++PKCS11H_BOOL ++_pkcs11h_hooks_default_token_prompt ( ++ IN void * const global_data, ++ IN void * const user_data, ++ IN const pkcs11h_token_id_t token, ++ IN const unsigned retry ++) { ++ /*PKCS11H_ASSERT (global_data) NOT NEEDED */ ++ /*PKCS11H_ASSERT (user_data) NOT NEEDED */ ++ PKCS11H_ASSERT (token!=NULL); ++ ++ (void)global_data; ++ (void)user_data; ++ (void)retry; ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_hooks_default_token_prompt global_data=%p, user_data=%p, display='%s'", ++ global_data, ++ user_data, ++ token->display ++ ); ++ ++ return FALSE; ++} ++ ++static ++PKCS11H_BOOL ++_pkcs11h_hooks_default_pin_prompt ( ++ IN void * const global_data, ++ IN void * const user_data, ++ IN const pkcs11h_token_id_t token, ++ IN const unsigned retry, ++ OUT char * const pin, ++ IN const size_t pin_max ++) { ++ /*PKCS11H_ASSERT (global_data) NOT NEEDED */ ++ /*PKCS11H_ASSERT (user_data) NOT NEEDED */ ++ PKCS11H_ASSERT (token!=NULL); ++ ++ (void)global_data; ++ (void)user_data; ++ (void)retry; ++ (void)pin; ++ (void)pin_max; ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_hooks_default_pin_prompt global_data=%p, user_data=%p, display='%s'", ++ global_data, ++ user_data, ++ token->display ++ ); ++ ++ return FALSE; ++} ++ ++#if !defined(WIN32) ++#if defined(ENABLE_PKCS11H_THREADING) ++ ++static ++void ++__pkcs11h_threading_atfork_prepare () { ++ __pkcs1h_threading_mutexLockAll (); ++} ++static ++void ++__pkcs11h_threading_atfork_parent () { ++ __pkcs1h_threading_mutexReleaseAll (); ++} ++static ++void ++__pkcs11h_threading_atfork_child () { ++ __pkcs1h_threading_mutexReleaseAll (); ++ _pkcs11h_forkFixup (); ++} ++ ++#endif /* ENABLE_PKCS11H_THREADING */ ++ ++static ++CK_RV ++_pkcs11h_forkFixup () { ++#if defined(ENABLE_PKCS11H_THREADING) ++ PKCS11H_BOOL mutex_locked = FALSE; ++#endif ++ pid_t mypid = getpid (); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_forkFixup entry pid=%d", ++ mypid ++ ); ++ ++ if (s_pkcs11h_data != NULL && s_pkcs11h_data->initialized) { ++ pkcs11h_provider_t current; ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if (_pkcs11h_threading_mutexLock (&s_pkcs11h_data->mutexes.global) == CKR_OK) { ++ mutex_locked = TRUE; ++ } ++#endif ++ ++ for ( ++ current = s_pkcs11h_data->providers; ++ current != NULL; ++ current = current->next ++ ) { ++ if (current->enabled) { ++ current->f->C_Initialize (NULL); ++ } ++ ++#if defined(ENABLE_PKCS11H_SLOTEVENT) ++ /* ++ * After fork we have no threads... ++ * So just initialized. ++ */ ++ if (s_pkcs11h_data->slotevent.initialized) { ++ s_pkcs11h_data->slotevent.initialized = FALSE; ++ _pkcs11h_slotevent_init (); ++ } ++#endif ++ } ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if (mutex_locked) { ++ _pkcs11h_threading_mutexRelease (&s_pkcs11h_data->mutexes.global); ++ mutex_locked = FALSE; ++ } ++#endif ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_forkFixup return" ++ ); ++ ++ return CKR_OK; ++} ++ ++#endif /* !WIN32 */ ++ ++#if defined(ENABLE_PKCS11H_TOKEN) ++/*======================================================================* ++ * TOKEN INTERFACE ++ *======================================================================*/ ++ ++CK_RV ++pkcs11h_token_ensureAccess ( ++ IN const pkcs11h_token_id_t token_id, ++ IN void * const user_data, ++ IN const unsigned mask_prompt ++) { ++#if defined(ENABLE_PKCS11H_THREADING) ++ PKCS11H_BOOL mutex_locked = FALSE; ++#endif ++ pkcs11h_session_t session = NULL; ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ PKCS11H_ASSERT (token_id!=NULL); ++ /*PKCS11H_ASSERT (user_data) NOT NEEDED */ ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_token_ensureAccess entry token_id=%p, user_data=%p, mask_prompt=%08x", ++ (void *)token_id, ++ user_data, ++ mask_prompt ++ ); ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_getSessionByTokenId ( ++ token_id, ++ &session ++ ); ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_threading_mutexLock (&session->mutex)) == CKR_OK ++ ) { ++ mutex_locked = TRUE; ++ } ++#endif ++ ++ if (rv == CKR_OK) { ++ CK_SLOT_ID slot; ++ ++ rv = _pkcs11h_session_reset ( ++ session, ++ user_data, ++ mask_prompt, ++ &slot ++ ); ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if (mutex_locked) { ++ _pkcs11h_threading_mutexRelease (&session->mutex); ++ mutex_locked = FALSE; ++ } ++#endif ++ ++ if (session != NULL) { ++ _pkcs11h_session_release (session); ++ session = NULL; ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_token_ensureAccess return rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ return rv; ++} ++ ++#endif /* ENABLE_PKCS11H_TOKEN */ ++ ++#if defined(ENABLE_PKCS11H_DATA) ++/*======================================================================* ++ * DATA INTERFACE ++ *======================================================================*/ ++ ++static ++CK_RV ++_pkcs11h_data_getObject ( ++ IN const pkcs11h_session_t session, ++ IN const char * const application, ++ IN const char * const label, ++ OUT CK_OBJECT_HANDLE * const p_handle ++) { ++ CK_OBJECT_CLASS class = CKO_DATA; ++ CK_ATTRIBUTE filter[] = { ++ {CKA_CLASS, (void *)&class, sizeof (class)}, ++ {CKA_APPLICATION, (void *)application, application == NULL ? 0 : strlen (application)}, ++ {CKA_LABEL, (void *)label, label == NULL ? 0 : strlen (label)} ++ }; ++ CK_OBJECT_HANDLE *objects = NULL; ++ CK_ULONG objects_found = 0; ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (session!=NULL); ++ PKCS11H_ASSERT (application!=NULL); ++ PKCS11H_ASSERT (label!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_data_getObject entry session=%p, application='%s', label='%s', p_handle=%p", ++ (void *)session, ++ application, ++ label, ++ (void *)p_handle ++ ); ++ ++ *p_handle = PKCS11H_INVALID_OBJECT_HANDLE; ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_validate (session); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_findObjects ( ++ session, ++ filter, ++ sizeof (filter) / sizeof (CK_ATTRIBUTE), ++ &objects, ++ &objects_found ++ ); ++ } ++ ++ if ( ++ rv == CKR_OK && ++ objects_found == 0 ++ ) { ++ rv = CKR_FUNCTION_REJECTED; ++ } ++ ++ if (rv == CKR_OK) { ++ *p_handle = objects[0]; ++ } ++ ++ if (objects != NULL) { ++ _pkcs11h_mem_free ((void *)&objects); ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_data_getObject return rv=%ld-'%s', *p_handle=%p", ++ rv, ++ pkcs11h_getMessage (rv), ++ (void *)*p_handle ++ ); ++ ++ return rv; ++} ++ ++CK_RV ++pkcs11h_data_get ( ++ IN const pkcs11h_token_id_t token_id, ++ IN const PKCS11H_BOOL is_public, ++ IN const char * const application, ++ IN const char * const label, ++ IN void * const user_data, ++ IN const unsigned mask_prompt, ++ OUT unsigned char * const blob, ++ IN OUT size_t * const p_blob_size ++) { ++ CK_ATTRIBUTE attrs[] = { ++ {CKA_VALUE, NULL, 0} ++ }; ++ CK_OBJECT_HANDLE handle = PKCS11H_INVALID_OBJECT_HANDLE; ++ CK_RV rv = CKR_OK; ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ PKCS11H_BOOL mutex_locked = FALSE; ++#endif ++ pkcs11h_session_t session = NULL; ++ PKCS11H_BOOL op_succeed = FALSE; ++ PKCS11H_BOOL login_retry = FALSE; ++ size_t blob_size_max = 0; ++ ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ PKCS11H_ASSERT (token_id!=NULL); ++ PKCS11H_ASSERT (application!=NULL); ++ PKCS11H_ASSERT (label!=NULL); ++ /*PKCS11H_ASSERT (user_data) NOT NEEDED */ ++ /*PKCS11H_ASSERT (blob!=NULL); NOT NEEDED*/ ++ PKCS11H_ASSERT (p_blob_size!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_data_get entry token_id=%p, application='%s', label='%s', user_data=%p, mask_prompt=%08x, blob=%p, *p_blob_size=%u", ++ (void *)token_id, ++ application, ++ label, ++ user_data, ++ mask_prompt, ++ blob, ++ blob != NULL ? *p_blob_size : 0 ++ ); ++ ++ if (blob != NULL) { ++ blob_size_max = *p_blob_size; ++ } ++ *p_blob_size = 0; ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_getSessionByTokenId ( ++ token_id, ++ &session ++ ); ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_threading_mutexLock (&session->mutex)) == CKR_OK ++ ) { ++ mutex_locked = TRUE; ++ } ++#endif ++ ++ while (rv == CKR_OK && !op_succeed) { ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_validate (session); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_data_getObject ( ++ session, ++ application, ++ label, ++ &handle ++ ); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_getObjectAttributes ( ++ session, ++ handle, ++ attrs, ++ sizeof (attrs)/sizeof (CK_ATTRIBUTE) ++ ); ++ } ++ ++ if (rv == CKR_OK) { ++ op_succeed = TRUE; ++ } ++ else { ++ if (!login_retry) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Read data object failed rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ login_retry = TRUE; ++ rv = _pkcs11h_session_login ( ++ session, ++ is_public, ++ TRUE, ++ user_data, ++ mask_prompt ++ ); ++ } ++ } ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if (mutex_locked) { ++ _pkcs11h_threading_mutexRelease (&session->mutex); ++ mutex_locked = FALSE; ++ } ++#endif ++ ++ if (rv == CKR_OK) { ++ *p_blob_size = attrs[0].ulValueLen; ++ } ++ ++ if (rv == CKR_OK) { ++ if (blob != NULL) { ++ if (*p_blob_size > blob_size_max) { ++ rv = CKR_BUFFER_TOO_SMALL; ++ } ++ else { ++ memmove (blob, attrs[0].pValue, *p_blob_size); ++ } ++ } ++ } ++ ++ _pkcs11h_session_freeObjectAttributes ( ++ attrs, ++ sizeof (attrs)/sizeof (CK_ATTRIBUTE) ++ ); ++ ++ if (session != NULL) { ++ _pkcs11h_session_release (session); ++ session = NULL; ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_data_get return rv=%ld-'%s', *p_blob_size=%u", ++ rv, ++ pkcs11h_getMessage (rv), ++ *p_blob_size ++ ); ++ ++ return rv; ++} ++ ++CK_RV ++pkcs11h_data_put ( ++ IN const pkcs11h_token_id_t token_id, ++ IN const PKCS11H_BOOL is_public, ++ IN const char * const application, ++ IN const char * const label, ++ IN void * const user_data, ++ IN const unsigned mask_prompt, ++ OUT unsigned char * const blob, ++ IN const size_t blob_size ++) { ++ CK_OBJECT_CLASS class = CKO_DATA; ++ CK_BBOOL ck_true = CK_TRUE; ++ CK_BBOOL ck_false = CK_FALSE; ++ ++ CK_ATTRIBUTE attrs[] = { ++ {CKA_CLASS, &class, sizeof (class)}, ++ {CKA_TOKEN, &ck_true, sizeof (ck_true)}, ++ {CKA_PRIVATE, is_public ? &ck_false : &ck_true, sizeof (CK_BBOOL)}, ++ {CKA_APPLICATION, (void *)application, strlen (application)}, ++ {CKA_LABEL, (void *)label, strlen (label)}, ++ {CKA_VALUE, blob, blob_size} ++ }; ++ ++ CK_OBJECT_HANDLE handle = PKCS11H_INVALID_OBJECT_HANDLE; ++ CK_RV rv = CKR_OK; ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ PKCS11H_BOOL mutex_locked = FALSE; ++#endif ++ pkcs11h_session_t session = NULL; ++ PKCS11H_BOOL op_succeed = FALSE; ++ PKCS11H_BOOL login_retry = FALSE; ++ ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ PKCS11H_ASSERT (token_id!=NULL); ++ PKCS11H_ASSERT (application!=NULL); ++ PKCS11H_ASSERT (label!=NULL); ++ /*PKCS11H_ASSERT (user_data) NOT NEEDED */ ++ PKCS11H_ASSERT (blob!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_data_put entry token_id=%p, application='%s', label='%s', user_data=%p, mask_prompt=%08x, blob=%p, blob_size=%u", ++ (void *)token_id, ++ application, ++ label, ++ user_data, ++ mask_prompt, ++ blob, ++ blob != NULL ? blob_size : 0 ++ ); ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_getSessionByTokenId ( ++ token_id, ++ &session ++ ); ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_threading_mutexLock (&session->mutex)) == CKR_OK ++ ) { ++ mutex_locked = TRUE; ++ } ++#endif ++ ++ while (rv == CKR_OK && !op_succeed) { ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_validate (session); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = session->provider->f->C_CreateObject ( ++ session->session_handle, ++ attrs, ++ sizeof (attrs)/sizeof (CK_ATTRIBUTE), ++ &handle ++ ); ++ } ++ ++ if (rv == CKR_OK) { ++ op_succeed = TRUE; ++ } ++ else { ++ if (!login_retry) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Write data object failed rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ login_retry = TRUE; ++ rv = _pkcs11h_session_login ( ++ session, ++ is_public, ++ FALSE, ++ user_data, ++ mask_prompt ++ ); ++ } ++ } ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if (mutex_locked) { ++ _pkcs11h_threading_mutexRelease (&session->mutex); ++ mutex_locked = FALSE; ++ } ++#endif ++ ++ if (session != NULL) { ++ _pkcs11h_session_release (session); ++ session = NULL; ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_data_put return rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ return rv; ++} ++ ++CK_RV ++pkcs11h_data_del ( ++ IN const pkcs11h_token_id_t token_id, ++ IN const PKCS11H_BOOL is_public, ++ IN const char * const application, ++ IN const char * const label, ++ IN void * const user_data, ++ IN const unsigned mask_prompt ++) { ++#if defined(ENABLE_PKCS11H_THREADING) ++ PKCS11H_BOOL mutex_locked = FALSE; ++#endif ++ pkcs11h_session_t session = NULL; ++ PKCS11H_BOOL op_succeed = FALSE; ++ PKCS11H_BOOL login_retry = FALSE; ++ CK_OBJECT_HANDLE handle = PKCS11H_INVALID_OBJECT_HANDLE; ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ PKCS11H_ASSERT (token_id!=NULL); ++ PKCS11H_ASSERT (application!=NULL); ++ PKCS11H_ASSERT (label!=NULL); ++ /*PKCS11H_ASSERT (user_data) NOT NEEDED */ ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_data_del entry token_id=%p, application='%s', label='%s', user_data=%p, mask_prompt=%08x", ++ (void *)token_id, ++ application, ++ label, ++ user_data, ++ mask_prompt ++ ); ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_getSessionByTokenId ( ++ token_id, ++ &session ++ ); ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_threading_mutexLock (&session->mutex)) == CKR_OK ++ ) { ++ mutex_locked = TRUE; ++ } ++#endif ++ ++ while (rv == CKR_OK && !op_succeed) { ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_validate (session); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_data_getObject ( ++ session, ++ application, ++ label, ++ &handle ++ ); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = session->provider->f->C_DestroyObject ( ++ session->session_handle, ++ handle ++ ); ++ } ++ ++ if (rv == CKR_OK) { ++ op_succeed = TRUE; ++ } ++ else { ++ if (!login_retry) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Remove data object failed rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ login_retry = TRUE; ++ rv = _pkcs11h_session_login ( ++ session, ++ is_public, ++ FALSE, ++ user_data, ++ mask_prompt ++ ); ++ } ++ } ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if (mutex_locked) { ++ _pkcs11h_threading_mutexRelease (&session->mutex); ++ mutex_locked = FALSE; ++ } ++#endif ++ ++ if (session != NULL) { ++ _pkcs11h_session_release (session); ++ session = NULL; ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_data_del return rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ return rv; ++} ++ ++#endif /* ENABLE_PKCS11H_DATA */ ++ ++#if defined(ENABLE_PKCS11H_CERTIFICATE) ++/*======================================================================* ++ * CERTIFICATE INTERFACE ++ *======================================================================*/ ++ ++static ++time_t ++_pkcs11h_certificate_getExpiration ( ++ IN const unsigned char * const certificate, ++ IN const size_t certificate_size ++) { ++ /* ++ * This function compare the notAfter ++ * and select the most recent certificate ++ */ ++ ++#if defined(USE_PKCS11H_OPENSSL) ++ X509 *x509 = NULL; ++#elif defined(USE_PKCS11H_GNUTLS) ++ gnutls_x509_crt_t cert = NULL; ++#endif ++ time_t expire = (time_t)0; ++ ++ PKCS11H_ASSERT (certificate!=NULL); ++ ++#if defined(USE_PKCS11H_OPENSSL) ++ x509 = X509_new (); ++ ++ if (x509 != NULL) { ++ pkcs11_openssl_d2i_t d2i = (pkcs11_openssl_d2i_t)certificate; ++ ++ if ( ++ d2i_X509 (&x509, &d2i, certificate_size) ++ ) { ++ ASN1_TIME *notBefore = X509_get_notBefore (x509); ++ ASN1_TIME *notAfter = X509_get_notAfter (x509); ++ ++ if ( ++ notBefore != NULL && ++ notAfter != NULL && ++ X509_cmp_current_time (notBefore) <= 0 && ++ X509_cmp_current_time (notAfter) >= 0 && ++ notAfter->length >= 12 ++ ) { ++ struct tm tm1; ++ time_t now = time (NULL); ++ ++ memset (&tm1, 0, sizeof (tm1)); ++ tm1.tm_year = (notAfter->data[ 0] - '0') * 10 + (notAfter->data[ 1] - '0') + 100; ++ tm1.tm_mon = (notAfter->data[ 2] - '0') * 10 + (notAfter->data[ 3] - '0') - 1; ++ tm1.tm_mday = (notAfter->data[ 4] - '0') * 10 + (notAfter->data[ 5] - '0'); ++ tm1.tm_hour = (notAfter->data[ 6] - '0') * 10 + (notAfter->data[ 7] - '0'); ++ tm1.tm_min = (notAfter->data[ 8] - '0') * 10 + (notAfter->data[ 9] - '0'); ++ tm1.tm_sec = (notAfter->data[10] - '0') * 10 + (notAfter->data[11] - '0'); ++ ++ tm1.tm_sec += (int)(mktime (localtime (&now)) - mktime (gmtime (&now))); ++ ++ expire = mktime (&tm1); ++ } ++ } ++ } ++ ++ if (x509 != NULL) { ++ X509_free (x509); ++ x509 = NULL; ++ } ++#elif defined(USE_PKCS11H_GNUTLS) ++ if (gnutls_x509_crt_init (&cert) == GNUTLS_E_SUCCESS) { ++ gnutls_datum_t datum = {(unsigned char *)certificate, certificate_size}; ++ ++ if (gnutls_x509_crt_import (cert, &datum, GNUTLS_X509_FMT_DER) == GNUTLS_E_SUCCESS) { ++ ++ time_t activation_time = gnutls_x509_crt_get_activation_time (cert); ++ time_t expiration_time = gnutls_x509_crt_get_expiration_time (cert); ++ time_t now = time (NULL); ++ ++ if ( ++ now >= activation_time && ++ now <= expiration_time ++ ) { ++ expire = expiration_time; ++ } ++ } ++ gnutls_x509_crt_deinit (cert); ++ } ++#else ++#error Invalid configuration ++#endif ++ ++ return expire; ++} ++ ++static ++PKCS11H_BOOL ++_pkcs11h_certificate_isBetterCertificate ( ++ IN const unsigned char * const current, ++ IN const size_t current_size, ++ IN const unsigned char * const newone, ++ IN const size_t newone_size ++) { ++ PKCS11H_BOOL is_better = FALSE; ++ ++ /*PKCS11H_ASSERT (current!=NULL); NOT NEEDED */ ++ PKCS11H_ASSERT (newone!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_certificate_isBetterCertificate entry current=%p, current_size=%u, newone=%p, newone_size=%u", ++ current, ++ current_size, ++ newone, ++ newone_size ++ ); ++ ++ /* ++ * First certificae ++ * always select ++ */ ++ if (current_size == 0 || current == NULL) { ++ is_better = TRUE; ++ } ++ else { ++ time_t notAfterCurrent, notAfterNew; ++ ++ notAfterCurrent = _pkcs11h_certificate_getExpiration ( ++ current, ++ current_size ++ ); ++ notAfterNew = _pkcs11h_certificate_getExpiration ( ++ newone, ++ newone_size ++ ); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_certificate_isBetterCertificate notAfterCurrent='%s', notAfterNew='%s'", ++ asctime (localtime (¬AfterCurrent)), ++ asctime (localtime (¬AfterNew)) ++ ); ++ ++ is_better = notAfterNew > notAfterCurrent; ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_certificate_isBetterCertificate return is_better=%d", ++ is_better ? 1 : 0 ++ ); ++ ++ return is_better; ++} ++ ++static ++CK_RV ++_pkcs11h_certificate_newCertificateId ( ++ OUT pkcs11h_certificate_id_t * const p_certificate_id ++) { ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (p_certificate_id!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_certificate_newCertificateId entry p_certificate_id=%p", ++ (void *)p_certificate_id ++ ); ++ ++ *p_certificate_id = NULL; ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_mem_malloc ((void *)p_certificate_id, sizeof (struct pkcs11h_certificate_id_s)); ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_certificate_newCertificateId return rv=%ld-'%s', *p_certificate_id=%p", ++ rv, ++ pkcs11h_getMessage (rv), ++ (void *)*p_certificate_id ++ ); ++ ++ return rv; ++} ++ ++static ++CK_RV ++_pkcs11h_certificate_getDN ( ++ IN const unsigned char * const blob, ++ IN const size_t blob_size, ++ OUT char * const dn, ++ IN const size_t dn_size ++) { ++#if defined(USE_PKCS11H_OPENSSL) ++ X509 *x509 = NULL; ++ pkcs11_openssl_d2i_t d2i1; ++#elif defined(USE_PKCS11H_GNUTLS) ++ gnutls_x509_crt_t cert = NULL; ++#endif ++ ++ PKCS11H_ASSERT (blob_size==0||blob!=NULL); ++ PKCS11H_ASSERT (dn!=NULL); ++ ++ dn[0] = '\x0'; ++ ++#if defined(USE_PKCS11H_OPENSSL) ++ ++ if (blob_size > 0) { ++ x509 = X509_new (); ++ ++ d2i1 = (pkcs11_openssl_d2i_t)blob; ++ if (d2i_X509 (&x509, &d2i1, blob_size)) { ++ X509_NAME_oneline ( ++ X509_get_subject_name (x509), ++ dn, ++ dn_size ++ ); ++ } ++ ++ if (x509 != NULL) { ++ X509_free (x509); ++ x509 = NULL; ++ } ++ } ++ ++#elif defined(USE_PKCS11H_GNUTLS) ++ ++ if (blob_size > 0) { ++ if (gnutls_x509_crt_init (&cert) == GNUTLS_E_SUCCESS) { ++ gnutls_datum_t datum = {(unsigned char *)blob, blob_size}; ++ ++ if (gnutls_x509_crt_import (cert, &datum, GNUTLS_X509_FMT_DER) == GNUTLS_E_SUCCESS) { ++ size_t s = dn_size; ++ if ( ++ gnutls_x509_crt_get_dn ( ++ cert, ++ dn, ++ &s ++ ) != GNUTLS_E_SUCCESS ++ ) { ++ /* gnutls sets output parameters */ ++ dn[0] = '\x0'; ++ } ++ } ++ gnutls_x509_crt_deinit (cert); ++ } ++ } ++ ++#else ++#error Invalid configuration ++#endif ++ ++ return CKR_OK; ++} ++ ++static ++CK_RV ++_pkcs11h_certificate_loadCertificate ( ++ IN const pkcs11h_certificate_t certificate ++) { ++ /* ++ * THREADING: ++ * certificate->mutex must be locked ++ */ ++#if defined(ENABLE_PKCS11H_THREADING) ++ PKCS11H_BOOL mutex_locked = FALSE; ++#endif ++ CK_OBJECT_CLASS cert_filter_class = CKO_CERTIFICATE; ++ CK_ATTRIBUTE cert_filter[] = { ++ {CKA_CLASS, &cert_filter_class, sizeof (cert_filter_class)}, ++ {CKA_ID, NULL, 0} ++ }; ++ ++ CK_OBJECT_HANDLE *objects = NULL; ++ CK_ULONG objects_found = 0; ++ CK_RV rv = CKR_OK; ++ ++ CK_ULONG i; ++ ++ PKCS11H_ASSERT (certificate!=NULL); ++ PKCS11H_ASSERT (certificate->id!=NULL); ++ ++ /* Must be after assert */ ++ cert_filter[1].pValue = certificate->id->attrCKA_ID; ++ cert_filter[1].ulValueLen = certificate->id->attrCKA_ID_size; ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_certificate_loadCertificate entry certificate=%p", ++ (void *)certificate ++ ); ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_threading_mutexLock (&certificate->session->mutex)) == CKR_OK ++ ) { ++ mutex_locked = TRUE; ++ } ++#endif ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_validate (certificate->session); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_findObjects ( ++ certificate->session, ++ cert_filter, ++ sizeof (cert_filter) / sizeof (CK_ATTRIBUTE), ++ &objects, ++ &objects_found ++ ); ++ } ++ ++ for (i=0;rv == CKR_OK && i < objects_found;i++) { ++ CK_ATTRIBUTE attrs[] = { ++ {CKA_VALUE, NULL, 0} ++ }; ++ ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_session_getObjectAttributes ( ++ certificate->session, ++ objects[i], ++ attrs, ++ sizeof (attrs) / sizeof (CK_ATTRIBUTE) ++ )) == CKR_OK ++ ) { ++ if ( ++ _pkcs11h_certificate_isBetterCertificate ( ++ certificate->id->certificate_blob, ++ certificate->id->certificate_blob_size, ++ attrs[0].pValue, ++ attrs[0].ulValueLen ++ ) ++ ) { ++ if (certificate->id->certificate_blob != NULL) { ++ _pkcs11h_mem_free ((void *)&certificate->id->certificate_blob); ++ } ++ ++ rv = _pkcs11h_mem_duplicate ( ++ (void*)&certificate->id->certificate_blob, ++ &certificate->id->certificate_blob_size, ++ attrs[0].pValue, ++ attrs[0].ulValueLen ++ ); ++ } ++ } ++ ++ if (rv != CKR_OK) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Cannot get object attribute for provider '%s' object %ld rv=%ld-'%s'", ++ certificate->session->provider->manufacturerID, ++ objects[i], ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ /* ++ * Ignore error ++ */ ++ rv = CKR_OK; ++ } ++ ++ _pkcs11h_session_freeObjectAttributes ( ++ attrs, ++ sizeof (attrs) / sizeof (CK_ATTRIBUTE) ++ ); ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if (mutex_locked) { ++ _pkcs11h_threading_mutexRelease (&certificate->session->mutex); ++ mutex_locked = FALSE; ++ } ++#endif ++ ++ if ( ++ rv == CKR_OK && ++ certificate->id->certificate_blob == NULL ++ ) { ++ rv = CKR_ATTRIBUTE_VALUE_INVALID; ++ } ++ ++ if (objects != NULL) { ++ _pkcs11h_mem_free ((void *)&objects); ++ } ++ ++ /* ++ * No need to free allocated objects ++ * on error, since the certificate_id ++ * should be free by caller. ++ */ ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_certificate_loadCertificate return rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ return rv; ++} ++ ++static ++CK_RV ++_pkcs11h_certificate_updateCertificateIdDescription ( ++ IN OUT pkcs11h_certificate_id_t certificate_id ++) { ++ static const char * separator = " on "; ++ static const char * unknown = "UNKNOWN"; ++ ++ PKCS11H_ASSERT (certificate_id!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_certificate_updateCertificateIdDescription entry certificate_id=%p", ++ (void *)certificate_id ++ ); ++ ++ certificate_id->displayName[0] = '\x0'; ++ ++ _pkcs11h_certificate_getDN ( ++ certificate_id->certificate_blob, ++ certificate_id->certificate_blob_size, ++ certificate_id->displayName, ++ sizeof (certificate_id->displayName) ++ ); ++ ++ if (strlen (certificate_id->displayName) == 0) { ++ strncpy ( ++ certificate_id->displayName, ++ unknown, ++ sizeof (certificate_id->displayName)-1 ++ ); ++ } ++ ++ /* ++ * Try to avoid using snprintf, ++ * may be unavailable ++ */ ++ strncat ( ++ certificate_id->displayName, ++ separator, ++ sizeof (certificate_id->displayName)-1-strlen (certificate_id->displayName) ++ ); ++ strncat ( ++ certificate_id->displayName, ++ certificate_id->token_id->display, ++ sizeof (certificate_id->displayName)-1-strlen (certificate_id->displayName) ++ ); ++ certificate_id->displayName[sizeof (certificate_id->displayName) - 1] = '\0'; ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_certificate_updateCertificateIdDescription return displayName='%s'", ++ certificate_id->displayName ++ ); ++ ++ return CKR_OK; ++} ++ ++static ++CK_RV ++_pkcs11h_certificate_getKeyAttributes ( ++ IN const pkcs11h_certificate_t certificate ++) { ++#if defined(ENABLE_PKCS11H_THREADING) ++ PKCS11H_BOOL mutex_locked = FALSE; ++#endif ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_BOOL op_succeed = FALSE; ++ PKCS11H_BOOL login_retry = FALSE; ++ ++ PKCS11H_ASSERT (certificate!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_certificate_getKeyAttributes entry certificate=%p", ++ (void *)certificate ++ ); ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_threading_mutexLock (&certificate->mutex)) == CKR_OK ++ ) { ++ mutex_locked = TRUE; ++ } ++#endif ++ ++ certificate->mask_sign_mode = 0; ++ ++ while (rv == CKR_OK && !op_succeed) { ++ CK_ATTRIBUTE key_attrs[] = { ++ {CKA_SIGN, NULL, 0}, ++ {CKA_SIGN_RECOVER, NULL, 0} ++ }; ++ ++ /* ++ * Don't try invalid object ++ */ ++ if ( ++ rv == CKR_OK && ++ certificate->key_handle == PKCS11H_INVALID_OBJECT_HANDLE ++ ) { ++ rv = CKR_OBJECT_HANDLE_INVALID; ++ } ++ ++ if (rv == CKR_OK) { ++ if (certificate->session->provider->mask_sign_mode != 0) { ++ certificate->mask_sign_mode = certificate->session->provider->mask_sign_mode; ++ op_succeed = TRUE; ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Key attributes enforced by provider (%08x)", ++ certificate->mask_sign_mode ++ ); ++ } ++ } ++ ++ if (rv == CKR_OK && !op_succeed) { ++ rv = _pkcs11h_session_getObjectAttributes ( ++ certificate->session, ++ certificate->key_handle, ++ key_attrs, ++ sizeof (key_attrs) / sizeof (CK_ATTRIBUTE) ++ ); ++ } ++ ++ if (rv == CKR_OK && !op_succeed) { ++ CK_BBOOL *key_attrs_sign = (CK_BBOOL *)key_attrs[0].pValue; ++ CK_BBOOL *key_attrs_sign_recover = (CK_BBOOL *)key_attrs[1].pValue; ++ ++ if (key_attrs_sign != NULL && *key_attrs_sign != CK_FALSE) { ++ certificate->mask_sign_mode |= PKCS11H_SIGNMODE_MASK_SIGN; ++ } ++ if (key_attrs_sign_recover != NULL && *key_attrs_sign_recover != CK_FALSE) { ++ certificate->mask_sign_mode |= PKCS11H_SIGNMODE_MASK_RECOVER; ++ } ++ if (certificate->mask_sign_mode == 0) { ++ rv = CKR_KEY_TYPE_INCONSISTENT; ++ } ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Key attributes loaded (%08x)", ++ certificate->mask_sign_mode ++ ); ++ } ++ ++ _pkcs11h_session_freeObjectAttributes ( ++ key_attrs, ++ sizeof (key_attrs) / sizeof (CK_ATTRIBUTE) ++ ); ++ ++ if (rv == CKR_OK) { ++ op_succeed = TRUE; ++ } ++ else { ++ if (!login_retry) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Get private key attributes failed: %ld:'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ rv = _pkcs11h_certificate_resetSession ( ++ certificate, ++ FALSE, ++ TRUE ++ ); ++ ++ login_retry = TRUE; ++ } ++ } ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if (mutex_locked) { ++ _pkcs11h_threading_mutexRelease (&certificate->mutex); ++ mutex_locked = FALSE; ++ } ++#endif ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_certificate_getKeyAttributes return rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ return rv; ++} ++ ++static ++CK_RV ++_pkcs11h_certificate_validateSession ( ++ IN const pkcs11h_certificate_t certificate ++) { ++ /* ++ * THREADING: ++ * certificate->mutex must be locked ++ * certificate->session->mutex must be locked ++ */ ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (certificate!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_certificate_validateSession entry certificate=%p", ++ (void *)certificate ++ ); ++ ++ if (certificate->session == NULL) { ++ rv = CKR_SESSION_HANDLE_INVALID; ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_validate (certificate->session); ++ } ++ ++ if (rv == CKR_OK) { ++ if (certificate->key_handle == PKCS11H_INVALID_OBJECT_HANDLE) { ++ rv = CKR_OBJECT_HANDLE_INVALID; ++ } ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_certificate_validateSession return rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ return rv; ++} ++ ++CK_RV ++_pkcs11h_certificate_resetSession ( ++ IN const pkcs11h_certificate_t certificate, ++ IN const PKCS11H_BOOL public_only, ++ IN const PKCS11H_BOOL session_mutex_locked ++) { ++ /* ++ * THREADING: ++ * certificate->mutex must be locked ++ */ ++#if defined(ENABLE_PKCS11H_THREADING) ++ PKCS11H_BOOL mutex_locked = FALSE; ++#endif ++ PKCS11H_BOOL is_key_valid = FALSE; ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (certificate!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_certificate_resetSession entry certificate=%p, public_only=%d, session_mutex_locked=%d", ++ (void *)certificate, ++ public_only ? 1 : 0, ++ session_mutex_locked ? 1 : 0 ++ ); ++ ++ if (rv == CKR_OK && certificate->session == NULL) { ++ rv = _pkcs11h_session_getSessionByTokenId (certificate->id->token_id, &certificate->session); ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if ( ++ rv == CKR_OK && ++ !session_mutex_locked && ++ (rv = _pkcs11h_threading_mutexLock (&certificate->session->mutex)) == CKR_OK ++ ) { ++ mutex_locked = TRUE; ++ } ++#endif ++ ++ if ( ++ rv == CKR_OK && ++ !certificate->pin_cache_populated_to_session ++ ) { ++ certificate->pin_cache_populated_to_session = TRUE; ++ ++ if (certificate->pin_cache_period != PKCS11H_PIN_CACHE_INFINITE) { ++ if (certificate->session->pin_cache_period != PKCS11H_PIN_CACHE_INFINITE) { ++ if (certificate->session->pin_cache_period > certificate->pin_cache_period) { ++ certificate->session->pin_expire_time = ( ++ certificate->session->pin_expire_time - ++ (time_t)certificate->session->pin_cache_period + ++ (time_t)certificate->pin_cache_period ++ ); ++ certificate->session->pin_cache_period = certificate->pin_cache_period; ++ } ++ } ++ else { ++ certificate->session->pin_expire_time = ( ++ PKCS11H_TIME (NULL) + ++ (time_t)certificate->pin_cache_period ++ ); ++ certificate->session->pin_cache_period = certificate->pin_cache_period; ++ } ++ } ++ } ++ ++ /* ++ * First, if session seems to be valid ++ * and key handle is invalid (hard-set), ++ * try to fetch key handle, ++ * maybe the token is already logged in ++ */ ++ if (rv == CKR_OK) { ++ if ( ++ certificate->session->session_handle != PKCS11H_INVALID_SESSION_HANDLE && ++ certificate->key_handle == PKCS11H_INVALID_OBJECT_HANDLE ++ ) { ++ if (!public_only || certificate->session->provider->cert_is_private) { ++ if ( ++ (rv = _pkcs11h_session_getObjectById ( ++ certificate->session, ++ CKO_PRIVATE_KEY, ++ certificate->id->attrCKA_ID, ++ certificate->id->attrCKA_ID_size, ++ &certificate->key_handle ++ )) == CKR_OK ++ ) { ++ is_key_valid = TRUE; ++ } ++ else { ++ /* ++ * Ignore error ++ */ ++ rv = CKR_OK; ++ certificate->key_handle = PKCS11H_INVALID_OBJECT_HANDLE; ++ } ++ } ++ } ++ } ++ ++ if ( ++ !is_key_valid && ++ rv == CKR_OK && ++ (rv = _pkcs11h_session_login ( ++ certificate->session, ++ public_only, ++ TRUE, ++ certificate->user_data, ++ certificate->mask_prompt ++ )) == CKR_OK ++ ) { ++ rv = _pkcs11h_certificate_updateCertificateIdDescription (certificate->id); ++ } ++ ++ if ( ++ !is_key_valid && ++ rv == CKR_OK && ++ !public_only && ++ (rv = _pkcs11h_session_getObjectById ( ++ certificate->session, ++ CKO_PRIVATE_KEY, ++ certificate->id->attrCKA_ID, ++ certificate->id->attrCKA_ID_size, ++ &certificate->key_handle ++ )) == CKR_OK ++ ) { ++ is_key_valid = TRUE; ++ } ++ ++ if ( ++ rv == CKR_OK && ++ !public_only && ++ !is_key_valid ++ ) { ++ rv = CKR_FUNCTION_REJECTED; ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if (mutex_locked) { ++ _pkcs11h_threading_mutexRelease (&certificate->session->mutex); ++ mutex_locked = FALSE; ++ } ++#endif ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_certificate_resetSession return rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ return rv; ++} ++ ++static ++CK_RV ++_pkcs11h_certificate_doPrivateOperation ( ++ IN const pkcs11h_certificate_t certificate, ++ IN const enum _pkcs11h_private_op_e op, ++ IN const CK_MECHANISM_TYPE mech_type, ++ IN const unsigned char * const source, ++ IN const size_t source_size, ++ OUT unsigned char * const target, ++ IN OUT size_t * const p_target_size ++) { ++#if defined(ENABLE_PKCS11H_THREADING) ++ PKCS11H_BOOL mutex_locked = FALSE; ++#endif ++ CK_MECHANISM mech = { ++ mech_type, NULL, 0 ++ }; ++ ++ CK_RV rv = CKR_OK; ++ PKCS11H_BOOL login_retry = FALSE; ++ PKCS11H_BOOL op_succeed = FALSE; ++ ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ PKCS11H_ASSERT (certificate!=NULL); ++ PKCS11H_ASSERT (source!=NULL); ++ /*PKCS11H_ASSERT (target); NOT NEEDED*/ ++ PKCS11H_ASSERT (p_target_size!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_certificate_doPrivateOperation entry certificate=%p, op=%d, mech_type=%ld, source=%p, source_size=%u, target=%p, *p_target_size=%u", ++ (void *)certificate, ++ op, ++ mech_type, ++ source, ++ source_size, ++ target, ++ target != NULL ? *p_target_size : 0 ++ ); ++ ++ if (target == NULL) { ++ *p_target_size = 0; ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_threading_mutexLock (&certificate->mutex)) == CKR_OK ++ ) { ++ mutex_locked = TRUE; ++ } ++#endif ++ ++ while (rv == CKR_OK && !op_succeed) { ++ if (rv == CKR_OK && !certificate->operation_active) { ++ rv = _pkcs11h_certificate_validateSession (certificate); ++ } ++ ++ if (rv == CKR_OK && !certificate->operation_active) { ++ switch (op) { ++ case _pkcs11h_private_op_sign: ++ rv = certificate->session->provider->f->C_SignInit ( ++ certificate->session->session_handle, ++ &mech, ++ certificate->key_handle ++ ); ++ break; ++ case _pkcs11h_private_op_sign_recover: ++ rv = certificate->session->provider->f->C_SignRecoverInit ( ++ certificate->session->session_handle, ++ &mech, ++ certificate->key_handle ++ ); ++ break; ++ case _pkcs11h_private_op_decrypt: ++ rv = certificate->session->provider->f->C_DecryptInit ( ++ certificate->session->session_handle, ++ &mech, ++ certificate->key_handle ++ ); ++ break; ++ default: ++ rv = CKR_ARGUMENTS_BAD; ++ break; ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_certificate_doPrivateOperation init rv=%ld", ++ rv ++ ); ++ } ++ ++ if (rv == CKR_OK) { ++ CK_ULONG size = *p_target_size; ++ ++ switch (op) { ++ case _pkcs11h_private_op_sign: ++ rv = certificate->session->provider->f->C_Sign ( ++ certificate->session->session_handle, ++ (CK_BYTE_PTR)source, ++ source_size, ++ (CK_BYTE_PTR)target, ++ &size ++ ); ++ break; ++ case _pkcs11h_private_op_sign_recover: ++ rv = certificate->session->provider->f->C_SignRecover ( ++ certificate->session->session_handle, ++ (CK_BYTE_PTR)source, ++ source_size, ++ (CK_BYTE_PTR)target, ++ &size ++ ); ++ break; ++ case _pkcs11h_private_op_decrypt: ++ rv = certificate->session->provider->f->C_Decrypt ( ++ certificate->session->session_handle, ++ (CK_BYTE_PTR)source, ++ source_size, ++ (CK_BYTE_PTR)target, ++ &size ++ ); ++ break; ++ default: ++ rv = CKR_ARGUMENTS_BAD; ++ break; ++ } ++ ++ *p_target_size = size; ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_certificate_doPrivateOperation op rv=%ld", ++ rv ++ ); ++ } ++ ++ if ( ++ target == NULL && ++ ( ++ rv == CKR_BUFFER_TOO_SMALL || ++ rv == CKR_OK ++ ) ++ ) { ++ certificate->operation_active = TRUE; ++ rv = CKR_OK; ++ } ++ else { ++ certificate->operation_active = FALSE; ++ } ++ ++ if (rv == CKR_OK) { ++ op_succeed = TRUE; ++ } ++ else { ++ /* ++ * OpenSC workaround ++ * It still allows C_FindObjectsInit when ++ * token is removed/inserted but fails ++ * private key operation. ++ * So we force logout. ++ * bug#108 at OpenSC trac ++ */ ++ if (login_retry && rv == CKR_DEVICE_REMOVED) { ++ login_retry = FALSE; ++ _pkcs11h_session_logout (certificate->session); ++ } ++ ++ if (!login_retry) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Private key operation failed rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ login_retry = TRUE; ++ rv = _pkcs11h_certificate_resetSession ( ++ certificate, ++ FALSE, ++ TRUE ++ ); ++ } ++ } ++ ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if (mutex_locked) { ++ _pkcs11h_threading_mutexRelease (&certificate->mutex); ++ mutex_locked = FALSE; ++ } ++#endif ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_certificate_doPrivateOperation return rv=%ld-'%s', *p_target_size=%u", ++ rv, ++ pkcs11h_getMessage (rv), ++ *p_target_size ++ ); ++ ++ return rv; ++} ++ ++CK_RV ++pkcs11h_certificate_freeCertificateId ( ++ IN pkcs11h_certificate_id_t certificate_id ++) { ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ PKCS11H_ASSERT (certificate_id!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_certificate_freeCertificateId entry certificate_id=%p", ++ (void *)certificate_id ++ ); ++ ++ if (certificate_id->attrCKA_ID != NULL) { ++ _pkcs11h_mem_free ((void *)&certificate_id->attrCKA_ID); ++ } ++ if (certificate_id->certificate_blob != NULL) { ++ _pkcs11h_mem_free ((void *)&certificate_id->certificate_blob); ++ } ++ if (certificate_id->token_id != NULL) { ++ pkcs11h_token_freeTokenId (certificate_id->token_id); ++ certificate_id->token_id = NULL; ++ } ++ _pkcs11h_mem_free ((void *)&certificate_id); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_certificate_freeCertificateId return" ++ ); ++ ++ return CKR_OK; ++} ++ ++CK_RV ++pkcs11h_certificate_duplicateCertificateId ( ++ OUT pkcs11h_certificate_id_t * const to, ++ IN const pkcs11h_certificate_id_t from ++) { ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ PKCS11H_ASSERT (to!=NULL); ++ PKCS11H_ASSERT (from!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_certificate_duplicateCertificateId entry to=%p form=%p", ++ (void *)to, ++ (void *)from ++ ); ++ ++ *to = NULL; ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_mem_duplicate ( ++ (void*)to, ++ NULL, ++ from, ++ sizeof (struct pkcs11h_certificate_id_s) ++ ); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_mem_duplicate ( ++ (void*)&(*to)->token_id, ++ NULL, ++ from->token_id, ++ sizeof (struct pkcs11h_token_id_s) ++ ); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_mem_duplicate ( ++ (void*)&(*to)->attrCKA_ID, ++ &(*to)->attrCKA_ID_size, ++ from->attrCKA_ID, ++ from->attrCKA_ID_size ++ ); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_mem_duplicate ( ++ (void*)&(*to)->certificate_blob, ++ &(*to)->certificate_blob_size, ++ from->certificate_blob, ++ from->certificate_blob_size ++ ); ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_certificate_duplicateCertificateId return rv=%ld-'%s', *to=%p", ++ rv, ++ pkcs11h_getMessage (rv), ++ (void *)*to ++ ); ++ ++ return rv; ++} ++ ++CK_RV ++pkcs11h_certificate_setCertificateIdCertificateBlob ( ++ IN const pkcs11h_certificate_id_t certificate_id, ++ IN const unsigned char * const blob, ++ IN const size_t blob_size ++) { ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ PKCS11H_ASSERT (certificate_id!=NULL); ++ PKCS11H_ASSERT (blob!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_certificate_setCertificateIdCertificateBlob entry certificate_id=%p", ++ (void *)certificate_id ++ ); ++ ++ if (rv == CKR_OK && certificate_id->certificate_blob != NULL) { ++ rv = _pkcs11h_mem_free ((void *)&certificate_id->certificate_blob); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_mem_duplicate ( ++ (void *)&certificate_id->certificate_blob, ++ &certificate_id->certificate_blob_size, ++ blob, ++ blob_size ++ ); ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_certificate_setCertificateIdCertificateBlob return rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ return rv; ++} ++ ++CK_RV ++pkcs11h_certificate_freeCertificate ( ++ IN pkcs11h_certificate_t certificate ++) { ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_certificate_freeCertificate entry certificate=%p", ++ (void *)certificate ++ ); ++ ++ if (certificate != NULL) { ++ if (certificate->session != NULL) { ++ _pkcs11h_session_release (certificate->session); ++ } ++ pkcs11h_certificate_freeCertificateId (certificate->id); ++ certificate->id = NULL; ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ _pkcs11h_threading_mutexFree (&certificate->mutex); ++#endif ++ ++ _pkcs11h_mem_free ((void *)&certificate); ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_certificate_freeCertificate return" ++ ); ++ ++ return CKR_OK; ++} ++ ++CK_RV ++pkcs11h_certificate_lockSession ( ++ IN const pkcs11h_certificate_t certificate ++) { ++#if defined(ENABLE_PKCS11H_THREADING) ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ PKCS11H_ASSERT (certificate!=NULL); ++ ++ if (rv == CKR_OK && certificate->session == NULL) { ++ rv = _pkcs11h_session_getSessionByTokenId (certificate->id->token_id, &certificate->session); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_threading_mutexLock (&certificate->session->mutex); ++ } ++ ++ return rv; ++#else ++ return CKR_OK; ++#endif ++} ++ ++CK_RV ++pkcs11h_certificate_releaseSession ( ++ IN const pkcs11h_certificate_t certificate ++) { ++#if defined(ENABLE_PKCS11H_THREADING) ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ PKCS11H_ASSERT (certificate!=NULL); ++ ++ if (certificate->session != NULL) { ++ rv = _pkcs11h_threading_mutexRelease (&certificate->session->mutex); ++ } ++ ++ return rv; ++#else ++ return CKR_OK; ++#endif ++} ++ ++CK_RV ++pkcs11h_certificate_sign ( ++ IN const pkcs11h_certificate_t certificate, ++ IN const CK_MECHANISM_TYPE mech_type, ++ IN const unsigned char * const source, ++ IN const size_t source_size, ++ OUT unsigned char * const target, ++ IN OUT size_t * const p_target_size ++) { ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ PKCS11H_ASSERT (certificate!=NULL); ++ PKCS11H_ASSERT (source!=NULL); ++ /*PKCS11H_ASSERT (target); NOT NEEDED*/ ++ PKCS11H_ASSERT (p_target_size!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_certificate_sign entry certificate=%p, mech_type=%ld, source=%p, source_size=%u, target=%p, *p_target_size=%u", ++ (void *)certificate, ++ mech_type, ++ source, ++ source_size, ++ target, ++ target != NULL ? *p_target_size : 0 ++ ); ++ ++ if (target == NULL) { ++ *p_target_size = 0; ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_certificate_doPrivateOperation ( ++ certificate, ++ _pkcs11h_private_op_sign, ++ mech_type, ++ source, ++ source_size, ++ target, ++ p_target_size ++ ); ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_certificate_sign return rv=%ld-'%s', *p_target_size=%u", ++ rv, ++ pkcs11h_getMessage (rv), ++ *p_target_size ++ ); ++ ++ return rv; ++} ++ ++CK_RV ++pkcs11h_certificate_signRecover ( ++ IN const pkcs11h_certificate_t certificate, ++ IN const CK_MECHANISM_TYPE mech_type, ++ IN const unsigned char * const source, ++ IN const size_t source_size, ++ OUT unsigned char * const target, ++ IN OUT size_t * const p_target_size ++) { ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ PKCS11H_ASSERT (certificate!=NULL); ++ PKCS11H_ASSERT (source!=NULL); ++ /*PKCS11H_ASSERT (target); NOT NEEDED*/ ++ PKCS11H_ASSERT (p_target_size!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_certificate_signRecover entry certificate=%p, mech_type=%ld, source=%p, source_size=%u, target=%p, *p_target_size=%u", ++ (void *)certificate, ++ mech_type, ++ source, ++ source_size, ++ target, ++ target != NULL ? *p_target_size : 0 ++ ); ++ ++ if (target == NULL) { ++ *p_target_size = 0; ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_certificate_doPrivateOperation ( ++ certificate, ++ _pkcs11h_private_op_sign_recover, ++ mech_type, ++ source, ++ source_size, ++ target, ++ p_target_size ++ ); ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_certificate_signRecover return rv=%ld-'%s', *p_target_size=%u", ++ rv, ++ pkcs11h_getMessage (rv), ++ *p_target_size ++ ); ++ ++ return rv; ++} ++ ++CK_RV ++pkcs11h_certificate_signAny ( ++ IN const pkcs11h_certificate_t certificate, ++ IN const CK_MECHANISM_TYPE mech_type, ++ IN const unsigned char * const source, ++ IN const size_t source_size, ++ OUT unsigned char * const target, ++ IN OUT size_t * const p_target_size ++) { ++ CK_RV rv = CKR_OK; ++ PKCS11H_BOOL fSigned = FALSE; ++ ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ PKCS11H_ASSERT (certificate!=NULL); ++ PKCS11H_ASSERT (source!=NULL); ++ /*PKCS11H_ASSERT (target); NOT NEEDED*/ ++ PKCS11H_ASSERT (p_target_size!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_certificate_signAny entry certificate=%p, mech_type=%ld, source=%p, source_size=%u, target=%p, *p_target_size=%u", ++ (void *)certificate, ++ mech_type, ++ source, ++ source_size, ++ target, ++ target != NULL ? *p_target_size : 0 ++ ); ++ ++ if ( ++ rv == CKR_OK && ++ certificate->mask_sign_mode == 0 ++ ) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Getting key attributes" ++ ); ++ rv = _pkcs11h_certificate_getKeyAttributes (certificate); ++ } ++ ++ if ( ++ rv == CKR_OK && ++ !fSigned && ++ (certificate->mask_sign_mode & PKCS11H_SIGNMODE_MASK_SIGN) != 0 ++ ) { ++ rv = pkcs11h_certificate_sign ( ++ certificate, ++ mech_type, ++ source, ++ source_size, ++ target, ++ p_target_size ++ ); ++ ++ if (rv == CKR_OK) { ++ fSigned = TRUE; ++ } ++ else if ( ++ rv == CKR_FUNCTION_NOT_SUPPORTED || ++ rv == CKR_KEY_FUNCTION_NOT_PERMITTED ++ ) { ++ certificate->mask_sign_mode &= ~PKCS11H_SIGNMODE_MASK_SIGN; ++ rv = CKR_OK; ++ } ++ } ++ ++ if ( ++ rv == CKR_OK && ++ !fSigned && ++ (certificate->mask_sign_mode & PKCS11H_SIGNMODE_MASK_RECOVER) != 0 ++ ) { ++ rv = pkcs11h_certificate_signRecover ( ++ certificate, ++ mech_type, ++ source, ++ source_size, ++ target, ++ p_target_size ++ ); ++ ++ if (rv == CKR_OK) { ++ fSigned = TRUE; ++ } ++ else if ( ++ rv == CKR_FUNCTION_NOT_SUPPORTED || ++ rv == CKR_KEY_FUNCTION_NOT_PERMITTED ++ ) { ++ certificate->mask_sign_mode &= ~PKCS11H_SIGNMODE_MASK_RECOVER; ++ rv = CKR_OK; ++ } ++ } ++ ++ if (rv == CKR_OK && !fSigned) { ++ rv = CKR_FUNCTION_FAILED; ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_certificate_signAny return rv=%ld-'%s', *p_target_size=%p", ++ rv, ++ pkcs11h_getMessage (rv), ++ (void *)*p_target_size ++ ); ++ ++ return rv; ++} ++ ++CK_RV ++pkcs11h_certificate_decrypt ( ++ IN const pkcs11h_certificate_t certificate, ++ IN const CK_MECHANISM_TYPE mech_type, ++ IN const unsigned char * const source, ++ IN const size_t source_size, ++ OUT unsigned char * const target, ++ IN OUT size_t * const p_target_size ++) { ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ PKCS11H_ASSERT (certificate!=NULL); ++ PKCS11H_ASSERT (source!=NULL); ++ /*PKCS11H_ASSERT (target); NOT NEEDED*/ ++ PKCS11H_ASSERT (p_target_size!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_decrypt entry certificate=%p, mech_type=%ld, source=%p, source_size=%u, target=%p, *p_target_size=%u", ++ (void *)certificate, ++ mech_type, ++ source, ++ source_size, ++ target, ++ target != NULL ? *p_target_size : 0 ++ ); ++ ++ if (target == NULL) { ++ *p_target_size = 0; ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_certificate_doPrivateOperation ( ++ certificate, ++ _pkcs11h_private_op_decrypt, ++ mech_type, ++ source, ++ source_size, ++ target, ++ p_target_size ++ ); ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_decrypt return rv=%ld-'%s', *p_target_size=%u", ++ rv, ++ pkcs11h_getMessage (rv), ++ *p_target_size ++ ); ++ ++ return rv; ++} ++ ++CK_RV ++pkcs11h_certificate_create ( ++ IN const pkcs11h_certificate_id_t certificate_id, ++ IN void * const user_data, ++ IN const unsigned mask_prompt, ++ IN const int pin_cache_period, ++ OUT pkcs11h_certificate_t * const p_certificate ++) { ++ pkcs11h_certificate_t certificate = NULL; ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ /*PKCS11H_ASSERT (user_data!=NULL); NOT NEEDED */ ++ PKCS11H_ASSERT (p_certificate!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_certificate_create entry certificate_id=%p, user_data=%p, mask_prompt=%08x, pin_cache_period=%d, p_certificate=%p", ++ (void *)certificate_id, ++ user_data, ++ mask_prompt, ++ pin_cache_period, ++ (void *)p_certificate ++ ); ++ ++ *p_certificate = NULL; ++ ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_mem_malloc ((void*)&certificate, sizeof (struct pkcs11h_certificate_s))) == CKR_OK ++ ) { ++ certificate->user_data = user_data; ++ certificate->mask_prompt = mask_prompt; ++ certificate->key_handle = PKCS11H_INVALID_OBJECT_HANDLE; ++ certificate->pin_cache_period = pin_cache_period; ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_threading_mutexInit (&certificate->mutex); ++ } ++#endif ++ ++ if (rv == CKR_OK) { ++ rv = pkcs11h_certificate_duplicateCertificateId (&certificate->id, certificate_id); ++ } ++ ++ if (rv == CKR_OK) { ++ *p_certificate = certificate; ++ certificate = NULL; ++ } ++ ++ if (certificate != NULL) { ++#if defined(ENABLE_PKCS11H_THREADING) ++ _pkcs11h_threading_mutexFree (&certificate->mutex); ++#endif ++ _pkcs11h_mem_free ((void *)&certificate); ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_certificate_create return rv=%ld-'%s' *p_certificate=%p", ++ rv, ++ pkcs11h_getMessage (rv), ++ (void *)*p_certificate ++ ); ++ ++ return rv; ++} ++ ++unsigned ++pkcs11h_certificate_getPromptMask ( ++ IN const pkcs11h_certificate_t certificate ++) { ++ PKCS11H_ASSERT (certificate!=NULL); ++ ++ return certificate->mask_prompt; ++} ++ ++void ++pkcs11h_certificate_setPromptMask ( ++ IN const pkcs11h_certificate_t certificate, ++ IN const unsigned mask_prompt ++) { ++ PKCS11H_ASSERT (certificate!=NULL); ++ ++ certificate->mask_prompt = mask_prompt; ++} ++ ++void * ++pkcs11h_certificate_getUserData ( ++ IN const pkcs11h_certificate_t certificate ++) { ++ PKCS11H_ASSERT (certificate!=NULL); ++ ++ return certificate->user_data; ++} ++ ++void ++pkcs11h_certificate_setUserData ( ++ IN const pkcs11h_certificate_t certificate, ++ IN void * const user_data ++) { ++ PKCS11H_ASSERT (certificate!=NULL); ++ ++ certificate->user_data = user_data; ++} ++ ++CK_RV ++pkcs11h_certificate_getCertificateId ( ++ IN const pkcs11h_certificate_t certificate, ++ OUT pkcs11h_certificate_id_t * const p_certificate_id ++) { ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ PKCS11H_ASSERT (certificate!=NULL); ++ PKCS11H_ASSERT (p_certificate_id!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_certificate_getCertificateId entry certificate=%p, certificate_id=%p", ++ (void *)certificate, ++ (void *)p_certificate_id ++ ); ++ ++ if (rv == CKR_OK) { ++ rv = pkcs11h_certificate_duplicateCertificateId ( ++ p_certificate_id, ++ certificate->id ++ ); ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_certificate_getCertificateId return rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ return rv; ++} ++ ++CK_RV ++pkcs11h_certificate_getCertificateBlob ( ++ IN const pkcs11h_certificate_t certificate, ++ OUT unsigned char * const certificate_blob, ++ IN OUT size_t * const p_certificate_blob_size ++) { ++#if defined(ENABLE_PKCS11H_THREADING) ++ PKCS11H_BOOL mutex_locked = FALSE; ++#endif ++ CK_RV rv = CKR_OK; ++ size_t certifiate_blob_size_max = 0; ++ ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ PKCS11H_ASSERT (certificate!=NULL); ++ /*PKCS11H_ASSERT (certificate_blob!=NULL); NOT NEEDED */ ++ PKCS11H_ASSERT (p_certificate_blob_size!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_certificate_getCertificateBlob entry certificate=%p, certificate_blob=%p, *p_certificate_blob_size=%u", ++ (void *)certificate, ++ certificate_blob, ++ certificate_blob != NULL ? *p_certificate_blob_size : 0 ++ ); ++ ++ if (certificate_blob != NULL) { ++ certifiate_blob_size_max = *p_certificate_blob_size; ++ } ++ *p_certificate_blob_size = 0; ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_threading_mutexLock (&certificate->mutex)) == CKR_OK ++ ) { ++ mutex_locked = TRUE; ++ } ++#endif ++ ++ if (rv == CKR_OK && certificate->id->certificate_blob == NULL) { ++ PKCS11H_BOOL op_succeed = FALSE; ++ PKCS11H_BOOL login_retry = FALSE; ++ while (rv == CKR_OK && !op_succeed) { ++ if (certificate->session == NULL) { ++ rv = CKR_SESSION_HANDLE_INVALID; ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_certificate_loadCertificate (certificate); ++ } ++ ++ if (rv == CKR_OK) { ++ op_succeed = TRUE; ++ } ++ else { ++ if (!login_retry) { ++ login_retry = TRUE; ++ rv = _pkcs11h_certificate_resetSession ( ++ certificate, ++ TRUE, ++ FALSE ++ ); ++ } ++ } ++ } ++ } ++ ++ if ( ++ rv == CKR_OK && ++ certificate->id->certificate_blob == NULL ++ ) { ++ rv = CKR_FUNCTION_REJECTED; ++ } ++ ++ if (rv == CKR_OK) { ++ _pkcs11h_certificate_updateCertificateIdDescription (certificate->id); ++ } ++ ++ if (rv == CKR_OK) { ++ *p_certificate_blob_size = certificate->id->certificate_blob_size; ++ } ++ ++ if (certificate_blob != NULL) { ++ if ( ++ rv == CKR_OK && ++ certificate->id->certificate_blob_size > certifiate_blob_size_max ++ ) { ++ rv = CKR_BUFFER_TOO_SMALL; ++ } ++ ++ if (rv == CKR_OK) { ++ memmove ( ++ certificate_blob, ++ certificate->id->certificate_blob, ++ *p_certificate_blob_size ++ ); ++ } ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if (mutex_locked) { ++ _pkcs11h_threading_mutexRelease (&certificate->mutex); ++ mutex_locked = FALSE; ++ } ++#endif ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_certificate_getCertificateBlob return rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ return rv; ++} ++ ++#if defined(ENABLE_PKCS11H_SERIALIZATION) ++ ++CK_RV ++pkcs11h_certificate_serializeCertificateId ( ++ OUT char * const sz, ++ IN OUT size_t *max, ++ IN const pkcs11h_certificate_id_t certificate_id ++) { ++ CK_RV rv = CKR_OK; ++ size_t saved_max = 0; ++ size_t n = 0; ++ size_t _max = 0; ++ ++ /*PKCS11H_ASSERT (sz!=NULL); Not required */ ++ PKCS11H_ASSERT (max!=NULL); ++ PKCS11H_ASSERT (certificate_id!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_certificate_serializeCertificateId entry sz=%p, *max=%u, certificate_id=%p", ++ sz, ++ sz != NULL ? *max : 0, ++ (void *)certificate_id ++ ); ++ ++ if (sz != NULL) { ++ saved_max = n = *max; ++ } ++ *max = 0; ++ ++ if (rv == CKR_OK) { ++ rv = pkcs11h_token_serializeTokenId ( ++ sz, ++ &n, ++ certificate_id->token_id ++ ); ++ } ++ ++ if (rv == CKR_OK) { ++ _max = n + certificate_id->attrCKA_ID_size*2 + 1; ++ } ++ ++ if (sz != NULL) { ++ if (saved_max < _max) { ++ rv = CKR_ATTRIBUTE_VALUE_INVALID; ++ } ++ ++ if (rv == CKR_OK) { ++ sz[n-1] = '/'; ++ rv = _pkcs11h_util_binaryToHex ( ++ sz+n, ++ saved_max-n, ++ certificate_id->attrCKA_ID, ++ certificate_id->attrCKA_ID_size ++ ); ++ ++ } ++ } ++ ++ *max = _max; ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_certificate_serializeCertificateId return rv=%ld-'%s', *max=%u, sz='%s'", ++ rv, ++ pkcs11h_getMessage (rv), ++ *max, ++ sz ++ ); ++ ++ return rv; ++} ++ ++CK_RV ++pkcs11h_certificate_deserializeCertificateId ( ++ OUT pkcs11h_certificate_id_t * const p_certificate_id, ++ IN const char * const sz ++) { ++ pkcs11h_certificate_id_t certificate_id = NULL; ++ CK_RV rv = CKR_OK; ++ char *p = NULL; ++ char *_sz = NULL; ++ ++ PKCS11H_ASSERT (p_certificate_id!=NULL); ++ PKCS11H_ASSERT (sz!=NULL); ++ ++ *p_certificate_id = NULL; ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_certificate_deserializeCertificateId entry p_certificate_id=%p, sz='%s'", ++ (void *)p_certificate_id, ++ sz ++ ); ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_mem_strdup ( ++ (void *)&_sz, ++ sz ++ ); ++ } ++ ++ if (rv == CKR_OK) { ++ p = _sz; ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_certificate_newCertificateId (&certificate_id); ++ } ++ ++ if ( ++ rv == CKR_OK && ++ (p = strrchr (_sz, '/')) == NULL ++ ) { ++ rv = CKR_ATTRIBUTE_VALUE_INVALID; ++ } ++ ++ if (rv == CKR_OK) { ++ *p = '\x0'; ++ p++; ++ } ++ ++ if (rv == CKR_OK) { ++ rv = pkcs11h_token_deserializeTokenId ( ++ &certificate_id->token_id, ++ _sz ++ ); ++ } ++ ++ if (rv == CKR_OK) { ++ certificate_id->attrCKA_ID_size = strlen (p)/2; ++ } ++ ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_mem_malloc ( ++ (void *)&certificate_id->attrCKA_ID, ++ certificate_id->attrCKA_ID_size) ++ ) == CKR_OK ++ ) { ++ rv = _pkcs11h_util_hexToBinary ( ++ certificate_id->attrCKA_ID, ++ p, ++ &certificate_id->attrCKA_ID_size ++ ); ++ } ++ ++ if (rv == CKR_OK) { ++ *p_certificate_id = certificate_id; ++ certificate_id = NULL; ++ } ++ ++ if (certificate_id != NULL) { ++ pkcs11h_certificate_freeCertificateId (certificate_id); ++ certificate_id = NULL; ++ } ++ ++ if (_sz != NULL) { ++ _pkcs11h_mem_free ((void *)&_sz); ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_certificate_deserializeCertificateId return rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ return rv; ++ ++} ++ ++#endif /* ENABLE_PKCS11H_SERIALIZATION */ ++ ++CK_RV ++pkcs11h_certificate_ensureCertificateAccess ( ++ IN const pkcs11h_certificate_t certificate ++) { ++#if defined(ENABLE_PKCS11H_THREADING) ++ PKCS11H_BOOL mutex_locked_cert = FALSE; ++ PKCS11H_BOOL mutex_locked_sess = FALSE; ++#endif ++ PKCS11H_BOOL validCert = FALSE; ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ PKCS11H_ASSERT (certificate!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_certificate_ensureCertificateAccess entry certificate=%p", ++ (void *)certificate ++ ); ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_threading_mutexLock (&certificate->mutex)) == CKR_OK ++ ) { ++ mutex_locked_cert = TRUE; ++ } ++#endif ++ ++ if (!validCert && rv == CKR_OK) { ++ CK_OBJECT_HANDLE h = PKCS11H_INVALID_OBJECT_HANDLE; ++ ++ if (certificate->session == NULL) { ++ rv = CKR_SESSION_HANDLE_INVALID; ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_threading_mutexLock (&certificate->session->mutex)) == CKR_OK ++ ) { ++ mutex_locked_sess = TRUE; ++ } ++#endif ++ ++ if ( ++ (rv = _pkcs11h_session_getObjectById ( ++ certificate->session, ++ CKO_CERTIFICATE, ++ certificate->id->attrCKA_ID, ++ certificate->id->attrCKA_ID_size, ++ &h ++ )) == CKR_OK ++ ) { ++ validCert = TRUE; ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if (mutex_locked_sess) { ++ _pkcs11h_threading_mutexRelease (&certificate->session->mutex); ++ mutex_locked_sess = FALSE; ++ } ++#endif ++ ++ if (rv != CKR_OK) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Cannot access existing object rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ /* ++ * Ignore error ++ */ ++ rv = CKR_OK; ++ } ++ } ++ ++ if (!validCert && rv == CKR_OK) { ++ if ( ++ (rv = _pkcs11h_certificate_resetSession ( ++ certificate, ++ TRUE, ++ FALSE ++ )) == CKR_OK ++ ) { ++ validCert = TRUE; ++ } ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if (mutex_locked_cert) { ++ _pkcs11h_threading_mutexRelease (&certificate->mutex); ++ mutex_locked_cert = FALSE; ++ } ++#endif ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_certificate_ensureCertificateAccess return rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ return rv; ++} ++ ++CK_RV ++pkcs11h_certificate_ensureKeyAccess ( ++ IN const pkcs11h_certificate_t certificate ++) { ++#if defined(ENABLE_PKCS11H_THREADING) ++ PKCS11H_BOOL mutex_locked_cert = FALSE; ++ PKCS11H_BOOL mutex_locked_sess = FALSE; ++#endif ++ CK_RV rv = CKR_OK; ++ PKCS11H_BOOL valid_key = FALSE; ++ ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ PKCS11H_ASSERT (certificate!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_certificate_ensureKeyAccess entry certificate=%p", ++ (void *)certificate ++ ); ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_threading_mutexLock (&certificate->mutex)) == CKR_OK ++ ) { ++ mutex_locked_cert = TRUE; ++ } ++#endif ++ ++ if (!valid_key && rv == CKR_OK) { ++ ++ if (certificate->session == NULL) { ++ rv = CKR_SESSION_HANDLE_INVALID; ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_threading_mutexLock (&certificate->session->mutex)) == CKR_OK ++ ) { ++ mutex_locked_sess = TRUE; ++ } ++#endif ++ ++ if ( ++ (rv = _pkcs11h_session_getObjectById ( ++ certificate->session, ++ CKO_PRIVATE_KEY, ++ certificate->id->attrCKA_ID, ++ certificate->id->attrCKA_ID_size, ++ &certificate->key_handle ++ )) == CKR_OK ++ ) { ++ valid_key = TRUE; ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if (mutex_locked_sess) { ++ _pkcs11h_threading_mutexRelease (&certificate->session->mutex); ++ mutex_locked_sess = FALSE; ++ } ++#endif ++ ++ if (rv != CKR_OK) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Cannot access existing object rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ /* ++ * Ignore error ++ */ ++ rv = CKR_OK; ++ certificate->key_handle = PKCS11H_INVALID_OBJECT_HANDLE; ++ } ++ } ++ ++ if (!valid_key && rv == CKR_OK) { ++ if ( ++ (rv = _pkcs11h_certificate_resetSession ( ++ certificate, ++ FALSE, ++ FALSE ++ )) == CKR_OK ++ ) { ++ valid_key = TRUE; ++ } ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if (mutex_locked_sess) { ++ _pkcs11h_threading_mutexRelease (&certificate->session->mutex); ++ mutex_locked_sess = FALSE; ++ } ++#endif ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_certificate_ensureKeyAccess return rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ return rv; ++} ++ ++#endif /* ENABLE_PKCS11H_CERTIFICATE */ ++ ++#if defined(ENABLE_PKCS11H_LOCATE) ++/*======================================================================* ++ * LOCATE INTERFACE ++ *======================================================================*/ ++ ++#if defined(ENABLE_PKCS11H_TOKEN) || defined(ENABLE_PKCS11H_CERTIFICATE) ++ ++static ++CK_RV ++_pkcs11h_locate_getTokenIdBySlotId ( ++ IN const char * const slot, ++ OUT pkcs11h_token_id_t * const p_token_id ++) { ++ pkcs11h_provider_t current_provider = NULL; ++ char reference[sizeof (((pkcs11h_provider_t)NULL)->reference)]; ++ ++ CK_SLOT_ID selected_slot = PKCS11H_INVALID_SLOT_ID; ++ CK_TOKEN_INFO info; ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (slot!=NULL); ++ PKCS11H_ASSERT (p_token_id!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_locate_getTokenIdBySlotId entry slot='%s', p_token_id=%p", ++ slot, ++ (void *)p_token_id ++ ); ++ ++ *p_token_id = NULL; ++ ++ if (rv == CKR_OK) { ++ if (strchr (slot, ':') == NULL) { ++ reference[0] = '\0'; ++ selected_slot = atol (slot); ++ } ++ else { ++ char *p; ++ ++ strncpy (reference, slot, sizeof (reference)); ++ reference[sizeof (reference)-1] = '\0'; ++ ++ p = strchr (reference, ':'); ++ ++ *p = '\0'; ++ p++; ++ selected_slot = atol (p); ++ } ++ } ++ ++ if (rv == CKR_OK) { ++ current_provider=s_pkcs11h_data->providers; ++ while ( ++ current_provider != NULL && ++ reference[0] != '\0' && /* So first provider will be selected */ ++ strcmp (current_provider->reference, reference) ++ ) { ++ current_provider = current_provider->next; ++ } ++ ++ if ( ++ current_provider == NULL || ++ ( ++ current_provider != NULL && ++ !current_provider->enabled ++ ) ++ ) { ++ rv = CKR_SLOT_ID_INVALID; ++ } ++ } ++ ++ if ( ++ rv == CKR_OK && ++ (rv = current_provider->f->C_GetTokenInfo (selected_slot, &info)) == CKR_OK ++ ) { ++ rv = _pkcs11h_token_getTokenId ( ++ &info, ++ p_token_id ++ ); ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_locate_getTokenIdBySlotId return rv=%ld-'%s', *p_token_id=%p", ++ rv, ++ pkcs11h_getMessage (rv), ++ (void *)*p_token_id ++ ); ++ ++ return rv; ++} ++ ++static ++CK_RV ++_pkcs11h_locate_getTokenIdBySlotName ( ++ IN const char * const name, ++ OUT pkcs11h_token_id_t * const p_token_id ++) { ++ pkcs11h_provider_t current_provider = NULL; ++ ++ CK_SLOT_ID selected_slot = PKCS11H_INVALID_SLOT_ID; ++ CK_TOKEN_INFO info; ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_BOOL found = FALSE; ++ ++ PKCS11H_ASSERT (name!=NULL); ++ PKCS11H_ASSERT (p_token_id!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_locate_getTokenIdBySlotName entry name='%s', p_token_id=%p", ++ name, ++ (void *)p_token_id ++ ); ++ ++ *p_token_id = NULL; ++ ++ current_provider = s_pkcs11h_data->providers; ++ while ( ++ current_provider != NULL && ++ rv == CKR_OK && ++ !found ++ ) { ++ CK_SLOT_ID_PTR slots = NULL; ++ CK_ULONG slotnum; ++ CK_SLOT_ID slot_index; ++ ++ if (!current_provider->enabled) { ++ rv = CKR_CRYPTOKI_NOT_INITIALIZED; ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_getSlotList ( ++ current_provider, ++ CK_TRUE, ++ &slots, ++ &slotnum ++ ); ++ } ++ ++ for ( ++ slot_index=0; ++ ( ++ slot_index < slotnum && ++ rv == CKR_OK && ++ !found ++ ); ++ slot_index++ ++ ) { ++ CK_SLOT_INFO info; ++ ++ if ( ++ (rv = current_provider->f->C_GetSlotInfo ( ++ slots[slot_index], ++ &info ++ )) == CKR_OK ++ ) { ++ char current_name[sizeof (info.slotDescription)+1]; ++ ++ _pkcs11h_util_fixupFixedString ( ++ current_name, ++ (char *)info.slotDescription, ++ sizeof (info.slotDescription) ++ ); ++ ++ if (!strcmp (current_name, name)) { ++ found = TRUE; ++ selected_slot = slots[slot_index]; ++ } ++ } ++ ++ if (rv != CKR_OK) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Cannot get slot information for provider '%s' slot %ld rv=%ld-'%s'", ++ current_provider->manufacturerID, ++ slots[slot_index], ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ /* ++ * Ignore error ++ */ ++ rv = CKR_OK; ++ } ++ } ++ ++ if (rv != CKR_OK) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Cannot get slot list for provider '%s' rv=%ld-'%s'", ++ current_provider->manufacturerID, ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ /* ++ * Ignore error ++ */ ++ rv = CKR_OK; ++ } ++ ++ if (slots != NULL) { ++ _pkcs11h_mem_free ((void *)&slots); ++ slots = NULL; ++ } ++ ++ if (!found) { ++ current_provider = current_provider->next; ++ } ++ } ++ ++ if (rv == CKR_OK && !found) { ++ rv = CKR_SLOT_ID_INVALID; ++ } ++ ++ if ( ++ rv == CKR_OK && ++ (rv = current_provider->f->C_GetTokenInfo (selected_slot, &info)) == CKR_OK ++ ) { ++ rv = _pkcs11h_token_getTokenId ( ++ &info, ++ p_token_id ++ ); ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_locate_getTokenIdBySlotName return rv=%ld-'%s' *p_token_id=%p", ++ rv, ++ pkcs11h_getMessage (rv), ++ (void *)*p_token_id ++ ); ++ ++ return rv; ++} ++ ++static ++CK_RV ++_pkcs11h_locate_getTokenIdByLabel ( ++ IN const char * const label, ++ OUT pkcs11h_token_id_t * const p_token_id ++) { ++ pkcs11h_provider_t current_provider = NULL; ++ ++ CK_SLOT_ID selected_slot = PKCS11H_INVALID_SLOT_ID; ++ CK_TOKEN_INFO info; ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_BOOL found = FALSE; ++ ++ PKCS11H_ASSERT (label!=NULL); ++ PKCS11H_ASSERT (p_token_id!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_locate_getTokenIdByLabel entry label='%s', p_token_id=%p", ++ label, ++ (void *)p_token_id ++ ); ++ ++ *p_token_id = NULL; ++ ++ current_provider = s_pkcs11h_data->providers; ++ while ( ++ current_provider != NULL && ++ rv == CKR_OK && ++ !found ++ ) { ++ CK_SLOT_ID_PTR slots = NULL; ++ CK_ULONG slotnum; ++ CK_SLOT_ID slot_index; ++ ++ if (!current_provider->enabled) { ++ rv = CKR_CRYPTOKI_NOT_INITIALIZED; ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_getSlotList ( ++ current_provider, ++ CK_TRUE, ++ &slots, ++ &slotnum ++ ); ++ } ++ ++ for ( ++ slot_index=0; ++ ( ++ slot_index < slotnum && ++ rv == CKR_OK && ++ !found ++ ); ++ slot_index++ ++ ) { ++ CK_TOKEN_INFO info; ++ ++ if (rv == CKR_OK) { ++ rv = current_provider->f->C_GetTokenInfo ( ++ slots[slot_index], ++ &info ++ ); ++ } ++ ++ if (rv == CKR_OK) { ++ char current_label[sizeof (info.label)+1]; ++ ++ _pkcs11h_util_fixupFixedString ( ++ current_label, ++ (char *)info.label, ++ sizeof (info.label) ++ ); ++ ++ if (!strcmp (current_label, label)) { ++ found = TRUE; ++ selected_slot = slots[slot_index]; ++ } ++ } ++ ++ if (rv != CKR_OK) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Cannot get token information for provider '%s' slot %ld rv=%ld-'%s'", ++ current_provider->manufacturerID, ++ slots[slot_index], ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ /* ++ * Ignore error ++ */ ++ rv = CKR_OK; ++ } ++ } ++ ++ if (rv != CKR_OK) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Cannot get slot list for provider '%s' rv=%ld-'%s'", ++ current_provider->manufacturerID, ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ /* ++ * Ignore error ++ */ ++ rv = CKR_OK; ++ } ++ ++ if (slots != NULL) { ++ _pkcs11h_mem_free ((void *)&slots); ++ slots = NULL; ++ } ++ ++ if (!found) { ++ current_provider = current_provider->next; ++ } ++ } ++ ++ if (rv == CKR_OK && !found) { ++ rv = CKR_SLOT_ID_INVALID; ++ } ++ ++ if ( ++ rv == CKR_OK && ++ (rv = current_provider->f->C_GetTokenInfo (selected_slot, &info)) == CKR_OK ++ ) { ++ rv = _pkcs11h_token_getTokenId ( ++ &info, ++ p_token_id ++ ); ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_locate_getTokenIdByLabel return rv=%ld-'%s', *p_token_id=%p", ++ rv, ++ pkcs11h_getMessage (rv), ++ (void *)*p_token_id ++ ); ++ ++ return rv; ++} ++ ++CK_RV ++pkcs11h_locate_token ( ++ IN const char * const slot_type, ++ IN const char * const slot, ++ IN void * const user_data, ++ IN const unsigned mask_prompt, ++ OUT pkcs11h_token_id_t * const p_token_id ++) { ++#if defined(ENABLE_PKCS11H_THREADING) ++ PKCS11H_BOOL mutex_locked = FALSE; ++#endif ++ ++ pkcs11h_token_id_t dummy_token_id = NULL; ++ pkcs11h_token_id_t token_id = NULL; ++ PKCS11H_BOOL found = FALSE; ++ ++ CK_RV rv = CKR_OK; ++ ++ unsigned nRetry = 0; ++ ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ PKCS11H_ASSERT (slot_type!=NULL); ++ PKCS11H_ASSERT (slot!=NULL); ++ /*PKCS11H_ASSERT (user_data) NOT NEEDED */ ++ PKCS11H_ASSERT (p_token_id!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_locate_token entry slot_type='%s', slot='%s', user_data=%p, p_token_id=%p", ++ slot_type, ++ slot, ++ user_data, ++ (void *)p_token_id ++ ); ++ ++ *p_token_id = NULL; ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_threading_mutexLock (&s_pkcs11h_data->mutexes.global)) == CKR_OK ++ ) { ++ mutex_locked = TRUE; ++ } ++#endif ++ ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_token_newTokenId (&dummy_token_id)) == CKR_OK ++ ) { ++ /* ++ * Temperary slot id ++ */ ++ strcpy (dummy_token_id->display, "SLOT("); ++ strncat (dummy_token_id->display, slot_type, sizeof (dummy_token_id->display)-1-strlen (dummy_token_id->display)); ++ strncat (dummy_token_id->display, "=", sizeof (dummy_token_id->display)-1-strlen (dummy_token_id->display)); ++ strncat (dummy_token_id->display, slot, sizeof (dummy_token_id->display)-1-strlen (dummy_token_id->display)); ++ strncat (dummy_token_id->display, ")", sizeof (dummy_token_id->display)-1-strlen (dummy_token_id->display)); ++ dummy_token_id->display[sizeof (dummy_token_id->display)-1] = 0; ++ } ++ ++ while (rv == CKR_OK && !found) { ++ if (!strcmp (slot_type, "id")) { ++ rv = _pkcs11h_locate_getTokenIdBySlotId ( ++ slot, ++ &token_id ++ ); ++ } ++ else if (!strcmp (slot_type, "name")) { ++ rv = _pkcs11h_locate_getTokenIdBySlotName ( ++ slot, ++ &token_id ++ ); ++ } ++ else if (!strcmp (slot_type, "label")) { ++ rv = _pkcs11h_locate_getTokenIdByLabel ( ++ slot, ++ &token_id ++ ); ++ } ++ else { ++ rv = CKR_ARGUMENTS_BAD; ++ } ++ ++ if (rv == CKR_OK) { ++ found = TRUE; ++ } ++ ++ /* ++ * Ignore error, since we have what we ++ * want in found. ++ */ ++ if (rv != CKR_OK && rv != CKR_ARGUMENTS_BAD) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: pkcs11h_locate_token failed rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ rv = CKR_OK; ++ } ++ ++ if (rv == CKR_OK && !found && (mask_prompt & PKCS11H_PROMPT_MAST_ALLOW_CARD_PROMPT) == 0) { ++ rv = CKR_TOKEN_NOT_PRESENT; ++ } ++ ++ if (rv == CKR_OK && !found) { ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Calling token_prompt hook for '%s'", ++ dummy_token_id->display ++ ); ++ ++ if ( ++ !s_pkcs11h_data->hooks.token_prompt ( ++ s_pkcs11h_data->hooks.token_prompt_data, ++ user_data, ++ dummy_token_id, ++ nRetry++ ++ ) ++ ) { ++ rv = CKR_CANCEL; ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: token_prompt returned %ld", ++ rv ++ ); ++ } ++ } ++ ++ if (rv == CKR_OK && !found) { ++ rv = CKR_SLOT_ID_INVALID; ++ } ++ ++ if (rv == CKR_OK) { ++ *p_token_id = token_id; ++ token_id = NULL; ++ } ++ ++ if (dummy_token_id != NULL) { ++ pkcs11h_token_freeTokenId (dummy_token_id); ++ dummy_token_id = NULL; ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if (mutex_locked) { ++ _pkcs11h_threading_mutexRelease (&s_pkcs11h_data->mutexes.global); ++ mutex_locked = FALSE; ++ } ++#endif ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_locate_token return rv=%ld-'%s', *p_token_id=%p", ++ rv, ++ pkcs11h_getMessage (rv), ++ (void *)*p_token_id ++ ); ++ ++ return rv; ++} ++ ++#endif /* ENABLE_PKCS11H_TOKEN || ENABLE_PKCS11H_CERTIFICATE */ ++ ++#if defined(ENABLE_PKCS11H_CERTIFICATE) ++ ++static ++CK_RV ++_pkcs11h_locate_getCertificateIdByLabel ( ++ IN const pkcs11h_session_t session, ++ IN OUT const pkcs11h_certificate_id_t certificate_id, ++ IN const char * const label ++) { ++#if defined(ENABLE_PKCS11H_THREADING) ++ PKCS11H_BOOL mutex_locked = FALSE; ++#endif ++ CK_OBJECT_CLASS cert_filter_class = CKO_CERTIFICATE; ++ CK_ATTRIBUTE cert_filter[] = { ++ {CKA_CLASS, &cert_filter_class, sizeof (cert_filter_class)}, ++ {CKA_LABEL, (CK_BYTE_PTR)label, strlen (label)} ++ }; ++ ++ CK_OBJECT_HANDLE *objects = NULL; ++ CK_ULONG objects_found = 0; ++ CK_RV rv = CKR_OK; ++ ++ CK_ULONG i; ++ ++ PKCS11H_ASSERT (session!=NULL); ++ PKCS11H_ASSERT (certificate_id!=NULL); ++ PKCS11H_ASSERT (label!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_locate_getCertificateIdByLabel entry session=%p, certificate_id=%p, label='%s'", ++ (void *)session, ++ (void *)certificate_id, ++ label ++ ); ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_threading_mutexLock (&session->mutex)) == CKR_OK ++ ) { ++ mutex_locked = TRUE; ++ } ++#endif ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_validate (session); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_findObjects ( ++ session, ++ cert_filter, ++ sizeof (cert_filter) / sizeof (CK_ATTRIBUTE), ++ &objects, ++ &objects_found ++ ); ++ } ++ ++ for (i=0;rv == CKR_OK && i < objects_found;i++) { ++ CK_ATTRIBUTE attrs[] = { ++ {CKA_ID, NULL, 0}, ++ {CKA_VALUE, NULL, 0} ++ }; ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_getObjectAttributes ( ++ session, ++ objects[i], ++ attrs, ++ sizeof (attrs) / sizeof (CK_ATTRIBUTE) ++ ); ++ } ++ ++ if ( ++ rv == CKR_OK && ++ _pkcs11h_certificate_isBetterCertificate ( ++ certificate_id->certificate_blob, ++ certificate_id->certificate_blob_size, ++ attrs[1].pValue, ++ attrs[1].ulValueLen ++ ) ++ ) { ++ if (certificate_id->attrCKA_ID != NULL) { ++ _pkcs11h_mem_free ((void *)&certificate_id->attrCKA_ID); ++ } ++ if (certificate_id->certificate_blob != NULL) { ++ _pkcs11h_mem_free ((void *)&certificate_id->certificate_blob); ++ } ++ rv = _pkcs11h_mem_duplicate ( ++ (void *)&certificate_id->attrCKA_ID, ++ &certificate_id->attrCKA_ID_size, ++ attrs[0].pValue, ++ attrs[0].ulValueLen ++ ); ++ rv = _pkcs11h_mem_duplicate ( ++ (void *)&certificate_id->certificate_blob, ++ &certificate_id->certificate_blob_size, ++ attrs[1].pValue, ++ attrs[1].ulValueLen ++ ); ++ } ++ ++ if (rv != CKR_OK) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Cannot get object attribute for provider '%s' object %ld rv=%ld-'%s'", ++ session->provider->manufacturerID, ++ objects[i], ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ /* ++ * Ignore error ++ */ ++ rv = CKR_OK; ++ } ++ ++ _pkcs11h_session_freeObjectAttributes ( ++ attrs, ++ sizeof (attrs) / sizeof (CK_ATTRIBUTE) ++ ); ++ } ++ ++ if ( ++ rv == CKR_OK && ++ certificate_id->certificate_blob == NULL ++ ) { ++ rv = CKR_ATTRIBUTE_VALUE_INVALID; ++ } ++ ++ if (objects != NULL) { ++ _pkcs11h_mem_free ((void *)&objects); ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if (mutex_locked) { ++ _pkcs11h_threading_mutexRelease (&session->mutex); ++ mutex_locked = FALSE; ++ } ++#endif ++ ++ /* ++ * No need to free allocated objects ++ * on error, since the certificate_id ++ * should be free by caller. ++ */ ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_locate_getCertificateIdByLabel return rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ return rv; ++} ++ ++static ++CK_RV ++_pkcs11h_locate_getCertificateIdBySubject ( ++ IN const pkcs11h_session_t session, ++ IN OUT const pkcs11h_certificate_id_t certificate_id, ++ IN const char * const subject ++) { ++#if defined(ENABLE_PKCS11H_THREADING) ++ PKCS11H_BOOL mutex_locked = FALSE; ++#endif ++ CK_OBJECT_CLASS cert_filter_class = CKO_CERTIFICATE; ++ CK_ATTRIBUTE cert_filter[] = { ++ {CKA_CLASS, &cert_filter_class, sizeof (cert_filter_class)} ++ }; ++ ++ CK_OBJECT_HANDLE *objects = NULL; ++ CK_ULONG objects_found = 0; ++ CK_RV rv = CKR_OK; ++ ++ CK_ULONG i; ++ ++ PKCS11H_ASSERT (session!=NULL); ++ PKCS11H_ASSERT (certificate_id!=NULL); ++ PKCS11H_ASSERT (subject!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_locate_getCertificateIdBySubject entry session=%p, certificate_id=%p, subject='%s'", ++ (void *)session, ++ (void *)certificate_id, ++ subject ++ ); ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_threading_mutexLock (&session->mutex)) == CKR_OK ++ ) { ++ mutex_locked = TRUE; ++ } ++#endif ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_validate (session); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_findObjects ( ++ session, ++ cert_filter, ++ sizeof (cert_filter) / sizeof (CK_ATTRIBUTE), ++ &objects, ++ &objects_found ++ ); ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if (mutex_locked) { ++ _pkcs11h_threading_mutexRelease (&session->mutex); ++ mutex_locked = FALSE; ++ } ++#endif ++ ++ for (i=0;rv == CKR_OK && i < objects_found;i++) { ++ CK_ATTRIBUTE attrs[] = { ++ {CKA_ID, NULL, 0}, ++ {CKA_VALUE, NULL, 0} ++ }; ++ char current_subject[1024]; ++ current_subject[0] = '\0'; ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_getObjectAttributes ( ++ session, ++ objects[i], ++ attrs, ++ sizeof (attrs) / sizeof (CK_ATTRIBUTE) ++ ); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_certificate_getDN ( ++ attrs[1].pValue, ++ attrs[1].ulValueLen, ++ current_subject, ++ sizeof (current_subject) ++ ); ++ } ++ ++ if ( ++ rv == CKR_OK && ++ !strcmp (subject, current_subject) && ++ _pkcs11h_certificate_isBetterCertificate ( ++ certificate_id->certificate_blob, ++ certificate_id->certificate_blob_size, ++ attrs[1].pValue, ++ attrs[1].ulValueLen ++ ) ++ ) { ++ if (certificate_id->attrCKA_ID != NULL) { ++ _pkcs11h_mem_free ((void *)&certificate_id->attrCKA_ID); ++ } ++ if (certificate_id->certificate_blob != NULL) { ++ _pkcs11h_mem_free ((void *)&certificate_id->certificate_blob); ++ } ++ rv = _pkcs11h_mem_duplicate ( ++ (void *)&certificate_id->attrCKA_ID, ++ &certificate_id->attrCKA_ID_size, ++ attrs[0].pValue, ++ attrs[0].ulValueLen ++ ); ++ rv = _pkcs11h_mem_duplicate ( ++ (void *)&certificate_id->certificate_blob, ++ &certificate_id->certificate_blob_size, ++ attrs[1].pValue, ++ attrs[1].ulValueLen ++ ); ++ } ++ ++ if (rv != CKR_OK) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Cannot get object attribute for provider '%s' object %ld rv=%ld-'%s'", ++ session->provider->manufacturerID, ++ objects[i], ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ /* ++ * Ignore error ++ */ ++ rv = CKR_OK; ++ } ++ ++ _pkcs11h_session_freeObjectAttributes ( ++ attrs, ++ sizeof (attrs) / sizeof (CK_ATTRIBUTE) ++ ); ++ } ++ ++ if ( ++ rv == CKR_OK && ++ certificate_id->certificate_blob == NULL ++ ) { ++ rv = CKR_ATTRIBUTE_VALUE_INVALID; ++ } ++ ++ if (objects != NULL) { ++ _pkcs11h_mem_free ((void *)&objects); ++ } ++ ++ /* ++ * No need to free allocated objects ++ * on error, since the certificate_id ++ * should be free by caller. ++ */ ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_locate_getCertificateIdBySubject return rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ return rv; ++} ++ ++CK_RV ++pkcs11h_locate_certificate ( ++ IN const char * const slot_type, ++ IN const char * const slot, ++ IN const char * const id_type, ++ IN const char * const id, ++ IN void * const user_data, ++ IN const unsigned mask_prompt, ++ OUT pkcs11h_certificate_id_t * const p_certificate_id ++) { ++#if defined(ENABLE_PKCS11H_THREADING) ++ PKCS11H_BOOL mutex_locked = FALSE; ++#endif ++ pkcs11h_certificate_id_t certificate_id = NULL; ++ pkcs11h_session_t session = NULL; ++ PKCS11H_BOOL op_succeed = FALSE; ++ PKCS11H_BOOL login_retry = FALSE; ++ ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ PKCS11H_ASSERT (slot_type!=NULL); ++ PKCS11H_ASSERT (slot!=NULL); ++ PKCS11H_ASSERT (id_type!=NULL); ++ PKCS11H_ASSERT (id!=NULL); ++ /*PKCS11H_ASSERT (user_data) NOT NEEDED */ ++ PKCS11H_ASSERT (p_certificate_id!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_locateCertificate entry slot_type='%s', slot='%s', id_type='%s', id='%s', user_data=%p, mask_prompt=%08x, p_certificate_id=%p", ++ slot_type, ++ slot, ++ id_type, ++ id, ++ user_data, ++ mask_prompt, ++ (void *)p_certificate_id ++ ); ++ ++ *p_certificate_id = NULL; ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_certificate_newCertificateId (&certificate_id); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = pkcs11h_locate_token ( ++ slot_type, ++ slot, ++ user_data, ++ mask_prompt, ++ &certificate_id->token_id ++ ); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_getSessionByTokenId ( ++ certificate_id->token_id, ++ &session ++ ); ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_threading_mutexLock (&s_pkcs11h_data->mutexes.global)) == CKR_OK ++ ) { ++ mutex_locked = TRUE; ++ } ++#endif ++ ++ while (rv == CKR_OK && !op_succeed) { ++ if (!strcmp (id_type, "id")) { ++ certificate_id->attrCKA_ID_size = strlen (id)/2; ++ ++ if (certificate_id->attrCKA_ID_size == 0) { ++ rv = CKR_FUNCTION_FAILED; ++ } ++ ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_mem_malloc ( ++ (void*)&certificate_id->attrCKA_ID, ++ certificate_id->attrCKA_ID_size ++ )) == CKR_OK ++ ) { ++ _pkcs11h_util_hexToBinary ( ++ certificate_id->attrCKA_ID, ++ id, ++ &certificate_id->attrCKA_ID_size ++ ); ++ } ++ } ++ else if (!strcmp (id_type, "label")) { ++ rv = _pkcs11h_locate_getCertificateIdByLabel ( ++ session, ++ certificate_id, ++ id ++ ); ++ } ++ else if (!strcmp (id_type, "subject")) { ++ rv = _pkcs11h_locate_getCertificateIdBySubject ( ++ session, ++ certificate_id, ++ id ++ ); ++ } ++ else { ++ rv = CKR_ARGUMENTS_BAD; ++ } ++ ++ if (rv == CKR_OK) { ++ op_succeed = TRUE; ++ } ++ else { ++ if (!login_retry) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Get certificate failed: %ld:'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ rv = _pkcs11h_session_login ( ++ session, ++ TRUE, ++ TRUE, ++ user_data, ++ mask_prompt ++ ); ++ ++ login_retry = TRUE; ++ } ++ } ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if (mutex_locked) { ++ _pkcs11h_threading_mutexRelease (&s_pkcs11h_data->mutexes.global); ++ mutex_locked = FALSE; ++ } ++#endif ++ ++ if (rv == CKR_OK) { ++ *p_certificate_id = certificate_id; ++ certificate_id = NULL; ++ } ++ ++ if (certificate_id != NULL) { ++ pkcs11h_certificate_freeCertificateId (certificate_id); ++ certificate_id = NULL; ++ } ++ ++ if (session != NULL) { ++ _pkcs11h_session_release (session); ++ session = NULL; ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_locateCertificate return rv=%ld-'%s' *p_certificate_id=%p", ++ rv, ++ pkcs11h_getMessage (rv), ++ (void *)*p_certificate_id ++ ); ++ ++ return rv; ++} ++ ++#endif /* ENABLE_PKCS11H_CERTIFICATE */ ++ ++#endif /* ENABLE_PKCS11H_LOCATE */ ++ ++#if defined(ENABLE_PKCS11H_ENUM) ++/*======================================================================* ++ * ENUM INTERFACE ++ *======================================================================*/ ++ ++#if defined(ENABLE_PKCS11H_TOKEN) ++ ++CK_RV ++pkcs11h_token_freeTokenIdList ( ++ IN const pkcs11h_token_id_list_t token_id_list ++) { ++ pkcs11h_token_id_list_t _id = token_id_list; ++ ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ /*PKCS11H_ASSERT (token_id_list!=NULL); NOT NEEDED*/ ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_token_freeTokenIdList entry token_id_list=%p", ++ (void *)token_id_list ++ ); ++ ++ while (_id != NULL) { ++ pkcs11h_token_id_list_t x = _id; ++ _id = _id->next; ++ if (x->token_id != NULL) { ++ pkcs11h_token_freeTokenId (x->token_id); ++ } ++ x->next = NULL; ++ _pkcs11h_mem_free ((void *)&x); ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_token_freeTokenIdList return" ++ ); ++ ++ return CKR_OK; ++} ++ ++CK_RV ++pkcs11h_token_enumTokenIds ( ++ IN const int method, ++ OUT pkcs11h_token_id_list_t * const p_token_id_list ++) { ++#if defined(ENABLE_PKCS11H_THREADING) ++ PKCS11H_BOOL mutex_locked = FALSE; ++#endif ++ ++ pkcs11h_token_id_list_t token_id_list = NULL; ++ pkcs11h_provider_t current_provider; ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ PKCS11H_ASSERT (p_token_id_list!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_token_enumTokenIds entry p_token_id_list=%p", ++ (void *)p_token_id_list ++ ); ++ ++ *p_token_id_list = NULL; ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_threading_mutexLock (&s_pkcs11h_data->mutexes.global)) == CKR_OK ++ ) { ++ mutex_locked = TRUE; ++ } ++#endif ++ ++ for ( ++ current_provider = s_pkcs11h_data->providers; ++ ( ++ current_provider != NULL && ++ rv == CKR_OK ++ ); ++ current_provider = current_provider->next ++ ) { ++ CK_SLOT_ID_PTR slots = NULL; ++ CK_ULONG slotnum; ++ CK_SLOT_ID slot_index; ++ ++ if (!current_provider->enabled) { ++ rv = CKR_CRYPTOKI_NOT_INITIALIZED; ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_getSlotList ( ++ current_provider, ++ CK_TRUE, ++ &slots, ++ &slotnum ++ ); ++ } ++ ++ for ( ++ slot_index=0; ++ ( ++ slot_index < slotnum && ++ rv == CKR_OK ++ ); ++ slot_index++ ++ ) { ++ pkcs11h_token_id_list_t entry = NULL; ++ CK_TOKEN_INFO info; ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_mem_malloc ((void *)&entry, sizeof (struct pkcs11h_token_id_list_s)); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = current_provider->f->C_GetTokenInfo ( ++ slots[slot_index], ++ &info ++ ); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_token_getTokenId ( ++ &info, ++ &entry->token_id ++ ); ++ } ++ ++ if (rv == CKR_OK) { ++ entry->next = token_id_list; ++ token_id_list = entry; ++ entry = NULL; ++ } ++ ++ if (entry != NULL) { ++ pkcs11h_token_freeTokenIdList (entry); ++ entry = NULL; ++ } ++ } ++ ++ if (rv != CKR_OK) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Cannot get slot list for provider '%s' rv=%ld-'%s'", ++ current_provider->manufacturerID, ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ /* ++ * Ignore error ++ */ ++ rv = CKR_OK; ++ } ++ ++ if (slots != NULL) { ++ _pkcs11h_mem_free ((void *)&slots); ++ slots = NULL; ++ } ++ } ++ ++ if (rv == CKR_OK && method == PKCS11H_ENUM_METHOD_CACHE) { ++ pkcs11h_session_t session = NULL; ++ ++ for ( ++ session = s_pkcs11h_data->sessions; ++ session != NULL && rv == CKR_OK; ++ session = session->next ++ ) { ++ pkcs11h_token_id_list_t entry = NULL; ++ PKCS11H_BOOL found = FALSE; ++ ++ for ( ++ entry = token_id_list; ++ entry != NULL && !found; ++ entry = entry->next ++ ) { ++ if ( ++ pkcs11h_token_sameTokenId ( ++ session->token_id, ++ entry->token_id ++ ) ++ ) { ++ found = TRUE; ++ } ++ } ++ ++ if (!found) { ++ entry = NULL; ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_mem_malloc ( ++ (void *)&entry, ++ sizeof (struct pkcs11h_token_id_list_s) ++ ); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = pkcs11h_token_duplicateTokenId ( ++ &entry->token_id, ++ session->token_id ++ ); ++ } ++ ++ if (rv == CKR_OK) { ++ entry->next = token_id_list; ++ token_id_list = entry; ++ entry = NULL; ++ } ++ ++ if (entry != NULL) { ++ if (entry->token_id != NULL) { ++ pkcs11h_token_freeTokenId (entry->token_id); ++ } ++ _pkcs11h_mem_free ((void *)&entry); ++ } ++ } ++ } ++ } ++ ++ if (rv == CKR_OK) { ++ *p_token_id_list = token_id_list; ++ token_id_list = NULL; ++ } ++ ++ if (token_id_list != NULL) { ++ pkcs11h_token_freeTokenIdList (token_id_list); ++ token_id_list = NULL; ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if (mutex_locked) { ++ rv = _pkcs11h_threading_mutexRelease (&s_pkcs11h_data->mutexes.global); ++ mutex_locked = FALSE; ++ } ++#endif ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_token_enumTokenIds return rv=%ld-'%s', *p_token_id_list=%p", ++ rv, ++ pkcs11h_getMessage (rv), ++ (void *)p_token_id_list ++ ); ++ ++ return rv; ++} ++ ++#endif ++ ++#if defined(ENABLE_PKCS11H_DATA) ++ ++CK_RV ++pkcs11h_data_freeDataIdList ( ++ IN const pkcs11h_data_id_list_t data_id_list ++) { ++ pkcs11h_data_id_list_t _id = data_id_list; ++ ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ /*PKCS11H_ASSERT (data_id_list!=NULL); NOT NEEDED*/ ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_freeDataIdList entry token_id_list=%p", ++ (void *)data_id_list ++ ); ++ ++ while (_id != NULL) { ++ pkcs11h_data_id_list_t x = _id; ++ _id = _id->next; ++ ++ if (x->application != NULL) { ++ _pkcs11h_mem_free ((void *)&x->application); ++ } ++ if (x->label != NULL) { ++ _pkcs11h_mem_free ((void *)&x->label); ++ } ++ _pkcs11h_mem_free ((void *)&x); ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_token_freeDataIdList return" ++ ); ++ ++ return CKR_OK; ++} ++ ++CK_RV ++pkcs11h_data_enumDataObjects ( ++ IN const pkcs11h_token_id_t token_id, ++ IN const PKCS11H_BOOL is_public, ++ IN void * const user_data, ++ IN const unsigned mask_prompt, ++ OUT pkcs11h_data_id_list_t * const p_data_id_list ++) { ++#if defined(ENABLE_PKCS11H_THREADING) ++ PKCS11H_BOOL mutex_locked = FALSE; ++#endif ++ pkcs11h_session_t session = NULL; ++ pkcs11h_data_id_list_t data_id_list = NULL; ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_BOOL op_succeed = FALSE; ++ PKCS11H_BOOL login_retry = FALSE; ++ ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ PKCS11H_ASSERT (p_data_id_list!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_data_enumDataObjects entry token_id=%p, is_public=%d, user_data=%p, mask_prompt=%08x, p_data_id_list=%p", ++ (void *)token_id, ++ is_public ? 1 : 0, ++ user_data, ++ mask_prompt, ++ (void *)p_data_id_list ++ ); ++ ++ *p_data_id_list = NULL; ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_getSessionByTokenId ( ++ token_id, ++ &session ++ ); ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_threading_mutexLock (&session->mutex)) == CKR_OK ++ ) { ++ mutex_locked = TRUE; ++ } ++#endif ++ ++ while (rv == CKR_OK && !op_succeed) { ++ ++ CK_OBJECT_CLASS class = CKO_DATA; ++ CK_ATTRIBUTE filter[] = { ++ {CKA_CLASS, (void *)&class, sizeof (class)} ++ }; ++ CK_OBJECT_HANDLE *objects = NULL; ++ CK_ULONG objects_found = 0; ++ ++ CK_ULONG i; ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_validate (session); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_findObjects ( ++ session, ++ filter, ++ sizeof (filter) / sizeof (CK_ATTRIBUTE), ++ &objects, ++ &objects_found ++ ); ++ } ++ ++ for (i = 0;rv == CKR_OK && i < objects_found;i++) { ++ pkcs11h_data_id_list_t entry = NULL; ++ ++ CK_ATTRIBUTE attrs[] = { ++ {CKA_APPLICATION, NULL, 0}, ++ {CKA_LABEL, NULL, 0} ++ }; ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_getObjectAttributes ( ++ session, ++ objects[i], ++ attrs, ++ sizeof (attrs) / sizeof (CK_ATTRIBUTE) ++ ); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_mem_malloc ( ++ (void *)&entry, ++ sizeof (struct pkcs11h_data_id_list_s) ++ ); ++ } ++ ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_mem_malloc ( ++ (void *)&entry->application, ++ attrs[0].ulValueLen+1 ++ )) == CKR_OK ++ ) { ++ memmove (entry->application, attrs[0].pValue, attrs[0].ulValueLen); ++ entry->application[attrs[0].ulValueLen] = '\0'; ++ } ++ ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_mem_malloc ( ++ (void *)&entry->label, ++ attrs[1].ulValueLen+1 ++ )) == CKR_OK ++ ) { ++ memmove (entry->label, attrs[1].pValue, attrs[1].ulValueLen); ++ entry->label[attrs[1].ulValueLen] = '\0'; ++ } ++ ++ if (rv == CKR_OK) { ++ entry->next = data_id_list; ++ data_id_list = entry; ++ entry = NULL; ++ } ++ ++ _pkcs11h_session_freeObjectAttributes ( ++ attrs, ++ sizeof (attrs) / sizeof (CK_ATTRIBUTE) ++ ); ++ ++ if (entry != NULL) { ++ if (entry->application != NULL) { ++ _pkcs11h_mem_free ((void *)&entry->application); ++ } ++ if (entry->label != NULL) { ++ _pkcs11h_mem_free ((void *)&entry->label); ++ } ++ _pkcs11h_mem_free ((void *)&entry); ++ } ++ } ++ ++ if (objects != NULL) { ++ _pkcs11h_mem_free ((void *)&objects); ++ } ++ ++ if (rv == CKR_OK) { ++ op_succeed = TRUE; ++ } ++ else { ++ if (!login_retry) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Enumerate data objects failed rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ login_retry = TRUE; ++ rv = _pkcs11h_session_login ( ++ session, ++ is_public, ++ TRUE, ++ user_data, ++ mask_prompt ++ ); ++ } ++ } ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if (mutex_locked) { ++ _pkcs11h_threading_mutexRelease (&session->mutex); ++ mutex_locked = FALSE; ++ } ++#endif ++ ++ if (rv == CKR_OK) { ++ *p_data_id_list = data_id_list; ++ data_id_list = NULL; ++ } ++ ++ if (session != NULL) { ++ _pkcs11h_session_release (session); ++ session = NULL; ++ } ++ ++ if (data_id_list != NULL) { ++ pkcs11h_data_freeDataIdList (data_id_list); ++ data_id_list = NULL; ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_data_enumDataObjects return rv=%ld-'%s', *p_data_id_list=%p", ++ rv, ++ pkcs11h_getMessage (rv), ++ (void *)*p_data_id_list ++ ); ++ ++ return rv; ++} ++ ++#endif /* ENABLE_PKCS11H_DATA */ ++ ++#if defined(ENABLE_PKCS11H_CERTIFICATE) ++ ++static ++CK_RV ++_pkcs11h_certificate_enumSessionCertificates ( ++ IN const pkcs11h_session_t session, ++ IN void * const user_data, ++ IN const unsigned mask_prompt ++) { ++#if defined(ENABLE_PKCS11H_THREADING) ++ PKCS11H_BOOL mutex_locked = FALSE; ++#endif ++ PKCS11H_BOOL op_succeed = FALSE; ++ PKCS11H_BOOL login_retry = FALSE; ++ ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (session!=NULL); ++ /*PKCS11H_ASSERT (user_data) NOT NEEDED */ ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_certificate_enumSessionCertificates entry session=%p, user_data=%p, mask_prompt=%08x", ++ (void *)session, ++ user_data, ++ mask_prompt ++ ); ++ ++ /* THREADS: NO NEED TO LOCK, GLOBAL CACHE IS LOCKED */ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_threading_mutexLock (&session->mutex)) == CKR_OK ++ ) { ++ mutex_locked = TRUE; ++ } ++#endif ++ ++ while (rv == CKR_OK && !op_succeed) { ++ CK_OBJECT_CLASS cert_filter_class = CKO_CERTIFICATE; ++ CK_ATTRIBUTE cert_filter[] = { ++ {CKA_CLASS, &cert_filter_class, sizeof (cert_filter_class)} ++ }; ++ ++ CK_OBJECT_HANDLE *objects = NULL; ++ CK_ULONG objects_found = 0; ++ ++ CK_ULONG i; ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_validate (session); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_findObjects ( ++ session, ++ cert_filter, ++ sizeof (cert_filter) / sizeof (CK_ATTRIBUTE), ++ &objects, ++ &objects_found ++ ); ++ } ++ ++ for (i=0;rv == CKR_OK && i < objects_found;i++) { ++ pkcs11h_certificate_id_t certificate_id = NULL; ++ pkcs11h_certificate_id_list_t new_element = NULL; ++ ++ CK_ATTRIBUTE attrs[] = { ++ {CKA_ID, NULL, 0}, ++ {CKA_VALUE, NULL, 0} ++ }; ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_getObjectAttributes ( ++ session, ++ objects[i], ++ attrs, ++ sizeof (attrs) / sizeof (CK_ATTRIBUTE) ++ ); ++ } ++ ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_certificate_newCertificateId (&certificate_id)) == CKR_OK ++ ) { ++ rv = pkcs11h_token_duplicateTokenId ( ++ &certificate_id->token_id, ++ session->token_id ++ ); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_mem_duplicate ( ++ (void*)&certificate_id->attrCKA_ID, ++ &certificate_id->attrCKA_ID_size, ++ attrs[0].pValue, ++ attrs[0].ulValueLen ++ ); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_mem_duplicate ( ++ (void*)&certificate_id->certificate_blob, ++ &certificate_id->certificate_blob_size, ++ attrs[1].pValue, ++ attrs[1].ulValueLen ++ ); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_certificate_updateCertificateIdDescription (certificate_id); ++ } ++ ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_mem_malloc ( ++ (void *)&new_element, ++ sizeof (struct pkcs11h_certificate_id_list_s) ++ )) == CKR_OK ++ ) { ++ new_element->next = session->cached_certs; ++ new_element->certificate_id = certificate_id; ++ certificate_id = NULL; ++ ++ session->cached_certs = new_element; ++ new_element = NULL; ++ } ++ ++ if (certificate_id != NULL) { ++ pkcs11h_certificate_freeCertificateId (certificate_id); ++ certificate_id = NULL; ++ } ++ ++ if (new_element != NULL) { ++ _pkcs11h_mem_free ((void *)&new_element); ++ new_element = NULL; ++ } ++ ++ _pkcs11h_session_freeObjectAttributes ( ++ attrs, ++ sizeof (attrs) / sizeof (CK_ATTRIBUTE) ++ ); ++ ++ if (rv != CKR_OK) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Cannot get object attribute for provider '%s' object %ld rv=%ld-'%s'", ++ session->provider->manufacturerID, ++ objects[i], ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ /* ++ * Ignore error ++ */ ++ rv = CKR_OK; ++ } ++ } ++ ++ if (objects != NULL) { ++ _pkcs11h_mem_free ((void *)&objects); ++ } ++ ++ if (rv == CKR_OK) { ++ op_succeed = TRUE; ++ } ++ else { ++ if (!login_retry) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Get certificate attributes failed: %ld:'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ rv = _pkcs11h_session_login ( ++ session, ++ TRUE, ++ TRUE, ++ user_data, ++ (mask_prompt & PKCS11H_PROMPT_MASK_ALLOW_PIN_PROMPT) ++ ); ++ ++ login_retry = TRUE; ++ } ++ } ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if (mutex_locked) { ++ _pkcs11h_threading_mutexRelease (&session->mutex); ++ mutex_locked = FALSE; ++ } ++#endif ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_certificate_enumSessionCertificates return rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ return rv; ++} ++ ++static ++CK_RV ++_pkcs11h_certificate_splitCertificateIdList ( ++ IN const pkcs11h_certificate_id_list_t cert_id_all, ++ OUT pkcs11h_certificate_id_list_t * const p_cert_id_issuers_list, ++ OUT pkcs11h_certificate_id_list_t * const p_cert_id_end_list ++) { ++ typedef struct info_s { ++ struct info_s *next; ++ pkcs11h_certificate_id_t e; ++#if defined(USE_PKCS11H_OPENSSL) ++ X509 *x509; ++#elif defined(USE_PKCS11H_GNUTLS) ++ gnutls_x509_crt_t cert; ++#endif ++ PKCS11H_BOOL is_issuer; ++ } *info_t; ++ ++ pkcs11h_certificate_id_list_t cert_id_issuers_list = NULL; ++ pkcs11h_certificate_id_list_t cert_id_end_list = NULL; ++ ++ info_t head = NULL; ++ info_t info = NULL; ++ ++ CK_RV rv = CKR_OK; ++ ++ /*PKCS11H_ASSERT (cert_id_all!=NULL); NOT NEEDED */ ++ /*PKCS11H_ASSERT (p_cert_id_issuers_list!=NULL); NOT NEEDED*/ ++ PKCS11H_ASSERT (p_cert_id_end_list!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_certificate_splitCertificateIdList entry cert_id_all=%p, p_cert_id_issuers_list=%p, p_cert_id_end_list=%p", ++ (void *)cert_id_all, ++ (void *)p_cert_id_issuers_list, ++ (void *)p_cert_id_end_list ++ ); ++ ++ if (p_cert_id_issuers_list != NULL) { ++ *p_cert_id_issuers_list = NULL; ++ } ++ *p_cert_id_end_list = NULL; ++ ++ if (rv == CKR_OK) { ++ pkcs11h_certificate_id_list_t entry = NULL; ++ ++ for ( ++ entry = cert_id_all; ++ entry != NULL && rv == CKR_OK; ++ entry = entry->next ++ ) { ++ info_t new_info = NULL; ++ ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_mem_malloc ((void *)&new_info, sizeof (struct info_s))) == CKR_OK && ++ entry->certificate_id->certificate_blob != NULL ++ ) { ++#if defined(USE_PKCS11H_OPENSSL) ++ pkcs11_openssl_d2i_t d2i = (pkcs11_openssl_d2i_t)entry->certificate_id->certificate_blob; ++#endif ++ ++ new_info->next = head; ++ new_info->e = entry->certificate_id; ++#if defined(USE_PKCS11H_OPENSSL) ++ new_info->x509 = X509_new (); ++ if ( ++ new_info->x509 != NULL && ++ !d2i_X509 ( ++ &new_info->x509, ++ &d2i, ++ entry->certificate_id->certificate_blob_size ++ ) ++ ) { ++ X509_free (new_info->x509); ++ new_info->x509 = NULL; ++ } ++#elif defined(USE_PKCS11H_GNUTLS) ++ if (gnutls_x509_crt_init (&new_info->cert) != GNUTLS_E_SUCCESS) { ++ /* gnutls sets output */ ++ new_info->cert = NULL; ++ } ++ else { ++ gnutls_datum_t datum = { ++ entry->certificate_id->certificate_blob, ++ entry->certificate_id->certificate_blob_size ++ }; ++ ++ if ( ++ gnutls_x509_crt_import ( ++ new_info->cert, ++ &datum, ++ GNUTLS_X509_FMT_DER ++ ) != GNUTLS_E_SUCCESS ++ ) { ++ gnutls_x509_crt_deinit (new_info->cert); ++ new_info->cert = NULL; ++ } ++ } ++#else ++#error Invalid configuration. ++#endif ++ head = new_info; ++ new_info = NULL; ++ } ++ } ++ ++ } ++ ++ if (rv == CKR_OK) { ++ for ( ++ info = head; ++ info != NULL; ++ info = info->next ++ ) { ++ info_t info2 = NULL; ++#if defined(USE_PKCS11H_OPENSSL) ++ EVP_PKEY *pub = X509_get_pubkey (info->x509); ++#endif ++ ++ for ( ++ info2 = head; ++ info2 != NULL && !info->is_issuer; ++ info2 = info2->next ++ ) { ++ if (info != info2) { ++#if defined(USE_PKCS11H_OPENSSL) ++ if ( ++ info->x509 != NULL && ++ info2->x509 != NULL && ++ !X509_NAME_cmp ( ++ X509_get_subject_name (info->x509), ++ X509_get_issuer_name (info2->x509) ++ ) && ++ X509_verify (info2->x509, pub) == 1 ++ ) { ++ info->is_issuer = TRUE; ++ } ++#elif defined(USE_PKCS11H_GNUTLS) ++ unsigned result; ++ ++ if ( ++ info->cert != NULL && ++ info2->cert != NULL && ++ gnutls_x509_crt_verify ( ++ info2->cert, ++ &info->cert, ++ 1, ++ 0, ++ &result ++ ) && ++ (result & GNUTLS_CERT_INVALID) == 0 ++ ) { ++ info->is_issuer = TRUE; ++ } ++#else ++#error Invalid configuration. ++#endif ++ } ++ ++ } ++ ++#if defined(USE_PKCS11H_OPENSSL) ++ if (pub != NULL) { ++ EVP_PKEY_free (pub); ++ pub = NULL; ++ } ++#endif ++ } ++ } ++ ++ if (rv == CKR_OK) { ++ for ( ++ info = head; ++ info != NULL && rv == CKR_OK; ++ info = info->next ++ ) { ++ pkcs11h_certificate_id_list_t new_entry = NULL; ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_mem_malloc ( ++ (void *)&new_entry, ++ sizeof (struct pkcs11h_certificate_id_list_s) ++ ); ++ } ++ ++ if ( ++ rv == CKR_OK && ++ (rv = pkcs11h_certificate_duplicateCertificateId ( ++ &new_entry->certificate_id, ++ info->e ++ )) == CKR_OK ++ ) { ++ /* ++ * Should not free base list ++ */ ++ info->e = NULL; ++ } ++ ++ if (rv == CKR_OK) { ++ if (info->is_issuer) { ++ new_entry->next = cert_id_issuers_list; ++ cert_id_issuers_list = new_entry; ++ new_entry = NULL; ++ } ++ else { ++ new_entry->next = cert_id_end_list; ++ cert_id_end_list = new_entry; ++ new_entry = NULL; ++ } ++ } ++ ++ if (new_entry != NULL) { ++ if (new_entry->certificate_id != NULL) { ++ pkcs11h_certificate_freeCertificateId (new_entry->certificate_id); ++ } ++ _pkcs11h_mem_free ((void *)&new_entry); ++ } ++ } ++ } ++ ++ if (rv == CKR_OK) { ++ while (head != NULL) { ++ info_t entry = head; ++ head = head->next; ++ ++#if defined(USE_PKCS11H_OPENSSL) ++ if (entry->x509 != NULL) { ++ X509_free (entry->x509); ++ entry->x509 = NULL; ++ } ++#elif defined(USE_PKCS11H_GNUTLS) ++ if (entry->cert != NULL) { ++ gnutls_x509_crt_deinit (entry->cert); ++ entry->cert = NULL; ++ } ++#else ++#error Invalid configuration. ++#endif ++ ++ _pkcs11h_mem_free ((void *)&entry); ++ } ++ } ++ ++ if (rv == CKR_OK && p_cert_id_issuers_list != NULL ) { ++ *p_cert_id_issuers_list = cert_id_issuers_list; ++ cert_id_issuers_list = NULL; ++ } ++ ++ if (rv == CKR_OK) { ++ *p_cert_id_end_list = cert_id_end_list; ++ cert_id_end_list = NULL; ++ } ++ ++ if (cert_id_issuers_list != NULL) { ++ pkcs11h_certificate_freeCertificateIdList (cert_id_issuers_list); ++ } ++ ++ if (cert_id_end_list != NULL) { ++ pkcs11h_certificate_freeCertificateIdList (cert_id_end_list); ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_certificate_splitCertificateIdList return rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ return rv; ++} ++ ++CK_RV ++pkcs11h_certificate_freeCertificateIdList ( ++ IN const pkcs11h_certificate_id_list_t cert_id_list ++) { ++ pkcs11h_certificate_id_list_t _id = cert_id_list; ++ ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ /*PKCS11H_ASSERT (cert_id_list!=NULL); NOT NEEDED*/ ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_certificate_freeCertificateIdList entry cert_id_list=%p", ++ (void *)cert_id_list ++ ); ++ ++ while (_id != NULL) { ++ pkcs11h_certificate_id_list_t x = _id; ++ _id = _id->next; ++ if (x->certificate_id != NULL) { ++ pkcs11h_certificate_freeCertificateId (x->certificate_id); ++ } ++ x->next = NULL; ++ _pkcs11h_mem_free ((void *)&x); ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_certificate_freeCertificateIdList return" ++ ); ++ ++ return CKR_OK; ++} ++ ++CK_RV ++pkcs11h_certificate_enumTokenCertificateIds ( ++ IN const pkcs11h_token_id_t token_id, ++ IN const int method, ++ IN void * const user_data, ++ IN const unsigned mask_prompt, ++ OUT pkcs11h_certificate_id_list_t * const p_cert_id_issuers_list, ++ OUT pkcs11h_certificate_id_list_t * const p_cert_id_end_list ++) { ++#if defined(ENABLE_PKCS11H_THREADING) ++ PKCS11H_BOOL mutex_locked = FALSE; ++#endif ++ pkcs11h_session_t session = NULL; ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ PKCS11H_ASSERT (token_id!=NULL); ++ /*PKCS11H_ASSERT (user_data) NOT NEEDED */ ++ /*PKCS11H_ASSERT (p_cert_id_issuers_list!=NULL); NOT NEEDED*/ ++ PKCS11H_ASSERT (p_cert_id_end_list!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_certificate_enumTokenCertificateIds entry token_id=%p, method=%d, user_data=%p, mask_prompt=%08x, p_cert_id_issuers_list=%p, p_cert_id_end_list=%p", ++ (void *)token_id, ++ method, ++ user_data, ++ mask_prompt, ++ (void *)p_cert_id_issuers_list, ++ (void *)p_cert_id_end_list ++ ); ++ ++ if (p_cert_id_issuers_list != NULL) { ++ *p_cert_id_issuers_list = NULL; ++ } ++ *p_cert_id_end_list = NULL; ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_threading_mutexLock (&s_pkcs11h_data->mutexes.cache)) == CKR_OK ++ ) { ++ mutex_locked = TRUE; ++ } ++#endif ++ ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_session_getSessionByTokenId ( ++ token_id, ++ &session ++ )) == CKR_OK ++ ) { ++ if (method == PKCS11H_ENUM_METHOD_RELOAD) { ++ pkcs11h_certificate_freeCertificateIdList (session->cached_certs); ++ session->cached_certs = NULL; ++ } ++ ++ if (session->cached_certs == NULL) { ++ rv = _pkcs11h_certificate_enumSessionCertificates (session, user_data, mask_prompt); ++ } ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_certificate_splitCertificateIdList ( ++ session->cached_certs, ++ p_cert_id_issuers_list, ++ p_cert_id_end_list ++ ); ++ } ++ ++ if (session != NULL) { ++ _pkcs11h_session_release (session); ++ } ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if (mutex_locked) { ++ _pkcs11h_threading_mutexRelease (&s_pkcs11h_data->mutexes.cache); ++ mutex_locked = FALSE; ++ } ++#endif ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_certificate_enumTokenCertificateIds return rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ return rv; ++} ++ ++CK_RV ++pkcs11h_certificate_enumCertificateIds ( ++ IN const int method, ++ IN void * const user_data, ++ IN const unsigned mask_prompt, ++ OUT pkcs11h_certificate_id_list_t * const p_cert_id_issuers_list, ++ OUT pkcs11h_certificate_id_list_t * const p_cert_id_end_list ++) { ++#if defined(ENABLE_PKCS11H_THREADING) ++ PKCS11H_BOOL mutex_locked = FALSE; ++#endif ++ pkcs11h_certificate_id_list_t cert_id_list = NULL; ++ pkcs11h_provider_t current_provider; ++ pkcs11h_session_t current_session; ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_ASSERT (s_pkcs11h_data!=NULL); ++ PKCS11H_ASSERT (s_pkcs11h_data->initialized); ++ /*PKCS11H_ASSERT (user_data!=NULL); NOT NEEDED*/ ++ /*PKCS11H_ASSERT (p_cert_id_issuers_list!=NULL); NOT NEEDED*/ ++ PKCS11H_ASSERT (p_cert_id_end_list!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_certificate_enumCertificateIds entry method=%d, mask_prompt=%08x, p_cert_id_issuers_list=%p, p_cert_id_end_list=%p", ++ method, ++ mask_prompt, ++ (void *)p_cert_id_issuers_list, ++ (void *)p_cert_id_end_list ++ ); ++ ++ if (p_cert_id_issuers_list != NULL) { ++ *p_cert_id_issuers_list = NULL; ++ } ++ *p_cert_id_end_list = NULL; ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_threading_mutexLock (&s_pkcs11h_data->mutexes.cache)) == CKR_OK ++ ) { ++ mutex_locked = TRUE; ++ } ++#endif ++ ++ for ( ++ current_session = s_pkcs11h_data->sessions; ++ current_session != NULL; ++ current_session = current_session->next ++ ) { ++ current_session->touch = FALSE; ++ if (method == PKCS11H_ENUM_METHOD_RELOAD) { ++ pkcs11h_certificate_freeCertificateIdList (current_session->cached_certs); ++ current_session->cached_certs = NULL; ++ } ++ } ++ ++ for ( ++ current_provider = s_pkcs11h_data->providers; ++ ( ++ current_provider != NULL && ++ rv == CKR_OK ++ ); ++ current_provider = current_provider->next ++ ) { ++ CK_SLOT_ID_PTR slots = NULL; ++ CK_ULONG slotnum; ++ CK_SLOT_ID slot_index; ++ ++ if (!current_provider->enabled) { ++ rv = CKR_CRYPTOKI_NOT_INITIALIZED; ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_session_getSlotList ( ++ current_provider, ++ CK_TRUE, ++ &slots, ++ &slotnum ++ ); ++ } ++ ++ for ( ++ slot_index=0; ++ ( ++ slot_index < slotnum && ++ rv == CKR_OK ++ ); ++ slot_index++ ++ ) { ++ pkcs11h_session_t session = NULL; ++ pkcs11h_token_id_t token_id = NULL; ++ CK_TOKEN_INFO info; ++ ++ if (rv == CKR_OK) { ++ rv = current_provider->f->C_GetTokenInfo ( ++ slots[slot_index], ++ &info ++ ); ++ } ++ ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_token_getTokenId ( ++ &info, ++ &token_id ++ )) == CKR_OK && ++ (rv = _pkcs11h_session_getSessionByTokenId ( ++ token_id, ++ &session ++ )) == CKR_OK ++ ) { ++ session->touch = TRUE; ++ ++ if (session->cached_certs == NULL) { ++ rv = _pkcs11h_certificate_enumSessionCertificates (session, user_data, mask_prompt); ++ } ++ } ++ ++ if (rv != CKR_OK) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Cannot get token information for provider '%s' slot %ld rv=%ld-'%s'", ++ current_provider->manufacturerID, ++ slots[slot_index], ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ /* ++ * Ignore error ++ */ ++ rv = CKR_OK; ++ } ++ ++ if (session != NULL) { ++ _pkcs11h_session_release (session); ++ session = NULL; ++ } ++ ++ if (token_id != NULL) { ++ pkcs11h_token_freeTokenId (token_id); ++ token_id = NULL; ++ } ++ } ++ ++ if (rv != CKR_OK) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Cannot get slot list for provider '%s' rv=%ld-'%s'", ++ current_provider->manufacturerID, ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ /* ++ * Ignore error ++ */ ++ rv = CKR_OK; ++ } ++ ++ if (slots != NULL) { ++ _pkcs11h_mem_free ((void *)&slots); ++ slots = NULL; ++ } ++ } ++ ++ for ( ++ current_session = s_pkcs11h_data->sessions; ++ ( ++ current_session != NULL && ++ rv == CKR_OK ++ ); ++ current_session = current_session->next ++ ) { ++ if ( ++ method == PKCS11H_ENUM_METHOD_CACHE || ++ ( ++ ( ++ method == PKCS11H_ENUM_METHOD_RELOAD || ++ method == PKCS11H_ENUM_METHOD_CACHE_EXIST ++ ) && ++ current_session->touch ++ ) ++ ) { ++ pkcs11h_certificate_id_list_t entry = NULL; ++ ++ for ( ++ entry = current_session->cached_certs; ++ ( ++ entry != NULL && ++ rv == CKR_OK ++ ); ++ entry = entry->next ++ ) { ++ pkcs11h_certificate_id_list_t new_entry = NULL; ++ ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_mem_malloc ( ++ (void *)&new_entry, ++ sizeof (struct pkcs11h_certificate_id_list_s) ++ )) == CKR_OK && ++ (rv = pkcs11h_certificate_duplicateCertificateId ( ++ &new_entry->certificate_id, ++ entry->certificate_id ++ )) == CKR_OK ++ ) { ++ new_entry->next = cert_id_list; ++ cert_id_list = new_entry; ++ new_entry = NULL; ++ } ++ ++ if (new_entry != NULL) { ++ new_entry->next = NULL; ++ pkcs11h_certificate_freeCertificateIdList (new_entry); ++ new_entry = NULL; ++ } ++ } ++ } ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_certificate_splitCertificateIdList ( ++ cert_id_list, ++ p_cert_id_issuers_list, ++ p_cert_id_end_list ++ ); ++ } ++ ++ if (cert_id_list != NULL) { ++ pkcs11h_certificate_freeCertificateIdList (cert_id_list); ++ cert_id_list = NULL; ++ } ++ ++ ++#if defined(ENABLE_PKCS11H_THREADING) ++ if (mutex_locked) { ++ _pkcs11h_threading_mutexRelease (&s_pkcs11h_data->mutexes.cache); ++ mutex_locked = FALSE; ++ } ++#endif ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_certificate_enumCertificateIds return rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ return rv; ++} ++ ++#endif /* ENABLE_PKCS11H_CERTIFICATE */ ++ ++#endif /* ENABLE_PKCS11H_ENUM */ ++ ++#if defined(ENABLE_PKCS11H_SLOTEVENT) ++/*======================================================================* ++ * SLOTEVENT INTERFACE ++ *======================================================================*/ ++ ++static ++unsigned long ++_pkcs11h_slotevent_checksum ( ++ IN const unsigned char * const p, ++ IN const size_t s ++) { ++ unsigned long r = 0; ++ size_t i; ++ for (i=0;imanufacturerID ++ ); ++ ++ if (rv == CKR_OK && !provider->enabled) { ++ rv = CKR_OPERATION_NOT_INITIALIZED; ++ } ++ ++ if (rv == CKR_OK) { ++ ++ if (provider->slot_poll_interval == 0) { ++ provider->slot_poll_interval = PKCS11H_DEFAULT_SLOTEVENT_POLL; ++ } ++ ++ /* ++ * If we cannot finalize, we cannot cause ++ * WaitForSlotEvent to terminate ++ */ ++ if (!provider->should_finalize) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Setup slotevent provider='%s' mode hardset to poll", ++ provider->manufacturerID ++ ); ++ provider->slot_event_method = PKCS11H_SLOTEVENT_METHOD_POLL; ++ } ++ ++ if ( ++ provider->slot_event_method == PKCS11H_SLOTEVENT_METHOD_AUTO || ++ provider->slot_event_method == PKCS11H_SLOTEVENT_METHOD_TRIGGER ++ ) { ++ if ( ++ provider->f->C_WaitForSlotEvent ( ++ CKF_DONT_BLOCK, ++ &slot, ++ NULL_PTR ++ ) == CKR_FUNCTION_NOT_SUPPORTED ++ ) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Setup slotevent provider='%s' mode is poll", ++ provider->manufacturerID ++ ); ++ ++ provider->slot_event_method = PKCS11H_SLOTEVENT_METHOD_POLL; ++ } ++ else { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Setup slotevent provider='%s' mode is trigger", ++ provider->manufacturerID ++ ); ++ ++ provider->slot_event_method = PKCS11H_SLOTEVENT_METHOD_TRIGGER; ++ } ++ } ++ } ++ ++ if (provider->slot_event_method == PKCS11H_SLOTEVENT_METHOD_TRIGGER) { ++ while ( ++ !s_pkcs11h_data->slotevent.should_terminate && ++ provider->enabled && ++ rv == CKR_OK && ++ (rv = provider->f->C_WaitForSlotEvent ( ++ 0, ++ &slot, ++ NULL_PTR ++ )) == CKR_OK ++ ) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Slotevent provider='%s' event", ++ provider->manufacturerID ++ ); ++ ++ _pkcs11h_threading_condSignal (&s_pkcs11h_data->slotevent.cond_event); ++ } ++ } ++ else { ++ unsigned long ulLastChecksum = 0; ++ PKCS11H_BOOL is_first_time = TRUE; ++ ++ while ( ++ !s_pkcs11h_data->slotevent.should_terminate && ++ provider->enabled && ++ rv == CKR_OK ++ ) { ++ unsigned long ulCurrentChecksum = 0; ++ ++ CK_SLOT_ID_PTR slots = NULL; ++ CK_ULONG slotnum; ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Slotevent provider='%s' poll", ++ provider->manufacturerID ++ ); ++ ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_session_getSlotList ( ++ provider, ++ TRUE, ++ &slots, ++ &slotnum ++ )) == CKR_OK ++ ) { ++ CK_ULONG i; ++ ++ for (i=0;if->C_GetTokenInfo (slots[i], &info) == CKR_OK) { ++ ulCurrentChecksum += ( ++ _pkcs11h_slotevent_checksum ( ++ info.label, ++ sizeof (info.label) ++ ) + ++ _pkcs11h_slotevent_checksum ( ++ info.manufacturerID, ++ sizeof (info.manufacturerID) ++ ) + ++ _pkcs11h_slotevent_checksum ( ++ info.model, ++ sizeof (info.model) ++ ) + ++ _pkcs11h_slotevent_checksum ( ++ info.serialNumber, ++ sizeof (info.serialNumber) ++ ) ++ ); ++ } ++ } ++ } ++ ++ if (rv == CKR_OK) { ++ if (is_first_time) { ++ is_first_time = FALSE; ++ } ++ else { ++ if (ulLastChecksum != ulCurrentChecksum) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Slotevent provider='%s' event", ++ provider->manufacturerID ++ ); ++ ++ _pkcs11h_threading_condSignal (&s_pkcs11h_data->slotevent.cond_event); ++ } ++ } ++ ulLastChecksum = ulCurrentChecksum; ++ } ++ ++ if (slots != NULL) { ++ _pkcs11h_mem_free ((void *)&slots); ++ } ++ ++ if (!s_pkcs11h_data->slotevent.should_terminate) { ++ _pkcs11h_threading_sleep (provider->slot_poll_interval); ++ } ++ } ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_slotevent_provider provider='%s' return", ++ provider->manufacturerID ++ ); ++ ++ return NULL; ++} ++ ++static ++void * ++_pkcs11h_slotevent_manager ( ++ IN void *p ++) { ++ PKCS11H_BOOL first_time = TRUE; ++ ++ (void)p; ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_slotevent_manager entry" ++ ); ++ ++ /* ++ * Trigger hook, so application may ++ * depend on initial slot change ++ */ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Calling slotevent hook" ++ ); ++ s_pkcs11h_data->hooks.slotevent (s_pkcs11h_data->hooks.slotevent_data); ++ ++ while ( ++ first_time || /* Must enter wait or mutex will never be free */ ++ !s_pkcs11h_data->slotevent.should_terminate ++ ) { ++ pkcs11h_provider_t current_provider; ++ ++ first_time = FALSE; ++ ++ /* ++ * Start each provider thread ++ * if not already started. ++ * This is required in order to allow ++ * adding new providers. ++ */ ++ for ( ++ current_provider = s_pkcs11h_data->providers; ++ current_provider != NULL; ++ current_provider = current_provider->next ++ ) { ++ if (!current_provider->enabled) { ++ if (current_provider->slotevent_thread == PKCS11H_THREAD_NULL) { ++ _pkcs11h_threading_threadStart ( ++ ¤t_provider->slotevent_thread, ++ _pkcs11h_slotevent_provider, ++ current_provider ++ ); ++ } ++ } ++ else { ++ if (current_provider->slotevent_thread != PKCS11H_THREAD_NULL) { ++ _pkcs11h_threading_threadJoin (¤t_provider->slotevent_thread); ++ } ++ } ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_slotevent_manager waiting for slotevent" ++ ); ++ _pkcs11h_threading_condWait (&s_pkcs11h_data->slotevent.cond_event, PKCS11H_COND_INFINITE); ++ ++ if (s_pkcs11h_data->slotevent.skip_event) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Slotevent skipping event" ++ ); ++ s_pkcs11h_data->slotevent.skip_event = FALSE; ++ } ++ else { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Calling slotevent hook" ++ ); ++ s_pkcs11h_data->hooks.slotevent (s_pkcs11h_data->hooks.slotevent_data); ++ } ++ } ++ ++ { ++ pkcs11h_provider_t current_provider; ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_slotevent_manager joining threads" ++ ); ++ ++ ++ for ( ++ current_provider = s_pkcs11h_data->providers; ++ current_provider != NULL; ++ current_provider = current_provider->next ++ ) { ++ if (current_provider->slotevent_thread != PKCS11H_THREAD_NULL) { ++ _pkcs11h_threading_threadJoin (¤t_provider->slotevent_thread); ++ } ++ } ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_slotevent_manager return" ++ ); ++ ++ return NULL; ++} ++ ++static ++CK_RV ++_pkcs11h_slotevent_init () { ++ CK_RV rv = CKR_OK; ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_slotevent_init entry" ++ ); ++ ++ if (!s_pkcs11h_data->slotevent.initialized) { ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_threading_condInit (&s_pkcs11h_data->slotevent.cond_event); ++ } ++ ++ if (rv == CKR_OK) { ++ rv = _pkcs11h_threading_threadStart ( ++ &s_pkcs11h_data->slotevent.thread, ++ _pkcs11h_slotevent_manager, ++ NULL ++ ); ++ } ++ ++ if (rv == CKR_OK) { ++ s_pkcs11h_data->slotevent.initialized = TRUE; ++ } ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_slotevent_init return rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ return rv; ++} ++ ++static ++CK_RV ++_pkcs11h_slotevent_notify () { ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_slotevent_notify entry" ++ ); ++ ++ if (s_pkcs11h_data->slotevent.initialized) { ++ s_pkcs11h_data->slotevent.skip_event = TRUE; ++ _pkcs11h_threading_condSignal (&s_pkcs11h_data->slotevent.cond_event); ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_slotevent_notify return" ++ ); ++ ++ return CKR_OK; ++} ++ ++static ++CK_RV ++_pkcs11h_slotevent_terminate () { ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_slotevent_terminate entry" ++ ); ++ ++ if (s_pkcs11h_data->slotevent.initialized) { ++ s_pkcs11h_data->slotevent.should_terminate = TRUE; ++ ++ _pkcs11h_slotevent_notify (); ++ ++ if (s_pkcs11h_data->slotevent.thread != PKCS11H_THREAD_NULL) { ++ _pkcs11h_threading_threadJoin (&s_pkcs11h_data->slotevent.thread); ++ } ++ ++ _pkcs11h_threading_condFree (&s_pkcs11h_data->slotevent.cond_event); ++ s_pkcs11h_data->slotevent.initialized = FALSE; ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_slotevent_terminate return" ++ ); ++ ++ return CKR_OK; ++} ++ ++#endif ++ ++#if defined(ENABLE_PKCS11H_OPENSSL) ++/*======================================================================* ++ * OPENSSL INTERFACE ++ *======================================================================*/ ++ ++static ++pkcs11h_openssl_session_t ++_pkcs11h_openssl_get_openssl_session ( ++ IN OUT const RSA *rsa ++) { ++ pkcs11h_openssl_session_t session; ++ ++ PKCS11H_ASSERT (rsa!=NULL); ++#if OPENSSL_VERSION_NUMBER < 0x00907000L ++ session = (pkcs11h_openssl_session_t)RSA_get_app_data ((RSA *)rsa); ++#else ++ session = (pkcs11h_openssl_session_t)RSA_get_app_data (rsa); ++#endif ++ PKCS11H_ASSERT (session!=NULL); ++ ++ return session; ++} ++ ++static ++pkcs11h_certificate_t ++_pkcs11h_openssl_get_pkcs11h_certificate ( ++ IN OUT const RSA *rsa ++) { ++ pkcs11h_openssl_session_t session = _pkcs11h_openssl_get_openssl_session (rsa); ++ ++ PKCS11H_ASSERT (session!=NULL); ++ PKCS11H_ASSERT (session->certificate!=NULL); ++ ++ return session->certificate; ++} ++ ++#if OPENSSL_VERSION_NUMBER < 0x00907000L ++static ++int ++_pkcs11h_openssl_dec ( ++ IN int flen, ++ IN unsigned char *from, ++ OUT unsigned char *to, ++ IN OUT RSA *rsa, ++ IN int padding ++) { ++#else ++static ++int ++_pkcs11h_openssl_dec ( ++ IN int flen, ++ IN const unsigned char *from, ++ OUT unsigned char *to, ++ IN OUT RSA *rsa, ++ IN int padding ++) { ++#endif ++ PKCS11H_ASSERT (from!=NULL); ++ PKCS11H_ASSERT (to!=NULL); ++ PKCS11H_ASSERT (rsa!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_openssl_dec entered - flen=%d, from=%p, to=%p, rsa=%p, padding=%d", ++ flen, ++ from, ++ to, ++ (void *)rsa, ++ padding ++ ); ++ ++ PKCS11H_LOG ( ++ PKCS11H_LOG_ERROR, ++ "PKCS#11: Private key decryption is not supported" ++ ); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_openssl_dec return" ++ ); ++ ++ return -1; ++} ++ ++#if OPENSSL_VERSION_NUMBER < 0x00907000L ++static ++int ++_pkcs11h_openssl_sign ( ++ IN int type, ++ IN unsigned char *m, ++ IN unsigned int m_len, ++ OUT unsigned char *sigret, ++ OUT unsigned int *siglen, ++ IN OUT RSA *rsa ++) { ++#else ++static ++int ++_pkcs11h_openssl_sign ( ++ IN int type, ++ IN const unsigned char *m, ++ IN unsigned int m_len, ++ OUT unsigned char *sigret, ++ OUT unsigned int *siglen, ++ IN OUT const RSA *rsa ++) { ++#endif ++ pkcs11h_certificate_t certificate = _pkcs11h_openssl_get_pkcs11h_certificate (rsa); ++ PKCS11H_BOOL session_locked = FALSE; ++ CK_RV rv = CKR_OK; ++ ++ int myrsa_size = 0; ++ ++ unsigned char *enc_alloc = NULL; ++ unsigned char *enc = NULL; ++ int enc_len = 0; ++ ++ PKCS11H_ASSERT (m!=NULL); ++ PKCS11H_ASSERT (sigret!=NULL); ++ PKCS11H_ASSERT (siglen!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_openssl_sign entered - type=%d, m=%p, m_len=%u, signret=%p, *signlen=%u, rsa=%p", ++ type, ++ m, ++ m_len, ++ sigret, ++ sigret != NULL ? *siglen : 0, ++ (void *)rsa ++ ); ++ ++ if (rv == CKR_OK) { ++ myrsa_size=RSA_size(rsa); ++ } ++ ++ if (type == NID_md5_sha1) { ++ if (rv == CKR_OK) { ++ enc = (unsigned char *)m; ++ enc_len = m_len; ++ } ++ } ++ else { ++ X509_SIG sig; ++ ASN1_TYPE parameter; ++ X509_ALGOR algor; ++ ASN1_OCTET_STRING digest; ++ unsigned char *p = NULL; ++ ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_mem_malloc ((void*)&enc, myrsa_size+1)) == CKR_OK ++ ) { ++ enc_alloc = enc; ++ } ++ ++ if (rv == CKR_OK) { ++ sig.algor = &algor; ++ } ++ ++ if ( ++ rv == CKR_OK && ++ (sig.algor->algorithm = OBJ_nid2obj (type)) == NULL ++ ) { ++ rv = CKR_FUNCTION_FAILED; ++ } ++ ++ if ( ++ rv == CKR_OK && ++ sig.algor->algorithm->length == 0 ++ ) { ++ rv = CKR_KEY_SIZE_RANGE; ++ } ++ ++ if (rv == CKR_OK) { ++ parameter.type = V_ASN1_NULL; ++ parameter.value.ptr = NULL; ++ ++ sig.algor->parameter = ¶meter; ++ ++ sig.digest = &digest; ++ sig.digest->data = (unsigned char *)m; ++ sig.digest->length = m_len; ++ } ++ ++ if ( ++ rv == CKR_OK && ++ (enc_len=i2d_X509_SIG (&sig, NULL)) < 0 ++ ) { ++ rv = CKR_FUNCTION_FAILED; ++ } ++ ++ /* ++ * d_X509_SIG increments pointer! ++ */ ++ p = enc; ++ ++ if ( ++ rv == CKR_OK && ++ (enc_len=i2d_X509_SIG (&sig, &p)) < 0 ++ ) { ++ rv = CKR_FUNCTION_FAILED; ++ } ++ } ++ ++ if ( ++ rv == CKR_OK && ++ enc_len > (myrsa_size-RSA_PKCS1_PADDING_SIZE) ++ ) { ++ rv = CKR_KEY_SIZE_RANGE; ++ } ++ ++ if ( ++ rv == CKR_OK && ++ (rv = pkcs11h_certificate_lockSession (certificate)) == CKR_OK ++ ) { ++ session_locked = TRUE; ++ } ++ ++ if (rv == CKR_OK) { ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG1, ++ "PKCS#11: Performing signature" ++ ); ++ ++ *siglen = myrsa_size; ++ ++ if ( ++ (rv = pkcs11h_certificate_signAny ( ++ certificate, ++ CKM_RSA_PKCS, ++ enc, ++ enc_len, ++ sigret, ++ siglen ++ )) != CKR_OK ++ ) { ++ PKCS11H_LOG (PKCS11H_LOG_WARN, "PKCS#11: Cannot perform signature %ld:'%s'", rv, pkcs11h_getMessage (rv)); ++ } ++ } ++ ++ if (session_locked) { ++ pkcs11h_certificate_releaseSession (certificate); ++ session_locked = FALSE; ++ } ++ ++ if (enc_alloc != NULL) { ++ _pkcs11h_mem_free ((void *)&enc_alloc); ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_openssl_sign - return rv=%ld-'%s'", ++ rv, ++ pkcs11h_getMessage (rv) ++ ); ++ ++ return rv == CKR_OK ? 1 : -1; ++} ++ ++static ++int ++_pkcs11h_openssl_finish ( ++ IN OUT RSA *rsa ++) { ++ pkcs11h_openssl_session_t openssl_session = _pkcs11h_openssl_get_openssl_session (rsa); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_openssl_finish - entered rsa=%p", ++ (void *)rsa ++ ); ++ ++ RSA_set_app_data (rsa, NULL); ++ ++ if (openssl_session->orig_finish != NULL) { ++ openssl_session->orig_finish (rsa); ++ ++#ifdef BROKEN_OPENSSL_ENGINE ++ { ++ /* We get called TWICE here, once for ++ * releasing the key and also for ++ * releasing the engine. ++ * To prevent endless recursion, FIRST ++ * clear rsa->engine, THEN call engine->finish ++ */ ++ ENGINE *e = rsa->engine; ++ rsa->engine = NULL; ++ if (e) { ++ ENGINE_finish(e); ++ } ++ } ++#endif ++ } ++ ++ pkcs11h_openssl_freeSession (openssl_session); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: _pkcs11h_openssl_finish - return" ++ ); ++ ++ return 1; ++} ++ ++X509 * ++pkcs11h_openssl_getX509 ( ++ IN const pkcs11h_certificate_t certificate ++) { ++ unsigned char *certificate_blob = NULL; ++ size_t certificate_blob_size = 0; ++ X509 *x509 = NULL; ++ CK_RV rv = CKR_OK; ++ ++ pkcs11_openssl_d2i_t d2i1 = NULL; ++ PKCS11H_BOOL ok = TRUE; ++ ++ PKCS11H_ASSERT (certificate!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_openssl_getX509 - entry certificate=%p", ++ (void *)certificate ++ ); ++ ++ if ( ++ ok && ++ (x509 = X509_new ()) == NULL ++ ) { ++ ok = FALSE; ++ PKCS11H_LOG (PKCS11H_LOG_WARN, "PKCS#11: Unable to allocate certificate object"); ++ } ++ ++ if ( ++ ok && ++ pkcs11h_certificate_getCertificateBlob ( ++ certificate, ++ NULL, ++ &certificate_blob_size ++ ) != CKR_OK ++ ) { ++ ok = FALSE; ++ PKCS11H_LOG (PKCS11H_LOG_WARN, "PKCS#11: Cannot read X.509 certificate from token %ld-'%s'", rv, pkcs11h_getMessage (rv)); ++ } ++ ++ if ( ++ ok && ++ (rv = _pkcs11h_mem_malloc ((void *)&certificate_blob, certificate_blob_size)) != CKR_OK ++ ) { ++ ok = FALSE; ++ PKCS11H_LOG (PKCS11H_LOG_WARN, "PKCS#11: Cannot allocate X.509 memory %ld-'%s'", rv, pkcs11h_getMessage (rv)); ++ } ++ ++ if ( ++ ok && ++ pkcs11h_certificate_getCertificateBlob ( ++ certificate, ++ certificate_blob, ++ &certificate_blob_size ++ ) != CKR_OK ++ ) { ++ ok = FALSE; ++ PKCS11H_LOG (PKCS11H_LOG_WARN, "PKCS#11: Cannot read X.509 certificate from token %ld-'%s'", rv, pkcs11h_getMessage (rv)); ++ } ++ ++ d2i1 = (pkcs11_openssl_d2i_t)certificate_blob; ++ if ( ++ ok && ++ !d2i_X509 (&x509, &d2i1, certificate_blob_size) ++ ) { ++ ok = FALSE; ++ PKCS11H_LOG (PKCS11H_LOG_WARN, "PKCS#11: Unable to parse X.509 certificate"); ++ } ++ ++ if (!ok) { ++ X509_free (x509); ++ x509 = NULL; ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_openssl_getX509 - return x509=%p", ++ (void *)x509 ++ ); ++ ++ return x509; ++} ++ ++pkcs11h_openssl_session_t ++pkcs11h_openssl_createSession ( ++ IN const pkcs11h_certificate_t certificate ++) { ++ pkcs11h_openssl_session_t openssl_session = NULL; ++ PKCS11H_BOOL ok = TRUE; ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_openssl_createSession - entry" ++ ); ++ ++ if ( ++ ok && ++ _pkcs11h_mem_malloc ( ++ (void*)&openssl_session, ++ sizeof (struct pkcs11h_openssl_session_s)) != CKR_OK ++ ) { ++ ok = FALSE; ++ PKCS11H_LOG (PKCS11H_LOG_WARN, "PKCS#11: Cannot allocate memory"); ++ } ++ ++ if (ok) { ++ const RSA_METHOD *def = RSA_get_default_method(); ++ ++ memmove (&openssl_session->smart_rsa, def, sizeof(RSA_METHOD)); ++ ++ openssl_session->orig_finish = def->finish; ++ ++ openssl_session->smart_rsa.name = "pkcs11"; ++ openssl_session->smart_rsa.rsa_priv_dec = _pkcs11h_openssl_dec; ++ openssl_session->smart_rsa.rsa_sign = _pkcs11h_openssl_sign; ++ openssl_session->smart_rsa.finish = _pkcs11h_openssl_finish; ++ openssl_session->smart_rsa.flags = RSA_METHOD_FLAG_NO_CHECK | RSA_FLAG_EXT_PKEY; ++ openssl_session->certificate = certificate; ++ openssl_session->reference_count = 1; ++ } ++ ++ if (!ok) { ++ _pkcs11h_mem_free ((void *)&openssl_session); ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_openssl_createSession - return openssl_session=%p", ++ (void *)openssl_session ++ ); ++ ++ return openssl_session; ++} ++ ++pkcs11h_hook_openssl_cleanup_t ++pkcs11h_openssl_getCleanupHook ( ++ IN const pkcs11h_openssl_session_t openssl_session ++) { ++ PKCS11H_ASSERT (openssl_session!=NULL); ++ ++ return openssl_session->cleanup_hook; ++} ++ ++void ++pkcs11h_openssl_setCleanupHook ( ++ IN const pkcs11h_openssl_session_t openssl_session, ++ IN const pkcs11h_hook_openssl_cleanup_t cleanup ++) { ++ PKCS11H_ASSERT (openssl_session!=NULL); ++ ++ openssl_session->cleanup_hook = cleanup; ++} ++ ++void ++pkcs11h_openssl_freeSession ( ++ IN const pkcs11h_openssl_session_t openssl_session ++) { ++ PKCS11H_ASSERT (openssl_session!=NULL); ++ PKCS11H_ASSERT (openssl_session->reference_count>0); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_openssl_freeSession - entry openssl_session=%p, count=%d", ++ (void *)openssl_session, ++ openssl_session->reference_count ++ ); ++ ++ openssl_session->reference_count--; ++ ++ if (openssl_session->reference_count == 0) { ++ if (openssl_session->cleanup_hook != NULL) { ++ openssl_session->cleanup_hook (openssl_session->certificate); ++ } ++ ++ if (openssl_session->x509 != NULL) { ++ X509_free (openssl_session->x509); ++ openssl_session->x509 = NULL; ++ } ++ if (openssl_session->certificate != NULL) { ++ pkcs11h_certificate_freeCertificate (openssl_session->certificate); ++ openssl_session->certificate = NULL; ++ } ++ ++ _pkcs11h_mem_free ((void *)&openssl_session); ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_openssl_freeSession - return" ++ ); ++} ++ ++RSA * ++pkcs11h_openssl_session_getRSA ( ++ IN const pkcs11h_openssl_session_t openssl_session ++) { ++ X509 *x509 = NULL; ++ RSA *rsa = NULL; ++ EVP_PKEY *pubkey = NULL; ++ PKCS11H_BOOL ok = TRUE; ++ ++ PKCS11H_ASSERT (openssl_session!=NULL); ++ PKCS11H_ASSERT (!openssl_session->initialized); ++ PKCS11H_ASSERT (openssl_session!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_openssl_session_getRSA - entry openssl_session=%p", ++ (void *)openssl_session ++ ); ++ ++ /* ++ * Dup x509 so RSA will not hold session x509 ++ */ ++ if ( ++ ok && ++ (x509 = pkcs11h_openssl_session_getX509 (openssl_session)) == NULL ++ ) { ++ ok = FALSE; ++ PKCS11H_LOG (PKCS11H_LOG_WARN, "PKCS#11: Cannot get certificate object"); ++ } ++ ++ if ( ++ ok && ++ (pubkey = X509_get_pubkey (x509)) == NULL ++ ) { ++ ok = FALSE; ++ PKCS11H_LOG (PKCS11H_LOG_WARN, "PKCS#11: Cannot get public key"); ++ } ++ ++ if ( ++ ok && ++ pubkey->type != EVP_PKEY_RSA ++ ) { ++ ok = FALSE; ++ PKCS11H_LOG (PKCS11H_LOG_WARN, "PKCS#11: Invalid public key algorithm"); ++ } ++ ++ if ( ++ ok && ++ (rsa = EVP_PKEY_get1_RSA (pubkey)) == NULL ++ ) { ++ ok = FALSE; ++ PKCS11H_LOG (PKCS11H_LOG_WARN, "PKCS#11: Cannot get RSA key"); ++ } ++ ++ if (ok) { ++ RSA_set_method (rsa, &openssl_session->smart_rsa); ++ RSA_set_app_data (rsa, openssl_session); ++ openssl_session->reference_count++; ++ } ++ ++#ifdef BROKEN_OPENSSL_ENGINE ++ if (ok) { ++ if (!rsa->engine) { ++ rsa->engine = ENGINE_get_default_RSA(); ++ } ++ ++ ENGINE_set_RSA(ENGINE_get_default_RSA(), &openssl_session->smart_rsa); ++ PKCS11H_LOG (PKCS11H_LOG_WARN, "PKCS#11: OpenSSL engine support is broken! Workaround enabled"); ++ } ++#endif ++ ++ if (ok) { ++ rsa->flags |= RSA_FLAG_SIGN_VER; ++ openssl_session->initialized = TRUE; ++ } ++ else { ++ if (rsa != NULL) { ++ RSA_free (rsa); ++ rsa = NULL; ++ } ++ } ++ ++ /* ++ * openssl objects have reference ++ * count, so release them ++ */ ++ if (pubkey != NULL) { ++ EVP_PKEY_free (pubkey); ++ pubkey = NULL; ++ } ++ ++ if (x509 != NULL) { ++ X509_free (x509); ++ x509 = NULL; ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_openssl_session_getRSA - return rsa=%p", ++ (void *)rsa ++ ); ++ ++ return rsa; ++} ++ ++X509 * ++pkcs11h_openssl_session_getX509 ( ++ IN const pkcs11h_openssl_session_t openssl_session ++) { ++ X509 *x509 = NULL; ++ PKCS11H_BOOL ok = TRUE; ++ ++ PKCS11H_ASSERT (openssl_session!=NULL); ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_openssl_session_getX509 - entry openssl_session=%p", ++ (void *)openssl_session ++ ); ++ ++ if ( ++ ok && ++ openssl_session->x509 == NULL && ++ (openssl_session->x509 = pkcs11h_openssl_getX509 (openssl_session->certificate)) == NULL ++ ) { ++ ok = FALSE; ++ PKCS11H_LOG (PKCS11H_LOG_WARN, "PKCS#11: Cannot get certificate object"); ++ } ++ ++ if ( ++ ok && ++ (x509 = X509_dup (openssl_session->x509)) == NULL ++ ) { ++ ok = FALSE; ++ PKCS11H_LOG (PKCS11H_LOG_WARN, "PKCS#11: Cannot duplicate certificate object"); ++ } ++ ++ PKCS11H_DEBUG ( ++ PKCS11H_LOG_DEBUG2, ++ "PKCS#11: pkcs11h_openssl_session_getX509 - return x509=%p", ++ (void *)x509 ++ ); ++ ++ return x509; ++} ++ ++#endif /* ENABLE_PKCS11H_OPENSSL */ ++ ++#if defined(ENABLE_PKCS11H_STANDALONE) ++/*======================================================================* ++ * STANDALONE INTERFACE ++ *======================================================================*/ ++ ++void ++pkcs11h_standalone_dump_slots ( ++ IN const pkcs11h_output_print_t my_output, ++ IN void * const global_data, ++ IN const char * const provider ++) { ++ CK_RV rv = CKR_OK; ++ ++ pkcs11h_provider_t pkcs11h_provider; ++ ++ PKCS11H_ASSERT (my_output!=NULL); ++ /*PKCS11H_ASSERT (global_data) NOT NEEDED */ ++ PKCS11H_ASSERT (provider!=NULL); ++ ++ if ( ++ rv == CKR_OK && ++ (rv = pkcs11h_initialize ()) != CKR_OK ++ ) { ++ my_output (global_data, "PKCS#11: Cannot initialize interface %ld-'%s'\n", rv, pkcs11h_getMessage (rv)); ++ } ++ ++ if ( ++ rv == CKR_OK && ++ (rv = pkcs11h_addProvider ( ++ provider, ++ provider, ++ FALSE, ++ ( ++ PKCS11H_SIGNMODE_MASK_SIGN | ++ PKCS11H_SIGNMODE_MASK_RECOVER ++ ), ++ PKCS11H_SLOTEVENT_METHOD_AUTO, ++ 0, ++ FALSE ++ )) != CKR_OK ++ ) { ++ my_output (global_data, "PKCS#11: Cannot initialize provider %ld-'%s'\n", rv, pkcs11h_getMessage (rv)); ++ } ++ ++ /* ++ * our provider is head ++ */ ++ if (rv == CKR_OK) { ++ pkcs11h_provider = s_pkcs11h_data->providers; ++ if (pkcs11h_provider == NULL || !pkcs11h_provider->enabled) { ++ my_output (global_data, "PKCS#11: Cannot get provider %ld-'%s'\n", rv, pkcs11h_getMessage (rv)); ++ rv = CKR_GENERAL_ERROR; ++ } ++ } ++ ++ if (rv == CKR_OK) { ++ CK_INFO info; ++ ++ if ((rv = pkcs11h_provider->f->C_GetInfo (&info)) != CKR_OK) { ++ my_output (global_data, "PKCS#11: Cannot get PKCS#11 provider information %ld-'%s'\n", rv, pkcs11h_getMessage (rv)); ++ rv = CKR_OK; ++ } ++ else { ++ char manufacturerID[sizeof (info.manufacturerID)+1]; ++ ++ _pkcs11h_util_fixupFixedString ( ++ manufacturerID, ++ (char *)info.manufacturerID, ++ sizeof (info.manufacturerID) ++ ); ++ ++ my_output ( ++ global_data, ++ ( ++ "Provider Information:\n" ++ "\tcryptokiVersion:\t%u.%u\n" ++ "\tmanufacturerID:\t\t%s\n" ++ "\tflags:\t\t\t%08x\n" ++ "\n" ++ ), ++ info.cryptokiVersion.major, ++ info.cryptokiVersion.minor, ++ manufacturerID, ++ (unsigned)info.flags ++ ); ++ } ++ } ++ ++ if (rv == CKR_OK) { ++ CK_SLOT_ID_PTR slots = NULL; ++ CK_ULONG slotnum; ++ CK_SLOT_ID slot_index; ++ ++ if ( ++ _pkcs11h_session_getSlotList ( ++ pkcs11h_provider, ++ CK_FALSE, ++ &slots, ++ &slotnum ++ ) != CKR_OK ++ ) { ++ my_output (global_data, "PKCS#11: Cannot get slot list %ld-'%s'\n", rv, pkcs11h_getMessage (rv)); ++ } ++ else { ++ my_output ( ++ global_data, ++ "The following slots are available for use with this provider.\n" ++ ); ++ ++#if defined(PKCS11H_PRM_SLOT_TYPE) ++ my_output ( ++ global_data, ++ ( ++ "Each slot shown below may be used as a parameter to a\n" ++ "%s and %s options.\n" ++ ), ++ PKCS11H_PRM_SLOT_TYPE, ++ PKCS11H_PRM_SLOT_ID ++ ); ++#endif ++ ++ my_output ( ++ global_data, ++ ( ++ "\n" ++ "Slots: (id - name)\n" ++ ) ++ ); ++ ++ for (slot_index=0;slot_index < slotnum;slot_index++) { ++ CK_SLOT_INFO info; ++ ++ if ( ++ (rv = pkcs11h_provider->f->C_GetSlotInfo ( ++ slots[slot_index], ++ &info ++ )) == CKR_OK ++ ) { ++ char current_name[sizeof (info.slotDescription)+1]; ++ ++ _pkcs11h_util_fixupFixedString ( ++ current_name, ++ (char *)info.slotDescription, ++ sizeof (info.slotDescription) ++ ); ++ ++ my_output (global_data, "\t%lu - %s\n", slots[slot_index], current_name); ++ } ++ } ++ } ++ ++ if (slots != NULL) { ++ _pkcs11h_mem_free ((void *)&slots); ++ } ++ } ++ ++ pkcs11h_terminate (); ++} ++ ++static ++PKCS11H_BOOL ++_pkcs11h_standalone_dump_objects_pin_prompt ( ++ IN void * const global_data, ++ IN void * const user_data, ++ IN const pkcs11h_token_id_t token, ++ IN const unsigned retry, ++ OUT char * const pin, ++ IN const size_t pin_max ++) { ++ (void)user_data; ++ (void)token; ++ ++ /* ++ * Don't lock card ++ */ ++ if (retry == 0) { ++ strncpy (pin, (char *)global_data, pin_max); ++ return TRUE; ++ } ++ else { ++ return FALSE; ++ } ++} ++ ++void ++_pkcs11h_standalone_dump_objects_hex ( ++ IN const unsigned char * const p, ++ IN const size_t p_size, ++ OUT char * const sz, ++ IN const size_t max, ++ IN const char * const prefix ++) { ++ size_t j; ++ ++ sz[0] = '\0'; ++ ++ for (j=0;jproviders; ++ if (pkcs11h_provider == NULL || !pkcs11h_provider->enabled) { ++ my_output (global_data, "PKCS#11: Cannot get provider %ld-'%s'\n", rv, pkcs11h_getMessage (rv)); ++ rv = CKR_GENERAL_ERROR; ++ } ++ } ++ ++ if (rv == CKR_OK) { ++ CK_TOKEN_INFO info; ++ ++ if ( ++ (rv = pkcs11h_provider->f->C_GetTokenInfo ( ++ s, ++ &info ++ )) != CKR_OK ++ ) { ++ my_output (global_data, "PKCS#11: Cannot get token information for slot %ld %ld-'%s'\n", s, rv, pkcs11h_getMessage (rv)); ++ /* Ignore this error */ ++ rv = CKR_OK; ++ } ++ else { ++ char label[sizeof (info.label)+1]; ++ char manufacturerID[sizeof (info.manufacturerID)+1]; ++ char model[sizeof (info.model)+1]; ++ char serialNumberNumber[sizeof (info.serialNumber)+1]; ++ ++ _pkcs11h_util_fixupFixedString ( ++ label, ++ (char *)info.label, ++ sizeof (info.label) ++ ); ++ _pkcs11h_util_fixupFixedString ( ++ manufacturerID, ++ (char *)info.manufacturerID, ++ sizeof (info.manufacturerID) ++ ); ++ _pkcs11h_util_fixupFixedString ( ++ model, ++ (char *)info.model, ++ sizeof (info.model) ++ ); ++ _pkcs11h_util_fixupFixedString ( ++ serialNumberNumber, ++ (char *)info.serialNumber, ++ sizeof (info.serialNumber) ++ ); ++ ++ my_output ( ++ global_data, ++ ( ++ "Token Information:\n" ++ "\tlabel:\t\t%s\n" ++ "\tmanufacturerID:\t%s\n" ++ "\tmodel:\t\t%s\n" ++ "\tserialNumber:\t%s\n" ++ "\tflags:\t\t%08x\n" ++ "\n" ++ ), ++ label, ++ manufacturerID, ++ model, ++ serialNumberNumber, ++ (unsigned)info.flags ++ ); ++ ++#if defined(PKCS11H_PRM_SLOT_TYPE) ++ my_output ( ++ global_data, ++ ( ++ "You can access this token using\n" ++ "%s \"label\" %s \"%s\" options.\n" ++ "\n" ++ ), ++ PKCS11H_PRM_SLOT_TYPE, ++ PKCS11H_PRM_SLOT_ID, ++ label ++ ); ++#endif ++ ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_token_getTokenId ( ++ &info, ++ &token_id ++ )) != CKR_OK ++ ) { ++ my_output (global_data, "PKCS#11: Cannot get token id for slot %ld %ld-'%s'\n", s, rv, pkcs11h_getMessage (rv)); ++ rv = CKR_OK; ++ } ++ } ++ } ++ ++ if (token_id != NULL) { ++ if ( ++ (rv = _pkcs11h_session_getSessionByTokenId ( ++ token_id, ++ &session ++ )) != CKR_OK ++ ) { ++ my_output (global_data, "PKCS#11: Cannot session for token '%s' %ld-'%s'\n", token_id->display, rv, pkcs11h_getMessage (rv)); ++ rv = CKR_OK; ++ } ++ } ++ ++ if (session != NULL) { ++ CK_OBJECT_HANDLE *objects = NULL; ++ CK_ULONG objects_found = 0; ++ CK_ULONG i; ++ ++ if ( ++ (rv = _pkcs11h_session_login ( ++ session, ++ FALSE, ++ TRUE, ++ NULL, ++ PKCS11H_PROMPT_MASK_ALLOW_PIN_PROMPT ++ )) != CKR_OK ++ ) { ++ my_output (global_data, "PKCS#11: Cannot open session to token '%s' %ld-'%s'\n", session->token_id->display, rv, pkcs11h_getMessage (rv)); ++ } ++ ++ my_output ( ++ global_data, ++ "The following objects are available for use with this token.\n" ++ ); ++ ++#if defined(PKCS11H_PRM_OBJ_TYPE) ++ my_output ( ++ global_data, ++ ( ++ "Each object shown below may be used as a parameter to\n" ++ "%s and %s options.\n" ++ ), ++ PKCS11H_PRM_OBJ_TYPE, ++ PKCS11H_PRM_OBJ_ID ++ ); ++#endif ++ ++ my_output ( ++ global_data, ++ "\n" ++ ); ++ ++ if ( ++ rv == CKR_OK && ++ (rv = _pkcs11h_session_findObjects ( ++ session, ++ NULL, ++ 0, ++ &objects, ++ &objects_found ++ )) != CKR_OK ++ ) { ++ my_output (global_data, "PKCS#11: Cannot query objects for token '%s' %ld-'%s'\n", session->token_id->display, rv, pkcs11h_getMessage (rv)); ++ } ++ ++ for (i=0;rv == CKR_OK && i < objects_found;i++) { ++ CK_OBJECT_CLASS attrs_class = 0; ++ CK_ATTRIBUTE attrs[] = { ++ {CKA_CLASS, &attrs_class, sizeof (attrs_class)} ++ }; ++ ++ if ( ++ _pkcs11h_session_getObjectAttributes ( ++ session, ++ objects[i], ++ attrs, ++ sizeof (attrs) / sizeof (CK_ATTRIBUTE) ++ ) == CKR_OK ++ ) { ++ if (attrs_class == CKO_CERTIFICATE) { ++ CK_ATTRIBUTE attrs_cert[] = { ++ {CKA_ID, NULL, 0}, ++ {CKA_LABEL, NULL, 0}, ++ {CKA_VALUE, NULL, 0} ++ }; ++ unsigned char *attrs_id = NULL; ++ int attrs_id_size = 0; ++ unsigned char *attrs_value = NULL; ++ int attrs_value_size = 0; ++ char *attrs_label = NULL; ++ char hex_id[1024]; ++ char subject[1024]; ++ char serialNumber[1024]; ++ time_t notAfter = 0; ++ ++ subject[0] = '\0'; ++ serialNumber[0] = '\0'; ++ ++ ++ if ( ++ _pkcs11h_session_getObjectAttributes ( ++ session, ++ objects[i], ++ attrs_cert, ++ sizeof (attrs_cert) / sizeof (CK_ATTRIBUTE) ++ ) == CKR_OK && ++ _pkcs11h_mem_malloc ( ++ (void *)&attrs_label, ++ attrs_cert[1].ulValueLen+1 ++ ) == CKR_OK ++ ) { ++ attrs_id = (unsigned char *)attrs_cert[0].pValue; ++ attrs_id_size = attrs_cert[0].ulValueLen; ++ attrs_value = (unsigned char *)attrs_cert[2].pValue; ++ attrs_value_size = attrs_cert[2].ulValueLen; ++ ++ memset (attrs_label, 0, attrs_cert[1].ulValueLen+1); ++ memmove (attrs_label, attrs_cert[1].pValue, attrs_cert[1].ulValueLen); ++ _pkcs11h_standalone_dump_objects_hex ( ++ attrs_id, ++ attrs_id_size, ++ hex_id, ++ sizeof (hex_id), ++ "\t\t" ++ ); ++ } ++ ++ if (attrs_value != NULL) { ++#if defined(USE_PKCS11H_OPENSSL) ++ X509 *x509 = NULL; ++ BIO *bioSerial = NULL; ++#elif defined(USE_PKCS11H_GNUTLS) ++ gnutls_x509_crt_t cert = NULL; ++#endif ++ ++ _pkcs11h_certificate_getDN ( ++ attrs_value, ++ attrs_value_size, ++ subject, ++ sizeof (subject) ++ ); ++ notAfter = _pkcs11h_certificate_getExpiration ( ++ attrs_value, ++ attrs_value_size ++ ); ++#if defined(USE_PKCS11H_OPENSSL) ++ if ((x509 = X509_new ()) == NULL) { ++ my_output (global_data, "Cannot create x509 context\n"); ++ } ++ else { ++ pkcs11_openssl_d2i_t d2i1 = (pkcs11_openssl_d2i_t)attrs_value; ++ if (d2i_X509 (&x509, &d2i1, attrs_value_size)) { ++ if ((bioSerial = BIO_new (BIO_s_mem ())) == NULL) { ++ my_output (global_data, "Cannot create BIO context\n"); ++ } ++ else { ++ int n; ++ ++ i2a_ASN1_INTEGER(bioSerial, X509_get_serialNumber (x509)); ++ n = BIO_read (bioSerial, serialNumber, sizeof (serialNumber)-1); ++ if (n<0) { ++ serialNumber[0] = '\0'; ++ } ++ else { ++ serialNumber[n] = '\0'; ++ } ++ } ++ } ++ } ++ ++ ++ if (bioSerial != NULL) { ++ BIO_free_all (bioSerial); ++ bioSerial = NULL; ++ } ++ if (x509 != NULL) { ++ X509_free (x509); ++ x509 = NULL; ++ } ++#elif defined(USE_PKCS11H_GNUTLS) ++ if (gnutls_x509_crt_init (&cert) == GNUTLS_E_SUCCESS) { ++ gnutls_datum_t datum = {attrs_value, attrs_value_size}; ++ ++ if (gnutls_x509_crt_import (cert, &datum, GNUTLS_X509_FMT_DER) == GNUTLS_E_SUCCESS) { ++ unsigned char ser[1024]; ++ size_t ser_size = sizeof (ser); ++ if (gnutls_x509_crt_get_serial (cert, ser, &ser_size) == GNUTLS_E_SUCCESS) { ++ _pkcs11h_util_binaryToHex ( ++ serialNumber, ++ sizeof (serialNumber), ++ ser, ++ ser_size ++ ); ++ } ++ } ++ gnutls_x509_crt_deinit (cert); ++ } ++#else ++#error Invalid configuration. ++#endif ++ } ++ ++ my_output ( ++ global_data, ++ ( ++ "Object\n" ++ "\tType:\t\t\tCertificate\n" ++ "\tCKA_ID:\n" ++ "%s" ++ "\tCKA_LABEL:\t\t%s\n" ++ "\tsubject:\t\t%s\n" ++ "\tserialNumber:\t\t%s\n" ++ "\tnotAfter:\t\t%s\n" ++ ), ++ hex_id, ++ attrs_label, ++ subject, ++ serialNumber, ++ asctime (localtime (¬After)) ++ ); ++ ++ _pkcs11h_mem_free ((void *)&attrs_label); ++ ++ _pkcs11h_session_freeObjectAttributes ( ++ attrs_cert, ++ sizeof (attrs_cert) / sizeof (CK_ATTRIBUTE) ++ ); ++ } ++ else if (attrs_class == CKO_PRIVATE_KEY) { ++ CK_BBOOL sign_recover = CK_FALSE; ++ CK_BBOOL sign = CK_FALSE; ++ CK_ATTRIBUTE attrs_key[] = { ++ {CKA_SIGN, &sign, sizeof (sign)}, ++ {CKA_SIGN_RECOVER, &sign_recover, sizeof (sign_recover)} ++ }; ++ CK_ATTRIBUTE attrs_key_common[] = { ++ {CKA_ID, NULL, 0}, ++ {CKA_LABEL, NULL, 0} ++ }; ++ unsigned char *attrs_id = NULL; ++ int attrs_id_size = 0; ++ char *attrs_label = NULL; ++ char hex_id[1024]; ++ ++ pkcs11h_provider->f->C_GetAttributeValue ( ++ session->session_handle, ++ objects[i], ++ attrs_key, ++ sizeof (attrs_key) / sizeof (CK_ATTRIBUTE) ++ ); ++ ++ if ( ++ _pkcs11h_session_getObjectAttributes ( ++ session, ++ objects[i], ++ attrs_key_common, ++ sizeof (attrs_key_common) / sizeof (CK_ATTRIBUTE) ++ ) == CKR_OK && ++ _pkcs11h_mem_malloc ( ++ (void *)&attrs_label, ++ attrs_key_common[1].ulValueLen+1 ++ ) == CKR_OK ++ ) { ++ attrs_id = (unsigned char *)attrs_key_common[0].pValue; ++ attrs_id_size = attrs_key_common[0].ulValueLen; ++ ++ memset (attrs_label, 0, attrs_key_common[1].ulValueLen+1); ++ memmove (attrs_label, attrs_key_common[1].pValue, attrs_key_common[1].ulValueLen); ++ ++ _pkcs11h_standalone_dump_objects_hex ( ++ attrs_id, ++ attrs_id_size, ++ hex_id, ++ sizeof (hex_id), ++ "\t\t" ++ ); ++ ++ } ++ ++ my_output ( ++ global_data, ++ ( ++ "Object\n" ++ "\tType:\t\t\tPrivate Key\n" ++ "\tCKA_ID:\n" ++ "%s" ++ "\tCKA_LABEL:\t\t%s\n" ++ "\tCKA_SIGN:\t\t%s\n" ++ "\tCKA_SIGN_RECOVER:\t%s\n" ++ ), ++ hex_id, ++ attrs_label, ++ sign ? "TRUE" : "FALSE", ++ sign_recover ? "TRUE" : "FALSE" ++ ); ++ ++ _pkcs11h_mem_free ((void *)&attrs_label); ++ ++ _pkcs11h_session_freeObjectAttributes ( ++ attrs_key_common, ++ sizeof (attrs_key_common) / sizeof (CK_ATTRIBUTE) ++ ); ++ } ++ else if (attrs_class == CKO_PUBLIC_KEY) { ++ CK_ATTRIBUTE attrs_key_common[] = { ++ {CKA_ID, NULL, 0}, ++ {CKA_LABEL, NULL, 0} ++ }; ++ unsigned char *attrs_id = NULL; ++ int attrs_id_size = 0; ++ char *attrs_label = NULL; ++ char hex_id[1024]; ++ ++ if ( ++ _pkcs11h_session_getObjectAttributes ( ++ session, ++ objects[i], ++ attrs_key_common, ++ sizeof (attrs_key_common) / sizeof (CK_ATTRIBUTE) ++ ) == CKR_OK && ++ _pkcs11h_mem_malloc ( ++ (void *)&attrs_label, ++ attrs_key_common[1].ulValueLen+1 ++ ) == CKR_OK ++ ) { ++ attrs_id = (unsigned char *)attrs_key_common[0].pValue; ++ attrs_id_size = attrs_key_common[0].ulValueLen; ++ ++ memset (attrs_label, 0, attrs_key_common[1].ulValueLen+1); ++ memmove (attrs_label, attrs_key_common[1].pValue, attrs_key_common[1].ulValueLen); ++ ++ _pkcs11h_standalone_dump_objects_hex ( ++ attrs_id, ++ attrs_id_size, ++ hex_id, ++ sizeof (hex_id), ++ "\t\t" ++ ); ++ ++ } ++ ++ my_output ( ++ global_data, ++ ( ++ "Object\n" ++ "\tType:\t\t\tPublic Key\n" ++ "\tCKA_ID:\n" ++ "%s" ++ "\tCKA_LABEL:\t\t%s\n" ++ ), ++ hex_id, ++ attrs_label ++ ); ++ ++ _pkcs11h_mem_free ((void *)&attrs_label); ++ ++ _pkcs11h_session_freeObjectAttributes ( ++ attrs_key_common, ++ sizeof (attrs_key_common) / sizeof (CK_ATTRIBUTE) ++ ); ++ } ++ else if (attrs_class == CKO_DATA) { ++ CK_ATTRIBUTE attrs_key_common[] = { ++ {CKA_APPLICATION, NULL, 0}, ++ {CKA_LABEL, NULL, 0} ++ }; ++ char *attrs_application = NULL; ++ char *attrs_label = NULL; ++ ++ if ( ++ _pkcs11h_session_getObjectAttributes ( ++ session, ++ objects[i], ++ attrs_key_common, ++ sizeof (attrs_key_common) / sizeof (CK_ATTRIBUTE) ++ ) == CKR_OK && ++ _pkcs11h_mem_malloc ( ++ (void *)&attrs_application, ++ attrs_key_common[0].ulValueLen+1 ++ ) == CKR_OK && ++ _pkcs11h_mem_malloc ( ++ (void *)&attrs_label, ++ attrs_key_common[1].ulValueLen+1 ++ ) == CKR_OK ++ ) { ++ memset (attrs_application, 0, attrs_key_common[0].ulValueLen+1); ++ memmove (attrs_application, attrs_key_common[0].pValue, attrs_key_common[0].ulValueLen); ++ memset (attrs_label, 0, attrs_key_common[1].ulValueLen+1); ++ memmove (attrs_label, attrs_key_common[1].pValue, attrs_key_common[1].ulValueLen); ++ } ++ ++ my_output ( ++ global_data, ++ ( ++ "Object\n" ++ "\tType:\t\t\tData\n" ++ "\tCKA_APPLICATION\t\t%s\n" ++ "\tCKA_LABEL:\t\t%s\n" ++ ), ++ attrs_application, ++ attrs_label ++ ); ++ ++ _pkcs11h_mem_free ((void *)&attrs_application); ++ _pkcs11h_mem_free ((void *)&attrs_label); ++ ++ _pkcs11h_session_freeObjectAttributes ( ++ attrs_key_common, ++ sizeof (attrs_key_common) / sizeof (CK_ATTRIBUTE) ++ ); ++ } ++ else { ++ my_output ( ++ global_data, ++ ( ++ "Object\n" ++ "\tType:\t\t\tUnsupported\n" ++ ) ++ ); ++ } ++ } ++ ++ _pkcs11h_session_freeObjectAttributes ( ++ attrs, ++ sizeof (attrs) / sizeof (CK_ATTRIBUTE) ++ ); ++ ++ /* ++ * Ignore any error and ++ * perform next iteration ++ */ ++ rv = CKR_OK; ++ } ++ ++ if (objects != NULL) { ++ _pkcs11h_mem_free ((void *)&objects); ++ } ++ ++ /* ++ * Ignore this error ++ */ ++ rv = CKR_OK; ++ } ++ ++ if (session != NULL) { ++ _pkcs11h_session_release (session); ++ session = NULL; ++ } ++ ++ if (token_id != NULL) { ++ pkcs11h_token_freeTokenId (token_id); ++ token_id = NULL; ++ } ++ ++ pkcs11h_terminate (); ++} ++ ++#endif /* ENABLE_PKCS11H_STANDALONE */ ++ ++#ifdef BROKEN_OPENSSL_ENGINE ++static void broken_openssl_init() __attribute__ ((constructor)); ++static void broken_openssl_init() ++{ ++ SSL_library_init(); ++ ENGINE_load_openssl(); ++ ENGINE_register_all_RSA(); ++} ++#endif ++ ++#else ++static void dummy (void) {} ++#endif /* PKCS11H_HELPER_ENABLE */ ++ +diff -urNp openssh-4.4p1/pkcs11-helper-config.h openssh-4.4p1+pkcs11-0.17/pkcs11-helper-config.h +--- openssh-4.4p1/pkcs11-helper-config.h 1970-01-01 02:00:00.000000000 +0200 ++++ openssh-4.4p1+pkcs11-0.17/pkcs11-helper-config.h 2006-10-12 16:43:38.000000000 +0200 +@@ -0,0 +1,103 @@ ++/* ++ * Copyright (c) 2005-2006 Alon Bar-Lev. 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. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. ++ */ ++ ++#ifndef __PKCS11H_HELPER_CONFIG_H ++#define __PKCS11H_HELPER_CONFIG_H ++ ++#if !defined(PKCS11H_NO_NEED_INCLUDE_CONFIG) ++ ++#include "includes.h" ++ ++#endif /* PKCS11H_NO_NEED_INCLUDE_CONFIG */ ++ ++#ifndef SSH_PKCS11H_DISABLED ++#define ENABLE_PKCS11H_HELPER ++#endif ++ ++#include ++#include ++#include ++#if !defined(WIN32) ++#include ++#include ++#endif ++ ++#include "log.h" ++#include "xmalloc.h" ++#include "openssl/x509.h" ++ ++#if defined(HAVE_CYGWIN) ++#define PKCS11H_USE_CYGWIN ++#endif ++ ++#if !defined(FALSE) ++#define FALSE 0 ++#endif ++#if !defined(TRUE) ++#define TRUE (!FALSE) ++#endif ++ ++typedef int PKCS11H_BOOL; ++ ++#if !defined(IN) ++#define IN ++#endif ++#if !defined(OUT) ++#define OUT ++#endif ++ ++#define USE_PKCS11H_OPENSSL ++#define ENABLE_PKCS11H_DEBUG ++#undef ENABLE_PKCS11H_THREADING ++#undef ENABLE_PKCS11H_TOKEN ++#undef ENABLE_PKCS11H_DATA ++#define ENABLE_PKCS11H_CERTIFICATE ++#undef ENABLE_PKCS11H_LOCATE ++#define ENABLE_PKCS11H_ENUM ++#define ENABLE_PKCS11H_SERIALIZATION ++#undef ENABLE_PKCS11H_SLOTEVENT ++#define ENABLE_PKCS11H_OPENSSL ++#define ENABLE_PKCS11H_STANDALONE ++ ++/* ++#define PKCS11H_PRM_SLOT_TYPE "--pkcs11-slot-type" ++#define PKCS11H_PRM_SLOT_ID "--pkcs11-slot" ++#define PKCS11H_PRM_OBJ_TYPE "--pkcs11-id-type" ++#define PKCS11H_PRM_OBJ_ID "--pkcs11-id" ++*/ ++ ++#define PKCS11H_ASSERT assert ++#define PKCS11H_TIME time ++#define PKCS11H_MALLOC xmalloc ++#define PKCS11H_FREE xfree ++ ++#ifdef ENABLE_PKCS11H_HELPER ++#if defined(WIN32) || defined(PKCS11H_USE_CYGWIN) ++#include "cryptoki-win32.h" ++#else ++#include "cryptoki.h" ++#endif ++ ++#endif /* ENABLE_PKCS11H_HELPER */ ++#endif /* __PKCS11H_HELPER_CONFIG_H */ +diff -urNp openssh-4.4p1/pkcs11-helper.h openssh-4.4p1+pkcs11-0.17/pkcs11-helper.h +--- openssh-4.4p1/pkcs11-helper.h 1970-01-01 02:00:00.000000000 +0200 ++++ openssh-4.4p1+pkcs11-0.17/pkcs11-helper.h 2006-10-22 17:11:14.000000000 +0200 +@@ -0,0 +1,1303 @@ ++/* ++ * Copyright (c) 2005-2006 Alon Bar-Lev ++ * All rights reserved. ++ * ++ * This software is available to you under a choice of one of two ++ * licenses. You may choose to be licensed under the terms of the GNU ++ * General Public License (GPL) Version 2, or the OpenIB.org BSD license. ++ * ++ * GNU General Public License (GPL) Version 2 ++ * =========================================== ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License version 2 ++ * as published by the Free Software Foundation. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT 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[.GPL2] included with this ++ * distribution); if not, write to the Free Software Foundation, Inc., ++ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ * ++ * OpenIB.org BSD license ++ * ======================= ++ * Redistribution and use in source and binary forms, with or without modifi- ++ * cation, are permitted provided that the following conditions are met: ++ * ++ * o Redistributions of source code must retain the above copyright notice, ++ * this list of conditions and the following disclaimer. ++ * ++ * o Redistributions in binary form must reproduce the above copyright no- ++ * tice, this list of conditions and the following disclaimer in the do- ++ * cumentation and/or other materials provided with the distribution. ++ * ++ * o The names of the 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 COPYRIGHT HOLDERS AND 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 REGENTS OR CONTRIBUTORS BE LI- ++ * ABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUEN- ++ * TIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEV- ++ * ER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABI- ++ * LITY, 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. ++ */ ++ ++/* ++ * The routines in this file deal with providing private key cryptography ++ * using RSA Security Inc. PKCS #11 Cryptographic Token Interface (Cryptoki). ++ * ++ */ ++ ++#ifndef __PKCS11H_HELPER_H ++#define __PKCS11H_HELPER_H ++ ++#if defined(__cplusplus) ++extern "C" { ++#endif ++ ++#include "pkcs11-helper-config.h" ++ ++#if !defined(USE_PKCS11H_OPENSSL) && !defined(USE_PKCS11H_GNUTLS) ++#error PKCS#11: USE_PKCS11H_OPENSSL or USE_PKCS11H_GNUTLS must be defined ++#endif ++ ++#if defined(ENABLE_PKCS11H_SLOTEVENT) && !defined(ENABLE_PKCS11H_THREADING) ++#error PKCS#11: ENABLE_PKCS11H_SLOTEVENT requires ENABLE_PKCS11H_THREADING ++#endif ++#if defined(ENABLE_PKCS11H_OPENSSL) && !defined(ENABLE_PKCS11H_CERTIFICATE) ++#error PKCS#11: ENABLE_PKCS11H_OPENSSL requires ENABLE_PKCS11H_CERTIFICATE ++#endif ++ ++#define PKCS11H_LOG_DEBUG2 5 ++#define PKCS11H_LOG_DEBUG1 4 ++#define PKCS11H_LOG_INFO 3 ++#define PKCS11H_LOG_WARN 2 ++#define PKCS11H_LOG_ERROR 1 ++#define PKCS11H_LOG_QUITE 0 ++ ++#define PKCS11H_PIN_CACHE_INFINITE -1 ++ ++#define PKCS11H_SIGNMODE_MASK_SIGN (1<<0) ++#define PKCS11H_SIGNMODE_MASK_RECOVER (1<<1) ++ ++#define PKCS11H_PROMPT_MASK_ALLOW_PIN_PROMPT (1<<0) ++#define PKCS11H_PROMPT_MAST_ALLOW_CARD_PROMPT (1<<1) ++#define PKCS11H_PROMPT_MASK_ALLOW_ALL ( \ ++ PKCS11H_PROMPT_MASK_ALLOW_PIN_PROMPT | \ ++ PKCS11H_PROMPT_MAST_ALLOW_CARD_PROMPT \ ++ ) ++ ++#define PKCS11H_SLOTEVENT_METHOD_AUTO 0 ++#define PKCS11H_SLOTEVENT_METHOD_TRIGGER 1 ++#define PKCS11H_SLOTEVENT_METHOD_POLL 2 ++ ++#define PKCS11H_ENUM_METHOD_CACHE 0 ++#define PKCS11H_ENUM_METHOD_CACHE_EXIST 1 ++#define PKCS11H_ENUM_METHOD_RELOAD 2 ++ ++typedef void (*pkcs11h_output_print_t)( ++ IN void * const global_data, ++ IN const char * const format, ++ IN ... ++) ++#if __GNUC__ > 2 ++ __attribute__ ((format (printf, 2, 3))) ++#endif ++ ; ++ ++struct pkcs11h_token_id_s; ++typedef struct pkcs11h_token_id_s *pkcs11h_token_id_t; ++ ++#if defined(ENABLE_PKCS11H_CERTIFICATE) ++ ++struct pkcs11h_certificate_id_s; ++struct pkcs11h_certificate_s; ++typedef struct pkcs11h_certificate_id_s *pkcs11h_certificate_id_t; ++typedef struct pkcs11h_certificate_s *pkcs11h_certificate_t; ++ ++#endif /* ENABLE_PKCS11H_CERTIFICATE */ ++ ++#if defined(ENABLE_PKCS11H_ENUM) ++ ++struct pkcs11h_token_id_list_s; ++typedef struct pkcs11h_token_id_list_s *pkcs11h_token_id_list_t; ++ ++#if defined(ENABLE_PKCS11H_DATA) ++ ++struct pkcs11h_data_id_list_s; ++typedef struct pkcs11h_data_id_list_s *pkcs11h_data_id_list_t; ++ ++#endif /* ENABLE_PKCS11H_DATA */ ++ ++#if defined(ENABLE_PKCS11H_CERTIFICATE) ++ ++struct pkcs11h_certificate_id_list_s; ++typedef struct pkcs11h_certificate_id_list_s *pkcs11h_certificate_id_list_t; ++ ++#endif /* ENABLE_PKCS11H_CERTIFICATE */ ++ ++#endif /* ENABLE_PKCS11H_ENUM */ ++ ++typedef void (*pkcs11h_hook_log_t)( ++ IN void * const global_data, ++ IN const unsigned flags, ++ IN const char * const format, ++ IN va_list args ++); ++ ++typedef void (*pkcs11h_hook_slotevent_t)( ++ IN void * const global_data ++); ++ ++typedef PKCS11H_BOOL (*pkcs11h_hook_token_prompt_t)( ++ IN void * const global_data, ++ IN void * const user_data, ++ IN const pkcs11h_token_id_t token, ++ IN const unsigned retry ++); ++ ++typedef PKCS11H_BOOL (*pkcs11h_hook_pin_prompt_t)( ++ IN void * const global_data, ++ IN void * const user_data, ++ IN const pkcs11h_token_id_t token, ++ IN const unsigned retry, ++ OUT char * const pin, ++ IN const size_t pin_max ++); ++ ++struct pkcs11h_token_id_s { ++ char display[1024]; ++ char manufacturerID[sizeof (((CK_TOKEN_INFO *)NULL)->manufacturerID)+1]; ++ char model[sizeof (((CK_TOKEN_INFO *)NULL)->model)+1]; ++ char serialNumber[sizeof (((CK_TOKEN_INFO *)NULL)->serialNumber)+1]; ++ char label[sizeof (((CK_TOKEN_INFO *)NULL)->label)+1]; ++}; ++ ++#if defined(ENABLE_PKCS11H_CERTIFICATE) ++ ++struct pkcs11h_certificate_id_s { ++ pkcs11h_token_id_t token_id; ++ ++ char displayName[1024]; ++ CK_BYTE_PTR attrCKA_ID; ++ size_t attrCKA_ID_size; ++ ++ unsigned char *certificate_blob; ++ size_t certificate_blob_size; ++}; ++ ++#endif ++ ++#if defined(ENABLE_PKCS11H_ENUM) ++ ++struct pkcs11h_token_id_list_s { ++ pkcs11h_token_id_list_t next; ++ pkcs11h_token_id_t token_id; ++}; ++ ++#if defined(ENABLE_PKCS11H_DATA) ++ ++struct pkcs11h_data_id_list_s { ++ pkcs11h_data_id_list_t next; ++ ++ char *application; ++ char *label; ++}; ++ ++#endif /* ENABLE_PKCS11H_DATA */ ++ ++#if defined(ENABLE_PKCS11H_CERTIFICATE) ++ ++struct pkcs11h_certificate_id_list_s { ++ pkcs11h_certificate_id_list_t next; ++ pkcs11h_certificate_id_t certificate_id; ++}; ++ ++#endif /* ENABLE_PKCS11H_CERTIFICATE */ ++ ++#endif /* ENABLE_PKCS11H_CERTIFICATE */ ++ ++#if defined(ENABLE_PKCS11H_OPENSSL) ++ ++typedef void (*pkcs11h_hook_openssl_cleanup_t) ( ++ IN const pkcs11h_certificate_t certificate ++); ++ ++struct pkcs11h_openssl_session_s; ++typedef struct pkcs11h_openssl_session_s *pkcs11h_openssl_session_t; ++ ++#endif /* ENABLE_PKCS11H_OPENSSL */ ++ ++/* ++ * pkcs11h_getMessage - Get message by return value. ++ * ++ * Parameters: ++ * rv - Return value. ++ */ ++const char * ++pkcs11h_getMessage ( ++ IN const CK_RV rv ++); ++ ++/* ++ * pkcs11h_initialize - Inititalize helper interface. ++ * ++ * Must be called once, from main thread. ++ * Defaults: ++ * Protected authentication enabled. ++ * PIN cached is infinite. ++ */ ++CK_RV ++pkcs11h_initialize (); ++ ++/* ++ * pkcs11h_terminate - Terminate helper interface. ++ * ++ * Must be called once, from main thread, after all ++ * related resources freed. ++ */ ++CK_RV ++pkcs11h_terminate (); ++ ++/* ++ * pkcs11h_setLogLevel - Set current log level of the helper. ++ * ++ * Parameters: ++ * flags - current log level. ++ * ++ * The log level can be set to maximum, but setting it to lower ++ * level will improve performance. ++ */ ++void ++pkcs11h_setLogLevel ( ++ IN const unsigned flags ++); ++ ++/* ++ * pkcs11h_getLogLevel - Get current log level. ++ */ ++unsigned ++pkcs11h_getLogLevel (); ++ ++/* ++ * pkcs11h_setLogHook - Set a log callback. ++ * ++ * Parameters: ++ * hook - Callback. ++ * pData - Data to send to callback. ++ */ ++CK_RV ++pkcs11h_setLogHook ( ++ IN const pkcs11h_hook_log_t hook, ++ IN void * const global_data ++); ++ ++/* ++ * pkcs11h_setSlotEventHook - Set a slot event callback. ++ * ++ * Parameters: ++ * hook - Callback. ++ * pData - Data to send to callback. ++ * ++ * Calling this function initialize slot event notifications, these ++ * notifications can be started, but never terminate due to PKCS#11 limitation. ++ * ++ * In order to use slot events you must have threading enabled. ++ */ ++CK_RV ++pkcs11h_setSlotEventHook ( ++ IN const pkcs11h_hook_slotevent_t hook, ++ IN void * const global_data ++); ++ ++/* ++ * pkcs11h_setTokenPromptHook - Set a token prompt callback. ++ * ++ * Parameters: ++ * hook - Callback. ++ * pData - Data to send to callback. ++ */ ++CK_RV ++pkcs11h_setTokenPromptHook ( ++ IN const pkcs11h_hook_token_prompt_t hook, ++ IN void * const global_data ++); ++ ++/* ++ * pkcs11h_setPINPromptHook - Set a pin prompt callback. ++ * ++ * Parameters: ++ * hook - Callback. ++ * pData - Data to send to callback. ++ */ ++CK_RV ++pkcs11h_setPINPromptHook ( ++ IN const pkcs11h_hook_pin_prompt_t hook, ++ IN void * const global_data ++); ++ ++/* ++ * pkcs11h_setProtectedAuthentication - Set global protected authentication mode. ++ * ++ * Parameters: ++ * allow_protected_auth - Allow protected authentication if enabled by token. ++ */ ++CK_RV ++pkcs11h_setProtectedAuthentication ( ++ IN const PKCS11H_BOOL allow_protected_auth ++); ++ ++/* ++ * pkcs11h_setPINCachePeriod - Set global PIN cache timeout. ++ * ++ * Parameters: ++ * pin_cache_period - Cache period in seconds, or PKCS11H_PIN_CACHE_INFINITE. ++ */ ++CK_RV ++pkcs11h_setPINCachePeriod ( ++ IN const int pin_cache_period ++); ++ ++/* ++ * pkcs11h_setMaxLoginRetries - Set global login retries attempts. ++ * ++ * Parameters: ++ * max_retries - Login retries handled by the helper. ++ */ ++CK_RV ++pkcs11h_setMaxLoginRetries ( ++ IN const unsigned max_retries ++); ++ ++/* ++ * pkcs11h_addProvider - Add a PKCS#11 provider. ++ * ++ * Parameters: ++ * reference - Reference name for this provider. ++ * provider - Provider library location. ++ * allow_protected_auth - Allow this provider to use protected authentication. ++ * mask_sign_mode - Provider signmode override. ++ * slot_event_method - Provider slot event method. ++ * slot_poll_interval - Slot event poll interval (If in polling mode). ++ * cert_is_private - Provider's certificate access should be done after login. ++ * ++ * This function must be called from the main thread. ++ * ++ * The global allow_protected_auth must be enabled in order to allow provider specific. ++ * The mask_sign_mode can be 0 in order to automatically detect key sign mode. ++ */ ++CK_RV ++pkcs11h_addProvider ( ++ IN const char * const reference, ++ IN const char * const provider_location, ++ IN const PKCS11H_BOOL allow_protected_auth, ++ IN const unsigned mask_sign_mode, ++ IN const int slot_event_method, ++ IN const int slot_poll_interval, ++ IN const PKCS11H_BOOL cert_is_private ++); ++ ++/* ++ * pkcs11h_delProvider - Delete a PKCS#11 provider. ++ * ++ * Parameters: ++ * reference - Reference name for this provider. ++ * ++ * This function must be called from the main thread. ++ */ ++CK_RV ++pkcs11h_removeProvider ( ++ IN const char * const reference ++); ++ ++/* ++ * pkcs11h_forkFixup - Handle special case of Unix fork() ++ * ++ * This function should be called after fork is called. This is required ++ * due to a limitation of the PKCS#11 standard. ++ * ++ * This function must be called from the main thread. ++ * ++ * The helper library handles fork automatically if ENABLE_PKCS11H_THREADING ++ * is set on configuration file, by use of pthread_atfork. ++ */ ++CK_RV ++pkcs11h_forkFixup (); ++ ++/* ++ * pkcs11h_plugAndPlay - Handle slot rescan. ++ * ++ * This function must be called from the main thread. ++ * ++ * PKCS#11 providers do not allow plug&play, plug&play can be established by ++ * finalizing all providers and initializing them again. ++ * ++ * The cost of this process is invalidating all sessions, and require user ++ * login at the next access. ++ */ ++CK_RV ++pkcs11h_plugAndPlay (); ++ ++/* ++ * pkcs11h_token_freeTokenId - Free token_id object. ++ * ++ * Parameters: ++ * token_id - token_id. ++ */ ++CK_RV ++pkcs11h_token_freeTokenId ( ++ IN pkcs11h_token_id_t token_id ++); ++ ++/* ++ * pkcs11h_duplicateTokenId - Duplicate token_id object. ++ * ++ * Parameters: ++ * to - target. ++ * from - source. ++ */ ++CK_RV ++pkcs11h_token_duplicateTokenId ( ++ OUT pkcs11h_token_id_t * const to, ++ IN const pkcs11h_token_id_t from ++); ++ ++/* ++ * pkcs11h_sameTokenId - Returns TRUE if same token id ++ * ++ * Parameters: ++ * a - a. ++ * b - b. ++ */ ++PKCS11H_BOOL ++pkcs11h_token_sameTokenId ( ++ IN const pkcs11h_token_id_t a, ++ IN const pkcs11h_token_id_t b ++); ++ ++/* ++ * pkcs11h_token_login - Force login, avoid hooks. ++ * ++ * Parameters: ++ * token_id - Token to login into. ++ * readonly - Should session be readonly. ++ * pin - PIN to login, NULL for protected authentication ++ */ ++CK_RV ++pkcs11h_token_login ( ++ IN const pkcs11h_token_id_t token_id, ++ IN const PKCS11H_BOOL readonly, ++ IN const char * const pin ++); ++ ++#if defined(ENABLE_PKCS11H_SERIALIZATION) ++ ++/* ++ * pkcs11h_serializeTokenId - Serialize token_id into string. ++ * ++ * Parameters: ++ * sz - Output string. ++ * max - Maximum string size. ++ * token_id - id to serialize ++ * ++ * sz may be NULL to get size ++ */ ++CK_RV ++pkcs11h_token_serializeTokenId ( ++ OUT char * const sz, ++ IN OUT size_t *max, ++ IN const pkcs11h_token_id_t token_id ++); ++ ++/* ++ * pkcs11h_deserializeTokenId - Deserialize token_id from string. ++ * ++ * Parameters: ++ * p_token_id - id. ++ * sz - Input string ++ */ ++CK_RV ++pkcs11h_token_deserializeTokenId ( ++ OUT pkcs11h_token_id_t *p_token_id, ++ IN const char * const sz ++); ++ ++#endif /* ENABLE_PKCS11H_SERIALIZATION */ ++ ++#if defined(ENABLE_PKCS11H_TOKEN) ++ ++/* ++ * pkcs11h_token_ensureAccess - Ensure token is accessible. ++ * ++ * Parameters: ++ * token_id - Token id object. ++ * user_data - Optional user data, to be passed to hooks. ++ * mask_prompt - Allow prompt. ++ */ ++CK_RV ++pkcs11h_token_ensureAccess ( ++ IN const pkcs11h_token_id_t token_id, ++ IN void * const user_data, ++ IN const unsigned mask_prompt ++); ++ ++#endif /* ENABLE_PKCS11H_TOKEN */ ++ ++#if defined(ENABLE_PKCS11H_DATA) ++ ++/* ++ * pkcs11h_data_get - get data object. ++ * ++ * Parameters: ++ * token_id - Token id object. ++ * is_public - Object is public. ++ * application - Object application attribute. ++ * label - Object label attribute. ++ * user_data - Optional user data, to be passed to hooks. ++ * mask_prompt - Allow prompt. ++ * blob - blob, set to NULL to get size. ++ * p_blob_size - blob size. ++ */ ++CK_RV ++pkcs11h_data_get ( ++ IN const pkcs11h_token_id_t token_id, ++ IN const PKCS11H_BOOL is_public, ++ IN const char * const application, ++ IN const char * const label, ++ IN void * const user_data, ++ IN const unsigned mask_prompt, ++ OUT unsigned char * const blob, ++ IN OUT size_t * const p_blob_size ++); ++ ++/* ++ * pkcs11h_data_put - put data object. ++ * ++ * Parameters: ++ * token_id - Token id object. ++ * is_public - Object is public. ++ * application - Object application attribute. ++ * label - Object label attribute. ++ * user_data - Optional user data, to be passed to hooks. ++ * mask_prompt - Allow prompt. ++ * blob - blob. ++ * blob_size - blob size. ++ */ ++CK_RV ++pkcs11h_data_put ( ++ IN const pkcs11h_token_id_t token_id, ++ IN const PKCS11H_BOOL is_public, ++ IN const char * const application, ++ IN const char * const label, ++ IN void * const user_data, ++ IN const unsigned mask_prompt, ++ OUT unsigned char * const blob, ++ IN const size_t blob_size ++); ++ ++/* ++ * pkcs11h_data_del - delete data object. ++ * ++ * Parameters: ++ * token_id - Token id object. ++ * is_public - Object is public. ++ * application - Object application attribute. ++ * label - Object label attribute. ++ * user_data - Optional user data, to be passed to hooks. ++ * mask_prompt - Allow prompt. ++ */ ++CK_RV ++pkcs11h_data_del ( ++ IN const pkcs11h_token_id_t token_id, ++ IN const PKCS11H_BOOL is_public, ++ IN const char * const application, ++ IN const char * const label, ++ IN void * const user_data, ++ IN const unsigned mask_prompt ++); ++ ++#endif /* ENABLE_PKCS11H_DATA */ ++ ++#if defined(ENABLE_PKCS11H_CERTIFICATE) ++/*======================================================================* ++ * CERTIFICATE INTERFACE ++ *======================================================================*/ ++ ++/* ++ * pkcs11h_certificate_freeCertificateId - Free certificate_id object. ++ */ ++CK_RV ++pkcs11h_certificate_freeCertificateId ( ++ IN pkcs11h_certificate_id_t certificate_id ++); ++ ++/* ++ * pkcs11h_duplicateCertificateId - Duplicate certificate_id object. ++ */ ++CK_RV ++pkcs11h_certificate_duplicateCertificateId ( ++ OUT pkcs11h_certificate_id_t * const to, ++ IN const pkcs11h_certificate_id_t from ++); ++ ++/* ++ * pkcs11h_certificate_setCertificateIdCertificateBlob - Sets internal certificate_id blob. ++ * ++ * Parameters: ++ * certificate_id - Certificate id ojbect. ++ * blob - blob. ++ * blob_size - blob size. ++ * ++ * Useful to set after deserialization so certificate is available and not read from token. ++ */ ++CK_RV ++pkcs11h_certificate_setCertificateIdCertificateBlob ( ++ IN const pkcs11h_certificate_id_t certificate_id, ++ IN const unsigned char * const blob, ++ IN const size_t blob_size ++); ++ ++/* ++ * pkcs11h_certificate_freeCertificate - Free certificate object. ++ * ++ * Parameters: ++ * certificate - Certificate ojbect. ++ */ ++CK_RV ++pkcs11h_certificate_freeCertificate ( ++ IN pkcs11h_certificate_t certificate ++); ++ ++/* ++ * pkcs11h_certificate_create - Create a certificate object out of certificate_id. ++ * ++ * Parameters: ++ * certificate_id - Certificate id object to be based on. ++ * user_data - Optional user data, to be passed to hooks. ++ * mask_prompt - Allow prompt. ++ * pin_cache_period - Session specific cache period. ++ * p_certificate - Receives certificate object. ++ * ++ * The certificate id object may not specify the full certificate. ++ * The certificate object must be freed by caller. ++ */ ++CK_RV ++pkcs11h_certificate_create ( ++ IN const pkcs11h_certificate_id_t certificate_id, ++ IN void * const user_data, ++ IN const unsigned mask_prompt, ++ IN const int pin_cache_period, ++ OUT pkcs11h_certificate_t * const p_certificate ++); ++ ++/* ++ * pkcs11h_certificate_getPromptMask - Extract user data out of certificate. ++ * ++ * Parameters: ++ * certificate - Certificate ojbect. ++ * ++ * Returns: ++ * mask_prompt - Allow prompt. ++ * ++ */ ++unsigned ++pkcs11h_certificate_getPromptMask ( ++ IN const pkcs11h_certificate_t certificate ++); ++ ++/* ++ * pkcs11h_certificate_setPromptMask - Extract user data out of certificate. ++ * ++ * Parameters: ++ * certificate - Certificate ojbect. ++ * mask_prompt - Allow prompt. ++ */ ++void ++pkcs11h_certificate_setPromptMask ( ++ IN const pkcs11h_certificate_t certificate, ++ IN const unsigned ask_prompt ++); ++ ++/* ++ * pkcs11h_certificate_getUserData - Extract user data out of certificate. ++ * ++ * Parameters: ++ * certificate - Certificate ojbect. ++ * ++ * Returns: ++ * user_data - Optional user data, to be passed to hooks. ++ */ ++void * ++pkcs11h_certificate_getUserData ( ++ IN const pkcs11h_certificate_t certificate ++); ++ ++/* ++ * pkcs11h_certificate_setUserData - Extract user data out of certificate. ++ * ++ * Parameters: ++ * certificate - Certificate ojbect. ++ * user_data - Optional user data, to be passed to hooks. ++ */ ++void ++pkcs11h_certificate_setUserData ( ++ IN const pkcs11h_certificate_t certificate, ++ IN void * const user_data ++); ++ ++/* ++ * pkcs11h_certificate_getCertificateId - Get certifiate id object out of a certifiate ++ * ++ * Parameters: ++ * certificate - Certificate object. ++ * p_certificate_id - Certificate id object pointer. ++ * ++ * The certificate id must be freed by caller. ++ */ ++CK_RV ++pkcs11h_certificate_getCertificateId ( ++ IN const pkcs11h_certificate_t certificate, ++ OUT pkcs11h_certificate_id_t * const p_certificate_id ++); ++ ++/* ++ * pkcs11h_certificate_getCertificateBlob - Get the certificate blob out of the certificate object. ++ * ++ * Parameters: ++ * certificate - Certificate object. ++ * certificate_blob - Buffer. ++ * certificate_blob_size - Buffer size. ++ * ++ * Buffer may be NULL in order to get size. ++ */ ++CK_RV ++pkcs11h_certificate_getCertificateBlob ( ++ IN const pkcs11h_certificate_t certificate, ++ OUT unsigned char * const certificate_blob, ++ IN OUT size_t * const p_certificate_blob_size ++); ++ ++#if defined(ENABLE_PKCS11H_SERIALIZATION) ++ ++/* ++ * pkcs11h_certificate_serializeCertificateId - Serialize certificate_id into a string ++ * ++ * Parametrs: ++ * sz - Output string. ++ * max - Max buffer size. ++ * certificate_id - id to serialize ++ * ++ * sz may be NULL in order to get size. ++ */ ++CK_RV ++pkcs11h_certificate_serializeCertificateId ( ++ OUT char * const sz, ++ IN OUT size_t *max, ++ IN const pkcs11h_certificate_id_t certificate_id ++); ++ ++/* ++ * pkcs11h_certificate_deserializeCertificateId - Deserialize certificate_id out of string. ++ * ++ * Parameters: ++ * p_certificate_id - id. ++ * sz - Inut string ++ */ ++CK_RV ++pkcs11h_certificate_deserializeCertificateId ( ++ OUT pkcs11h_certificate_id_t * const p_certificate_id, ++ IN const char * const sz ++); ++ ++#endif /* ENABLE_PKCS11H_SERIALIZATION */ ++ ++/* ++ * pkcs11h_certificate_ensureCertificateAccess - Ensure certificate is accessible. ++ * ++ * Parameters: ++ * certificate - Certificate object. ++ */ ++CK_RV ++pkcs11h_certificate_ensureCertificateAccess ( ++ IN const pkcs11h_certificate_t certificate ++); ++ ++/* ++ * pkcs11h_certificate_ensureKeyAccess - Ensure key is accessible. ++ * ++ * Parameters: ++ * certificate - Certificate object. ++ */ ++CK_RV ++pkcs11h_certificate_ensureKeyAccess ( ++ IN const pkcs11h_certificate_t certificate ++); ++ ++/* ++ * pkcs11h_certificate_lockSession - Lock session for threded environment ++ * ++ * Parameters: ++ * certificate - Certificate object. ++ * ++ * This must be called on threaded environment, so both calls to _sign and ++ * _signRecover and _decrypt will be from the same source. ++ * Failing to lock session, will result with CKR_OPERATION_ACTIVE if ++ * provider is good, or unexpected behaviour for others. ++ * ++ * It is save to call this also in none threaded environment, it will do nothing. ++ * Call this also if you are doing one stage operation, since locking is not ++ * done by method. ++ */ ++CK_RV ++pkcs11h_certificate_lockSession ( ++ IN const pkcs11h_certificate_t certificate ++); ++ ++/* ++ * pkcs11h_certificate_releaseSession - Releases session lock. ++ * ++ * Parameters: ++ * certificate - Certificate object. ++ * ++ * See pkcs11h_certificate_lockSession. ++ */ ++CK_RV ++pkcs11h_certificate_releaseSession ( ++ IN const pkcs11h_certificate_t certificate ++); ++ ++/* ++ * pkcs11h_certificate_sign - Sign data. ++ * ++ * Parameters: ++ * certificate - Certificate object. ++ * mech_type - PKCS#11 mechanism. ++ * source - Buffer to sign. ++ * source_size - Buffer size. ++ * target - Target buffer, can be NULL to get size. ++ * target_size - Target buffer size. ++ */ ++CK_RV ++pkcs11h_certificate_sign ( ++ IN const pkcs11h_certificate_t certificate, ++ IN const CK_MECHANISM_TYPE mech_type, ++ IN const unsigned char * const source, ++ IN const size_t source_size, ++ OUT unsigned char * const target, ++ IN OUT size_t * const p_target_size ++); ++ ++/* ++ * pkcs11h_certificate_signRecover - Sign data. ++ * ++ * Parameters: ++ * certificate - Certificate object. ++ * mech_type - PKCS#11 mechanism. ++ * source - Buffer to sign. ++ * source_size - Buffer size. ++ * target - Target buffer, can be NULL to get size. ++ * target_size - Target buffer size. ++ */ ++CK_RV ++pkcs11h_certificate_signRecover ( ++ IN const pkcs11h_certificate_t certificate, ++ IN const CK_MECHANISM_TYPE mech_type, ++ IN const unsigned char * const source, ++ IN const size_t source_size, ++ OUT unsigned char * const target, ++ IN OUT size_t * const p_target_size ++); ++ ++/* ++ * pkcs11h_certificate_signAny - Sign data mechanism determined by key attributes. ++ * ++ * Parameters: ++ * certificate - Certificate object. ++ * mech_type - PKCS#11 mechanism. ++ * source - Buffer to sign. ++ * source_size - Buffer size. ++ * target - Target buffer, can be NULL to get size. ++ * target_size - Target buffer size. ++ */ ++CK_RV ++pkcs11h_certificate_signAny ( ++ IN const pkcs11h_certificate_t certificate, ++ IN const CK_MECHANISM_TYPE mech_type, ++ IN const unsigned char * const source, ++ IN const size_t source_size, ++ OUT unsigned char * const target, ++ IN OUT size_t * const p_target_size ++); ++ ++/* ++ * pkcs11h_certificate_decrypt - Decrypt data. ++ * ++ * Parameters: ++ * certificate - Certificate object. ++ * mech_type - PKCS#11 mechanism. ++ * source - Buffer to sign. ++ * source_size - Buffer size. ++ * target - Target buffer, can be NULL to get size. ++ * target_size - Target buffer size. ++ */ ++CK_RV ++pkcs11h_certificate_decrypt ( ++ IN const pkcs11h_certificate_t certificate, ++ IN const CK_MECHANISM_TYPE mech_type, ++ IN const unsigned char * const source, ++ IN const size_t source_size, ++ OUT unsigned char * const target, ++ IN OUT size_t * const p_target_size ++); ++ ++#endif /* ENABLE_PKCS11H_CERTIFICATE */ ++ ++#if defined(ENABLE_PKCS11H_LOCATE) ++/*======================================================================* ++ * LOCATE INTERFACE ++ *======================================================================*/ ++ ++#if defined(ENABLE_PKCS11H_TOKEN) || defined(ENABLE_PKCS11H_CERTIFICATE) ++ ++/* ++ * pkcs11h_locate_token - Locate token based on atributes. ++ * ++ * Parameters: ++ * slot_type - How to locate slot. ++ * slot - Slot name. ++ * user_data - Optional user data, to be passed to hooks. ++ * mask_prompt - Allow prompt. ++ * p_token_id - Token object. ++ * ++ * Slot: ++ * id - Slot number. ++ * name - Slot name. ++ * label - Available token label. ++ * ++ * Caller must free token id. ++ */ ++CK_RV ++pkcs11h_locate_token ( ++ IN const char * const slot_type, ++ IN const char * const slot, ++ IN void * const user_data, ++ IN const unsigned mask_prompt, ++ OUT pkcs11h_token_id_t * const p_token_id ++); ++ ++#endif /* ENABLE_PKCS11H_TOKEN || ENABLE_PKCS11H_CERTIFICATE */ ++ ++#if defined(ENABLE_PKCS11H_CERTIFICATE) ++ ++/* ++ * pkcs11h_locate_certificate - Locate certificate based on atributes. ++ * ++ * Parameters: ++ * slot_type - How to locate slot. ++ * slot - Slot name. ++ * id_type - How to locate object. ++ * id - Object name. ++ * user_data - Optional user data, to be passed to hooks. ++ * mask_prompt - Allow prompt. ++ * p_certificate_id - Certificate object. ++ * ++ * Slot: ++ * Same as pkcs11h_locate_token. ++ * ++ * Object: ++ * id - Certificate CKA_ID (hex string) (Fastest). ++ * label - Certificate CKA_LABEL (string). ++ * subject - Certificate subject (OpenSSL or gnutls DN). ++ * ++ * Caller must free certificate id. ++ */ ++CK_RV ++pkcs11h_locate_certificate ( ++ IN const char * const slot_type, ++ IN const char * const slot, ++ IN const char * const id_type, ++ IN const char * const id, ++ IN void * const user_data, ++ IN const unsigned mask_prompt, ++ OUT pkcs11h_certificate_id_t * const p_certificate_id ++); ++ ++#endif /* ENABLE_PKCS11H_CERTIFICATE */ ++ ++#endif /* ENABLE_PKCS11H_LOCATE */ ++ ++#if defined(ENABLE_PKCS11H_ENUM) ++/*======================================================================* ++ * ENUM INTERFACE ++ *======================================================================*/ ++ ++#if defined(ENABLE_PKCS11H_TOKEN) ++ ++/* ++ * pkcs11h_freeTokenIdList - Free certificate_id list. ++ */ ++CK_RV ++pkcs11h_token_freeTokenIdList ( ++ IN const pkcs11h_token_id_list_t token_id_list ++); ++ ++/* ++ * pkcs11h_token_enumTokenIds - Enumerate available tokens ++ * ++ * Parameters: ++ * p_token_id_list - A list of token ids. ++ * ++ * Caller must free the list. ++ */ ++CK_RV ++pkcs11h_token_enumTokenIds ( ++ IN const int method, ++ OUT pkcs11h_token_id_list_t * const p_token_id_list ++); ++ ++#endif /* ENABLE_PKCS11H_TOKEN */ ++ ++#if defined(ENABLE_PKCS11H_DATA) ++ ++/* ++ * pkcs11h_data_freeDataIdList - free data object list.. ++ * ++ * Parameters: ++ * data_id_list - list to free. ++ */ ++CK_RV ++pkcs11h_data_freeDataIdList ( ++ IN const pkcs11h_data_id_list_t data_id_list ++); ++ ++/* ++ * pkcs11h_data_enumDataObjects - get list of data objects. ++ * ++ * Parameters: ++ * token_id - token id. ++ * is_public - Get a list of public objects. ++ * user_data - Optional user data, to be passed to hooks. ++ * mask_prompt - Allow prompt. ++ * p_data_id_list - List location. ++ */ ++CK_RV ++pkcs11h_data_enumDataObjects ( ++ IN const pkcs11h_token_id_t token_id, ++ IN const PKCS11H_BOOL is_public, ++ IN void * const user_data, ++ IN const unsigned mask_prompt, ++ OUT pkcs11h_data_id_list_t * const p_data_id_list ++); ++ ++#endif /* ENABLE_PKCS11H_DATA */ ++ ++#if defined(ENABLE_PKCS11H_CERTIFICATE) ++ ++/* ++ * pkcs11h_certificate_freeCertificateIdList - Free certificate_id list. ++ */ ++CK_RV ++pkcs11h_certificate_freeCertificateIdList ( ++ IN const pkcs11h_certificate_id_list_t cert_id_list ++); ++ ++/* ++ * pkcs11h_certificate_enumTokenCertificateIds - Enumerate available certificates on specific token ++ * ++ * Parameters: ++ * token_id - Token id to enum. ++ * method - How to fetch certificates. ++ * user_data - Some user specific data. ++ * mask_prompt - Allow prompt. ++ * p_cert_id_issuers_list - Receives issues list, can be NULL. ++ * p_cert_id_end_list - Receives end certificates list. ++ * ++ * This function will likely take long time. ++ * ++ * Method can be one of the following: ++ * PKCS11H_ENUM_METHOD_CACHE ++ * Return available certificates, even if token was once detected and ++ * was removed. ++ * PKCS11H_ENUM_METHOD_CACHE_EXIST ++ * Return available certificates for available tokens only, don't ++ * read the contents of the token if already read, even if this token ++ * removed and inserted. ++ * PKCS11H_ENUM_METHOD_RELOAD ++ * Clear all caches and then enum. ++ * ++ * Caller must free the lists. ++ */ ++CK_RV ++pkcs11h_certificate_enumTokenCertificateIds ( ++ IN const pkcs11h_token_id_t token_id, ++ IN const int method, ++ IN void * const user_data, ++ IN const unsigned mask_prompt, ++ OUT pkcs11h_certificate_id_list_t * const p_cert_id_issuers_list, ++ OUT pkcs11h_certificate_id_list_t * const p_cert_id_end_list ++); ++ ++/* ++ * pkcs11h_enum_getCertificateIds - Enumerate available certificates. ++ * ++ * Parameters: ++ * method - How to fetch certificates. ++ * user_data - Some user specific data. ++ * mask_prompt - Allow prompt. ++ * p_cert_id_issuers_list - Receives issues list, can be NULL. ++ * p_cert_id_end_list - Receives end certificates list. ++ * ++ * This function will likely take long time. ++ * ++ * Method can be one of the following: ++ * PKCS11H_ENUM_METHOD_CACHE ++ * Return available certificates, even if token was once detected and ++ * was removed. ++ * PKCS11H_ENUM_METHOD_CACHE_EXIST ++ * Return available certificates for available tokens only, don't ++ * read the contents of the token if already read, even if this token ++ * removed and inserted. ++ * PKCS11H_ENUM_METHOD_RELOAD ++ * Clear all caches and then enum. ++ * ++ * Caller must free lists. ++ */ ++CK_RV ++pkcs11h_certificate_enumCertificateIds ( ++ IN const int method, ++ IN void * const user_data, ++ IN const unsigned mask_prompt, ++ OUT pkcs11h_certificate_id_list_t * const p_cert_id_issuers_list, ++ OUT pkcs11h_certificate_id_list_t * const p_cert_id_end_list ++); ++ ++#endif /* ENABLE_PKCS11H_CERTIFICATE */ ++ ++#endif /* ENABLE_PKCS11H_ENUM */ ++ ++#if defined(ENABLE_PKCS11H_OPENSSL) ++/*======================================================================* ++ * OPENSSL INTERFACE ++ *======================================================================*/ ++ ++/* ++ * pkcs11h_openssl_getX509 - Returns an X509 object out of the openssl_session object. ++ * ++ * Parameters: ++ * certificate - Certificate object. ++ */ ++X509 * ++pkcs11h_openssl_getX509 ( ++ IN const pkcs11h_certificate_t certificate ++); ++ ++/* ++ * pkcs11h_openssl_createSession - Create OpenSSL session based on a certificate object. ++ * ++ * Parameters: ++ * certificate - Certificate object. ++ * ++ * The certificate object will be freed by the OpenSSL interface on session end. ++ */ ++pkcs11h_openssl_session_t ++pkcs11h_openssl_createSession ( ++ IN const pkcs11h_certificate_t certificate ++); ++ ++/* ++ * pkcs11h_openssl_getCleanupHook - Sets cleanup hook ++ * ++ * Parameters: ++ * openssl_session - session. ++ */ ++pkcs11h_hook_openssl_cleanup_t ++pkcs11h_openssl_getCleanupHook ( ++ IN const pkcs11h_openssl_session_t openssl_session ++); ++ ++/* ++ * pkcs11h_openssl_setCleanupHook - Sets cleanup hook ++ * ++ * Parameters: ++ * openssl_session - session. ++ * cleanup - hook. ++ */ ++void ++pkcs11h_openssl_setCleanupHook ( ++ IN const pkcs11h_openssl_session_t openssl_session, ++ IN const pkcs11h_hook_openssl_cleanup_t cleanup ++); ++ ++/* ++ * pkcs11h_openssl_freeSession - Free OpenSSL session. ++ * ++ * Parameters: ++ * openssl_session - Session to free. ++ * ++ * The openssl_session object has a reference count just like other OpenSSL objects. ++ */ ++void ++pkcs11h_openssl_freeSession ( ++ IN const pkcs11h_openssl_session_t openssl_session ++); ++ ++/* ++ * pkcs11h_openssl_session_getRSA - Returns an RSA object out of the openssl_session object. ++ * ++ * Parameters: ++ * openssl_session - Session. ++ */ ++RSA * ++pkcs11h_openssl_session_getRSA ( ++ IN const pkcs11h_openssl_session_t openssl_session ++); ++ ++/* ++ * pkcs11h_openssl_session_getX509 - Returns an X509 object out of the openssl_session object. ++ * ++ * Parameters: ++ * openssl_session - Session. ++ */ ++X509 * ++pkcs11h_openssl_session_getX509 ( ++ IN const pkcs11h_openssl_session_t openssl_session ++); ++ ++#endif /* ENABLE_PKCS11H_OPENSSL */ ++ ++#if defined(ENABLE_PKCS11H_STANDALONE) ++/*======================================================================* ++ * STANDALONE INTERFACE ++ *======================================================================*/ ++ ++void ++pkcs11h_standalone_dump_slots ( ++ IN const pkcs11h_output_print_t my_output, ++ IN void * const global_data, ++ IN const char * const provider ++); ++ ++void ++pkcs11h_standalone_dump_objects ( ++ IN const pkcs11h_output_print_t my_output, ++ IN void * const global_data, ++ IN const char * const provider, ++ IN const char * const slot, ++ IN const char * const pin ++); ++ ++#endif /* ENABLE_PKCS11H_STANDALONE */ ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* __PKCS11H_HELPER_H */ +diff -urNp openssh-4.4p1/README.pkcs11 openssh-4.4p1+pkcs11-0.17/README.pkcs11 +--- openssh-4.4p1/README.pkcs11 1970-01-01 02:00:00.000000000 +0200 ++++ openssh-4.4p1+pkcs11-0.17/README.pkcs11 2006-10-18 20:22:08.000000000 +0200 +@@ -0,0 +1,49 @@ ++The PKCS#11 patch modify ssh-add and ssh-agent to support PKCS#11 private keys ++and certificates (http://alon.barlev.googlepages.com/openssh-pkcs11). ++ ++It allows using multiple PKCS#11 providers at the same time, selecting keys by ++id, label or certificate subject, handling card removal and card insert events, ++handling card re-insert to a different slot, supporting session expiration. ++ ++A valid X.509 certificate should exist on the token, without X.509 support it is ++exported as regular RSA key. Self-signed certificates are treated as RSA key and ++not as X.509 RSA key. ++ ++If you like X.509 (http://roumenpetrov.info/openssh) support apply the X.509 ++patch AFTER the PKCS#11 patch. You can use -o PubkeyAlgorithms=ssh-rsa in order to ++authenticate to none X.509 servers. ++ ++One significant change is that the ssh-agent prompts for passwords now... So you ++need to configure it with a program that asks for card insert or PIN, a program ++such as x11-ssh-askpass. Current implementation (ssh-add asks for passwords) is ++not valid for dynamic smartcard environment. ++ ++Current implementation uses the askpin program also for prompting card insert... ++Don't be confused, it only expects ok or cancel, some simple scripts available ++at http://alon.barlev.googlepages.com/openssh-pkcs11 that uses KDE, Gnome and .NET ++in order to display these dialogs. ++ ++You can view full usage by: ++$ ssh-agent /bin/sh ++$ ssh-add -h ++ ++A common scenario is the following: ++$ ssh-agent /bin/sh ++$ ssh-add --pkcs11-ask-pin `which openssh-kde-dialogs.sh` ++$ ssh-add --pkcs11-add-provider --pkcs11-provider /usr/lib/pkcs11/MyProvider.so ++$ ssh-add --pkcs11-add-id --pkcs11-id "serialized id" ++$ ssh myhost ++ ++In order to see available objects, you can use: ++$ ssh-add --pkcs11-show-ids --pkcs11-provider /usr/lib/pkcs11/MyProvider.so ++ ++In order to add id without accessing the token, you must put the certificate in ++a PEM file and use: ++$ ssh-add --pkcs11-add-id --pkcs11-id "serialized id" --pkcs11-cert-file my.pem ++ ++In order to debug open two shells: ++1$ rm -fr /tmp/s; ssh-agent -d -d -d -a /tmp/s ++ ++2$ SSH_AUTH_SOCK=/tmp/s; export SSH_AUTH_SOCK; ++2$ [ssh-add]... ++ +diff -urNp openssh-4.4p1/ssh-add.c openssh-4.4p1+pkcs11-0.17/ssh-add.c +--- openssh-4.4p1/ssh-add.c 2006-09-01 08:38:37.000000000 +0300 ++++ openssh-4.4p1+pkcs11-0.17/ssh-add.c 2006-10-12 15:10:42.000000000 +0200 +@@ -56,12 +56,15 @@ + #include "rsa.h" + #include "log.h" + #include "key.h" ++#include "pkcs11.h" + #include "buffer.h" + #include "authfd.h" + #include "authfile.h" + #include "pathnames.h" + #include "misc.h" + ++static void usage (void); ++ + /* argv0 */ + extern char *__progname; + +@@ -306,6 +309,261 @@ do_file(AuthenticationConnection *ac, in + return 0; + } + ++#ifndef SSH_PKCS11_DISABLED ++ ++static ++int ++do_pkcs11 (AuthenticationConnection *ac, int argc, char *argv[]) ++{ ++ /* ++ * TEMP TEMP TEMP TEMP ++ * ++ * This should be fixed if another mechanism ++ * will be propsed. ++ */ ++ pkcs11_identity *id = NULL; ++ char *szPKCS11Provider = NULL; ++ char *szPKCS11Id = NULL; ++ char *szPKCS11SignMode = NULL; ++ char *szPKCS11AskPIN = NULL; ++ char *szPKCS11SlotId = NULL; ++ char *szPKCS11CertFile = NULL; ++ int fDebug = 0; ++ int fPKCS11AddProvider = 0; ++ int fPKCS11AddId = 0; ++ int fPKCS11RemoveId = 0; ++ int fPKCS11ShowIds = 0; ++ int fPKCS11DumpSlots = 0; ++ int fPKCS11DumpObjects = 0; ++ int fPKCS11ProtectedAuthentication = 0; ++ int fPKCS11CertPrivate = 0; ++ int nPKCS11PINCachePeriod = -1; ++ int fBadUsage = 0; ++ int ret = 0; ++ int nSkipPrmCount; ++ int i; ++ ++ for (i=0,nSkipPrmCount=0;iid = strdup (szPKCS11Id); ++ id->pin_cache_period = nPKCS11PINCachePeriod; ++ id->cert_file = szPKCS11CertFile; ++ } ++ } ++ } ++ ++ if (ret == 0) { ++ if (fDebug) { ++ log_init(__progname, SYSLOG_LEVEL_DEBUG3, SYSLOG_FACILITY_AUTH, 1); ++ } ++ ++ if (fPKCS11ShowIds) { ++ pkcs11_show_ids (szPKCS11Provider, fPKCS11ProtectedAuthentication, fPKCS11CertPrivate); ++ ret = 0; ++ } ++ else if (fPKCS11DumpSlots) { ++ pkcs11_dump_slots (szPKCS11Provider); ++ ret = 0; ++ } ++ else if (fPKCS11DumpObjects) { ++ char *szPIN = read_passphrase("PIN: ", RP_ALLOW_STDIN); ++ if (szPIN[0] != '\0') { ++ pkcs11_dump_objects (szPKCS11Provider, szPKCS11SlotId, szPIN); ++ } ++ memset (szPIN, 0, strlen (szPIN)); ++ xfree (szPIN); ++ ret = 0; ++ } ++ else if (szPKCS11AskPIN != NULL) { ++ ret = !ssh_pkcs11_set_ask_pin (ac, szPKCS11AskPIN); ++ ++ if (ret) { ++ fprintf (stderr, "Failed\n"); ++ } ++ else { ++ fprintf (stderr, "Success\n"); ++ } ++ } ++ else if (fPKCS11AddProvider) { ++ ret = !ssh_pkcs11_add_provider ( ++ ac, ++ szPKCS11Provider, ++ fPKCS11ProtectedAuthentication, ++ szPKCS11SignMode, ++ fPKCS11CertPrivate ++ ); ++ ++ if (ret) { ++ fprintf (stderr, "Cannot add provider %s\n", szPKCS11Provider); ++ } ++ else { ++ fprintf (stderr, "Provider %s added successfully\n", szPKCS11Provider); ++ } ++ } ++ else if (fPKCS11AddId) { ++ ret = !ssh_pkcs11_id (ac, id, 0); ++ ++ if (ret) { ++ fprintf (stderr, "Cannot add identity\n"); ++ } ++ else { ++ fprintf (stderr, "Identity added successfully\n"); ++ } ++ } ++ else if (fPKCS11RemoveId) { ++ ret = !ssh_pkcs11_id (ac, id, 1); ++ ++ if (ret) { ++ fprintf (stderr, "Cannot remove identity\n"); ++ } ++ else { ++ fprintf (stderr, "Identity removed successfully\n"); ++ } ++ } ++ } ++ ++ if (id != NULL) { ++ pkcs11_identity_free (id); ++ } ++ ++ return ret; ++} ++ ++#endif /* SSH_PKCS11_DISABLED */ ++ + static void + usage(void) + { +@@ -323,6 +581,50 @@ usage(void) + fprintf(stderr, " -s reader Add key in smartcard reader.\n"); + fprintf(stderr, " -e reader Remove key in smartcard reader.\n"); + #endif ++#ifndef SSH_PKCS11_DISABLED ++ fprintf( ++ stderr, ++ ( ++ "\n" ++ " PKCS#11 Options:\n" ++ " --pkcs11-ask-pin prog Set ask-pin program\n" ++ "\n" ++ " --pkcs11-add-provider Add PKCS#11 provider\n" ++ " --pkcs11-provider provider PKCS#11 provider library\n" ++ " [--pkcs11-protected-authentication] Use PKCS#11 protected authentication\n" ++ " [--pkcs11-sign-mode mode] Provider signature mode\n" ++ " auto - determine automatically\n" ++ " sign - perform sign\n" ++ " recover - perform sign recover\n" ++ " any - perform sign and then sign recover\n" ++ " [--pkcs11-cert-private] Login required in order to access certificate\n" ++ "\n" ++ " --pkcs11-show-ids Show available identities\n" ++ " --pkcs11-provider provider PKCS#11 provider library\n" ++ " [--pkcs11-protected-authentication] Use PKCS#11 protected authentication\n" ++ " [--pkcs11-cert-private] Login required in order to access certificate\n" ++ " [-d] debug\n" ++ "\n" ++ " --pkcs11-add-id Add PKCS#11 identity\n" ++ " --pkcs11-id id Serialized string\n" ++ " [--pkcs11-cert-file file] Use this PEM file, don't access token\n" ++ " [--pkcs11-pin-cache period] PIN cache period (seconds)\n" ++ "\n" ++ " --pkcs11-remove-id Remove PKCS#11 identity\n" ++ " --pkcs11-id id Serialized string\n" ++ " [--pkcs11-cert-file file] Use this PEM file, don't access token\n" ++ "\n" ++ " PKCS#11 Debugging Options:\n" ++ " --pkcs11-dump-slots Dump available PKCS#11 slots\n" ++ " --pkcs11-provider provider PKCS#11 provider library\n" ++ "\n" ++ " --pkcs11-dump-objects Dump available PKCS#11 objects\n" ++ " --pkcs11-provider provider PKCS#11 provider library\n" ++ " --pkcs11-slot slot Slot numeric id\n" ++ "\n" ++ ) ++ ); ++#endif /* SSH_PKCS11_DISABLED */ + } + + int +@@ -350,6 +652,17 @@ main(int argc, char **argv) + "Could not open a connection to your authentication agent.\n"); + exit(2); + } ++ ++#ifndef SSH_PKCS11_DISABLED ++ { ++ int r = do_pkcs11 (ac, argc, argv); ++ if (r != -2) { ++ ret = r; ++ goto done; ++ } ++ } ++#endif /* SSH_PKCS11_DISABLED */ ++ + while ((ch = getopt(argc, argv, "lLcdDxXe:s:t:")) != -1) { + switch (ch) { + case 'l': +diff -urNp openssh-4.4p1/ssh-agent.c openssh-4.4p1+pkcs11-0.17/ssh-agent.c +--- openssh-4.4p1/ssh-agent.c 2006-09-01 08:38:37.000000000 +0300 ++++ openssh-4.4p1+pkcs11-0.17/ssh-agent.c 2006-10-12 14:00:53.000000000 +0200 +@@ -71,6 +71,7 @@ + #include "buffer.h" + #include "key.h" + #include "authfd.h" ++#include "pkcs11.h" + #include "compat.h" + #include "log.h" + #include "misc.h" +@@ -690,6 +691,157 @@ send: + } + #endif /* SMARTCARD */ + ++#ifndef SSH_PKCS11_DISABLED ++ ++static ++void ++process_pkcs11_set_ask_pin (SocketEntry *e) ++{ ++ char *szAskPIN = NULL; ++ int success = 0; ++ ++ szAskPIN = buffer_get_string(&e->request, NULL); ++ ++ success = pkcs11_setAskPIN (szAskPIN); ++ ++ buffer_put_int(&e->output, 1); ++ buffer_put_char(&e->output, ++ success ? SSH_AGENT_SUCCESS : SSH_AGENT_FAILURE); ++} ++ ++static void ++process_pkcs11_add_provider (SocketEntry *e) ++{ ++ char *szProvider = NULL; ++ int fProtectedAuthentication = 0; ++ char *szSignMode = NULL; ++ int fCertIsPrivate = 0; ++ int success = 0; ++ ++ szProvider = buffer_get_string(&e->request, NULL); ++ fProtectedAuthentication = buffer_get_int (&e->request); ++ szSignMode = buffer_get_string(&e->request, NULL); ++ fCertIsPrivate = buffer_get_int (&e->request); ++ ++ success = pkcs11_addProvider (szProvider, fProtectedAuthentication, szSignMode, fCertIsPrivate); ++ ++ buffer_put_int(&e->output, 1); ++ buffer_put_char(&e->output, ++ success ? SSH_AGENT_SUCCESS : SSH_AGENT_FAILURE); ++} ++ ++static ++void ++process_pkcs11_add_id (SocketEntry *e) ++{ ++ int success = 0; ++ int version = 2; ++ char szComment[1024]; ++ Key *k = NULL; ++ pkcs11_identity *pkcs11_id = NULL; ++ ++ pkcs11_id = pkcs11_identity_new (); ++ if (pkcs11_id != NULL) { ++ pkcs11_id->id = strdup (buffer_get_string(&e->request, NULL)); ++ pkcs11_id->pin_cache_period = buffer_get_int(&e->request); ++ pkcs11_id->cert_file = strdup (buffer_get_string(&e->request, NULL)); ++ ++ pkcs11_getKey ( ++ pkcs11_id, ++ &k, ++ szComment, ++ sizeof (szComment) ++ ); ++ ++ if (k != NULL) { ++ if (lookup_identity(k, version) == NULL) { ++ Identity *id = xmalloc(sizeof(Identity)); ++ Idtab *tab = NULL; ++ ++ id->key = k; ++ k = NULL; ++ id->comment = xstrdup (szComment); ++ id->death = 0; /* handled by pkcs#11 helper */ ++ id->confirm = 0; ++ ++ tab = idtab_lookup(version); ++ TAILQ_INSERT_TAIL(&tab->idlist, id, next); ++ /* Increment the number of identities. */ ++ tab->nentries++; ++ success = 1; ++ } ++ } ++ } ++ ++ if (k != NULL) { ++ key_free (k); ++ } ++ ++ if (pkcs11_id != NULL) { ++ pkcs11_identity_free (pkcs11_id); ++ } ++ ++ buffer_put_int(&e->output, 1); ++ buffer_put_char(&e->output, ++ success ? SSH_AGENT_SUCCESS : SSH_AGENT_FAILURE); ++} ++ ++static ++void ++process_pkcs11_remove_id (SocketEntry *e) ++{ ++ int success = 0; ++ Identity *id = NULL; ++ int version = 2; ++ char szComment[1024]; ++ Key *k = NULL; ++ ++ pkcs11_identity *pkcs11_id = NULL; ++ ++ pkcs11_id = pkcs11_identity_new (); ++ if (pkcs11_id != NULL) { ++ pkcs11_id->id = strdup (buffer_get_string(&e->request, NULL)); ++ pkcs11_id->pin_cache_period = buffer_get_int(&e->request); ++ pkcs11_id->cert_file = strdup (buffer_get_string(&e->request, NULL)); ++ ++ pkcs11_getKey ( ++ pkcs11_id, ++ &k, ++ szComment, ++ sizeof (szComment) ++ ); ++ ++ if (k != NULL) { ++ id = lookup_identity (k, version); ++ } ++ ++ if (id != NULL) { ++ Idtab *tab = NULL; ++ ++ tab = idtab_lookup(version); ++ TAILQ_REMOVE(&tab->idlist, id, next); ++ tab->nentries--; ++ free_identity(id); ++ id = NULL; ++ success = 1; ++ } ++ } ++ ++ if (k != NULL) { ++ key_free (k); ++ } ++ ++ if (pkcs11_id != NULL) { ++ pkcs11_identity_free (pkcs11_id); ++ } ++ ++ buffer_put_int(&e->output, 1); ++ buffer_put_char(&e->output, ++ success ? SSH_AGENT_SUCCESS : SSH_AGENT_FAILURE); ++} ++ ++#endif /* SSH_PKCS11_DISABLED */ ++ + /* dispatch incoming messages */ + + static void +@@ -785,6 +937,21 @@ process_message(SocketEntry *e) + process_remove_smartcard_key(e); + break; + #endif /* SMARTCARD */ ++ ++#ifndef SSH_PKCS11_DISABLED ++ case SSH_AGENTC_PKCS11_SET_ASK_PIN: ++ process_pkcs11_set_ask_pin (e); ++ break; ++ case SSH_AGENTC_PKCS11_ADD_PROVIDER: ++ process_pkcs11_add_provider (e); ++ break; ++ case SSH_AGENTC_PKCS11_ADD_ID: ++ process_pkcs11_add_id (e); ++ break; ++ case SSH_AGENTC_PKCS11_REMOVE_ID: ++ process_pkcs11_remove_id (e); ++ break; ++#endif /* SSH_PKCS11_DISABLED */ + default: + /* Unknown message. Respond with failure. */ + error("Unknown message %d", type); +@@ -1064,7 +1231,7 @@ main(int ac, char **av) + s_flag++; + break; + case 'd': +- if (d_flag) ++ if (d_flag > 3) + usage(); + d_flag++; + break; +@@ -1167,7 +1334,7 @@ main(int ac, char **av) + * the socket data. The child continues as the authentication agent. + */ + if (d_flag) { +- log_init(__progname, SYSLOG_LEVEL_DEBUG1, SYSLOG_FACILITY_AUTH, 1); ++ log_init(__progname, SYSLOG_LEVEL_DEBUG1+d_flag-1, SYSLOG_FACILITY_AUTH, 1); + format = c_flag ? "setenv %s %s;\n" : "%s=%s; export %s;\n"; + printf(format, SSH_AUTHSOCKET_ENV_NAME, socket_name, + SSH_AUTHSOCKET_ENV_NAME); +@@ -1228,6 +1395,11 @@ main(int ac, char **av) + #endif + + skip: ++ ++#ifndef SSH_PKCS11_DISABLED ++ pkcs11_initialize (1, -1); ++#endif /* SSH_PKCS11_DISABLED */ ++ + new_socket(AUTH_SOCKET, sock); + if (ac > 0) { + mysignal(SIGALRM, check_parent_exists); +@@ -1251,4 +1423,8 @@ skip: + after_select(readsetp, writesetp); + } + /* NOTREACHED */ ++ ++#ifndef SSH_PKCS11_DISABLED ++ pkcs11_terminate (); ++#endif /* SSH_PKCS11_DISABLED */ + } diff --git a/openssh-5.0p1-blacklist.patch b/openssh-5.0p1-blacklist.patch new file mode 100644 index 0000000..0495baf --- /dev/null +++ b/openssh-5.0p1-blacklist.patch @@ -0,0 +1,565 @@ +--- openssh-5.0p1/Makefile.in ++++ openssh-5.0p1/Makefile.in +@@ -62,7 +62,7 @@ + + TARGETS=ssh$(EXEEXT) sshd$(EXEEXT) ssh-add$(EXEEXT) ssh-keygen$(EXEEXT) ssh-keyscan${EXEEXT} ssh-keysign${EXEEXT} ssh-agent$(EXEEXT) scp$(EXEEXT) ssh-rand-helper${EXEEXT} sftp-server$(EXEEXT) sftp$(EXEEXT) + +-LIBSSH_OBJS=acss.o authfd.o authfile.o bufaux.o bufbn.o buffer.o \ ++LIBSSH_OBJS=acss.o authfd.o authfile.o blacklist.o bufaux.o bufbn.o buffer.o \ + canohost.o channels.o cipher.o cipher-acss.o cipher-aes.o \ + cipher-bf1.o cipher-ctr.o cipher-3des1.o cleanup.o \ + compat.o compress.o crc32.o deattack.o fatal.o hostfile.o \ +--- openssh-5.0p1/auth-rh-rsa.c ++++ openssh-5.0p1/auth-rh-rsa.c +@@ -34,6 +34,7 @@ + #include "ssh-gss.h" + #endif + #include "monitor_wrap.h" ++#include "blacklist.h" + + /* import */ + extern ServerOptions options; +@@ -48,6 +49,9 @@ + if (!auth_rhosts(pw, cuser)) + return 0; + ++ if (blacklisted_key(client_host_key, 0)) ++ return 0; ++ + host_status = check_key_in_hostfiles(pw, client_host_key, + chost, _PATH_SSH_SYSTEM_HOSTFILE, + options.ignore_user_known_hosts ? NULL : _PATH_SSH_USER_HOSTFILE); +--- openssh-5.0p1/auth-rsa.c ++++ openssh-5.0p1/auth-rsa.c +@@ -47,6 +47,7 @@ + #include "monitor_wrap.h" + #include "ssh.h" + #include "misc.h" ++#include "blacklist.h" + + /* import */ + extern ServerOptions options; +@@ -265,6 +272,9 @@ + "actual %d vs. announced %d.", + file, linenum, BN_num_bits(key->rsa->n), bits); + ++ if (blacklisted_key(key, 0)) ++ continue; ++ + /* We have found the desired key. */ + /* + * If our options do not allow this key to be used, +--- openssh-5.0p1/auth2-hostbased.c ++++ openssh-5.0p1/auth2-hostbased.c +@@ -47,6 +47,7 @@ + #endif + #include "monitor_wrap.h" + #include "pathnames.h" ++#include "blacklist.h" + + /* import */ + extern ServerOptions options; +@@ -145,6 +146,9 @@ + HostStatus host_status; + int len; + ++ if (blacklisted_key(key, 0)) ++ return 0; ++ + resolvedname = get_canonical_hostname(options.use_dns); + ipaddr = get_remote_ipaddr(); + +--- openssh-5.0p1/auth2-pubkey.c ++++ openssh-5.0p1/auth2-pubkey.c +@@ -52,6 +52,7 @@ + #endif + #include "monitor_wrap.h" + #include "misc.h" ++#include "blacklist.h" + + /* import */ + extern ServerOptions options; +@@ -272,6 +273,9 @@ + int success; + char *file; + ++ if (blacklisted_key(key, 0)) ++ return 0; ++ + file = authorized_keys_file(pw); + success = user_key_allowed2(pw, key, file); + xfree(file); +new file mode 100644 +--- /dev/null ++++ openssh-5.0p1/blacklist.c +@@ -0,0 +1,267 @@ ++/* ++ * Support for RSA/DSA key blacklisting based on partial fingerprints, ++ * developed under Openwall Project for Owl - http://www.openwall.com/Owl/ ++ * ++ * Copyright (c) 2008 Dmitry V. Levin ++ * ++ * Permission to use, copy, modify, and distribute this software for any ++ * purpose with or without fee is hereby granted, provided that the above ++ * copyright notice and this permission notice appear in all copies. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ++ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ++ * ++ * The blacklist encoding was designed by Solar Designer and Dmitry V. Levin. ++ * No intellectual property rights to the encoding scheme are claimed. ++ * ++ * This effort was supported by CivicActions - http://www.civicactions.com ++ * ++ * The file size to encode 294,903 of 48-bit fingerprints is just 1.3 MB, ++ * which corresponds to less than 4.5 bytes per fingerprint. ++ */ ++ ++#include "includes.h" ++#include ++#include ++#include ++#include ++ ++#include "atomicio.h" ++#include "blacklist.h" ++#include "canohost.h" ++#include "log.h" ++#include "pathnames.h" ++#include "servconf.h" ++#include "xmalloc.h" ++ ++extern ServerOptions options; ++ ++typedef struct ++{ ++ /* format version identifier */ ++ char version[8]; ++ /* index size, in bits */ ++ uint8_t index_size; ++ /* offset size, in bits */ ++ uint8_t offset_size; ++ /* record size, in bits */ ++ uint8_t record_bits; ++ /* number of records */ ++ uint8_t records[3]; ++ /* offset shift */ ++ uint8_t shift[2]; ++ ++} __attribute__((packed)) blacklist_header; ++ ++static unsigned ++c2u(uint8_t c) ++{ ++ return (c >= 'a') ? (c - 'a' + 10) : (c - '0'); ++} ++ ++static blacklist_error_t ++validate_blacklist(const char *fname, int fd, unsigned *bytes, ++ unsigned *records, unsigned *shift) ++{ ++ unsigned expected; ++ struct stat st; ++ blacklist_header header; ++ ++ if (fstat(fd, &st)) { ++ error("fstat for blacklist file %s failed: %m", fname); ++ return BLACKLIST_ERROR_ACCESS; ++ } ++ ++ if (atomicio(read, fd, &header, sizeof(header)) != sizeof(header)) { ++ error("read blacklist file %s header failed: %m", fname); ++ return BLACKLIST_ERROR_ACCESS; ++ } ++ ++ if (memcmp(header.version, "SSH-FP", 6)) { ++ error("blacklist file %s has unrecognized format", fname); ++ return BLACKLIST_ERROR_FORMAT; ++ } ++ ++ if (header.index_size != 16 || header.offset_size != 16 || ++ memcmp(header.version, "SSH-FP00", 8)) { ++ error("blacklist file %s has unsupported format", fname); ++ return BLACKLIST_ERROR_VERSION; ++ } ++ ++ *bytes = (header.record_bits >> 3) - 2; ++ *records = ++ (((header.records[0] << 8) + ++ header.records[1]) << 8) + header.records[2]; ++ *shift = (header.shift[0] << 8) + header.shift[1]; ++ ++ expected = sizeof(header) + 0x20000 + (*records) * (*bytes); ++ if (st.st_size != expected) { ++ error("blacklist file %s size mismatch: " ++ "expected size %u, found size %lu", ++ fname, expected, (unsigned long) st.st_size); ++ return BLACKLIST_ERROR_ACCESS; ++ } ++ ++ return BLACKLIST_ERROR_NONE; ++} ++ ++static int ++expected_offset(uint16_t index, uint16_t shift, unsigned records) ++{ ++ return ((index * (long long) records) >> 16) - shift; ++} ++ ++static int ++xlseek(const char *fname, int fd, unsigned seek) ++{ ++ if (lseek(fd, seek, SEEK_SET) != seek) { ++ error("lseek for blacklist file %s failed: %m", fname); ++ return BLACKLIST_ERROR_ACCESS; ++ } ++ return BLACKLIST_ERROR_NONE; ++} ++ ++static blacklist_error_t ++check(const char *fname, int fd, const char *s) ++{ ++ unsigned bytes, records, shift; ++ unsigned num, i, j; ++ int off_start, off_end; ++ blacklist_error_t rc; ++ uint16_t index; ++ /* max number of bytes stored in record_bits, minus two bytes used for index */ ++ uint8_t buf[(0xff >> 3) - 2]; ++ ++ if ((rc = validate_blacklist(fname, fd, &bytes, &records, &shift))) ++ return rc; ++ ++ index = (((((c2u(s[0]) << 4) | c2u(s[1])) << 4) | ++ c2u(s[2])) << 4) | c2u(s[3]); ++ if (xlseek(fname, fd, sizeof(blacklist_header) + index * 2)) ++ return BLACKLIST_ERROR_ACCESS; ++ ++ if (atomicio(read, fd, buf, 4) != 4) { ++ error("read blacklist file %s offsets failed: %m", fname); ++ return BLACKLIST_ERROR_ACCESS; ++ } ++ ++ off_start = (buf[0] << 8) + buf[1] + ++ expected_offset(index, shift, records); ++ if (off_start < 0 || (unsigned) off_start > records) { ++ error("blacklist file %s off_start overflow [%d] for index %#x", ++ fname, off_start, index); ++ return BLACKLIST_ERROR_ACCESS; ++ } ++ if (index < 0xffff) { ++ off_end = (buf[2] << 8) + buf[3] + ++ expected_offset(index + 1, shift, records); ++ if (off_end < off_start || (unsigned) off_end > records) { ++ error("blacklist file %s off_end overflow [%d] for index %#x", ++ fname, off_end, index); ++ return BLACKLIST_ERROR_ACCESS; ++ } ++ } else ++ off_end = records; ++ ++ if (xlseek(fname, fd, ++ sizeof(blacklist_header) + 0x20000 + off_start * bytes)) ++ return BLACKLIST_ERROR_ACCESS; ++ ++ num = off_end - off_start; ++ for (i = 0; i < num; ++i) { ++ if (atomicio(read, fd, buf, bytes) != bytes) { ++ error("read blacklist file %s fingerprints failed: %m", ++ fname); ++ return BLACKLIST_ERROR_ACCESS; ++ } ++ ++ for (j = 0; j < bytes; ++j) ++ if (((c2u(s[4 + j * 2]) << 4) | c2u(s[5 + j * 2])) != ++ buf[j]) ++ break; ++ if (j >= bytes) { ++ debug("blacklisted fingerprint: %s offset=%u, number=%u", ++ s, off_start, i); ++ return BLACKLIST_ERROR_ALL; ++ } ++ } ++ ++ debug("non-blacklisted fingerprint: %s offset=%u, number=%u", ++ s, off_start, num); ++ return BLACKLIST_ERROR_NONE; ++} ++ ++static blacklist_error_t ++blacklisted_fingerprint(const char *hex) ++{ ++ int fd = -1; ++ blacklist_error_t rc = BLACKLIST_ERROR_ACCESS; ++ const char *fname = _PATH_BLACKLIST; ++ char *s, *p; ++ ++ debug("Checking fingerprint %s using blacklist file %s", hex, fname); ++ ++ s = xstrdup(hex); ++ for (p = s; *hex; ++hex) ++ if (*hex != ':') ++ *p++ = *hex; ++ *p = '\0'; ++ ++ if (strlen(s) != 32 || strlen(s) != strspn(s, "0123456789abcdef")) { ++ error("%s: invalid fingerprint", s); ++ goto out; ++ } ++ ++ if ((fd = open(fname, O_RDONLY)) < 0) { ++ if (ENOENT == errno) { ++ rc = BLACKLIST_ERROR_MISSING; ++ verbose("open blacklist file %s failed: %m", fname); ++ } else ++ logit("open blacklist file %s failed: %m", fname); ++ goto out; ++ } ++ ++ rc = check(fname, fd, s); ++ ++out: ++ close(fd); ++ xfree(s); ++ return rc; ++} ++ ++int ++blacklisted_key(Key *key, int hostkey) ++{ ++ int rc; ++ const char *text; ++ char *fp = key_fingerprint(key, SSH_FP_MD5, SSH_FP_HEX); ++ ++ switch ((rc = blacklisted_fingerprint(fp))) { ++ case BLACKLIST_ERROR_NONE: ++ break; ++ case BLACKLIST_ERROR_ALL: ++ text = (options.ignore_blacklist_errors == rc) ? ++ "Permitted" : "Rejected"; ++ if (hostkey) ++ logit("%s blacklisted host key %s", text, fp); ++ else ++ logit("%s blacklisted public key %s from %.100s", ++ text, fp, get_remote_ipaddr()); ++ break; ++ default: ++ if (hostkey) ++ logit("Unable to check blacklist for host key %s", ++ fp); ++ else ++ logit("Unable to check blacklist for public key %s from %.100s", ++ fp, get_remote_ipaddr()); ++ } ++ ++ xfree(fp); ++ return (rc > options.ignore_blacklist_errors); ++} +new file mode 100644 +--- /dev/null ++++ openssh-5.0p1/blacklist.h +@@ -0,0 +1,37 @@ ++/* ++ * Support for RSA/DSA key blacklisting based on partial fingerprints, ++ * developed under Openwall Project for Owl - http://www.openwall.com/Owl/ ++ * ++ * Copyright (c) 2008 Dmitry V. Levin ++ * ++ * Permission to use, copy, modify, and distribute this software for any ++ * purpose with or without fee is hereby granted, provided that the above ++ * copyright notice and this permission notice appear in all copies. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ++ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ++ */ ++ ++#ifndef BLACKLIST_H_ ++#define BLACKLIST_H_ ++ ++#include "key.h" ++ ++int blacklisted_key(Key *, int); ++ ++typedef enum ++{ ++ BLACKLIST_ERROR_NONE = 0, ++ BLACKLIST_ERROR_MISSING, ++ BLACKLIST_ERROR_VERSION, ++ BLACKLIST_ERROR_FORMAT, ++ BLACKLIST_ERROR_ACCESS, ++ BLACKLIST_ERROR_ALL ++} blacklist_error_t; ++ ++#endif /* BLACKLIST_H_ */ +--- openssh-5.0p1/pathnames.h ++++ openssh-5.0p1/pathnames.h +@@ -43,6 +43,8 @@ + /* Backwards compatibility */ + #define _PATH_DH_PRIMES SSHDIR "/primes" + ++#define _PATH_BLACKLIST SSHDIR "/blacklist" ++ + #ifndef _PATH_SSH_PROGRAM + #define _PATH_SSH_PROGRAM "/usr/bin/ssh" + #endif +--- openssh-5.0p1/servconf.c ++++ openssh-5.0p1/servconf.c +@@ -39,6 +39,7 @@ + #include "match.h" + #include "channels.h" + #include "groupaccess.h" ++#include "blacklist.h" + + static void add_listen_addr(ServerOptions *, char *, u_short); + static void add_one_listen_addr(ServerOptions *, char *, u_short); +@@ -94,6 +95,7 @@ + options->password_authentication = -1; + options->kbd_interactive_authentication = -1; + options->challenge_response_authentication = -1; ++ options->ignore_blacklist_errors = -1; + options->permit_empty_passwd = -1; + options->permit_user_env = -1; + options->use_login = -1; +@@ -213,6 +217,8 @@ + options->kbd_interactive_authentication = 0; + if (options->challenge_response_authentication == -1) + options->challenge_response_authentication = 1; ++ if (options->ignore_blacklist_errors == -1) ++ options->ignore_blacklist_errors = BLACKLIST_ERROR_ALL; //VERSION; + if (options->permit_empty_passwd == -1) + options->permit_empty_passwd = 0; + if (options->permit_user_env == -1) +@@ -282,7 +299,7 @@ + sListenAddress, sAddressFamily, + sPrintMotd, sPrintLastLog, sIgnoreRhosts, + sX11Forwarding, sX11DisplayOffset, sX11UseLocalhost, +- sStrictModes, sEmptyPasswd, sTCPKeepAlive, ++ sStrictModes, sIgnoreBlacklistErrors, sEmptyPasswd, sTCPKeepAlive, + sPermitUserEnvironment, sUseLogin, sAllowTcpForwarding, sCompression, + sAllowUsers, sDenyUsers, sAllowGroups, sDenyGroups, + sIgnoreUserKnownHosts, sCiphers, sMacs, sProtocol, sPidFile, +@@ -372,6 +390,7 @@ + { "x11uselocalhost", sX11UseLocalhost, SSHCFG_ALL }, + { "xauthlocation", sXAuthLocation, SSHCFG_GLOBAL }, + { "strictmodes", sStrictModes, SSHCFG_GLOBAL }, ++ { "ignoreblacklisterrors", sIgnoreBlacklistErrors, SSHCFG_GLOBAL }, + { "permitemptypasswords", sEmptyPasswd, SSHCFG_GLOBAL }, + { "permituserenvironment", sPermitUserEnvironment, SSHCFG_GLOBAL }, + { "uselogin", sUseLogin, SSHCFG_GLOBAL }, +@@ -923,6 +944,32 @@ + intptr = &options->tcp_keep_alive; + goto parse_flag; + ++ case sIgnoreBlacklistErrors: ++ intptr = &options->ignore_blacklist_errors; ++ arg = strdelim(&cp); ++ if (!arg || *arg == '\0') ++ fatal("%s line %d: missing none/missing/version/format/access/all argument.", ++ filename, linenum); ++ value = 0; /* silence compiler */ ++ if (strcmp(arg, "none") == 0) ++ value = BLACKLIST_ERROR_NONE; ++ else if (strcmp(arg, "missing") == 0) ++ value = BLACKLIST_ERROR_MISSING; ++ else if (strcmp(arg, "version") == 0) ++ value = BLACKLIST_ERROR_VERSION; ++ else if (strcmp(arg, "format") == 0) ++ value = BLACKLIST_ERROR_FORMAT; ++ else if (strcmp(arg, "access") == 0) ++ value = BLACKLIST_ERROR_ACCESS; ++ else if (strcmp(arg, "all") == 0) ++ value = BLACKLIST_ERROR_ALL; ++ else ++ fatal("%s line %d: Bad none/missing/version/format/access/all argument: %s", ++ filename, linenum, arg); ++ if (*activep && *intptr == -1) ++ *intptr = value; ++ break; ++ + case sEmptyPasswd: + intptr = &options->permit_empty_passwd; + goto parse_flag; +--- openssh-5.0p1/servconf.h ++++ openssh-5.0p1/servconf.h +@@ -95,6 +95,7 @@ + * authentication. */ + int kbd_interactive_authentication; /* If true, permit */ + int challenge_response_authentication; ++ int ignore_blacklist_errors; /* none/missing/version/format/access/all */ + int permit_empty_passwd; /* If false, do not permit empty + * passwords. */ + int permit_user_env; /* If true, read ~/.ssh/environment */ +--- openssh-5.0p1/sshd.c ++++ openssh-5.0p1/sshd.c +@@ -118,6 +118,7 @@ + #include "monitor_wrap.h" + #include "monitor_fdpass.h" + #include "version.h" ++#include "blacklist.h" + + #ifdef LIBWRAP + #include +@@ -1484,6 +1494,11 @@ + sensitive_data.host_keys[i] = NULL; + continue; + } ++ if (blacklisted_key(key, 1)) { ++ sensitive_data.host_keys[i] = NULL; ++ key_free(key); ++ continue; ++ } + switch (key->type) { + case KEY_RSA1: + sensitive_data.ssh1_host_key = key; +--- openssh-5.0p1/sshd_config.5 ++++ openssh-5.0p1/sshd_config.5 +@@ -611,6 +611,39 @@ + Specifies whether password authentication is allowed. + The default is + .Dq yes . ++.It Cm IgnoreBlacklistErrors ++Specifies whether ++.Xr sshd 8 ++should allow keys recorded in its blacklist of known-compromised keys. ++If ++.Dq all , ++then attempts to authenticate with compromised keys will be logged ++but accepted. ++If ++.Dq access , ++then attempts to authenticate with compromised keys will be rejected, ++but blacklist file access errors will be ignored. ++If ++.Dq format , ++then attempts to authenticate with compromised keys will be rejected, but ++blacklist file access errors due to missing blacklist file or blacklist ++file unrecognized format will be ignored. ++If ++.Dq version , ++then attempts to authenticate with compromised keys will be rejected, but ++blacklist file access errors due to missing blacklist file or blacklist ++file format version mismatch will be ignored. ++If ++.Dq missing , ++then attempts to authenticate with compromised keys will be rejected, ++but blacklist file access errors due to missing blacklist file will ++be ignored. ++If ++.Dq none , ++then attempts to authenticate with compromised keys, or in case of ++any blacklist file access error, will be rejected. ++The default is ++.Dq version . + .It Cm PermitEmptyPasswords + When password authentication is allowed, it specifies whether the + server allows login to accounts with empty password strings. diff --git a/openssh-opensc-libs.patch b/openssh-opensc-libs.patch new file mode 100644 index 0000000..8f6851a --- /dev/null +++ b/openssh-opensc-libs.patch @@ -0,0 +1,16 @@ +Index: configure.ac +=================================================================== +RCS file: /cvs/openssh/configure.ac,v +retrieving revision 1.365 +diff -u -p -r1.365 configure.ac +--- configure.ac 18 Sep 2006 13:17:41 -0000 1.365 ++++ configure.ac 23 Sep 2006 04:54:12 -0000 +@@ -3086,7 +3086,7 @@ AC_ARG_WITH(opensc, + LIBOPENSC_CFLAGS=`$OPENSC_CONFIG --cflags` + LIBOPENSC_LIBS=`$OPENSC_CONFIG --libs` + CPPFLAGS="$CPPFLAGS $LIBOPENSC_CFLAGS" +- LDFLAGS="$LDFLAGS $LIBOPENSC_LIBS" ++ LIBS="$LIBS $LIBOPENSC_LIBS" + AC_DEFINE(SMARTCARD) + AC_DEFINE(USE_OPENSC, 1, + [Define if you want smartcard support diff --git a/openssl-sha-sys-types.patch b/openssl-sha-sys-types.patch new file mode 100644 index 0000000..d692994 --- /dev/null +++ b/openssl-sha-sys-types.patch @@ -0,0 +1,18 @@ +Index: ./crypto/sha/sha.h +=================================================================== +RCS file: /usr/local/src/openssl/cvs-tree/openssl/crypto/sha/sha.h,v +retrieving revision 1.21 +diff -u -p -r1.21 sha.h +--- ./crypto/sha/sha.h 18 Dec 2005 19:11:33 -0000 1.21 ++++ ./crypto/sha/sha.h 10 Dec 2006 19:26:12 -0000 +@@ -65,6 +65,10 @@ + extern "C" { + #endif + ++#if !defined(NO_SYS_TYPES_H) ++#include ++#endif ++ + #if defined(OPENSSL_NO_SHA) || (defined(OPENSSL_NO_SHA0) && defined(OPENSSL_NO_SHA1)) + #error SHA is disabled. + #endif diff --git a/pciutils-build-touchup.patch b/pciutils-build-touchup.patch new file mode 100644 index 0000000..e63b696 --- /dev/null +++ b/pciutils-build-touchup.patch @@ -0,0 +1,22 @@ +diff --git a/lib/Makefile b/lib/Makefile +index 9751eb5..a98ef42 100644 +--- a/lib/Makefile ++++ b/lib/Makefile +@@ -50,12 +50,14 @@ OBJS += nbsd-libpci.o + PCILIB=libpciutils.a + endif + ++AR ?= ar ++RANLIB ?= ranlib ++ + all: $(PCILIB) $(PCILIBPC) + + $(PCILIB): $(OBJS) +- rm -f $@ +- ar rcs $@ $^ +- ranlib $@ ++ $(AR) rcs $@ $^ ++ $(RANLIB) $@ + + $(PCILIBPC): $(PCILIBPC).in + sed <$< >$@ -e 's,@PREFIX@,$(PREFIX),' \ diff --git a/portage-debug-build-backend.patch b/portage-debug-build-backend.patch new file mode 100644 index 0000000..b4a0073 --- /dev/null +++ b/portage-debug-build-backend.patch @@ -0,0 +1,28 @@ +Index: pym/portage.py +=================================================================== +--- pym/portage.py (revision 3337) ++++ pym/portage.py (working copy) +@@ -1310,6 +1310,23 @@ class config: + if "usersandbox" in self.features: + self.features.remove("usersandbox") + ++ if "debug-build" in self.features: ++ # the profile should be setting these, but just in case ... ++ if not len(self["DEBUG_CFLAGS"]): ++ self["DEBUG_CFLAGS"] = "-g -O" ++ self.backup_changes("DEBUG_CFLAGS") ++ if not len(self["DEBUG_CXXFLAGS"]): ++ self["DEBUG_CXXFLAGS"] = self["DEBUG_CFLAGS"] ++ self.backup_changes("DEBUG_CXXFLAGS") ++ # replace user vars with debug version ++ for var in ["CFLAGS","CXXFLAGS","LDFLAGS"]: ++ self[var]=self["DEBUG_"+var] ++ self.backup_changes(var) ++ # if user has splitdebug, the debug info will be auto saved for ++ # gdb, otherwise we want to keep the binaries from being stripped ++ if not "splitdebug" in self.features: ++ self.features.append("nostrip") ++ + self.features.sort() + self["FEATURES"] = " ".join(self.features) + self.backup_changes("FEATURES") diff --git a/portage-debug-build.patch b/portage-debug-build.patch new file mode 100644 index 0000000..1e15bbd --- /dev/null +++ b/portage-debug-build.patch @@ -0,0 +1,81 @@ +--- pym/portage.py (revision 2565) ++++ pym/portage.py (working copy) +@@ -1266,10 +1266,6 @@ + if "usersandbox" in self.features: + self.features.remove("usersandbox") + +- self.features.sort() +- self["FEATURES"] = " ".join(["-*"]+self.features) +- self.backup_changes("FEATURES") +- + if not len(self["CBUILD"]) and len(self["CHOST"]): + self["CBUILD"] = self["CHOST"] + self.backup_changes("CBUILD") +@@ -1277,6 +1273,32 @@ + if mycpv: + self.setcpv(mycpv) + ++ self.mutate_env ++ ++ def mutate_env(self): ++ "emerge may have mutated the env slightly, so we may have to rebuild some things" ++ ++ if "debug-build" in self.features: ++ # the profile should be setting these, but just in case ... ++ if not len(self["DEBUG_CFLAGS"]): ++ self["DEBUG_CFLAGS"] = "-g -O" ++ self.backup_changes("DEBUG_CFLAGS") ++ if not len(self["DEBUG_CXXFLAGS"]): ++ self["DEBUG_CXXFLAGS"] = self["DEBUG_CFLAGS"] ++ self.backup_changes("DEBUG_CXXFLAGS") ++ # replace user vars with debug version ++ for var in ["CFLAGS","CXXFLAGS","LDFLAGS"]: ++ self[var]=self["DEBUG_"+var] ++ self.backup_changes(var) ++ # if user has splitdebug, the debug info will be auto saved for ++ # gdb, otherwise we want to keep the binaries from being stripped ++ if not "splitdebug" in self.features: ++ self.features.append("nostrip") ++ ++ self.features.sort() ++ self["FEATURES"] = " ".join(["-*"]+self.features) ++ self.backup_changes("FEATURES") ++ + def loadVirtuals(self,root): + self.virtuals = self.getvirtuals(root) + +--- pym/portage_const.py (revision 2565) ++++ pym/portage_const.py (working copy) +@@ -40,7 +40,7 @@ + CONFIG_MEMORY_FILE = PRIVATE_PATH + "/config" + + INCREMENTALS=["USE","USE_EXPAND","USE_EXPAND_HIDDEN","FEATURES","ACCEPT_KEYWORDS","ACCEPT_LICENSE","CONFIG_PROTECT_MASK","CONFIG_PROTECT","PRELINK_PATH","PRELINK_PATH_MASK"] +-STICKIES=["KEYWORDS_ACCEPT","USE","CFLAGS","CXXFLAGS","MAKEOPTS","EXTRA_ECONF","EXTRA_EINSTALL","EXTRA_EMAKE"] ++STICKIES=["KEYWORDS_ACCEPT","USE","CFLAGS","CXXFLAGS","LDFLAGS","DEBUG_CFLAGS","DEBUG_CXXFLAGS","DEBUG_LDFLAGS","MAKEOPTS","EXTRA_ECONF","EXTRA_EINSTALL","EXTRA_EMAKE"] + EBUILD_PHASES = ["setup","unpack","compile","test","install","preinst","postinst","prerm","postrm"] + + EAPI = 0 +--- bin/emerge (revision 2565) ++++ bin/emerge (working copy) +@@ -173,6 +173,7 @@ + "--ask", + "--buildpkg", "--buildpkgonly", + "--changelog", "--columns", "--cols", ++"--debug-build", "--debugbuild" + "--debug", "--deep", + "--digest", + "--emptytree", +@@ -429,6 +430,13 @@ + if ("--nocolor" in myopts) and (sys.stdout.isatty()): + nocolor() + ++# Now mutate portage env based upon options user gave us ++if ("--debug-build" in myopts): ++ portage.settings.unlock() ++ portage.settings.features.append("debug-build") ++ portage.settings.mutate_env() ++ portage.settings.lock() ++ + CLEAN_DELAY = 5 + EMERGE_WARNING_DELAY = 10 + if portage.settings["CLEAN_DELAY"]: diff --git a/portage-ecompress.patch b/portage-ecompress.patch new file mode 100644 index 0000000..4fd1d45 --- /dev/null +++ b/portage-ecompress.patch @@ -0,0 +1,386 @@ +Index: dodoc +=================================================================== +--- dodoc (revision 5536) ++++ dodoc (working copy) +@@ -1,9 +1,10 @@ + #!/bin/bash +-# Copyright 1999-2006 Gentoo Foundation ++# Copyright 1999-2007 Gentoo Foundation + # Distributed under the terms of the GNU General Public License v2 ++# $Id$ + + if [ $# -lt 1 ] ; then +- echo "$0: at least one argument needed" 1>&2 ++ vecho "${0##*/}: at least one argument needed" 1>&2 + exit 1 + fi + +@@ -16,7 +17,7 @@ ret=0 + for x in "$@" ; do + if [ -s "${x}" ] ; then + install -m0644 "${x}" "${dir}" +- gzip -f -9 "${dir}/${x##*/}" ++ ecompress "${dir}/${x##*/}" + elif [ ! -e "${x}" ] ; then + echo "dodoc: ${x} does not exist" 1>&2 + ((++ret)) +Index: prepallman +=================================================================== +--- prepallman (revision 5536) ++++ prepallman (working copy) +@@ -1,5 +1,5 @@ + #!/bin/bash +-# Copyright 1999-2006 Gentoo Foundation ++# Copyright 1999-2007 Gentoo Foundation + # Distributed under the terms of the GNU General Public License v2 + # $Id$ + +@@ -7,14 +7,11 @@ source "${PORTAGE_BIN_PATH:-/usr/lib/por + + ret=0 + +-vecho "man:" +-for x in "${D}"opt/*/man "${D}"usr/share/man "${D}"usr/local/man "${D}"usr/X11R6/man ; do +- if [[ -d ${x} ]] ; then +- x=${x#${D}} +- x=${x%/man} +- prepman "${x}" +- ((ret+=$?)) +- fi +-done ++find "${D}" -type d -name man > "${T}"/prepallman.filelist ++while read mandir ; do ++ mandir=${mandir#${D}} ++ prepman "${mandir%/man}" ++ ((ret+=$?)) ++done < "${T}"/prepallman.filelist + + exit ${ret} +Index: prepman +=================================================================== +--- prepman (revision 5536) ++++ prepman (working copy) +@@ -1,51 +1,33 @@ + #!/bin/bash +-# Copyright 1999-2006 Gentoo Foundation ++# Copyright 1999-2007 Gentoo Foundation + # Distributed under the terms of the GNU General Public License v2 + # $Id$ + + source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh + + if [[ -z $1 ]] ; then +- z="${D}usr/share/man" ++ mandir="${D}usr/share/man" + else +- z="${D}$1/man" ++ mandir="${D}$1/man" + fi + +-if [[ ! -d ${z} ]] ; then +- eqawarn "QA Notice: prepman called with non-existent dir '${z#${D}}'" ++if [[ ! -d ${mandir} ]] ; then ++ eqawarn "QA Notice: prepman called with non-existent dir '${mandir#${D}}'" + exit 0 + fi + +-for x in $(find "${z}"/ -type d 2>/dev/null) ; do +- for y in $(find "${x}"/ -mindepth 1 -maxdepth 1 \( -type f -or -type l \) ! -name '.keep_*' 2>/dev/null) ; do +- if [[ -L ${y} ]] ; then +- # Symlink ... +- mylink=${y} +- linkto=$(readlink "${y}") +- +- # Do NOT change links to directories +- if [[ -d ${z}/${linkto} ]] ; then +- continue +- fi +- +- if [[ ${linkto##*.} != "gz" ]] && [[ ${linkto##*.} != "bz2" ]] ; then +- linkto="${linkto}.gz" +- fi +- if [[ ${mylink##*.} != "gz" ]] && [[ ${mylink##*.} != "bz2" ]] ; then +- mylink="${mylink}.gz" +- fi +- +- vecho "fixing man page symlink: ${mylink##*/}" +- ln -snf "${linkto}" "${mylink}" +- if [[ ${y} != "${mylink}" ]] ; then +- vecho "removing old symlink: ${y##*/}" +- rm -f "${y}" +- fi +- else +- if [[ ${y##*.} != "gz" ]] && [[ ${y##*.} != "bz2" ]] && [[ ! -d ${y} ]] ; then +- vecho "gzipping man page: ${y##*/}" +- gzip -f -9 "${y}" +- fi +- fi +- done ++shopt -s nullglob ++ ++# figure out the new suffix ++suffix=$(ecompress --suffix) ++[[ -z ${suffix} ]] && exit 0 ++ ++ret=0 ++ ++# compress and fixup links in each dir ++for subdir in "${mandir}"/man* "${mandir}"/*/man* ; do ++ ecompressdir "${subdir#${D}}" ++ ((ret+=$?)) + done ++ ++exit ${ret} +Index: misc-functions.sh +=================================================================== +--- misc-functions.sh (revision 5536) ++++ misc-functions.sh (working copy) +@@ -340,9 +340,7 @@ install_qa_check() { + fi + + # Portage regenerates this on the installed system. +- if [[ -f ${D}/usr/share/info/dir.gz ]] ; then +- rm -f "${D}"/usr/share/info/dir.gz +- fi ++ rm -f "${D}"/usr/share/info/dir{,.gz,.bz2} + + if hasq multilib-strict ${FEATURES} && \ + [[ -x /usr/bin/file && -x /usr/bin/find ]] && \ +Index: doinfo +=================================================================== +--- doinfo (revision 5536) ++++ doinfo (working copy) +@@ -1,10 +1,10 @@ + #!/bin/bash +-# Copyright 1999-2006 Gentoo Foundation ++# Copyright 1999-2007 Gentoo Foundation + # Distributed under the terms of the GNU General Public License v2 + # $Id$ + + if [ ${#} -lt 1 ] ; then +- echo "doinfo: at least one argument needed" ++ vecho "${0##*/}: at least one argument needed" + exit 1 + fi + if [ ! -d "${D}usr/share/info" ] ; then +@@ -14,7 +14,7 @@ fi + for x in "$@" ; do + if [ -e "${x}" ] ; then + install -m0644 "${x}" "${D}usr/share/info" +- gzip -f -9 "${D}usr/share/info/${x##*/}" ++ ecompress "${D}usr/share/info/${x##*/}" + else + echo "doinfo: ${x} does not exist" + fi +Index: prepinfo +=================================================================== +--- prepinfo (revision 5536) ++++ prepinfo (working copy) +@@ -1,47 +1,22 @@ + #!/bin/bash +-# Copyright 1999-2006 Gentoo Foundation ++# Copyright 1999-2007 Gentoo Foundation + # Distributed under the terms of the GNU General Public License v2 + # $Id$ + + source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh + +-if [ -z "$1" ] ; then +- z="${D}usr/share/info" ++if [[ -z $1 ]] ; then ++ infodir=="${D}usr/share/info" + else +- if [ -d "${D}$1/share/info" ] ; then +- z="${D}$1/share/info" ++ if [[ -d ${D}$1/share/info ]] ; then ++ infodir="${D}$1/share/info" + else +- z="${D}$1/info" ++ infodir="${D}$1/info" + fi + fi + +-[ ! -d "${z}" ] && exit 0 ++[[ ! -d ${infodir} ]] && exit 0 + +-rm -f "${z}"/{dir,dir.info,dir.info.gz} ++rm -f "${infodir}"/dir{,.info}{,.gz,.bz2} + +-for x in $(find "${z}"/ -mindepth 1 -maxdepth 1 \( -type f -or -type l \) 2>/dev/null) ; do +- if [ -L "${x}" ] ; then +- # Symlink ... +- mylink="${x}" +- linkto="$(readlink "${x}")" +- +- if [ "${linkto##*.}" != "gz" ] ; then +- linkto="${linkto}.gz" +- fi +- if [ "${mylink##*.}" != "gz" ] ; then +- mylink="${mylink}.gz" +- fi +- +- vecho "fixing GNU info symlink: ${mylink##*/}" +- ln -snf "${linkto}" "${mylink}" +- if [ "${x}" != "${mylink}" ] ; then +- vecho "removing old symlink: ${x##*/}" +- rm -f "${x}" +- fi +- else +- if [ "${x##*.}" != "gz" ] ; then +- vecho "gzipping GNU info page: ${x##*/}" +- gzip -f -9 "${x}" +- fi +- fi +-done ++exec ecompressdir "${infodir}" +Index: ecompress +=================================================================== +--- ecompress (revision 0) ++++ ecompress (revision 0) +@@ -0,0 +1,38 @@ ++#!/bin/bash ++# Copyright 1999-2007 Gentoo Foundation ++# Distributed under the terms of the GNU General Public License v2 ++# $Id: prepman 5507 2007-01-10 04:22:27Z zmedico $ ++ ++if [[ -z $1 ]] ; then ++ echo "${0##*/}: at least one argument needed" 1>&2 ++ exit 1 ++fi ++ ++source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh ++ ++# setup compression stuff ++PORTAGE_COMPRESS=${PORTAGE_COMPRESS:-bzip2} ++if [[ -z ${PORTAGE_COMPRESS_FLAGS} ]] ; then ++ case ${PORTAGE_COMPRESS} in ++ bzip2|gzip) PORTAGE_COMPRESS_FLAGS="-9";; ++ esac ++fi ++ ++if [[ $1 == "--suffix" ]] ; then ++ set -e ++ tmpdir="${T}"/.ecompress$$.${RANDOM} ++ mkdir "${tmpdir}" ++ cd "${tmpdir}" ++ # we have to fill the file enough so that there is something ++ # to compress as some programs will refuse to do compression ++ # if it cannot actually compress the file ++ echo {0..1000} > compressme ++ ${PORTAGE_COMPRESS} ${PORTAGE_COMPRESS_FLAGS} compressme ++ suffix=$(ls compressme*) ++ suffix=${suffix#compressme} ++ cd / ++ rm -rf "${tmpdir}" ++ echo "${suffix}" ++else ++ exec "${PORTAGE_COMPRESS}" ${PORTAGE_COMPRESS_FLAGS} "$@" ++fi + +Property changes on: ecompress +___________________________________________________________________ +Name: svn:executable + + * + +Index: prepalldocs +=================================================================== +--- prepalldocs (revision 5536) ++++ prepalldocs (working copy) +@@ -1,35 +1,13 @@ + #!/bin/bash +-# Copyright 1999-2006 Gentoo Foundation ++# Copyright 1999-2007 Gentoo Foundation + # Distributed under the terms of the GNU General Public License v2 + # $Id$ + +-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh ++if [[ -n $1 ]] ; then ++ vecho "${0##*/}: invalid usage; takes no arguments" 1>&2 ++fi + +-z="$(find "${D}"usr/share/doc \( -type f -or -type l \) -not -name "*.gz" -not -name "*.js" 2>/dev/null)" ++cd "${D}" ++[[ -d usr/share/doc ]] || exit 0 + +-for y in ${z} ; do +- if [ -L "${y}" ] ; then +- # Symlink ... +- mylink="${y}" +- linkto="$(readlink "${y}")" +- +- if [ "${linkto##*.}" != "gz" ] ; then +- linkto="${linkto}.gz" +- fi +- if [ "${mylink##*.}" != "gz" ] ; then +- mylink="${mylink}.gz" +- fi +- +- vecho "fixing doc symlink: ${mylink##*/}" +- ln -snf "${linkto}" "${mylink}" +- if [ "${y}" != "${mylink}" ] ; then +- vecho "removing old symlink: ${y##*/}" +- rm -f "${y}" +- fi +- else +- if [ "${y##*.}" != "gz" ] ; then +- vecho "gzipping doc: ${y##*/}" +- gzip -f -9 "${y}" +- fi +- fi +-done ++exec ecompressdir "${D}"usr/share/doc +Index: ecompressdir +=================================================================== +--- ecompressdir (revision 0) ++++ ecompressdir (revision 0) +@@ -0,0 +1,44 @@ ++#!/bin/bash ++# Copyright 1999-2007 Gentoo Foundation ++# Distributed under the terms of the GNU General Public License v2 ++# $Id: prepalldocs 3483 2006-06-10 21:40:40Z genone $ ++ ++if [[ -z $1 ]] ; then ++ echo "${0##*/}: at least one argument needed" 1>&2 ++ exit 1 ++fi ++ ++# figure out the new suffix ++suffix=$(ecompress --suffix) ++[[ -z ${suffix} ]] && exit 0 ++ ++source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh ++ ++ret=0 ++ ++for dir in "$@" ; do ++ dir="${D}${dir}" ++ if [[ ! -d ${dir} ]] ; then ++ vecho "${0##*/}: ${dir#${D}} does not exist!" ++ continue ++ else ++ vecho "${0##*/}: compressing ${dir#${D}}" ++ fi ++ ++ find "${dir}" -type f -print0 | xargs -0 ecompress ++ ((ret+=$?)) ++ find -L "${dir}" -type l | \ ++ while read brokenlink ; do ++ olddest=$(readlink "${brokenlink}") ++ newdest="${olddest}${suffix}" ++ if [[ -e ${newdest} ]] ; then ++ ln -snf "${newdest}" "${brokenlink}" ++ ((ret+=$?)) ++ else ++ vecho "ecompressdir: unknown broken symlink: ${brokenlink}" ++ ((++ret)) ++ fi ++ done ++done ++ ++exit ${ret} + +Property changes on: ecompressdir +___________________________________________________________________ +Name: svn:executable + + * + diff --git a/portage-ignore-kernel-modules.patch b/portage-ignore-kernel-modules.patch new file mode 100644 index 0000000..b679e0b --- /dev/null +++ b/portage-ignore-kernel-modules.patch @@ -0,0 +1,23 @@ +Index: misc-functions.sh +=================================================================== +--- bin/misc-functions.sh (revision 7590) ++++ bin/misc-functions.sh (working copy) +@@ -94,7 +94,7 @@ install_qa_check() { + qa_var="QA_TEXTRELS_${ARCH/-/_}" + [[ -n ${!qa_var} ]] && QA_TEXTRELS=${!qa_var} + [[ -n ${QA_STRICT_TEXTRELS} ]] && QA_TEXTRELS="" +- export QA_TEXTRELS ++ export QA_TEXTRELS="${QA_TEXTRELS} /lib*/modules/*.ko" + f=$(scanelf -qyRF '%t %p' "${D}" | grep -v 'usr/lib/debug/') + if [[ -n ${f} ]] ; then + scanelf -qyRF '%T %p' "${PORTAGE_BUILDDIR}"/ &> "${T}"/scanelf-textrel.log +@@ -134,7 +134,8 @@ install_qa_check() { + qa_var="QA_WX_LOAD_${ARCH/-/_}" + [[ -n ${!qa_var} ]] && QA_WX_LOAD=${!qa_var} + [[ -n ${QA_STRICT_WX_LOAD} ]] && QA_WX_LOAD="" +- export QA_EXECSTACK QA_WX_LOAD ++ export QA_EXECSTACK="${QA_EXECSTACK} /lib*/modules/*.ko" ++ export QA_WX_LOAD="${QA_WX_LOAD} /lib*/modules/*.ko" + f=$(scanelf -qyRF '%e %p' "${D}" | grep -v 'usr/lib/debug/') + ;; + esac diff --git a/portage-only-ldconfig-when-needed.patch b/portage-only-ldconfig-when-needed.patch new file mode 100644 index 0000000..e57fdab --- /dev/null +++ b/portage-only-ldconfig-when-needed.patch @@ -0,0 +1,58 @@ +Index: pym/portage.py +=================================================================== +--- pym/portage.py (revision 2563) ++++ pym/portage.py (working copy) +@@ -521,7 +521,7 @@ + + #parse /etc/env.d and generate /etc/profile.env + +-def env_update(makelinks=1): ++def env_update(makelinks=1,srcroot=""): + global root + if not os.path.exists(root+"etc/env.d"): + prevmask=os.umask(0) +@@ -637,7 +634,10 @@ + if not mtimedb.has_key("ldpath"): + mtimedb["ldpath"]={} + +- for x in specials["LDPATH"]+['/usr/lib','/lib']: ++ skip_makelinks=1 ++ for x in portage_util.unique_array(specials["LDPATH"]+['/usr/lib','/usr/lib64','/usr/lib32','/lib','/lib64','/lib32']): ++ if makelinks and skip_makelinks and os.access(srcroot+x,os.R_OK): ++ skip_makelinks=0 + try: + newldpathtime=os.stat(x)[stat.ST_MTIME] + except SystemExit, e: +@@ -654,9 +654,10 @@ + mtimedb["ldpath"][x]=newldpathtime + ld_cache_update=True + +- # ldconfig has very different behaviour between FreeBSD and Linux +- if ostype=="Linux" or ostype.lower().endswith("gnu"): +- if (ld_cache_update or makelinks): ++ # Don't run ldconfig if the package didn't install any libs ++ if (ld_cache_update or (makelinks and not skip_makelinks)): ++ # ldconfig has very different behaviour between FreeBSD and Linux ++ if ostype=="Linux" or ostype.lower().endswith("gnu"): + # We can't update links if we haven't cleaned other versions first, as + # an older package installed ON TOP of a newer version will cause ldconfig + # to overwrite the symlinks we just made. -X means no links. After 'clean' +@@ -666,8 +667,7 @@ + commands.getstatusoutput("cd / ; /sbin/ldconfig -r "+root) + else: + commands.getstatusoutput("cd / ; /sbin/ldconfig -X -r "+root) +- elif ostype in ("FreeBSD","DragonFly"): +- if (ld_cache_update): ++ elif ostype in ("FreeBSD","DragonFly"): + writemsg(">>> Regenerating "+str(root)+"var/run/ld-elf.so.hints...\n") + commands.getstatusoutput("cd / ; /sbin/ldconfig -elf -i -f "+str(root)+"var/run/ld-elf.so.hints "+str(root)+"etc/ld.so.conf") + +@@ -6113,7 +6113,7 @@ + downgrade = True + + #update environment settings, library paths. DO NOT change symlinks. +- env_update(makelinks=(not downgrade)) ++ env_update(makelinks=(not downgrade),srcroot=srcroot) + #dircache may break autoclean because it remembers the -MERGING-pkg file + global dircache + if dircache.has_key(self.dbcatdir): diff --git a/portage-qa-ignores.patch b/portage-qa-ignores.patch new file mode 100644 index 0000000..6f5af25 --- /dev/null +++ b/portage-qa-ignores.patch @@ -0,0 +1,82 @@ +Index: ebuild.sh +=================================================================== +--- ebuild.sh (revision 2825) ++++ ebuild.sh (working copy) +@@ -1095,7 +1095,7 @@ + done + + if type -p scanelf > /dev/null ; then +- local insecure_rpath=0 ++ local qa_var insecure_rpath=0 + + # Make sure we disallow insecure RUNPATH/RPATH's + # Don't want paths that point to the tree where the package was built +@@ -1132,9 +1132,22 @@ + fi + + # TEXTREL's are baaaaaaaad +- f=$(scanelf -qyRF '%t %p' "${D}") ++ # Allow devs to mark things as ignorable ... e.g. things that are ++ # binary-only and upstream isn't cooperating (nvidia-glx) ... we ++ # allow ebuild authors to set QA_TEXTRELS_arch and QA_TEXTRELS ... ++ # the former overrides the latter ... regexes allowed ! :) ++ qa_var="QA_TEXTRELS_${ARCH}" ++ [[ -n ${!qa_var} ]] && QA_TEXTRELS=${!qa_var} ++ f=$(scanelf -qyRF '%t %p' "${D}" | grep -v ' usr/lib/debug/' | \ ++ gawk ' ++ BEGIN { split("'"${QA_TEXTRELS}"'", ignore); } ++ { for (idx in ignore) ++ if ($NF ~ "^"ignore[idx]"$") ++ next; ++ print; ++ }') + if [[ -n ${f} ]] ; then +- scanelf -qyRF '%T %p' "${WORKDIR}"/ &> "${T}"/scanelf-textrel.log ++ scanelf -qyRF '%T %p' "${PORTAGE_BUILDDIR}"/ &> "${T}"/scanelf-textrel.log + echo -ne '\a\n' + echo "QA Notice: the following files contain runtime text relocations" + echo " Text relocations force the dynamic linker to perform extra" +@@ -1158,15 +1171,30 @@ + # http://hardened.gentoo.org/gnu-stack.xml (Arch Status) + case ${CTARGET:-${CHOST}} in + i?86*|ia64*|m68k*|powerpc64*|s390*|x86_64*) +- f=$(scanelf -qyRF '%e %p' "${D}") ;; +- *) +- f="" ;; ++ # Allow devs to mark things as ignorable ... e.g. things ++ # that are binary-only and upstream isn't cooperating ... ++ # we allow ebuild authors to set QA_EXECSTACK_arch and ++ # QA_EXECSTACK ... the former overrides the latter ... ++ # regexes allowed ! :) ++ ++ qa_var="QA_EXECSTACK_${ARCH}" ++ [[ -n ${!qa_var} ]] && QA_EXECSTACK=${!qa_var} ++ f=$(scanelf -qyRF '%e %p' "${D}" | grep -v ' usr/lib/debug/' | \ ++ gawk ' ++ BEGIN { split("'"${QA_EXECSTACK}"'", ignore); } ++ { for (idx in ignore) ++ if ($NF ~ "^"ignore[idx]"$") ++ next; ++ print; ++ }') ++ ;; ++ *) f="" ;; + esac + ;; + esac + if [[ -n ${f} ]] ; then + # One more pass to help devs track down the source +- scanelf -qyRF '%e %p' "${WORKDIR}"/ &> "${T}"/scanelf-exec.log ++ scanelf -qyRF '%e %p' "${PORTAGE_BUILDDIR}"/ &> "${T}"/scanelf-execstack.log + echo -ne '\a\n' + echo "QA Notice: the following files contain executable stacks" + echo " Files with executable stacks will not work properly (or at all!)" +@@ -1174,7 +1202,7 @@ + echo " at http://bugs.gentoo.org/ to make sure the file is fixed." + echo " For more information, see http://hardened.gentoo.org/gnu-stack.xml" + echo " Please include this file in your report:" +- echo " ${T}/scanelf-exec.log" ++ echo " ${T}/scanelf-execstack.log" + echo "${f}" + echo -ne '\a\n' + die_msg="${die_msg} execstacks" diff --git a/portmap-build-cleanup.patch b/portmap-build-cleanup.patch new file mode 100644 index 0000000..9d890d1 --- /dev/null +++ b/portmap-build-cleanup.patch @@ -0,0 +1,144 @@ +diff --git a/Makefile b/Makefile +index 7131fc8..1376ea7 100644 +--- a/Makefile ++++ b/Makefile +@@ -7,7 +7,7 @@ + # sendmail transaction logs. Change the definition of the following macro + # if you disagree. See `man 3 syslog' for examples. Some syslog versions + # do not provide this flexibility. +-# ++ + FACILITY=LOG_DAEMON + + # To disable tcp-wrapper style access control, comment out the following +@@ -15,8 +15,10 @@ FACILITY=LOG_DAEMON + # no access control tables. The local system, since it runs the portmap + # daemon, is always treated as an authorized host. + +-HOSTS_ACCESS= -DHOSTS_ACCESS +-WRAP_LIB = -lwrap ++ifeq ($(NO_TCP_WRAPPER),) ++CPPFLAGS += -DHOSTS_ACCESS ++WRAP_LIB = -lwrap ++endif + + # Comment out if your RPC library does not allocate privileged ports for + # requests from processes with root privilege, or the new portmap will +@@ -24,7 +26,7 @@ WRAP_LIB = -lwrap + # ports. You can find out by running "rpcinfo -p"; if all mountd and NIS + # daemons use a port >= 1024 you should probably disable the next line. + +-CHECK_PORT = -DCHECK_PORT ++CPPFLAGS += -DCHECK_PORT + + # Warning: troublesome feature ahead!! Enable only when you are really + # desperate!! +@@ -59,63 +61,52 @@ CHECK_PORT = -DCHECK_PORT + # probably much easier to just block port UDP and TCP ports 111 on + # your routers. + # +-# LOOPBACK = -DLOOPBACK_SETUNSET ++# CPPFLAGS += -DLOOPBACK_SETUNSET + + # When the portmapper cannot find any local interfaces (it will complain + # to the syslog daemon) your system probably has variable-length socket + # address structures (struct sockaddr has a sa_len component; examples: + # AIX 4.1 and 4.4BSD). Uncomment next macro definition in that case. + # +-# SA_LEN = -DHAS_SA_LEN # AIX 4.x, BSD 4.4, FreeBSD, NetBSD ++# CPPFLAGS += -DHAS_SA_LEN # AIX 4.x, BSD 4.4, FreeBSD, NetBSD + + # With verbose logging on, HP-UX 9.x and AIX 4.1 leave zombies behind when + # SIGCHLD is not ignored. Enable next macro for a fix. + # +-ZOMBIES = -DIGNORE_SIGCHLD # AIX 4.x, HP-UX 9.x ++CPPFLAGS += -DIGNORE_SIGCHLD # AIX 4.x, HP-UX 9.x + + # Uncomment the following macro if your system does not have u_long. + # +-# ULONG =-Du_long="unsigned long" ++# CPPFLAGS +=-Du_long="unsigned long" + + # +-# LIBS = -m +-# NSARCHS = -arch m68k -arch i386 -arch hppa ++# LDLIBS += -m ++# CFLAGS += -arch m68k -arch i386 -arch hppa + + # Auxiliary libraries that you may have to specify + # +-# LIBS = -lrpc ++# LDLIBS += -lrpc + + # Comment out if your compiler talks ANSI and understands const + # +-# CONST = -Dconst= ++# CPPFLAGS += -Dconst= + + ### End of configurable stuff. + ############################## + +-SHELL = /bin/sh +- +-RPM_OPT_FLAGS = -O2 +- +-COPT = $(CONST) $(HOSTS_ACCESS) $(CHECK_PORT) \ +- $(SYS) -DFACILITY=$(FACILITY) $(ULONG) $(ZOMBIES) $(SA_LEN) \ +- $(LOOPBACK) +-CFLAGS = $(COPT) $(RPM_OPT_FLAGS) $(NSARCHS) -Wall -Wstrict-prototypes \ +- -fpie +-OBJECTS = portmap.o pmap_check.o from_local.o ++CPPFLAGS += -DFACILITY=$(FACILITY) ++CFLAGS ?= -O2 ++CFLAGS += -Wall -Wstrict-prototypes + + all: portmap pmap_dump pmap_set + +-portmap: $(OBJECTS) +- $(CC) $(CFLAGS) -pie -o $@ $(OBJECTS) $(WRAP_LIB) $(LIBS) ++CPPFLAGS += $(HOSTS_ACCESS) ++portmap: CFLAGS += -fpie ++portmap: LDLIBS += $(WRAP_LIB) ++portmap: LDFLAGS += -pie ++portmap: portmap.o pmap_check.o from_local.o + +-pmap_dump: pmap_dump.c +- $(CC) $(CFLAGS) -o $@ $? $(LIBS) +- +-pmap_set: pmap_set.c +- $(CC) $(CFLAGS) -o $@ $? $(LIBS) +- +-from_local: from_local.c +- cc $(CFLAGS) -DTEST -o $@ from_local.c ++from_local: CPPFLAGS += -DTEST + + install: all + install -o root -g root -m 0755 -s portmap ${BASEDIR}/sbin +@@ -125,23 +116,12 @@ install: all + install -o root -g root -m 0644 pmap_dump.8 ${BASEDIR}/usr/share/man/man8 + install -o root -g root -m 0644 pmap_set.8 ${BASEDIR}/usr/share/man/man8 + +-lint: +- lint $(COPT) $(OBJECTS:%.o=%.c) +- + clean: + rm -f *.o portmap pmap_dump pmap_set from_local \ + core + +-tidy: clean +- chmod 755 . ; chmod -R a+r . +- +-deps: +- @$(CC) -M $(CFLAGS) *.c | grep -v /usr/include |sed 's/\.\///' ++-include .depend ++.depend: *.c ++ $(CC) -MM $(CFLAGS) *.c > .depend + +-from_local.o: from_local.c +-pmap_check.o: pmap_check.c +-pmap_check.o: pmap_check.h Makefile +-pmap_dump.o: pmap_dump.c +-pmap_set.o: pmap_set.c +-portmap.o: portmap.c +-portmap.o: pmap_check.h Makefile ++.PHONY: all clean install diff --git a/portmap-destdir-strip.patch b/portmap-destdir-strip.patch new file mode 100644 index 0000000..5cf607b --- /dev/null +++ b/portmap-destdir-strip.patch @@ -0,0 +1,25 @@ +diff --git a/Makefile b/Makefile +index 9e9a4b4..5343428 100644 +--- a/Makefile ++++ b/Makefile +@@ -135,13 +135,14 @@ from_local: CPPFLAGS += -DTEST + portmap.man : portmap.8 + sed $(MAN_SED) < portmap.8 > portmap.man + ++DESTDIR = $(BASEDIR) + install: all +- install -o root -g root -m 0755 -s portmap ${BASEDIR}/sbin +- install -o root -g root -m 0755 -s pmap_dump ${BASEDIR}/sbin +- install -o root -g root -m 0755 -s pmap_set ${BASEDIR}/sbin +- install -o root -g root -m 0644 portmap.man ${BASEDIR}/usr/share/man/man8/portmap.8 +- install -o root -g root -m 0644 pmap_dump.8 ${BASEDIR}/usr/share/man/man8 +- install -o root -g root -m 0644 pmap_set.8 ${BASEDIR}/usr/share/man/man8 ++ install -o root -g root -m 0755 portmap $(DESTDIR)/sbin ++ install -o root -g root -m 0755 pmap_dump $(DESTDIR)/sbin ++ install -o root -g root -m 0755 pmap_set $(DESTDIR)/sbin ++ install -o root -g root -m 0644 portmap.man $(DESTDIR)/usr/share/man/man8/portmap.8 ++ install -o root -g root -m 0644 pmap_dump.8 $(DESTDIR)/usr/share/man/man8 ++ install -o root -g root -m 0644 pmap_set.8 $(DESTDIR)/usr/share/man/man8 + + clean: + rm -f *.o portmap pmap_dump pmap_set from_local \ diff --git a/portmap-help.patch b/portmap-help.patch new file mode 100644 index 0000000..45dfe1d --- /dev/null +++ b/portmap-help.patch @@ -0,0 +1,15 @@ +diff --git a/portmap.c b/portmap.c +index 76cb6f5..e561415 100644 +--- a/portmap.c ++++ b/portmap.c +@@ -211,8 +211,8 @@ main(int argc, char **argv) + "-f: don't daemonize, log to standard error\n"); + fprintf(stderr, "-t dir: chroot into dir\n"); + fprintf(stderr, "-v: verbose logging\n"); +- fprintf(stderr, "-i address; bind to address\n"); +- fprintf(stderr, "-l: same as -l 127.0.0.1\n"); ++ fprintf(stderr, "-i address: bind to address\n"); ++ fprintf(stderr, "-l: same as -i 127.0.0.1\n"); + exit(1); + } + } diff --git a/portmap-no-tcpd-header.patch b/portmap-no-tcpd-header.patch new file mode 100644 index 0000000..bb81ca5 --- /dev/null +++ b/portmap-no-tcpd-header.patch @@ -0,0 +1,14 @@ +diff --git a/pmap_check.c b/pmap_check.c +index 84f2c12..443a822 100644 +--- a/pmap_check.c ++++ b/pmap_check.c +@@ -44,7 +44,9 @@ + #include + #include + #endif ++#ifdef HOSTS_ACCESS + #include ++#endif + #include + #include + diff --git a/posixtestsuite-flags.patch b/posixtestsuite-flags.patch new file mode 100644 index 0000000..72f1705 --- /dev/null +++ b/posixtestsuite-flags.patch @@ -0,0 +1,95 @@ +--- Makefile ++++ Makefile +@@ -29,7 +29,9 @@ + + LOGFILE = $(top_builddir)/logfile + +-LDFLAGS := $(shell cat LDFLAGS | grep -v \^\#) ++LDFLAGS := $(strip $(shell grep -sv '^\#' LDFLAGS)) ++CFLAGS := $(strip $(shell grep -sv '^\#' CFLAGS)) ++CPPFLAGS := $(strip $(shell grep -sv '^\#' CPPFLAGS)) + + RUN_TESTS := $(shell $(top_builddir)/locate-test \ + --execs $(top_builddir)/$(POSIX_TARGET)) +@@ -54,14 +56,19 @@ stress-tests: stress-make stress-run + tests-pretty: + $(MAKE) all | column -t -s: + +-CFLAGS = -g -O2 -Wall -Werror -D_POSIX_C_SOURCE=200112L ++ifeq ($(CFLAGS),) ++CFLAGS = -g -O2 ++endif ++CFLAGS += -Wall -Werror ++ifeq ($(CPPFLAGS),) ++CPPFLAGS = -D_POSIX_C_SOURCE=200112L ++endif + + # add -std=c99, -std=gnu99 if compiler supports it (gcc-2.95.3 does not). + check_gcc = $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi) +-CFLAGS += $(call check_gcc,-std=c99,) +-CFLAGS += $(call check_gcc,-std=gnu99,) ++CFLAGS += $(call check_gcc,-std=gnu99,$(call check_gcc,-std=c99,)) + +-INCLUDE = -Iinclude ++CPPFLAGS += -Iinclude + + # FIXME: exaust cmd line length + clean: +@@ -165,7 +172,7 @@ $(top_builddir)/t0.val: $(top_builddir)/ + .PRECIOUS: %.o + %.o: %.c + @COMPLOG=$(LOGFILE).$$$$; \ +- if $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ $(LDFLAGS) > $$COMPLOG 2>&1; \ ++ if $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ > $$COMPLOG 2>&1; \ + then \ + echo "$(@:.o=): build: PASS" | tee -a $(LOGFILE); \ + else \ +--- LDFLAGS ++++ LDFLAGS +@@ -1,16 +1,11 @@ + #This file contains all lines needed for linking the test suites. + #These may be on one line or multiple lines. + # +-#Place the -l, -L, or -D piece before the item to link. ++#Place the -l or -L pieces before the item to link. + #Lines beginning with # are comments. + # + #For example, +-#-lpthread -D_GNU_SOURCE ++#-lpthread + # + #Recommended flags: + #-D_XOPEN_SOURCE=600 -lpthread -lrt -lm +-# +-# For use with Linux, you may try the following flags to +-# allow for the NPTL-specific compilation (used in some test cases) +-# Note: this sometimes require the package nptl-devel.*.rpm to be installed. +-#-I /usr/include/nptl -L /usr/lib/nptl -D_XOPEN_SOURCE=600 -lpthread -lrt -lm +--- CPPFLAGS ++++ CPPFLAGS +@@ -0,0 +1,11 @@ ++#This file contains all the preprocessor flags (such as defines and includes) ++#needed for compiling the test suites. ++#These may be on one line or multiple lines. ++# ++#Lines beginning with # are comments. ++# ++#For example: ++#-D_GNU_SOURCE -I/usr/include/nptl ++# ++#Recommended flags: ++#-D_XOPEN_SOURCE=600 +--- CFLAGS ++++ CFLAGS +@@ -0,0 +1,11 @@ ++#This file contains all the optimizations/compiler settings ++#needed for compiling the test suites. ++#These may be on one line or multiple lines. ++# ++#Lines beginning with # are comments. ++# ++#For example: ++#-g -O2 -std=c99 ++# ++#Recommended flags: ++# diff --git a/ppmtompeg-handle-gop.patch b/ppmtompeg-handle-gop.patch new file mode 100644 index 0000000..5004afb --- /dev/null +++ b/ppmtompeg-handle-gop.patch @@ -0,0 +1,13 @@ +Index: converter/ppm/ppmtompeg/mpeg.c +=================================================================== +--- converter/ppm/ppmtompeg/mpeg.c (revision 82) ++++ converter/ppm/ppmtompeg/mpeg.c (working copy) +@@ -1150,7 +1150,7 @@ GenMPEGStream(struct inputSource * const + if (showBitRatePerFrame) + OpenBitRateFile(); /* May modify showBitRatePerFrame */ + +- if (context == CONTEXT_WHOLESTREAM) ++ if (context == CONTEXT_WHOLESTREAM || context == CONTEXT_GOP) + bbP = Bitio_New(ofP); + else + bbP = NULL; diff --git a/ppmtompeg-no-shadow.patch b/ppmtompeg-no-shadow.patch new file mode 100644 index 0000000..6811c41 --- /dev/null +++ b/ppmtompeg-no-shadow.patch @@ -0,0 +1,12 @@ +Index: converter/ppm/ppmtompeg/combine.c +=================================================================== +--- converter/ppm/ppmtompeg/combine.c (revision 101) ++++ converter/ppm/ppmtompeg/combine.c (working copy) +@@ -110,7 +110,6 @@ appendSpecifiedGopFiles(struct inputSour + nAttempts < READ_ATTEMPTS && !ifP; + ++nAttempts) { + +- FILE * ifP; + ifP = fopen(fileName, "rb"); + if (ifP == NULL) { + pm_message("ERROR: Couldn't read file '%s'. retry %u", diff --git a/pread_write_sh.patch b/pread_write_sh.patch new file mode 100644 index 0000000..3f47b57 --- /dev/null +++ b/pread_write_sh.patch @@ -0,0 +1,21 @@ +diff -upr libc/sysdeps/linux/sh/pread_write.c libc-st/sysdeps/linux/sh/pread_write.c +--- libc/sysdeps/linux/sh/pread_write.c 2007-04-26 10:03:10.154246000 +0200 ++++ libc-st/sysdeps/linux/sh/pread_write.c 2007-04-26 10:04:12.474506000 +0200 +@@ -33,7 +33,7 @@ static inline _syscall6(ssize_t, __sysca + + ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset) + { +- return(__syscall_pread(fd,buf,count,0,__LONG_LONG_PAIR((off_t)0,offset))); ++ return(__syscall_pread(fd,buf,count,0,__LONG_LONG_PAIR(offset >> 31,offset))); + } + weak_alias(__libc_pread,pread) + +@@ -66,7 +66,7 @@ static inline _syscall6(ssize_t, __sysca + + ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset) + { +- return(__syscall_pwrite(fd,buf,count,0,__LONG_LONG_PAIR((off_t)0,offset))); ++ return(__syscall_pwrite(fd,buf,count,0,__LONG_LONG_PAIR(offset >> 31,offset))); + } + weak_alias(__libc_pwrite,pwrite) + diff --git a/printk-add-interfaces-for-external-access-to-the-log-buffer-dont-use-ring-buffer.patch b/printk-add-interfaces-for-external-access-to-the-log-buffer-dont-use-ring-buffer.patch new file mode 100644 index 0000000..56cf53a --- /dev/null +++ b/printk-add-interfaces-for-external-access-to-the-log-buffer-dont-use-ring-buffer.patch @@ -0,0 +1,31 @@ +Key off of the log buffer rather than the kernel ring buffer as the +latter is constantly cleared by userspace daemons. Also, make sure +we index into the buffer properly as pointed out by Tim Bird. + +Signed-off-by: Mike Frysinger +--- +--- a/kernel/printk.c ++++ b/kernel/printk.c +@@ -168,7 +168,7 @@ + */ + int log_buf_get_len(void) + { +- return log_end - log_start; ++ return logged_chars; + } + + /* +@@ -191,10 +191,9 @@ + if (len > max) + len = max; + ret = len; +- while (len-- > 0) { +- *dest = LOG_BUF(idx++); +- ++dest; +- } ++ idx += (log_end - max); ++ while (len-- > 0) ++ dest[len] = LOG_BUF(idx + len); + } + + if (took_lock) diff --git a/psmisc-dont-need-c++.patch b/psmisc-dont-need-c++.patch new file mode 100644 index 0000000..53e4745 --- /dev/null +++ b/psmisc-dont-need-c++.patch @@ -0,0 +1,15 @@ +Index: configure.ac +=================================================================== +RCS file: /cvsroot/psmisc/psmisc/configure.ac,v +retrieving revision 1.4 +diff -u -p -r1.4 configure.ac +--- configure.ac 4 Jul 2007 02:25:00 -0000 1.4 ++++ configure.ac 26 Sep 2007 05:42:47 -0000 +@@ -7,7 +7,6 @@ AC_CONFIG_AUX_DIR([config]) + AM_INIT_AUTOMAKE([1.10]) + + dnl Checks for programs. +-AC_PROG_CXX + AC_PROG_CC + #AC_PROG_CPP + AC_PROG_MAKE_SET diff --git a/qemu-friendlier-syscall.patch b/qemu-friendlier-syscall.patch new file mode 100644 index 0000000..b783182 --- /dev/null +++ b/qemu-friendlier-syscall.patch @@ -0,0 +1,327 @@ +--- linux-user/syscall.c 22 Mar 2007 15:08:55 -0000 1.95 ++++ linux-user/syscall.c 31 Mar 2007 08:36:00 -0000 +@@ -2043,6 +2047,7 @@ long do_syscall(void *cpu_env, int num, + case TARGET_NR_fork: + ret = get_errno(do_fork(cpu_env, SIGCHLD, 0)); + break; ++#ifdef TARGET_NR_waitpid + case TARGET_NR_waitpid: + { + int status; +@@ -2051,6 +2056,7 @@ long do_syscall(void *cpu_env, int num, + tput32(arg2, status); + } + break; ++#endif + case TARGET_NR_creat: + p = lock_user_string(arg1); + ret = get_errno(creat(p, arg2)); +@@ -2179,11 +2185,13 @@ long do_syscall(void *cpu_env, int num, + unlock_user(p3, arg3, 0); + break; + } ++#ifdef TARGET_NR_umount + case TARGET_NR_umount: + p = lock_user_string(arg1); + ret = get_errno(umount(p)); + unlock_user(p, arg1, 0); + break; ++#endif + case TARGET_NR_stime: + { + time_t host_time; +@@ -2203,6 +2211,7 @@ long do_syscall(void *cpu_env, int num, + case TARGET_NR_pause: + ret = get_errno(pause()); + break; ++#ifdef TARGET_NR_utime + case TARGET_NR_utime: + { + struct utimbuf tbuf, *host_tbuf; +@@ -2221,6 +2230,7 @@ long do_syscall(void *cpu_env, int num, + unlock_user(p, arg1, 0); + } + break; ++#endif + case TARGET_NR_utimes: + { + struct timeval *tvp, tv[2]; +@@ -2317,9 +2327,10 @@ long do_syscall(void *cpu_env, int num, + case TARGET_NR_prof: + goto unimplemented; + #endif ++#ifdef TARGET_NR_signal + case TARGET_NR_signal: + goto unimplemented; +- ++#endif + case TARGET_NR_acct: + p = lock_user_string(arg1); + ret = get_errno(acct(path(p))); +@@ -2377,6 +2388,7 @@ long do_syscall(void *cpu_env, int num, + case TARGET_NR_setsid: + ret = get_errno(setsid()); + break; ++#ifdef TARGET_NR_sigaction + case TARGET_NR_sigaction: + { + #if !defined(TARGET_MIPS) +@@ -2431,6 +2443,7 @@ long do_syscall(void *cpu_env, int num, + #endif + } + break; ++#endif + case TARGET_NR_rt_sigaction: + { + struct target_sigaction *act; +@@ -2472,6 +2485,7 @@ long do_syscall(void *cpu_env, int num, + ret = target_set; + } + break; ++#ifdef TARGET_NR_sigprocmask + case TARGET_NR_sigprocmask: + { + int how = arg1; +@@ -2508,6 +2522,7 @@ long do_syscall(void *cpu_env, int num, + } + } + break; ++#endif + case TARGET_NR_rt_sigprocmask: + { + int how = arg1; +@@ -2544,6 +2559,7 @@ long do_syscall(void *cpu_env, int num, + } + } + break; ++#ifdef TARGET_NR_sigpending + case TARGET_NR_sigpending: + { + sigset_t set; +@@ -2555,6 +2571,7 @@ long do_syscall(void *cpu_env, int num, + } + } + break; ++#endif + case TARGET_NR_rt_sigpending: + { + sigset_t set; +@@ -2566,6 +2583,7 @@ long do_syscall(void *cpu_env, int num, + } + } + break; ++#ifdef TARGET_NR_sigsuspend + case TARGET_NR_sigsuspend: + { + sigset_t set; +@@ -2575,6 +2593,7 @@ long do_syscall(void *cpu_env, int num, + ret = get_errno(sigsuspend(&set)); + } + break; ++#endif + case TARGET_NR_rt_sigsuspend: + { + sigset_t set; +@@ -2616,10 +2635,12 @@ long do_syscall(void *cpu_env, int num, + ret = get_errno(sys_rt_sigqueueinfo(arg1, arg2, &uinfo)); + } + break; ++#ifdef TARGET_NR_sigreturn + case TARGET_NR_sigreturn: + /* NOTE: ret is eax, so not transcoding must be done */ + ret = do_sigreturn(cpu_env); + break; ++#endif + case TARGET_NR_rt_sigreturn: + /* NOTE: ret is eax, so not transcoding must be done */ + ret = do_rt_sigreturn(cpu_env); +@@ -2725,17 +2746,24 @@ long do_syscall(void *cpu_env, int num, + unlock_user(p, arg1, 0); + } + break; ++#ifdef TARGET_NR_uselib + case TARGET_NR_uselib: + goto unimplemented; ++#endif ++#ifdef TARGET_NR_swapon + case TARGET_NR_swapon: + p = lock_user_string(arg1); + ret = get_errno(swapon(p, arg2)); + unlock_user(p, arg1, 0); + break; ++#endif + case TARGET_NR_reboot: + goto unimplemented; ++#ifdef TARGET_NR_readdir + case TARGET_NR_readdir: + goto unimplemented; ++#endif ++#ifdef TARGET_NR_mmap + case TARGET_NR_mmap: + #if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_M68K) + { +@@ -2760,6 +2788,7 @@ long do_syscall(void *cpu_env, int num, + arg6)); + #endif + break; ++#endif + #ifdef TARGET_NR_mmap2 + case TARGET_NR_mmap2: + #if defined(TARGET_SPARC) || defined(TARGET_MIPS) +@@ -2779,25 +2808,37 @@ long do_syscall(void *cpu_env, int num, + case TARGET_NR_mprotect: + ret = get_errno(target_mprotect(arg1, arg2, arg3)); + break; ++#ifdef TARGET_NR_mremap + case TARGET_NR_mremap: + ret = get_errno(target_mremap(arg1, arg2, arg3, arg4, arg5)); + break; ++#endif + /* ??? msync/mlock/munlock are broken for softmmu. */ ++#ifdef TARGET_NR_msync + case TARGET_NR_msync: + ret = get_errno(msync(g2h(arg1), arg2, arg3)); + break; ++#endif ++#ifdef TARGET_NR_mlock + case TARGET_NR_mlock: + ret = get_errno(mlock(g2h(arg1), arg2)); + break; ++#endif ++#ifdef TARGET_NR_munlock + case TARGET_NR_munlock: + ret = get_errno(munlock(g2h(arg1), arg2)); + break; ++#endif ++#ifdef TARGET_NR_mlockall + case TARGET_NR_mlockall: + ret = get_errno(mlockall(arg1)); + break; ++#endif ++#ifdef TARGET_NR_munlockall + case TARGET_NR_munlockall: + ret = get_errno(munlockall()); + break; ++#endif + case TARGET_NR_truncate: + p = lock_user_string(arg1); + ret = get_errno(truncate(p, arg2)); +@@ -2875,10 +2916,11 @@ long do_syscall(void *cpu_env, int num, + case TARGET_NR_ioperm: + goto unimplemented; + #endif ++#ifdef TARGET_NR_socketcall + case TARGET_NR_socketcall: + ret = do_socketcall(arg1, arg2); + break; +- ++#endif + #ifdef TARGET_NR_accept + case TARGET_NR_accept: + ret = do_accept(arg1, arg2, arg3); +@@ -3087,11 +3129,13 @@ long do_syscall(void *cpu_env, int num, + } + } + break; ++#ifdef TARGET_NR_swapoff + case TARGET_NR_swapoff: + p = lock_user_string(arg1); + ret = get_errno(swapoff(p)); + unlock_user(p, arg1, 0); + break; ++#endif + case TARGET_NR_sysinfo: + { + struct target_sysinfo *target_value; +@@ -3119,9 +3163,11 @@ long do_syscall(void *cpu_env, int num, + } + } + break; ++#ifdef TARGET_NR_ipc + case TARGET_NR_ipc: + ret = do_ipc(arg1, arg2, arg3, arg4, arg5, arg6); + break; ++#endif + case TARGET_NR_fsync: + ret = get_errno(fsync(arg1)); + break; +@@ -3170,10 +3216,14 @@ long do_syscall(void *cpu_env, int num, + #endif + case TARGET_NR_adjtimex: + goto unimplemented; ++#ifdef TARGET_NR_create_module + case TARGET_NR_create_module: ++#endif + case TARGET_NR_init_module: + case TARGET_NR_delete_module: ++#ifdef TARGET_NR_get_kernel_syms + case TARGET_NR_get_kernel_syms: ++#endif + goto unimplemented; + case TARGET_NR_quotactl: + goto unimplemented; +@@ -3185,13 +3235,17 @@ long do_syscall(void *cpu_env, int num, + break; + case TARGET_NR_bdflush: + goto unimplemented; ++#ifdef TARGET_NR_sysfs + case TARGET_NR_sysfs: + goto unimplemented; ++#endif + case TARGET_NR_personality: + ret = get_errno(personality(arg1)); + break; ++#ifdef TARGET_NR_afs_syscall + case TARGET_NR_afs_syscall: + goto unimplemented; ++#endif + case TARGET_NR__llseek: + { + #if defined (__x86_64__) +@@ -3305,9 +3359,12 @@ long do_syscall(void *cpu_env, int num, + } + break; + #endif /* TARGET_NR_getdents64 */ ++#ifdef TARGET_NR__newselect + case TARGET_NR__newselect: + ret = do_select(arg1, arg2, arg3, arg4, arg5); + break; ++#endif ++#ifdef TARGET_NR_poll + case TARGET_NR_poll: + { + struct target_pollfd *target_pfd; +@@ -3333,6 +3390,7 @@ long do_syscall(void *cpu_env, int num, + unlock_user(target_pfd, arg1, ret); + } + break; ++#endif + case TARGET_NR_flock: + /* NOTE: the flock constant seems to be the same for every + Linux platform */ +@@ -3434,10 +3492,14 @@ long do_syscall(void *cpu_env, int num, + } + } + break; ++#ifdef TARGET_NR_query_module + case TARGET_NR_query_module: + goto unimplemented; ++#endif ++#ifdef TARGET_NR_nfsservctl + case TARGET_NR_nfsservctl: + goto unimplemented; ++#endif + case TARGET_NR_prctl: + switch (arg1) + { +@@ -3970,8 +4032,10 @@ long do_syscall(void *cpu_env, int num, + case TARGET_NR_gettid: + ret = get_errno(gettid()); + break; ++#ifdef TARGET_NR_readahead + case TARGET_NR_readahead: + goto unimplemented; ++#endif + #ifdef TARGET_NR_setxattr + case TARGET_NR_setxattr: + case TARGET_NR_lsetxattr: diff --git a/qemu-socklen-t.patch b/qemu-socklen-t.patch new file mode 100644 index 0000000..6827fba --- /dev/null +++ b/qemu-socklen-t.patch @@ -0,0 +1,30 @@ +--- linux-user/syscall.c ++++ linux-user/syscall.c +@@ -642,7 +642,8 @@ static long do_setsockopt(int sockfd, in + static long do_getsockopt(int sockfd, int level, int optname, + target_ulong optval, target_ulong optlen) + { +- int len, lv, val, ret; ++ int len, val, ret; ++ socklen_t lv; + + switch(level) { + case TARGET_SOL_SOCKET: +@@ -665,7 +666,7 @@ static long do_getsockopt(int sockfd, in + len = tget32(optlen); + if (len < 0) + return -EINVAL; +- lv = sizeof(int); ++ lv = sizeof(val); + ret = get_errno(getsockopt(sockfd, level, optname, &val, &lv)); + if (ret < 0) + return ret; +@@ -698,7 +699,7 @@ static long do_getsockopt(int sockfd, in + len = tget32(optlen); + if (len < 0) + return -EINVAL; +- lv = sizeof(int); ++ lv = sizeof(val); + ret = get_errno(getsockopt(sockfd, level, optname, &val, &lv)); + if (ret < 0) + return ret; diff --git a/redland-bindings-mkdir.patch b/redland-bindings-mkdir.patch new file mode 100644 index 0000000..a3cdcc6 --- /dev/null +++ b/redland-bindings-mkdir.patch @@ -0,0 +1,26 @@ +Index: csharp/Makefile.am +=================================================================== +--- csharp/Makefile.am (revision 11290) ++++ csharp/Makefile.am (working copy) +@@ -86,7 +86,8 @@ test.exe: test.cs Redland.dll + $(CSHARP_LINK) test.cs -target:exe -r:Redland.dll -out:$@ + + install-csharp: build-csharp-stamp +- $(INSTALL_PROGRAM) $(CSHARP_DLL) @libdir@ ++ $(mkinstalldirs) $(DESTDIR)$(libdir) ++ $(INSTALL_PROGRAM) $(CSHARP_DLL) $(libdir) + + clean-local: + rm -f build-csharp-stamp $(CSHARP_DLL) +Index: tcl/Makefile.am +=================================================================== +--- tcl/Makefile.am (revision 11290) ++++ tcl/Makefile.am (working copy) +@@ -70,6 +70,7 @@ $(TCL_PACKAGE)-stamp: $(TCL_PACKAGE)_wra + touch $(TCL_PACKAGE)-stamp + + install-tclDATA: $(tcl_DATA) ++ $(mkinstalldirs) $(DESTDIR)$(tcldir) + if test -r $(TCL_PACKAGE).dylib; then \ + $(INSTALL_PROGRAM) $(TCL_PACKAGE).dylib $(DESTDIR)$(tcldir)/$(TCL_PACKAGE).dylib; \ + else \ diff --git a/redland-configure-threads.patch b/redland-configure-threads.patch new file mode 100644 index 0000000..b2010b8 --- /dev/null +++ b/redland-configure-threads.patch @@ -0,0 +1,13 @@ +Index: configure.ac +=================================================================== +--- configure.ac (revision 11290) ++++ configure.ac (working copy) +@@ -897,7 +897,7 @@ LIBS="$LIBRDF_LIBS" + + dnl Check for use of threads + +-AC_ARG_WITH(threads, [ --with-threads With POSIX thread support (default=no)], with_threads="yes", with_threads="no") ++AC_ARG_WITH(threads, [ --with-threads With POSIX thread support (default=no)], with_threads="$withval", with_threads="no") + + AC_CHECK_HEADERS(pthread.h) + diff --git a/reiserfsprogs-3.6.20-swab-non-portable.patch b/reiserfsprogs-3.6.20-swab-non-portable.patch new file mode 100644 index 0000000..c7451ad --- /dev/null +++ b/reiserfsprogs-3.6.20-swab-non-portable.patch @@ -0,0 +1,59 @@ +--- include/misc/swab.h.orig 2006-11-06 20:06:59.000000000 -0500 ++++ include/misc/swab.h 2006-11-06 20:07:55.000000000 -0500 +@@ -7,36 +7,30 @@ + #define MISC_SWAB_H + + #define __swab16(x) \ +-({ \ +- __u16 __x = (x); \ +- ((__u16)( \ +- (((__u16)(__x) & (__u16)0x00ffU) << 8) | \ +- (((__u16)(__x) & (__u16)0xff00U) >> 8) )); \ +-}) ++( ((__u16)( \ ++ (((__u16)(x) & (__u16)0x00ffU) << 8) | \ ++ (((__u16)(x) & (__u16)0xff00U) >> 8) )) \ ++) + + #define __swab32(x) \ +-({ \ +- __u32 __x = (x); \ +- ((__u32)( \ +- (((__u32)(__x) & (__u32)0x000000ffUL) << 24) | \ +- (((__u32)(__x) & (__u32)0x0000ff00UL) << 8) | \ +- (((__u32)(__x) & (__u32)0x00ff0000UL) >> 8) | \ +- (((__u32)(__x) & (__u32)0xff000000UL) >> 24) )); \ +-}) ++( ((__u32)( \ ++ (((__u32)(x) & (__u32)0x000000ffUL) << 24) | \ ++ (((__u32)(x) & (__u32)0x0000ff00UL) << 8) | \ ++ (((__u32)(x) & (__u32)0x00ff0000UL) >> 8) | \ ++ (((__u32)(x) & (__u32)0xff000000UL) >> 24) )) \ ++) + + #define __swab64(x) \ +-({ \ +- __u64 __x = (x); \ +- ((__u64)( \ +- (__u64)(((__u64)(__x) & (__u64)0x00000000000000ffULL) << 56) | \ +- (__u64)(((__u64)(__x) & (__u64)0x000000000000ff00ULL) << 40) | \ +- (__u64)(((__u64)(__x) & (__u64)0x0000000000ff0000ULL) << 24) | \ +- (__u64)(((__u64)(__x) & (__u64)0x00000000ff000000ULL) << 8) | \ +- (__u64)(((__u64)(__x) & (__u64)0x000000ff00000000ULL) >> 8) | \ +- (__u64)(((__u64)(__x) & (__u64)0x0000ff0000000000ULL) >> 24) | \ +- (__u64)(((__u64)(__x) & (__u64)0x00ff000000000000ULL) >> 40) | \ +- (__u64)(((__u64)(__x) & (__u64)0xff00000000000000ULL) >> 56) )); \ +-}) ++( ((__u64)( \ ++ (__u64)(((__u64)(x) & (__u64)0x00000000000000ffULL) << 56) | \ ++ (__u64)(((__u64)(x) & (__u64)0x000000000000ff00ULL) << 40) | \ ++ (__u64)(((__u64)(x) & (__u64)0x0000000000ff0000ULL) << 24) | \ ++ (__u64)(((__u64)(x) & (__u64)0x00000000ff000000ULL) << 8) | \ ++ (__u64)(((__u64)(x) & (__u64)0x000000ff00000000ULL) >> 8) | \ ++ (__u64)(((__u64)(x) & (__u64)0x0000ff0000000000ULL) >> 24) | \ ++ (__u64)(((__u64)(x) & (__u64)0x00ff000000000000ULL) >> 40) | \ ++ (__u64)(((__u64)(x) & (__u64)0xff00000000000000ULL) >> 56) )) \ ++) + + + #ifndef WORDS_BIGENDIAN diff --git a/rrdtool-bindings-build-cleanup.patch b/rrdtool-bindings-build-cleanup.patch new file mode 100644 index 0000000..553a751 --- /dev/null +++ b/rrdtool-bindings-build-cleanup.patch @@ -0,0 +1,41 @@ +--- rrdtool-1.2.23/bindings/Makefile.am ++++ rrdtool-1.2.23/bindings/Makefile.am +@@ -1,4 +1,4 @@ +-.PHONY: python ruby ++.PHONY: python ruby perl_piped perl_shared + + if BUILD_TCL + SUB_tcl = tcl +@@ -16,11 +16,27 @@ + # add the following to the all target + all-local: @COMP_PERL@ @COMP_RUBY@ @COMP_PYTHON@ + +-install-data-local: +- test -f perl-piped/Makefile && cd perl-piped && $(MAKE) install || true +- test -f perl-shared/Makefile && cd perl-shared && $(MAKE) install || true +- test -f ruby/Makefile && cd ruby && $(MAKE) EPREFIX=$(exec_prefix) $(RUBY_MAKE_OPTIONS) install || true +- test -d python/build && cd python && env LIBDIR=$(libdir) $(PYTHON) setup.py install --skip-build --prefix=$(DESTDIR)$(prefix) --exec-prefix=$(DESTDIR)$(exec_prefix) || true ++install-exec-local: install-perl install-ruby install-python ++ ++install-perl: install-perl-piped install-perl-shared ++ ++install-perl-piped: @COMP_PERL@ ++ test -n "@COMP_PERL@" || exit 0 ; \ ++ cd perl-piped && $(MAKE) install ++ ++install-perl-shared: @COMP_PERL@ ++ test -n "@COMP_PERL@" || exit 0 ; \ ++ cd perl-shared && $(MAKE) install ++ ++install-ruby: @COMP_RUBY@ ++ test -n "@COMP_RUBY@" || exit 0 ; \ ++ cd ruby && $(MAKE) EPREFIX=$(exec_prefix) $(RUBY_MAKE_OPTIONS) install ++ ++# need to delete "build" as it will have RPATHs ++# encoded in it for the local compile ++install-python: @COMP_PYTHON@ ++ test -n "@COMP_PYTHON@" || exit 0 ; \ ++ cd python && rm -rf build && env LIBDIR=$(libdir) $(PYTHON) setup.py install --prefix=$(DESTDIR)$(prefix) --exec-prefix=$(DESTDIR)$(exec_prefix) + + # rules for buildung the ruby module + ruby: diff --git a/sdl-check-reversed.patch b/sdl-check-reversed.patch new file mode 100644 index 0000000..d445ed8 --- /dev/null +++ b/sdl-check-reversed.patch @@ -0,0 +1,98 @@ +Index: src/video/fbcon/SDL_fbvideo.c +=================================================================== +--- src/video/fbcon/SDL_fbvideo.c (revision 2761) ++++ src/video/fbcon/SDL_fbvideo.c (working copy) +@@ -412,7 +412,7 @@ FB_CheckMode(_THIS, struct fb_var_screen + + static int + FB_AddMode(_THIS, int index, unsigned int w, unsigned int h, +- int check_timings) ++ int check_timings, int reversed) + { + SDL_Rect *mode; + int i; +@@ -435,10 +435,12 @@ FB_AddMode(_THIS, int index, unsigned in + if (check_timings) { + int found_timing = 0; + for (i = 0; i < (sizeof(vesa_timings) / sizeof(vesa_timings[0])); ++i) { +- if ((w == vesa_timings[i].xres) && +- (h == vesa_timings[i].yres) && vesa_timings[i].pixclock) { +- found_timing = 1; +- break; ++ if (vesa_timings[i].pixclock) { ++ if (!reversed && w == vesa_timings[i].xres && h == vesa_timings[i].yres || ++ reversed && h == vesa_timings[i].xres && w == vesa_timings[i].yres) { ++ found_timing = 1; ++ break; ++ } + } + } + if (!found_timing) { +@@ -653,24 +655,33 @@ FB_VideoInit(_THIS, SDL_PixelFormat * vf + SDL_modelist[i] = NULL; + } + if (SDL_getenv("SDL_FB_BROKEN_MODES") != NULL) { +- FB_AddMode(this, current_index, current_w, current_h, 0); ++ FB_AddMode(this, current_index, current_w, current_h, 0, 0); + } else if (modesdb) { + while (read_fbmodes_mode(modesdb, &vinfo)) { + for (i = 0; i < NUM_MODELISTS; ++i) { + unsigned int w, h; ++ int reversed = 0; + + /* See if we are querying for the current mode */ + w = vinfo.xres; + h = vinfo.yres; ++try_reversed_dynamic: + if (i == current_index) { + if ((current_w > w) || (current_h > h)) { + /* Only check once */ +- FB_AddMode(this, i, current_w, current_h, 0); ++ FB_AddMode(this, i, current_w, current_h, 0, reversed); + current_index = -1; + } + } + if (FB_CheckMode(this, &vinfo, i, &w, &h)) { +- FB_AddMode(this, i, w, h, 0); ++ FB_AddMode(this, i, w, h, 0, reversed); ++ } ++ ++ /* See if a reversed X/Y matches */ ++ if (!reversed) { ++ unsigned tmp = w; w = h; h = tmp; ++ reversed = 1; ++ goto try_reversed_dynamic; + } + } + } +@@ -680,19 +691,28 @@ FB_VideoInit(_THIS, SDL_PixelFormat * vf + for (i = 0; i < NUM_MODELISTS; ++i) { + for (j = 0; j < (sizeof(checkres) / sizeof(checkres[0])); ++j) { + unsigned int w, h; ++ int reversed = 0; + + /* See if we are querying for the current mode */ + w = checkres[j].w; + h = checkres[j].h; ++try_reversed_static: + if (i == current_index) { + if ((current_w > w) || (current_h > h)) { + /* Only check once */ +- FB_AddMode(this, i, current_w, current_h, 0); ++ FB_AddMode(this, i, current_w, current_h, 0, reversed); + current_index = -1; + } + } + if (FB_CheckMode(this, &vinfo, i, &w, &h)) { +- FB_AddMode(this, i, w, h, 1); ++ FB_AddMode(this, i, w, h, 1, reversed); ++ } ++ ++ /* See if a reversed X/Y matches */ ++ if (!reversed) { ++ unsigned tmp = w; w = h; h = tmp; ++ reversed = 1; ++ goto try_reversed_static; + } + } + } diff --git a/sdl-fbcon-page-header.patch b/sdl-fbcon-page-header.patch new file mode 100644 index 0000000..07cf978 --- /dev/null +++ b/sdl-fbcon-page-header.patch @@ -0,0 +1,108 @@ +Index: src/video/fbcon/SDL_fbvideo.c +=================================================================== +--- src/video/fbcon/SDL_fbvideo.c (revision 2990) ++++ src/video/fbcon/SDL_fbvideo.c (working copy) +@@ -29,7 +29,9 @@ + #include + #include + #include ++#ifndef HAVE_GETPAGESIZE + #include /* For definition of PAGE_SIZE */ ++#endif + #include + + #include "SDL_video.h" +@@ -425,7 +427,7 @@ FB_CheckMode(_THIS, struct fb_var_screen + + static int + FB_AddMode(_THIS, int index, unsigned int w, unsigned int h, +- int check_timings) ++ int check_timings, int reversed) + { + SDL_Rect *mode; + int i; +@@ -448,10 +450,12 @@ FB_AddMode(_THIS, int index, unsigned in + if (check_timings) { + int found_timing = 0; + for (i = 0; i < (sizeof(vesa_timings) / sizeof(vesa_timings[0])); ++i) { +- if ((w == vesa_timings[i].xres) && +- (h == vesa_timings[i].yres) && vesa_timings[i].pixclock) { +- found_timing = 1; +- break; ++ if (vesa_timings[i].pixclock) { ++ if (!reversed && w == vesa_timings[i].xres && h == vesa_timings[i].yres || ++ reversed && h == vesa_timings[i].xres && w == vesa_timings[i].yres) { ++ found_timing = 1; ++ break; ++ } + } + } + if (!found_timing) { +@@ -667,24 +671,33 @@ FB_VideoInit(_THIS, SDL_PixelFormat * vf + SDL_modelist[i] = NULL; + } + if (SDL_getenv("SDL_FB_BROKEN_MODES") != NULL) { +- FB_AddMode(this, current_index, current_w, current_h, 0); ++ FB_AddMode(this, current_index, current_w, current_h, 0, 0); + } else if (modesdb) { + while (read_fbmodes_mode(modesdb, &vinfo)) { + for (i = 0; i < NUM_MODELISTS; ++i) { + unsigned int w, h; ++ int reversed = 0; + + /* See if we are querying for the current mode */ + w = vinfo.xres; + h = vinfo.yres; ++try_reversed_dynamic: + if (i == current_index) { + if ((current_w > w) || (current_h > h)) { + /* Only check once */ +- FB_AddMode(this, i, current_w, current_h, 0); ++ FB_AddMode(this, i, current_w, current_h, 0, reversed); + current_index = -1; + } + } + if (FB_CheckMode(this, &vinfo, i, &w, &h)) { +- FB_AddMode(this, i, w, h, 0); ++ FB_AddMode(this, i, w, h, 0, reversed); ++ } ++ ++ /* See if a reversed X/Y matches */ ++ if (!reversed) { ++ unsigned tmp = w; w = h; h = tmp; ++ reversed = 1; ++ goto try_reversed_dynamic; + } + } + } +@@ -694,19 +707,28 @@ FB_VideoInit(_THIS, SDL_PixelFormat * vf + for (i = 0; i < NUM_MODELISTS; ++i) { + for (j = 0; j < (sizeof(checkres) / sizeof(checkres[0])); ++j) { + unsigned int w, h; ++ int reversed = 0; + + /* See if we are querying for the current mode */ + w = checkres[j].w; + h = checkres[j].h; ++try_reversed_static: + if (i == current_index) { + if ((current_w > w) || (current_h > h)) { + /* Only check once */ +- FB_AddMode(this, i, current_w, current_h, 0); ++ FB_AddMode(this, i, current_w, current_h, 0, reversed); + current_index = -1; + } + } + if (FB_CheckMode(this, &vinfo, i, &w, &h)) { +- FB_AddMode(this, i, w, h, 1); ++ FB_AddMode(this, i, w, h, 1, reversed); ++ } ++ ++ /* See if a reversed X/Y matches */ ++ if (!reversed) { ++ unsigned tmp = w; w = h; h = tmp; ++ reversed = 1; ++ goto try_reversed_static; + } + } + } diff --git a/sdl-no-inline-BlitRGBtoRGBPixelAlphaMMX3DNOW.patch b/sdl-no-inline-BlitRGBtoRGBPixelAlphaMMX3DNOW.patch new file mode 100644 index 0000000..50f33ab --- /dev/null +++ b/sdl-no-inline-BlitRGBtoRGBPixelAlphaMMX3DNOW.patch @@ -0,0 +1,11 @@ +--- src/video/SDL_blit_A.c ++++ src/video/SDL_blit_A.c +@@ -1621,7 +1621,7 @@ BlitRGBtoRGBPixelAlpha(SDL_BlitInfo * in + + #if GCC_ASMBLIT + /* fast (as in MMX with prefetch) ARGB888->(A)RGB888 blending with pixel alpha */ +-inline static void ++static void + BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo * info) + { + int width = info->d_width; diff --git a/sdl-sound-1.0.2-headers.patch b/sdl-sound-1.0.2-headers.patch new file mode 100644 index 0000000..c9a531c --- /dev/null +++ b/sdl-sound-1.0.2-headers.patch @@ -0,0 +1,12 @@ +Index: decoders/shn.c +=================================================================== +--- decoders/shn.c (revision 553) ++++ decoders/shn.c (working copy) +@@ -50,6 +50,7 @@ + #include + #include + #include ++#include + + #include "SDL_sound.h" + diff --git a/sdl-yasm-sections.patch b/sdl-yasm-sections.patch new file mode 100644 index 0000000..67bd746 --- /dev/null +++ b/sdl-yasm-sections.patch @@ -0,0 +1,83 @@ +Index: configure.in +=================================================================== +--- configure.in (revision 2987) ++++ configure.in (working copy) +@@ -640,38 +640,56 @@ CheckNASM() + AC_HELP_STRING([--enable-nasm], [use nasm assembly blitters on x86 [[default=yes]]]), + , enable_nasm=yes) + if test x$enable_video = xyes -a x$enable_assembly = xyes -a x$enable_nasm = xyes; then ++ CompileNASM() ++ { ++ # Usage: CompileNASM ++ AC_MSG_CHECKING(to see if $NASM supports $1) ++ if $NASM $NASMFLAGS $1 -o $1.o >&AS_MESSAGE_LOG_FD 2>&1; then ++ CompileNASM_ret="yes" ++ else ++ CompileNASM_ret="no" ++ fi ++ rm -f $1 $1.o ++ AC_MSG_RESULT($CompileNASM_ret) ++ test "$CompileNASM_ret" = "yes" ++ } ++ ++ if test x"$NASMFLAGS" = x; then ++ case $ARCH in ++ win32) ++ NASMFLAGS="-f win32" ++ ;; ++ openbsd) ++ NASMFLAGS="-f aoutb" ++ ;; ++ macosx) ++ NASMFLAGS="-f macho" ++ ;; ++ *) ++ NASMFLAGS="-f elf" ++ ;; ++ esac ++ fi ++ + AC_PATH_PROG(NASM, yasm) ++ echo "%ifidn __OUTPUT_FORMAT__,elf" > unquoted-sections ++ echo "section .note.GNU-stack noalloc noexec nowrite progbits" >> unquoted-sections ++ echo "%endif" >> unquoted-sections ++ CompileNASM unquoted-sections || NASM="" ++ + if test "x$NASM" = x -o "x$NASM" = x'"$NASM"'; then ++ $as_unset ac_cv_path_NASM + AC_PATH_PROG(NASM, nasm) + fi + if test "x$NASM" != x -a "x$NASM" != x'"$NASM"'; then + AC_DEFINE(SDL_HERMES_BLITTERS) + SOURCES="$SOURCES $srcdir/src/hermes/*.asm" +- if test x"$NASMFLAGS" = x; then +- case $ARCH in +- win32) +- NASMFLAGS="-f win32" +- ;; +- openbsd) +- NASMFLAGS="-f aoutb" +- ;; +- macosx) +- NASMFLAGS="-f macho" +- ;; +- *) +- NASMFLAGS="-f elf" +- ;; +- esac +- fi + NASMFLAGS="$NASMFLAGS -i $srcdir/src/hermes/" + + dnl See if hidden visibility is supported +- echo "GLOBAL _bar:function hidden" > nasm_vis.asm +- echo "_bar:" >>nasm_vis.asm +- if $NASM $NASMFLAGS nasm_vis.asm -o nasm_vis.o >&AS_MESSAGE_LOG_FD 2>&1; then +- NASMFLAGS="$NASMFLAGS -DHIDDEN_VISIBILITY" +- fi +- rm -f nasm_vis.asm nasm_vis.o ++ echo "GLOBAL _bar:function hidden" > symbol-visibility ++ echo "_bar:" >> symbol-visibility ++ CompileNASM symbol-visibility && NASMFLAGS="$NASMFLAGS -DHIDDEN_VISIBILITY" + + AC_SUBST(NASM) + AC_SUBST(NASMFLAGS) diff --git a/sed-help2man-locales.patch b/sed-help2man-locales.patch new file mode 100644 index 0000000..f17d49f --- /dev/null +++ b/sed-help2man-locales.patch @@ -0,0 +1,16 @@ +Index: build-aux/help2man +=================================================================== +RCS file: /sources/sed/sed/build-aux/help2man,v +retrieving revision 1.1 +diff -u -p -r1.1 help2man +--- build-aux/help2man 27 Sep 2006 12:28:23 -0000 1.1 ++++ build-aux/help2man 26 Sep 2007 06:55:16 -0000 +@@ -353,7 +353,7 @@ while (length) + s/(.)\n(Copyright |This +is +free +software)/$1\n.br\n$2/g; + + # Join hyphenated lines. +- s/([A-Za-z])-\n */$1/g; ++ s/([[:alpha:]])-\n */$1/g; + } + + $include{$sect} .= $copy; diff --git a/sed-manpage-quit.patch b/sed-manpage-quit.patch new file mode 100644 index 0000000..28cdeab --- /dev/null +++ b/sed-manpage-quit.patch @@ -0,0 +1,23 @@ +Index: doc/sed.x +=================================================================== +RCS file: /sources/sed/sed/doc/sed.x,v +retrieving revision 1.2 +diff -u -p -r1.2 sed.x +--- doc/sed.x 30 Jan 2006 07:20:30 -0000 1.2 ++++ doc/sed.x 26 Sep 2007 07:00:22 -0000 +@@ -67,13 +67,13 @@ Insert + .IR text , + which has each embedded newline preceded by a backslash. + .TP +-q ++q [\fIexit-code\fR] + Immediately quit the \*(sd script without processing + any more input, + except that if auto-print is not disabled + the current pattern space will be printed. + .TP +-Q ++Q [\fIexit-code\fR] + Immediately quit the \*(sd script without processing + any more input. + .TP diff --git a/shadow-4.0.13-nonis.patch b/shadow-4.0.13-nonis.patch new file mode 100644 index 0000000..0c89e90 --- /dev/null +++ b/shadow-4.0.13-nonis.patch @@ -0,0 +1,53 @@ +--- src/login_nopam.c ++++ src/login_nopam.c +@@ -50,7 +50,9 @@ + #include + #include /* for inet_ntoa() */ + extern struct group *getgrnam (); ++#ifdef USE_NIS + extern int innetgr (); ++#endif + + #if !defined(MAXHOSTNAMELEN) || (MAXHOSTNAMELEN < 64) + #undef MAXHOSTNAMELEN +@@ -178,6 +180,7 @@ static char *myhostname (void) + return (name); + } + ++#ifdef USE_NIS + /* netgroup_match - match group against machine or user */ + static int + netgroup_match (const char *group, const char *machine, const char *user) +@@ -193,6 +196,7 @@ netgroup_match (const char *group, const + + return innetgr (group, machine, user, mydomain); + } ++#endif + + /* user_match - match a username against one token */ + static int user_match (const char *tok, const char *string) +@@ -214,8 +218,10 @@ static int user_match (const char *tok, + *at = 0; + return (user_match (tok, string) + && from_match (at + 1, myhostname ())); ++#ifdef USE_NIS + } else if (tok[0] == '@') { /* netgroup */ + return (netgroup_match (tok + 1, (char *) 0, string)); ++#endif + } else if (string_match (tok, string)) { /* ALL or exact match */ + return (YES); + } else if ((group = getgrnam (tok))) { /* try group membership */ +@@ -271,9 +277,12 @@ static int from_match (const char *tok, + * contain a "." character. If the token is a network number, return YES + * if it matches the head of the string. + */ ++#ifdef USE_NIS + if (tok[0] == '@') { /* netgroup */ + return (netgroup_match (tok + 1, string, (char *) 0)); +- } else if (string_match (tok, string)) { /* ALL or exact match */ ++ } else ++#endif ++ if (string_match (tok, string)) { /* ALL or exact match */ + return (YES); + } else if (tok[0] == '.') { /* domain: match last fields */ + if ((str_len = strlen (string)) > (tok_len = strlen (tok)) diff --git a/shadow-4.0.14-su-fix-environment.patch b/shadow-4.0.14-su-fix-environment.patch new file mode 100644 index 0000000..b537c7b --- /dev/null +++ b/shadow-4.0.14-su-fix-environment.patch @@ -0,0 +1,26 @@ +The patch from upstream (shadow-4.0.11.1-SUPATH.patch) sets environ too +early when using PAM, so move it to !USE_PAM. + +--- shadow-4.0.14/src/su.c ++++ shadow-4.0.14/src/su.c +@@ -594,11 +594,6 @@ + addenv ("PATH", cp); + } + +-#ifndef USE_PAM +- /* setup the environment for PAM later on, else we run into auth problems */ +- environ = newenvp; /* make new environment active */ +-#endif +- + if (getenv ("IFS")) /* don't export user IFS ... */ + addenv ("IFS= \t\n", NULL); /* ... instead, set a safe IFS */ + +@@ -666,6 +664,8 @@ + exit (1); + } + #else /* !USE_PAM */ ++ environ = newenvp; /* make new environment active */ ++ + if (!amroot) /* no limits if su from root */ + setup_limits (&pwent); + diff --git a/shadow-4.0.16-fix-useradd-usergroups.patch b/shadow-4.0.16-fix-useradd-usergroups.patch new file mode 100644 index 0000000..a1c1500 --- /dev/null +++ b/shadow-4.0.16-fix-useradd-usergroups.patch @@ -0,0 +1,95 @@ +--- src/useradd.c ++++ src/useradd.c +@@ -114,7 +114,7 @@ static int do_grp_update = 0; /* group f + static char *Prog; + + static int +- bflg = 0, /* new default root of home directory */ ++ bflg = 0, /* new default root of home directory */ + cflg = 0, /* comment (GECOS) field for new account */ + dflg = 0, /* home directory for new account */ + Dflg = 0, /* set/show new user default values */ +@@ -253,6 +253,12 @@ static void get_defaults (void) + const struct group *grp; + + /* ++ * Pull relevant settings from login.defs first. ++ */ ++ if (getdef_bool ("USERGROUPS_ENAB")) ++ nflg = -1; ++ ++ /* + * Open the defaults file for reading. + */ + +@@ -628,6 +634,8 @@ static void usage (void) + " -K, --key KEY=VALUE overrides /etc/login.defs defaults\n" + " -m, --create-home create home directory for the new user\n" + " account\n" ++ " -n, --user-group create a new group with the same name as the\n" ++ " new user\n" + " -o, --non-unique allow create user with duplicate\n" + " (non-unique) UID\n" + " -p, --password PASSWORD use encrypted password for the new user\n" +@@ -1009,6 +1017,7 @@ static void process_flags (int argc, cha + {"skel", required_argument, NULL, 'k'}, + {"key", required_argument, NULL, 'K'}, + {"create-home", no_argument, NULL, 'm'}, ++ {"user-group", no_argument, NULL, 'n'}, + {"non-unique", no_argument, NULL, 'o'}, + {"password", required_argument, NULL, 'p'}, + {"shell", required_argument, NULL, 's'}, +@@ -1016,7 +1025,7 @@ static void process_flags (int argc, cha + {NULL, 0, NULL, '\0'} + }; + while ((c = +- getopt_long (argc, argv, "b:c:d:De:f:g:G:k:K:mMop:s:u:", ++ getopt_long (argc, argv, "b:c:d:De:f:g:G:k:K:mMnop:s:u:", + long_options, NULL)) != -1) { + switch (c) { + case 'b': +@@ -1156,6 +1165,9 @@ static void process_flags (int argc, cha + case 'm': + mflg++; + break; ++ case 'n': ++ nflg = 1; ++ break; + case 'o': + oflg++; + break; +@@ -1203,6 +1215,16 @@ static void process_flags (int argc, cha + usage (); + + /* ++ * Using --gid and --user-group doesn't make sense. ++ */ ++ if (nflg == -1 && gflg) ++ nflg = 0; ++ if (nflg && gflg) { ++ fprintf (stderr, _("%s: options -g and -n conflict\n"), Prog); ++ exit (E_BAD_ARG); ++ } ++ ++ /* + * Either -D or username is required. Defaults can be set with -D + * for the -b, -e, -f, -g, -s options only. + */ +@@ -1725,7 +1747,7 @@ int main (int argc, char **argv) + * to that group, use useradd -g username username. + * --bero + */ +- if (!gflg) { ++ if (nflg) { + if (getgrnam (user_name)) { + fprintf (stderr, + _ +@@ -1759,7 +1781,7 @@ int main (int argc, char **argv) + + /* do we have to add a group for that user? This is why we need to + * open the group files in the open_files() function --gafton */ +- if (!(nflg || gflg)) { ++ if (nflg) { + find_new_gid (); + grp_add (); + } diff --git a/shadow-abort-when-man-support-fails.patch b/shadow-abort-when-man-support-fails.patch new file mode 100644 index 0000000..2805a63 --- /dev/null +++ b/shadow-abort-when-man-support-fails.patch @@ -0,0 +1,25 @@ +Index: configure.in +=================================================================== +RCS file: /cvsroot/shadow/configure.in,v +retrieving revision 1.142 +diff -u -p -r1.142 configure.in +--- configure.in 1 Jun 2006 21:07:27 -0000 1.142 ++++ configure.in 10 Jun 2006 21:44:08 -0000 +@@ -246,14 +246,14 @@ if test "$enable_man" = "yes"; then + dnl + AC_PATH_PROG([XSLTPROC], [xsltproc]) + if test -z "$XSLTPROC"; then +- enable_man=no ++ AC_MSG_ERROR(man support requested but no xsltproc found) + fi + + dnl check for DocBook DTD and stylesheets in the local catalog. + JH_CHECK_XML_CATALOG([-//OASIS//DTD DocBook XML V4.1.2//EN], +- [DocBook XML DTD V4.1.2], [], enable_man=no) ++ [DocBook XML DTD V4.1.2], [], [AC_MSG_ERROR(man support requested but no docbook xml found)]) + JH_CHECK_XML_CATALOG([http://docbook.sf.net/release/xsl/current/manpages/docbook.xsl], +- [DocBook XSL Stylesheets >= 1.70.1], [], enable_man=no) ++ [DocBook XSL Stylesheets >= 1.70.1], [], [AC_MSG_ERROR(man support requested but no docbook xsl found)]) + fi + AM_CONDITIONAL(ENABLE_REGENERATE_MAN, test x$enable_man != xno) + diff --git a/shadow-document-USERGROUPS_ENAB.patch b/shadow-document-USERGROUPS_ENAB.patch new file mode 100644 index 0000000..e4429c2 --- /dev/null +++ b/shadow-document-USERGROUPS_ENAB.patch @@ -0,0 +1,32 @@ +2006-04-07 Mike Frysinger + + * man/login.defs.5.xml (USERGROUPS_ENAB): Document. + +--- man/login.defs.5.xml ++++ man/login.defs.5.xml +@@ -163,6 +163,17 @@ + + + ++ ++ USERGROUPS_ENAB (boolean) ++ ++ ++ If yes, then when a user logs in ++ and their uid != 0, uid == gid, and their username is the same as ++ their initial login group, their umask is set to 002 instead of ++ 022. ++ ++ ++ + + + +@@ -222,6 +233,7 @@ + + MAIL_DIR + USERDEL_CMD ++ USERGROUPS_ENAB + + + diff --git a/shadow-fix-useradd-usergroups.patch b/shadow-fix-useradd-usergroups.patch new file mode 100644 index 0000000..38c16b2 --- /dev/null +++ b/shadow-fix-useradd-usergroups.patch @@ -0,0 +1,127 @@ +Index: src/useradd.c +=================================================================== +RCS file: /cvsroot/shadow/src/useradd.c,v +retrieving revision 1.96 +diff -u -p -r1.96 useradd.c +--- src/useradd.c 30 May 2006 18:28:45 -0000 1.96 ++++ src/useradd.c 10 Jun 2006 22:13:32 -0000 +@@ -114,7 +114,7 @@ static int do_grp_update = 0; /* group f + static char *Prog; + + static int +- bflg = 0, /* new default root of home directory */ ++ bflg = 0, /* new default root of home directory */ + cflg = 0, /* comment (GECOS) field for new account */ + dflg = 0, /* home directory for new account */ + Dflg = 0, /* set/show new user default values */ +@@ -253,6 +253,12 @@ static void get_defaults (void) + const struct group *grp; + + /* ++ * Pull relevant settings from login.defs first. ++ */ ++ if (getdef_bool ("USERGROUPS_ENAB")) ++ nflg = -1; ++ ++ /* + * Open the defaults file for reading. + */ + +@@ -628,6 +634,8 @@ static void usage (void) + " -K, --key KEY=VALUE overrides /etc/login.defs defaults\n" + " -m, --create-home create home directory for the new user\n" + " account\n" ++ " -n, --user-group create a new group with the same name as the\n" ++ " new user\n" + " -o, --non-unique allow create user with duplicate\n" + " (non-unique) UID\n" + " -p, --password PASSWORD use encrypted password for the new user\n" +@@ -1009,6 +1017,7 @@ static void process_flags (int argc, cha + {"skel", required_argument, NULL, 'k'}, + {"key", required_argument, NULL, 'K'}, + {"create-home", no_argument, NULL, 'm'}, ++ {"user-group", no_argument, NULL, 'n'}, + {"non-unique", no_argument, NULL, 'o'}, + {"password", required_argument, NULL, 'p'}, + {"shell", required_argument, NULL, 's'}, +@@ -1016,7 +1025,7 @@ static void process_flags (int argc, cha + {NULL, 0, NULL, '\0'} + }; + while ((c = +- getopt_long (argc, argv, "b:c:d:De:f:g:G:k:K:mMop:s:u:", ++ getopt_long (argc, argv, "b:c:d:De:f:g:G:k:K:mMnop:s:u:", + long_options, NULL)) != -1) { + switch (c) { + case 'b': +@@ -1156,6 +1165,9 @@ static void process_flags (int argc, cha + case 'm': + mflg++; + break; ++ case 'n': ++ nflg = 1; ++ break; + case 'o': + oflg++; + break; +@@ -1203,6 +1215,16 @@ static void process_flags (int argc, cha + usage (); + + /* ++ * Using --gid and --user-group doesn't make sense. ++ */ ++ if (nflg == -1 && gflg) ++ nflg = 0; ++ if (nflg && gflg) { ++ fprintf (stderr, _("%s: options -g and -n conflict\n"), Prog); ++ exit (E_BAD_ARG); ++ } ++ ++ /* + * Either -D or username is required. Defaults can be set with -D + * for the -b, -e, -f, -g, -s options only. + */ +@@ -1725,7 +1747,7 @@ int main (int argc, char **argv) + * to that group, use useradd -g username username. + * --bero + */ +- if (!gflg) { ++ if (nflg) { + if (getgrnam (user_name)) { + fprintf (stderr, + _ +@@ -1759,7 +1781,7 @@ int main (int argc, char **argv) + + /* do we have to add a group for that user? This is why we need to + * open the group files in the open_files() function --gafton */ +- if (!(nflg || gflg)) { ++ if (nflg) { + find_new_gid (); + grp_add (); + } +Index: man/useradd.8.xml +=================================================================== +RCS file: /cvsroot/shadow/man/useradd.8.xml,v +retrieving revision 1.34 +diff -u -p -r1.34 useradd.8.xml +--- man/useradd.8.xml 20 May 2006 12:11:38 -0000 1.34 ++++ man/useradd.8.xml 10 Jun 2006 22:17:13 -0000 +@@ -204,6 +204,19 @@ + + + ++ , ++ ++ ++ ++ Create a new group with the same name as the new user. ++ ++ ++ See the USERGROUPS_ENAB login.defs option for more details. ++ ++ ++ ++ ++ + , + + diff --git a/shadow-friendly-selinux.patch b/shadow-friendly-selinux.patch new file mode 100644 index 0000000..403f1f8 --- /dev/null +++ b/shadow-friendly-selinux.patch @@ -0,0 +1,41 @@ +Index: configure.in +=================================================================== +RCS file: /cvsroot/shadow/configure.in,v +retrieving revision 1.150 +diff -u -p -r1.150 configure.in +--- configure.in 3 Aug 2006 10:14:05 -0000 1.150 ++++ configure.in 5 Aug 2006 18:51:34 -0000 +@@ -220,7 +220,7 @@ AC_ARG_WITH(libpam, + [with_libpam=$withval], [with_libpam=yes]) + AC_ARG_WITH(selinux, + [AC_HELP_STRING([--with-selinux], [use SELinux support @<:@default=autodetect@:>@])], +- [with_selinux=$withval], [with_selinux=yes]) ++ [with_selinux=$withval], [with_selinux=maybe]) + AC_ARG_WITH(skey, + [AC_HELP_STRING([--with-skey], [use S/Key support @<:@default=no@:>@])], + [with_skey=$withval], [with_skey=no]) +@@ -282,15 +282,21 @@ if test "$with_libcrack" = "yes"; then + AC_DEFINE(HAVE_LIBCRACK_PW, 1, [Defined if it includes *Pw functions.])) + fi + +-if test "$with_selinux" = "yes"; then ++if test "$with_selinux" != "no" ; then ++ have_selinux="yes" + AC_CHECK_LIB(selinux, is_selinux_enabled, + [LIBSELINUX="-lselinux" + AC_SUBST(LIBSELINUX) + AC_CHECK_HEADERS(selinux/selinux.h, [], +- [AC_MSG_ERROR([selinux/selinux.h is missing])]) ++ [have_selinux="no"]) + AC_DEFINE(WITH_SELINUX, 1, [Build shadow with SELinux support]) + ], +- [AC_MSG_ERROR([libselinux not found])]) ++ [have_selinux="no"]) ++ if test "x$have_selinux$with_selinux" = "xnoyes" ; then ++ AC_MSG_ERROR([selinux support not found]) ++ else ++ with_selinux="$have_selinux" ++ fi + fi + + AC_SUBST(LIBPAM) diff --git a/shadow-no-innetgr-simpler.patch b/shadow-no-innetgr-simpler.patch new file mode 100644 index 0000000..a416868 --- /dev/null +++ b/shadow-no-innetgr-simpler.patch @@ -0,0 +1,65 @@ +Index: configure.in +=================================================================== +RCS file: /cvsroot/shadow/configure.in,v +retrieving revision 1.150 +diff -u -p -r1.150 configure.in +--- configure.in 3 Aug 2006 10:14:05 -0000 1.150 ++++ configure.in 5 Aug 2006 19:21:51 -0000 +@@ -32,11 +32,11 @@ AC_HEADER_SYS_WAIT + AC_CHECK_HEADERS(errno.h fcntl.h limits.h unistd.h sys/time.h utmp.h \ + utmpx.h termios.h termio.h sgtty.h sys/ioctl.h syslog.h paths.h \ + utime.h ulimit.h sys/resource.h gshadow.h shadow.h lastlog.h \ +- locale.h rpc/key_prot.h) ++ locale.h rpc/key_prot.h netdb.h) + + AC_CHECK_FUNCS(a64l fchmod fchown fsync getgroups gethostname getspnam \ + gettimeofday getusershell getutent initgroups lchown lckpwdf lstat \ +- memcpy memset setgroups sigaction strchr updwtmp updwtmpx) ++ memcpy memset setgroups sigaction strchr updwtmp updwtmpx innetgr) + AC_SYS_LARGEFILE + + dnl Checks for typedefs, structures, and compiler characteristics. +Index: src/login_nopam.c +=================================================================== +RCS file: /cvsroot/shadow/src/login_nopam.c,v +retrieving revision 1.8 +diff -u -p -r1.8 login_nopam.c +--- src/login_nopam.c 7 Sep 2005 15:00:45 -0000 1.8 ++++ src/login_nopam.c 5 Aug 2006 19:21:51 -0000 +@@ -37,7 +37,9 @@ + #include + #include + #include ++#ifdef HAVE_NETDB_H + #include ++#endif + #include + #ifdef PRIMARY_GROUP_MATCH + #include +@@ -49,8 +51,6 @@ + #include + #include + #include /* for inet_ntoa() */ +-extern struct group *getgrnam (); +-extern int innetgr (); + + #if !defined(MAXHOSTNAMELEN) || (MAXHOSTNAMELEN < 64) + #undef MAXHOSTNAMELEN +@@ -182,6 +182,7 @@ static char *myhostname (void) + static int + netgroup_match (const char *group, const char *machine, const char *user) + { ++#ifdef HAVE_INNETGR + static char *mydomain = 0; + + if (mydomain == 0) { +@@ -192,6 +193,9 @@ netgroup_match (const char *group, const + } + + return innetgr (group, machine, user, mydomain); ++#else ++ return (NO); ++#endif + } + + /* user_match - match a username against one token */ diff --git a/shadow-no-innetgr.patch b/shadow-no-innetgr.patch new file mode 100644 index 0000000..ab41f15 --- /dev/null +++ b/shadow-no-innetgr.patch @@ -0,0 +1,88 @@ +Index: configure.in +=================================================================== +RCS file: /cvsroot/shadow/configure.in,v +retrieving revision 1.150 +diff -u -p -r1.150 configure.in +--- configure.in 3 Aug 2006 10:14:05 -0000 1.150 ++++ configure.in 5 Aug 2006 19:19:10 -0000 +@@ -32,11 +32,11 @@ AC_HEADER_SYS_WAIT + AC_CHECK_HEADERS(errno.h fcntl.h limits.h unistd.h sys/time.h utmp.h \ + utmpx.h termios.h termio.h sgtty.h sys/ioctl.h syslog.h paths.h \ + utime.h ulimit.h sys/resource.h gshadow.h shadow.h lastlog.h \ +- locale.h rpc/key_prot.h) ++ locale.h rpc/key_prot.h netdb.h) + + AC_CHECK_FUNCS(a64l fchmod fchown fsync getgroups gethostname getspnam \ + gettimeofday getusershell getutent initgroups lchown lckpwdf lstat \ +- memcpy memset setgroups sigaction strchr updwtmp updwtmpx) ++ memcpy memset setgroups sigaction strchr updwtmp updwtmpx innetgr) + AC_SYS_LARGEFILE + + dnl Checks for typedefs, structures, and compiler characteristics. +Index: src/login_nopam.c +=================================================================== +RCS file: /cvsroot/shadow/src/login_nopam.c,v +retrieving revision 1.8 +diff -u -p -r1.8 login_nopam.c +--- src/login_nopam.c 7 Sep 2005 15:00:45 -0000 1.8 ++++ src/login_nopam.c 5 Aug 2006 19:19:10 -0000 +@@ -37,7 +37,9 @@ + #include + #include + #include ++#ifdef HAVE_NETDB_H + #include ++#endif + #include + #ifdef PRIMARY_GROUP_MATCH + #include +@@ -49,8 +51,6 @@ + #include + #include + #include /* for inet_ntoa() */ +-extern struct group *getgrnam (); +-extern int innetgr (); + + #if !defined(MAXHOSTNAMELEN) || (MAXHOSTNAMELEN < 64) + #undef MAXHOSTNAMELEN +@@ -178,6 +178,7 @@ static char *myhostname (void) + return (name); + } + ++#ifdef HAVE_INNETGR + /* netgroup_match - match group against machine or user */ + static int + netgroup_match (const char *group, const char *machine, const char *user) +@@ -193,6 +194,7 @@ netgroup_match (const char *group, const + + return innetgr (group, machine, user, mydomain); + } ++#endif + + /* user_match - match a username against one token */ + static int user_match (const char *tok, const char *string) +@@ -214,8 +216,10 @@ static int user_match (const char *tok, + *at = 0; + return (user_match (tok, string) + && from_match (at + 1, myhostname ())); ++#ifdef HAVE_INNETGR + } else if (tok[0] == '@') { /* netgroup */ + return (netgroup_match (tok + 1, (char *) 0, string)); ++#endif + } else if (string_match (tok, string)) { /* ALL or exact match */ + return (YES); + } else if ((group = getgrnam (tok))) { /* try group membership */ +@@ -271,9 +275,12 @@ static int from_match (const char *tok, + * contain a "." character. If the token is a network number, return YES + * if it matches the head of the string. + */ ++#ifdef HAVE_INNETGR + if (tok[0] == '@') { /* netgroup */ + return (netgroup_match (tok + 1, string, (char *) 0)); +- } else if (string_match (tok, string)) { /* ALL or exact match */ ++ } else ++#endif ++ if (string_match (tok, string)) { /* ALL or exact match */ + return (YES); + } else if (tok[0] == '.') { /* domain: match last fields */ + if ((str_len = strlen (string)) > (tok_len = strlen (tok)) diff --git a/shadow-su-logging.patch b/shadow-su-logging.patch new file mode 100644 index 0000000..c70d51a --- /dev/null +++ b/shadow-su-logging.patch @@ -0,0 +1,14 @@ +--- src/su.c ++++ src/su.c +@@ -731,8 +731,9 @@ int main (int argc, char **argv) + endspent (); + #ifdef USE_SYSLOG + if (getdef_bool ("SYSLOG_SU_ENAB")) +- SYSLOG ((LOG_INFO, "+ %s %s:%s", tty, +- oldname[0] ? oldname : "???", name[0] ? name : "???")); ++ SYSLOG ((LOG_INFO, "+ %s %s:%s (%s)", tty, ++ oldname[0] ? oldname : "???", name[0] ? name : "???", ++ doshell ? "new shell" : command)); + #endif + + #ifdef USE_PAM diff --git a/shadow-user-friendly-man-error.patch b/shadow-user-friendly-man-error.patch new file mode 100644 index 0000000..ec390ef --- /dev/null +++ b/shadow-user-friendly-man-error.patch @@ -0,0 +1,23 @@ +Index: man/Makefile.am +=================================================================== +RCS file: /cvsroot/shadow/man/Makefile.am,v +retrieving revision 1.62 +diff -u -p -r1.62 Makefile.am +--- man/Makefile.am 5 Jun 2006 02:57:27 -0000 1.62 ++++ man/Makefile.am 10 Jun 2006 21:32:35 -0000 +@@ -240,6 +240,15 @@ vigr.8 vipw.8: vipw.8.xml + + CLEANFILES = $(man_MANS) + ++else ++ ++$(man_MANS): ++ @echo "" ++ @echo "Error: you need to run configure with '--enable-man'" ++ @echo " in order to regenerate man pages." ++ @echo "" ++ @false ++ + endif + + POFILES = $(foreach lang, $(LINGUAS), $(lang)/$(lang).po) diff --git a/shadow-useradd-no-gid-option.patch b/shadow-useradd-no-gid-option.patch new file mode 100644 index 0000000..1bbd6f1 --- /dev/null +++ b/shadow-useradd-no-gid-option.patch @@ -0,0 +1,19 @@ +2006-04-07 Mike Frysinger + + * man/useradd.8.xml: Document behavior when -g is not specified. + +--- man/useradd.8.xml ++++ man/useradd.8.xml +@@ -41,6 +41,12 @@ + will update system files and may also create the new user's home + directory and copy initial files. + ++ ++ When invoked without the option, the ++ useradd command automatically creates a new group ++ account with the same name as the new user account and sets that as ++ the user's initial login group. ++ + + + diff --git a/shadow-userdel-grammar-touchup.patch b/shadow-userdel-grammar-touchup.patch new file mode 100644 index 0000000..db28c7b --- /dev/null +++ b/shadow-userdel-grammar-touchup.patch @@ -0,0 +1,11 @@ +--- man/userdel.8.xml ++++ man/userdel.8.xml +@@ -54,7 +54,7 @@ + group of another user. + + +- Note: This option is dangerous and may let ++ Note: This option is dangerous and may leave + your system in an inconsistent state. + + diff --git a/sqlite-cross-compile.patch b/sqlite-cross-compile.patch new file mode 100644 index 0000000..99177e7 --- /dev/null +++ b/sqlite-cross-compile.patch @@ -0,0 +1,223 @@ +Index: configure.ac +=================================================================== +RCS file: /sqlite/sqlite/configure.ac,v +retrieving revision 1.26 +diff -u -p -r1.26 configure.ac +--- configure.ac 3 Jun 2006 18:02:18 -0000 1.26 ++++ configure.ac 16 Feb 2007 23:53:20 -0000 +@@ -45,18 +45,6 @@ + # The filename extension for executables on the build + # platform. "" for Unix and ".exe" for Windows. + # +-# TARGET_CC +-# +-# The name of a command that runs on the build platform +-# and converts C source files into *.o files for the +-# target platform. In other words, the cross-compiler. +-# +-# TARGET_CFLAGS +-# +-# Switches that the target compiler needs to turn C source files +-# into *.o files. Do not include TARGET_TCL_INC in this list. +-# Makefiles might add additional switches such as "-I.". +-# + # TCL_* + # + # Lots of values are read in from the tclConfig.sh script, +@@ -76,18 +64,6 @@ + # files for the readline library. If the compiler is able + # to find on its own, then this can be blank. + # +-# TARGET_LINK +-# +-# The name of the linker that combines *.o files generated +-# by TARGET_CC into executables for the target platform. +-# +-# TARGET_LIBS +-# +-# Additional libraries or other switch that the target linker needs +-# to build an executable on the target. Do not include +-# on this list any libraries in TARGET_TCL_LIBS and +-# TARGET_READLINE_LIBS, etc. +-# + # TARGET_EXEEXT + # + # The filename extension for executables on the +@@ -184,96 +160,19 @@ fi + # Locate a compiler for the build machine. This compiler should + # generate command-line programs that run on the build machine. + # +-default_build_cflags="-g" +-if test "$config_BUILD_CC" = ""; then +- AC_PROG_CC +- if test "$cross_compiling" = "yes"; then +- AC_MSG_ERROR([unable to find a compiler for building build tools]) +- fi +- BUILD_CC=$CC +- default_build_cflags=$CFLAGS +-else +- BUILD_CC=$config_BUILD_CC +- AC_MSG_CHECKING([host compiler]) +- CC=$BUILD_CC +- AC_MSG_RESULT($BUILD_CC) +-fi +-AC_MSG_CHECKING([switches for the host compiler]) +-if test "$config_BUILD_CFLAGS" != ""; then +- CFLAGS=$config_BUILD_CFLAGS +- BUILD_CFLAGS=$config_BUILD_CFLAGS +-else +- BUILD_CFLAGS=$default_build_cflags +-fi +-AC_MSG_RESULT($BUILD_CFLAGS) +-if test "$config_BUILD_LIBS" != ""; then +- BUILD_LIBS=$config_BUILD_LIBS ++if test x"$cross_compiling" = xno; then ++ BUILD_CC=$CC ++ BUILD_CFLAGS=$CFLAGS ++else ++ if test "${BUILD_CC+set}" != set; then ++ AC_CHECK_PROGS(BUILD_CC, gcc cc cl) ++ fi ++ if test "${BUILD_CFLAGS+set}" != set; then ++ BUILD_CFLAGS="-g" ++ fi + fi + AC_SUBST(BUILD_CC) + AC_SUBST(BUILD_CFLAGS) +-AC_SUBST(BUILD_LIBS) +- +-########## +-# Locate a compiler that converts C code into *.o files that run on +-# the target machine. +-# +-AC_MSG_CHECKING([target compiler]) +-if test "$config_TARGET_CC" != ""; then +- TARGET_CC=$config_TARGET_CC +-else +- TARGET_CC=$BUILD_CC +-fi +-AC_MSG_RESULT($TARGET_CC) +-AC_MSG_CHECKING([switches on the target compiler]) +-if test "$config_TARGET_CFLAGS" != ""; then +- TARGET_CFLAGS=$config_TARGET_CFLAGS +-else +- TARGET_CFLAGS=$BUILD_CFLAGS +-fi +-AC_MSG_RESULT($TARGET_CFLAGS) +-AC_MSG_CHECKING([target linker]) +-if test "$config_TARGET_LINK" = ""; then +- TARGET_LINK=$TARGET_CC +-else +- TARGET_LINK=$config_TARGET_LINK +-fi +-AC_MSG_RESULT($TARGET_LINK) +-AC_MSG_CHECKING([switches on the target compiler]) +-if test "$config_TARGET_TFLAGS" != ""; then +- TARGET_TFLAGS=$config_TARGET_TFLAGS +-else +- TARGET_TFLAGS=$BUILD_CFLAGS +-fi +-if test "$config_TARGET_RANLIB" != ""; then +- TARGET_RANLIB=$config_TARGET_RANLIB +-else +- AC_PROG_RANLIB +- TARGET_RANLIB=$RANLIB +-fi +-if test "$config_TARGET_AR" != ""; then +- TARGET_AR=$config_TARGET_AR +-else +- TARGET_AR='ar cr' +-fi +-AC_MSG_RESULT($TARGET_TFLAGS) +-AC_SUBST(TARGET_CC) +-AC_SUBST(TARGET_CFLAGS) +-AC_SUBST(TARGET_LINK) +-AC_SUBST(TARGET_LFLAGS) +-AC_SUBST(TARGET_RANLIB) +-AC_SUBST(TARGET_AR) +- +-# Set the $cross variable if we are cross-compiling. Make +-# it 0 if we are not. +-# +-AC_MSG_CHECKING([if host and target compilers are the same]) +-if test "$BUILD_CC" = "$TARGET_CC"; then +- cross=0 +- AC_MSG_RESULT(yes) +-else +- cross=1 +- AC_MSG_RESULT(no) +-fi + + ########## + # Do we want to support multithreaded use of sqlite +@@ -401,7 +300,7 @@ if test "$CYGWIN" = "yes"; then + else + BUILD_EXEEXT=$EXEEXT + fi +-if test "$cross" = "0"; then ++if test x"$cross_compiling" = xno; then + TARGET_EXEEXT=$BUILD_EXEEXT + else + TARGET_EXEEXT=$config_TARGET_EXEEXT +@@ -438,15 +337,6 @@ AC_SUBST(OS_OS2) + AC_SUBST(TARGET_EXEEXT) + + ########## +-# Extract generic linker options from the environment. +-# +-if test "$config_TARGET_LIBS" != ""; then +- TARGET_LIBS=$config_TARGET_LIBS +-else +- TARGET_LIBS="" +-fi +- +-########## + # Figure out all the parameters needed to compile against Tcl. + # + # This code is derived from the SC_PATH_TCLCONFIG and SC_LOAD_TCLCONFIG +@@ -676,11 +574,6 @@ AC_CHECK_FUNC(usleep, [TARGET_CFLAGS="$T + AC_CHECK_FUNC(fdatasync, [TARGET_CFLAGS="$TARGET_CFLAGS -DHAVE_FDATASYNC=1"]) + + ######### +-# Put out accumulated miscellaneous LIBRARIES +-# +-AC_SUBST(TARGET_LIBS) +- +-######### + # Generate the output files. + # + AC_OUTPUT([ +Index: Makefile.in +=================================================================== +RCS file: /sqlite/sqlite/Makefile.in,v +retrieving revision 1.162 +diff -u -p -r1.162 Makefile.in +--- Makefile.in 8 Jan 2007 13:40:36 -0000 1.162 ++++ Makefile.in 16 Feb 2007 23:53:21 -0000 +@@ -26,7 +26,7 @@ BCC = @BUILD_CC@ @BUILD_CFLAGS@ + # will run on the target platform. (BCC and TCC are usually the + # same unless your are cross-compiling.) + # +-TCC = @TARGET_CC@ @TARGET_CFLAGS@ -I. -I${TOP}/src ++TCC = @CC@ @CFLAGS@ -I. -I${TOP}/src + + # Define -DNDEBUG to compile without debugging (i.e., for production usage) + # Omitting the define will cause extra debugging code to be inserted and +@@ -63,7 +63,7 @@ LIBPTHREAD=@TARGET_THREAD_LIB@ + TCC += -DSQLITE_THREAD_OVERRIDE_LOCK=@THREADSOVERRIDELOCKS@ + + # The fdatasync library +-TLIBS = @TARGET_LIBS@ ++TLIBS = @LIBS@ + + # Flags controlling use of the in memory btree implementation + # +@@ -107,7 +107,7 @@ LIBTOOL = ./libtool + ALLOWRELEASE = @ALLOWRELEASE@ + + # libtool compile/link/install +-LTCOMPILE = $(LIBTOOL) --mode=compile $(TCC) ++LTCOMPILE = $(LIBTOOL) --mode=compile --tag=CC $(TCC) + LTLINK = $(LIBTOOL) --mode=link $(TCC) + LTINSTALL = $(LIBTOOL) --mode=install $(INSTALL) + diff --git a/sqlite-readline.patch b/sqlite-readline.patch new file mode 100644 index 0000000..45cad8d --- /dev/null +++ b/sqlite-readline.patch @@ -0,0 +1,132 @@ +Index: configure.ac +=================================================================== +RCS file: /sqlite/sqlite/configure.ac,v +retrieving revision 1.26 +diff -u -p -r1.26 configure.ac +--- configure.ac 3 Jun 2006 18:02:18 -0000 1.26 ++++ configure.ac 16 Feb 2007 23:31:32 -0000 +@@ -592,16 +592,68 @@ AC_SUBST(HAVE_TCL) + # Figure out what C libraries are required to compile programs + # that use "readline()" library. + # +-if test "$config_TARGET_READLINE_LIBS" != ""; then +- TARGET_READLINE_LIBS="$config_TARGET_READLINE_LIBS" +-else +- CC=$TARGET_CC +- LIBS="" +- AC_SEARCH_LIBS(tgetent, [readline ncurses curses termcap]) +- AC_CHECK_LIB([readline], [readline]) +- TARGET_READLINE_LIBS="$LIBS" ++TARGET_READLINE_LIBS="" ++TARGET_READLINE_INC="" ++TARGET_HAVE_READLINE=0 ++AC_ARG_ENABLE([readline], ++ [AC_HELP_STRING([--disable-readline],[disable readline support [default=detect]])], ++ [with_readline=$enableval], ++ [with_readline=auto]) ++ ++if test x"$with_readline" != xno; then ++ found="yes" ++ ++ AC_ARG_WITH([readline-lib], ++ [AC_HELP_STRING([--with-readline-lib],[specify readline library])], ++ [with_readline_lib=$withval], ++ [with_readline_lib="auto"]) ++ if test "x$with_readline_lib" = xauto; then ++ save_LIBS="$LIBS" ++ LIBS="" ++ AC_SEARCH_LIBS(tgetent, [readline ncurses curses termcap], [term_LIBS="$LIBS"], [term_LIBS=""]) ++ AC_CHECK_LIB([readline], [readline], [TARGET_READLINE_LIBS="-lreadline"], [found="no"]) ++ TARGET_READLINE_LIBS="$TARGET_READLINE_LIBS $term_LIBS" ++ LIBS="$save_LIBS" ++ else ++ TARGET_READLINE_LIBS="$with_readline_lib" ++ fi ++ ++ AC_ARG_WITH([readline-inc], ++ [AC_HELP_STRING([--with-readline-inc],[specify readline include paths])], ++ [with_readline_inc=$withval], ++ [with_readline_inc="auto"]) ++ if test "x$with_readline_inc" = xauto; then ++ AC_CHECK_HEADER(readline.h, [found="yes"], [ ++ found="no" ++ if test "$cross_compiling" != yes; then ++ for dir in /usr /usr/local /usr/local/readline /usr/contrib /mingw; do ++ for subdir in include include/readline; do ++ AC_CHECK_FILE($dir/$subdir/readline.h, found=yes) ++ if test "$found" = "yes"; then ++ TARGET_READLINE_INC="-I$dir/$subdir" ++ break ++ fi ++ done ++ test "$found" = "yes" && break ++ done ++ fi ++ ]) ++ else ++ TARGET_READLINE_INC="$with_readline_inc" ++ fi ++ ++ if test x"$found" = xno; then ++ TARGET_READLINE_LIBS="" ++ TARGET_READLINE_INC="" ++ TARGET_HAVE_READLINE=0 ++ else ++ TARGET_HAVE_READLINE=1 ++ fi + fi ++ + AC_SUBST(TARGET_READLINE_LIBS) ++AC_SUBST(TARGET_READLINE_INC) ++AC_SUBST(TARGET_HAVE_READLINE) + + ########## + # Figure out what C libraries are required to compile programs +@@ -612,47 +664,6 @@ LIBS=$TARGET_LIBS + AC_SEARCH_LIBS(fdatasync, [rt]) + TARGET_LIBS="$LIBS" + +-########## +-# Figure out where to get the READLINE header files. +-# +-AC_MSG_CHECKING([readline header files]) +-found=no +-if test "$config_TARGET_READLINE_INC" != ""; then +- TARGET_READLINE_INC=$config_TARGET_READLINE_INC +- found=yes +-fi +-if test "$found" = "yes"; then +- AC_MSG_RESULT($TARGET_READLINE_INC) +-else +- AC_MSG_RESULT(not specified: still searching...) +- AC_CHECK_HEADER(readline.h, [found=yes]) +-fi +-if test "$found" = "no"; then +- for dir in /usr /usr/local /usr/local/readline /usr/contrib /mingw; do +- AC_CHECK_FILE($dir/include/readline.h, found=yes) +- if test "$found" = "yes"; then +- TARGET_READLINE_INC="-I$dir/include" +- break +- fi +- AC_CHECK_FILE($dir/include/readline/readline.h, found=yes) +- if test "$found" = "yes"; then +- TARGET_READLINE_INC="-I$dir/include/readline" +- break +- fi +- done +-fi +-if test "$found" = "yes"; then +- if test "$TARGET_READLINE_LIBS" = ""; then +- TARGET_HAVE_READLINE=0 +- else +- TARGET_HAVE_READLINE=1 +- fi +-else +- TARGET_HAVE_READLINE=0 +-fi +-AC_SUBST(TARGET_READLINE_INC) +-AC_SUBST(TARGET_HAVE_READLINE) +- + ######### + # check for debug enabled + AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug],[enable debugging & verbose explain]), diff --git a/sysklogd-1.4.1-accept.patch b/sysklogd-1.4.1-accept.patch new file mode 100644 index 0000000..e01cdd0 --- /dev/null +++ b/sysklogd-1.4.1-accept.patch @@ -0,0 +1,13 @@ +accept/recvfrom take pointers to socklen_t's + +--- syslogd.c ++++ syslogd.c +@@ -841,7 +841,7 @@ + int len, num_fds; + #else /* __GLIBC__ */ + #ifndef TESTING +- size_t len; ++ socklen_t len; + #endif + int num_fds; + #endif /* __GLIBC__ */ diff --git a/syslinux-3.36-nopie.patch b/syslinux-3.36-nopie.patch new file mode 100644 index 0000000..e952232 --- /dev/null +++ b/syslinux-3.36-nopie.patch @@ -0,0 +1,27 @@ +diff -ur syslinux-3.36.old/com32/libutil/Makefile syslinux-3.36/com32/libutil/Makefile +--- syslinux-3.36.old/com32/libutil/Makefile 2007-02-10 20:47:08.000000000 +0000 ++++ syslinux-3.36/com32/libutil/Makefile 2007-02-11 07:27:16.000000000 +0000 +@@ -32,7 +32,7 @@ + gcc_ok = $(shell if gcc $(1) -c -x c /dev/null -o /dev/null 2>/dev/null; \ + then echo $(1); else echo $(2); fi) + +-M32 := $(call gcc_ok,-m32,) $(call gcc_ok,-fno-stack-protector,) ++M32 := $(call gcc_ok,-m32,) $(call gcc_ok,-fno-stack-protector,) $(call gcc_ok,-nopie,) $(call gcc_ok,-no-pie,) + + CC = gcc + LD = ld -m elf_i386 +diff -ur syslinux-3.36.old/dos/Makefile syslinux-3.36/dos/Makefile +--- syslinux-3.36.old/dos/Makefile 2007-02-10 20:47:08.000000000 +0000 ++++ syslinux-3.36/dos/Makefile 2007-02-11 07:30:23.000000000 +0000 +@@ -1,7 +1,10 @@ + gcc_ok = $(shell if gcc $(1) -c -x c /dev/null -o /dev/null 2>/dev/null; \ + then echo $(1); else echo $(2); fi) + +-M32 := $(call gcc_ok,-m32,) $(call gcc_ok,-ffreestanding,) $(call gcc_ok,-fno-stack-protector,) ++M32 := $(call gcc_ok,-m32,) \ ++ $(call gcc_ok,-ffreestanding,) \ ++ $(call gcc_ok,-fno-stack-protector,) \ ++ $(call gcc_ok,-nopie,) $(call gcc_ok,-no-pie,) + + CC = gcc + LD = ld -m elf_i386 diff --git a/telnetd-ptmx.patch b/telnetd-ptmx.patch new file mode 100644 index 0000000..daf51ff --- /dev/null +++ b/telnetd-ptmx.patch @@ -0,0 +1,44 @@ +Index: user/telnetd/sys_term.c +=================================================================== +RCS file: /usr/local/src/blackfin/rsync/uclinux533/uClinux-dist/user/telnetd/sys_term.c,v +retrieving revision 1.2 +diff -u -p -r1.2 sys_term.c +--- user/telnetd/sys_term.c 25 Jul 2005 06:44:04 -0000 1.2 ++++ user/telnetd/sys_term.c 9 Sep 2006 03:36:52 -0000 +@@ -453,6 +453,27 @@ int getpty(void) { + int p; + #ifndef CRAY + ++#ifdef USE_PTMX ++ char *pts; ++ int ptm = open("/dev/ptmx", O_RDWR | O_NOCTTY); ++ if (ptm < 0) ++ fatalperror(net, "Could not open /dev/ptmx"); ++ if (grantpt(ptm) < 0) ++ fatalperror(net, "Could not grantpt(/dev/ptmx)"); ++ if (unlockpt(ptm) < 0) ++ fatalperror(net, "Could not unlockpt(/dev/ptmx)"); ++ pts = ptsname(ptm); ++ if (pts == NULL) ++ fatalperror(net, "Could not get ptsname()"); ++ free(line); ++ line = strdup(pts); ++ ptyslavefd = open(pts, O_RDWR | O_NOCTTY); ++ if (ptyslavefd < 0) ++ fatalperror(net, "Could not open slave pty"); ++ ++ return ptm; ++#else ++ + #ifndef DEVFS + char *p1, *p2; + int i,j; +@@ -502,6 +523,8 @@ int getpty(void) { + + #endif /* DEVFS */ + ++#endif /* PTMX */ ++ + #else /* CRAY */ + int npty; + extern lowpty, highpty; diff --git a/tftp-hpa-0.45-parallel.patch b/tftp-hpa-0.45-parallel.patch new file mode 100644 index 0000000..5cda045 --- /dev/null +++ b/tftp-hpa-0.45-parallel.patch @@ -0,0 +1,13 @@ +--- Makefile ++++ Makefile +@@ -17,8 +17,8 @@ + + all: MCONFIG $(patsubst %, %.build, $(SUB)) + +-tftp.build: lib.build +-tftpd.build: lib.build ++tftp.build: lib.build common.build ++tftpd.build: lib.build common.build + + install: MCONFIG $(patsubst %, %.install, $(SUB)) + diff --git a/thread_stack.patch b/thread_stack.patch new file mode 100644 index 0000000..6e53684 --- /dev/null +++ b/thread_stack.patch @@ -0,0 +1,26 @@ +--- threads.c.orig 2007-05-16 13:59:44.000000000 +0800 ++++ threads.c 2007-05-08 16:23:31.000000000 +0800 +@@ -524,6 +524,8 @@ + { + int i_ret; + void *p_data = (void *)p_this; ++ pthread_attr_t th_attr; ++ size_t th_size = 0; + + vlc_mutex_lock( &p_this->object_lock ); + +@@ -569,7 +571,13 @@ + i_ret = resume_thread( p_this->thread_id ); + + #elif defined( PTHREAD_COND_T_IN_PTHREAD_H ) +- i_ret = pthread_create( &p_this->thread_id, NULL, func, p_data ); ++ ++ pthread_attr_init(&th_attr); ++ pthread_attr_getstacksize(&th_attr, &th_size); ++ printf("vlc: default stack size: %d\n", th_size); ++ th_size = 65536; ++ pthread_attr_setstacksize(&th_attr, th_size); ++ i_ret = pthread_create( &p_this->thread_id, &th_attr, func, p_data ); + + #ifndef __APPLE__ + if( config_GetInt( p_this, "rt-priority" ) ) diff --git a/trylinkbug.diff b/trylinkbug.diff new file mode 100644 index 0000000..a6567f8 --- /dev/null +++ b/trylinkbug.diff @@ -0,0 +1,90 @@ +--- trylink 2007-11-24 05:31:28.000000000 +0100 ++++ trylink2 2007-11-10 02:40:48.000000000 +0100 +@@ -46,14 +46,6 @@ + return $exitcode + } + +-check_cc() { +- if $CC $1 -shared -o /dev/null -xc /dev/null > /dev/null 2>&1; then +- echo "$1"; +- else +- echo "$2"; +- fi +-} +- + EXE="$1" + CC="$2" + LDFLAGS="$3" +@@ -61,9 +53,6 @@ + A_FILES="$5" + LDLIBS="$6" + +-# The -Wl,--sort-section option is not supported by older versions of ld +-SORT_SECTION=`check_cc "-Wl,--sort-section -Wl,alignment" ""` +- + # Sanitize lib list (dups, extra spaces etc) + LDLIBS=`echo "$LDLIBS" | xargs -n1 | sort | uniq | xargs` + +@@ -75,7 +64,7 @@ + try $CC $LDFLAGS \ + -o $EXE \ + -Wl,--sort-common \ +- $SORT_SECTION \ ++ -Wl,--sort-section -Wl,alignment \ + -Wl,--gc-sections \ + -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \ + $l_list \ +@@ -99,7 +88,7 @@ + try $CC $LDFLAGS \ + -o $EXE \ + -Wl,--sort-common \ +- $SORT_SECTION \ ++ -Wl,--sort-section -Wl,alignment \ + -Wl,--gc-sections \ + -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \ + $l_list +@@ -128,7 +117,7 @@ + try $CC $LDFLAGS \ + -o $EXE \ + -Wl,--sort-common \ +- $SORT_SECTION \ ++ -Wl,--sort-section -Wl,alignment \ + -Wl,--gc-sections \ + -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \ + $l_list \ +@@ -150,7 +139,7 @@ + try $CC $LDFLAGS \ + -o $EXE \ + -Wl,--sort-common \ +- $SORT_SECTION \ ++ -Wl,--sort-section -Wl,alignment \ + -Wl,--gc-sections \ + -Wl,-T -Wl,busybox_ldscript \ + -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \ +@@ -185,7 +174,7 @@ + -Wl,-soname="libbusybox.so.$BB_VER" \ + -Wl,--undefined=lbb_main \ + -Wl,--sort-common \ +- $SORT_SECTION \ ++ -Wl,--sort-section -Wl,alignment \ + -Wl,--start-group $A_FILES -Wl,--end-group \ + $l_list \ + -Wl,--warn-common \ +@@ -206,7 +195,7 @@ + try $CC $LDFLAGS \ + -o $EXE \ + -Wl,--sort-common \ +- $SORT_SECTION \ ++ -Wl,--sort-section -Wl,alignment \ + -Wl,--gc-sections \ + -Wl,--start-group $O_FILES -Wl,--end-group \ + -L"$sharedlib_dir" -lbusybox \ +@@ -245,7 +234,7 @@ + try $CC $LDFLAGS "$sharedlib_dir/applet.c" \ + -o $EXE \ + -Wl,--sort-common \ +- $SORT_SECTION \ ++ -Wl,--sort-section -Wl,alignment \ + -Wl,--gc-sections \ + -L"$sharedlib_dir" -lbusybox \ + -Wl,--warn-common \ diff --git a/u-boot-MAKEALL-size.patch b/u-boot-MAKEALL-size.patch new file mode 100644 index 0000000..5434314 --- /dev/null +++ b/u-boot-MAKEALL-size.patch @@ -0,0 +1,13 @@ +diff --git a/MAKEALL b/MAKEALL +index a9969a3..2ef75e9 100755 +--- a/MAKEALL ++++ b/MAKEALL +@@ -339,7 +339,7 @@ build_target() { + ${MAKE} ${JOBS} all 2>&1 >${LOG_DIR}/$target.MAKELOG \ + | tee ${LOG_DIR}/$target.ERR + +- ${CROSS_COMPILE:-ppc_8xx-}size ${BUILD_DIR}/u-boot \ ++ ${CROSS_COMPILE}size ${BUILD_DIR}/u-boot \ + | tee -a ${LOG_DIR}/$target.MAKELOG + } + diff --git a/u-boot-cpp-linker-script.patch b/u-boot-cpp-linker-script.patch new file mode 100644 index 0000000..c891b59 --- /dev/null +++ b/u-boot-cpp-linker-script.patch @@ -0,0 +1,268 @@ +Index: config.mk +=================================================================== +--- config.mk (revision 608) ++++ config.mk (working copy) +@@ -182,7 +182,7 @@ + + AFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS) + +-LDFLAGS += -Bstatic -T $(LDSCRIPT) -Ttext $(TEXT_BASE) $(PLATFORM_LDFLAGS) ++LDFLAGS += -Bstatic -T $(LDSCRIPT) $(PLATFORM_LDFLAGS) + + # Location of a usable BFD library, where we define "usable" as + # "built for ${HOST}, supports ${TARGET}". Sensible values are +Index: Makefile +=================================================================== +--- Makefile (revision 608) ++++ Makefile (working copy) +@@ -2299,6 +2299,7 @@ + rm -f $(obj)tools/env/fw_printenv $(obj)tools/env/fw_setenv + rm -f $(obj)tools/bin2ldr/app.bin $(obj)tools/bin2ldr/app.hex $(obj)tools/bin2ldr/app.ldr + rm -f $(obj)tools/bin2ldr/init_sdram* $(obj)tools/bin2ldr/jump $(obj)tools/bin2ldr/bin2ldr ++ rm -f $(obj)board/bf*/u-boot.lds + rm -f $(obj)board/cray/L1/bootscript.c $(obj)board/cray/L1/bootscript.image + rm -f $(obj)board/netstar/eeprom $(obj)board/netstar/crcek $(obj)board/netstar/crcit + rm -f $(obj)board/netstar/*.srec $(obj)board/netstar/*.bin +Index: board/bf537-stamp/u-boot.lds +=================================================================== +--- board/bf537-stamp/u-boot.lds (revision 608) ++++ board/bf537-stamp/u-boot.lds (working copy) +@@ -1,188 +0,0 @@ +-/* +- * U-boot - u-boot.lds +- * +- * Copyright (c) 2005 blackfin.uclinux.org +- * +- * (C) Copyright 2000-2004 +- * Wolfgang Denk, DENX Software Engineering, wd@denx.de. +- * +- * See file CREDITS for list of people who contributed to this +- * project. +- * +- * This program is free software; you can redistribute it and/or +- * modify it under the terms of the GNU General Public License as +- * published by the Free Software Foundation; either version 2 of +- * the License, or (at your option) any later version. +- * +- * This program is distributed in the hope that it will be useful, +- * but WITHOUT 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 +- */ +- +-OUTPUT_ARCH(bfin) +-SEARCH_DIR(/lib); SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/local/lib); +-/* Do we need any of these for elf? +- __DYNAMIC = 0; */ +-MEMORY +- { +- ram : ORIGIN = 0x03FC0000, LENGTH = (256 * 1024) +- l1_code : ORIGIN = 0xFFA00000, LENGTH = 0xC000 +- l1_data : ORIGIN = 0xFF900000, LENGTH = 0x4000 +- } +- +-SECTIONS +-{ +- /* Read-only sections, merged into text segment: */ +- . = + SIZEOF_HEADERS; /*0x1000;*/ +- .interp : { *(.interp) } +- .hash : { *(.hash) } +- .dynsym : { *(.dynsym) } +- .dynstr : { *(.dynstr) } +- .rel.text : { *(.rel.text) } +- .rela.text : { *(.rela.text) } +- .rel.data : { *(.rel.data) } +- .rela.data : { *(.rela.data) } +- .rel.rodata : { *(.rel.rodata) } +- .rela.rodata : { *(.rela.rodata) } +- .rel.got : { *(.rel.got) } +- .rela.got : { *(.rela.got) } +- .rel.ctors : { *(.rel.ctors) } +- .rela.ctors : { *(.rela.ctors) } +- .rel.dtors : { *(.rel.dtors) } +- .rela.dtors : { *(.rela.dtors) } +- .rel.bss : { *(.rel.bss) } +- .rela.bss : { *(.rela.bss) } +- .rel.plt : { *(.rel.plt) } +- .rela.plt : { *(.rela.plt) } +- .init : { *(.init) } +- .plt : { *(.plt) } +- .text : +- { +- /* WARNING - the following is hand-optimized to fit within */ +- /* the sector before the environment sector. If it throws */ +- /* an error during compilation remove an object here to get */ +- /* it linked after the configuration sector. */ +- +- cpu/bf537/start.o (.text) +- cpu/bf537/start1.o (.text) +- cpu/bf537/traps.o (.text) +- cpu/bf537/interrupt.o (.text) +- cpu/bf537/serial.o (.text) +- common/dlmalloc.o (.text) +-/* lib_blackfin/bf533_string.o (.text) */ +-/* lib_generic/vsprintf.o (.text) */ +- lib_generic/crc32.o (.text) +- lib_generic/zlib.o (.text) +-/* board/bf537-stamp/bf537-stamp.o (.text) */ +- +- . = DEFINED(env_offset) ? env_offset : .; +- common/environment.o (.text) +- +- *(EXCLUDE_FILE (board/bf537-stamp/post-memory.o) .text) +- *(.fixup) +- *(.got1) +- } > ram +- _etext = .; +- PROVIDE (etext = .); +- .text_l1 : +- { +- . = ALIGN(4) ; +- _text_l1 = .; +- PROVIDE (text_l1 = .); +- board/bf537-stamp/post-memory.o (.text) +- . = ALIGN(4) ; +- _etext_l1 = .; +- PROVIDE (etext_l1 = .); +- } > l1_code AT > ram +- +- .rodata : +- { +- . = ALIGN(4); +- *(EXCLUDE_FILE (board/bf537-stamp/post-memory.o) .rodata) +- *(EXCLUDE_FILE (board/bf537-stamp/post-memory.o) .rodata1) +- *(EXCLUDE_FILE (board/bf537-stamp/post-memory.o) .rodata.str1.4) +- *(.eh_frame) +- . = ALIGN(4); +- } > ram +- +- . = ALIGN(4); +- _erodata = .; +- PROVIDE (erodata = .); +- .rodata_l1 : +- { +- . = ALIGN(4) ; +- _rodata_l1 = .; +- PROVIDE (rodata_l1 = .); +- board/bf537-stamp/post-memory.o (.rodata) +- board/bf537-stamp/post-memory.o (.rodata1) +- board/bf537-stamp/post-memory.o (.rodata.str1.4) +- . = ALIGN(4) ; +- _erodata_l1 = .; +- PROVIDE(erodata_l1 = .); +- } > l1_data AT > ram +- +- .fini : { *(.fini) } =0 +- .ctors : { *(.ctors) } +- .dtors : { *(.dtors) } +- +- /* Read-write section, merged into data segment: */ +- . = (. + 0x00FF) & 0xFFFFFF00; +- _erotext = .; +- PROVIDE (erotext = .); +- .reloc : +- { +- *(.got) +- _GOT2_TABLE_ = .; +- *(.got2) +- _FIXUP_TABLE_ = .; +- *(.fixup) +- } +- __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2; +- __fixup_entries = (. - _FIXUP_TABLE_)>>2; +- +- .data : +- { +- *(.data) +- *(.data1) +- *(.sdata) +- *(.sdata2) +- *(.dynamic) +- CONSTRUCTORS +- } > ram +- _edata = .; +- PROVIDE (edata = .); +- +- ___u_boot_cmd_start = .; +- .u_boot_cmd : { *(.u_boot_cmd) } > ram +- ___u_boot_cmd_end = .; +- +- +- __start___ex_table = .; +- __ex_table : { *(__ex_table) } +- __stop___ex_table = .; +- +- . = ALIGN(256); +- __init_begin = .; +- .text.init : { *(.text.init) } +- .data.init : { *(.data.init) } +- . = ALIGN(256); +- __init_end = .; +- +- .bss : +- { +- __bss_start = .; +- *(.sbss) *(.scommon) +- *(.dynbss) +- *(.bss) +- *(COMMON) +- } > ram +- _end = . ; +- PROVIDE (end = .); +-} +- +Index: board/bf537-stamp/u-boot.lds.S +=================================================================== +--- board/bf537-stamp/u-boot.lds.S (revision 608) ++++ board/bf537-stamp/u-boot.lds.S (working copy) +@@ -25,6 +25,8 @@ + * MA 02111-1307 USA + */ + ++#include ++ + OUTPUT_ARCH(bfin) + SEARCH_DIR(/lib); SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/local/lib); + /* Do we need any of these for elf? +@@ -62,6 +64,7 @@ + .rela.plt : { *(.rela.plt) } + .init : { *(.init) } + .plt : { *(.plt) } ++ . = CFG_MONITOR_BASE; + .text : + { + /* WARNING - the following is hand-optimized to fit within */ +Index: board/bf537-stamp/config.mk +=================================================================== +--- board/bf537-stamp/config.mk (revision 608) ++++ board/bf537-stamp/config.mk (working copy) +@@ -21,4 +21,4 @@ + # MA 02111-1307 USA + # + +-TEXT_BASE = 0x03FC0000 ++TEXT_BASE = do-not-use-me +Index: board/bf537-stamp/Makefile +=================================================================== +--- board/bf537-stamp/Makefile (revision 608) ++++ board/bf537-stamp/Makefile (working copy) +@@ -31,9 +31,13 @@ + + OBJS = $(BOARD).o flash.o ether_bf537.o post-memory.o stm_m25p64.o cmd_bf537led.o nand.o + +-$(LIB): .depend $(OBJS) ++$(LIB): .depend $(OBJS) u-boot.lds + $(AR) cr $@ $(OBJS) + ++u-boot.lds: u-boot.lds.S ++ $(CPP) $(CPPFLAGS) -P -Ubfin $^ > $@.tmp ++ mv -f $@.tmp $@ ++ + ######################################################################### + + .depend: Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c) diff --git a/u-boot-envcrc-export.patch b/u-boot-envcrc-export.patch new file mode 100644 index 0000000..86720fb --- /dev/null +++ b/u-boot-envcrc-export.patch @@ -0,0 +1,74 @@ +Index: common/environment.c +=================================================================== +--- common/environment.c (revision 950) ++++ common/environment.c (working copy) +@@ -44,7 +44,7 @@ + * Generate embedded environment table + * inside U-Boot image, if needed. + */ +-#if defined(ENV_IS_EMBEDDED) ++#if defined(ENV_IS_EMBEDDED) || (defined(ENV_IS_EMBEDDED_CUSTOM) && defined(USE_HOSTCC)) + /* + * Only put the environment in it's own section when we are building + * U-Boot proper. The host based program "tools/envcrc" does not need +Index: tools/envcrc.c +=================================================================== +--- tools/envcrc.c (revision 950) ++++ tools/envcrc.c (working copy) +@@ -23,6 +23,7 @@ + + #include + #include ++#include + #include + + #ifndef __ASSEMBLY__ +@@ -68,14 +69,14 @@ + + extern unsigned long crc32 (unsigned long, const unsigned char *, unsigned int); + +-#ifdef ENV_IS_EMBEDDED ++#if defined(ENV_IS_EMBEDDED) || defined(ENV_IS_EMBEDDED_CUSTOM) + extern unsigned int env_size; + extern unsigned char environment; + #endif /* ENV_IS_EMBEDDED */ + + int main (int argc, char **argv) + { +-#ifdef ENV_IS_EMBEDDED ++#if defined(ENV_IS_EMBEDDED) || defined(ENV_IS_EMBEDDED_CUSTOM) + int crc; + unsigned char *envptr = &environment, + *dataptr = envptr + ENV_HEADER_SIZE; +@@ -85,10 +86,27 @@ int main (int argc, char **argv) + + /* Check if verbose mode is activated passing a parameter to the program */ + if (argc > 1) { +- printf ("CRC32 from offset %08X to %08X of environment = %08X\n", +- (unsigned int) (dataptr - envptr), +- (unsigned int) (dataptr - envptr) + datasize, +- crc); ++ if (!strcmp(argv[1], "--binary")) { ++ int le = (argc > 2 ? !strcmp(argv[2], "le") : 1); ++ size_t i, start, end, step; ++ if (le) { ++ start = 0; ++ end = ENV_HEADER_SIZE; ++ step = 1; ++ } else { ++ start = ENV_HEADER_SIZE - 1; ++ end = -1; ++ step = -1; ++ } ++ for (i = start; i != end; i += step) ++ printf ("%c", (crc & (0xFF << (i * 8))) >> (i * 8)); ++ fwrite (dataptr, 1, datasize, stdout); ++ } else { ++ printf ("CRC32 from offset %08X to %08X of environment = %08X\n", ++ (unsigned int) (dataptr - envptr), ++ (unsigned int) (dataptr - envptr) + datasize, ++ crc); ++ } + } else { + printf ("0x%08X\n", crc); + } diff --git a/u-boot-init-rts.patch b/u-boot-init-rts.patch new file mode 100644 index 0000000..03f605e --- /dev/null +++ b/u-boot-init-rts.patch @@ -0,0 +1,39 @@ +Index: cpu/bf548/init_sdram.S +=================================================================== +--- cpu/bf548/init_sdram.S (revision 817) ++++ cpu/bf548/init_sdram.S (working copy) +@@ -38,6 +38,15 @@ init_sdram: + [--SP] = (R7:0); + [--SP] = (P5:0); + ++#if (BFIN_BOOT_MODE == BFIN_UART_BOOT) ++ /* force RTS rather than relying on auto RTS */ ++ P3.h = hi(UART1_MCR) ++ P3.l = lo(UART1_MCR) ++ R0 = w[P3]; ++ bitset(R0, 5); ++ w[p3] = R0; ++#endif ++ + /************************************************* + * System interrupt wakeup registers (SIC_IWRx) * + * Required for PLL_CTL and VR_CTL configuration * +@@ -239,8 +248,17 @@ test_failed: + r0.l = 0x0080; /* Test failed, light on LED2 */ + w[p0]= r0; + ssync +- + ddr_init_end: ++ ++#if (BFIN_BOOT_MODE == BFIN_UART_BOOT) ++ /* clear forced RTS rather than relying on auto RTS */ ++ P3.h = hi(UART1_MCR) ++ P3.l = lo(UART1_MCR) ++ R0 = w[P3]; ++ bitclr(R0, 5); ++ w[p3] = R0; ++#endif ++ + (P5:0) = [SP++]; + (R7:0) = [SP++]; + RETS = [SP++]; diff --git a/u-boot-jump-cmd.patch b/u-boot-jump-cmd.patch new file mode 100644 index 0000000..1432052 --- /dev/null +++ b/u-boot-jump-cmd.patch @@ -0,0 +1,58 @@ +diff --git a/common/cmd_boot.c b/common/cmd_boot.c +index d83f5af..0c34572 100644 +--- a/common/cmd_boot.c ++++ b/common/cmd_boot.c +@@ -34,8 +34,14 @@ unsigned long do_go_exec (ulong (*entry)(int, char *[]), int argc, char *argv[]) + { + return entry (argc, argv); + } ++__attribute__((weak)) ++unsigned long do_jump_exec (ulong (*entry)(int, char *[]), int argc, char *argv[]) ++{ ++ return entry (argc, argv); ++} + +-int do_go (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) ++int do_it (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], ++ unsigned long (*exec_hook)(ulong (*entry)(int, char *[]), int argc, char *argv[])) + { + ulong addr, rc; + int rcode = 0; +@@ -53,13 +59,22 @@ int do_go (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) + * pass address parameter as argv[0] (aka command name), + * and all remaining args + */ +- rc = do_go_exec ((void *)addr, argc - 1, argv + 1); ++ rc = exec_hook ((void *)addr, argc - 1, argv + 1); + if (rc != 0) rcode = 1; + + printf ("## Application terminated, rc = 0x%lX\n", rc); + return rcode; + } + ++int do_go (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) ++{ ++ return do_it (cmdtp, flag, argc, argv, do_go_exec); ++} ++int do_jump (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) ++{ ++ return do_it (cmdtp, flag, argc, argv, do_jump_exec); ++} ++ + /* -------------------------------------------------------------------- */ + + U_BOOT_CMD( +@@ -69,6 +84,13 @@ U_BOOT_CMD( + " passing 'arg' as arguments\n" + ); + ++U_BOOT_CMD( ++ jump, CFG_MAXARGS, 1, do_jump, ++ "jump - start executing code at address 'addr' and never return\n", ++ "addr [arg ...]\n - jump to address 'addr'\n" ++ " passing 'arg' as arguments\n" ++); ++ + extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); + + U_BOOT_CMD( diff --git a/u-boot-nand-warning.patch b/u-boot-nand-warning.patch new file mode 100644 index 0000000..85349fd --- /dev/null +++ b/u-boot-nand-warning.patch @@ -0,0 +1,15 @@ +Index: nand_base.c +=================================================================== +--- nand_base.c (revision 870) ++++ nand_base.c (working copy) +@@ -1631,7 +1631,9 @@ static int nand_write_ecc (struct mtd_in + + /* reject writes, which are not page aligned */ + if (NOTALIGNED (to) || NOTALIGNED(len)) { +- printk (KERN_NOTICE "nand_write_ecc: Attempt to write not page aligned data\n"); ++// printk (KERN_NOTICE "nand_write_ecc: Attempt to write not page aligned data\n"); ++ printk (KERN_NOTICE "nand_write_ecc: to (0x%08x) and len (0x%08x) need to be aligned to 0x%08x\n", ++ (unsigned int) to, (unsigned int) len, mtd->oobblock); + return -EINVAL; + } + diff --git a/u-boot-nand.patch b/u-boot-nand.patch new file mode 100644 index 0000000..0291d1f --- /dev/null +++ b/u-boot-nand.patch @@ -0,0 +1,12 @@ +diff --git a/include/nand.h b/include/nand.h +index 23493f7..3c0752e 100644 +--- a/include/nand.h ++++ b/include/nand.h +@@ -32,6 +32,7 @@ typedef struct mtd_info nand_info_t; + + extern int nand_curr_device; + extern nand_info_t nand_info[]; ++extern void nand_init(void); + + static inline int nand_read(nand_info_t *info, ulong ofs, ulong *len, u_char *buf) + { diff --git a/u-boot-nicer-version-handling.patch b/u-boot-nicer-version-handling.patch new file mode 100644 index 0000000..ca120f2 --- /dev/null +++ b/u-boot-nicer-version-handling.patch @@ -0,0 +1,41 @@ +diff --git a/Makefile b/Makefile +index 2d8cff3..41661e3 100644 +--- a/Makefile ++++ b/Makefile +@@ -290,11 +290,15 @@ $(U_BOOT_NAND): $(NAND_SPL) $(obj)u-boot.bin + cat $(obj)nand_spl/u-boot-spl-16k.bin $(obj)u-boot.bin > $(obj)u-boot-nand.bin + + version: +- @echo -n "#define U_BOOT_VERSION \"U-Boot " > $(VERSION_FILE); \ +- echo -n "$(U_BOOT_VERSION)" >> $(VERSION_FILE); \ +- echo -n $(shell $(CONFIG_SHELL) $(TOPDIR)/tools/setlocalversion \ +- $(TOPDIR)) >> $(VERSION_FILE); \ +- echo "\"" >> $(VERSION_FILE) ++ @echo -n "#define U_BOOT_VERSION \"U-Boot " > $(VERSION_FILE).tmp; \ ++ echo -n "$(U_BOOT_VERSION)" >> $(VERSION_FILE).tmp; \ ++ echo -n "$(shell $(CONFIG_SHELL) $(TOPDIR)/tools/setlocalversion $(TOPDIR))" >> $(VERSION_FILE).tmp; \ ++ echo "\"" >> $(VERSION_FILE).tmp ++ @if ! cmp -s $(VERSION_FILE) $(VERSION_FILE).tmp; then \ ++ mv -f $(VERSION_FILE).tmp $(VERSION_FILE); \ ++ else \ ++ rm -f $(VERSION_FILE).tmp; \ ++ fi + + gdbtools: + $(MAKE) -C tools/gdb all || exit 1 +diff --git a/tools/setlocalversion b/tools/setlocalversion +index 9a23825..25072fd 100755 +--- a/tools/setlocalversion ++++ b/tools/setlocalversion +@@ -20,3 +20,11 @@ if head=`git rev-parse --verify HEAD 2>/dev/null`; then + printf '%s' -dirty + fi + fi ++ ++# Check for svn and a svn repo. ++if rev=`svn info 2>/dev/null | grep '^Revision' | awk '{print $NF}'` ; then ++ printf -- '-svn%s' $rev ++fi ++ ++# Check for any localversion-* files ++printf '%s' "`cat localversion-* 2>/dev/null`" diff --git a/u-boot-no-TEXT_BASE.patch b/u-boot-no-TEXT_BASE.patch new file mode 100644 index 0000000..04f84cd --- /dev/null +++ b/u-boot-no-TEXT_BASE.patch @@ -0,0 +1,29 @@ +diff --git a/config.mk b/config.mk +index 582df32..e57339f 100644 +--- a/config.mk ++++ b/config.mk +@@ -147,8 +147,10 @@ OBJCFLAGS += --gap-fill=0xff + + gccincdir := $(shell $(CC) -print-file-name=include) + +-CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS) \ +- -D__KERNEL__ -DTEXT_BASE=$(TEXT_BASE) \ ++CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS) -D__KERNEL__ ++ifneq ($(TEXT_BASE),) ++CPPFLAGS += -DTEXT_BASE=$(TEXT_BASE) ++endif + + ifneq ($(OBJTREE),$(SRCTREE)) + CPPFLAGS += -I$(OBJTREE)/include2 -I$(OBJTREE)/include +@@ -186,7 +188,10 @@ endif + + AFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS) + +-LDFLAGS += -Bstatic -T $(LDSCRIPT) -Ttext $(TEXT_BASE) $(PLATFORM_LDFLAGS) ++LDFLAGS += -Bstatic -T $(LDSCRIPT) $(PLATFORM_LDFLAGS) ++ifneq ($(TEXT_BASE),) ++LDFLAGS += -Ttext $(TEXT_BASE) ++endif + + # Location of a usable BFD library, where we define "usable" as + # "built for ${HOST}, supports ${TARGET}". Sensible values are diff --git a/u-boot-no-host-ppc-check.patch b/u-boot-no-host-ppc-check.patch new file mode 100644 index 0000000..278d39b --- /dev/null +++ b/u-boot-no-host-ppc-check.patch @@ -0,0 +1,26 @@ +diff --git a/Makefile b/Makefile +index 358d181..a04715d 100644 +--- a/Makefile ++++ b/Makefile +@@ -118,7 +118,7 @@ include $(OBJTREE)/include/config.mk + export ARCH CPU BOARD VENDOR SOC + + ifndef CROSS_COMPILE +-ifeq ($(HOSTARCH),ppc) ++ifeq ($(HOSTARCH),$(ARCH)) + CROSS_COMPILE = + else + ifeq ($(ARCH),ppc) +@@ -128,12 +128,8 @@ ifeq ($(ARCH),arm) + CROSS_COMPILE = arm-linux- + endif + ifeq ($(ARCH),i386) +-ifeq ($(HOSTARCH),i386) +-CROSS_COMPILE = +-else + CROSS_COMPILE = i386-linux- + endif +-endif + ifeq ($(ARCH),mips) + CROSS_COMPILE = mips_4KC- + endif diff --git a/uCam.patch b/uCam.patch new file mode 100644 index 0000000..a25da8b --- /dev/null +++ b/uCam.patch @@ -0,0 +1,96 @@ +--- uCam.c.orig 2006-10-04 18:44:26.000000000 +0200 ++++ uCam.c 2006-10-04 18:58:00.000000000 +0200 +@@ -387,33 +387,89 @@ + return IRQ_HANDLED; + } + ++ + static irqreturn_t + ppifcd_irq_error( + int irq, + void *dev_id, + struct pt_regs *regs ) + { ++ u16 status; ++ size_t count=0; ++ struct uCam_buffer *tmp_buf; + ppi_device_t *pdev = (ppi_device_t*)dev_id; +- u16 status; + BUG_ON(dev_id == NULL); + ++ // Acknowledge DMA Interrupt ++ clear_dma_irqstat(CH_PPI); ++ + status = bfin_read_PPI_STATUS(); + + #if defined(CONFIG_BF537) || defined(CONFIG_BF536) || defined(CONFIG_BF534) + bfin_write_PPI_STATUS(0xFFFF); //BF537/6/4 PPI_STATUS is Write to Clear + #endif // CONFIG_BF537/6/4 + +- +- DPRINTK("-->ppifcd_irq_error: PPI Status = 0x%X \n", status); + + // disable ppi + bfin_write_PPI_CONTROL(pdev->ppi_control & ~PORT_EN); + +- DPRINTK("-->ppifcd_irq_error: buf [0x%p]\n", uCam_dev->dma_buf->data); ++ pdev->done = 1; ++ DPRINTK("->ppifcd_irq: pdev->done=%d (%ld)\n", pdev->done, jiffies*1000/HZ); ++ ++ uCam_dev->dma_buf->state = FRAME_DONE; ++ DPRINTK("->ppifcd_irq: active buffer [0x%p] done\n", ++ uCam_dev->dma_buf->data); ++ DPRINTK("->ppifcd_irq: next [0x%p] state %d\n", ++ uCam_dev->next_buf->data, ++ uCam_dev->next_buf->state); ++ ++ if( waitqueue_active(&uCam_dev->dma_buf->wq) ) ++ wake_up_interruptible(&uCam_dev->dma_buf->wq); ++ ++ if( uCam_dev->next_buf->state == FRAME_READY ) { // if next frame is ready for grabbing ++ DPRINTK("->ppifcd_irq: initiating next grab [0x%p]\n", uCam_dev->next_buf->data); ++ tmp_buf = uCam_dev->dma_buf; ++ uCam_dev->dma_buf = uCam_dev->next_buf; ++ uCam_dev->next_buf = tmp_buf; ++ uCam_dev->dma_buf->state = FRAME_GRABBING; ++ count = ppi2dma(uCam_dev->ppidev, uCam_dev->dma_buf->data, uCam_dev->size); ++ } ++ ++ if( pdev->fasyc ) ++ kill_fasync( &(pdev->fasyc), SIGIO, POLLIN ); ++ wake_up_interruptible( pdev->rx_avail ); + + return IRQ_HANDLED; ++ + } + ++//static irqreturn_t ++//ppifcd_irq_error( ++// int irq, ++// void *dev_id, ++// struct pt_regs *regs ) ++//{ ++// ppi_device_t *pdev = (ppi_device_t*)dev_id; ++// u16 status; ++// BUG_ON(dev_id == NULL); ++// ++// status = bfin_read_PPI_STATUS(); ++// ++//#if defined(CONFIG_BF537) || defined(CONFIG_BF536) || defined(CONFIG_BF534) ++// bfin_write_PPI_STATUS(0xFFFF); //BF537/6/4 PPI_STATUS is Write to Clear ++//#endif // CONFIG_BF537/6/4 ++// ++// ++// DPRINTK("-->ppifcd_irq_error: PPI Status = 0x%X \n", status); ++// ++// // disable ppi ++// bfin_write_PPI_CONTROL(pdev->ppi_control & ~PORT_EN); ++// ++// DPRINTK("-->ppifcd_irq_error: buf [0x%p]\n", uCam_dev->dma_buf->data); ++// ++// return IRQ_HANDLED; ++//} ++ + + static int + ppi_fasync( diff --git a/uClibc-0.9.28.3-endian.patch b/uClibc-0.9.28.3-endian.patch new file mode 100644 index 0000000..1406edd --- /dev/null +++ b/uClibc-0.9.28.3-endian.patch @@ -0,0 +1,30 @@ +diff -Nru uClibc-0.9.28.3.orig/utils/bswap.h uClibc-0.9.28.3/utils/bswap.h +--- uClibc-0.9.28.3.orig/utils/bswap.h 2007-01-28 08:46:31.000000000 +0200 ++++ uClibc-0.9.28.3/utils/bswap.h 2007-03-02 22:41:00.000000000 +0200 +@@ -3,6 +3,12 @@ + + #if !defined(__BYTE_ORDER) && defined(BYTE_ORDER) + # define __BYTE_ORDER BYTE_ORDER ++# if !defined(__BIG_ENDIAN) && defined(BIG_ENDIAN) ++# define __BIG_ENDIAN BIG_ENDIAN ++# endif ++# if !defined(__LITTLE_ENDIAN) && defined(LITTLE_ENDIAN) ++# define __LITTLE_ENDIAN LITTLE_ENDIAN ++# endif + #endif + + #ifndef __BYTE_ORDER +@@ -13,11 +19,11 @@ + #define __BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */ + #define __PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp) */ + +-#if defined(sun386) || defined(i386) ++#if defined(sun386) || defined(i386) || defined(__LITTLE_ENDIAN__) + #define __BYTE_ORDER __LITTLE_ENDIAN + #endif + +-#if defined(sparc) ++#if defined(sparc) || defined(__BIG_ENDIAN__) + #define __BYTE_ORDER __BIG_ENDIAN + #endif + diff --git a/uClibc-0.9.29-libc_string_tester_memcmp.diff b/uClibc-0.9.29-libc_string_tester_memcmp.diff new file mode 100644 index 0000000..e1b35bb --- /dev/null +++ b/uClibc-0.9.29-libc_string_tester_memcmp.diff @@ -0,0 +1,42 @@ +--- /tmp/test/string/tester.c.orig 2007-10-27 19:36:22.998411224 +0200 ++++ /tmp/test/string/tester.c 2007-10-27 19:36:08.118673288 +0200 +@@ -1087,15 +1087,31 @@ + static void + test_memcmp (void) + { ++ int i, cnt = 1; ++ char one[21], two[21]; ++ + it = "memcmp"; +- check(memcmp("a", "a", 1) == 0, 1); /* Identity. */ +- check(memcmp("abc", "abc", 3) == 0, 2); /* Multicharacter. */ +- check(memcmp("abcd", "abce", 4) < 0, 3); /* Honestly unequal. */ +- check(memcmp("abce", "abcd", 4) > 0, 4); +- check(memcmp("alph", "beta", 4) < 0, 5); +- check(memcmp("a\203", "a\003", 2) > 0, 6); +- check(memcmp("abce", "abcd", 3) == 0, 7); /* Count limited. */ +- check(memcmp("abc", "def", 0) == 0, 8); /* Zero count. */ ++ check(memcmp("a", "a", 1) == 0, cnt++); /* Identity. */ ++ check(memcmp("abc", "abc", 3) == 0, cnt++); /* Multicharacter. */ ++ check(memcmp("abcd", "abcf", 4) < 0, cnt++); /* Honestly unequal. */ ++ check(memcmp("abcf", "abcd", 4) > 0, cnt++); ++ check(memcmp("alph", "cold", 4) < 0, cnt++); ++ check(memcmp("a\203", "a\003", 2) > 0, cnt++); ++ check(memcmp("a\003", "a\203", 2) < 0, cnt++); ++ check(memcmp("a\003bc", "a\203bc", 2) < 0, cnt++); ++ check(memcmp("abc\203", "abc\003", 4) > 0, cnt++); ++ check(memcmp("abc\003", "abc\203", 4) < 0, cnt++); ++ check(memcmp("abcf", "abcd", 3) == 0, cnt++); /* Count limited. */ ++ check(memcmp("abc", "def", 0) == 0, cnt++); /* Zero count. */ ++ /* Comparisons with shifting 4-byte boundaries. */ ++ for (i=0; i<4; i++) ++ { ++ char *a = one + i, *b = two + i; ++ strncpy( a, "--------11112222", 16); ++ strncpy( b, "--------33334444", 16); ++ check( memcmp(b, a, 16) > 0, cnt++); ++ check( memcmp(a, b, 16) < 0, cnt++); ++ } + } + + static void diff --git a/uClibc-mutex-cancel.patch b/uClibc-mutex-cancel.patch new file mode 100644 index 0000000..5e56a73 --- /dev/null +++ b/uClibc-mutex-cancel.patch @@ -0,0 +1,8631 @@ +diff --git a/include/printf.h b/include/printf.h +index 340b6cb..2dea58f 100644 +--- a/include/printf.h ++++ b/include/printf.h +@@ -75,6 +75,7 @@ struct printf_info + unsigned int is_short:1; /* h flag. */ + unsigned int is_long:1; /* l flag. */ + unsigned int is_long_double:1;/* L flag. */ ++ unsigned int __padding:20;/* non-gnu -- total of 32 bits on 32bit arch */ + + #elif __BYTE_ORDER == __BIG_ENDIAN + +diff --git a/include/pthread.h b/include/pthread.h +index 8c01172..cee112b 100644 +--- a/include/pthread.h ++++ b/include/pthread.h +@@ -644,7 +644,8 @@ extern void _pthread_cleanup_pop (struct + /* Install a cleanup handler as pthread_cleanup_push does, but also + saves the current cancellation type and set it to deferred cancellation. */ + +-#ifdef __USE_GNU ++/* #ifdef __USE_GNU */ ++#if defined(__USE_GNU) || defined(_LIBC) + # define pthread_cleanup_push_defer_np(routine,arg) \ + { struct _pthread_cleanup_buffer _buffer; \ + _pthread_cleanup_push_defer (&_buffer, (routine), (arg)); +diff --git a/libc/inet/getnetent.c b/libc/inet/getnetent.c +index 181c5ad..659bf5d 100644 +--- a/libc/inet/getnetent.c ++++ b/libc/inet/getnetent.c +@@ -22,18 +22,9 @@ + #include + #include + ++#include + +-#ifdef __UCLIBC_HAS_THREADS__ +-#include +-static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER; +-# define LOCK __pthread_mutex_lock(&mylock) +-# define UNLOCK __pthread_mutex_unlock(&mylock); +-#else +-# define LOCK +-# define UNLOCK +-#endif +- +- ++__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER); + + #define MAXALIASES 35 + static const char NETDB[] = _PATH_NETWORKS; +@@ -46,25 +37,25 @@ int _net_stayopen; + + void setnetent(int f) + { +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + if (netf == NULL) +- netf = fopen(NETDB, "r" ); ++ netf = fopen(NETDB, "r" ); + else +- rewind(netf); ++ rewind(netf); + _net_stayopen |= f; +- UNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(mylock); + return; + } + + void endnetent(void) + { +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + if (netf) { +- fclose(netf); +- netf = NULL; ++ fclose(netf); ++ netf = NULL; + } + _net_stayopen = 0; +- UNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(mylock); + } + + static char * any(register char *cp, char *match) +@@ -72,10 +63,10 @@ static char * any(register char *cp, cha + register char *mp, c; + + while ((c = *cp)) { +- for (mp = match; *mp; mp++) +- if (*mp == c) +- return (cp); +- cp++; ++ for (mp = match; *mp; mp++) ++ if (*mp == c) ++ return (cp); ++ cp++; + } + return ((char *)0); + } +@@ -84,59 +75,62 @@ struct netent * getnetent(void) + { + char *p; + register char *cp, **q; ++ struct netent *rv = NULL; + +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + if (netf == NULL && (netf = fopen(NETDB, "r" )) == NULL) { +- UNLOCK; +- return (NULL); ++ goto DONE; + } +-again: ++ again: + + if (!line) { +- line = malloc(BUFSIZ + 1); +- if (!line) +- abort(); ++ line = malloc(BUFSIZ + 1); ++ if (!line) ++ abort(); + } + + p = fgets(line, BUFSIZ, netf); + if (p == NULL) { +- UNLOCK; +- return (NULL); ++ goto DONE; + } + if (*p == '#') +- goto again; ++ goto again; + cp = any(p, "#\n"); + if (cp == NULL) +- goto again; ++ goto again; + *cp = '\0'; + net.n_name = p; + cp = any(p, " \t"); + if (cp == NULL) +- goto again; ++ goto again; + *cp++ = '\0'; + while (*cp == ' ' || *cp == '\t') +- cp++; ++ cp++; + p = any(cp, " \t"); + if (p != NULL) +- *p++ = '\0'; ++ *p++ = '\0'; + net.n_net = inet_network(cp); + net.n_addrtype = AF_INET; + q = net.n_aliases = net_aliases; + if (p != NULL) +- cp = p; ++ cp = p; + while (cp && *cp) { +- if (*cp == ' ' || *cp == '\t') { +- cp++; +- continue; +- } +- if (q < &net_aliases[MAXALIASES - 1]) +- *q++ = cp; +- cp = any(cp, " \t"); +- if (cp != NULL) +- *cp++ = '\0'; ++ if (*cp == ' ' || *cp == '\t') { ++ cp++; ++ continue; ++ } ++ if (q < &net_aliases[MAXALIASES - 1]) ++ *q++ = cp; ++ cp = any(cp, " \t"); ++ if (cp != NULL) ++ *cp++ = '\0'; + } + *q = NULL; +- UNLOCK; +- return (&net); ++ ++ rv = &net; ++ ++ DONE: ++ __UCLIBC_MUTEX_UNLOCK(mylock); ++ return rv; + } + +diff --git a/libc/inet/getproto.c b/libc/inet/getproto.c +index c9f35f1..3665d89 100644 +--- a/libc/inet/getproto.c ++++ b/libc/inet/getproto.c +@@ -62,17 +62,9 @@ + #include + #include + +-#ifdef __UCLIBC_HAS_THREADS__ +-#include +-static pthread_mutex_t mylock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; +-# define LOCK __pthread_mutex_lock(&mylock) +-# define UNLOCK __pthread_mutex_unlock(&mylock); +-#else +-# define LOCK +-# define UNLOCK +-#endif +- ++#include + ++__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP); + + #define MAXALIASES 35 + #define SBUFSIZE (BUFSIZ + 1 + (sizeof(char *) * MAXALIASES)) +@@ -85,109 +77,114 @@ static int proto_stayopen; + static void __initbuf(void) + { + if (!static_aliases) { +- static_aliases = malloc(SBUFSIZE); +- if (!static_aliases) +- abort(); ++ static_aliases = malloc(SBUFSIZE); ++ if (!static_aliases) ++ abort(); + } + } + + void setprotoent(int f) + { +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + if (protof == NULL) +- protof = fopen(_PATH_PROTOCOLS, "r" ); ++ protof = fopen(_PATH_PROTOCOLS, "r" ); + else +- rewind(protof); ++ rewind(protof); + proto_stayopen |= f; +- UNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(mylock); + } + + void endprotoent(void) + { +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + if (protof) { +- fclose(protof); +- protof = NULL; ++ fclose(protof); ++ protof = NULL; + } + proto_stayopen = 0; +- UNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(mylock); + } + + int getprotoent_r(struct protoent *result_buf, +- char *buf, size_t buflen, +- struct protoent **result) ++ char *buf, size_t buflen, ++ struct protoent **result) + { + char *p; + register char *cp, **q; + char **proto_aliases; + char *line; ++ int rv; + + *result = NULL; + + if (buflen < sizeof(*proto_aliases)*MAXALIASES) { +- errno=ERANGE; +- return errno; ++ errno=ERANGE; ++ return errno; + } +- LOCK; ++ ++ __UCLIBC_MUTEX_LOCK(mylock); + proto_aliases=(char **)buf; + buf+=sizeof(*proto_aliases)*MAXALIASES; + buflen-=sizeof(*proto_aliases)*MAXALIASES; + + if (buflen < BUFSIZ+1) { +- UNLOCK; +- errno=ERANGE; +- return errno; ++ errno=rv=ERANGE; ++ goto DONE; + } + line=buf; + buf+=BUFSIZ+1; + buflen-=BUFSIZ+1; + + if (protof == NULL && (protof = fopen(_PATH_PROTOCOLS, "r" )) == NULL) { +- UNLOCK; +- return errno; ++ rv=errno; ++ goto DONE; + } +-again: ++ again: + if ((p = fgets(line, BUFSIZ, protof)) == NULL) { +- UNLOCK; +- return TRY_AGAIN; ++ rv=TRY_AGAIN; ++ goto DONE; + } + + if (*p == '#') +- goto again; ++ goto again; + cp = strpbrk(p, "#\n"); + if (cp == NULL) +- goto again; ++ goto again; + *cp = '\0'; + result_buf->p_name = p; + cp = strpbrk(p, " \t"); + if (cp == NULL) +- goto again; ++ goto again; + *cp++ = '\0'; + while (*cp == ' ' || *cp == '\t') +- cp++; ++ cp++; + p = strpbrk(cp, " \t"); + if (p != NULL) +- *p++ = '\0'; ++ *p++ = '\0'; + result_buf->p_proto = atoi(cp); + q = result_buf->p_aliases = proto_aliases; + if (p != NULL) { +- cp = p; +- while (cp && *cp) { +- if (*cp == ' ' || *cp == '\t') { +- cp++; +- continue; +- } +- if (q < &proto_aliases[MAXALIASES - 1]) +- *q++ = cp; +- cp = strpbrk(cp, " \t"); +- if (cp != NULL) +- *cp++ = '\0'; +- } ++ cp = p; ++ while (cp && *cp) { ++ if (*cp == ' ' || *cp == '\t') { ++ cp++; ++ continue; ++ } ++ if (q < &proto_aliases[MAXALIASES - 1]) ++ *q++ = cp; ++ cp = strpbrk(cp, " \t"); ++ if (cp != NULL) ++ *cp++ = '\0'; ++ } + } + *q = NULL; + *result=result_buf; +- UNLOCK; +- return 0; ++ ++ rv = 0; ++ ++ DONE: ++ __UCLIBC_MUTEX_UNLOCK(mylock); ++ return rv; + } + + struct protoent * getprotoent(void) +@@ -201,26 +198,26 @@ struct protoent * getprotoent(void) + + + int getprotobyname_r(const char *name, +- struct protoent *result_buf, +- char *buf, size_t buflen, +- struct protoent **result) ++ struct protoent *result_buf, ++ char *buf, size_t buflen, ++ struct protoent **result) + { + register char **cp; + int ret; + +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + setprotoent(proto_stayopen); + while (!(ret=getprotoent_r(result_buf, buf, buflen, result))) { +- if (strcmp(result_buf->p_name, name) == 0) +- break; +- for (cp = result_buf->p_aliases; *cp != 0; cp++) +- if (strcmp(*cp, name) == 0) +- goto found; ++ if (strcmp(result_buf->p_name, name) == 0) ++ break; ++ for (cp = result_buf->p_aliases; *cp != 0; cp++) ++ if (strcmp(*cp, name) == 0) ++ goto found; + } +-found: ++ found: + if (!proto_stayopen) +- endprotoent(); +- UNLOCK; ++ endprotoent(); ++ __UCLIBC_MUTEX_UNLOCK(mylock); + return *result?0:ret; + } + +@@ -236,20 +233,20 @@ struct protoent * getprotobyname(const c + + + int getprotobynumber_r (int proto_num, +- struct protoent *result_buf, +- char *buf, size_t buflen, +- struct protoent **result) ++ struct protoent *result_buf, ++ char *buf, size_t buflen, ++ struct protoent **result) + { + int ret; + +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + setprotoent(proto_stayopen); + while (!(ret=getprotoent_r(result_buf, buf, buflen, result))) +- if (result_buf->p_proto == proto_num) +- break; ++ if (result_buf->p_proto == proto_num) ++ break; + if (!proto_stayopen) +- endprotoent(); +- UNLOCK; ++ endprotoent(); ++ __UCLIBC_MUTEX_UNLOCK(mylock); + return *result?0:ret; + } + +diff --git a/libc/inet/getservice.c b/libc/inet/getservice.c +index cbe5c50..b666057 100644 +--- a/libc/inet/getservice.c ++++ b/libc/inet/getservice.c +@@ -65,20 +65,9 @@ + #include + #include + ++#include + +- +-#ifdef __UCLIBC_HAS_THREADS__ +-#include +-static pthread_mutex_t mylock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; +-# define LOCK __pthread_mutex_lock(&mylock) +-# define UNLOCK __pthread_mutex_unlock(&mylock); +-#else +-# define LOCK +-# define UNLOCK +-#endif +- +- +- ++__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP); + + #define MAXALIASES 35 + #define SBUFSIZE (BUFSIZ + 1 + (sizeof(char *) * MAXALIASES)) +@@ -91,32 +80,32 @@ static int serv_stayopen; + static void __initbuf(void) + { + if (!servbuf) { +- servbuf = malloc(SBUFSIZE); +- if (!servbuf) +- abort(); ++ servbuf = malloc(SBUFSIZE); ++ if (!servbuf) ++ abort(); + } + } + + void setservent(int f) + { +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + if (servf == NULL) +- servf = fopen(_PATH_SERVICES, "r" ); ++ servf = fopen(_PATH_SERVICES, "r" ); + else +- rewind(servf); ++ rewind(servf); + serv_stayopen |= f; +- UNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(mylock); + } + + void endservent(void) + { +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + if (servf) { +- fclose(servf); +- servf = NULL; ++ fclose(servf); ++ servf = NULL; + } + serv_stayopen = 0; +- UNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(mylock); + } + + struct servent * getservent(void) +@@ -149,127 +138,129 @@ struct servent * getservbyport(int port, + } + + int getservent_r(struct servent * result_buf, +- char * buf, size_t buflen, +- struct servent ** result) ++ char * buf, size_t buflen, ++ struct servent ** result) + { + char *p; + register char *cp, **q; + char **serv_aliases; + char *line; ++ int rv; + + *result=NULL; + + if (buflen < sizeof(*serv_aliases)*MAXALIASES) { +- errno=ERANGE; +- return errno; ++ errno=ERANGE; ++ return errno; + } +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + serv_aliases=(char **)buf; + buf+=sizeof(*serv_aliases)*MAXALIASES; + buflen-=sizeof(*serv_aliases)*MAXALIASES; + + if (buflen < BUFSIZ+1) { +- UNLOCK; +- errno=ERANGE; +- return errno; ++ errno=rv=ERANGE; ++ goto DONE; + } + line=buf; + buf+=BUFSIZ+1; + buflen-=BUFSIZ+1; + + if (servf == NULL && (servf = fopen(_PATH_SERVICES, "r" )) == NULL) { +- UNLOCK; +- errno=EIO; +- return errno; ++ errno=rv=EIO; ++ goto DONE; + } +-again: ++ again: + if ((p = fgets(line, BUFSIZ, servf)) == NULL) { +- UNLOCK; +- errno=EIO; +- return errno; ++ errno=rv=EIO; ++ goto DONE; + } + if (*p == '#') +- goto again; ++ goto again; + cp = strpbrk(p, "#\n"); + if (cp == NULL) +- goto again; ++ goto again; + *cp = '\0'; + result_buf->s_name = p; + p = strpbrk(p, " \t"); + if (p == NULL) +- goto again; ++ goto again; + *p++ = '\0'; + while (*p == ' ' || *p == '\t') +- p++; ++ p++; + cp = strpbrk(p, ",/"); + if (cp == NULL) +- goto again; ++ goto again; + *cp++ = '\0'; + result_buf->s_port = htons((u_short)atoi(p)); + result_buf->s_proto = cp; + q = result_buf->s_aliases = serv_aliases; + cp = strpbrk(cp, " \t"); + if (cp != NULL) +- *cp++ = '\0'; ++ *cp++ = '\0'; + while (cp && *cp) { +- if (*cp == ' ' || *cp == '\t') { +- cp++; +- continue; +- } +- if (q < &serv_aliases[MAXALIASES - 1]) +- *q++ = cp; +- cp = strpbrk(cp, " \t"); +- if (cp != NULL) +- *cp++ = '\0'; ++ if (*cp == ' ' || *cp == '\t') { ++ cp++; ++ continue; ++ } ++ if (q < &serv_aliases[MAXALIASES - 1]) ++ *q++ = cp; ++ cp = strpbrk(cp, " \t"); ++ if (cp != NULL) ++ *cp++ = '\0'; + } + *q = NULL; + *result=result_buf; +- UNLOCK; +- return 0; ++ ++ rv = 0; ++ ++ DONE: ++ __UCLIBC_MUTEX_UNLOCK(mylock); ++ return rv; + } + + int getservbyname_r(const char *name, const char *proto, +- struct servent * result_buf, char * buf, size_t buflen, +- struct servent ** result) ++ struct servent * result_buf, char * buf, size_t buflen, ++ struct servent ** result) + { + register char **cp; + int ret; + +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + setservent(serv_stayopen); + while (!(ret=getservent_r(result_buf, buf, buflen, result))) { +- if (strcmp(name, result_buf->s_name) == 0) +- goto gotname; +- for (cp = result_buf->s_aliases; *cp; cp++) +- if (strcmp(name, *cp) == 0) +- goto gotname; +- continue; +-gotname: +- if (proto == 0 || strcmp(result_buf->s_proto, proto) == 0) +- break; ++ if (strcmp(name, result_buf->s_name) == 0) ++ goto gotname; ++ for (cp = result_buf->s_aliases; *cp; cp++) ++ if (strcmp(name, *cp) == 0) ++ goto gotname; ++ continue; ++ gotname: ++ if (proto == 0 || strcmp(result_buf->s_proto, proto) == 0) ++ break; + } + if (!serv_stayopen) +- endservent(); +- UNLOCK; ++ endservent(); ++ __UCLIBC_MUTEX_UNLOCK(mylock); + return *result?0:ret; + } + + int getservbyport_r(int port, const char *proto, +- struct servent * result_buf, char * buf, +- size_t buflen, struct servent ** result) ++ struct servent * result_buf, char * buf, ++ size_t buflen, struct servent ** result) + { + int ret; + +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + setservent(serv_stayopen); + while (!(ret=getservent_r(result_buf, buf, buflen, result))) { +- if (result_buf->s_port != port) +- continue; +- if (proto == 0 || strcmp(result_buf->s_proto, proto) == 0) +- break; ++ if (result_buf->s_port != port) ++ continue; ++ if (proto == 0 || strcmp(result_buf->s_proto, proto) == 0) ++ break; + } + if (!serv_stayopen) +- endservent(); +- UNLOCK; ++ endservent(); ++ __UCLIBC_MUTEX_UNLOCK(mylock); + return *result?0:ret; + } +diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c +index 27b60ef..0f583ab 100644 +--- a/libc/inet/resolv.c ++++ b/libc/inet/resolv.c +@@ -7,7 +7,7 @@ + * 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. +-*/ ++ */ + + /* + * Portions Copyright (c) 1985, 1993 +@@ -153,6 +153,11 @@ + #include + #include + ++#include ++ ++__UCLIBC_MUTEX_EXTERN(__resolv_lock); ++ ++ + #define MAX_RECURSE 5 + #define REPLY_TIMEOUT 10 + #define MAX_RETRIES 3 +@@ -180,18 +185,6 @@ extern char * __nameserver[MAX_SERVERS]; + extern int __searchdomains; + extern char * __searchdomain[MAX_SEARCH]; + +-#ifdef __UCLIBC_HAS_THREADS__ +-#include +-extern pthread_mutex_t __resolv_lock; +-# define BIGLOCK __pthread_mutex_lock(&__resolv_lock) +-# define BIGUNLOCK __pthread_mutex_unlock(&__resolv_lock); +-#else +-# define BIGLOCK +-# define BIGUNLOCK +-#endif +- +- +- + /* Structs */ + struct resolv_header { + int id; +@@ -229,49 +222,49 @@ enum etc_hosts_action { + + /* function prototypes */ + extern int __get_hosts_byname_r(const char * name, int type, +- struct hostent * result_buf, +- char * buf, size_t buflen, +- struct hostent ** result, +- int * h_errnop); ++ struct hostent * result_buf, ++ char * buf, size_t buflen, ++ struct hostent ** result, ++ int * h_errnop); + extern int __get_hosts_byaddr_r(const char * addr, int len, int type, +- struct hostent * result_buf, +- char * buf, size_t buflen, +- struct hostent ** result, +- int * h_errnop); ++ struct hostent * result_buf, ++ char * buf, size_t buflen, ++ struct hostent ** result, ++ int * h_errnop); + extern void __open_etc_hosts(FILE **fp); + extern int __read_etc_hosts_r(FILE *fp, const char * name, int type, +- enum etc_hosts_action action, +- struct hostent * result_buf, +- char * buf, size_t buflen, +- struct hostent ** result, +- int * h_errnop); ++ enum etc_hosts_action action, ++ struct hostent * result_buf, ++ char * buf, size_t buflen, ++ struct hostent ** result, ++ int * h_errnop); + extern int __dns_lookup(const char * name, int type, int nscount, +- char ** nsip, unsigned char ** outpacket, struct resolv_answer * a); ++ char ** nsip, unsigned char ** outpacket, struct resolv_answer * a); + + extern int __encode_dotted(const char * dotted, unsigned char * dest, int maxlen); + extern int __decode_dotted(const unsigned char * message, int offset, +- char * dest, int maxlen); ++ char * dest, int maxlen); + extern int __length_dotted(const unsigned char * message, int offset); + extern int __encode_header(struct resolv_header * h, unsigned char * dest, int maxlen); + extern int __decode_header(unsigned char * data, struct resolv_header * h); + extern int __encode_question(struct resolv_question * q, +- unsigned char * dest, int maxlen); ++ unsigned char * dest, int maxlen); + extern int __decode_question(unsigned char * message, int offset, +- struct resolv_question * q); ++ struct resolv_question * q); + extern int __encode_answer(struct resolv_answer * a, +- unsigned char * dest, int maxlen); ++ unsigned char * dest, int maxlen); + extern int __decode_answer(unsigned char * message, int offset, +- struct resolv_answer * a); ++ struct resolv_answer * a); + extern int __length_question(unsigned char * message, int offset); + extern int __open_nameservers(void); + extern void __close_nameservers(void); + extern int __dn_expand(const u_char *, const u_char *, const u_char *, +- char *, int); ++ char *, int); + extern int __ns_name_uncompress(const u_char *, const u_char *, +- const u_char *, char *, size_t); ++ const u_char *, char *, size_t); + extern int __ns_name_ntop(const u_char *, char *, size_t); + extern int __ns_name_unpack(const u_char *, const u_char *, const u_char *, +- u_char *, size_t); ++ u_char *, size_t); + + + #ifdef L_encodeh +@@ -361,7 +354,7 @@ int __encode_dotted(const char *dotted, + This routine understands compressed data. */ + + int __decode_dotted(const unsigned char *data, int offset, +- char *dest, int maxlen) ++ char *dest, int maxlen) + { + int l; + int measure = 1; +@@ -435,7 +428,7 @@ int __length_dotted(const unsigned char + + #ifdef L_encodeq + int __encode_question(struct resolv_question *q, +- unsigned char *dest, int maxlen) ++ unsigned char *dest, int maxlen) + { + int i; + +@@ -460,7 +453,7 @@ int __encode_question(struct resolv_ques + + #ifdef L_decodeq + int __decode_question(unsigned char *message, int offset, +- struct resolv_question *q) ++ struct resolv_question *q) + { + char temp[256]; + int i; +@@ -525,7 +518,7 @@ int __encode_answer(struct resolv_answer + + #ifdef L_decodea + int __decode_answer(unsigned char *message, int offset, +- struct resolv_answer *a) ++ struct resolv_answer *a) + { + char temp[256]; + int i; +@@ -557,11 +550,11 @@ int __decode_answer(unsigned char *messa + + #ifdef L_encodep + int __encode_packet(struct resolv_header *h, +- struct resolv_question **q, +- struct resolv_answer **an, +- struct resolv_answer **ns, +- struct resolv_answer **ar, +- unsigned char *dest, int maxlen) ++ struct resolv_question **q, ++ struct resolv_answer **an, ++ struct resolv_answer **ns, ++ struct resolv_answer **ar, ++ unsigned char *dest, int maxlen) + { + int i, total = 0; + int j; +@@ -621,7 +614,7 @@ int __decode_packet(unsigned char *data, + + #ifdef L_formquery + int __form_query(int id, const char *name, int type, unsigned char *packet, +- int maxlen) ++ int maxlen) + { + struct resolv_header h; + struct resolv_question q; +@@ -649,14 +642,7 @@ int __form_query(int id, const char *nam + + #ifdef L_dnslookup + +-#ifdef __UCLIBC_HAS_THREADS__ +-static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER; +-# define LOCK __pthread_mutex_lock(&mylock) +-# define UNLOCK __pthread_mutex_unlock(&mylock); +-#else +-# define LOCK +-# define UNLOCK +-#endif ++__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER); + + /* Just for the record, having to lock __dns_lookup() just for these two globals + * is pretty lame. I think these two variables can probably be de-global-ized, +@@ -665,7 +651,7 @@ static pthread_mutex_t mylock = PTHREAD_ + static int ns=0, id=1; + + int __dns_lookup(const char *name, int type, int nscount, char **nsip, +- unsigned char **outpacket, struct resolv_answer *a) ++ unsigned char **outpacket, struct resolv_answer *a) + { + int i, j, len, fd, pos, rc; + struct timeval tv; +@@ -693,10 +679,10 @@ int __dns_lookup(const char *name, int t + DPRINTF("Looking up type %d answer for '%s'\n", type, name); + + /* Mess with globals while under lock */ +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + local_ns = ns % nscount; + local_id = id; +- UNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(mylock); + + while (retries < MAX_RETRIES) { + if (fd != -1) +@@ -722,13 +708,13 @@ int __dns_lookup(const char *name, int t + + strncpy(lookup,name,MAXDNAME); + if (variant >= 0) { +- BIGLOCK; +- if (variant < __searchdomains) { +- strncat(lookup,".", MAXDNAME); +- strncat(lookup,__searchdomain[variant], MAXDNAME); +- } +- BIGUNLOCK; +- } ++ __UCLIBC_MUTEX_LOCK(__resolv_lock); ++ if (variant < __searchdomains) { ++ strncat(lookup,".", MAXDNAME); ++ strncat(lookup,__searchdomain[variant], MAXDNAME); ++ } ++ __UCLIBC_MUTEX_UNLOCK(__resolv_lock); ++ } + DPRINTF("lookup name: %s\n", lookup); + q.dotted = (char *)lookup; + q.qtype = type; +@@ -750,7 +736,7 @@ int __dns_lookup(const char *name, int t + fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + #endif + if (fd < 0) { +- retries++; ++ retries++; + continue; + } + +@@ -772,11 +758,11 @@ int __dns_lookup(const char *name, int t + #endif + if (rc < 0) { + if (errno == ENETUNREACH) { +- /* routing error, presume not transient */ +- goto tryall; ++ /* routing error, presume not transient */ ++ goto tryall; + } else +- /* retry */ +- retries++; ++ /* retry */ ++ retries++; + continue; + } + +@@ -838,55 +824,55 @@ int __dns_lookup(const char *name, int t + + first_answer = 1; + for (j=0;jbuf; +- ma.buflen = a->buflen; +- ma.add_count = a->add_count; +- memcpy(a, &ma, sizeof(ma)); +- if (a->atype != T_SIG && (0 == a->buf || (type != T_A && type != T_AAAA))) +- { +- break; +- } +- if (a->atype != type) +- { +- free(a->dotted); +- continue; +- } +- a->add_count = h.ancount - j - 1; +- if ((a->rdlength + sizeof(struct in_addr*)) * a->add_count > a->buflen) +- { +- break; +- } +- a->add_count = 0; +- first_answer = 0; +- } +- else +- { +- free(ma.dotted); +- if (ma.atype != type) +- { +- continue; +- } +- if (a->rdlength != ma.rdlength) +- { +- free(a->dotted); +- DPRINTF("Answer address len(%u) differs from original(%u)\n", +- ma.rdlength, a->rdlength); +- goto again; ++ if ( first_answer ) ++ { ++ ma.buf = a->buf; ++ ma.buflen = a->buflen; ++ ma.add_count = a->add_count; ++ memcpy(a, &ma, sizeof(ma)); ++ if (a->atype != T_SIG && (0 == a->buf || (type != T_A && type != T_AAAA))) ++ { ++ break; ++ } ++ if (a->atype != type) ++ { ++ free(a->dotted); ++ continue; ++ } ++ a->add_count = h.ancount - j - 1; ++ if ((a->rdlength + sizeof(struct in_addr*)) * a->add_count > a->buflen) ++ { ++ break; ++ } ++ a->add_count = 0; ++ first_answer = 0; ++ } ++ else ++ { ++ free(ma.dotted); ++ if (ma.atype != type) ++ { ++ continue; ++ } ++ if (a->rdlength != ma.rdlength) ++ { ++ free(a->dotted); ++ DPRINTF("Answer address len(%u) differs from original(%u)\n", ++ ma.rdlength, a->rdlength); ++ goto again; ++ } ++ memcpy(a->buf + (a->add_count * ma.rdlength), ma.rdata, ma.rdlength); ++ ++a->add_count; ++ } + } +- memcpy(a->buf + (a->add_count * ma.rdlength), ma.rdata, ma.rdlength); +- ++a->add_count; +- } +- } + + DPRINTF("Answer name = |%s|\n", a->dotted); + DPRINTF("Answer type = |%d|\n", a->atype); +@@ -900,48 +886,48 @@ int __dns_lookup(const char *name, int t + free(lookup); + + /* Mess with globals while under lock */ +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + ns = local_ns; + id = local_id; +- UNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(mylock); + + return (len); /* success! */ + +- tryall: ++ tryall: + /* if there are other nameservers, give them a go, + otherwise return with error */ + { + variant = -1; +- local_ns = (local_ns + 1) % nscount; +- if (local_ns == 0) +- retries++; ++ local_ns = (local_ns + 1) % nscount; ++ if (local_ns == 0) ++ retries++; + +- continue; ++ continue; + } + +- again: ++ again: + /* if there are searchdomains, try them or fallback as passed */ + { + int sdomains; +- BIGLOCK; ++ __UCLIBC_MUTEX_LOCK(__resolv_lock); + sdomains=__searchdomains; +- BIGUNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(__resolv_lock); + + if (variant < sdomains - 1) { +- /* next search */ +- variant++; ++ /* next search */ ++ variant++; + } else { +- /* next server, first search */ +- local_ns = (local_ns + 1) % nscount; +- if (local_ns == 0) +- retries++; ++ /* next server, first search */ ++ local_ns = (local_ns + 1) % nscount; ++ if (local_ns == 0) ++ retries++; + +- variant = -1; ++ variant = -1; + } + } + } + +-fail: ++ fail: + if (fd != -1) + close(fd); + if (lookup) +@@ -951,10 +937,10 @@ fail: + h_errno = NETDB_INTERNAL; + /* Mess with globals while under lock */ + if (local_ns != -1) { +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + ns = local_ns; + id = local_id; +- UNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(mylock); + } + return -1; + } +@@ -966,9 +952,8 @@ int __nameservers; + char * __nameserver[MAX_SERVERS]; + int __searchdomains; + char * __searchdomain[MAX_SEARCH]; +-#ifdef __UCLIBC_HAS_THREADS__ +-pthread_mutex_t __resolv_lock = PTHREAD_MUTEX_INITIALIZER; +-#endif ++ ++__UCLIBC_MUTEX_INIT(__resolv_lock, PTHREAD_MUTEX_INITIALIZER); + + /* + * we currently read formats not quite the same as that on normal +@@ -982,60 +967,63 @@ int __open_nameservers() + #define RESOLV_ARGS 5 + char szBuffer[128], *p, *argv[RESOLV_ARGS]; + int argc; ++ int rv = 0; + +- BIGLOCK; ++ __UCLIBC_MUTEX_LOCK(__resolv_lock); + if (__nameservers > 0) { +- BIGUNLOCK; +- return 0; ++ goto DONE; + } + + if ((fp = fopen("/etc/resolv.conf", "r")) || +- (fp = fopen("/etc/config/resolv.conf", "r"))) +- { +- +- while (fgets(szBuffer, sizeof(szBuffer), fp) != NULL) { ++ (fp = fopen("/etc/config/resolv.conf", "r"))) ++ { + +- for (p = szBuffer; *p && isspace(*p); p++) +- /* skip white space */; +- if (*p == '\0' || *p == '\n' || *p == '#') /* skip comments etc */ +- continue; +- argc = 0; +- while (*p && argc < RESOLV_ARGS) { +- argv[argc++] = p; +- while (*p && !isspace(*p) && *p != '\n') +- p++; +- while (*p && (isspace(*p) || *p == '\n')) /* remove spaces */ +- *p++ = '\0'; +- } ++ while (fgets(szBuffer, sizeof(szBuffer), fp) != NULL) { + +- if (strcmp(argv[0], "nameserver") == 0) { +- for (i = 1; i < argc && __nameservers < MAX_SERVERS; i++) { +- __nameserver[__nameservers++] = strdup(argv[i]); +- DPRINTF("adding nameserver %s\n", argv[i]); ++ for (p = szBuffer; *p && isspace(*p); p++) ++ /* skip white space */; ++ if (*p == '\0' || *p == '\n' || *p == '#') /* skip comments etc */ ++ continue; ++ argc = 0; ++ while (*p && argc < RESOLV_ARGS) { ++ argv[argc++] = p; ++ while (*p && !isspace(*p) && *p != '\n') ++ p++; ++ while (*p && (isspace(*p) || *p == '\n')) /* remove spaces */ ++ *p++ = '\0'; + } +- } + +- /* domain and search are mutually exclusive, the last one wins */ +- if (strcmp(argv[0],"domain")==0 || strcmp(argv[0],"search")==0) { +- while (__searchdomains > 0) { +- free(__searchdomain[--__searchdomains]); +- __searchdomain[__searchdomains] = NULL; ++ if (strcmp(argv[0], "nameserver") == 0) { ++ for (i = 1; i < argc && __nameservers < MAX_SERVERS; i++) { ++ __nameserver[__nameservers++] = strdup(argv[i]); ++ DPRINTF("adding nameserver %s\n", argv[i]); ++ } + } +- for (i=1; i < argc && __searchdomains < MAX_SEARCH; i++) { +- __searchdomain[__searchdomains++] = strdup(argv[i]); +- DPRINTF("adding search %s\n", argv[i]); ++ ++ /* domain and search are mutually exclusive, the last one wins */ ++ if (strcmp(argv[0],"domain")==0 || strcmp(argv[0],"search")==0) { ++ while (__searchdomains > 0) { ++ free(__searchdomain[--__searchdomains]); ++ __searchdomain[__searchdomains] = NULL; ++ } ++ for (i=1; i < argc && __searchdomains < MAX_SEARCH; i++) { ++ __searchdomain[__searchdomains++] = strdup(argv[i]); ++ DPRINTF("adding search %s\n", argv[i]); ++ } + } + } ++ fclose(fp); ++ DPRINTF("nameservers = %d\n", __nameservers); ++ goto DONE; + } +- fclose(fp); +- DPRINTF("nameservers = %d\n", __nameservers); +- BIGUNLOCK; +- return 0; +- } + DPRINTF("failed to open %s\n", "resolv.conf"); + h_errno = NO_RECOVERY; +- BIGUNLOCK; +- return -1; ++ ++ rv = -1; ++ ++ DONE: ++ __UCLIBC_MUTEX_UNLOCK(__resolv_lock); ++ return rv; + } + #endif + +@@ -1044,7 +1032,7 @@ int __open_nameservers() + + void __close_nameservers(void) + { +- BIGLOCK; ++ __UCLIBC_MUTEX_LOCK(__resolv_lock); + while (__nameservers > 0) { + free(__nameserver[--__nameservers]); + __nameserver[__nameservers] = NULL; +@@ -1053,7 +1041,7 @@ void __close_nameservers(void) + free(__searchdomain[--__searchdomains]); + __searchdomain[__searchdomains] = NULL; + } +- BIGUNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(__resolv_lock); + } + #endif + +@@ -1063,8 +1051,8 @@ struct hostent *gethostbyname(const char + { + static struct hostent h; + static char buf[sizeof(struct in_addr) + +- sizeof(struct in_addr *)*2 + +- sizeof(char *)*(ALIAS_DIM) + 384/*namebuffer*/ + 32/* margin */]; ++ sizeof(struct in_addr *)*2 + ++ sizeof(char *)*(ALIAS_DIM) + 384/*namebuffer*/ + 32/* margin */]; + struct hostent *hp; + + gethostbyname_r(name, &h, buf, sizeof(buf), &hp, &h_errno); +@@ -1082,8 +1070,8 @@ struct hostent *gethostbyname2(const cha + #else /* __UCLIBC_HAS_IPV6__ */ + static struct hostent h; + static char buf[sizeof(struct in6_addr) + +- sizeof(struct in6_addr *)*2 + +- sizeof(char *)*(ALIAS_DIM) + 384/*namebuffer*/ + 32/* margin */]; ++ sizeof(struct in6_addr *)*2 + ++ sizeof(char *)*(ALIAS_DIM) + 384/*namebuffer*/ + 32/* margin */]; + struct hostent *hp; + + gethostbyname2_r(name, family, &h, buf, sizeof(buf), &hp, &h_errno); +@@ -1119,7 +1107,7 @@ int res_init(void) + /** rp->rhook = NULL; **/ + /** rp->_u._ext.nsinit = 0; **/ + +- BIGLOCK; ++ __UCLIBC_MUTEX_LOCK(__resolv_lock); + if(__searchdomains) { + int i; + for(i=0; i<__searchdomains; i++) { +@@ -1139,7 +1127,7 @@ int res_init(void) + } + } + rp->nscount = __nameservers; +- BIGUNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(__resolv_lock); + + return(0); + } +@@ -1175,10 +1163,10 @@ int res_query(const char *dname, int cla + + memset((char *) &a, '\0', sizeof(a)); + +- BIGLOCK; ++ __UCLIBC_MUTEX_LOCK(__resolv_lock); + __nameserversXX=__nameservers; + __nameserverXX=__nameserver; +- BIGUNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(__resolv_lock); + i = __dns_lookup(dname, type, __nameserversXX, __nameserverXX, &packet, &a); + + if (i < 0) { +@@ -1207,10 +1195,10 @@ int res_query(const char *dname, int cla + * is detected. Error code, if any, is left in h_errno. + */ + int res_search(name, class, type, answer, anslen) +- const char *name; /* domain name */ +- int class, type; /* class and type of query */ +- u_char *answer; /* buffer to put answer */ +- int anslen; /* size of answer */ ++ const char *name; /* domain name */ ++ int class, type; /* class and type of query */ ++ u_char *answer; /* buffer to put answer */ ++ int anslen; /* size of answer */ + { + const char *cp, * const *domain; + HEADER *hp = (HEADER *)(void *)answer; +@@ -1256,11 +1244,11 @@ int res_search(name, class, type, answer + int done = 0; + + for (domain = (const char * const *)_res.dnsrch; +- *domain && !done; +- domain++) { ++ *domain && !done; ++ domain++) { + + ret = res_querydomain(name, *domain, class, type, +- answer, anslen); ++ answer, anslen); + if (ret > 0) + return (ret); + +@@ -1283,22 +1271,22 @@ int res_search(name, class, type, answer + } + + switch (h_errno) { +- case NO_DATA: +- got_nodata++; +- /* FALLTHROUGH */ +- case HOST_NOT_FOUND: +- /* keep trying */ +- break; +- case TRY_AGAIN: +- if (hp->rcode == SERVFAIL) { +- /* try next search element, if any */ +- got_servfail++; ++ case NO_DATA: ++ got_nodata++; ++ /* FALLTHROUGH */ ++ case HOST_NOT_FOUND: ++ /* keep trying */ + break; +- } +- /* FALLTHROUGH */ +- default: +- /* anything else implies that we're done */ +- done++; ++ case TRY_AGAIN: ++ if (hp->rcode == SERVFAIL) { ++ /* try next search element, if any */ ++ got_servfail++; ++ break; ++ } ++ /* FALLTHROUGH */ ++ default: ++ /* anything else implies that we're done */ ++ done++; + } + /* + * if we got here for some reason other than DNSRCH, +@@ -1342,10 +1330,10 @@ int res_search(name, class, type, answer + * removing a trailing dot from name if domain is NULL. + */ + int res_querydomain(name, domain, class, type, answer, anslen) +- const char *name, *domain; +- int class, type; /* class and type of query */ +- u_char *answer; /* buffer to put answer */ +- int anslen; /* size of answer */ ++ const char *name, *domain; ++ int class, type; /* class and type of query */ ++ u_char *answer; /* buffer to put answer */ ++ int anslen; /* size of answer */ + { + char nbuf[MAXDNAME]; + const char *longname = nbuf; +@@ -1359,7 +1347,7 @@ int res_querydomain(name, domain, class, + #ifdef DEBUG + if (_res.options & RES_DEBUG) + printf(";; res_querydomain(%s, %s, %d, %d)\n", +- name, domain?domain:"", class, type); ++ name, domain?domain:"", class, type); + #endif + if (domain == NULL) { + /* +@@ -1400,11 +1388,11 @@ struct hostent *gethostbyaddr (const voi + static struct hostent h; + static char buf[ + #ifndef __UCLIBC_HAS_IPV6__ +- sizeof(struct in_addr) + sizeof(struct in_addr *)*2 + ++ sizeof(struct in_addr) + sizeof(struct in_addr *)*2 + + #else +- sizeof(struct in6_addr) + sizeof(struct in6_addr *)*2 + ++ sizeof(struct in6_addr) + sizeof(struct in6_addr *)*2 + + #endif /* __UCLIBC_HAS_IPV6__ */ +- sizeof(char *)*(ALIAS_DIM) + 384/*namebuffer*/ + 32/* margin */]; ++ sizeof(char *)*(ALIAS_DIM) + 384/*namebuffer*/ + 32/* margin */]; + struct hostent *hp; + + gethostbyaddr_r(addr, len, type, &h, buf, sizeof(buf), &hp, &h_errno); +@@ -1425,11 +1413,11 @@ void __open_etc_hosts(FILE **fp) + } + + int __read_etc_hosts_r(FILE * fp, const char * name, int type, +- enum etc_hosts_action action, +- struct hostent * result_buf, +- char * buf, size_t buflen, +- struct hostent ** result, +- int * h_errnop) ++ enum etc_hosts_action action, ++ struct hostent * result_buf, ++ char * buf, size_t buflen, ++ struct hostent ** result, ++ int * h_errnop) + { + struct in_addr *in=NULL; + struct in_addr **addr_list=NULL; +@@ -1576,56 +1564,49 @@ int __read_etc_hosts_r(FILE * fp, const + + #ifdef L_gethostent + +-#ifdef __UCLIBC_HAS_THREADS__ +-static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER; +-# define LOCK __pthread_mutex_lock(&mylock) +-# define UNLOCK __pthread_mutex_unlock(&mylock); +-#else +-# define LOCK +-# define UNLOCK +-#endif ++__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER); + + static int __stay_open; + static FILE * __gethostent_fp; + + void endhostent (void) + { +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + __stay_open = 0; + if (__gethostent_fp) { +- fclose(__gethostent_fp); ++ fclose(__gethostent_fp); + } +- UNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(mylock); + } + + void sethostent (int stay_open) + { +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + __stay_open = stay_open; +- UNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(mylock); + } + + int gethostent_r(struct hostent *result_buf, char *buf, size_t buflen, +- struct hostent **result, int *h_errnop) ++ struct hostent **result, int *h_errnop) + { +- int ret; ++ int ret = 0; + +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + if (__gethostent_fp == NULL) { +- __open_etc_hosts(&__gethostent_fp); +- if (__gethostent_fp == NULL) { +- UNLOCK; +- *result=NULL; +- return 0; +- } ++ __open_etc_hosts(&__gethostent_fp); ++ if (__gethostent_fp == NULL) { ++ *result=NULL; ++ goto DONE; ++ } + } + + ret = __read_etc_hosts_r(__gethostent_fp, NULL, AF_INET, GETHOSTENT, +- result_buf, buf, buflen, result, h_errnop); ++ result_buf, buf, buflen, result, h_errnop); + if (__stay_open==0) { +- fclose(__gethostent_fp); ++ fclose(__gethostent_fp); + } +- UNLOCK; ++ DONE: ++ __UCLIBC_MUTEX_UNLOCK(mylock); + return(ret); + } + +@@ -1634,17 +1615,17 @@ struct hostent *gethostent (void) + static struct hostent h; + static char buf[ + #ifndef __UCLIBC_HAS_IPV6__ +- sizeof(struct in_addr) + sizeof(struct in_addr *)*2 + ++ sizeof(struct in_addr) + sizeof(struct in_addr *)*2 + + #else +- sizeof(struct in6_addr) + sizeof(struct in6_addr *)*2 + ++ sizeof(struct in6_addr) + sizeof(struct in6_addr *)*2 + + #endif /* __UCLIBC_HAS_IPV6__ */ +- sizeof(char *)*(ALIAS_DIM) + +- 80/*namebuffer*/ + 2/* margin */]; ++ sizeof(char *)*(ALIAS_DIM) + ++ 80/*namebuffer*/ + 2/* margin */]; + struct hostent *host; + +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + gethostent_r(&h, buf, sizeof(buf), &host, &h_errno); +- UNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(mylock); + return(host); + } + #endif +@@ -1652,23 +1633,23 @@ struct hostent *gethostent (void) + #ifdef L_get_hosts_byname_r + + int __get_hosts_byname_r(const char * name, int type, +- struct hostent * result_buf, +- char * buf, size_t buflen, +- struct hostent ** result, +- int * h_errnop) ++ struct hostent * result_buf, ++ char * buf, size_t buflen, ++ struct hostent ** result, ++ int * h_errnop) + { + return(__read_etc_hosts_r(NULL, name, type, GET_HOSTS_BYNAME, +- result_buf, buf, buflen, result, h_errnop)); ++ result_buf, buf, buflen, result, h_errnop)); + } + #endif + + #ifdef L_get_hosts_byaddr_r + + int __get_hosts_byaddr_r(const char * addr, int len, int type, +- struct hostent * result_buf, +- char * buf, size_t buflen, +- struct hostent ** result, +- int * h_errnop) ++ struct hostent * result_buf, ++ char * buf, size_t buflen, ++ struct hostent ** result, ++ int * h_errnop) + { + #ifndef __UCLIBC_HAS_IPV6__ + char ipaddr[INET_ADDRSTRLEN]; +@@ -1677,24 +1658,24 @@ int __get_hosts_byaddr_r(const char * ad + #endif /* __UCLIBC_HAS_IPV6__ */ + + switch (type) { +- case AF_INET: +- if (len != sizeof(struct in_addr)) +- return 0; +- break; ++ case AF_INET: ++ if (len != sizeof(struct in_addr)) ++ return 0; ++ break; + #ifdef __UCLIBC_HAS_IPV6__ +- case AF_INET6: +- if (len != sizeof(struct in6_addr)) +- return 0; +- break; ++ case AF_INET6: ++ if (len != sizeof(struct in6_addr)) ++ return 0; ++ break; + #endif /* __UCLIBC_HAS_IPV6__ */ +- default: +- return 0; ++ default: ++ return 0; + } + + inet_ntop(type, addr, ipaddr, sizeof(ipaddr)); + + return(__read_etc_hosts_r(NULL, ipaddr, type, GET_HOSTS_BYADDR, +- result_buf, buf, buflen, result, h_errnop)); ++ result_buf, buf, buflen, result, h_errnop)); + } + #endif + +@@ -1705,8 +1686,8 @@ int __get_hosts_byaddr_r(const char * ad + #endif /* min */ + + int getnameinfo (const struct sockaddr *sa, socklen_t addrlen, char *host, +- socklen_t hostlen, char *serv, socklen_t servlen, +- unsigned int flags) ++ socklen_t hostlen, char *serv, socklen_t servlen, ++ unsigned int flags) + { + int serrno = errno; + int ok = 0; +@@ -1720,167 +1701,167 @@ int getnameinfo (const struct sockaddr * + return EAI_FAMILY; + + switch (sa->sa_family) { +- case AF_LOCAL: +- break; +- case AF_INET: +- if (addrlen < sizeof (struct sockaddr_in)) +- return EAI_FAMILY; +- break; ++ case AF_LOCAL: ++ break; ++ case AF_INET: ++ if (addrlen < sizeof (struct sockaddr_in)) ++ return EAI_FAMILY; ++ break; + #ifdef __UCLIBC_HAS_IPV6__ +- case AF_INET6: +- if (addrlen < sizeof (struct sockaddr_in6)) +- return EAI_FAMILY; +- break; ++ case AF_INET6: ++ if (addrlen < sizeof (struct sockaddr_in6)) ++ return EAI_FAMILY; ++ break; + #endif /* __UCLIBC_HAS_IPV6__ */ +- default: +- return EAI_FAMILY; ++ default: ++ return EAI_FAMILY; + } + + if (host != NULL && hostlen > 0) + switch (sa->sa_family) { +- case AF_INET: ++ case AF_INET: + #ifdef __UCLIBC_HAS_IPV6__ +- case AF_INET6: ++ case AF_INET6: + #endif /* __UCLIBC_HAS_IPV6__ */ +- if (!(flags & NI_NUMERICHOST)) { ++ if (!(flags & NI_NUMERICHOST)) { + #ifdef __UCLIBC_HAS_IPV6__ +- if (sa->sa_family == AF_INET6) +- h = gethostbyaddr ((const void *) +- &(((const struct sockaddr_in6 *) sa)->sin6_addr), +- sizeof(struct in6_addr), AF_INET6); +- else +-#endif /* __UCLIBC_HAS_IPV6__ */ +- h = gethostbyaddr ((const void *) &(((const struct sockaddr_in *)sa)->sin_addr), +- sizeof(struct in_addr), AF_INET); +- +- if (h) { +- char *c; +- if ((flags & NI_NOFQDN) +- && (getdomainname (domain, sizeof(domain)) == 0) +- && (c = strstr (h->h_name, domain)) +- && (c != h->h_name) && (*(--c) == '.')) { +- strncpy (host, h->h_name, +- min(hostlen, (size_t) (c - h->h_name))); +- host[min(hostlen - 1, (size_t) (c - h->h_name))] = '\0'; +- ok = 1; +- } else { +- strncpy (host, h->h_name, hostlen); +- ok = 1; ++ if (sa->sa_family == AF_INET6) ++ h = gethostbyaddr ((const void *) ++ &(((const struct sockaddr_in6 *) sa)->sin6_addr), ++ sizeof(struct in6_addr), AF_INET6); ++ else ++#endif /* __UCLIBC_HAS_IPV6__ */ ++ h = gethostbyaddr ((const void *) &(((const struct sockaddr_in *)sa)->sin_addr), ++ sizeof(struct in_addr), AF_INET); ++ ++ if (h) { ++ char *c; ++ if ((flags & NI_NOFQDN) ++ && (getdomainname (domain, sizeof(domain)) == 0) ++ && (c = strstr (h->h_name, domain)) ++ && (c != h->h_name) && (*(--c) == '.')) { ++ strncpy (host, h->h_name, ++ min(hostlen, (size_t) (c - h->h_name))); ++ host[min(hostlen - 1, (size_t) (c - h->h_name))] = '\0'; ++ ok = 1; ++ } else { ++ strncpy (host, h->h_name, hostlen); ++ ok = 1; ++ } + } +- } +- } ++ } + +- if (!ok) { +- if (flags & NI_NAMEREQD) { +- errno = serrno; +- return EAI_NONAME; +- } else { +- const char *c; ++ if (!ok) { ++ if (flags & NI_NAMEREQD) { ++ errno = serrno; ++ return EAI_NONAME; ++ } else { ++ const char *c; + #ifdef __UCLIBC_HAS_IPV6__ +- if (sa->sa_family == AF_INET6) { +- const struct sockaddr_in6 *sin6p; ++ if (sa->sa_family == AF_INET6) { ++ const struct sockaddr_in6 *sin6p; + +- sin6p = (const struct sockaddr_in6 *) sa; ++ sin6p = (const struct sockaddr_in6 *) sa; + +- c = inet_ntop (AF_INET6, +- (const void *) &sin6p->sin6_addr, host, hostlen); ++ c = inet_ntop (AF_INET6, ++ (const void *) &sin6p->sin6_addr, host, hostlen); + #if 0 +- /* Does scope id need to be supported? */ +- uint32_t scopeid; +- scopeid = sin6p->sin6_scope_id; +- if (scopeid != 0) { +- /* Buffer is >= IFNAMSIZ+1. */ +- char scopebuf[IFNAMSIZ + 1]; +- char *scopeptr; +- int ni_numericscope = 0; +- size_t real_hostlen = __strnlen (host, hostlen); +- size_t scopelen = 0; +- +- scopebuf[0] = SCOPE_DELIMITER; +- scopebuf[1] = '\0'; +- scopeptr = &scopebuf[1]; +- +- if (IN6_IS_ADDR_LINKLOCAL (&sin6p->sin6_addr) +- || IN6_IS_ADDR_MC_LINKLOCAL (&sin6p->sin6_addr)) { +- if (if_indextoname (scopeid, scopeptr) == NULL) ++ /* Does scope id need to be supported? */ ++ uint32_t scopeid; ++ scopeid = sin6p->sin6_scope_id; ++ if (scopeid != 0) { ++ /* Buffer is >= IFNAMSIZ+1. */ ++ char scopebuf[IFNAMSIZ + 1]; ++ char *scopeptr; ++ int ni_numericscope = 0; ++ size_t real_hostlen = __strnlen (host, hostlen); ++ size_t scopelen = 0; ++ ++ scopebuf[0] = SCOPE_DELIMITER; ++ scopebuf[1] = '\0'; ++ scopeptr = &scopebuf[1]; ++ ++ if (IN6_IS_ADDR_LINKLOCAL (&sin6p->sin6_addr) ++ || IN6_IS_ADDR_MC_LINKLOCAL (&sin6p->sin6_addr)) { ++ if (if_indextoname (scopeid, scopeptr) == NULL) ++ ++ni_numericscope; ++ else ++ scopelen = strlen (scopebuf); ++ } else { + ++ni_numericscope; +- else +- scopelen = strlen (scopebuf); +- } else { +- ++ni_numericscope; +- } ++ } + +- if (ni_numericscope) +- scopelen = 1 + snprintf (scopeptr, +- (scopebuf +- + sizeof scopebuf +- - scopeptr), +- "%u", scopeid); +- +- if (real_hostlen + scopelen + 1 > hostlen) +- return EAI_SYSTEM; +- memcpy (host + real_hostlen, scopebuf, scopelen + 1); +- } ++ if (ni_numericscope) ++ scopelen = 1 + snprintf (scopeptr, ++ (scopebuf ++ + sizeof scopebuf ++ - scopeptr), ++ "%u", scopeid); ++ ++ if (real_hostlen + scopelen + 1 > hostlen) ++ return EAI_SYSTEM; ++ memcpy (host + real_hostlen, scopebuf, scopelen + 1); ++ } + #endif +- } else ++ } else + #endif /* __UCLIBC_HAS_IPV6__ */ +- c = inet_ntop (AF_INET, (const void *) +- &(((const struct sockaddr_in *) sa)->sin_addr), +- host, hostlen); +- +- if (c == NULL) { +- errno = serrno; +- return EAI_SYSTEM; ++ c = inet_ntop (AF_INET, (const void *) ++ &(((const struct sockaddr_in *) sa)->sin_addr), ++ host, hostlen); ++ ++ if (c == NULL) { ++ errno = serrno; ++ return EAI_SYSTEM; ++ } + } ++ ok = 1; + } +- ok = 1; +- } +- break; +- +- case AF_LOCAL: +- if (!(flags & NI_NUMERICHOST)) { +- struct utsname utsname; ++ break; + +- if (!uname (&utsname)) { +- strncpy (host, utsname.nodename, hostlen); +- break; ++ case AF_LOCAL: ++ if (!(flags & NI_NUMERICHOST)) { ++ struct utsname utsname; ++ ++ if (!uname (&utsname)) { ++ strncpy (host, utsname.nodename, hostlen); ++ break; ++ }; + }; +- }; + +- if (flags & NI_NAMEREQD) { +- errno = serrno; +- return EAI_NONAME; +- } ++ if (flags & NI_NAMEREQD) { ++ errno = serrno; ++ return EAI_NONAME; ++ } + +- strncpy (host, "localhost", hostlen); +- break; ++ strncpy (host, "localhost", hostlen); ++ break; + +- default: +- return EAI_FAMILY; +- } ++ default: ++ return EAI_FAMILY; ++ } + + if (serv && (servlen > 0)) { + switch (sa->sa_family) { +- case AF_INET: ++ case AF_INET: + #ifdef __UCLIBC_HAS_IPV6__ +- case AF_INET6: ++ case AF_INET6: + #endif /* __UCLIBC_HAS_IPV6__ */ +- if (!(flags & NI_NUMERICSERV)) { +- struct servent *s; +- s = getservbyport (((const struct sockaddr_in *) sa)->sin_port, +- ((flags & NI_DGRAM) ? "udp" : "tcp")); +- if (s) { +- strncpy (serv, s->s_name, servlen); +- break; ++ if (!(flags & NI_NUMERICSERV)) { ++ struct servent *s; ++ s = getservbyport (((const struct sockaddr_in *) sa)->sin_port, ++ ((flags & NI_DGRAM) ? "udp" : "tcp")); ++ if (s) { ++ strncpy (serv, s->s_name, servlen); ++ break; ++ } + } +- } +- snprintf (serv, servlen, "%d", +- ntohs (((const struct sockaddr_in *) sa)->sin_port)); +- break; ++ snprintf (serv, servlen, "%d", ++ ntohs (((const struct sockaddr_in *) sa)->sin_port)); ++ break; + +- case AF_LOCAL: +- strncpy (serv, ((const struct sockaddr_un *) sa)->sun_path, servlen); +- break; ++ case AF_LOCAL: ++ strncpy (serv, ((const struct sockaddr_un *) sa)->sun_path, servlen); ++ break; + } + } + if (host && (hostlen > 0)) +@@ -1896,10 +1877,10 @@ int getnameinfo (const struct sockaddr * + #ifdef L_gethostbyname_r + + int gethostbyname_r(const char * name, +- struct hostent * result_buf, +- char * buf, size_t buflen, +- struct hostent ** result, +- int * h_errnop) ++ struct hostent * result_buf, ++ char * buf, size_t buflen, ++ struct hostent ** result, ++ int * h_errnop) + { + struct in_addr *in; + struct in_addr **addr_list; +@@ -1921,7 +1902,7 @@ int gethostbyname_r(const char * name, + __set_errno(0); /* to check for missing /etc/hosts. */ + + if ((i=__get_hosts_byname_r(name, AF_INET, result_buf, +- buf, buflen, result, h_errnop))==0) ++ buf, buflen, result, h_errnop))==0) + return i; + switch (*h_errnop) { + case HOST_NOT_FOUND: +@@ -1983,60 +1964,60 @@ int gethostbyname_r(const char * name, + + for (;;) { + +- BIGLOCK; ++ __UCLIBC_MUTEX_LOCK(__resolv_lock); + __nameserversXX=__nameservers; + __nameserverXX=__nameserver; +- BIGUNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(__resolv_lock); + a.buf = buf; + a.buflen = buflen; + a.add_count = 0; + i = __dns_lookup(name, T_A, __nameserversXX, __nameserverXX, &packet, &a); + + if (i < 0) { +- *h_errnop = HOST_NOT_FOUND; +- DPRINTF("__dns_lookup\n"); +- return TRY_AGAIN; ++ *h_errnop = HOST_NOT_FOUND; ++ DPRINTF("__dns_lookup\n"); ++ return TRY_AGAIN; + } + + if ((a.rdlength + sizeof(struct in_addr*)) * a.add_count + 256 > buflen) +- { +- free(a.dotted); +- free(packet); +- *h_errnop = NETDB_INTERNAL; +- DPRINTF("buffer too small for all addresses\n"); +- return ERANGE; +- } ++ { ++ free(a.dotted); ++ free(packet); ++ *h_errnop = NETDB_INTERNAL; ++ DPRINTF("buffer too small for all addresses\n"); ++ return ERANGE; ++ } + else if(a.add_count > 0) +- { +- memmove(buf - sizeof(struct in_addr*)*2, buf, a.add_count * a.rdlength); +- addr_list = (struct in_addr**)(buf + a.add_count * a.rdlength); +- addr_list[0] = in; +- for (i = a.add_count-1; i>=0; --i) +- addr_list[i+1] = (struct in_addr*)(buf - sizeof(struct in_addr*)*2 + a.rdlength * i); +- addr_list[a.add_count + 1] = 0; +- buflen -= (((char*)&(addr_list[a.add_count + 2])) - buf); +- buf = (char*)&addr_list[a.add_count + 2]; +- } ++ { ++ memmove(buf - sizeof(struct in_addr*)*2, buf, a.add_count * a.rdlength); ++ addr_list = (struct in_addr**)(buf + a.add_count * a.rdlength); ++ addr_list[0] = in; ++ for (i = a.add_count-1; i>=0; --i) ++ addr_list[i+1] = (struct in_addr*)(buf - sizeof(struct in_addr*)*2 + a.rdlength * i); ++ addr_list[a.add_count + 1] = 0; ++ buflen -= (((char*)&(addr_list[a.add_count + 2])) - buf); ++ buf = (char*)&addr_list[a.add_count + 2]; ++ } + + strncpy(buf, a.dotted, buflen); + free(a.dotted); + + if (a.atype == T_A) { /* ADDRESS */ +- memcpy(in, a.rdata, sizeof(*in)); +- result_buf->h_name = buf; +- result_buf->h_addrtype = AF_INET; +- result_buf->h_length = sizeof(*in); +- result_buf->h_addr_list = (char **) addr_list; ++ memcpy(in, a.rdata, sizeof(*in)); ++ result_buf->h_name = buf; ++ result_buf->h_addrtype = AF_INET; ++ result_buf->h_length = sizeof(*in); ++ result_buf->h_addr_list = (char **) addr_list; + #ifdef __UCLIBC_MJN3_ONLY__ + #warning TODO -- generate the full list + #endif +- result_buf->h_aliases = alias; /* TODO: generate the full list */ +- free(packet); +- break; ++ result_buf->h_aliases = alias; /* TODO: generate the full list */ ++ free(packet); ++ break; + } else { +- free(packet); +- *h_errnop=HOST_NOT_FOUND; +- return TRY_AGAIN; ++ free(packet); ++ *h_errnop=HOST_NOT_FOUND; ++ return TRY_AGAIN; + } + } + +@@ -2049,14 +2030,14 @@ int gethostbyname_r(const char * name, + #ifdef L_gethostbyname2_r + + int gethostbyname2_r(const char *name, int family, +- struct hostent * result_buf, +- char * buf, size_t buflen, +- struct hostent ** result, +- int * h_errnop) ++ struct hostent * result_buf, ++ char * buf, size_t buflen, ++ struct hostent ** result, ++ int * h_errnop) + { + #ifndef __UCLIBC_HAS_IPV6__ + return family == (AF_INET)? gethostbyname_r(name, result_buf, +- buf, buflen, result, h_errnop) : HOST_NOT_FOUND; ++ buf, buflen, result, h_errnop) : HOST_NOT_FOUND; + #else /* __UCLIBC_HAS_IPV6__ */ + struct in6_addr *in; + struct in6_addr **addr_list; +@@ -2084,7 +2065,7 @@ int gethostbyname2_r(const char *name, i + __set_errno(0); /* to check for missing /etc/hosts. */ + + if ((i=__get_hosts_byname_r(name, AF_INET, result_buf, +- buf, buflen, result, h_errnop))==0) ++ buf, buflen, result, h_errnop))==0) + return i; + switch (*h_errnop) { + case HOST_NOT_FOUND: +@@ -2137,10 +2118,10 @@ int gethostbyname2_r(const char *name, i + memset((char *) &a, '\0', sizeof(a)); + + for (;;) { +- BIGLOCK; +- __nameserversXX=__nameservers; +- __nameserverXX=__nameserver; +- BIGUNLOCK; ++ __UCLIBC_MUTEX_LOCK(__resolv_lock); ++ __nameserversXX=__nameservers; ++ __nameserverXX=__nameserver; ++ __UCLIBC_MUTEX_UNLOCK(__resolv_lock); + + i = __dns_lookup(buf, T_AAAA, __nameserversXX, __nameserverXX, &packet, &a); + +@@ -2190,10 +2171,10 @@ int gethostbyname2_r(const char *name, i + + #ifdef L_gethostbyaddr_r + int gethostbyaddr_r (const void *addr, socklen_t len, int type, +- struct hostent * result_buf, +- char * buf, size_t buflen, +- struct hostent ** result, +- int * h_errnop) ++ struct hostent * result_buf, ++ char * buf, size_t buflen, ++ struct hostent ** result, ++ int * h_errnop) + + { + struct in_addr *in; +@@ -2234,7 +2215,7 @@ int gethostbyaddr_r (const void *addr, s + + /* do /etc/hosts first */ + if ((i=__get_hosts_byaddr_r(addr, len, type, result_buf, +- buf, buflen, result, h_errnop))==0) ++ buf, buflen, result, h_errnop))==0) + return i; + switch (*h_errnop) { + case HOST_NOT_FOUND: +@@ -2294,7 +2275,7 @@ int gethostbyaddr_r (const void *addr, s + addr_list[0] = in; + + sprintf(buf, "%u.%u.%u.%u.in-addr.arpa", +- tmp_addr[3], tmp_addr[2], tmp_addr[1], tmp_addr[0]); ++ tmp_addr[3], tmp_addr[2], tmp_addr[1], tmp_addr[0]); + #ifdef __UCLIBC_HAS_IPV6__ + } else { + memcpy(in6->s6_addr, addr, len); +@@ -2304,7 +2285,7 @@ int gethostbyaddr_r (const void *addr, s + + for (i = len - 1; i >= 0; i--) { + qp += sprintf(qp, "%x.%x.", in6->s6_addr[i] & 0xf, +- (in6->s6_addr[i] >> 4) & 0xf); ++ (in6->s6_addr[i] >> 4) & 0xf); + } + strcpy(qp, "ip6.int"); + #endif /* __UCLIBC_HAS_IPV6__ */ +@@ -2314,10 +2295,10 @@ int gethostbyaddr_r (const void *addr, s + + for (;;) { + +- BIGLOCK; +- __nameserversXX=__nameservers; +- __nameserverXX=__nameserver; +- BIGUNLOCK; ++ __UCLIBC_MUTEX_LOCK(__resolv_lock); ++ __nameserversXX=__nameservers; ++ __nameserverXX=__nameserver; ++ __UCLIBC_MUTEX_UNLOCK(__resolv_lock); + i = __dns_lookup(buf, T_PTR, __nameserversXX, __nameserverXX, &packet, &a); + + if (i < 0) { +@@ -2381,7 +2362,7 @@ int gethostbyaddr_r (const void *addr, s + * Return size of compressed name or -1 if there was an error. + */ + int __dn_expand(const u_char *msg, const u_char *eom, const u_char *src, +- char *dst, int dstsiz) ++ char *dst, int dstsiz) + { + int n = ns_name_uncompress(msg, eom, src, dst, (size_t)dstsiz); + +@@ -2401,7 +2382,7 @@ int __dn_expand(const u_char *msg, const + */ + static int printable(int ch) + { +- return (ch > 0x20 && ch < 0x7f); ++ return (ch > 0x20 && ch < 0x7f); + } + + /* +@@ -2413,18 +2394,18 @@ static int printable(int ch) + */ + static int special(int ch) + { +- switch (ch) { ++ switch (ch) { + case 0x22: /* '"' */ + case 0x2E: /* '.' */ + case 0x3B: /* ';' */ + case 0x5C: /* '\\' */ +- /* Special modifiers in zone files. */ ++ /* Special modifiers in zone files. */ + case 0x40: /* '@' */ + case 0x24: /* '$' */ +- return (1); ++ return (1); + default: +- return (0); +- } ++ return (0); ++ } + } + + /* +@@ -2436,7 +2417,7 @@ static int special(int ch) + * Root domain returns as "." not "". + */ + int __ns_name_uncompress(const u_char *msg, const u_char *eom, +- const u_char *src, char *dst, size_t dstsiz) ++ const u_char *src, char *dst, size_t dstsiz) + { + u_char tmp[NS_MAXCDNAME]; + int n; +@@ -2525,7 +2506,7 @@ int __ns_name_ntop(const u_char *src, ch + return (-1); + } + *dn++ = '\0'; +- return (dn - dst); ++ return (dn - dst); + } + + /* +@@ -2535,7 +2516,7 @@ int __ns_name_ntop(const u_char *src, ch + * -1 if it fails, or consumed octets if it succeeds. + */ + int __ns_name_unpack(const u_char *msg, const u_char *eom, const u_char *src, +- u_char *dst, size_t dstsiz) ++ u_char *dst, size_t dstsiz) + { + const u_char *srcp, *dstlim; + u_char *dstp; +@@ -2554,46 +2535,46 @@ int __ns_name_unpack(const u_char *msg, + while ((n = *srcp++) != 0) { + /* Check for indirection. */ + switch (n & NS_CMPRSFLGS) { +- case 0: +- /* Limit checks. */ +- if (dstp + n + 1 >= dstlim || srcp + n >= eom) { +- __set_errno (EMSGSIZE); +- return (-1); +- } +- checked += n + 1; +- *dstp++ = n; +- memcpy(dstp, srcp, n); +- dstp += n; +- srcp += n; +- break; ++ case 0: ++ /* Limit checks. */ ++ if (dstp + n + 1 >= dstlim || srcp + n >= eom) { ++ __set_errno (EMSGSIZE); ++ return (-1); ++ } ++ checked += n + 1; ++ *dstp++ = n; ++ memcpy(dstp, srcp, n); ++ dstp += n; ++ srcp += n; ++ break; + +- case NS_CMPRSFLGS: +- if (srcp >= eom) { +- __set_errno (EMSGSIZE); +- return (-1); +- } +- if (len < 0) +- len = srcp - src + 1; +- srcp = msg + (((n & 0x3f) << 8) | (*srcp & 0xff)); +- if (srcp < msg || srcp >= eom) { /* Out of range. */ +- __set_errno (EMSGSIZE); +- return (-1); +- } +- checked += 2; +- /* +- * Check for loops in the compressed name; +- * if we've looked at the whole message, +- * there must be a loop. +- */ +- if (checked >= eom - msg) { +- __set_errno (EMSGSIZE); +- return (-1); +- } +- break; ++ case NS_CMPRSFLGS: ++ if (srcp >= eom) { ++ __set_errno (EMSGSIZE); ++ return (-1); ++ } ++ if (len < 0) ++ len = srcp - src + 1; ++ srcp = msg + (((n & 0x3f) << 8) | (*srcp & 0xff)); ++ if (srcp < msg || srcp >= eom) { /* Out of range. */ ++ __set_errno (EMSGSIZE); ++ return (-1); ++ } ++ checked += 2; ++ /* ++ * Check for loops in the compressed name; ++ * if we've looked at the whole message, ++ * there must be a loop. ++ */ ++ if (checked >= eom - msg) { ++ __set_errno (EMSGSIZE); ++ return (-1); ++ } ++ break; + +- default: +- __set_errno (EMSGSIZE); +- return (-1); /* flag error */ ++ default: ++ __set_errno (EMSGSIZE); ++ return (-1); /* flag error */ + } + } + *dstp = '\0'; +diff --git a/libc/inet/rpc/create_xid.c b/libc/inet/rpc/create_xid.c +index cbb961e..c86cbb4 100644 +--- a/libc/inet/rpc/create_xid.c ++++ b/libc/inet/rpc/create_xid.c +@@ -27,15 +27,7 @@ + + /* The RPC code is not threadsafe, but new code should be threadsafe. */ + +-#ifdef __UCLIBC_HAS_THREADS__ +-#include +-static pthread_mutex_t createxid_lock = PTHREAD_MUTEX_INITIALIZER; +-# define LOCK __pthread_mutex_lock(&createxid_lock) +-# define UNLOCK __pthread_mutex_unlock(&createxid_lock); +-#else +-# define LOCK +-# define UNLOCK +-#endif ++__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER); + + static int is_initialized; + static struct drand48_data __rpc_lrand48_data; +@@ -43,22 +35,22 @@ static struct drand48_data __rpc_lrand48 + unsigned long + _create_xid (void) + { +- unsigned long res; ++ unsigned long res; + +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + +- if (!is_initialized) +- { +- struct timeval now; ++ if (!is_initialized) ++ { ++ struct timeval now; + +- gettimeofday (&now, (struct timezone *) 0); +- srand48_r (now.tv_sec ^ now.tv_usec, &__rpc_lrand48_data); +- is_initialized = 1; +- } ++ gettimeofday (&now, (struct timezone *) 0); ++ srand48_r (now.tv_sec ^ now.tv_usec, &__rpc_lrand48_data); ++ is_initialized = 1; ++ } + +- lrand48_r (&__rpc_lrand48_data, &res); ++ lrand48_r (&__rpc_lrand48_data, &res); + +- UNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(mylock); + +- return res; ++ return res; + } +diff --git a/libc/misc/dirent/closedir.c b/libc/misc/dirent/closedir.c +index 068e2d3..56adb23 100644 +--- a/libc/misc/dirent/closedir.c ++++ b/libc/misc/dirent/closedir.c +@@ -4,7 +4,6 @@ + #include + #include "dirstream.h" + +- + int closedir(DIR * dir) + { + int fd; +@@ -19,14 +18,10 @@ int closedir(DIR * dir) + __set_errno(EBADF); + return -1; + } +-#ifdef __UCLIBC_HAS_THREADS__ +- __pthread_mutex_lock(&(dir->dd_lock)); +-#endif ++ __UCLIBC_MUTEX_LOCK(dir->dd_lock); + fd = dir->dd_fd; + dir->dd_fd = -1; +-#ifdef __UCLIBC_HAS_THREADS__ +- __pthread_mutex_unlock(&(dir->dd_lock)); +-#endif ++ __UCLIBC_MUTEX_UNLOCK(dir->dd_lock); + free(dir->dd_buf); + free(dir); + return close(fd); +diff --git a/libc/misc/dirent/dirstream.h b/libc/misc/dirent/dirstream.h +index 2dd0264..bd721c5 100644 +--- a/libc/misc/dirent/dirstream.h ++++ b/libc/misc/dirent/dirstream.h +@@ -26,9 +26,8 @@ Cambridge, MA 02139, USA. */ + + #include + #include +-#ifdef __UCLIBC_HAS_THREADS__ +-#include +-#endif ++ ++#include + + /* For now, syscall readdir () only supports one entry at a time. It + * will be changed in the future. +@@ -63,11 +62,7 @@ struct __dirstream { + size_t dd_max; + + /* lock */ +-#ifdef __UCLIBC_HAS_THREADS__ +- pthread_mutex_t dd_lock; +-#else +- void *dd_lock; +-#endif ++ __UCLIBC_MUTEX(dd_lock); + }; /* stream data from opendir() */ + + +diff --git a/libc/misc/dirent/readdir.c b/libc/misc/dirent/readdir.c +index 1f196e1..c55317a 100644 +--- a/libc/misc/dirent/readdir.c ++++ b/libc/misc/dirent/readdir.c +@@ -5,7 +5,6 @@ + #include + #include "dirstream.h" + +- + struct dirent *readdir(DIR * dir) + { + ssize_t bytes; +@@ -16,9 +15,7 @@ struct dirent *readdir(DIR * dir) + return NULL; + } + +-#ifdef __UCLIBC_HAS_THREADS__ +- __pthread_mutex_lock(&(dir->dd_lock)); +-#endif ++ __UCLIBC_MUTEX_LOCK(dir->dd_lock); + + do { + if (dir->dd_size <= dir->dd_nextloc) { +@@ -44,8 +41,6 @@ struct dirent *readdir(DIR * dir) + } while (de->d_ino == 0); + + all_done: +-#ifdef __UCLIBC_HAS_THREADS__ +- __pthread_mutex_unlock(&(dir->dd_lock)); +-#endif ++ __UCLIBC_MUTEX_UNLOCK(dir->dd_lock); + return de; + } +diff --git a/libc/misc/dirent/readdir64.c b/libc/misc/dirent/readdir64.c +index f798c6f..6da3b0d 100644 +--- a/libc/misc/dirent/readdir64.c ++++ b/libc/misc/dirent/readdir64.c +@@ -20,7 +20,6 @@ + #include + #include "dirstream.h" + +- + struct dirent64 *readdir64(DIR * dir) + { + ssize_t bytes; +@@ -31,9 +30,7 @@ struct dirent64 *readdir64(DIR * dir) + return NULL; + } + +-#ifdef __UCLIBC_HAS_THREADS__ +- __pthread_mutex_lock(&(dir->dd_lock)); +-#endif ++ __UCLIBC_MUTEX_LOCK(dir->dd_lock); + + do { + if (dir->dd_size <= dir->dd_nextloc) { +@@ -59,9 +56,7 @@ struct dirent64 *readdir64(DIR * dir) + } while (de->d_ino == 0); + + all_done: +-#ifdef __UCLIBC_HAS_THREADS__ +- __pthread_mutex_unlock(&(dir->dd_lock)); +-#endif ++ __UCLIBC_MUTEX_UNLOCK(dir->dd_lock); + + return de; + } +diff --git a/libc/misc/dirent/readdir64_r.c b/libc/misc/dirent/readdir64_r.c +index da3564e..cc96eff 100644 +--- a/libc/misc/dirent/readdir64_r.c ++++ b/libc/misc/dirent/readdir64_r.c +@@ -19,7 +19,6 @@ + #include + #include "dirstream.h" + +- + int readdir64_r(DIR *dir, struct dirent64 *entry, struct dirent64 **result) + { + int ret; +@@ -32,21 +31,19 @@ int readdir64_r(DIR *dir, struct dirent6 + } + de = NULL; + +-#ifdef __UCLIBC_HAS_THREADS__ +- __pthread_mutex_lock(&(dir->dd_lock)); +-#endif ++ __UCLIBC_MUTEX_LOCK(dir->dd_lock); + + do { + if (dir->dd_size <= dir->dd_nextloc) { +- /* read dir->dd_max bytes of directory entries. */ +- bytes = __getdents64(dir->dd_fd, dir->dd_buf, dir->dd_max); +- if (bytes <= 0) { +- *result = NULL; +- ret = errno; +- goto all_done; +- } +- dir->dd_size = bytes; +- dir->dd_nextloc = 0; ++ /* read dir->dd_max bytes of directory entries. */ ++ bytes = __getdents64(dir->dd_fd, dir->dd_buf, dir->dd_max); ++ if (bytes <= 0) { ++ *result = NULL; ++ ret = errno; ++ goto all_done; ++ } ++ dir->dd_size = bytes; ++ dir->dd_nextloc = 0; + } + + de = (struct dirent64 *) (((char *) dir->dd_buf) + dir->dd_nextloc); +@@ -66,12 +63,10 @@ int readdir64_r(DIR *dir, struct dirent6 + } + ret = 0; + +-all_done: ++ all_done: + +-#ifdef __UCLIBC_HAS_THREADS__ +- __pthread_mutex_unlock(&(dir->dd_lock)); +-#endif +- return((de != NULL)? 0 : ret); ++ __UCLIBC_MUTEX_UNLOCK(dir->dd_lock); ++ return((de != NULL)? 0 : ret); + } + #endif /* __UCLIBC_HAS_LFS__ */ + +diff --git a/libc/misc/dirent/readdir_r.c b/libc/misc/dirent/readdir_r.c +index 245dcbd..aeccdd8 100644 +--- a/libc/misc/dirent/readdir_r.c ++++ b/libc/misc/dirent/readdir_r.c +@@ -5,7 +5,6 @@ + #include + #include "dirstream.h" + +- + int readdir_r(DIR *dir, struct dirent *entry, struct dirent **result) + { + int ret; +@@ -18,21 +17,19 @@ int readdir_r(DIR *dir, struct dirent *e + } + de = NULL; + +-#ifdef __UCLIBC_HAS_THREADS__ +- __pthread_mutex_lock(&(dir->dd_lock)); +-#endif ++ __UCLIBC_MUTEX_LOCK(dir->dd_lock); + + do { + if (dir->dd_size <= dir->dd_nextloc) { +- /* read dir->dd_max bytes of directory entries. */ +- bytes = __getdents(dir->dd_fd, dir->dd_buf, dir->dd_max); +- if (bytes <= 0) { +- *result = NULL; +- ret = errno; +- goto all_done; +- } +- dir->dd_size = bytes; +- dir->dd_nextloc = 0; ++ /* read dir->dd_max bytes of directory entries. */ ++ bytes = __getdents(dir->dd_fd, dir->dd_buf, dir->dd_max); ++ if (bytes <= 0) { ++ *result = NULL; ++ ret = errno; ++ goto all_done; ++ } ++ dir->dd_size = bytes; ++ dir->dd_nextloc = 0; + } + + de = (struct dirent *) (((char *) dir->dd_buf) + dir->dd_nextloc); +@@ -52,10 +49,8 @@ int readdir_r(DIR *dir, struct dirent *e + } + ret = 0; + +-all_done: ++ all_done: + +-#ifdef __UCLIBC_HAS_THREADS__ +- __pthread_mutex_unlock(&(dir->dd_lock)); +-#endif +- return((de != NULL)? 0 : ret); ++ __UCLIBC_MUTEX_UNLOCK(dir->dd_lock); ++ return((de != NULL)? 0 : ret); + } +diff --git a/libc/misc/dirent/rewinddir.c b/libc/misc/dirent/rewinddir.c +index 60ef71d..fe8fc2a 100644 +--- a/libc/misc/dirent/rewinddir.c ++++ b/libc/misc/dirent/rewinddir.c +@@ -3,7 +3,6 @@ + #include + #include "dirstream.h" + +- + /* rewinddir() just does an lseek(fd,0,0) - see close for comments */ + void rewinddir(DIR * dir) + { +@@ -11,12 +10,8 @@ void rewinddir(DIR * dir) + __set_errno(EBADF); + return; + } +-#ifdef __UCLIBC_HAS_THREADS__ +- __pthread_mutex_lock(&(dir->dd_lock)); +-#endif ++ __UCLIBC_MUTEX_LOCK(dir->dd_lock); + lseek(dir->dd_fd, 0, SEEK_SET); + dir->dd_nextoff = dir->dd_nextloc = dir->dd_size = 0; +-#ifdef __UCLIBC_HAS_THREADS__ +- __pthread_mutex_unlock(&(dir->dd_lock)); +-#endif ++ __UCLIBC_MUTEX_UNLOCK(dir->dd_lock); + } +diff --git a/libc/misc/dirent/seekdir.c b/libc/misc/dirent/seekdir.c +index 139f1e1..6d6f5f0 100644 +--- a/libc/misc/dirent/seekdir.c ++++ b/libc/misc/dirent/seekdir.c +@@ -3,19 +3,14 @@ + #include + #include "dirstream.h" + +- + void seekdir(DIR * dir, long int offset) + { + if (!dir) { + __set_errno(EBADF); + return; + } +-#ifdef __UCLIBC_HAS_THREADS__ +- __pthread_mutex_lock(&(dir->dd_lock)); +-#endif ++ __UCLIBC_MUTEX_LOCK(dir->dd_lock); + dir->dd_nextoff = lseek(dir->dd_fd, offset, SEEK_SET); + dir->dd_size = dir->dd_nextloc = 0; +-#ifdef __UCLIBC_HAS_THREADS__ +- __pthread_mutex_unlock(&(dir->dd_lock)); +-#endif ++ __UCLIBC_MUTEX_UNLOCK(dir->dd_lock); + } +diff --git a/libc/misc/mntent/mntent.c b/libc/misc/mntent/mntent.c +index d98a687..af6d848 100644 +--- a/libc/misc/mntent/mntent.c ++++ b/libc/misc/mntent/mntent.c +@@ -3,15 +3,9 @@ + #include + #include + +-#ifdef __UCLIBC_HAS_THREADS__ +-#include +-static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER; +-# define LOCK __pthread_mutex_lock(&mylock) +-# define UNLOCK __pthread_mutex_unlock(&mylock); +-#else +-# define LOCK +-# define UNLOCK +-#endif ++#include ++ ++__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER); + + /* Reentrant version of getmntent. */ + struct mntent *getmntent_r (FILE *filep, +@@ -67,7 +61,7 @@ struct mntent *getmntent(FILE * filep) + struct mntent *tmp; + static char *buff = NULL; + static struct mntent mnt; +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + + if (!buff) { + buff = malloc(BUFSIZ); +@@ -76,7 +70,7 @@ struct mntent *getmntent(FILE * filep) + } + + tmp = getmntent_r(filep, &mnt, buff, BUFSIZ); +- UNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(mylock); + return(tmp); + } + +diff --git a/libc/misc/pthread/weaks.c b/libc/misc/pthread/weaks.c +index 89c2611..c27bd10 100644 +--- a/libc/misc/pthread/weaks.c ++++ b/libc/misc/pthread/weaks.c +@@ -21,6 +21,7 @@ + #include + #include + ++static void __pthread_return_void __P ((void)); + static int __pthread_return_0 __P ((void)); + static int __pthread_return_1 __P ((void)); + +@@ -104,8 +105,17 @@ weak_alias (__pthread_return_0, __pthrea + weak_alias (__pthread_return_0, __pthread_mutex_trylock) + weak_alias (__pthread_return_0, __pthread_mutex_unlock) + ++weak_alias (__pthread_return_void, _pthread_cleanup_push_defer) ++weak_alias (__pthread_return_void, _pthread_cleanup_pop_restore) ++ + /**********************************************************************/ + ++static void ++__pthread_return_void (void) ++{ ++ return; ++} ++ + static int + __pthread_return_0 (void) + { +diff --git a/libc/misc/syslog/syslog.c b/libc/misc/syslog/syslog.c +index 2b478e1..9e9ddbf 100644 +--- a/libc/misc/syslog/syslog.c ++++ b/libc/misc/syslog/syslog.c +@@ -80,17 +80,9 @@ + #include + #include + ++#include + +-#ifdef __UCLIBC_HAS_THREADS__ +-#include +-static pthread_mutex_t mylock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; +-# define LOCK __pthread_mutex_lock(&mylock) +-# define UNLOCK __pthread_mutex_unlock(&mylock); +-#else +-# define LOCK +-# define UNLOCK +-#endif +- ++__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP); + + static int LogFile = -1; /* fd for log */ + static int connected; /* have done connect */ +@@ -110,26 +102,26 @@ int setlogmask(int pmask); + static void + closelog_intern(int to_default) + { +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + if (LogFile != -1) { + (void) close(LogFile); + } + LogFile = -1; + connected = 0; + if (to_default) +- { +- LogStat = 0; +- LogTag = "syslog"; +- LogFacility = LOG_USER; +- LogMask = 0xff; +- } +- UNLOCK; ++ { ++ LogStat = 0; ++ LogTag = "syslog"; ++ LogFacility = LOG_USER; ++ LogMask = 0xff; ++ } ++ __UCLIBC_MUTEX_UNLOCK(mylock); + } + + static void + sigpipe_handler (int sig) + { +- closelog_intern (0); ++ closelog_intern (0); + } + + /* +@@ -165,7 +157,7 @@ vsyslog( int pri, const char *fmt, va_li + + saved_errno = errno; + +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + + /* See if we should just throw out this message. */ + if (!(LogMask & LOG_MASK(LOG_PRI(pri))) || (pri &~ (LOG_PRIMASK|LOG_FACMASK))) +@@ -208,7 +200,7 @@ vsyslog( int pri, const char *fmt, va_li + if (p >= end || p < head_end) { /* Returned -1 in case of error... */ + static const char truncate_msg[12] = "[truncated] "; + memmove(head_end + sizeof(truncate_msg), head_end, +- end - head_end - sizeof(truncate_msg)); ++ end - head_end - sizeof(truncate_msg)); + memcpy(head_end, truncate_msg, sizeof(truncate_msg)); + if (p < head_end) { + while (p < end && *p) { +@@ -261,11 +253,11 @@ vsyslog( int pri, const char *fmt, va_li + (void)close(fd); + } + +-getout: +- UNLOCK; ++ getout: ++ __UCLIBC_MUTEX_UNLOCK(mylock); + if (sigpipe == 0) + sigaction (SIGPIPE, &oldaction, +- (struct sigaction *) NULL); ++ (struct sigaction *) NULL); + } + + /* +@@ -276,48 +268,48 @@ openlog( const char *ident, int logstat, + { + int logType = SOCK_DGRAM; + +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + + if (ident != NULL) +- LogTag = ident; ++ LogTag = ident; + LogStat = logstat; + if (logfac != 0 && (logfac &~ LOG_FACMASK) == 0) +- LogFacility = logfac; ++ LogFacility = logfac; + if (LogFile == -1) { +- SyslogAddr.sa_family = AF_UNIX; +- (void)strncpy(SyslogAddr.sa_data, _PATH_LOG, +- sizeof(SyslogAddr.sa_data)); +-retry: +- if (LogStat & LOG_NDELAY) { +- if ((LogFile = socket(AF_UNIX, logType, 0)) == -1){ +- UNLOCK; +- return; +- } +- /* fcntl(LogFile, F_SETFD, 1); */ +- } ++ SyslogAddr.sa_family = AF_UNIX; ++ (void)strncpy(SyslogAddr.sa_data, _PATH_LOG, ++ sizeof(SyslogAddr.sa_data)); ++ retry: ++ if (LogStat & LOG_NDELAY) { ++ if ((LogFile = socket(AF_UNIX, logType, 0)) == -1){ ++ goto DONE; ++ } ++ /* fcntl(LogFile, F_SETFD, 1); */ ++ } + } + + if (LogFile != -1 && !connected) { +- if (connect(LogFile, &SyslogAddr, sizeof(SyslogAddr) - +- sizeof(SyslogAddr.sa_data) + strlen(SyslogAddr.sa_data)) != -1) +- { +- connected = 1; +- } else if (logType == SOCK_DGRAM) { +- logType = SOCK_STREAM; +- if (LogFile != -1) { +- close(LogFile); +- LogFile = -1; +- } +- goto retry; +- } else { +- if (LogFile != -1) { +- close(LogFile); +- LogFile = -1; +- } +- } ++ if (connect(LogFile, &SyslogAddr, sizeof(SyslogAddr) - ++ sizeof(SyslogAddr.sa_data) + strlen(SyslogAddr.sa_data)) != -1) ++ { ++ connected = 1; ++ } else if (logType == SOCK_DGRAM) { ++ logType = SOCK_STREAM; ++ if (LogFile != -1) { ++ close(LogFile); ++ LogFile = -1; ++ } ++ goto retry; ++ } else { ++ if (LogFile != -1) { ++ close(LogFile); ++ LogFile = -1; ++ } ++ } + } + +- UNLOCK; ++ DONE: ++ __UCLIBC_MUTEX_UNLOCK(mylock); + } + + /* +@@ -335,10 +327,10 @@ int setlogmask(int pmask) + int omask; + + omask = LogMask; +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + if (pmask != 0) +- LogMask = pmask; +- UNLOCK; ++ LogMask = pmask; ++ __UCLIBC_MUTEX_UNLOCK(mylock); + return (omask); + } + +diff --git a/libc/misc/time/time.c b/libc/misc/time/time.c +index f43bb8a..6165a52 100644 +--- a/libc/misc/time/time.c ++++ b/libc/misc/time/time.c +@@ -143,6 +143,8 @@ + #include + #include + ++#include ++ + #ifdef __UCLIBC_HAS_XLOCALE__ + #include + #endif +@@ -191,21 +193,7 @@ typedef struct { + char tzname[TZNAME_MAX+1]; + } rule_struct; + +-#ifdef __UCLIBC_HAS_THREADS__ +- +-#include +- +-extern pthread_mutex_t _time_tzlock; +- +-#define TZLOCK __pthread_mutex_lock(&_time_tzlock) +-#define TZUNLOCK __pthread_mutex_unlock(&_time_tzlock) +- +-#else +- +-#define TZLOCK ((void) 0) +-#define TZUNLOCK ((void) 0) +- +-#endif ++__UCLIBC_MUTEX_EXTERN(_time_tzlock); + + extern rule_struct _time_tzinfo[2]; + +@@ -542,13 +530,13 @@ struct tm *localtime(const time_t *timer + struct tm *localtime_r(register const time_t *__restrict timer, + register struct tm *__restrict result) + { +- TZLOCK; ++ __UCLIBC_MUTEX_LOCK(_time_tzlock); + + tzset(); + + __time_localtime_tzi(timer, result, _time_tzinfo); + +- TZUNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(_time_tzlock); + + return result; + } +@@ -1037,7 +1025,7 @@ size_t __XL(strftime)(char *__restrict s + goto LOOP; + } + +- o = spec + 26; /* set to "????" */ ++ o = ((const char *) spec) + 26; /* set to "????" */ + if ((code & MASK_SPEC) == CALC_SPEC) { + + if (*p == 's') { +@@ -1073,17 +1061,15 @@ size_t __XL(strftime)(char *__restrict s + + #ifdef __UCLIBC_HAS_TM_EXTENSIONS__ + +-#define RSP_TZUNLOCK ((void) 0) + #define RSP_TZNAME timeptr->tm_zone + #define RSP_GMT_OFFSET (-timeptr->tm_gmtoff) + + #else + +-#define RSP_TZUNLOCK TZUNLOCK + #define RSP_TZNAME rsp->tzname + #define RSP_GMT_OFFSET rsp->gmt_offset + +- TZLOCK; ++ __UCLIBC_MUTEX_LOCK(_time_tzlock); + + rsp = _time_tzinfo; + if (timeptr->tm_isdst > 0) { +@@ -1114,15 +1100,17 @@ size_t __XL(strftime)(char *__restrict s + } + #endif + o_count = SIZE_MAX; +- RSP_TZUNLOCK; ++/* RSP_TZUNLOCK; */ ++#ifdef __UCLIBC_HAS_TM_EXTENSIONS__ + goto OUTPUT; ++#endif + } else { /* z */ + *s = '+'; + if ((tzo = -RSP_GMT_OFFSET) < 0) { + tzo = -tzo; + *s = '-'; + } +- RSP_TZUNLOCK; ++/* RSP_TZUNLOCK; */ + ++s; + --count; + +@@ -1131,7 +1119,13 @@ size_t __XL(strftime)(char *__restrict s + + i = 16 + 6; /* 0-fill, width = 4 */ + } +- ++#ifdef __UCLIBC_HAS_TM_EXTENSIONS__ ++#else ++ __UCLIBC_MUTEX_UNLOCK(_time_tzlock); ++ if (*p == 'Z') { ++ goto OUTPUT; ++ } ++#endif + } else { + /* TODO: don't need year for U, W */ + for (i=0 ; i < 3 ; i++) { +@@ -1664,9 +1658,7 @@ int daylight = 0; + long timezone = 0; + char *tzname[2] = { (char *) UTC, (char *) (UTC-1) }; + +-#ifdef __UCLIBC_HAS_THREADS__ +-pthread_mutex_t _time_tzlock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; +-#endif ++__UCLIBC_MUTEX_INIT(_time_tzlock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP); + + rule_struct _time_tzinfo[2]; + +@@ -1796,7 +1788,7 @@ void tzset(void) + static char oldval[TZ_BUFLEN]; /* BSS-zero'd. */ + #endif /* __UCLIBC_HAS_TZ_CACHING__ */ + +- TZLOCK; ++ __UCLIBC_MUTEX_LOCK(_time_tzlock); + + e = getenv(TZ); /* TZ env var always takes precedence. */ + +@@ -1962,10 +1954,10 @@ void tzset(void) + daylight = !!_time_tzinfo[1].tzname[0]; + timezone = _time_tzinfo[0].gmt_offset; + +-#if defined(__UCLIBC_HAS_TZ_FILE__) ++#if defined(__UCLIBC_HAS_TZ_FILE__) || defined(__UCLIBC_HAS_TZ_CACHING__) + FAST_DONE: + #endif +- TZUNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(_time_tzlock); + } + + #endif +@@ -2167,13 +2159,13 @@ time_t _time_mktime(struct tm *timeptr, + { + time_t t; + +- TZLOCK; ++ __UCLIBC_MUTEX_LOCK(_time_tzlock); + + tzset(); + + t = _time_mktime_tzi(timeptr, store_on_success, _time_tzinfo); + +- TZUNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(_time_tzlock); + + return t; + } +diff --git a/libc/misc/ttyent/getttyent.c b/libc/misc/ttyent/getttyent.c +index 6e2fbd2..c85c73a 100644 +--- a/libc/misc/ttyent/getttyent.c ++++ b/libc/misc/ttyent/getttyent.c +@@ -35,9 +35,6 @@ + #include + #include + #include +-#ifdef __UCLIBC_HAS_THREADS__ +-#include +-#endif + + static char zapchar; + static FILE *tf; +@@ -50,8 +47,8 @@ struct ttyent * getttynam(const char *tt + + setttyent(); + while ((t = getttyent())) +- if (!strcmp(tty, t->ty_name)) +- break; ++ if (!strcmp(tty, t->ty_name)) ++ break; + endttyent(); + return (t); + } +@@ -67,27 +64,27 @@ static char * skip(register char *p) + register int c, q; + + for (q = 0, t = p; (c = *p) != '\0'; p++) { +- if (c == '"') { +- q ^= QUOTED; /* obscure, but nice */ +- continue; +- } +- if (q == QUOTED && *p == '\\' && *(p+1) == '"') +- p++; +- *t++ = *p; +- if (q == QUOTED) +- continue; +- if (c == '#') { +- zapchar = c; +- *p = 0; +- break; +- } +- if (c == '\t' || c == ' ' || c == '\n') { +- zapchar = c; +- *p++ = 0; +- while ((c = *p) == '\t' || c == ' ' || c == '\n') +- p++; +- break; +- } ++ if (c == '"') { ++ q ^= QUOTED; /* obscure, but nice */ ++ continue; ++ } ++ if (q == QUOTED && *p == '\\' && *(p+1) == '"') ++ p++; ++ *t++ = *p; ++ if (q == QUOTED) ++ continue; ++ if (c == '#') { ++ zapchar = c; ++ *p = 0; ++ break; ++ } ++ if (c == '\t' || c == ' ' || c == '\n') { ++ zapchar = c; ++ *p++ = 0; ++ while ((c = *p) == '\t' || c == ' ' || c == '\n') ++ p++; ++ break; ++ } + } + *--t = '\0'; + return (p); +@@ -104,46 +101,46 @@ struct ttyent * getttyent(void) + register int c; + register char *p; + static char *line = NULL; ++ struct ttyent *retval = NULL; + + if (!tf && !setttyent()) +- return (NULL); ++ return (NULL); + + if (!line) { +- line = malloc(BUFSIZ); ++ line = malloc(BUFSIZ); + if (!line) + abort(); + } + +- __STDIO_ALWAYS_THREADLOCK(tf); ++ __STDIO_ALWAYS_THREADLOCK(tf); + + for (;;) { +- if (!fgets_unlocked(p = line, BUFSIZ, tf)) { +- __STDIO_ALWAYS_THREADUNLOCK(tf); +- return (NULL); +- } +- /* skip lines that are too big */ +- if (!index(p, '\n')) { +- while ((c = getc_unlocked(tf)) != '\n' && c != EOF) +- ; +- continue; +- } +- while (isspace(*p)) +- ++p; +- if (*p && *p != '#') +- break; ++ if (!fgets_unlocked(p = line, BUFSIZ, tf)) { ++ goto DONE; ++ } ++ /* skip lines that are too big */ ++ if (!index(p, '\n')) { ++ while ((c = getc_unlocked(tf)) != '\n' && c != EOF) ++ ; ++ continue; ++ } ++ while (isspace(*p)) ++ ++p; ++ if (*p && *p != '#') ++ break; + } + + zapchar = 0; + tty.ty_name = p; + p = skip(p); + if (!*(tty.ty_getty = p)) +- tty.ty_getty = tty.ty_type = NULL; ++ tty.ty_getty = tty.ty_type = NULL; + else { +- p = skip(p); +- if (!*(tty.ty_type = p)) +- tty.ty_type = NULL; +- else +- p = skip(p); ++ p = skip(p); ++ if (!*(tty.ty_type = p)) ++ tty.ty_type = NULL; ++ else ++ p = skip(p); + } + tty.ty_status = 0; + tty.ty_window = NULL; +@@ -151,43 +148,45 @@ struct ttyent * getttyent(void) + #define scmp(e) !strncmp(p, e, sizeof(e) - 1) && isspace(p[sizeof(e) - 1]) + #define vcmp(e) !strncmp(p, e, sizeof(e) - 1) && p[sizeof(e) - 1] == '=' + for (; *p; p = skip(p)) { +- if (scmp(_TTYS_OFF)) +- tty.ty_status &= ~TTY_ON; +- else if (scmp(_TTYS_ON)) +- tty.ty_status |= TTY_ON; +- else if (scmp(_TTYS_SECURE)) +- tty.ty_status |= TTY_SECURE; +- else if (vcmp(_TTYS_WINDOW)) +- tty.ty_window = value(p); +- else +- break; ++ if (scmp(_TTYS_OFF)) ++ tty.ty_status &= ~TTY_ON; ++ else if (scmp(_TTYS_ON)) ++ tty.ty_status |= TTY_ON; ++ else if (scmp(_TTYS_SECURE)) ++ tty.ty_status |= TTY_SECURE; ++ else if (vcmp(_TTYS_WINDOW)) ++ tty.ty_window = value(p); ++ else ++ break; + } +- /* We can release the lock only here since `zapchar' is global. */ +- __STDIO_ALWAYS_THREADUNLOCK(tf); + + if (zapchar == '#' || *p == '#') +- while ((c = *++p) == ' ' || c == '\t') +- ; ++ while ((c = *++p) == ' ' || c == '\t') ++ ; + tty.ty_comment = p; + if (*p == 0) +- tty.ty_comment = 0; ++ tty.ty_comment = 0; + if ((p = index(p, '\n'))) +- *p = '\0'; +- return (&tty); ++ *p = '\0'; ++ retval = &tty; ++ ++ DONE: ++ __STDIO_ALWAYS_THREADUNLOCK(tf); ++ return retval; + } + + int setttyent(void) + { + + if (tf) { +- rewind(tf); +- return (1); ++ rewind(tf); ++ return (1); + } else if ((tf = fopen(_PATH_TTYS, "r"))) { +- /* We do the locking ourselves. */ ++ /* We do the locking ourselves. */ + #ifdef __UCLIBC_HAS_THREADS__ +- __fsetlocking (tf, FSETLOCKING_BYCALLER); ++ __fsetlocking (tf, FSETLOCKING_BYCALLER); + #endif +- return (1); ++ return (1); + } + return (0); + } +@@ -197,9 +196,9 @@ int endttyent(void) + int rval; + + if (tf) { +- rval = !(fclose(tf) == EOF); +- tf = NULL; +- return (rval); ++ rval = !(fclose(tf) == EOF); ++ tf = NULL; ++ return (rval); + } + return (1); + } +diff --git a/libc/misc/utmp/utent.c b/libc/misc/utmp/utent.c +index c1d8d6f..0fc6df4 100644 +--- a/libc/misc/utmp/utent.c ++++ b/libc/misc/utmp/utent.c +@@ -20,19 +20,9 @@ + #include + #include + ++#include + +- +-#ifdef __UCLIBC_HAS_THREADS__ +-#include +-static pthread_mutex_t utmplock = PTHREAD_MUTEX_INITIALIZER; +-# define LOCK __pthread_mutex_lock(&utmplock) +-# define UNLOCK __pthread_mutex_unlock(&utmplock) +-#else +-# define LOCK +-# define UNLOCK +-#endif +- +- ++__UCLIBC_MUTEX_STATIC(utmplock, PTHREAD_MUTEX_INITIALIZER); + + /* Some global crap */ + static int static_fd = -1; +@@ -46,19 +36,19 @@ static struct utmp *__getutent(int utmp_ + + { + if (utmp_fd == -1) { +- setutent(); ++ setutent(); + } + if (utmp_fd == -1) { +- return NULL; ++ return NULL; + } + +- LOCK; ++ __UCLIBC_MUTEX_LOCK(utmplock); + if (read(utmp_fd, (char *) &static_utmp, sizeof(struct utmp)) != sizeof(struct utmp)) +- { +- return NULL; +- } ++ { ++ return NULL; ++ } + +- UNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(utmplock); + return &static_utmp; + } + +@@ -66,39 +56,39 @@ void setutent(void) + { + int ret; + +- LOCK; ++ __UCLIBC_MUTEX_LOCK(utmplock); + if (static_fd == -1) { +- if ((static_fd = open(static_ut_name, O_RDWR)) < 0) { +- if ((static_fd = open(static_ut_name, O_RDONLY)) < 0) { +- goto bummer; +- } +- } +- /* Make sure the file will be closed on exec() */ +- ret = fcntl(static_fd, F_GETFD, 0); +- if (ret >= 0) { +- ret = fcntl(static_fd, F_GETFD, 0); +- } +- if (ret < 0) { +-bummer: +- UNLOCK; +- static_fd = -1; +- close(static_fd); +- return; +- } ++ if ((static_fd = open(static_ut_name, O_RDWR)) < 0) { ++ if ((static_fd = open(static_ut_name, O_RDONLY)) < 0) { ++ goto bummer; ++ } ++ } ++ /* Make sure the file will be closed on exec() */ ++ ret = fcntl(static_fd, F_GETFD, 0); ++ if (ret >= 0) { ++ ret = fcntl(static_fd, F_GETFD, 0); ++ } ++ if (ret < 0) { ++ bummer: ++ close(static_fd); ++ static_fd = -1; ++ goto DONE; ++ } + } + lseek(static_fd, 0, SEEK_SET); +- UNLOCK; ++ DONE: ++ __UCLIBC_MUTEX_UNLOCK(utmplock); + return; + } + + void endutent(void) + { +- LOCK; ++ __UCLIBC_MUTEX_LOCK(utmplock); + if (static_fd != -1) { +- close(static_fd); ++ close(static_fd); + } + static_fd = -1; +- UNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(utmplock); + } + + /* Locking is done in __getutent */ +@@ -113,22 +103,22 @@ struct utmp *getutid (const struct utmp + struct utmp *lutmp; + + while ((lutmp = __getutent(static_fd)) != NULL) { +- if ( (utmp_entry->ut_type == RUN_LVL || +- utmp_entry->ut_type == BOOT_TIME || +- utmp_entry->ut_type == NEW_TIME || +- utmp_entry->ut_type == OLD_TIME) && +- lutmp->ut_type == utmp_entry->ut_type) +- { +- return lutmp; +- } +- if ( (utmp_entry->ut_type == INIT_PROCESS || +- utmp_entry->ut_type == DEAD_PROCESS || +- utmp_entry->ut_type == LOGIN_PROCESS || +- utmp_entry->ut_type == USER_PROCESS) && +- !strncmp(lutmp->ut_id, utmp_entry->ut_id, sizeof(lutmp->ut_id))) +- { +- return lutmp; +- } ++ if ( (utmp_entry->ut_type == RUN_LVL || ++ utmp_entry->ut_type == BOOT_TIME || ++ utmp_entry->ut_type == NEW_TIME || ++ utmp_entry->ut_type == OLD_TIME) && ++ lutmp->ut_type == utmp_entry->ut_type) ++ { ++ return lutmp; ++ } ++ if ( (utmp_entry->ut_type == INIT_PROCESS || ++ utmp_entry->ut_type == DEAD_PROCESS || ++ utmp_entry->ut_type == LOGIN_PROCESS || ++ utmp_entry->ut_type == USER_PROCESS) && ++ !strncmp(lutmp->ut_id, utmp_entry->ut_id, sizeof(lutmp->ut_id))) ++ { ++ return lutmp; ++ } + } + + return NULL; +@@ -140,11 +130,11 @@ struct utmp *getutline(const struct utmp + struct utmp *lutmp; + + while ((lutmp = __getutent(static_fd)) != NULL) { +- if ((lutmp->ut_type == USER_PROCESS || lutmp->ut_type == LOGIN_PROCESS) && +- !strcmp(lutmp->ut_line, utmp_entry->ut_line)) +- { +- return lutmp; +- } ++ if ((lutmp->ut_type == USER_PROCESS || lutmp->ut_type == LOGIN_PROCESS) && ++ !strcmp(lutmp->ut_line, utmp_entry->ut_line)) ++ { ++ return lutmp; ++ } + } + + return NULL; +@@ -152,42 +142,42 @@ struct utmp *getutline(const struct utmp + + struct utmp *pututline (const struct utmp *utmp_entry) + { +- LOCK; ++ __UCLIBC_MUTEX_LOCK(utmplock); + /* Ignore the return value. That way, if they've already positioned + the file pointer where they want it, everything will work out. */ + lseek(static_fd, (off_t) - sizeof(struct utmp), SEEK_CUR); + + if (getutid(utmp_entry) != NULL) { +- lseek(static_fd, (off_t) - sizeof(struct utmp), SEEK_CUR); +- if (write(static_fd, utmp_entry, sizeof(struct utmp)) != sizeof(struct utmp)) +- return NULL; ++ lseek(static_fd, (off_t) - sizeof(struct utmp), SEEK_CUR); ++ if (write(static_fd, utmp_entry, sizeof(struct utmp)) != sizeof(struct utmp)) ++ return NULL; + } else { +- lseek(static_fd, (off_t) 0, SEEK_END); +- if (write(static_fd, utmp_entry, sizeof(struct utmp)) != sizeof(struct utmp)) +- return NULL; ++ lseek(static_fd, (off_t) 0, SEEK_END); ++ if (write(static_fd, utmp_entry, sizeof(struct utmp)) != sizeof(struct utmp)) ++ return NULL; + } + +- UNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(utmplock); + return (struct utmp *)utmp_entry; + } + + int utmpname (const char *new_ut_name) + { +- LOCK; ++ __UCLIBC_MUTEX_LOCK(utmplock); + if (new_ut_name != NULL) { +- if (static_ut_name != default_file_name) +- free((char *)static_ut_name); +- static_ut_name = strdup(new_ut_name); +- if (static_ut_name == NULL) { +- /* We should probably whine about out-of-memory +- * errors here... Instead just reset to the default */ +- static_ut_name = default_file_name; +- } ++ if (static_ut_name != default_file_name) ++ free((char *)static_ut_name); ++ static_ut_name = strdup(new_ut_name); ++ if (static_ut_name == NULL) { ++ /* We should probably whine about out-of-memory ++ * errors here... Instead just reset to the default */ ++ static_ut_name = default_file_name; ++ } + } + + if (static_fd != -1) +- close(static_fd); +- UNLOCK; ++ close(static_fd); ++ __UCLIBC_MUTEX_UNLOCK(utmplock); + return 0; + } + +diff --git a/libc/misc/wchar/wstdio.c b/libc/misc/wchar/wstdio.c +index b49494f..408c57a 100644 +--- a/libc/misc/wchar/wstdio.c ++++ b/libc/misc/wchar/wstdio.c +@@ -82,9 +82,6 @@ strong_alias(NAME,NAME##_unlocked) \ + void NAME PARAMS + #endif + +-#define __STDIO_THREADLOCK_OPENLIST +-#define __STDIO_THREADUNLOCK_OPENLIST +- + #else /* __UCLIBC_HAS_THREADS__ */ + + #include +@@ -112,15 +109,6 @@ void NAME PARAMS \ + } \ + void NAME##_unlocked PARAMS + +-#define __STDIO_THREADLOCK_OPENLIST \ +- __pthread_mutex_lock(&_stdio_openlist_lock) +- +-#define __STDIO_THREADUNLOCK_OPENLIST \ +- __pthread_mutex_unlock(&_stdio_openlist_lock) +- +-#define __STDIO_THREADTRYLOCK_OPENLIST \ +- __pthread_mutex_trylock(&_stdio_openlist_lock) +- + #endif /* __UCLIBC_HAS_THREADS__ */ + + #ifndef __STDIO_BUFFERS +diff --git a/libc/pwd_grp/lckpwdf.c b/libc/pwd_grp/lckpwdf.c +index 6b9c251..063fed4 100644 +--- a/libc/pwd_grp/lckpwdf.c ++++ b/libc/pwd_grp/lckpwdf.c +@@ -27,15 +27,9 @@ + #include + #include + +-#ifdef __UCLIBC_HAS_THREADS__ +-#include +-static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER; +-# define LOCK __pthread_mutex_lock(&mylock) +-# define UNLOCK __pthread_mutex_unlock(&mylock); +-#else +-# define LOCK +-# define UNLOCK +-#endif ++#include ++ ++__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER); + + /* How long to wait for getting the lock before returning with an + error. */ +@@ -57,18 +51,18 @@ int lckpwdf (void) + struct sigaction new_act; /* New signal action. */ + struct flock fl; /* Information struct for locking. */ + int result; ++ int rv = -1; + + if (lock_fd != -1) + /* Still locked by own process. */ + return -1; + +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + + lock_fd = open (_PATH_PASSWD, O_WRONLY); + if (lock_fd == -1) { + /* Cannot create lock file. */ +- UNLOCK; +- return -1; ++ goto DONE; + } + + /* Make sure file gets correctly closed when process finished. */ +@@ -77,16 +71,14 @@ int lckpwdf (void) + /* Cannot get file flags. */ + close(lock_fd); + lock_fd = -1; +- UNLOCK; +- return -1; ++ goto DONE; + } + flags |= FD_CLOEXEC; /* Close on exit. */ + if (fcntl (lock_fd, F_SETFD, flags) < 0) { + /* Cannot set new flags. */ + close(lock_fd); + lock_fd = -1; +- UNLOCK; +- return -1; ++ goto DONE; + } + + /* Now we have to get exclusive write access. Since multiple +@@ -107,8 +99,7 @@ int lckpwdf (void) + /* Cannot install signal handler. */ + close(lock_fd); + lock_fd = -1; +- UNLOCK; +- return -1; ++ goto DONE; + } + + /* Now make sure the alarm signal is not blocked. */ +@@ -118,8 +109,7 @@ int lckpwdf (void) + sigaction (SIGALRM, &saved_act, NULL); + close(lock_fd); + lock_fd = -1; +- UNLOCK; +- return -1; ++ goto DONE; + } + + /* Start timer. If we cannot get the lock in the specified time we +@@ -146,12 +136,14 @@ int lckpwdf (void) + if (result < 0) { + close(lock_fd); + lock_fd = -1; +- UNLOCK; +- return -1; ++ goto DONE; + } + +- UNLOCK; +- return 0; ++ rv = 0; ++ ++ DONE: ++ __UCLIBC_MUTEX_UNLOCK(mylock); ++ return rv; + } + + +@@ -164,11 +156,11 @@ int ulckpwdf (void) + result = -1; + } + else { +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + result = close (lock_fd); + /* Mark descriptor as unused. */ + lock_fd = -1; +- UNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(mylock); + } + + return result; +diff --git a/libc/pwd_grp/pwd_grp.c b/libc/pwd_grp/pwd_grp.c +index 91c0d83..a302c7c 100644 +--- a/libc/pwd_grp/pwd_grp.c ++++ b/libc/pwd_grp/pwd_grp.c +@@ -42,9 +42,8 @@ + #include + #include + #include +-#ifdef __UCLIBC_HAS_THREADS__ +-#include +-#endif ++ ++#include + + /**********************************************************************/ + /* Sizes for staticly allocated buffers. */ +@@ -445,34 +444,27 @@ int getpw(uid_t uid, char *buf) + /**********************************************************************/ + #ifdef L_getpwent_r + +-#ifdef __UCLIBC_HAS_THREADS__ +-static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER; +-# define LOCK __pthread_mutex_lock(&mylock) +-# define UNLOCK __pthread_mutex_unlock(&mylock); +-#else +-# define LOCK ((void) 0) +-# define UNLOCK ((void) 0) +-#endif ++__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER); + + static FILE *pwf /*= NULL*/; + + void setpwent(void) + { +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + if (pwf) { + rewind(pwf); + } +- UNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(mylock); + } + + void endpwent(void) + { +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + if (pwf) { + fclose(pwf); + pwf = NULL; + } +- UNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(mylock); + } + + +@@ -482,7 +474,7 @@ int getpwent_r(struct passwd *__restrict + { + int rv; + +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + + *result = NULL; /* In case of error... */ + +@@ -500,7 +492,7 @@ int getpwent_r(struct passwd *__restrict + } + + ERR: +- UNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(mylock); + + return rv; + } +@@ -509,34 +501,27 @@ int getpwent_r(struct passwd *__restrict + /**********************************************************************/ + #ifdef L_getgrent_r + +-#ifdef __UCLIBC_HAS_THREADS__ +-static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER; +-# define LOCK __pthread_mutex_lock(&mylock) +-# define UNLOCK __pthread_mutex_unlock(&mylock); +-#else +-# define LOCK ((void) 0) +-# define UNLOCK ((void) 0) +-#endif ++__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER); + + static FILE *grf /*= NULL*/; + + void setgrent(void) + { +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + if (grf) { + rewind(grf); + } +- UNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(mylock); + } + + void endgrent(void) + { +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + if (grf) { + fclose(grf); + grf = NULL; + } +- UNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(mylock); + } + + int getgrent_r(struct group *__restrict resultbuf, +@@ -545,7 +530,7 @@ int getgrent_r(struct group *__restrict + { + int rv; + +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + + *result = NULL; /* In case of error... */ + +@@ -563,7 +548,7 @@ int getgrent_r(struct group *__restrict + } + + ERR: +- UNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(mylock); + + return rv; + } +@@ -572,34 +557,27 @@ int getgrent_r(struct group *__restrict + /**********************************************************************/ + #ifdef L_getspent_r + +-#ifdef __UCLIBC_HAS_THREADS__ +-static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER; +-# define LOCK __pthread_mutex_lock(&mylock) +-# define UNLOCK __pthread_mutex_unlock(&mylock); +-#else +-# define LOCK ((void) 0) +-# define UNLOCK ((void) 0) +-#endif ++__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER); + + static FILE *spf /*= NULL*/; + + void setspent(void) + { +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + if (spf) { + rewind(spf); + } +- UNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(mylock); + } + + void endspent(void) + { +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + if (spf) { + fclose(spf); + spf = NULL; + } +- UNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(mylock); + } + + int getspent_r(struct spwd *resultbuf, char *buffer, +@@ -607,7 +585,7 @@ int getspent_r(struct spwd *resultbuf, c + { + int rv; + +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + + *result = NULL; /* In case of error... */ + +@@ -625,7 +603,7 @@ int getspent_r(struct spwd *resultbuf, c + } + + ERR: +- UNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(mylock); + + return rv; + } +diff --git a/libc/stdio/_READ.c b/libc/stdio/_READ.c +index 7d3c38c..fe1bc91 100644 +--- a/libc/stdio/_READ.c ++++ b/libc/stdio/_READ.c +@@ -41,7 +41,7 @@ size_t __stdio_READ(register FILE *strea + #warning EINTR? + #endif + /* RETRY: */ +- if ((rv = __READ(stream, buf, bufsize)) <= 0) { ++ if ((rv = __READ(stream, (char *) buf, bufsize)) <= 0) { + if (rv == 0) { + __STDIO_STREAM_SET_EOF(stream); + } else { +diff --git a/libc/stdio/_WRITE.c b/libc/stdio/_WRITE.c +index d300d39..4131eb7 100644 +--- a/libc/stdio/_WRITE.c ++++ b/libc/stdio/_WRITE.c +@@ -47,7 +47,7 @@ size_t __stdio_WRITE(register FILE *stre + return bufsize; + } + stodo = (todo <= SSIZE_MAX) ? todo : SSIZE_MAX; +- if ((rv = __WRITE(stream, buf, stodo)) >= 0) { ++ if ((rv = __WRITE(stream, (char *) buf, stodo)) >= 0) { + #ifdef __UCLIBC_MJN3_ONLY__ + #warning TODO: Make custom stream write return check optional. + #endif +diff --git a/libc/stdio/_fopen.c b/libc/stdio/_fopen.c +index f7f5bb6..4984f11 100644 +--- a/libc/stdio/_fopen.c ++++ b/libc/stdio/_fopen.c +@@ -194,10 +194,23 @@ FILE *_stdio_fopen(intptr_t fname_or_mod + #endif + + #ifdef __STDIO_HAS_OPENLIST +- __STDIO_THREADLOCK_OPENLIST; +- stream->__nextopen = _stdio_openlist; /* New files are inserted at */ +- _stdio_openlist = stream; /* the head of the list. */ +- __STDIO_THREADUNLOCK_OPENLIST; ++#if defined(__UCLIBC_HAS_THREADS__) && defined(__STDIO_BUFFERS) ++ if (!(stream->__modeflags & __FLAG_FREEFILE)) ++ { ++ /* An freopen call so the file was never removed from the list. */ ++ } ++ else ++#endif ++ { ++ /* We have to lock the del mutex in case another thread wants to fclose() ++ * the last file. */ ++ __STDIO_THREADLOCK_OPENLIST_DEL; ++ __STDIO_THREADLOCK_OPENLIST_ADD; ++ stream->__nextopen = _stdio_openlist; /* New files are inserted at */ ++ _stdio_openlist = stream; /* the head of the list. */ ++ __STDIO_THREADUNLOCK_OPENLIST_ADD; ++ __STDIO_THREADUNLOCK_OPENLIST_DEL; ++ } + #endif + + __STDIO_STREAM_VALIDATE(stream); +diff --git a/libc/stdio/_stdio.c b/libc/stdio/_stdio.c +index 4aae3c4..9cfe02c 100644 +--- a/libc/stdio/_stdio.c ++++ b/libc/stdio/_stdio.c +@@ -151,8 +151,12 @@ FILE *__stdout = _stdio_streams + 1; /* + FILE *_stdio_openlist = _stdio_streams; + + # ifdef __UCLIBC_HAS_THREADS__ +-pthread_mutex_t _stdio_openlist_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; +-int _stdio_openlist_delflag = 0; ++__UCLIBC_MUTEX_INIT(_stdio_openlist_add_lock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP); ++#ifdef __STDIO_BUFFERS ++__UCLIBC_MUTEX_INIT(_stdio_openlist_del_lock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP); ++volatile int _stdio_openlist_use_count = 0; ++int _stdio_openlist_del_count = 0; ++#endif + # endif + + #endif +@@ -162,10 +166,10 @@ int _stdio_openlist_delflag = 0; + /* 2 if threading not initialized and 0 otherwise; */ + int _stdio_user_locking = 2; + +-void __stdio_init_mutex(pthread_mutex_t *m) ++void __stdio_init_mutex(__UCLIBC_MUTEX_TYPE *m) + { +- static const pthread_mutex_t __stdio_mutex_initializer +- = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; ++ const __UCLIBC_MUTEX_STATIC(__stdio_mutex_initializer, ++ PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP); + + memcpy(m, &__stdio_mutex_initializer, sizeof(__stdio_mutex_initializer)); + } +@@ -184,7 +188,11 @@ void _stdio_term(void) + * locked, then I suppose there is a chance that a pointer in the + * chain might be corrupt due to a partial store. + */ +- __stdio_init_mutex(&_stdio_openlist_lock); ++ __stdio_init_mutex(&_stdio_openlist_add_lock); ++#warning check ++#ifdef __STDIO_BUFFERS ++ __stdio_init_mutex(&_stdio_openlist_del_lock); ++#endif + + /* Next we need to worry about the streams themselves. If a stream + * is currently locked, then it may be in an invalid state. So we +@@ -192,7 +200,7 @@ void _stdio_term(void) + * Then we reinitialize the locks. + */ + for (ptr = _stdio_openlist ; ptr ; ptr = ptr->__nextopen ) { +- if (__STDIO_ALWAYS_THREADTRYLOCK(ptr)) { ++ if (__STDIO_ALWAYS_THREADTRYLOCK_CANCEL_UNSAFE(ptr)) { + /* The stream is already locked, so we don't want to touch it. + * However, if we have custom streams, we can't just close it + * or leave it locked since a custom stream may be stacked +@@ -258,10 +266,6 @@ void _stdio_init(void) + #error Assumption violated about __MASK_READING and __FLAG_UNGOT + #endif + +-#ifdef __UCLIBC_HAS_THREADS__ +-#include +-#endif +- + #ifndef NDEBUG + + void _stdio_validate_FILE(const FILE *stream) +diff --git a/libc/stdio/_stdio.h b/libc/stdio/_stdio.h +index e3c2c58..decf57d 100644 +--- a/libc/stdio/_stdio.h ++++ b/libc/stdio/_stdio.h +@@ -22,23 +22,57 @@ + #include + #endif + +-#ifdef __UCLIBC_HAS_THREADS__ +-#include ++#include + +-#define __STDIO_THREADLOCK_OPENLIST \ +- __pthread_mutex_lock(&_stdio_openlist_lock) ++#define __STDIO_THREADLOCK_OPENLIST_ADD \ ++ __UCLIBC_MUTEX_LOCK(_stdio_openlist_add_lock) + +-#define __STDIO_THREADUNLOCK_OPENLIST \ +- __pthread_mutex_unlock(&_stdio_openlist_lock) ++#define __STDIO_THREADUNLOCK_OPENLIST_ADD \ ++ __UCLIBC_MUTEX_UNLOCK(_stdio_openlist_add_lock) + +-#define __STDIO_THREADTRYLOCK_OPENLIST \ +- __pthread_mutex_trylock(&_stdio_openlist_lock) ++#ifdef __STDIO_BUFFERS + +-#else ++#define __STDIO_THREADLOCK_OPENLIST_DEL \ ++ __UCLIBC_MUTEX_LOCK(_stdio_openlist_del_lock) ++ ++#define __STDIO_THREADUNLOCK_OPENLIST_DEL \ ++ __UCLIBC_MUTEX_UNLOCK(_stdio_openlist_del_lock) + +-#define __STDIO_THREADLOCK_OPENLIST ((void)0) +-#define __STDIO_THREADUNLOCK_OPENLIST ((void)0) ++#define __STDIO_OPENLIST_INC_USE \ ++do { \ ++ __STDIO_THREADLOCK_OPENLIST_DEL; \ ++ ++_stdio_openlist_use_count; \ ++ __STDIO_THREADUNLOCK_OPENLIST_DEL; \ ++} while (0) ++ ++extern void _stdio_openlist_dec_use(void); ++ ++#define __STDIO_OPENLIST_DEC_USE \ ++ _stdio_openlist_dec_use() ++ ++#define __STDIO_OPENLIST_INC_DEL_CNT \ ++do { \ ++ __STDIO_THREADLOCK_OPENLIST_DEL; \ ++ ++_stdio_openlist_del_count; \ ++ __STDIO_THREADUNLOCK_OPENLIST_DEL; \ ++} while (0) ++ ++#define __STDIO_OPENLIST_DEC_DEL_CNT \ ++do { \ ++ __STDIO_THREADLOCK_OPENLIST_DEL; \ ++ --_stdio_openlist_del_count; \ ++ __STDIO_THREADUNLOCK_OPENLIST_DEL; \ ++} while (0) ++ ++#endif /* __STDIO_BUFFERS */ + ++#ifndef __STDIO_THREADLOCK_OPENLIST_DEL ++#define __STDIO_THREADLOCK_OPENLIST_DEL ((void)0) ++#define __STDIO_THREADUNLOCK_OPENLIST_DEL ((void)0) ++#define __STDIO_OPENLIST_INC_USE ((void)0) ++#define __STDIO_OPENLIST_DEC_USE ((void)0) ++#define __STDIO_OPENLIST_INC_DEL_CNT ((void)0) ++#define __STDIO_OPENLIST_DEC_DEL_CNT ((void)0) + #endif + + #define __UNDEFINED_OR_NONPORTABLE ((void)0) +diff --git a/libc/stdio/fclose.c b/libc/stdio/fclose.c +index 4df2e42..dfababc 100644 +--- a/libc/stdio/fclose.c ++++ b/libc/stdio/fclose.c +@@ -12,30 +12,34 @@ int fclose(register FILE *stream) + int rv = 0; + __STDIO_AUTO_THREADLOCK_VAR; + +- /* First, remove the file from the open file list. */ +-#ifdef __STDIO_HAS_OPENLIST +- { +- register FILE *ptr; +- +- __STDIO_THREADLOCK_OPENLIST; +- if ((ptr = _stdio_openlist) == stream) { +- _stdio_openlist = stream->__nextopen; +- } else { +- while (ptr) { +- if (ptr->__nextopen == stream) { +- ptr->__nextopen = stream->__nextopen; +- break; +- } +- ptr = ptr->__nextopen; +- } +- } +- __STDIO_THREADUNLOCK_OPENLIST; +- +- if (!ptr) { /* Did not find stream in the open file list! */ +- return EOF; +- } +- } +-#endif ++#warning dead code... but may want to simply check and not remove ++/* #ifdef __STDIO_HAS_OPENLIST */ ++/* #if !defined(__UCLIBC_HAS_THREADS__) || !defined(__STDIO_BUFFERS) */ ++/* /\* First, remove the file from the open file list. *\/ */ ++/* { */ ++/* register FILE *ptr; */ ++ ++/* __STDIO_THREADLOCK_OPENLIST; */ ++/* if ((ptr = _stdio_openlist) == stream) { */ ++/* #warning does a mod!!! */ ++/* _stdio_openlist = stream->__nextopen; */ ++/* } else { */ ++/* while (ptr) { */ ++/* if (ptr->__nextopen == stream) { */ ++/* ptr->__nextopen = stream->__nextopen; */ ++/* break; */ ++/* } */ ++/* ptr = ptr->__nextopen; */ ++/* } */ ++/* } */ ++/* __STDIO_THREADUNLOCK_OPENLIST; */ ++ ++/* if (!ptr) { /\* Did not find stream in the open file list! *\/ */ ++/* return EOF; */ ++/* } */ ++/* } */ ++/* #endif */ ++/* #endif */ + + __STDIO_AUTO_THREADLOCK(stream); + +@@ -80,7 +84,15 @@ int fclose(register FILE *stream) + __STDIO_AUTO_THREADUNLOCK(stream); + + __STDIO_STREAM_FREE_BUFFER(stream); ++#warning... inefficient - locks and unlocks twice and walks whole list ++#if defined(__UCLIBC_HAS_THREADS__) && defined(__STDIO_BUFFERS) ++ /* inefficient - locks/unlocks twice and walks whole list */ ++ __STDIO_OPENLIST_INC_USE; ++ __STDIO_OPENLIST_INC_DEL_CNT; ++ __STDIO_OPENLIST_DEC_USE; /* This with free the file if necessary. */ ++#else + __STDIO_STREAM_FREE_FILE(stream); ++#endif + + return rv; + } +diff --git a/libc/stdio/fcloseall.c b/libc/stdio/fcloseall.c +index dbb6000..f62281a 100644 +--- a/libc/stdio/fcloseall.c ++++ b/libc/stdio/fcloseall.c +@@ -19,14 +19,34 @@ int fcloseall (void) + #ifdef __STDIO_HAS_OPENLIST + + int retval = 0; ++ FILE *f; + +- __STDIO_THREADLOCK_OPENLIST; +- while (_stdio_openlist) { +- if (fclose(_stdio_openlist)) { ++#warning remove dead code ++/* __STDIO_THREADLOCK_OPENLIST; */ ++/* while (_stdio_openlist) { */ ++/* if (fclose(_stdio_openlist)) { */ ++/* retval = EOF; */ ++/* } */ ++/* } */ ++/* __STDIO_THREADUNLOCK_OPENLIST; */ ++ ++ __STDIO_OPENLIST_INC_USE; ++ ++#warning should probably have a get_head() operation ++ __STDIO_THREADLOCK_OPENLIST_ADD; ++ f = _stdio_openlist; ++ __STDIO_THREADUNLOCK_OPENLIST_ADD; ++ ++ while (f) { ++#warning should probably have a get_next() operation ++ FILE *n = f->__nextopen; ++ if (fclose(f)) { + retval = EOF; + } ++ f = n; + } +- __STDIO_THREADUNLOCK_OPENLIST; ++ ++ __STDIO_OPENLIST_DEC_USE; + + return retval; + +diff --git a/libc/stdio/fflush.c b/libc/stdio/fflush.c +index 6baa0ec..66b65cd 100644 +--- a/libc/stdio/fflush.c ++++ b/libc/stdio/fflush.c +@@ -20,23 +20,50 @@ weak_alias(__fflush_unlocked,fflush_unlo + weak_alias(__fflush_unlocked,fflush); + #endif + +-#ifdef __UCLIBC_HAS_THREADS__ + /* Even if the stream is set to user-locking, we still need to lock + * when all (lbf) writing streams are flushed. */ +-#define MY_STDIO_THREADLOCK(STREAM) \ +- if (_stdio_user_locking != 2) { \ +- __STDIO_ALWAYS_THREADLOCK(STREAM); \ +- } + +-#define MY_STDIO_THREADUNLOCK(STREAM) \ +- if (_stdio_user_locking != 2) { \ +- __STDIO_ALWAYS_THREADUNLOCK(STREAM); \ +- } +-#else +-#define MY_STDIO_THREADLOCK(STREAM) ((void)0) +-#define MY_STDIO_THREADUNLOCK(STREAM) ((void)0) +-#endif ++#define __MY_STDIO_THREADLOCK(__stream) \ ++ __UCLIBC_MUTEX_CONDITIONAL_LOCK((__stream)->__lock, \ ++ (_stdio_user_locking != 2)) ++ ++#define __MY_STDIO_THREADUNLOCK(__stream) \ ++ __UCLIBC_MUTEX_CONDITIONAL_UNLOCK((__stream)->__lock, \ ++ (_stdio_user_locking != 2)) + ++#if defined(__UCLIBC_HAS_THREADS__) && defined(__STDIO_BUFFERS) ++void _stdio_openlist_dec_use(void) ++{ ++ __STDIO_THREADLOCK_OPENLIST_DEL; ++ if ((_stdio_openlist_use_count == 1) && (_stdio_openlist_del_count > 0)) { ++ FILE *p = NULL; ++ FILE *n; ++ FILE *stream; ++ ++ __STDIO_THREADLOCK_OPENLIST_ADD; ++ for (stream = _stdio_openlist; stream; stream = n) { ++#warning walk the list and clear out all fclosed()d files ++ n = stream->__nextopen; ++#warning fix for nonatomic ++ if ((stream->__modeflags & (__FLAG_READONLY|__FLAG_WRITEONLY)) ++ == (__FLAG_READONLY|__FLAG_WRITEONLY) ++ ) { /* The file was closed so remove from the list. */ ++ if (!p) { ++ _stdio_openlist = n; ++ } else { ++ p->__nextopen = n; ++ } ++ __STDIO_STREAM_FREE_FILE(stream); ++ } else { ++ p = stream; ++ } ++ } ++ __STDIO_THREADUNLOCK_OPENLIST_DEL; ++ } ++ --_stdio_openlist_use_count; ++ __STDIO_THREADUNLOCK_OPENLIST_DEL; ++} ++#endif + + int __fflush_unlocked(register FILE *stream) + { +@@ -60,23 +87,39 @@ int __fflush_unlocked(register FILE *str + } + + if (!stream) { /* Flush all (lbf) writing streams. */ +- __STDIO_THREADLOCK_OPENLIST; +- for (stream = _stdio_openlist; stream ; stream = stream->__nextopen) { +- MY_STDIO_THREADLOCK(stream); +- if (!(((stream->__modeflags | bufmask) +- ^ (__FLAG_WRITING|__FLAG_LBF) +- ) & (__FLAG_WRITING|__MASK_BUFMODE)) +- ) { +- if (!__STDIO_COMMIT_WRITE_BUFFER(stream)) { +- __STDIO_STREAM_DISABLE_PUTC(stream); +- __STDIO_STREAM_CLEAR_WRITING(stream); +- } else { +- retval = EOF; ++ ++ __STDIO_OPENLIST_INC_USE; ++ ++ __STDIO_THREADLOCK_OPENLIST_ADD; ++ stream = _stdio_openlist; ++ __STDIO_THREADUNLOCK_OPENLIST_ADD; ++ ++ while(stream) { ++ /* We only care about currently writing streams and do not want to ++ * block trying to obtain mutexes on non-writing streams. */ ++#warning fix for nonatomic ++#warning unnecessary check if no threads ++ if (__STDIO_STREAM_IS_WRITING(stream)) { /* ONLY IF ATOMIC!!! */ ++ __MY_STDIO_THREADLOCK(stream); ++ /* Need to check again once we have the lock. */ ++ if (!(((stream->__modeflags | bufmask) ++ ^ (__FLAG_WRITING|__FLAG_LBF) ++ ) & (__FLAG_WRITING|__MASK_BUFMODE)) ++ ) { ++ if (!__STDIO_COMMIT_WRITE_BUFFER(stream)) { ++ __STDIO_STREAM_DISABLE_PUTC(stream); ++ __STDIO_STREAM_CLEAR_WRITING(stream); ++ } else { ++ retval = EOF; ++ } + } ++ __MY_STDIO_THREADUNLOCK(stream); + } +- MY_STDIO_THREADUNLOCK(stream); ++ stream = stream->__nextopen; + } +- __STDIO_THREADUNLOCK_OPENLIST; ++ ++ __STDIO_OPENLIST_DEC_USE; ++ + } else if (__STDIO_STREAM_IS_WRITING(stream)) { + if (!__STDIO_COMMIT_WRITE_BUFFER(stream)) { + __STDIO_STREAM_DISABLE_PUTC(stream); +diff --git a/libc/stdio/flockfile.c b/libc/stdio/flockfile.c +index 0dcc7c2..3fad711 100644 +--- a/libc/stdio/flockfile.c ++++ b/libc/stdio/flockfile.c +@@ -11,6 +11,6 @@ void flockfile(FILE *stream) + { + __STDIO_STREAM_VALIDATE(stream); + +- __STDIO_ALWAYS_THREADLOCK(stream); ++ __STDIO_ALWAYS_THREADLOCK_CANCEL_UNSAFE(stream); + } + +diff --git a/libc/stdio/freopen.c b/libc/stdio/freopen.c +index 0eccaac..36b8488 100644 +--- a/libc/stdio/freopen.c ++++ b/libc/stdio/freopen.c +@@ -42,6 +42,8 @@ FILE *freopen(const char * __restrict fi + + __STDIO_STREAM_VALIDATE(stream); + ++ __STDIO_OPENLIST_INC_USE; /* Do not remove the file from the list. */ ++ + /* First, flush and close, but don't deallocate, the stream. */ + /* This also removes the stream for the open file list. */ + dynmode = (stream->__modeflags & (__FLAG_FREEBUF|__FLAG_FREEFILE)); +@@ -57,9 +59,16 @@ FILE *freopen(const char * __restrict fi + + fp = _stdio_fopen(((intptr_t) filename), mode, stream, FILEDES_ARG); + ++#warning if fp is NULL, then we do not free file (but beware stdin,stdout,stderr) ++ if (fp) { ++ __STDIO_OPENLIST_DEC_DEL_CNT; ++ } ++ + /* Reset the allocation flags. */ + stream->__modeflags |= dynmode; + ++ __STDIO_OPENLIST_DEC_USE; ++ + __STDIO_AUTO_THREADUNLOCK(stream); + + return fp; +diff --git a/libc/stdio/ftello.c b/libc/stdio/ftello.c +index 7092f34..69385ce 100644 +--- a/libc/stdio/ftello.c ++++ b/libc/stdio/ftello.c +@@ -48,7 +48,10 @@ OFFSET_TYPE FTELL(register FILE *stream) + + __STDIO_STREAM_VALIDATE(stream); + +- if ((__SEEK(stream, &pos, SEEK_CUR) < 0) ++ if ((__SEEK(stream, &pos, ++ ((__STDIO_STREAM_IS_WRITING(stream) ++ && (stream->__modeflags & __FLAG_APPEND)) ++ ? SEEK_END : SEEK_CUR)) < 0) + || (__stdio_adjust_position(stream, &pos) < 0)) { + pos = -1; + } +diff --git a/libc/stdio/ftrylockfile.c b/libc/stdio/ftrylockfile.c +index d85b8ff..0d2e156 100644 +--- a/libc/stdio/ftrylockfile.c ++++ b/libc/stdio/ftrylockfile.c +@@ -15,5 +15,5 @@ int ftrylockfile(FILE *stream) + { + __STDIO_STREAM_VALIDATE(stream); + +- return __STDIO_ALWAYS_THREADTRYLOCK(stream); ++ return __STDIO_ALWAYS_THREADTRYLOCK_CANCEL_UNSAFE(stream); + } +diff --git a/libc/stdio/funlockfile.c b/libc/stdio/funlockfile.c +index 048c093..2ddf097 100644 +--- a/libc/stdio/funlockfile.c ++++ b/libc/stdio/funlockfile.c +@@ -11,5 +11,5 @@ void funlockfile(FILE *stream) + { + __STDIO_STREAM_VALIDATE(stream); + +- __STDIO_ALWAYS_THREADUNLOCK(stream); ++ __STDIO_ALWAYS_THREADUNLOCK_CANCEL_UNSAFE(stream); + } +diff --git a/libc/stdio/popen.c b/libc/stdio/popen.c +index c7887ad..ab8d296 100644 +--- a/libc/stdio/popen.c ++++ b/libc/stdio/popen.c +@@ -14,6 +14,7 @@ + * Fix failure exit code for failed execve(). + */ + ++#warning hmm... susv3 says "Pipe streams are byte-oriented." + + #include + #include +@@ -21,6 +22,8 @@ + #include + #include + ++#include ++ + /* uClinux-2.0 has vfork, but Linux 2.0 doesn't */ + #include + #if ! defined __NR_vfork +@@ -29,19 +32,11 @@ + # define VFORK_UNLOCK ((void) 0) + #endif + +-#ifdef __UCLIBC_HAS_THREADS__ +-#include +-static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER; +-# define LOCK __pthread_mutex_lock(&mylock) +-# define UNLOCK __pthread_mutex_unlock(&mylock); +-#else +-# define LOCK ((void) 0) +-# define UNLOCK ((void) 0) +-#endif ++__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER); + + #ifndef VFORK_LOCK +-# define VFORK_LOCK LOCK +-# define VFORK_UNLOCK UNLOCK ++# define VFORK_LOCK __UCLIBC_MUTEX_LOCK(mylock) ++# define VFORK_UNLOCK __UCLIBC_MUTEX_UNLOCK(mylock) + #endif + + struct popen_list_item { +@@ -118,10 +113,10 @@ FILE *popen(const char *command, const c + if (pid > 0) { /* Parent of vfork... */ + pi->pid = pid; + pi->f = fp; +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + pi->next = popen_list; + popen_list = pi; +- UNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(mylock); + + return fp; + } +@@ -136,6 +131,8 @@ FILE *popen(const char *command, const c + return NULL; + } + ++#warning is pclose correct wrt the new mutex semantics? ++ + int pclose(FILE *stream) + { + struct popen_list_item *p; +@@ -144,7 +141,7 @@ int pclose(FILE *stream) + + /* First, find the list entry corresponding to stream and remove it + * from the list. Set p to the list item (NULL if not found). */ +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + if ((p = popen_list) != NULL) { + if (p->f == stream) { + popen_list = p->next; +@@ -163,7 +160,7 @@ int pclose(FILE *stream) + } while (1); + } + } +- UNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(mylock); + + if (p) { + pid = p->pid; /* Save the pid we need */ +diff --git a/libc/stdio/setvbuf.c b/libc/stdio/setvbuf.c +index 3fe62c6..6d53ab1 100644 +--- a/libc/stdio/setvbuf.c ++++ b/libc/stdio/setvbuf.c +@@ -75,8 +75,8 @@ int setvbuf(register FILE * __restrict s + } + + stream->__modeflags |= alloc_flag; +- stream->__bufstart = buf; +- stream->__bufend = buf + size; ++ stream->__bufstart = (unsigned char *) buf; ++ stream->__bufend = (unsigned char *) buf + size; + __STDIO_STREAM_INIT_BUFREAD_BUFPOS(stream); + __STDIO_STREAM_DISABLE_GETC(stream); + __STDIO_STREAM_DISABLE_PUTC(stream); +diff --git a/libc/stdio/vasprintf.c b/libc/stdio/vasprintf.c +index 688ab7c..6d7664d 100644 +--- a/libc/stdio/vasprintf.c ++++ b/libc/stdio/vasprintf.c +@@ -63,6 +63,8 @@ int vasprintf(char **__restrict buf, con + free(*buf); + *buf = NULL; + } ++ } else { ++ rv = -1; + } + } + +diff --git a/libc/stdio/vdprintf.c b/libc/stdio/vdprintf.c +index de8362c..7cb707f 100644 +--- a/libc/stdio/vdprintf.c ++++ b/libc/stdio/vdprintf.c +@@ -15,8 +15,8 @@ int vdprintf(int filedes, const char * _ + #ifdef __STDIO_BUFFERS + char buf[64]; /* TODO: provide _optional_ buffering? */ + +- f.__bufend = buf + sizeof(buf); +- f.__bufstart = buf; ++ f.__bufend = (unsigned char *) buf + sizeof(buf); ++ f.__bufstart = (unsigned char *) buf; + __STDIO_STREAM_DISABLE_GETC(&f); + __STDIO_STREAM_DISABLE_PUTC(&f); + __STDIO_STREAM_INIT_BUFREAD_BUFPOS(&f); +diff --git a/libc/stdio/vfprintf.c b/libc/stdio/vfprintf.c +index 10114f0..9214e3b 100644 +--- a/libc/stdio/vfprintf.c ++++ b/libc/stdio/vfprintf.c +@@ -569,7 +569,7 @@ int _ppfs_init(register ppfs_t *ppfs, co + ppfs->fmtpos = fmt0; /* rewind */ + } + +-#ifdef NL_MAX_ARG ++#ifdef NL_ARGMAX + /* If we have positional args, make sure we know all the types. */ + { + register int *p = ppfs->argtype; +@@ -581,7 +581,7 @@ int _ppfs_init(register ppfs_t *ppfs, co + ++p; + } + } +-#endif /* NL_MAX_ARG */ ++#endif /* NL_ARGMAX */ + + return 0; + } +@@ -1214,7 +1214,7 @@ static size_t _fp_out_narrow(FILE *fp, i + } + len = buflen; + } +- return r + OUTNSTR(fp, (const char *) buf, len); ++ return r + OUTNSTR(fp, (const unsigned char *) buf, len); + } + + #endif /* __STDIO_PRINTF_FLOAT */ +diff --git a/libc/stdlib/abort.c b/libc/stdlib/abort.c +index 77c2cdc..9f69918 100644 +--- a/libc/stdlib/abort.c ++++ b/libc/stdlib/abort.c +@@ -70,16 +70,9 @@ extern void _exit __P((int __status)) __ + static int been_there_done_that = 0; + + /* Be prepared in case multiple threads try to abort() */ +-#ifdef __UCLIBC_HAS_THREADS__ +-# include +-static pthread_mutex_t mylock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; +-# define LOCK __pthread_mutex_lock(&mylock) +-# define UNLOCK __pthread_mutex_unlock(&mylock) +-#else +-# define LOCK +-# define UNLOCK +-#endif ++#include + ++__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP); + + /* Cause an abnormal program termination with core-dump */ + void abort(void) +@@ -87,7 +80,7 @@ void abort(void) + sigset_t sigset; + + /* Make sure we acquire the lock before proceeding */ +- LOCK; ++ __UCLIBC_MUTEX_LOCK_CANCEL_UNSAFE(mylock); + + /* Unmask SIGABRT to be sure we can get it */ + if (__sigemptyset(&sigset) == 0 && __sigaddset(&sigset, SIGABRT) == 0) { +@@ -110,9 +103,9 @@ void abort(void) + #endif + + abort_it: +- UNLOCK; ++ __UCLIBC_MUTEX_UNLOCK_CANCEL_UNSAFE(mylock); + raise(SIGABRT); +- LOCK; ++ __UCLIBC_MUTEX_LOCK_CANCEL_UNSAFE(mylock); + } + + /* Still here? Try to remove any signal handlers */ +diff --git a/libc/stdlib/atexit.c b/libc/stdlib/atexit.c +index 280f42c..b028068 100644 +--- a/libc/stdlib/atexit.c ++++ b/libc/stdlib/atexit.c +@@ -40,17 +40,9 @@ + #include + #include + ++#include + +-#ifdef __UCLIBC_HAS_THREADS__ +-#include +-extern pthread_mutex_t mylock; +-# define LOCK __pthread_mutex_lock(&mylock) +-# define UNLOCK __pthread_mutex_unlock(&mylock); +-#else +-# define LOCK +-# define UNLOCK +-#endif +- ++__UCLIBC_MUTEX_EXTERN(__atexit_lock); + + typedef void (*aefuncp) (void); /* atexit function pointer */ + typedef void (*oefuncp) (int, void *); /* on_exit function pointer */ +@@ -90,8 +82,9 @@ extern struct exit_function __exit_funct + int atexit(aefuncp func) + { + struct exit_function *efp; ++ int rv = -1; + +- LOCK; ++ __UCLIBC_MUTEX_LOCK(__atexit_lock); + if (func) { + #ifdef __UCLIBC_DYNAMIC_ATEXIT__ + /* If we are out of function table slots, make some more */ +@@ -99,18 +92,16 @@ int atexit(aefuncp func) + efp=realloc(__exit_function_table, + (__exit_slots+20)*sizeof(struct exit_function)); + if (efp==NULL) { +- UNLOCK; + __set_errno(ENOMEM); +- return -1; ++ goto DONE; + } + __exit_function_table = efp; + __exit_slots+=20; + } + #else + if (__exit_count >= __UCLIBC_MAX_ATEXIT) { +- UNLOCK; + __set_errno(ENOMEM); +- return -1; ++ goto DONE; + } + #endif + __exit_cleanup = __exit_handler; /* enable cleanup */ +@@ -118,8 +109,12 @@ int atexit(aefuncp func) + efp->type = ef_atexit; + efp->funcs.atexit = func; + } +- UNLOCK; +- return 0; ++ ++ rv = 0; ++ ++ DONE: ++ __UCLIBC_MUTEX_UNLOCK(__atexit_lock); ++ return rv; + } + #endif + +@@ -133,8 +128,9 @@ int atexit(aefuncp func) + int on_exit(oefuncp func, void *arg) + { + struct exit_function *efp; ++ int rv = -1; + +- LOCK; ++ __UCLIBC_MUTEX_LOCK(__atexit_lock); + if (func) { + #ifdef __UCLIBC_DYNAMIC_ATEXIT__ + /* If we are out of function table slots, make some more */ +@@ -142,18 +138,16 @@ int on_exit(oefuncp func, void *arg) + efp=realloc(__exit_function_table, + (__exit_slots+20)*sizeof(struct exit_function)); + if (efp==NULL) { +- UNLOCK; + __set_errno(ENOMEM); +- return -1; ++ goto DONE; + } + __exit_function_table=efp; + __exit_slots+=20; + } + #else + if (__exit_count >= __UCLIBC_MAX_ATEXIT) { +- UNLOCK; + __set_errno(ENOMEM); +- return -1; ++ goto DONE; + } + #endif + +@@ -163,8 +157,12 @@ int on_exit(oefuncp func, void *arg) + efp->funcs.on_exit.func = func; + efp->funcs.on_exit.arg = arg; + } +- UNLOCK; +- return 0; ++ ++ rv = 0; ++ ++ DONE: ++ __UCLIBC_MUTEX_UNLOCK(__atexit_lock); ++ return rv; + } + #endif + +@@ -214,9 +212,8 @@ void __exit_handler(int status) + #ifdef L_exit + extern void weak_function _stdio_term(void); + void (*__exit_cleanup) (int) = 0; +-#ifdef __UCLIBC_HAS_THREADS__ +-pthread_mutex_t mylock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; +-#endif ++ ++__UCLIBC_MUTEX_INIT(__atexit_lock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP); + + #ifdef __UCLIBC_CTOR_DTOR__ + extern void (*__app_fini)(void); +@@ -229,11 +226,11 @@ extern void (*__rtld_fini)(void); + void exit(int rv) + { + /* Perform exit-specific cleanup (atexit and on_exit) */ +- LOCK; ++ __UCLIBC_MUTEX_LOCK(__atexit_lock); + if (__exit_cleanup) { + __exit_cleanup(rv); + } +- UNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(__atexit_lock); + + #ifdef __UCLIBC_CTOR_DTOR__ + if (__app_fini != NULL) +diff --git a/libc/stdlib/malloc-simple/alloc.c b/libc/stdlib/malloc-simple/alloc.c +index ed14c37..519a875 100644 +--- a/libc/stdlib/malloc-simple/alloc.c ++++ b/libc/stdlib/malloc-simple/alloc.c +@@ -108,15 +108,14 @@ void free(void *ptr) + #endif + + #ifdef L_memalign +-#ifdef __UCLIBC_HAS_THREADS__ +-#include +-pthread_mutex_t __malloc_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; +-# define LOCK __pthread_mutex_lock(&__malloc_lock) +-# define UNLOCK __pthread_mutex_unlock(&__malloc_lock); +-#else +-# define LOCK +-# define UNLOCK +-#endif ++ ++#include ++ ++__UCLIBC_MUTEX_EXTERN(__malloc_lock); ++ ++#define __MALLOC_LOCK __UCLIBC_MUTEX_LOCK(__malloc_lock) ++#define __MALLOC_UNLOCK __UCLIBC_MUTEX_UNLOCK(__malloc_lock) ++ + + /* List of blocks allocated with memalign or valloc */ + struct alignlist +@@ -135,7 +134,7 @@ int __libc_free_aligned(void *ptr) + if (ptr == NULL) + return 0; + +- LOCK; ++ __MALLOC_LOCK; + for (l = _aligned_blocks; l != NULL; l = l->next) { + if (l->aligned == ptr) { + /* Mark the block as free */ +@@ -146,7 +145,7 @@ int __libc_free_aligned(void *ptr) + return 1; + } + } +- UNLOCK; ++ __MALLOC_UNLOCK; + return 0; + } + void * memalign (size_t alignment, size_t size) +@@ -159,10 +158,10 @@ void * memalign (size_t alignment, size_ + return NULL; + + adj = (unsigned long int) ((unsigned long int) ((char *) result - +- (char *) NULL)) % alignment; ++ (char *) NULL)) % alignment; + if (adj != 0) { + struct alignlist *l; +- LOCK; ++ __MALLOC_LOCK; + for (l = _aligned_blocks; l != NULL; l = l->next) + if (l->aligned == NULL) + /* This slot is free. Use it. */ +@@ -171,15 +170,16 @@ void * memalign (size_t alignment, size_ + l = (struct alignlist *) malloc (sizeof (struct alignlist)); + if (l == NULL) { + free(result); +- UNLOCK; +- return NULL; ++ result = NULL; ++ goto DONE; + } + l->next = _aligned_blocks; + _aligned_blocks = l; + } + l->exact = result; + result = l->aligned = (char *) result + alignment - adj; +- UNLOCK; ++ DONE: ++ __MALLOC_UNLOCK; + } + + return result; +diff --git a/libc/stdlib/malloc-standard/calloc.c b/libc/stdlib/malloc-standard/calloc.c +index a67dad7..4277954 100644 +--- a/libc/stdlib/malloc-standard/calloc.c ++++ b/libc/stdlib/malloc-standard/calloc.c +@@ -8,7 +8,7 @@ + VERSION 2.7.2 Sat Aug 17 09:07:30 2002 Doug Lea (dl at gee) + + Note: There may be an updated version of this malloc obtainable at +- ftp://gee.cs.oswego.edu/pub/misc/malloc.c ++ ftp://gee.cs.oswego.edu/pub/misc/malloc.c + Check before installing! + + Hacked up for uClibc by Erik Andersen +@@ -31,63 +31,63 @@ void* calloc(size_t n_elements, size_t e + * to fall through and call malloc(0) */ + size = n_elements * elem_size; + if (n_elements && elem_size != (size / n_elements)) { +- __set_errno(ENOMEM); +- return NULL; ++ __set_errno(ENOMEM); ++ return NULL; + } + +- LOCK; ++ __MALLOC_LOCK; + mem = malloc(size); + if (mem != 0) { +- p = mem2chunk(mem); ++ p = mem2chunk(mem); + +- if (!chunk_is_mmapped(p)) +- { +- /* +- Unroll clear of <= 36 bytes (72 if 8byte sizes) +- We know that contents have an odd number of +- size_t-sized words; minimally 3. +- */ +- +- d = (size_t*)mem; +- clearsize = chunksize(p) - (sizeof(size_t)); +- nclears = clearsize / sizeof(size_t); +- assert(nclears >= 3); +- +- if (nclears > 9) +- memset(d, 0, clearsize); +- +- else { +- *(d+0) = 0; +- *(d+1) = 0; +- *(d+2) = 0; +- if (nclears > 4) { +- *(d+3) = 0; +- *(d+4) = 0; +- if (nclears > 6) { +- *(d+5) = 0; +- *(d+6) = 0; +- if (nclears > 8) { +- *(d+7) = 0; +- *(d+8) = 0; ++ if (!chunk_is_mmapped(p)) ++ { ++ /* ++ Unroll clear of <= 36 bytes (72 if 8byte sizes) ++ We know that contents have an odd number of ++ size_t-sized words; minimally 3. ++ */ ++ ++ d = (size_t*)mem; ++ clearsize = chunksize(p) - (sizeof(size_t)); ++ nclears = clearsize / sizeof(size_t); ++ assert(nclears >= 3); ++ ++ if (nclears > 9) ++ memset(d, 0, clearsize); ++ ++ else { ++ *(d+0) = 0; ++ *(d+1) = 0; ++ *(d+2) = 0; ++ if (nclears > 4) { ++ *(d+3) = 0; ++ *(d+4) = 0; ++ if (nclears > 6) { ++ *(d+5) = 0; ++ *(d+6) = 0; ++ if (nclears > 8) { ++ *(d+7) = 0; ++ *(d+8) = 0; ++ } ++ } ++ } ++ } + } +- } +- } +- } +- } + #if 0 +- else +- { +- /* Standard unix mmap using /dev/zero clears memory so calloc +- * doesn't need to actually zero anything.... +- */ +- d = (size_t*)mem; +- /* Note the additional (sizeof(size_t)) */ +- clearsize = chunksize(p) - 2*(sizeof(size_t)); +- memset(d, 0, clearsize); +- } ++ else ++ { ++ /* Standard unix mmap using /dev/zero clears memory so calloc ++ * doesn't need to actually zero anything.... ++ */ ++ d = (size_t*)mem; ++ /* Note the additional (sizeof(size_t)) */ ++ clearsize = chunksize(p) - 2*(sizeof(size_t)); ++ memset(d, 0, clearsize); ++ } + #endif + } +- UNLOCK; ++ __MALLOC_UNLOCK; + return mem; + } + +diff --git a/libc/stdlib/malloc-standard/free.c b/libc/stdlib/malloc-standard/free.c +index 94e1d65..4e08ef7 100644 +--- a/libc/stdlib/malloc-standard/free.c ++++ b/libc/stdlib/malloc-standard/free.c +@@ -8,7 +8,7 @@ + VERSION 2.7.2 Sat Aug 17 09:07:30 2002 Doug Lea (dl at gee) + + Note: There may be an updated version of this malloc obtainable at +- ftp://gee.cs.oswego.edu/pub/misc/malloc.c ++ ftp://gee.cs.oswego.edu/pub/misc/malloc.c + Check before installing! + + Hacked up for uClibc by Erik Andersen +@@ -42,71 +42,71 @@ static int __malloc_trim(size_t pad, mst + + if (extra > 0) { + +- /* +- Only proceed if end of memory is where we last set it. +- This avoids problems if there were foreign sbrk calls. +- */ +- current_brk = (char*)(MORECORE(0)); +- if (current_brk == (char*)(av->top) + top_size) { +- +- /* +- Attempt to release memory. We ignore MORECORE return value, +- and instead call again to find out where new end of memory is. +- This avoids problems if first call releases less than we asked, +- of if failure somehow altered brk value. (We could still +- encounter problems if it altered brk in some very bad way, +- but the only thing we can do is adjust anyway, which will cause +- some downstream failure.) +- */ +- +- MORECORE(-extra); +- new_brk = (char*)(MORECORE(0)); +- +- if (new_brk != (char*)MORECORE_FAILURE) { +- released = (long)(current_brk - new_brk); +- +- if (released != 0) { +- /* Success. Adjust top. */ +- av->sbrked_mem -= released; +- set_head(av->top, (top_size - released) | PREV_INUSE); +- check_malloc_state(); +- return 1; ++ /* ++ Only proceed if end of memory is where we last set it. ++ This avoids problems if there were foreign sbrk calls. ++ */ ++ current_brk = (char*)(MORECORE(0)); ++ if (current_brk == (char*)(av->top) + top_size) { ++ ++ /* ++ Attempt to release memory. We ignore MORECORE return value, ++ and instead call again to find out where new end of memory is. ++ This avoids problems if first call releases less than we asked, ++ of if failure somehow altered brk value. (We could still ++ encounter problems if it altered brk in some very bad way, ++ but the only thing we can do is adjust anyway, which will cause ++ some downstream failure.) ++ */ ++ ++ MORECORE(-extra); ++ new_brk = (char*)(MORECORE(0)); ++ ++ if (new_brk != (char*)MORECORE_FAILURE) { ++ released = (long)(current_brk - new_brk); ++ ++ if (released != 0) { ++ /* Success. Adjust top. */ ++ av->sbrked_mem -= released; ++ set_head(av->top, (top_size - released) | PREV_INUSE); ++ check_malloc_state(); ++ return 1; ++ } ++ } + } +- } +- } + } + return 0; + } + + /* ------------------------- malloc_trim ------------------------- +- malloc_trim(size_t pad); ++ malloc_trim(size_t pad); + +- If possible, gives memory back to the system (via negative +- arguments to sbrk) if there is unused memory at the `high' end of +- the malloc pool. You can call this after freeing large blocks of +- memory to potentially reduce the system-level memory requirements +- of a program. However, it cannot guarantee to reduce memory. Under +- some allocation patterns, some large free blocks of memory will be +- locked between two used chunks, so they cannot be given back to +- the system. +- +- The `pad' argument to malloc_trim represents the amount of free +- trailing space to leave untrimmed. If this argument is zero, +- only the minimum amount of memory to maintain internal data +- structures will be left (one page or less). Non-zero arguments +- can be supplied to maintain enough trailing space to service +- future expected allocations without having to re-obtain memory +- from the system. +- +- Malloc_trim returns 1 if it actually released any memory, else 0. +- On systems that do not support "negative sbrks", it will always +- return 0. ++ If possible, gives memory back to the system (via negative ++ arguments to sbrk) if there is unused memory at the `high' end of ++ the malloc pool. You can call this after freeing large blocks of ++ memory to potentially reduce the system-level memory requirements ++ of a program. However, it cannot guarantee to reduce memory. Under ++ some allocation patterns, some large free blocks of memory will be ++ locked between two used chunks, so they cannot be given back to ++ the system. ++ ++ The `pad' argument to malloc_trim represents the amount of free ++ trailing space to leave untrimmed. If this argument is zero, ++ only the minimum amount of memory to maintain internal data ++ structures will be left (one page or less). Non-zero arguments ++ can be supplied to maintain enough trailing space to service ++ future expected allocations without having to re-obtain memory ++ from the system. ++ ++ Malloc_trim returns 1 if it actually released any memory, else 0. ++ On systems that do not support "negative sbrks", it will always ++ return 0. + */ + int malloc_trim(size_t pad) + { +- mstate av = get_malloc_state(); +- __malloc_consolidate(av); +- return __malloc_trim(pad, av); ++ mstate av = get_malloc_state(); ++ __malloc_consolidate(av); ++ return __malloc_trim(pad, av); + } + + /* +@@ -125,8 +125,8 @@ static void malloc_init_state(mstate av) + + /* Establish circular links for normal bins */ + for (i = 1; i < NBINS; ++i) { +- bin = bin_at(av,i); +- bin->fd = bin->bk = bin; ++ bin = bin_at(av,i); ++ bin->fd = bin->bk = bin; + } + + av->top_pad = DEFAULT_TOP_PAD; +@@ -157,15 +157,15 @@ static void malloc_init_state(mstate av) + + /* ------------------------- __malloc_consolidate ------------------------- + +- __malloc_consolidate is a specialized version of free() that tears +- down chunks held in fastbins. Free itself cannot be used for this +- purpose since, among other things, it might place chunks back onto +- fastbins. So, instead, we need to use a minor variant of the same +- code. +- +- Also, because this routine needs to be called the first time through +- malloc anyway, it turns out to be the perfect place to trigger +- initialization code. ++__malloc_consolidate is a specialized version of free() that tears ++down chunks held in fastbins. Free itself cannot be used for this ++purpose since, among other things, it might place chunks back onto ++fastbins. So, instead, we need to use a minor variant of the same ++code. ++ ++Also, because this routine needs to be called the first time through ++malloc anyway, it turns out to be the perfect place to trigger ++initialization code. + */ + void __malloc_consolidate(mstate av) + { +@@ -186,78 +186,78 @@ void __malloc_consolidate(mstate av) + mchunkptr fwd; + + /* +- If max_fast is 0, we know that av hasn't +- yet been initialized, in which case do so below +- */ ++ If max_fast is 0, we know that av hasn't ++ yet been initialized, in which case do so below ++ */ + + if (av->max_fast != 0) { +- clear_fastchunks(av); ++ clear_fastchunks(av); + +- unsorted_bin = unsorted_chunks(av); ++ unsorted_bin = unsorted_chunks(av); + +- /* +- Remove each chunk from fast bin and consolidate it, placing it +- then in unsorted bin. Among other reasons for doing this, +- placing in unsorted bin avoids needing to calculate actual bins +- until malloc is sure that chunks aren't immediately going to be +- reused anyway. +- */ +- +- maxfb = &(av->fastbins[fastbin_index(av->max_fast)]); +- fb = &(av->fastbins[0]); +- do { +- if ( (p = *fb) != 0) { +- *fb = 0; ++ /* ++ Remove each chunk from fast bin and consolidate it, placing it ++ then in unsorted bin. Among other reasons for doing this, ++ placing in unsorted bin avoids needing to calculate actual bins ++ until malloc is sure that chunks aren't immediately going to be ++ reused anyway. ++ */ + ++ maxfb = &(av->fastbins[fastbin_index(av->max_fast)]); ++ fb = &(av->fastbins[0]); + do { +- check_inuse_chunk(p); +- nextp = p->fd; ++ if ( (p = *fb) != 0) { ++ *fb = 0; + +- /* Slightly streamlined version of consolidation code in free() */ +- size = p->size & ~PREV_INUSE; +- nextchunk = chunk_at_offset(p, size); +- nextsize = chunksize(nextchunk); ++ do { ++ check_inuse_chunk(p); ++ nextp = p->fd; ++ ++ /* Slightly streamlined version of consolidation code in free() */ ++ size = p->size & ~PREV_INUSE; ++ nextchunk = chunk_at_offset(p, size); ++ nextsize = chunksize(nextchunk); ++ ++ if (!prev_inuse(p)) { ++ prevsize = p->prev_size; ++ size += prevsize; ++ p = chunk_at_offset(p, -((long) prevsize)); ++ unlink(p, bck, fwd); ++ } ++ ++ if (nextchunk != av->top) { ++ nextinuse = inuse_bit_at_offset(nextchunk, nextsize); ++ set_head(nextchunk, nextsize); ++ ++ if (!nextinuse) { ++ size += nextsize; ++ unlink(nextchunk, bck, fwd); ++ } ++ ++ first_unsorted = unsorted_bin->fd; ++ unsorted_bin->fd = p; ++ first_unsorted->bk = p; ++ ++ set_head(p, size | PREV_INUSE); ++ p->bk = unsorted_bin; ++ p->fd = first_unsorted; ++ set_foot(p, size); ++ } ++ ++ else { ++ size += nextsize; ++ set_head(p, size | PREV_INUSE); ++ av->top = p; ++ } + +- if (!prev_inuse(p)) { +- prevsize = p->prev_size; +- size += prevsize; +- p = chunk_at_offset(p, -((long) prevsize)); +- unlink(p, bck, fwd); +- } ++ } while ( (p = nextp) != 0); + +- if (nextchunk != av->top) { +- nextinuse = inuse_bit_at_offset(nextchunk, nextsize); +- set_head(nextchunk, nextsize); +- +- if (!nextinuse) { +- size += nextsize; +- unlink(nextchunk, bck, fwd); + } +- +- first_unsorted = unsorted_bin->fd; +- unsorted_bin->fd = p; +- first_unsorted->bk = p; +- +- set_head(p, size | PREV_INUSE); +- p->bk = unsorted_bin; +- p->fd = first_unsorted; +- set_foot(p, size); +- } +- +- else { +- size += nextsize; +- set_head(p, size | PREV_INUSE); +- av->top = p; +- } +- +- } while ( (p = nextp) != 0); +- +- } +- } while (fb++ != maxfb); ++ } while (fb++ != maxfb); + } + else { +- malloc_init_state(av); +- check_malloc_state(); ++ malloc_init_state(av); ++ check_malloc_state(); + } + } + +@@ -279,9 +279,9 @@ void free(void* mem) + + /* free(0) has no effect */ + if (mem == NULL) +- return; ++ return; + +- LOCK; ++ __MALLOC_LOCK; + av = get_malloc_state(); + p = mem2chunk(mem); + size = chunksize(p); +@@ -289,9 +289,9 @@ void free(void* mem) + check_inuse_chunk(p); + + /* +- If eligible, place chunk on a fastbin so it can be found +- and used quickly in malloc. +- */ ++ If eligible, place chunk on a fastbin so it can be found ++ and used quickly in malloc. ++ */ + + if ((unsigned long)(size) <= (unsigned long)(av->max_fast) + +@@ -300,114 +300,114 @@ void free(void* mem) + bordering top into fastbins */ + && (chunk_at_offset(p, size) != av->top) + #endif +- ) { ++ ) { + +- set_fastchunks(av); +- fb = &(av->fastbins[fastbin_index(size)]); +- p->fd = *fb; +- *fb = p; ++ set_fastchunks(av); ++ fb = &(av->fastbins[fastbin_index(size)]); ++ p->fd = *fb; ++ *fb = p; + } + + /* +- Consolidate other non-mmapped chunks as they arrive. +- */ ++ Consolidate other non-mmapped chunks as they arrive. ++ */ + + else if (!chunk_is_mmapped(p)) { +- set_anychunks(av); ++ set_anychunks(av); ++ ++ nextchunk = chunk_at_offset(p, size); ++ nextsize = chunksize(nextchunk); ++ ++ /* consolidate backward */ ++ if (!prev_inuse(p)) { ++ prevsize = p->prev_size; ++ size += prevsize; ++ p = chunk_at_offset(p, -((long) prevsize)); ++ unlink(p, bck, fwd); ++ } ++ ++ if (nextchunk != av->top) { ++ /* get and clear inuse bit */ ++ nextinuse = inuse_bit_at_offset(nextchunk, nextsize); ++ set_head(nextchunk, nextsize); ++ ++ /* consolidate forward */ ++ if (!nextinuse) { ++ unlink(nextchunk, bck, fwd); ++ size += nextsize; ++ } ++ ++ /* ++ Place the chunk in unsorted chunk list. Chunks are ++ not placed into regular bins until after they have ++ been given one chance to be used in malloc. ++ */ ++ ++ bck = unsorted_chunks(av); ++ fwd = bck->fd; ++ p->bk = bck; ++ p->fd = fwd; ++ bck->fd = p; ++ fwd->bk = p; + +- nextchunk = chunk_at_offset(p, size); +- nextsize = chunksize(nextchunk); ++ set_head(p, size | PREV_INUSE); ++ set_foot(p, size); ++ ++ check_free_chunk(p); ++ } ++ ++ /* ++ If the chunk borders the current high end of memory, ++ consolidate into top ++ */ + +- /* consolidate backward */ +- if (!prev_inuse(p)) { +- prevsize = p->prev_size; +- size += prevsize; +- p = chunk_at_offset(p, -((long) prevsize)); +- unlink(p, bck, fwd); +- } +- +- if (nextchunk != av->top) { +- /* get and clear inuse bit */ +- nextinuse = inuse_bit_at_offset(nextchunk, nextsize); +- set_head(nextchunk, nextsize); +- +- /* consolidate forward */ +- if (!nextinuse) { +- unlink(nextchunk, bck, fwd); +- size += nextsize; +- } +- +- /* +- Place the chunk in unsorted chunk list. Chunks are +- not placed into regular bins until after they have +- been given one chance to be used in malloc. +- */ +- +- bck = unsorted_chunks(av); +- fwd = bck->fd; +- p->bk = bck; +- p->fd = fwd; +- bck->fd = p; +- fwd->bk = p; +- +- set_head(p, size | PREV_INUSE); +- set_foot(p, size); +- +- check_free_chunk(p); +- } +- +- /* +- If the chunk borders the current high end of memory, +- consolidate into top +- */ +- +- else { +- size += nextsize; +- set_head(p, size | PREV_INUSE); +- av->top = p; +- check_chunk(p); +- } +- +- /* +- If freeing a large space, consolidate possibly-surrounding +- chunks. Then, if the total unused topmost memory exceeds trim +- threshold, ask malloc_trim to reduce top. +- +- Unless max_fast is 0, we don't know if there are fastbins +- bordering top, so we cannot tell for sure whether threshold +- has been reached unless fastbins are consolidated. But we +- don't want to consolidate on each free. As a compromise, +- consolidation is performed if FASTBIN_CONSOLIDATION_THRESHOLD +- is reached. +- */ +- +- if ((unsigned long)(size) >= FASTBIN_CONSOLIDATION_THRESHOLD) { +- if (have_fastchunks(av)) +- __malloc_consolidate(av); +- +- if ((unsigned long)(chunksize(av->top)) >= +- (unsigned long)(av->trim_threshold)) +- __malloc_trim(av->top_pad, av); +- } ++ else { ++ size += nextsize; ++ set_head(p, size | PREV_INUSE); ++ av->top = p; ++ check_chunk(p); ++ } ++ ++ /* ++ If freeing a large space, consolidate possibly-surrounding ++ chunks. Then, if the total unused topmost memory exceeds trim ++ threshold, ask malloc_trim to reduce top. ++ ++ Unless max_fast is 0, we don't know if there are fastbins ++ bordering top, so we cannot tell for sure whether threshold ++ has been reached unless fastbins are consolidated. But we ++ don't want to consolidate on each free. As a compromise, ++ consolidation is performed if FASTBIN_CONSOLIDATION_THRESHOLD ++ is reached. ++ */ ++ ++ if ((unsigned long)(size) >= FASTBIN_CONSOLIDATION_THRESHOLD) { ++ if (have_fastchunks(av)) ++ __malloc_consolidate(av); ++ ++ if ((unsigned long)(chunksize(av->top)) >= ++ (unsigned long)(av->trim_threshold)) ++ __malloc_trim(av->top_pad, av); ++ } + + } + /* +- If the chunk was allocated via mmap, release via munmap() +- Note that if HAVE_MMAP is false but chunk_is_mmapped is +- true, then user must have overwritten memory. There's nothing +- we can do to catch this error unless DEBUG is set, in which case +- check_inuse_chunk (above) will have triggered error. +- */ ++ If the chunk was allocated via mmap, release via munmap() ++ Note that if HAVE_MMAP is false but chunk_is_mmapped is ++ true, then user must have overwritten memory. There's nothing ++ we can do to catch this error unless DEBUG is set, in which case ++ check_inuse_chunk (above) will have triggered error. ++ */ + + else { +- int ret; +- size_t offset = p->prev_size; +- av->n_mmaps--; +- av->mmapped_mem -= (size + offset); +- ret = munmap((char*)p - offset, size + offset); +- /* munmap returns non-zero on failure */ +- assert(ret == 0); ++ int ret; ++ size_t offset = p->prev_size; ++ av->n_mmaps--; ++ av->mmapped_mem -= (size + offset); ++ ret = munmap((char*)p - offset, size + offset); ++ /* munmap returns non-zero on failure */ ++ assert(ret == 0); + } +- UNLOCK; ++ __MALLOC_UNLOCK; + } + +diff --git a/libc/stdlib/malloc-standard/mallinfo.c b/libc/stdlib/malloc-standard/mallinfo.c +index 51ac423..1e0875c 100644 +--- a/libc/stdlib/malloc-standard/mallinfo.c ++++ b/libc/stdlib/malloc-standard/mallinfo.c +@@ -8,7 +8,7 @@ + VERSION 2.7.2 Sat Aug 17 09:07:30 2002 Doug Lea (dl at gee) + + Note: There may be an updated version of this malloc obtainable at +- ftp://gee.cs.oswego.edu/pub/misc/malloc.c ++ ftp://gee.cs.oswego.edu/pub/misc/malloc.c + Check before installing! + + Hacked up for uClibc by Erik Andersen +@@ -30,11 +30,11 @@ struct mallinfo mallinfo(void) + int nblocks; + int nfastblocks; + +- LOCK; ++ __MALLOC_LOCK; + av = get_malloc_state(); + /* Ensure initialization */ + if (av->top == 0) { +- __malloc_consolidate(av); ++ __malloc_consolidate(av); + } + + check_malloc_state(); +@@ -48,21 +48,21 @@ struct mallinfo mallinfo(void) + fastavail = 0; + + for (i = 0; i < NFASTBINS; ++i) { +- for (p = av->fastbins[i]; p != 0; p = p->fd) { +- ++nfastblocks; +- fastavail += chunksize(p); +- } ++ for (p = av->fastbins[i]; p != 0; p = p->fd) { ++ ++nfastblocks; ++ fastavail += chunksize(p); ++ } + } + + avail += fastavail; + + /* traverse regular bins */ + for (i = 1; i < NBINS; ++i) { +- b = bin_at(av, i); +- for (p = last(b); p != b; p = p->bk) { +- ++nblocks; +- avail += chunksize(p); +- } ++ b = bin_at(av, i); ++ for (p = last(b); p != b; p = p->bk) { ++ ++nblocks; ++ avail += chunksize(p); ++ } + } + + mi.smblks = nfastblocks; +@@ -75,7 +75,7 @@ struct mallinfo mallinfo(void) + mi.fsmblks = fastavail; + mi.keepcost = chunksize(av->top); + mi.usmblks = av->max_total_mem; +- UNLOCK; ++ __MALLOC_UNLOCK; + return mi; + } + +@@ -84,23 +84,40 @@ void malloc_stats(FILE *file) + struct mallinfo mi; + + if (file==NULL) { +- file = stderr; ++ file = stderr; + } + + mi = mallinfo(); +- fprintf(file, "total bytes allocated = %10u\n", (unsigned int)(mi.arena + mi.hblkhd)); +- fprintf(file, "total bytes in use bytes = %10u\n", (unsigned int)(mi.uordblks + mi.hblkhd)); +- fprintf(file, "total non-mmapped bytes allocated = %10d\n", mi.arena); +- fprintf(file, "number of mmapped regions = %10d\n", mi.hblks); +- fprintf(file, "total allocated mmap space = %10d\n", mi.hblkhd); +- fprintf(file, "total allocated sbrk space = %10d\n", mi.uordblks); ++ fprintf(file, ++ "total bytes allocated = %10u\n" ++ "total bytes in use bytes = %10u\n" ++ "total non-mmapped bytes allocated = %10d\n" ++ "number of mmapped regions = %10d\n" ++ "total allocated mmap space = %10d\n" ++ "total allocated sbrk space = %10d\n" + #if 0 +- fprintf(file, "number of free chunks = %10d\n", mi.ordblks); +- fprintf(file, "number of fastbin blocks = %10d\n", mi.smblks); +- fprintf(file, "space in freed fastbin blocks = %10d\n", mi.fsmblks); ++ "number of free chunks = %10d\n" ++ "number of fastbin blocks = %10d\n" ++ "space in freed fastbin blocks = %10d\n" + #endif +- fprintf(file, "maximum total allocated space = %10d\n", mi.usmblks); +- fprintf(file, "total free space = %10d\n", mi.fordblks); +- fprintf(file, "memory releasable via malloc_trim = %10d\n", mi.keepcost); ++ "maximum total allocated space = %10d\n" ++ "total free space = %10d\n" ++ "memory releasable via malloc_trim = %10d\n", ++ ++ (unsigned int)(mi.arena + mi.hblkhd), ++ (unsigned int)(mi.uordblks + mi.hblkhd), ++ mi.arena, ++ mi.hblks, ++ mi.hblkhd, ++ mi.uordblks, ++#if 0 ++ mi.ordblks, ++ mi.smblks, ++ mi.fsmblks, ++#endif ++ mi.usmblks, ++ mi.fordblks, ++ mi.keepcost ++ ); + } + +diff --git a/libc/stdlib/malloc-standard/malloc.c b/libc/stdlib/malloc-standard/malloc.c +index 7025e83..60494a0 100644 +--- a/libc/stdlib/malloc-standard/malloc.c ++++ b/libc/stdlib/malloc-standard/malloc.c +@@ -8,7 +8,7 @@ + VERSION 2.7.2 Sat Aug 17 09:07:30 2002 Doug Lea (dl at gee) + + Note: There may be an updated version of this malloc obtainable at +- ftp://gee.cs.oswego.edu/pub/misc/malloc.c ++ ftp://gee.cs.oswego.edu/pub/misc/malloc.c + Check before installing! + + Hacked up for uClibc by Erik Andersen +@@ -17,17 +17,14 @@ + #define _GNU_SOURCE + #include "malloc.h" + +- +-#ifdef __UCLIBC_HAS_THREADS__ +-pthread_mutex_t __malloc_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; +-#endif ++__UCLIBC_MUTEX_INIT(__malloc_lock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP); + + /* +- There is exactly one instance of this struct in this malloc. +- If you are adapting this malloc in a way that does NOT use a static +- malloc_state, you MUST explicitly zero-fill it before using. This +- malloc relies on the property that malloc_state is initialized to +- all zeroes (as is true of C statics). ++ There is exactly one instance of this struct in this malloc. ++ If you are adapting this malloc in a way that does NOT use a static ++ malloc_state, you MUST explicitly zero-fill it before using. This ++ malloc relies on the property that malloc_state is initialized to ++ all zeroes (as is true of C statics). + */ + struct malloc_state __malloc_state; /* never directly referenced */ + +@@ -77,30 +74,30 @@ void __do_check_chunk(mchunkptr p) + + if (!chunk_is_mmapped(p)) { + +- /* Has legal address ... */ +- if (p != av->top) { +- if (contiguous(av)) { +- assert(((char*)p) >= min_address); +- assert(((char*)p + sz) <= ((char*)(av->top))); +- } +- } +- else { +- /* top size is always at least MINSIZE */ +- assert((unsigned long)(sz) >= MINSIZE); +- /* top predecessor always marked inuse */ +- assert(prev_inuse(p)); +- } ++ /* Has legal address ... */ ++ if (p != av->top) { ++ if (contiguous(av)) { ++ assert(((char*)p) >= min_address); ++ assert(((char*)p + sz) <= ((char*)(av->top))); ++ } ++ } ++ else { ++ /* top size is always at least MINSIZE */ ++ assert((unsigned long)(sz) >= MINSIZE); ++ /* top predecessor always marked inuse */ ++ assert(prev_inuse(p)); ++ } + + } + else { +- /* address is outside main heap */ +- if (contiguous(av) && av->top != initial_top(av)) { +- assert(((char*)p) < min_address || ((char*)p) > max_address); +- } +- /* chunk is page-aligned */ +- assert(((p->prev_size + sz) & (av->pagesize-1)) == 0); +- /* mem is aligned */ +- assert(aligned_OK(chunk2mem(p))); ++ /* address is outside main heap */ ++ if (contiguous(av) && av->top != initial_top(av)) { ++ assert(((char*)p) < min_address || ((char*)p) > max_address); ++ } ++ /* chunk is page-aligned */ ++ assert(((p->prev_size + sz) & (av->pagesize-1)) == 0); ++ /* mem is aligned */ ++ assert(aligned_OK(chunk2mem(p))); + } + } + +@@ -121,21 +118,21 @@ void __do_check_free_chunk(mchunkptr p) + + /* Unless a special marker, must have OK fields */ + if ((unsigned long)(sz) >= MINSIZE) +- { +- assert((sz & MALLOC_ALIGN_MASK) == 0); +- assert(aligned_OK(chunk2mem(p))); +- /* ... matching footer field */ +- assert(next->prev_size == sz); +- /* ... and is fully consolidated */ +- assert(prev_inuse(p)); +- assert (next == av->top || inuse(next)); +- +- /* ... and has minimally sane links */ +- assert(p->fd->bk == p); +- assert(p->bk->fd == p); +- } ++ { ++ assert((sz & MALLOC_ALIGN_MASK) == 0); ++ assert(aligned_OK(chunk2mem(p))); ++ /* ... matching footer field */ ++ assert(next->prev_size == sz); ++ /* ... and is fully consolidated */ ++ assert(prev_inuse(p)); ++ assert (next == av->top || inuse(next)); ++ ++ /* ... and has minimally sane links */ ++ assert(p->fd->bk == p); ++ assert(p->bk->fd == p); ++ } + else /* markers are always of size (sizeof(size_t)) */ +- assert(sz == (sizeof(size_t))); ++ assert(sz == (sizeof(size_t))); + } + + /* Properties of inuse chunks */ +@@ -146,7 +143,7 @@ void __do_check_inuse_chunk(mchunkptr p) + __do_check_chunk(p); + + if (chunk_is_mmapped(p)) +- return; /* mmapped chunks have no next/prev */ ++ return; /* mmapped chunks have no next/prev */ + + /* Check whether it claims to be in use ... */ + assert(inuse(p)); +@@ -156,20 +153,20 @@ void __do_check_inuse_chunk(mchunkptr p) + /* ... and is surrounded by OK chunks. + Since more things can be checked with free chunks than inuse ones, + if an inuse chunk borders them and debug is on, it's worth doing them. +- */ ++ */ + if (!prev_inuse(p)) { +- /* Note that we cannot even look at prev unless it is not inuse */ +- mchunkptr prv = prev_chunk(p); +- assert(next_chunk(prv) == p); +- __do_check_free_chunk(prv); ++ /* Note that we cannot even look at prev unless it is not inuse */ ++ mchunkptr prv = prev_chunk(p); ++ assert(next_chunk(prv) == p); ++ __do_check_free_chunk(prv); + } + + if (next == av->top) { +- assert(prev_inuse(next)); +- assert(chunksize(next) >= MINSIZE); ++ assert(prev_inuse(next)); ++ assert(chunksize(next) >= MINSIZE); + } + else if (!inuse(next)) +- __do_check_free_chunk(next); ++ __do_check_free_chunk(next); + } + + /* Properties of chunks recycled from fastbins */ +@@ -198,14 +195,14 @@ void __do_check_malloced_chunk(mchunkptr + __do_check_remalloced_chunk(p, s); + + /* +- ... plus, must obey implementation invariant that prev_inuse is +- always true of any allocated chunk; i.e., that each allocated +- chunk borders either a previously allocated and still in-use +- chunk, or the base of its memory arena. This is ensured +- by making all allocations from the the `lowest' part of any found +- chunk. This does not necessarily hold however for chunks +- recycled via fastbins. +- */ ++ ... plus, must obey implementation invariant that prev_inuse is ++ always true of any allocated chunk; i.e., that each allocated ++ chunk borders either a previously allocated and still in-use ++ chunk, or the base of its memory arena. This is ensured ++ by making all allocations from the the `lowest' part of any found ++ chunk. This does not necessarily hold however for chunks ++ recycled via fastbins. ++ */ + + assert(prev_inuse(p)); + } +@@ -243,7 +240,7 @@ void __do_check_malloc_state(void) + + /* cannot run remaining checks until fully initialized */ + if (av->top == 0 || av->top == initial_top(av)) +- return; ++ return; + + /* pagesize is a power of 2 */ + assert((av->pagesize & (av->pagesize-1)) == 0); +@@ -256,64 +253,64 @@ void __do_check_malloc_state(void) + max_fast_bin = fastbin_index(av->max_fast); + + for (i = 0; i < NFASTBINS; ++i) { +- p = av->fastbins[i]; ++ p = av->fastbins[i]; + +- /* all bins past max_fast are empty */ +- if (i > max_fast_bin) +- assert(p == 0); +- +- while (p != 0) { +- /* each chunk claims to be inuse */ +- __do_check_inuse_chunk(p); +- total += chunksize(p); +- /* chunk belongs in this bin */ +- assert(fastbin_index(chunksize(p)) == i); +- p = p->fd; +- } ++ /* all bins past max_fast are empty */ ++ if (i > max_fast_bin) ++ assert(p == 0); ++ ++ while (p != 0) { ++ /* each chunk claims to be inuse */ ++ __do_check_inuse_chunk(p); ++ total += chunksize(p); ++ /* chunk belongs in this bin */ ++ assert(fastbin_index(chunksize(p)) == i); ++ p = p->fd; ++ } + } + + if (total != 0) +- assert(have_fastchunks(av)); ++ assert(have_fastchunks(av)); + else if (!have_fastchunks(av)) +- assert(total == 0); ++ assert(total == 0); + + /* check normal bins */ + for (i = 1; i < NBINS; ++i) { +- b = bin_at(av,i); ++ b = bin_at(av,i); + +- /* binmap is accurate (except for bin 1 == unsorted_chunks) */ +- if (i >= 2) { +- binbit = get_binmap(av,i); +- empty = last(b) == b; +- if (!binbit) +- assert(empty); +- else if (!empty) +- assert(binbit); +- } +- +- for (p = last(b); p != b; p = p->bk) { +- /* each chunk claims to be free */ +- __do_check_free_chunk(p); +- size = chunksize(p); +- total += size; +- if (i >= 2) { +- /* chunk belongs in bin */ +- idx = bin_index(size); +- assert(idx == i); +- /* lists are sorted */ +- if ((unsigned long) size >= (unsigned long)(FIRST_SORTED_BIN_SIZE)) { +- assert(p->bk == b || +- (unsigned long)chunksize(p->bk) >= +- (unsigned long)chunksize(p)); +- } +- } +- /* chunk is followed by a legal chain of inuse chunks */ +- for (q = next_chunk(p); +- (q != av->top && inuse(q) && +- (unsigned long)(chunksize(q)) >= MINSIZE); +- q = next_chunk(q)) +- __do_check_inuse_chunk(q); +- } ++ /* binmap is accurate (except for bin 1 == unsorted_chunks) */ ++ if (i >= 2) { ++ binbit = get_binmap(av,i); ++ empty = last(b) == b; ++ if (!binbit) ++ assert(empty); ++ else if (!empty) ++ assert(binbit); ++ } ++ ++ for (p = last(b); p != b; p = p->bk) { ++ /* each chunk claims to be free */ ++ __do_check_free_chunk(p); ++ size = chunksize(p); ++ total += size; ++ if (i >= 2) { ++ /* chunk belongs in bin */ ++ idx = bin_index(size); ++ assert(idx == i); ++ /* lists are sorted */ ++ if ((unsigned long) size >= (unsigned long)(FIRST_SORTED_BIN_SIZE)) { ++ assert(p->bk == b || ++ (unsigned long)chunksize(p->bk) >= ++ (unsigned long)chunksize(p)); ++ } ++ } ++ /* chunk is followed by a legal chain of inuse chunks */ ++ for (q = next_chunk(p); ++ (q != av->top && inuse(q) && ++ (unsigned long)(chunksize(q)) >= MINSIZE); ++ q = next_chunk(q)) ++ __do_check_inuse_chunk(q); ++ } + } + + /* top chunk is OK */ +@@ -326,13 +323,13 @@ void __do_check_malloc_state(void) + assert(av->n_mmaps <= av->max_n_mmaps); + + assert((unsigned long)(av->sbrked_mem) <= +- (unsigned long)(av->max_sbrked_mem)); ++ (unsigned long)(av->max_sbrked_mem)); + + assert((unsigned long)(av->mmapped_mem) <= +- (unsigned long)(av->max_mmapped_mem)); ++ (unsigned long)(av->max_mmapped_mem)); + + assert((unsigned long)(av->max_total_mem) >= +- (unsigned long)(av->mmapped_mem) + (unsigned long)(av->sbrked_mem)); ++ (unsigned long)(av->mmapped_mem) + (unsigned long)(av->sbrked_mem)); + } + #endif + +@@ -370,84 +367,84 @@ static void* __malloc_alloc(size_t nb, m + size_t pagemask = av->pagesize - 1; + + /* +- If there is space available in fastbins, consolidate and retry +- malloc from scratch rather than getting memory from system. This +- can occur only if nb is in smallbin range so we didn't consolidate +- upon entry to malloc. It is much easier to handle this case here +- than in malloc proper. +- */ ++ If there is space available in fastbins, consolidate and retry ++ malloc from scratch rather than getting memory from system. This ++ can occur only if nb is in smallbin range so we didn't consolidate ++ upon entry to malloc. It is much easier to handle this case here ++ than in malloc proper. ++ */ + + if (have_fastchunks(av)) { +- assert(in_smallbin_range(nb)); +- __malloc_consolidate(av); +- return malloc(nb - MALLOC_ALIGN_MASK); ++ assert(in_smallbin_range(nb)); ++ __malloc_consolidate(av); ++ return malloc(nb - MALLOC_ALIGN_MASK); + } + + + /* +- If have mmap, and the request size meets the mmap threshold, and +- the system supports mmap, and there are few enough currently +- allocated mmapped regions, try to directly map this request +- rather than expanding top. +- */ ++ If have mmap, and the request size meets the mmap threshold, and ++ the system supports mmap, and there are few enough currently ++ allocated mmapped regions, try to directly map this request ++ rather than expanding top. ++ */ + + if ((unsigned long)(nb) >= (unsigned long)(av->mmap_threshold) && + (av->n_mmaps < av->n_mmaps_max)) { + +- char* mm; /* return value from mmap call*/ +- +- /* +- Round up size to nearest page. For mmapped chunks, the overhead +- is one (sizeof(size_t)) unit larger than for normal chunks, because there +- is no following chunk whose prev_size field could be used. +- */ +- size = (nb + (sizeof(size_t)) + MALLOC_ALIGN_MASK + pagemask) & ~pagemask; +- +- /* Don't try if size wraps around 0 */ +- if ((unsigned long)(size) > (unsigned long)(nb)) { +- +- mm = (char*)(MMAP(0, size, PROT_READ|PROT_WRITE)); +- +- if (mm != (char*)(MORECORE_FAILURE)) { ++ char* mm; /* return value from mmap call*/ + + /* +- The offset to the start of the mmapped region is stored +- in the prev_size field of the chunk. This allows us to adjust +- returned start address to meet alignment requirements here +- and in memalign(), and still be able to compute proper +- address argument for later munmap in free() and realloc(). +- */ +- +- front_misalign = (size_t)chunk2mem(mm) & MALLOC_ALIGN_MASK; +- if (front_misalign > 0) { +- correction = MALLOC_ALIGNMENT - front_misalign; +- p = (mchunkptr)(mm + correction); +- p->prev_size = correction; +- set_head(p, (size - correction) |IS_MMAPPED); +- } +- else { +- p = (mchunkptr)mm; +- p->prev_size = 0; +- set_head(p, size|IS_MMAPPED); +- } ++ Round up size to nearest page. For mmapped chunks, the overhead ++ is one (sizeof(size_t)) unit larger than for normal chunks, because there ++ is no following chunk whose prev_size field could be used. ++ */ ++ size = (nb + (sizeof(size_t)) + MALLOC_ALIGN_MASK + pagemask) & ~pagemask; ++ ++ /* Don't try if size wraps around 0 */ ++ if ((unsigned long)(size) > (unsigned long)(nb)) { ++ ++ mm = (char*)(MMAP(0, size, PROT_READ|PROT_WRITE)); ++ ++ if (mm != (char*)(MORECORE_FAILURE)) { ++ ++ /* ++ The offset to the start of the mmapped region is stored ++ in the prev_size field of the chunk. This allows us to adjust ++ returned start address to meet alignment requirements here ++ and in memalign(), and still be able to compute proper ++ address argument for later munmap in free() and realloc(). ++ */ ++ ++ front_misalign = (size_t)chunk2mem(mm) & MALLOC_ALIGN_MASK; ++ if (front_misalign > 0) { ++ correction = MALLOC_ALIGNMENT - front_misalign; ++ p = (mchunkptr)(mm + correction); ++ p->prev_size = correction; ++ set_head(p, (size - correction) |IS_MMAPPED); ++ } ++ else { ++ p = (mchunkptr)mm; ++ p->prev_size = 0; ++ set_head(p, size|IS_MMAPPED); ++ } ++ ++ /* update statistics */ ++ ++ if (++av->n_mmaps > av->max_n_mmaps) ++ av->max_n_mmaps = av->n_mmaps; ++ ++ sum = av->mmapped_mem += size; ++ if (sum > (unsigned long)(av->max_mmapped_mem)) ++ av->max_mmapped_mem = sum; ++ sum += av->sbrked_mem; ++ if (sum > (unsigned long)(av->max_total_mem)) ++ av->max_total_mem = sum; + +- /* update statistics */ ++ check_chunk(p); + +- if (++av->n_mmaps > av->max_n_mmaps) +- av->max_n_mmaps = av->n_mmaps; +- +- sum = av->mmapped_mem += size; +- if (sum > (unsigned long)(av->max_mmapped_mem)) +- av->max_mmapped_mem = sum; +- sum += av->sbrked_mem; +- if (sum > (unsigned long)(av->max_total_mem)) +- av->max_total_mem = sum; +- +- check_chunk(p); +- +- return chunk2mem(p); +- } +- } ++ return chunk2mem(p); ++ } ++ } + } + + /* Record incoming configuration of top */ +@@ -462,8 +459,8 @@ static void* __malloc_alloc(size_t nb, m + * be at least MINSIZE and to have prev_inuse set. */ + + assert((old_top == initial_top(av) && old_size == 0) || +- ((unsigned long) (old_size) >= MINSIZE && +- prev_inuse(old_top))); ++ ((unsigned long) (old_size) >= MINSIZE && ++ prev_inuse(old_top))); + + /* Precondition: not enough current space to satisfy nb request */ + assert((unsigned long)(old_size) < (unsigned long)(nb + MINSIZE)); +@@ -477,272 +474,272 @@ static void* __malloc_alloc(size_t nb, m + size = nb + av->top_pad + MINSIZE; + + /* +- If contiguous, we can subtract out existing space that we hope to +- combine with new space. We add it back later only if +- we don't actually get contiguous space. +- */ ++ If contiguous, we can subtract out existing space that we hope to ++ combine with new space. We add it back later only if ++ we don't actually get contiguous space. ++ */ + + if (contiguous(av)) +- size -= old_size; ++ size -= old_size; + + /* +- Round to a multiple of page size. +- If MORECORE is not contiguous, this ensures that we only call it +- with whole-page arguments. And if MORECORE is contiguous and +- this is not first time through, this preserves page-alignment of +- previous calls. Otherwise, we correct to page-align below. +- */ ++ Round to a multiple of page size. ++ If MORECORE is not contiguous, this ensures that we only call it ++ with whole-page arguments. And if MORECORE is contiguous and ++ this is not first time through, this preserves page-alignment of ++ previous calls. Otherwise, we correct to page-align below. ++ */ + + size = (size + pagemask) & ~pagemask; + + /* +- Don't try to call MORECORE if argument is so big as to appear +- negative. Note that since mmap takes size_t arg, it may succeed +- below even if we cannot call MORECORE. +- */ ++ Don't try to call MORECORE if argument is so big as to appear ++ negative. Note that since mmap takes size_t arg, it may succeed ++ below even if we cannot call MORECORE. ++ */ + + if (size > 0) +- brk = (char*)(MORECORE(size)); ++ brk = (char*)(MORECORE(size)); + + /* +- If have mmap, try using it as a backup when MORECORE fails or +- cannot be used. This is worth doing on systems that have "holes" in +- address space, so sbrk cannot extend to give contiguous space, but +- space is available elsewhere. Note that we ignore mmap max count +- and threshold limits, since the space will not be used as a +- segregated mmap region. +- */ ++ If have mmap, try using it as a backup when MORECORE fails or ++ cannot be used. This is worth doing on systems that have "holes" in ++ address space, so sbrk cannot extend to give contiguous space, but ++ space is available elsewhere. Note that we ignore mmap max count ++ and threshold limits, since the space will not be used as a ++ segregated mmap region. ++ */ + + if (brk == (char*)(MORECORE_FAILURE)) { + +- /* Cannot merge with old top, so add its size back in */ +- if (contiguous(av)) +- size = (size + old_size + pagemask) & ~pagemask; +- +- /* If we are relying on mmap as backup, then use larger units */ +- if ((unsigned long)(size) < (unsigned long)(MMAP_AS_MORECORE_SIZE)) +- size = MMAP_AS_MORECORE_SIZE; +- +- /* Don't try if size wraps around 0 */ +- if ((unsigned long)(size) > (unsigned long)(nb)) { +- +- brk = (char*)(MMAP(0, size, PROT_READ|PROT_WRITE)); +- +- if (brk != (char*)(MORECORE_FAILURE)) { +- +- /* We do not need, and cannot use, another sbrk call to find end */ +- snd_brk = brk + size; +- +- /* Record that we no longer have a contiguous sbrk region. +- After the first time mmap is used as backup, we do not +- ever rely on contiguous space since this could incorrectly +- bridge regions. +- */ +- set_noncontiguous(av); +- } +- } ++ /* Cannot merge with old top, so add its size back in */ ++ if (contiguous(av)) ++ size = (size + old_size + pagemask) & ~pagemask; ++ ++ /* If we are relying on mmap as backup, then use larger units */ ++ if ((unsigned long)(size) < (unsigned long)(MMAP_AS_MORECORE_SIZE)) ++ size = MMAP_AS_MORECORE_SIZE; ++ ++ /* Don't try if size wraps around 0 */ ++ if ((unsigned long)(size) > (unsigned long)(nb)) { ++ ++ brk = (char*)(MMAP(0, size, PROT_READ|PROT_WRITE)); ++ ++ if (brk != (char*)(MORECORE_FAILURE)) { ++ ++ /* We do not need, and cannot use, another sbrk call to find end */ ++ snd_brk = brk + size; ++ ++ /* Record that we no longer have a contiguous sbrk region. ++ After the first time mmap is used as backup, we do not ++ ever rely on contiguous space since this could incorrectly ++ bridge regions. ++ */ ++ set_noncontiguous(av); ++ } ++ } + } + + if (brk != (char*)(MORECORE_FAILURE)) { +- av->sbrked_mem += size; ++ av->sbrked_mem += size; + +- /* +- If MORECORE extends previous space, we can likewise extend top size. +- */ +- +- if (brk == old_end && snd_brk == (char*)(MORECORE_FAILURE)) { +- set_head(old_top, (size + old_size) | PREV_INUSE); +- } +- +- /* +- Otherwise, make adjustments: +- +- * If the first time through or noncontiguous, we need to call sbrk +- just to find out where the end of memory lies. +- +- * We need to ensure that all returned chunks from malloc will meet +- MALLOC_ALIGNMENT +- +- * If there was an intervening foreign sbrk, we need to adjust sbrk +- request size to account for fact that we will not be able to +- combine new space with existing space in old_top. +- +- * Almost all systems internally allocate whole pages at a time, in +- which case we might as well use the whole last page of request. +- So we allocate enough more memory to hit a page boundary now, +- which in turn causes future contiguous calls to page-align. +- */ +- +- else { +- front_misalign = 0; +- end_misalign = 0; +- correction = 0; +- aligned_brk = brk; +- +- /* +- If MORECORE returns an address lower than we have seen before, +- we know it isn't really contiguous. This and some subsequent +- checks help cope with non-conforming MORECORE functions and +- the presence of "foreign" calls to MORECORE from outside of +- malloc or by other threads. We cannot guarantee to detect +- these in all cases, but cope with the ones we do detect. +- */ +- if (contiguous(av) && old_size != 0 && brk < old_end) { +- set_noncontiguous(av); +- } +- +- /* handle contiguous cases */ +- if (contiguous(av)) { +- +- /* We can tolerate forward non-contiguities here (usually due +- to foreign calls) but treat them as part of our space for +- stats reporting. */ +- if (old_size != 0) +- av->sbrked_mem += brk - old_end; +- +- /* Guarantee alignment of first new chunk made from this space */ +- +- front_misalign = (size_t)chunk2mem(brk) & MALLOC_ALIGN_MASK; +- if (front_misalign > 0) { +- +- /* +- Skip over some bytes to arrive at an aligned position. +- We don't need to specially mark these wasted front bytes. +- They will never be accessed anyway because +- prev_inuse of av->top (and any chunk created from its start) +- is always true after initialization. +- */ ++ /* ++ If MORECORE extends previous space, we can likewise extend top size. ++ */ + +- correction = MALLOC_ALIGNMENT - front_misalign; +- aligned_brk += correction; ++ if (brk == old_end && snd_brk == (char*)(MORECORE_FAILURE)) { ++ set_head(old_top, (size + old_size) | PREV_INUSE); + } + + /* +- If this isn't adjacent to existing space, then we will not +- be able to merge with old_top space, so must add to 2nd request. +- */ +- +- correction += old_size; +- +- /* Extend the end address to hit a page boundary */ +- end_misalign = (size_t)(brk + size + correction); +- correction += ((end_misalign + pagemask) & ~pagemask) - end_misalign; +- +- assert(correction >= 0); +- snd_brk = (char*)(MORECORE(correction)); +- +- if (snd_brk == (char*)(MORECORE_FAILURE)) { +- /* +- If can't allocate correction, try to at least find out current +- brk. It might be enough to proceed without failing. +- */ +- correction = 0; +- snd_brk = (char*)(MORECORE(0)); +- } +- else if (snd_brk < brk) { +- /* +- If the second call gives noncontiguous space even though +- it says it won't, the only course of action is to ignore +- results of second call, and conservatively estimate where +- the first call left us. Also set noncontiguous, so this +- won't happen again, leaving at most one hole. +- +- Note that this check is intrinsically incomplete. Because +- MORECORE is allowed to give more space than we ask for, +- there is no reliable way to detect a noncontiguity +- producing a forward gap for the second call. +- */ +- snd_brk = brk + size; +- correction = 0; +- set_noncontiguous(av); +- } +- +- } +- +- /* handle non-contiguous cases */ +- else { +- /* MORECORE/mmap must correctly align */ +- assert(aligned_OK(chunk2mem(brk))); +- +- /* Find out current end of memory */ +- if (snd_brk == (char*)(MORECORE_FAILURE)) { +- snd_brk = (char*)(MORECORE(0)); +- av->sbrked_mem += snd_brk - brk - size; +- } +- } +- +- /* Adjust top based on results of second sbrk */ +- if (snd_brk != (char*)(MORECORE_FAILURE)) { +- av->top = (mchunkptr)aligned_brk; +- set_head(av->top, (snd_brk - aligned_brk + correction) | PREV_INUSE); +- av->sbrked_mem += correction; ++ Otherwise, make adjustments: + +- /* +- If not the first time through, we either have a +- gap due to foreign sbrk or a non-contiguous region. Insert a +- double fencepost at old_top to prevent consolidation with space +- we don't own. These fenceposts are artificial chunks that are +- marked as inuse and are in any case too small to use. We need +- two to make sizes and alignments work out. +- */ +- +- if (old_size != 0) { +- /* Shrink old_top to insert fenceposts, keeping size a +- multiple of MALLOC_ALIGNMENT. We know there is at least +- enough space in old_top to do this. +- */ +- old_size = (old_size - 3*(sizeof(size_t))) & ~MALLOC_ALIGN_MASK; +- set_head(old_top, old_size | PREV_INUSE); +- +- /* +- Note that the following assignments completely overwrite +- old_top when old_size was previously MINSIZE. This is +- intentional. We need the fencepost, even if old_top otherwise gets +- lost. +- */ +- chunk_at_offset(old_top, old_size )->size = +- (sizeof(size_t))|PREV_INUSE; +- +- chunk_at_offset(old_top, old_size + (sizeof(size_t)))->size = +- (sizeof(size_t))|PREV_INUSE; +- +- /* If possible, release the rest, suppressing trimming. */ +- if (old_size >= MINSIZE) { +- size_t tt = av->trim_threshold; +- av->trim_threshold = (size_t)(-1); +- free(chunk2mem(old_top)); +- av->trim_threshold = tt; +- } +- } +- } +- } +- +- /* Update statistics */ +- sum = av->sbrked_mem; +- if (sum > (unsigned long)(av->max_sbrked_mem)) +- av->max_sbrked_mem = sum; +- +- sum += av->mmapped_mem; +- if (sum > (unsigned long)(av->max_total_mem)) +- av->max_total_mem = sum; +- +- check_malloc_state(); +- +- /* finally, do the allocation */ +- +- p = av->top; +- size = chunksize(p); +- +- /* check that one of the above allocation paths succeeded */ +- if ((unsigned long)(size) >= (unsigned long)(nb + MINSIZE)) { +- remainder_size = size - nb; +- remainder = chunk_at_offset(p, nb); +- av->top = remainder; +- set_head(p, nb | PREV_INUSE); +- set_head(remainder, remainder_size | PREV_INUSE); +- check_malloced_chunk(p, nb); +- return chunk2mem(p); +- } ++ * If the first time through or noncontiguous, we need to call sbrk ++ just to find out where the end of memory lies. ++ ++ * We need to ensure that all returned chunks from malloc will meet ++ MALLOC_ALIGNMENT ++ ++ * If there was an intervening foreign sbrk, we need to adjust sbrk ++ request size to account for fact that we will not be able to ++ combine new space with existing space in old_top. ++ ++ * Almost all systems internally allocate whole pages at a time, in ++ which case we might as well use the whole last page of request. ++ So we allocate enough more memory to hit a page boundary now, ++ which in turn causes future contiguous calls to page-align. ++ */ ++ ++ else { ++ front_misalign = 0; ++ end_misalign = 0; ++ correction = 0; ++ aligned_brk = brk; ++ ++ /* ++ If MORECORE returns an address lower than we have seen before, ++ we know it isn't really contiguous. This and some subsequent ++ checks help cope with non-conforming MORECORE functions and ++ the presence of "foreign" calls to MORECORE from outside of ++ malloc or by other threads. We cannot guarantee to detect ++ these in all cases, but cope with the ones we do detect. ++ */ ++ if (contiguous(av) && old_size != 0 && brk < old_end) { ++ set_noncontiguous(av); ++ } ++ ++ /* handle contiguous cases */ ++ if (contiguous(av)) { ++ ++ /* We can tolerate forward non-contiguities here (usually due ++ to foreign calls) but treat them as part of our space for ++ stats reporting. */ ++ if (old_size != 0) ++ av->sbrked_mem += brk - old_end; ++ ++ /* Guarantee alignment of first new chunk made from this space */ ++ ++ front_misalign = (size_t)chunk2mem(brk) & MALLOC_ALIGN_MASK; ++ if (front_misalign > 0) { ++ ++ /* ++ Skip over some bytes to arrive at an aligned position. ++ We don't need to specially mark these wasted front bytes. ++ They will never be accessed anyway because ++ prev_inuse of av->top (and any chunk created from its start) ++ is always true after initialization. ++ */ ++ ++ correction = MALLOC_ALIGNMENT - front_misalign; ++ aligned_brk += correction; ++ } ++ ++ /* ++ If this isn't adjacent to existing space, then we will not ++ be able to merge with old_top space, so must add to 2nd request. ++ */ ++ ++ correction += old_size; ++ ++ /* Extend the end address to hit a page boundary */ ++ end_misalign = (size_t)(brk + size + correction); ++ correction += ((end_misalign + pagemask) & ~pagemask) - end_misalign; ++ ++ assert(correction >= 0); ++ snd_brk = (char*)(MORECORE(correction)); ++ ++ if (snd_brk == (char*)(MORECORE_FAILURE)) { ++ /* ++ If can't allocate correction, try to at least find out current ++ brk. It might be enough to proceed without failing. ++ */ ++ correction = 0; ++ snd_brk = (char*)(MORECORE(0)); ++ } ++ else if (snd_brk < brk) { ++ /* ++ If the second call gives noncontiguous space even though ++ it says it won't, the only course of action is to ignore ++ results of second call, and conservatively estimate where ++ the first call left us. Also set noncontiguous, so this ++ won't happen again, leaving at most one hole. ++ ++ Note that this check is intrinsically incomplete. Because ++ MORECORE is allowed to give more space than we ask for, ++ there is no reliable way to detect a noncontiguity ++ producing a forward gap for the second call. ++ */ ++ snd_brk = brk + size; ++ correction = 0; ++ set_noncontiguous(av); ++ } ++ ++ } ++ ++ /* handle non-contiguous cases */ ++ else { ++ /* MORECORE/mmap must correctly align */ ++ assert(aligned_OK(chunk2mem(brk))); ++ ++ /* Find out current end of memory */ ++ if (snd_brk == (char*)(MORECORE_FAILURE)) { ++ snd_brk = (char*)(MORECORE(0)); ++ av->sbrked_mem += snd_brk - brk - size; ++ } ++ } ++ ++ /* Adjust top based on results of second sbrk */ ++ if (snd_brk != (char*)(MORECORE_FAILURE)) { ++ av->top = (mchunkptr)aligned_brk; ++ set_head(av->top, (snd_brk - aligned_brk + correction) | PREV_INUSE); ++ av->sbrked_mem += correction; ++ ++ /* ++ If not the first time through, we either have a ++ gap due to foreign sbrk or a non-contiguous region. Insert a ++ double fencepost at old_top to prevent consolidation with space ++ we don't own. These fenceposts are artificial chunks that are ++ marked as inuse and are in any case too small to use. We need ++ two to make sizes and alignments work out. ++ */ ++ ++ if (old_size != 0) { ++ /* Shrink old_top to insert fenceposts, keeping size a ++ multiple of MALLOC_ALIGNMENT. We know there is at least ++ enough space in old_top to do this. ++ */ ++ old_size = (old_size - 3*(sizeof(size_t))) & ~MALLOC_ALIGN_MASK; ++ set_head(old_top, old_size | PREV_INUSE); ++ ++ /* ++ Note that the following assignments completely overwrite ++ old_top when old_size was previously MINSIZE. This is ++ intentional. We need the fencepost, even if old_top otherwise gets ++ lost. ++ */ ++ chunk_at_offset(old_top, old_size )->size = ++ (sizeof(size_t))|PREV_INUSE; ++ ++ chunk_at_offset(old_top, old_size + (sizeof(size_t)))->size = ++ (sizeof(size_t))|PREV_INUSE; ++ ++ /* If possible, release the rest, suppressing trimming. */ ++ if (old_size >= MINSIZE) { ++ size_t tt = av->trim_threshold; ++ av->trim_threshold = (size_t)(-1); ++ free(chunk2mem(old_top)); ++ av->trim_threshold = tt; ++ } ++ } ++ } ++ } ++ ++ /* Update statistics */ ++ sum = av->sbrked_mem; ++ if (sum > (unsigned long)(av->max_sbrked_mem)) ++ av->max_sbrked_mem = sum; ++ ++ sum += av->mmapped_mem; ++ if (sum > (unsigned long)(av->max_total_mem)) ++ av->max_total_mem = sum; ++ ++ check_malloc_state(); ++ ++ /* finally, do the allocation */ ++ ++ p = av->top; ++ size = chunksize(p); ++ ++ /* check that one of the above allocation paths succeeded */ ++ if ((unsigned long)(size) >= (unsigned long)(nb + MINSIZE)) { ++ remainder_size = size - nb; ++ remainder = chunk_at_offset(p, nb); ++ av->top = remainder; ++ set_head(p, nb | PREV_INUSE); ++ set_head(remainder, remainder_size | PREV_INUSE); ++ check_malloced_chunk(p, nb); ++ return chunk2mem(p); ++ } + + } + +@@ -767,25 +764,25 @@ static int __malloc_largebin_index(unsig + #if defined(__GNUC__) && defined(i386) + + __asm__("bsrl %1,%0\n\t" +- : "=r" (m) +- : "g" (x)); ++ : "=r" (m) ++ : "g" (x)); + + #else + { +- /* +- Based on branch-free nlz algorithm in chapter 5 of Henry +- S. Warren Jr's book "Hacker's Delight". +- */ +- +- unsigned int n = ((x - 0x100) >> 16) & 8; +- x <<= n; +- m = ((x - 0x1000) >> 16) & 4; +- n += m; +- x <<= m; +- m = ((x - 0x4000) >> 16) & 2; +- n += m; +- x = (x << m) >> 14; +- m = 13 - n + (x & ~(x>>1)); ++ /* ++ Based on branch-free nlz algorithm in chapter 5 of Henry ++ S. Warren Jr's book "Hacker's Delight". ++ */ ++ ++ unsigned int n = ((x - 0x100) >> 16) & 8; ++ x <<= n; ++ m = ((x - 0x1000) >> 16) & 4; ++ n += m; ++ x <<= m; ++ m = ((x - 0x4000) >> 16) & 2; ++ n += m; ++ x = (x << m) >> 14; ++ m = 13 - n + (x & ~(x>>1)); + } + #endif + +@@ -826,69 +823,70 @@ void* malloc(size_t bytes) + mchunkptr fwd; /* misc temp for linking */ + mchunkptr bck; /* misc temp for linking */ + void * sysmem; ++ void * retval; + + #if !defined(__MALLOC_GLIBC_COMPAT__) + if (!bytes) return NULL; + #endif + +- LOCK; ++ __MALLOC_LOCK; + av = get_malloc_state(); + /* +- Convert request size to internal form by adding (sizeof(size_t)) bytes +- overhead plus possibly more to obtain necessary alignment and/or +- to obtain a size of at least MINSIZE, the smallest allocatable +- size. Also, checked_request2size traps (returning 0) request sizes +- that are so large that they wrap around zero when padded and +- aligned. +- */ ++ Convert request size to internal form by adding (sizeof(size_t)) bytes ++ overhead plus possibly more to obtain necessary alignment and/or ++ to obtain a size of at least MINSIZE, the smallest allocatable ++ size. Also, checked_request2size traps (returning 0) request sizes ++ that are so large that they wrap around zero when padded and ++ aligned. ++ */ + + checked_request2size(bytes, nb); + + /* +- Bypass search if no frees yet +- */ ++ Bypass search if no frees yet ++ */ + if (!have_anychunks(av)) { +- if (av->max_fast == 0) /* initialization check */ +- __malloc_consolidate(av); +- goto use_top; ++ if (av->max_fast == 0) /* initialization check */ ++ __malloc_consolidate(av); ++ goto use_top; + } + + /* +- If the size qualifies as a fastbin, first check corresponding bin. +- */ ++ If the size qualifies as a fastbin, first check corresponding bin. ++ */ + + if ((unsigned long)(nb) <= (unsigned long)(av->max_fast)) { +- fb = &(av->fastbins[(fastbin_index(nb))]); +- if ( (victim = *fb) != 0) { +- *fb = victim->fd; +- check_remalloced_chunk(victim, nb); +- UNLOCK; +- return chunk2mem(victim); +- } ++ fb = &(av->fastbins[(fastbin_index(nb))]); ++ if ( (victim = *fb) != 0) { ++ *fb = victim->fd; ++ check_remalloced_chunk(victim, nb); ++ retval = chunk2mem(victim); ++ goto DONE; ++ } + } + + /* +- If a small request, check regular bin. Since these "smallbins" +- hold one size each, no searching within bins is necessary. +- (For a large request, we need to wait until unsorted chunks are +- processed to find best fit. But for small ones, fits are exact +- anyway, so we can check now, which is faster.) +- */ ++ If a small request, check regular bin. Since these "smallbins" ++ hold one size each, no searching within bins is necessary. ++ (For a large request, we need to wait until unsorted chunks are ++ processed to find best fit. But for small ones, fits are exact ++ anyway, so we can check now, which is faster.) ++ */ + + if (in_smallbin_range(nb)) { +- idx = smallbin_index(nb); +- bin = bin_at(av,idx); ++ idx = smallbin_index(nb); ++ bin = bin_at(av,idx); + +- if ( (victim = last(bin)) != bin) { +- bck = victim->bk; +- set_inuse_bit_at_offset(victim, nb); +- bin->bk = bck; +- bck->fd = bin; +- +- check_malloced_chunk(victim, nb); +- UNLOCK; +- return chunk2mem(victim); +- } ++ if ( (victim = last(bin)) != bin) { ++ bck = victim->bk; ++ set_inuse_bit_at_offset(victim, nb); ++ bin->bk = bck; ++ bck->fd = bin; ++ ++ check_malloced_chunk(victim, nb); ++ retval = chunk2mem(victim); ++ goto DONE; ++ } + } + + /* If this is a large request, consolidate fastbins before continuing. +@@ -899,154 +897,154 @@ void* malloc(size_t bytes) + large requests, but less often mixtures, so consolidation is not + invoked all that often in most programs. And the programs that + it is called frequently in otherwise tend to fragment. +- */ ++ */ + + else { +- idx = __malloc_largebin_index(nb); +- if (have_fastchunks(av)) +- __malloc_consolidate(av); ++ idx = __malloc_largebin_index(nb); ++ if (have_fastchunks(av)) ++ __malloc_consolidate(av); + } + + /* +- Process recently freed or remaindered chunks, taking one only if +- it is exact fit, or, if this a small request, the chunk is remainder from +- the most recent non-exact fit. Place other traversed chunks in +- bins. Note that this step is the only place in any routine where +- chunks are placed in bins. +- */ ++ Process recently freed or remaindered chunks, taking one only if ++ it is exact fit, or, if this a small request, the chunk is remainder from ++ the most recent non-exact fit. Place other traversed chunks in ++ bins. Note that this step is the only place in any routine where ++ chunks are placed in bins. ++ */ + + while ( (victim = unsorted_chunks(av)->bk) != unsorted_chunks(av)) { +- bck = victim->bk; +- size = chunksize(victim); ++ bck = victim->bk; ++ size = chunksize(victim); ++ ++ /* If a small request, try to use last remainder if it is the ++ only chunk in unsorted bin. This helps promote locality for ++ runs of consecutive small requests. This is the only ++ exception to best-fit, and applies only when there is ++ no exact fit for a small chunk. ++ */ ++ ++ if (in_smallbin_range(nb) && ++ bck == unsorted_chunks(av) && ++ victim == av->last_remainder && ++ (unsigned long)(size) > (unsigned long)(nb + MINSIZE)) { ++ ++ /* split and reattach remainder */ ++ remainder_size = size - nb; ++ remainder = chunk_at_offset(victim, nb); ++ unsorted_chunks(av)->bk = unsorted_chunks(av)->fd = remainder; ++ av->last_remainder = remainder; ++ remainder->bk = remainder->fd = unsorted_chunks(av); ++ ++ set_head(victim, nb | PREV_INUSE); ++ set_head(remainder, remainder_size | PREV_INUSE); ++ set_foot(remainder, remainder_size); ++ ++ check_malloced_chunk(victim, nb); ++ retval = chunk2mem(victim); ++ goto DONE; ++ } ++ ++ /* remove from unsorted list */ ++ unsorted_chunks(av)->bk = bck; ++ bck->fd = unsorted_chunks(av); ++ ++ /* Take now instead of binning if exact fit */ ++ ++ if (size == nb) { ++ set_inuse_bit_at_offset(victim, size); ++ check_malloced_chunk(victim, nb); ++ retval = chunk2mem(victim); ++ goto DONE; ++ } ++ ++ /* place chunk in bin */ + +- /* If a small request, try to use last remainder if it is the +- only chunk in unsorted bin. This helps promote locality for +- runs of consecutive small requests. This is the only +- exception to best-fit, and applies only when there is +- no exact fit for a small chunk. +- */ +- +- if (in_smallbin_range(nb) && +- bck == unsorted_chunks(av) && +- victim == av->last_remainder && +- (unsigned long)(size) > (unsigned long)(nb + MINSIZE)) { +- +- /* split and reattach remainder */ +- remainder_size = size - nb; +- remainder = chunk_at_offset(victim, nb); +- unsorted_chunks(av)->bk = unsorted_chunks(av)->fd = remainder; +- av->last_remainder = remainder; +- remainder->bk = remainder->fd = unsorted_chunks(av); +- +- set_head(victim, nb | PREV_INUSE); +- set_head(remainder, remainder_size | PREV_INUSE); +- set_foot(remainder, remainder_size); +- +- check_malloced_chunk(victim, nb); +- UNLOCK; +- return chunk2mem(victim); +- } +- +- /* remove from unsorted list */ +- unsorted_chunks(av)->bk = bck; +- bck->fd = unsorted_chunks(av); +- +- /* Take now instead of binning if exact fit */ +- +- if (size == nb) { +- set_inuse_bit_at_offset(victim, size); +- check_malloced_chunk(victim, nb); +- UNLOCK; +- return chunk2mem(victim); +- } +- +- /* place chunk in bin */ +- +- if (in_smallbin_range(size)) { +- victim_index = smallbin_index(size); +- bck = bin_at(av, victim_index); +- fwd = bck->fd; +- } +- else { +- victim_index = __malloc_largebin_index(size); +- bck = bin_at(av, victim_index); +- fwd = bck->fd; +- +- if (fwd != bck) { +- /* if smaller than smallest, place first */ +- if ((unsigned long)(size) < (unsigned long)(bck->bk->size)) { +- fwd = bck; +- bck = bck->bk; +- } +- else if ((unsigned long)(size) >= +- (unsigned long)(FIRST_SORTED_BIN_SIZE)) { +- +- /* maintain large bins in sorted order */ +- size |= PREV_INUSE; /* Or with inuse bit to speed comparisons */ +- while ((unsigned long)(size) < (unsigned long)(fwd->size)) +- fwd = fwd->fd; +- bck = fwd->bk; +- } +- } +- } +- +- mark_bin(av, victim_index); +- victim->bk = bck; +- victim->fd = fwd; +- fwd->bk = victim; +- bck->fd = victim; ++ if (in_smallbin_range(size)) { ++ victim_index = smallbin_index(size); ++ bck = bin_at(av, victim_index); ++ fwd = bck->fd; ++ } ++ else { ++ victim_index = __malloc_largebin_index(size); ++ bck = bin_at(av, victim_index); ++ fwd = bck->fd; ++ ++ if (fwd != bck) { ++ /* if smaller than smallest, place first */ ++ if ((unsigned long)(size) < (unsigned long)(bck->bk->size)) { ++ fwd = bck; ++ bck = bck->bk; ++ } ++ else if ((unsigned long)(size) >= ++ (unsigned long)(FIRST_SORTED_BIN_SIZE)) { ++ ++ /* maintain large bins in sorted order */ ++ size |= PREV_INUSE; /* Or with inuse bit to speed comparisons */ ++ while ((unsigned long)(size) < (unsigned long)(fwd->size)) ++ fwd = fwd->fd; ++ bck = fwd->bk; ++ } ++ } ++ } ++ ++ mark_bin(av, victim_index); ++ victim->bk = bck; ++ victim->fd = fwd; ++ fwd->bk = victim; ++ bck->fd = victim; + } + + /* +- If a large request, scan through the chunks of current bin to +- find one that fits. (This will be the smallest that fits unless +- FIRST_SORTED_BIN_SIZE has been changed from default.) This is +- the only step where an unbounded number of chunks might be +- scanned without doing anything useful with them. However the +- lists tend to be short. +- */ ++ If a large request, scan through the chunks of current bin to ++ find one that fits. (This will be the smallest that fits unless ++ FIRST_SORTED_BIN_SIZE has been changed from default.) This is ++ the only step where an unbounded number of chunks might be ++ scanned without doing anything useful with them. However the ++ lists tend to be short. ++ */ + + if (!in_smallbin_range(nb)) { +- bin = bin_at(av, idx); +- +- for (victim = last(bin); victim != bin; victim = victim->bk) { +- size = chunksize(victim); ++ bin = bin_at(av, idx); + +- if ((unsigned long)(size) >= (unsigned long)(nb)) { +- remainder_size = size - nb; +- unlink(victim, bck, fwd); ++ for (victim = last(bin); victim != bin; victim = victim->bk) { ++ size = chunksize(victim); + +- /* Exhaust */ +- if (remainder_size < MINSIZE) { +- set_inuse_bit_at_offset(victim, size); +- check_malloced_chunk(victim, nb); +- UNLOCK; +- return chunk2mem(victim); +- } +- /* Split */ +- else { +- remainder = chunk_at_offset(victim, nb); +- unsorted_chunks(av)->bk = unsorted_chunks(av)->fd = remainder; +- remainder->bk = remainder->fd = unsorted_chunks(av); +- set_head(victim, nb | PREV_INUSE); +- set_head(remainder, remainder_size | PREV_INUSE); +- set_foot(remainder, remainder_size); +- check_malloced_chunk(victim, nb); +- UNLOCK; +- return chunk2mem(victim); ++ if ((unsigned long)(size) >= (unsigned long)(nb)) { ++ remainder_size = size - nb; ++ unlink(victim, bck, fwd); ++ ++ /* Exhaust */ ++ if (remainder_size < MINSIZE) { ++ set_inuse_bit_at_offset(victim, size); ++ check_malloced_chunk(victim, nb); ++ retval = chunk2mem(victim); ++ goto DONE; ++ } ++ /* Split */ ++ else { ++ remainder = chunk_at_offset(victim, nb); ++ unsorted_chunks(av)->bk = unsorted_chunks(av)->fd = remainder; ++ remainder->bk = remainder->fd = unsorted_chunks(av); ++ set_head(victim, nb | PREV_INUSE); ++ set_head(remainder, remainder_size | PREV_INUSE); ++ set_foot(remainder, remainder_size); ++ check_malloced_chunk(victim, nb); ++ retval = chunk2mem(victim); ++ goto DONE; ++ } ++ } + } +- } +- } + } + + /* +- Search for a chunk by scanning bins, starting with next largest +- bin. This search is strictly by best-fit; i.e., the smallest +- (with ties going to approximately the least recently used) chunk +- that fits is selected. ++ Search for a chunk by scanning bins, starting with next largest ++ bin. This search is strictly by best-fit; i.e., the smallest ++ (with ties going to approximately the least recently used) chunk ++ that fits is selected. + +- The bitmap avoids needing to check that most blocks are nonempty. +- */ ++ The bitmap avoids needing to check that most blocks are nonempty. ++ */ + + ++idx; + bin = bin_at(av,idx); +@@ -1056,109 +1054,111 @@ void* malloc(size_t bytes) + + for (;;) { + +- /* Skip rest of block if there are no more set bits in this block. */ +- if (bit > map || bit == 0) { +- do { +- if (++block >= BINMAPSIZE) /* out of bins */ +- goto use_top; +- } while ( (map = av->binmap[block]) == 0); +- +- bin = bin_at(av, (block << BINMAPSHIFT)); +- bit = 1; +- } +- +- /* Advance to bin with set bit. There must be one. */ +- while ((bit & map) == 0) { +- bin = next_bin(bin); +- bit <<= 1; +- assert(bit != 0); +- } +- +- /* Inspect the bin. It is likely to be non-empty */ +- victim = last(bin); +- +- /* If a false alarm (empty bin), clear the bit. */ +- if (victim == bin) { +- av->binmap[block] = map &= ~bit; /* Write through */ +- bin = next_bin(bin); +- bit <<= 1; +- } +- +- else { +- size = chunksize(victim); +- +- /* We know the first chunk in this bin is big enough to use. */ +- assert((unsigned long)(size) >= (unsigned long)(nb)); +- +- remainder_size = size - nb; +- +- /* unlink */ +- bck = victim->bk; +- bin->bk = bck; +- bck->fd = bin; +- +- /* Exhaust */ +- if (remainder_size < MINSIZE) { +- set_inuse_bit_at_offset(victim, size); +- check_malloced_chunk(victim, nb); +- UNLOCK; +- return chunk2mem(victim); +- } ++ /* Skip rest of block if there are no more set bits in this block. */ ++ if (bit > map || bit == 0) { ++ do { ++ if (++block >= BINMAPSIZE) /* out of bins */ ++ goto use_top; ++ } while ( (map = av->binmap[block]) == 0); + +- /* Split */ +- else { +- remainder = chunk_at_offset(victim, nb); ++ bin = bin_at(av, (block << BINMAPSHIFT)); ++ bit = 1; ++ } + +- unsorted_chunks(av)->bk = unsorted_chunks(av)->fd = remainder; +- remainder->bk = remainder->fd = unsorted_chunks(av); +- /* advertise as last remainder */ +- if (in_smallbin_range(nb)) +- av->last_remainder = remainder; ++ /* Advance to bin with set bit. There must be one. */ ++ while ((bit & map) == 0) { ++ bin = next_bin(bin); ++ bit <<= 1; ++ assert(bit != 0); ++ } + +- set_head(victim, nb | PREV_INUSE); +- set_head(remainder, remainder_size | PREV_INUSE); +- set_foot(remainder, remainder_size); +- check_malloced_chunk(victim, nb); +- UNLOCK; +- return chunk2mem(victim); +- } +- } ++ /* Inspect the bin. It is likely to be non-empty */ ++ victim = last(bin); ++ ++ /* If a false alarm (empty bin), clear the bit. */ ++ if (victim == bin) { ++ av->binmap[block] = map &= ~bit; /* Write through */ ++ bin = next_bin(bin); ++ bit <<= 1; ++ } ++ ++ else { ++ size = chunksize(victim); ++ ++ /* We know the first chunk in this bin is big enough to use. */ ++ assert((unsigned long)(size) >= (unsigned long)(nb)); ++ ++ remainder_size = size - nb; ++ ++ /* unlink */ ++ bck = victim->bk; ++ bin->bk = bck; ++ bck->fd = bin; ++ ++ /* Exhaust */ ++ if (remainder_size < MINSIZE) { ++ set_inuse_bit_at_offset(victim, size); ++ check_malloced_chunk(victim, nb); ++ retval = chunk2mem(victim); ++ goto DONE; ++ } ++ ++ /* Split */ ++ else { ++ remainder = chunk_at_offset(victim, nb); ++ ++ unsorted_chunks(av)->bk = unsorted_chunks(av)->fd = remainder; ++ remainder->bk = remainder->fd = unsorted_chunks(av); ++ /* advertise as last remainder */ ++ if (in_smallbin_range(nb)) ++ av->last_remainder = remainder; ++ ++ set_head(victim, nb | PREV_INUSE); ++ set_head(remainder, remainder_size | PREV_INUSE); ++ set_foot(remainder, remainder_size); ++ check_malloced_chunk(victim, nb); ++ retval = chunk2mem(victim); ++ goto DONE; ++ } ++ } + } + +-use_top: ++ use_top: + /* +- If large enough, split off the chunk bordering the end of memory +- (held in av->top). Note that this is in accord with the best-fit +- search rule. In effect, av->top is treated as larger (and thus +- less well fitting) than any other available chunk since it can +- be extended to be as large as necessary (up to system +- limitations). +- +- We require that av->top always exists (i.e., has size >= +- MINSIZE) after initialization, so if it would otherwise be +- exhuasted by current request, it is replenished. (The main +- reason for ensuring it exists is that we may need MINSIZE space +- to put in fenceposts in sysmalloc.) +- */ ++ If large enough, split off the chunk bordering the end of memory ++ (held in av->top). Note that this is in accord with the best-fit ++ search rule. In effect, av->top is treated as larger (and thus ++ less well fitting) than any other available chunk since it can ++ be extended to be as large as necessary (up to system ++ limitations). ++ ++ We require that av->top always exists (i.e., has size >= ++ MINSIZE) after initialization, so if it would otherwise be ++ exhuasted by current request, it is replenished. (The main ++ reason for ensuring it exists is that we may need MINSIZE space ++ to put in fenceposts in sysmalloc.) ++ */ + + victim = av->top; + size = chunksize(victim); + + if ((unsigned long)(size) >= (unsigned long)(nb + MINSIZE)) { +- remainder_size = size - nb; +- remainder = chunk_at_offset(victim, nb); +- av->top = remainder; +- set_head(victim, nb | PREV_INUSE); +- set_head(remainder, remainder_size | PREV_INUSE); +- +- check_malloced_chunk(victim, nb); +- UNLOCK; +- return chunk2mem(victim); ++ remainder_size = size - nb; ++ remainder = chunk_at_offset(victim, nb); ++ av->top = remainder; ++ set_head(victim, nb | PREV_INUSE); ++ set_head(remainder, remainder_size | PREV_INUSE); ++ ++ check_malloced_chunk(victim, nb); ++ retval = chunk2mem(victim); ++ goto DONE; + } + + /* If no space in top, relay to handle system-dependent cases */ + sysmem = __malloc_alloc(nb, av); +- UNLOCK; +- return sysmem; ++ retval = sysmem; ++ DONE: ++ __MALLOC_UNLOCK; ++ return retval; + } + +diff --git a/libc/stdlib/malloc-standard/malloc.h b/libc/stdlib/malloc-standard/malloc.h +index fbc1492..14a0dd9 100644 +--- a/libc/stdlib/malloc-standard/malloc.h ++++ b/libc/stdlib/malloc-standard/malloc.h +@@ -22,16 +22,12 @@ + #include + #include + ++#include + +-#ifdef __UCLIBC_HAS_THREADS__ +-#include +-extern pthread_mutex_t __malloc_lock; +-# define LOCK __pthread_mutex_lock(&__malloc_lock) +-# define UNLOCK __pthread_mutex_unlock(&__malloc_lock); +-#else +-# define LOCK +-# define UNLOCK +-#endif ++__UCLIBC_MUTEX_EXTERN(__malloc_lock); ++ ++#define __MALLOC_LOCK __UCLIBC_MUTEX_LOCK(__malloc_lock) ++#define __MALLOC_UNLOCK __UCLIBC_MUTEX_UNLOCK(__malloc_lock) + + + +diff --git a/libc/stdlib/malloc-standard/mallopt.c b/libc/stdlib/malloc-standard/mallopt.c +index e287920..41aa614 100644 +--- a/libc/stdlib/malloc-standard/mallopt.c ++++ b/libc/stdlib/malloc-standard/mallopt.c +@@ -8,7 +8,7 @@ + VERSION 2.7.2 Sat Aug 17 09:07:30 2002 Doug Lea (dl at gee) + + Note: There may be an updated version of this malloc obtainable at +- ftp://gee.cs.oswego.edu/pub/misc/malloc.c ++ ftp://gee.cs.oswego.edu/pub/misc/malloc.c + Check before installing! + + Hacked up for uClibc by Erik Andersen +@@ -25,40 +25,40 @@ int mallopt(int param_number, int value) + + ret = 0; + +- LOCK; ++ __MALLOC_LOCK; + av = get_malloc_state(); + /* Ensure initialization/consolidation */ + __malloc_consolidate(av); + + switch(param_number) { +- case M_MXFAST: +- if (value >= 0 && value <= MAX_FAST_SIZE) { +- set_max_fast(av, value); +- ret = 1; +- } +- break; +- +- case M_TRIM_THRESHOLD: +- av->trim_threshold = value; +- ret = 1; +- break; +- +- case M_TOP_PAD: +- av->top_pad = value; +- ret = 1; +- break; +- +- case M_MMAP_THRESHOLD: +- av->mmap_threshold = value; +- ret = 1; +- break; +- +- case M_MMAP_MAX: +- av->n_mmaps_max = value; +- ret = 1; +- break; ++ case M_MXFAST: ++ if (value >= 0 && value <= MAX_FAST_SIZE) { ++ set_max_fast(av, value); ++ ret = 1; ++ } ++ break; ++ ++ case M_TRIM_THRESHOLD: ++ av->trim_threshold = value; ++ ret = 1; ++ break; ++ ++ case M_TOP_PAD: ++ av->top_pad = value; ++ ret = 1; ++ break; ++ ++ case M_MMAP_THRESHOLD: ++ av->mmap_threshold = value; ++ ret = 1; ++ break; ++ ++ case M_MMAP_MAX: ++ av->n_mmaps_max = value; ++ ret = 1; ++ break; + } +- UNLOCK; ++ __MALLOC_UNLOCK; + return ret; + } + +diff --git a/libc/stdlib/malloc-standard/memalign.c b/libc/stdlib/malloc-standard/memalign.c +index bd95362..e78d752 100644 +--- a/libc/stdlib/malloc-standard/memalign.c ++++ b/libc/stdlib/malloc-standard/memalign.c +@@ -8,7 +8,7 @@ + VERSION 2.7.2 Sat Aug 17 09:07:30 2002 Doug Lea (dl at gee) + + Note: There may be an updated version of this malloc obtainable at +- ftp://gee.cs.oswego.edu/pub/misc/malloc.c ++ ftp://gee.cs.oswego.edu/pub/misc/malloc.c + Check before installing! + + Hacked up for uClibc by Erik Andersen +@@ -35,6 +35,7 @@ void* memalign(size_t alignment, size_t + mchunkptr remainder; /* spare room at end to split off */ + unsigned long remainder_size; /* its size */ + size_t size; ++ void *retval; + + /* If need less alignment than we give anyway, just relay to malloc */ + +@@ -46,12 +47,12 @@ void* memalign(size_t alignment, size_t + + /* Make sure alignment is power of 2 (in case MINSIZE is not). */ + if ((alignment & (alignment - 1)) != 0) { +- size_t a = MALLOC_ALIGNMENT * 2; +- while ((unsigned long)a < (unsigned long)alignment) a <<= 1; +- alignment = a; ++ size_t a = MALLOC_ALIGNMENT * 2; ++ while ((unsigned long)a < (unsigned long)alignment) a <<= 1; ++ alignment = a; + } + +- LOCK; ++ __MALLOC_LOCK; + checked_request2size(bytes, nb); + + /* Strategy: find a spot within that chunk that meets the alignment +@@ -63,64 +64,67 @@ void* memalign(size_t alignment, size_t + m = (char*)(malloc(nb + alignment + MINSIZE)); + + if (m == 0) { +- UNLOCK; +- return 0; /* propagate failure */ ++ retval = 0; /* propagate failure */ ++ goto DONE; + } + + p = mem2chunk(m); + + if ((((unsigned long)(m)) % alignment) != 0) { /* misaligned */ + +- /* +- Find an aligned spot inside chunk. Since we need to give back +- leading space in a chunk of at least MINSIZE, if the first +- calculation places us at a spot with less than MINSIZE leader, +- we can move to the next aligned spot -- we've allocated enough +- total room so that this is always possible. +- */ +- +- brk = (char*)mem2chunk((unsigned long)(((unsigned long)(m + alignment - 1)) & +- -((signed long) alignment))); +- if ((unsigned long)(brk - (char*)(p)) < MINSIZE) +- brk += alignment; +- +- newp = (mchunkptr)brk; +- leadsize = brk - (char*)(p); +- newsize = chunksize(p) - leadsize; +- +- /* For mmapped chunks, just adjust offset */ +- if (chunk_is_mmapped(p)) { +- newp->prev_size = p->prev_size + leadsize; +- set_head(newp, newsize|IS_MMAPPED); +- UNLOCK; +- return chunk2mem(newp); +- } +- +- /* Otherwise, give back leader, use the rest */ +- set_head(newp, newsize | PREV_INUSE); +- set_inuse_bit_at_offset(newp, newsize); +- set_head_size(p, leadsize); +- free(chunk2mem(p)); +- p = newp; ++ /* ++ Find an aligned spot inside chunk. Since we need to give back ++ leading space in a chunk of at least MINSIZE, if the first ++ calculation places us at a spot with less than MINSIZE leader, ++ we can move to the next aligned spot -- we've allocated enough ++ total room so that this is always possible. ++ */ ++ ++ brk = (char*)mem2chunk((unsigned long)(((unsigned long)(m + alignment - 1)) & ++ -((signed long) alignment))); ++ if ((unsigned long)(brk - (char*)(p)) < MINSIZE) ++ brk += alignment; ++ ++ newp = (mchunkptr)brk; ++ leadsize = brk - (char*)(p); ++ newsize = chunksize(p) - leadsize; ++ ++ /* For mmapped chunks, just adjust offset */ ++ if (chunk_is_mmapped(p)) { ++ newp->prev_size = p->prev_size + leadsize; ++ set_head(newp, newsize|IS_MMAPPED); ++ retval = chunk2mem(newp); ++ goto DONE; ++ } ++ ++ /* Otherwise, give back leader, use the rest */ ++ set_head(newp, newsize | PREV_INUSE); ++ set_inuse_bit_at_offset(newp, newsize); ++ set_head_size(p, leadsize); ++ free(chunk2mem(p)); ++ p = newp; + +- assert (newsize >= nb && +- (((unsigned long)(chunk2mem(p))) % alignment) == 0); ++ assert (newsize >= nb && ++ (((unsigned long)(chunk2mem(p))) % alignment) == 0); + } + + /* Also give back spare room at the end */ + if (!chunk_is_mmapped(p)) { +- size = chunksize(p); +- if ((unsigned long)(size) > (unsigned long)(nb + MINSIZE)) { +- remainder_size = size - nb; +- remainder = chunk_at_offset(p, nb); +- set_head(remainder, remainder_size | PREV_INUSE); +- set_head_size(p, nb); +- free(chunk2mem(remainder)); +- } ++ size = chunksize(p); ++ if ((unsigned long)(size) > (unsigned long)(nb + MINSIZE)) { ++ remainder_size = size - nb; ++ remainder = chunk_at_offset(p, nb); ++ set_head(remainder, remainder_size | PREV_INUSE); ++ set_head_size(p, nb); ++ free(chunk2mem(remainder)); ++ } + } + + check_inuse_chunk(p); +- UNLOCK; +- return chunk2mem(p); ++ retval = chunk2mem(p); ++ ++ DONE: ++ __MALLOC_UNLOCK; ++ return retval; + } + +diff --git a/libc/stdlib/malloc-standard/realloc.c b/libc/stdlib/malloc-standard/realloc.c +index 1950130..9ca4b26 100644 +--- a/libc/stdlib/malloc-standard/realloc.c ++++ b/libc/stdlib/malloc-standard/realloc.c +@@ -8,7 +8,7 @@ + VERSION 2.7.2 Sat Aug 17 09:07:30 2002 Doug Lea (dl at gee) + + Note: There may be an updated version of this malloc obtainable at +- ftp://gee.cs.oswego.edu/pub/misc/malloc.c ++ ftp://gee.cs.oswego.edu/pub/misc/malloc.c + Check before installing! + + Hacked up for uClibc by Erik Andersen +@@ -23,14 +23,14 @@ void* realloc(void* oldmem, size_t bytes + { + mstate av; + +- size_t nb; /* padded request size */ ++ size_t nb; /* padded request size */ + + mchunkptr oldp; /* chunk corresponding to oldmem */ +- size_t oldsize; /* its size */ ++ size_t oldsize; /* its size */ + + mchunkptr newp; /* chunk to return */ +- size_t newsize; /* its size */ +- void* newmem; /* corresponding user mem */ ++ size_t newsize; /* its size */ ++ void* newmem; /* corresponding user mem */ + + mchunkptr next; /* next contiguous chunk after oldp */ + +@@ -40,21 +40,23 @@ void* realloc(void* oldmem, size_t bytes + mchunkptr bck; /* misc temp for linking */ + mchunkptr fwd; /* misc temp for linking */ + +- unsigned long copysize; /* bytes to copy */ ++ unsigned long copysize; /* bytes to copy */ + unsigned int ncopies; /* size_t words to copy */ +- size_t* s; /* copy source */ +- size_t* d; /* copy destination */ ++ size_t* s; /* copy source */ ++ size_t* d; /* copy destination */ ++ ++ void *retval; + + + /* Check for special cases. */ + if (! oldmem) +- return malloc(bytes); ++ return malloc(bytes); + if (! bytes) { +- free (oldmem); +- return malloc(bytes); ++ free (oldmem); ++ return malloc(bytes); + } + +- LOCK; ++ __MALLOC_LOCK; + av = get_malloc_state(); + checked_request2size(bytes, nb); + +@@ -65,173 +67,176 @@ void* realloc(void* oldmem, size_t bytes + + if (!chunk_is_mmapped(oldp)) { + +- if ((unsigned long)(oldsize) >= (unsigned long)(nb)) { +- /* already big enough; split below */ +- newp = oldp; +- newsize = oldsize; +- } +- +- else { +- next = chunk_at_offset(oldp, oldsize); +- +- /* Try to expand forward into top */ +- if (next == av->top && +- (unsigned long)(newsize = oldsize + chunksize(next)) >= +- (unsigned long)(nb + MINSIZE)) { +- set_head_size(oldp, nb); +- av->top = chunk_at_offset(oldp, nb); +- set_head(av->top, (newsize - nb) | PREV_INUSE); +- UNLOCK; +- return chunk2mem(oldp); +- } +- +- /* Try to expand forward into next chunk; split off remainder below */ +- else if (next != av->top && +- !inuse(next) && +- (unsigned long)(newsize = oldsize + chunksize(next)) >= +- (unsigned long)(nb)) { +- newp = oldp; +- unlink(next, bck, fwd); +- } +- +- /* allocate, copy, free */ +- else { +- newmem = malloc(nb - MALLOC_ALIGN_MASK); +- if (newmem == 0) { +- UNLOCK; +- return 0; /* propagate failure */ +- } +- +- newp = mem2chunk(newmem); +- newsize = chunksize(newp); +- +- /* +- Avoid copy if newp is next chunk after oldp. +- */ +- if (newp == next) { +- newsize += oldsize; +- newp = oldp; ++ if ((unsigned long)(oldsize) >= (unsigned long)(nb)) { ++ /* already big enough; split below */ ++ newp = oldp; ++ newsize = oldsize; + } ++ + else { +- /* +- Unroll copy of <= 36 bytes (72 if 8byte sizes) +- We know that contents have an odd number of +- size_t-sized words; minimally 3. +- */ +- +- copysize = oldsize - (sizeof(size_t)); +- s = (size_t*)(oldmem); +- d = (size_t*)(newmem); +- ncopies = copysize / sizeof(size_t); +- assert(ncopies >= 3); +- +- if (ncopies > 9) +- memcpy(d, s, copysize); +- +- else { +- *(d+0) = *(s+0); +- *(d+1) = *(s+1); +- *(d+2) = *(s+2); +- if (ncopies > 4) { +- *(d+3) = *(s+3); +- *(d+4) = *(s+4); +- if (ncopies > 6) { +- *(d+5) = *(s+5); +- *(d+6) = *(s+6); +- if (ncopies > 8) { +- *(d+7) = *(s+7); +- *(d+8) = *(s+8); ++ next = chunk_at_offset(oldp, oldsize); ++ ++ /* Try to expand forward into top */ ++ if (next == av->top && ++ (unsigned long)(newsize = oldsize + chunksize(next)) >= ++ (unsigned long)(nb + MINSIZE)) { ++ set_head_size(oldp, nb); ++ av->top = chunk_at_offset(oldp, nb); ++ set_head(av->top, (newsize - nb) | PREV_INUSE); ++ retval = chunk2mem(oldp); ++ goto DONE; ++ } ++ ++ /* Try to expand forward into next chunk; split off remainder below */ ++ else if (next != av->top && ++ !inuse(next) && ++ (unsigned long)(newsize = oldsize + chunksize(next)) >= ++ (unsigned long)(nb)) { ++ newp = oldp; ++ unlink(next, bck, fwd); ++ } ++ ++ /* allocate, copy, free */ ++ else { ++ newmem = malloc(nb - MALLOC_ALIGN_MASK); ++ if (newmem == 0) { ++ retval = 0; /* propagate failure */ ++ goto DONE; ++ } ++ ++ newp = mem2chunk(newmem); ++ newsize = chunksize(newp); ++ ++ /* ++ Avoid copy if newp is next chunk after oldp. ++ */ ++ if (newp == next) { ++ newsize += oldsize; ++ newp = oldp; ++ } ++ else { ++ /* ++ Unroll copy of <= 36 bytes (72 if 8byte sizes) ++ We know that contents have an odd number of ++ size_t-sized words; minimally 3. ++ */ ++ ++ copysize = oldsize - (sizeof(size_t)); ++ s = (size_t*)(oldmem); ++ d = (size_t*)(newmem); ++ ncopies = copysize / sizeof(size_t); ++ assert(ncopies >= 3); ++ ++ if (ncopies > 9) ++ memcpy(d, s, copysize); ++ ++ else { ++ *(d+0) = *(s+0); ++ *(d+1) = *(s+1); ++ *(d+2) = *(s+2); ++ if (ncopies > 4) { ++ *(d+3) = *(s+3); ++ *(d+4) = *(s+4); ++ if (ncopies > 6) { ++ *(d+5) = *(s+5); ++ *(d+6) = *(s+6); ++ if (ncopies > 8) { ++ *(d+7) = *(s+7); ++ *(d+8) = *(s+8); ++ } ++ } ++ } ++ } ++ ++ free(oldmem); ++ check_inuse_chunk(newp); ++ retval = chunk2mem(newp); ++ goto DONE; + } +- } + } +- } ++ } ++ ++ /* If possible, free extra space in old or extended chunk */ ++ ++ assert((unsigned long)(newsize) >= (unsigned long)(nb)); ++ ++ remainder_size = newsize - nb; + +- free(oldmem); +- check_inuse_chunk(newp); +- UNLOCK; +- return chunk2mem(newp); +- } +- } +- } +- +- /* If possible, free extra space in old or extended chunk */ +- +- assert((unsigned long)(newsize) >= (unsigned long)(nb)); +- +- remainder_size = newsize - nb; +- +- if (remainder_size < MINSIZE) { /* not enough extra to split off */ +- set_head_size(newp, newsize); +- set_inuse_bit_at_offset(newp, newsize); +- } +- else { /* split remainder */ +- remainder = chunk_at_offset(newp, nb); +- set_head_size(newp, nb); +- set_head(remainder, remainder_size | PREV_INUSE); +- /* Mark remainder as inuse so free() won't complain */ +- set_inuse_bit_at_offset(remainder, remainder_size); +- free(chunk2mem(remainder)); +- } +- +- check_inuse_chunk(newp); +- UNLOCK; +- return chunk2mem(newp); ++ if (remainder_size < MINSIZE) { /* not enough extra to split off */ ++ set_head_size(newp, newsize); ++ set_inuse_bit_at_offset(newp, newsize); ++ } ++ else { /* split remainder */ ++ remainder = chunk_at_offset(newp, nb); ++ set_head_size(newp, nb); ++ set_head(remainder, remainder_size | PREV_INUSE); ++ /* Mark remainder as inuse so free() won't complain */ ++ set_inuse_bit_at_offset(remainder, remainder_size); ++ free(chunk2mem(remainder)); ++ } ++ ++ check_inuse_chunk(newp); ++ retval = chunk2mem(newp); ++ goto DONE; + } + + /* +- Handle mmap cases +- */ ++ Handle mmap cases ++ */ + + else { +- size_t offset = oldp->prev_size; +- size_t pagemask = av->pagesize - 1; +- char *cp; +- unsigned long sum; +- +- /* Note the extra (sizeof(size_t)) overhead */ +- newsize = (nb + offset + (sizeof(size_t)) + pagemask) & ~pagemask; +- +- /* don't need to remap if still within same page */ +- if (oldsize == newsize - offset) { +- UNLOCK; +- return oldmem; +- } +- +- cp = (char*)mremap((char*)oldp - offset, oldsize + offset, newsize, 1); +- +- if (cp != (char*)MORECORE_FAILURE) { +- +- newp = (mchunkptr)(cp + offset); +- set_head(newp, (newsize - offset)|IS_MMAPPED); +- +- assert(aligned_OK(chunk2mem(newp))); +- assert((newp->prev_size == offset)); +- +- /* update statistics */ +- sum = av->mmapped_mem += newsize - oldsize; +- if (sum > (unsigned long)(av->max_mmapped_mem)) +- av->max_mmapped_mem = sum; +- sum += av->sbrked_mem; +- if (sum > (unsigned long)(av->max_total_mem)) +- av->max_total_mem = sum; +- +- UNLOCK; +- return chunk2mem(newp); +- } +- +- /* Note the extra (sizeof(size_t)) overhead. */ +- if ((unsigned long)(oldsize) >= (unsigned long)(nb + (sizeof(size_t)))) +- newmem = oldmem; /* do nothing */ +- else { +- /* Must alloc, copy, free. */ +- newmem = malloc(nb - MALLOC_ALIGN_MASK); +- if (newmem != 0) { +- memcpy(newmem, oldmem, oldsize - 2*(sizeof(size_t))); +- free(oldmem); +- } +- } +- UNLOCK; +- return newmem; ++ size_t offset = oldp->prev_size; ++ size_t pagemask = av->pagesize - 1; ++ char *cp; ++ unsigned long sum; ++ ++ /* Note the extra (sizeof(size_t)) overhead */ ++ newsize = (nb + offset + (sizeof(size_t)) + pagemask) & ~pagemask; ++ ++ /* don't need to remap if still within same page */ ++ if (oldsize == newsize - offset) { ++ retval = oldmem; ++ goto DONE; ++ } ++ ++ cp = (char*)mremap((char*)oldp - offset, oldsize + offset, newsize, 1); ++ ++ if (cp != (char*)MORECORE_FAILURE) { ++ ++ newp = (mchunkptr)(cp + offset); ++ set_head(newp, (newsize - offset)|IS_MMAPPED); ++ ++ assert(aligned_OK(chunk2mem(newp))); ++ assert((newp->prev_size == offset)); ++ ++ /* update statistics */ ++ sum = av->mmapped_mem += newsize - oldsize; ++ if (sum > (unsigned long)(av->max_mmapped_mem)) ++ av->max_mmapped_mem = sum; ++ sum += av->sbrked_mem; ++ if (sum > (unsigned long)(av->max_total_mem)) ++ av->max_total_mem = sum; ++ ++ retval = chunk2mem(newp); ++ goto DONE; ++ } ++ ++ /* Note the extra (sizeof(size_t)) overhead. */ ++ if ((unsigned long)(oldsize) >= (unsigned long)(nb + (sizeof(size_t)))) ++ newmem = oldmem; /* do nothing */ ++ else { ++ /* Must alloc, copy, free. */ ++ newmem = malloc(nb - MALLOC_ALIGN_MASK); ++ if (newmem != 0) { ++ memcpy(newmem, oldmem, oldsize - 2*(sizeof(size_t))); ++ free(oldmem); ++ } ++ } ++ retval = newmem; + } ++ ++ DONE: ++ __MALLOC_UNLOCK; ++ return retval; + } + +diff --git a/libc/stdlib/random.c b/libc/stdlib/random.c +index b0a00e1..1bd63bc 100644 +--- a/libc/stdlib/random.c ++++ b/libc/stdlib/random.c +@@ -27,16 +27,14 @@ + #include + #include + #include +-#ifdef __UCLIBC_HAS_THREADS__ +-#include ++ + /* POSIX.1c requires that there is mutual exclusion for the `rand' and + `srand' functions to prevent concurrent calls from modifying common + data. */ +-static pthread_mutex_t lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; +-#else +-#define __pthread_mutex_lock(x) +-#define __pthread_mutex_unlock(x) +-#endif ++ ++#include ++ ++__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP); + + /* An improved random number generation package. In addition to the standard + rand()/srand() like interface, this package also has a special state info +@@ -184,9 +182,9 @@ static struct random_data unsafe_state = + for default usage relies on values produced by this routine. */ + void srandom (unsigned int x) + { +- __pthread_mutex_lock(&lock); ++ __UCLIBC_MUTEX_LOCK(mylock); + srandom_r (x, &unsafe_state); +- __pthread_mutex_unlock(&lock); ++ __UCLIBC_MUTEX_UNLOCK(mylock); + } + weak_alias (srandom, srand) + +@@ -205,10 +203,10 @@ char * initstate (unsigned int seed, cha + { + int32_t *ostate; + +- __pthread_mutex_lock(&lock); ++ __UCLIBC_MUTEX_LOCK(mylock); + ostate = &unsafe_state.state[-1]; + initstate_r (seed, arg_state, n, &unsafe_state); +- __pthread_mutex_unlock(&lock); ++ __UCLIBC_MUTEX_UNLOCK(mylock); + return (char *) ostate; + } + +@@ -224,11 +222,11 @@ char * setstate (char *arg_state) + { + int32_t *ostate; + +- __pthread_mutex_lock(&lock); ++ __UCLIBC_MUTEX_LOCK(mylock); + ostate = &unsafe_state.state[-1]; + if (setstate_r (arg_state, &unsafe_state) < 0) + ostate = NULL; +- __pthread_mutex_unlock(&lock); ++ __UCLIBC_MUTEX_UNLOCK(mylock); + return (char *) ostate; + } + +@@ -247,9 +245,9 @@ long int random () + { + int32_t retval; + +- __pthread_mutex_lock(&lock); ++ __UCLIBC_MUTEX_LOCK(mylock); + random_r (&unsafe_state, &retval); +- __pthread_mutex_unlock(&lock); ++ __UCLIBC_MUTEX_UNLOCK(mylock); + return retval; + } + +diff --git a/libc/stdlib/setenv.c b/libc/stdlib/setenv.c +index d0cfe52..2d899cc 100644 +--- a/libc/stdlib/setenv.c ++++ b/libc/stdlib/setenv.c +@@ -17,7 +17,7 @@ + 02111-1307 USA. + + modified for uClibc by Erik Andersen +- */ ++*/ + + #define _GNU_SOURCE + #include +@@ -26,16 +26,9 @@ + #include + #include + +-#ifdef __UCLIBC_HAS_THREADS__ +-#include +-static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER; +-# define LOCK __pthread_mutex_lock(&mylock) +-# define UNLOCK __pthread_mutex_unlock(&mylock); +-#else +-# define LOCK +-# define UNLOCK +-#endif ++#include + ++__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER); + + /* If this variable is not a null pointer we allocated the current + environment. */ +@@ -49,14 +42,15 @@ static char **last_environ; + to reuse values once generated for a `setenv' call since we can never + free the strings. */ + int __add_to_environ (const char *name, const char *value, +- const char *combined, int replace) ++ const char *combined, int replace) + { + register char **ep; + register size_t size; + const size_t namelen = strlen (name); + const size_t vallen = value != NULL ? strlen (value) + 1 : 0; ++ int rv = -1; + +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + + /* We have to get the pointer now that we have the lock and not earlier + since another thread might have created a new environment. */ +@@ -64,72 +58,72 @@ int __add_to_environ (const char *name, + + size = 0; + if (ep != NULL) { +- for (; *ep != NULL; ++ep) { +- if (!strncmp (*ep, name, namelen) && (*ep)[namelen] == '=') +- break; +- else +- ++size; +- } ++ for (; *ep != NULL; ++ep) { ++ if (!strncmp (*ep, name, namelen) && (*ep)[namelen] == '=') ++ break; ++ else ++ ++size; ++ } + } + + if (ep == NULL || *ep == NULL) { +- char **new_environ; ++ char **new_environ; + +- /* We allocated this space; we can extend it. */ +- new_environ = (char **) realloc (last_environ, +- (size + 2) * sizeof (char *)); +- if (new_environ == NULL) { +- UNLOCK; +- return -1; +- } +- +- /* If the whole entry is given add it. */ +- if (combined != NULL) { +- /* We must not add the string to the search tree since it belongs +- to the user. */ +- new_environ[size] = (char *) combined; +- } else { +- /* See whether the value is already known. */ +- new_environ[size] = (char *) malloc (namelen + 1 + vallen); +- if (new_environ[size] == NULL) { +- __set_errno (ENOMEM); +- UNLOCK; +- return -1; +- } +- +- memcpy (new_environ[size], name, namelen); +- new_environ[size][namelen] = '='; +- memcpy (&new_environ[size][namelen + 1], value, vallen); +- } +- +- if (__environ != last_environ) { +- memcpy ((char *) new_environ, (char *) __environ, +- size * sizeof (char *)); +- } ++ /* We allocated this space; we can extend it. */ ++ new_environ = (char **) realloc (last_environ, ++ (size + 2) * sizeof (char *)); ++ if (new_environ == NULL) { ++ goto DONE; ++ } ++ ++ /* If the whole entry is given add it. */ ++ if (combined != NULL) { ++ /* We must not add the string to the search tree since it belongs ++ to the user. */ ++ new_environ[size] = (char *) combined; ++ } else { ++ /* See whether the value is already known. */ ++ new_environ[size] = (char *) malloc (namelen + 1 + vallen); ++ if (new_environ[size] == NULL) { ++ __set_errno (ENOMEM); ++ goto DONE; ++ } ++ ++ memcpy (new_environ[size], name, namelen); ++ new_environ[size][namelen] = '='; ++ memcpy (&new_environ[size][namelen + 1], value, vallen); ++ } ++ ++ if (__environ != last_environ) { ++ memcpy ((char *) new_environ, (char *) __environ, ++ size * sizeof (char *)); ++ } + +- new_environ[size + 1] = NULL; +- last_environ = __environ = new_environ; ++ new_environ[size + 1] = NULL; ++ last_environ = __environ = new_environ; + } else if (replace) { +- char *np; ++ char *np; + +- /* Use the user string if given. */ +- if (combined != NULL) { +- np = (char *) combined; +- } else { +- np = malloc (namelen + 1 + vallen); +- if (np == NULL) { +- UNLOCK; +- return -1; +- } +- memcpy (np, name, namelen); +- np[namelen] = '='; +- memcpy (&np[namelen + 1], value, vallen); +- } +- *ep = np; +- } +- +- UNLOCK; +- return 0; ++ /* Use the user string if given. */ ++ if (combined != NULL) { ++ np = (char *) combined; ++ } else { ++ np = malloc (namelen + 1 + vallen); ++ if (np == NULL) { ++ goto DONE; ++ } ++ memcpy (np, name, namelen); ++ np[namelen] = '='; ++ memcpy (&np[namelen + 1], value, vallen); ++ } ++ *ep = np; ++ } ++ ++ rv = 0; ++ ++ DONE: ++ __UCLIBC_MUTEX_UNLOCK(mylock); ++ return rv; + } + + int setenv (const char *name, const char *value, int replace) +@@ -143,26 +137,26 @@ int unsetenv (const char *name) + char **ep; + + if (name == NULL || *name == '\0' || strchr (name, '=') != NULL) { +- __set_errno (EINVAL); +- return -1; ++ __set_errno (EINVAL); ++ return -1; + } + + len = strlen (name); +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + ep = __environ; + while (*ep != NULL) { +- if (!strncmp (*ep, name, len) && (*ep)[len] == '=') { +- /* Found it. Remove this pointer by moving later ones back. */ +- char **dp = ep; +- do { +- dp[0] = dp[1]; +- } while (*dp++); +- /* Continue the loop in case NAME appears again. */ +- } else { +- ++ep; +- } ++ if (!strncmp (*ep, name, len) && (*ep)[len] == '=') { ++ /* Found it. Remove this pointer by moving later ones back. */ ++ char **dp = ep; ++ do { ++ dp[0] = dp[1]; ++ } while (*dp++); ++ /* Continue the loop in case NAME appears again. */ ++ } else { ++ ++ep; ++ } + } +- UNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(mylock); + return 0; + } + +@@ -171,15 +165,15 @@ int unsetenv (const char *name) + for Fortran 77) requires this function. */ + int clearenv (void) + { +- LOCK; ++ __UCLIBC_MUTEX_LOCK(mylock); + if (__environ == last_environ && __environ != NULL) { +- /* We allocated this environment so we can free it. */ +- free (__environ); +- last_environ = NULL; ++ /* We allocated this environment so we can free it. */ ++ free (__environ); ++ last_environ = NULL; + } + /* Clear the environment pointer removes the whole environment. */ + __environ = NULL; +- UNLOCK; ++ __UCLIBC_MUTEX_UNLOCK(mylock); + return 0; + } + +@@ -190,10 +184,10 @@ int putenv (char *string) + const char *const name_end = strchr (string, '='); + + if (name_end != NULL) { +- char *name = strndup(string, name_end - string); +- result = __add_to_environ (name, NULL, string, 1); +- free(name); +- return(result); ++ char *name = strndup(string, name_end - string); ++ result = __add_to_environ (name, NULL, string, 1); ++ free(name); ++ return(result); + } + unsetenv (string); + return 0; +diff --git a/libc/sysdeps/linux/common/bits/uClibc_stdio.h b/libc/sysdeps/linux/common/bits/uClibc_stdio.h +index 40cd5fe..3c6911e 100644 +--- a/libc/sysdeps/linux/common/bits/uClibc_stdio.h ++++ b/libc/sysdeps/linux/common/bits/uClibc_stdio.h +@@ -116,9 +116,7 @@ + #endif + + /**********************************************************************/ +-#ifdef __UCLIBC_HAS_THREADS__ +-/* Need this for pthread_mutex_t. */ +-#include ++#include + + /* user_locking + * 0 : do auto locking/unlocking +@@ -132,43 +130,37 @@ + * This way, we avoid calling the weak lock/unlock functions. + */ + +-#define __STDIO_AUTO_THREADLOCK_VAR int __infunc_user_locking +- +-#define __STDIO_AUTO_THREADLOCK(__stream) \ +- if ((__infunc_user_locking = (__stream)->__user_locking) == 0) { \ +- __pthread_mutex_lock(&(__stream)->__lock); \ +- } +- +-#define __STDIO_AUTO_THREADUNLOCK(__stream) \ +- if (__infunc_user_locking == 0) { \ +- __pthread_mutex_unlock(&(__stream)->__lock); \ +- } ++#define __STDIO_AUTO_THREADLOCK_VAR \ ++ __UCLIBC_MUTEX_AUTO_LOCK_VAR(__infunc_user_locking) + +-#define __STDIO_SET_USER_LOCKING(__stream) ((__stream)->__user_locking = 1) ++#define __STDIO_AUTO_THREADLOCK(__stream) \ ++ __UCLIBC_MUTEX_AUTO_LOCK((__stream)->__lock, __infunc_user_locking, \ ++ (__stream)->__user_locking) + +-#define __STDIO_ALWAYS_THREADLOCK(__stream) \ +- __pthread_mutex_lock(&(__stream)->__lock) ++#define __STDIO_AUTO_THREADUNLOCK(__stream) \ ++ __UCLIBC_MUTEX_AUTO_UNLOCK((__stream)->__lock, __infunc_user_locking) + +-#define __STDIO_ALWAYS_THREADTRYLOCK(__stream) \ +- __pthread_mutex_trylock(&(__stream)->__lock) ++#define __STDIO_ALWAYS_THREADLOCK(__stream) \ ++ __UCLIBC_MUTEX_LOCK((__stream)->__lock) + +-#define __STDIO_ALWAYS_THREADUNLOCK(__stream) \ +- __pthread_mutex_unlock(&(__stream)->__lock) ++#define __STDIO_ALWAYS_THREADUNLOCK(__stream) \ ++ __UCLIBC_MUTEX_UNLOCK((__stream)->__lock) + +-#else /* __UCLIBC_HAS_THREADS__ */ ++#define __STDIO_ALWAYS_THREADLOCK_CANCEL_UNSAFE(__stream) \ ++ __UCLIBC_MUTEX_LOCK_CANCEL_UNSAFE((__stream)->__lock) + +-#define __STDIO_AUTO_THREADLOCK_VAR ((void)0) ++#define __STDIO_ALWAYS_THREADTRYLOCK_CANCEL_UNSAFE(__stream) \ ++ __UCLIBC_MUTEX_TRYLOCK_CANCEL_UNSAFE((__stream)->__lock) + +-#define __STDIO_AUTO_THREADLOCK(__stream) ((void)0) +-#define __STDIO_AUTO_THREADUNLOCK(__stream) ((void)0) ++#define __STDIO_ALWAYS_THREADUNLOCK_CANCEL_UNSAFE(__stream) \ ++ __UCLIBC_MUTEX_UNLOCK_CANCEL_UNSAFE((__stream)->__lock) + ++#ifdef __UCLIBC_HAS_THREADS__ ++#define __STDIO_SET_USER_LOCKING(__stream) ((__stream)->__user_locking = 1) ++#else + #define __STDIO_SET_USER_LOCKING(__stream) ((void)0) ++#endif + +-#define __STDIO_ALWAYS_THREADLOCK(__stream) ((void)0) +-#define __STDIO_ALWAYS_THREADTRYLOCK(__stream) (0) /* Always succeed. */ +-#define __STDIO_ALWAYS_THREADUNLOCK(__stream) ((void)0) +- +-#endif /* __UCLIBC_HAS_THREADS__ */ + /**********************************************************************/ + + #define __STDIO_IOFBF 0 /* Fully buffered. */ +@@ -283,7 +275,7 @@ struct __STDIO_FILE_STRUCT { + #endif + #ifdef __UCLIBC_HAS_THREADS__ + int __user_locking; +- pthread_mutex_t __lock; ++ __UCLIBC_MUTEX(__lock); + #endif + /* Everything after this is unimplemented... and may be trashed. */ + #if __STDIO_BUILTIN_BUF_SIZE > 0 +@@ -358,10 +350,14 @@ extern void _stdio_term(void); + extern struct __STDIO_FILE_STRUCT *_stdio_openlist; + + #ifdef __UCLIBC_HAS_THREADS__ +-extern pthread_mutex_t _stdio_openlist_lock; +-extern int _stdio_openlist_delflag; ++__UCLIBC_MUTEX_EXTERN(_stdio_openlist_add_lock); ++#ifdef __STDIO_BUFFERS ++__UCLIBC_MUTEX_EXTERN(_stdio_openlist_del_lock); ++extern volatile int _stdio_openlist_use_count; /* _stdio_openlist_del_lock */ ++extern int _stdio_openlist_del_count; /* _stdio_openlist_del_lock */ ++#endif + extern int _stdio_user_locking; +-extern void __stdio_init_mutex(pthread_mutex_t *m); ++extern void __stdio_init_mutex(__UCLIBC_MUTEX_TYPE *m); + #endif + + #endif +diff --git a/libc/sysdeps/linux/common/getdents.c b/libc/sysdeps/linux/common/getdents.c +index ab6a276..23463e5 100644 +--- a/libc/sysdeps/linux/common/getdents.c ++++ b/libc/sysdeps/linux/common/getdents.c +@@ -30,8 +30,6 @@ + #include + + +-#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +- + struct kernel_dirent + { + long d_ino; +diff --git a/libc/sysdeps/linux/common/sigprocmask.c b/libc/sysdeps/linux/common/sigprocmask.c +index 70ff366..565318d 100644 +--- a/libc/sysdeps/linux/common/sigprocmask.c ++++ b/libc/sysdeps/linux/common/sigprocmask.c +@@ -23,6 +23,8 @@ int sigprocmask(int how, const sigset_t + if (set && + #if (SIG_BLOCK == 0) && (SIG_UNBLOCK == 1) && (SIG_SETMASK == 2) + (((unsigned int) how) > 2) ++#elif (SIG_BLOCK == 1) && (SIG_UNBLOCK == 2) && (SIG_SETMASK == 3) ++ (((unsigned int)(how-1)) > 2) + #else + #warning "compile time assumption violated.. slow path..." + ((how != SIG_BLOCK) && (how != SIG_UNBLOCK) +@@ -48,6 +50,8 @@ int sigprocmask(int how, const sigset_t + if (set && + #if (SIG_BLOCK == 0) && (SIG_UNBLOCK == 1) && (SIG_SETMASK == 2) + (((unsigned int) how) > 2) ++#elif (SIG_BLOCK == 1) && (SIG_UNBLOCK == 2) && (SIG_SETMASK == 3) ++ (((unsigned int)(how-1)) > 2) + #else + #warning "compile time assumption violated.. slow path..." + ((how != SIG_BLOCK) && (how != SIG_UNBLOCK) +diff --git a/libc/sysdeps/linux/mips/bits/kernel_sigaction.h b/libc/sysdeps/linux/mips/bits/kernel_sigaction.h +index b6f52cc..317e5b3 100644 +--- a/libc/sysdeps/linux/mips/bits/kernel_sigaction.h ++++ b/libc/sysdeps/linux/mips/bits/kernel_sigaction.h +@@ -38,3 +38,6 @@ struct kernel_sigaction { + void (*sa_restorer)(void); + int s_resv[1]; /* reserved */ + }; ++ ++extern int __syscall_rt_sigaction (int, const struct kernel_sigaction *__unbounded, ++ struct kernel_sigaction *__unbounded, size_t); +diff --git a/libc/sysdeps/linux/mips/pipe.S b/libc/sysdeps/linux/mips/pipe.S +index c3afae5..cd88074 100644 +--- a/libc/sysdeps/linux/mips/pipe.S ++++ b/libc/sysdeps/linux/mips/pipe.S +@@ -7,25 +7,36 @@ + #include + #include + +- .globl pipe +- .ent pipe, 0 ++ .globl pipe ++ .ent pipe, 0 + pipe: +- addiu sp,sp,-24 +- sw a0,16(sp) +- li v0,__NR_pipe +- syscall +- beqz a3, 1f +- la t3, errno +- sw v0, (t3) +- li v0, -1 +- b 2f ++ .frame sp, 24, sp ++#ifdef __PIC__ ++ .set noreorder ++ .cpload $25 ++ .set reorder ++ addiu sp,sp,-24 ++ .cprestore 16 ++#else ++ addiu sp,sp,-24 ++#endif ++ sw a0,16(sp) ++ li v0,__NR_pipe ++ syscall ++ beqz a3, 1f ++#ifdef __PIC__ ++ la t0, __syscall_error ++ jr t9 ++#else ++ j __syscall_error ++#endif + 1: +- lw a0, 16(sp) +- sw v0, 0(a0) +- sw v1, 4(a0) +- li v0, 0 ++ lw a0, 16(sp) ++ sw v0, 0(a0) ++ sw v1, 4(a0) ++ li v0, 0 + 2: +- addiu sp,sp,24 +- j ra +- .end pipe +- .size pipe,.-pipe ++ addiu sp,sp,24 ++ j ra ++ .end pipe ++ .size pipe,.-pipe +diff --git a/libcrypt/des.c b/libcrypt/des.c +index 3b49a7a..f7a6be1 100644 +--- a/libcrypt/des.c ++++ b/libcrypt/des.c +@@ -504,7 +504,7 @@ do_des( u_int32_t l_in, u_int32_t r_in, + kl = kl1; + kr = kr1; + round = 16; +- while (round--) { ++ do { + /* + * Expand R to 48 bits (simulate the E-box). + */ +@@ -540,7 +540,7 @@ do_des( u_int32_t l_in, u_int32_t r_in, + f ^= l; + l = r; + r = f; +- } ++ } while (--round); + r = l; + l = f; + } +diff --git a/libpthread/linuxthreads/ptfork.c b/libpthread/linuxthreads/ptfork.c +index eb544f3..cfec2b7 100644 +--- a/libpthread/linuxthreads/ptfork.c ++++ b/libpthread/linuxthreads/ptfork.c +@@ -26,6 +26,15 @@ + #include "pthread.h" + #include "internals.h" + ++#warning hack alert... should be sufficent for system(), but what about other libc mutexes? ++#include ++ ++__UCLIBC_MUTEX_EXTERN(__malloc_lock); ++ ++#define __MALLOC_LOCK __UCLIBC_MUTEX_LOCK(__malloc_lock) ++#define __MALLOC_UNLOCK __UCLIBC_MUTEX_UNLOCK(__malloc_lock) ++#warning hack alert block end ++ + struct handler_list { + void (*handler)(void); + struct handler_list * next; +@@ -91,9 +100,18 @@ pid_t __fork(void) + parent = pthread_atfork_parent; + pthread_mutex_unlock(&pthread_atfork_lock); + pthread_call_handlers(prepare); ++ ++#warning hack alert ++ __MALLOC_LOCK; ++ + pid = __libc_fork(); ++ ++#warning hack alert ++ __MALLOC_UNLOCK; ++ + if (pid == 0) { + __pthread_reset_main_thread(); ++#warning need to reconsider __fresetlockfiles! + __fresetlockfiles(); + pthread_call_handlers(child); + } else { +diff -urN -x .git uClibc-0.9.28/libc/sysdeps/linux/common/bits/uClibc_mutex.h uClibc-mjn3/libc/sysdeps/linux/common/bits/uClibc_mutex.h +--- uClibc-0.9.28/libc/sysdeps/linux/common/bits/uClibc_mutex.h 1969-12-31 17:00:00.000000000 -0700 ++++ uClibc-mjn3/libc/sysdeps/linux/common/bits/uClibc_mutex.h 2006-03-08 11:21:58.000000000 -0700 +@@ -0,0 +1,87 @@ ++/* Copyright (C) 2006 Manuel Novoa III ++ * ++ * GNU Library General Public License (LGPL) version 2 or later. ++ * ++ * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details. ++ */ ++ ++#ifndef _UCLIBC_MUTEX_H ++#define _UCLIBC_MUTEX_H ++ ++#include ++ ++#ifdef __UCLIBC_HAS_THREADS__ ++ ++#include ++ ++#define __UCLIBC_MUTEX_TYPE pthread_mutex_t ++ ++#define __UCLIBC_MUTEX(M) pthread_mutex_t M ++#define __UCLIBC_MUTEX_INIT(M,I) pthread_mutex_t M = I ++#define __UCLIBC_MUTEX_STATIC(M,I) static pthread_mutex_t M = I ++#define __UCLIBC_MUTEX_EXTERN(M) extern pthread_mutex_t M ++ ++#define __UCLIBC_MUTEX_LOCK_CANCEL_UNSAFE(M) \ ++ __pthread_mutex_lock(&(M)) ++ ++#define __UCLIBC_MUTEX_UNLOCK_CANCEL_UNSAFE(M) \ ++ __pthread_mutex_unlock(&(M)) ++ ++#define __UCLIBC_MUTEX_TRYLOCK_CANCEL_UNSAFE(M) \ ++ __pthread_mutex_trylock(&(M)) ++ ++#define __UCLIBC_MUTEX_CONDITIONAL_LOCK(M,C) \ ++ do { \ ++ struct _pthread_cleanup_buffer __infunc_pthread_cleanup_buffer; \ ++ if (C) { \ ++ _pthread_cleanup_push_defer(&__infunc_pthread_cleanup_buffer, \ ++ __pthread_mutex_unlock, \ ++ &(M)); \ ++ __pthread_mutex_lock(&(M)); \ ++ } \ ++ ((void)0) ++ ++#define __UCLIBC_MUTEX_CONDITIONAL_UNLOCK(M,C) \ ++ if (C) { \ ++ _pthread_cleanup_pop_restore(&__infunc_pthread_cleanup_buffer,1);\ ++ } \ ++ } while (0) ++ ++#define __UCLIBC_MUTEX_AUTO_LOCK_VAR(A) int A ++ ++#define __UCLIBC_MUTEX_AUTO_LOCK(M,A,V) \ ++ __UCLIBC_MUTEX_CONDITIONAL_LOCK(M,((A=(V)) == 0)) ++ ++#define __UCLIBC_MUTEX_AUTO_UNLOCK(M,A) \ ++ __UCLIBC_MUTEX_CONDITIONAL_UNLOCK(M,(A == 0)) ++ ++#define __UCLIBC_MUTEX_LOCK(M) \ ++ __UCLIBC_MUTEX_CONDITIONAL_LOCK(M, 1) ++ ++#define __UCLIBC_MUTEX_UNLOCK(M) \ ++ __UCLIBC_MUTEX_CONDITIONAL_UNLOCK(M, 1) ++ ++#else ++ ++#define __UCLIBC_MUTEX(M) void *__UCLIBC_MUTEX_DUMMY_ ## M ++#define __UCLIBC_MUTEX_INIT(M,I) extern void *__UCLIBC_MUTEX_DUMMY_ ## M ++#define __UCLIBC_MUTEX_STATIC(M) extern void *__UCLIBC_MUTEX_DUMMY_ ## M ++#define __UCLIBC_MUTEX_EXTERN(M) extern void *__UCLIBC_MUTEX_DUMMY_ ## M ++ ++#define __UCLIBC_MUTEX_LOCK_CANCEL_UNSAFE(M) ((void)0) ++#define __UCLIBC_MUTEX_UNLOCK_CANCEL_UNSAFE(M) ((void)0) ++#define __UCLIBC_MUTEX_TRYLOCK_CANCEL_UNSAFE(M) (0) /* Always succeed? */ ++ ++#define __UCLIBC_MUTEX_CONDITIONAL_LOCK(M,C) ((void)0) ++#define __UCLIBC_MUTEX_CONDITIONAL_UNLOCK(M,C) ((void)0) ++ ++#define __UCLIBC_MUTEX_AUTO_LOCK_VAR(A) ((void)0) ++#define __UCLIBC_MUTEX_AUTO_LOCK(M,A,V) ((void)0) ++#define __UCLIBC_MUTEX_AUTO_UNLOCK(M,A) ((void)0) ++ ++#define __UCLIBC_MUTEX_LOCK(M) ((void)0) ++#define __UCLIBC_MUTEX_UNLOCK(M) ((void)0) ++ ++#endif ++ ++#endif /* _UCLIBC_MUTEX_H */ +diff -urN -x .git uClibc-0.9.28/libc/sysdeps/linux/mips/pipe.c uClibc-mjn3/libc/sysdeps/linux/mips/pipe.c +--- uClibc-0.9.28/libc/sysdeps/linux/mips/pipe.c 2005-08-17 16:49:44.000000000 -0600 ++++ uClibc-mjn3/libc/sysdeps/linux/mips/pipe.c 1969-12-31 17:00:00.000000000 -0700 +@@ -1,23 +0,0 @@ +-/* pipe system call for Linux/MIPS */ +- +-/*see uClibc's sh/pipe.c and glibc-2.2.4's mips/pipe.S */ +- +-#include +-#include +-#include +- +-int pipe(int *fd) +-{ +- register long int res __asm__ ("$2"); // v0 +- register long int res2 __asm__ ("$3"); // v1 +- +- asm ("move\t$4,%2\n\t" // $4 = a0 +- "syscall" /* Perform the system call. */ +- : "=r" (res) +- : "0" (__NR_pipe), "r" (fd) +- : "$4", "$7"); +- +- fd[0] = res; +- fd[1] = res2; +- return(0); +-} diff --git a/uclibc-cleanup-whitespaces.patch b/uclibc-cleanup-whitespaces.patch new file mode 100644 index 0000000..f213ad6 --- /dev/null +++ b/uclibc-cleanup-whitespaces.patch @@ -0,0 +1,77 @@ +diff --git a/libc/sysdeps/linux/arm/sigrestorer.S b/libc/sysdeps/linux/arm/sigrestorer.S +index daa614f..194228a 100644 +--- a/libc/sysdeps/linux/arm/sigrestorer.S ++++ b/libc/sysdeps/linux/arm/sigrestorer.S +@@ -18,7 +18,7 @@ + + #include + #include +- ++ + /* If no SA_RESTORER function was specified by the application we use + one of these. This avoids the need for the kernel to synthesise a return + instruction on the stack, which would involve expensive cache flushes. +diff --git a/libc/sysdeps/linux/sh/sys/ucontext.h b/libc/sysdeps/linux/sh/sys/ucontext.h +index e909f35..0996bf2 100644 +--- a/libc/sysdeps/linux/sh/sys/ucontext.h ++++ b/libc/sysdeps/linux/sh/sys/ucontext.h +@@ -88,7 +88,7 @@ typedef freg_t fpregset_t[NFPREG]; + typedef struct + { + unsigned int oldmask; +- ++ + /* CPU registers */ + gregset_t gregs; + unsigned int pc; +@@ -105,7 +105,7 @@ typedef struct + unsigned int fpscr; + unsigned int fpul; + unsigned int ownedfp; +-#endif ++#endif + } mcontext_t; + + /* Userlevel context. */ +diff --git a/libcrypt/md5.c b/libcrypt/md5.c +index 445cb69..95286bf 100644 +--- a/libcrypt/md5.c ++++ b/libcrypt/md5.c +@@ -28,8 +28,8 @@ + * edited for clarity and style only. + * + * ---------------------------------------------------------------------------- +- * The md5_crypt() function was taken from freeBSD's libcrypt and contains +- * this license: ++ * The md5_crypt() function was taken from freeBSD's libcrypt and contains ++ * this license: + * "THE BEER-WARE LICENSE" (Revision 42): + * wrote this file. As long as you retain this notice you + * can do whatever you want with this stuff. If we meet some day, and you think +@@ -38,7 +38,7 @@ + * $FreeBSD: src/lib/libcrypt/crypt.c,v 1.7.2.1 1999/08/29 14:56:33 peter Exp $ + * + * ---------------------------------------------------------------------------- +- * On April 19th, 2001 md5_crypt() was modified to make it reentrant ++ * On April 19th, 2001 md5_crypt() was modified to make it reentrant + * by Erik Andersen + * + * +@@ -99,7 +99,7 @@ static void __md5_Transform __P((u_int32_t [4], const unsigned char [64])); + #define MD5_MAGIC_STR "$1$" + #define MD5_MAGIC_LEN (sizeof(MD5_MAGIC_STR) - 1) + static const unsigned char __md5__magic[] = MD5_MAGIC_STR; +- /* This string is magic for this algorithm. Having ++ /* This string is magic for this algorithm. Having + it this way, we can get better later on */ + static const unsigned char __md5_itoa64[] = /* 0 ... 63 => ascii - 64 */ + "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; +@@ -333,7 +333,7 @@ __md5_Transform (state, block) + + __md5_Decode (x, block, 64); + +- a = state[0]; b = state[1]; c = state[2]; d = state[3]; ++ a = state[0]; b = state[1]; c = state[2]; d = state[3]; + + #if MD5_SIZE_OVER_SPEED > 2 + pc = C; pp = P; ps = S - 4; diff --git a/uclibc-misc1.diff b/uclibc-misc1.diff new file mode 100644 index 0000000..41a33c3 --- /dev/null +++ b/uclibc-misc1.diff @@ -0,0 +1,157 @@ +Index: ldso/ldso/dl-startup.c +=================================================================== +--- ldso/ldso/dl-startup.c (revision 16049) ++++ ldso/ldso/dl-startup.c (working copy) +@@ -259,7 +272,7 @@ + rel_addr += relative_count * sizeof(ELF_RELOC); + } + +- rpnt = (ELF_RELOC *) DL_RELOC_ADDR(load_addr, rel_addr); ++ rpnt = (ELF_RELOC *) rel_addr; + for (i = 0; i < rel_size; i += sizeof(ELF_RELOC), rpnt++) { + reloc_addr = (unsigned long *) DL_RELOC_ADDR(load_addr, (unsigned long)rpnt->r_offset); + symtab_index = ELF_R_SYM(rpnt->r_info); +Index: ldso/ldso/ldso.c +=================================================================== +--- ldso/ldso/ldso.c (revision 16049) ++++ ldso/ldso/ldso.c (working copy) +@@ -113,7 +125,7 @@ + for (j = 0; j < jm; ++j) { + void (*dl_elf_func) (void); + dl_elf_func = (void (*)(void)) (intptr_t) addrs[j]; +- (*dl_elf_func) (); ++ DL_CALL_FUNC_AT_ADDR (dl_elf_func, loadaddr, (void (*)(void))); + } + } + } +@@ -141,7 +153,7 @@ + while (i-- > 0) { + void (*dl_elf_func) (void); + dl_elf_func = (void (*)(void)) (intptr_t) array[i]; +- (*dl_elf_func) (); ++ DL_CALL_FUNC_AT_ADDR (dl_elf_func, tpnt->loadaddr, (void (*)(void))); + } + } + } +@@ -168,7 +180,7 @@ + + dl_elf_func = (void (*)(void)) (intptr_t) DL_RELOC_ADDR(tpnt->loadaddr, tpnt->dynamic_info[DT_FINI]); + _dl_if_debug_dprint("\ncalling FINI: %s\n\n", tpnt->libname); +- (*dl_elf_func) (); ++ DL_CALL_FUNC_AT_ADDR (dl_elf_func, tpnt->loadaddr, (void(*)(void))); + } + } + } +@@ -852,7 +880,7 @@ + + _dl_if_debug_dprint("calling INIT: %s\n\n", tpnt->libname); + +- (*dl_elf_func) (); ++ DL_CALL_FUNC_AT_ADDR (dl_elf_func, tpnt->loadaddr, (void(*)(void))); + } + + _dl_run_init_array(tpnt); +Index: ldso/ldso/dl-elf.c +=================================================================== +--- ldso/ldso/dl-elf.c (revision 16049) ++++ ldso/ldso/dl-elf.c (working copy) +@@ -118,10 +118,9 @@ + void + _dl_protect_relro (struct elf_resolve *l) + { +- ElfW(Addr) start = (DL_RELOC_ADDR(l->loadaddr, l->relro_addr) +- & ~(_dl_pagesize - 1)); +- ElfW(Addr) end = ((DL_RELOC_ADDR(l->loadaddr, l->relro_addr) + l->relro_size) +- & ~(_dl_pagesize - 1)); ++ ElfW(Addr) base = (ElfW(Addr)) DL_RELOC_ADDR(l->loadaddr, l->relro_addr); ++ ElfW(Addr) start = (base & ~(_dl_pagesize - 1)); ++ ElfW(Addr) end = ((base + l->relro_size) & ~(_dl_pagesize - 1)); + _dl_if_debug_dprint("RELRO protecting %s: start:%x, end:%x\n", l->libname, start, end); + if (start != end && + _dl_mprotect ((void *) start, end - start, PROT_READ) < 0) { +@@ -628,7 +747,7 @@ + } + + _dl_if_debug_dprint("\n\tfile='%s'; generating link map\n", libname); +- _dl_if_debug_dprint("\t\tdynamic: %x base: %x\n", dynamic_addr, DL_LOADADDR_BASE(libaddr)); ++ _dl_if_debug_dprint("\t\tdynamic: %x base: %x\n", dynamic_addr, DL_LOADADDR_BASE(lib_loadaddr)); + _dl_if_debug_dprint("\t\t entry: %x phdr: %x phnum: %x\n\n", + DL_RELOC_ADDR(lib_loadaddr, epnt->e_entry), tpnt->ppnt, tpnt->n_phent); + +@@ -822,7 +941,7 @@ + int ret = 0; + + for (l = _dl_loaded_modules; l != NULL; l = l->next) { +- info.dlpi_addr = DL_LOADADDR_BASE(l->loadaddr); ++ info.dlpi_addr = l->loadaddr; + info.dlpi_name = l->libname; + info.dlpi_phdr = l->ppnt; + info.dlpi_phnum = l->n_phent; +Index: ldso/include/dl-defs.h +=================================================================== +--- ldso/include/dl-defs.h (revision 16049) ++++ ldso/include/dl-defs.h (working copy) +@@ -140,4 +146,13 @@ + && (!(TFROM) || (TFROM)->loadaddr < (TPNT)->loadaddr)) + #endif + ++/* On some platforms, computing a pointer to function is more ++ expensive than calling a function at a given address, so this ++ alternative is provided. The function signature must be given ++ within parentheses, as in a type cast. */ ++#ifndef DL_CALL_FUNC_AT_ADDR ++# define DL_CALL_FUNC_AT_ADDR(ADDR, LOADADDR, SIGNATURE, ...) \ ++ ((*SIGNATURE DL_ADDR_TO_FUNC_PTR ((ADDR), (LOADADDR)))(__VA_ARGS__)) ++#endif ++ + #endif /* _LD_DEFS_H */ +Index: ldso/include/dl-hash.h +=================================================================== +--- ldso/include/dl-hash.h (revision 16049) ++++ ldso/include/dl-hash.h (working copy) +@@ -28,7 +28,7 @@ + struct elf_resolve { + /* These entries must be in this order to be compatible with the interface used + by gdb to obtain the list of symbols. */ +- DL_LOADADDR_TYPE loadaddr; /* Base address shared object is loaded at. */ ++ DL_LOADADDR_TYPE loadaddr; /* Base address shared object is loaded at. */ + char *libname; /* Absolute file name object was found in. */ + ElfW(Dyn) *dynamic_addr; /* Dynamic section of the shared object. */ + struct elf_resolve * next; +Index: ldso/libdl/libdl.c +=================================================================== +--- ldso/libdl/libdl.c (revision 16049) ++++ ldso/libdl/libdl.c (working copy) +@@ -378,10 +388,10 @@ + if (tpnt->dynamic_info[DT_INIT]) { + void (*dl_elf_func) (void); + dl_elf_func = (void (*)(void)) DL_RELOC_ADDR(tpnt->loadaddr, tpnt->dynamic_info[DT_INIT]); +- if (dl_elf_func && *dl_elf_func != NULL) { ++ if (dl_elf_func) { + _dl_if_debug_print("running ctors for library %s at '%p'\n", + tpnt->libname, dl_elf_func); +- (*dl_elf_func) (); ++ DL_CALL_FUNC_AT_ADDR (dl_elf_func, tpnt->loadaddr, (void(*)(void))); + } + } + +@@ -512,8 +539,8 @@ + if (tpnt->dynamic_info[DT_FINI]) { + dl_elf_fini = (int (*)(void)) DL_RELOC_ADDR(tpnt->loadaddr, tpnt->dynamic_info[DT_FINI]); + _dl_if_debug_print("running dtors for library %s at '%p'\n", +- tpnt->libname, dl_elf_fini); +- (*dl_elf_fini) (); ++ tpnt->libname, dl_elf_fini); ++ DL_CALL_FUNC_AT_ADDR (dl_elf_fini, tpnt->loadaddr, (int (*)(void))); + } + } + +@@ -660,7 +691,7 @@ + _dl_if_debug_print("Module \"%s\" at %p\n", + tpnt->libname, DL_LOADADDR_BASE(tpnt->loadaddr)); + +- if (DL_ADDR_IN_LOADADDR((ElfW(Addr)) __address, tpnt, pelf)) ++ if (DL_ADDR_IN_LOADADDR((ElfW(Addr)) __address, tpnt, pelf)) + pelf = tpnt; + } + diff --git a/uclibc-pt-manager.patch b/uclibc-pt-manager.patch new file mode 100644 index 0000000..19ba00f --- /dev/null +++ b/uclibc-pt-manager.patch @@ -0,0 +1,20 @@ +--- uClinux-dist/uClibc/libpthread/linuxthreads/manager.c ++++ uClinux-dist/uClibc/libpthread/linuxthreads/manager.c +@@ -195,9 +195,15 @@ + { + + PDEBUG("before __libc_read\n"); +- n = __libc_read(reqfd, (char *)&request, sizeof(request)); ++ n = TEMP_FAILURE_RETRY(__libc_read(reqfd, (char *)&request, sizeof(request))); + PDEBUG("after __libc_read, n=%d\n", n); +- ASSERT(n == sizeof(request)); ++ if (n < 0) { ++ char d[64]; ++ write(STDERR_FILENO, d, snprintf(d, sizeof(d), "*** read err %m\n")); ++ } else if (n != sizeof(request)) { ++ write(STDERR_FILENO, "*** short read in manager\n", 26); ++ } ++ + switch(request.req_kind) { + case REQ_CREATE: + PDEBUG("got REQ_CREATE\n"); diff --git a/uclibc-tempname3.patch b/uclibc-tempname3.patch new file mode 100644 index 0000000..758fc99 --- /dev/null +++ b/uclibc-tempname3.patch @@ -0,0 +1,36 @@ +--- /home/nickolai/build/uClibc-0.9.29_rc1/libc/misc/internals/tempname.c 2006-01-27 13:26:40.000000000 -0800 ++++ tempname.c 2007-05-02 13:25:05.000000000 -0700 +@@ -192,7 +192,7 @@ + int attribute_hidden __gen_tempname (char *tmpl, int kind) + { + char *XXXXXX; +- unsigned int i; ++ unsigned int i, count; + int fd, save_errno = errno; + unsigned char randomness[6]; + size_t len; +@@ -206,16 +206,15 @@ + return -1; + } + +- /* Get some random data. */ +- if (fillrand(randomness, sizeof(randomness)) != sizeof(randomness)) { +- /* if random device nodes failed us, lets use the braindamaged ver */ +- brain_damaged_fillrand(randomness, sizeof(randomness)); +- } +- +- for (i = 0; i < sizeof(randomness); ++i) +- XXXXXX[i] = letters[(randomness[i]) % NUM_LETTERS]; ++ for (count = 0; count < TMP_MAX; ++count) { ++ /* Get some random data. */ ++ if (fillrand(randomness, sizeof(randomness)) != sizeof(randomness)) { ++ /* if random device nodes failed us, lets use the braindamaged ver */ ++ brain_damaged_fillrand(randomness, sizeof(randomness)); ++ } + +- for (i = 0; i < TMP_MAX; ++i) { ++ for (i = 0; i < sizeof(randomness); ++i) ++ XXXXXX[i] = letters[(randomness[i]) % NUM_LETTERS]; + + switch(kind) { + case __GT_NOCREATE: diff --git a/uclinux-config-help-source.patch b/uclinux-config-help-source.patch new file mode 100644 index 0000000..0be437f --- /dev/null +++ b/uclinux-config-help-source.patch @@ -0,0 +1,40 @@ +Index: config/scripts/Menuconfig +=================================================================== +--- config/scripts/Menuconfig (revision 4820) ++++ config/scripts/Menuconfig (working copy) +@@ -376,6 +376,13 @@ + function extract_help () { + if [ -f ${HELP_FILE} ] + then ++ # add support for "source" syntax ++ extra_help="" ++ new_extra_help=${HELP_FILE} ++ while [ -n "${new_extra_help}" ] ; do ++ new_extra_help=$(sed -n '/^[[:space:]]*source[[:space:]]/s:^[[:space:]]*source[[:space:]]*::p' ${new_extra_help}) ++ extra_help="${extra_help} ${new_extra_help}" ++ done + #first escape regexp special characters in the argument: + var=$(echo "$1"|sed 's/[][\/.^$*]/\\&/g') + #now pick out the right help text: +@@ -387,16 +394,20 @@ + /^[^ ]/q + s/^ // + p +- }" ${HELP_FILE}) ++ }" ${HELP_FILE} ${extra_help}) + + if [ -z "$text" ] + then ++ echo "$1:" ++ echo + echo "There is no help available for this kernel option." + return 1 + else + echo "$text" + fi + else ++ echo "$1:" ++ echo + echo "There is no help available for this kernel option." + return 1 + fi diff --git a/uclinux-dosfstools-headers.patch b/uclinux-dosfstools-headers.patch new file mode 100644 index 0000000..ec0b59b --- /dev/null +++ b/uclinux-dosfstools-headers.patch @@ -0,0 +1,31 @@ +Index: user/dosfstools/dosfsck/io.c +=================================================================== +RCS file: /var/cvs/uClinux-dist/user/dosfstools/dosfsck/io.c,v +retrieving revision 1.1.1.2 +diff -u -p -r1.1.1.2 io.c +--- user/dosfstools/dosfsck/io.c 1 Feb 2007 13:37:11 -0000 1.1.1.2 ++++ user/dosfstools/dosfsck/io.c 5 Feb 2007 03:59:38 -0000 +@@ -55,7 +55,7 @@ static loff_t llseek( int fd, loff_t off + static int _llseek(uint fd, ulong hi, ulong lo, + loff_t *res, uint wh) + { +- return syscall(__NR__llseek, fd, hi, log, res, wh); ++ return syscall(__NR__llseek, fd, hi, lo, res, wh); + } + + static loff_t llseek( int fd, loff_t offset, int whence ) +Index: user/dosfstools/mkdosfs/mkdosfs.c +=================================================================== +RCS file: /var/cvs/uClinux-dist/user/dosfstools/mkdosfs/mkdosfs.c,v +retrieving revision 1.1.1.2 +diff -u -p -r1.1.1.2 mkdosfs.c +--- user/dosfstools/mkdosfs/mkdosfs.c 1 Feb 2007 13:37:12 -0000 1.1.1.2 ++++ user/dosfstools/mkdosfs/mkdosfs.c 5 Feb 2007 03:59:39 -0000 +@@ -50,6 +50,7 @@ + #include "../version.h" + + #include ++#include + #include + #include + #include diff --git a/uclinux-flashw-cleanup.patch b/uclinux-flashw-cleanup.patch new file mode 100644 index 0000000..2218a46 --- /dev/null +++ b/uclinux-flashw-cleanup.patch @@ -0,0 +1,49 @@ +Index: user/flashw/flashw.c +=================================================================== +RCS file: /var/cvs/uClinux-dist/user/flashw/flashw.c,v +retrieving revision 1.1.1.6 +diff -u -p -r1.1.1.6 flashw.c +--- user/flashw/flashw.c 12 Jul 2006 05:10:36 -0000 1.1.1.6 ++++ user/flashw/flashw.c 7 Jan 2007 13:59:22 -0000 +@@ -10,6 +10,7 @@ + + /*****************************************************************************/ + ++#define _GNU_SOURCE + #include + #include + #include +@@ -20,20 +21,23 @@ + #include + #include + #include +-#include + #include +-#ifdef CONFIG_MTD +-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,8) +-#include +-#else +-#include +-#endif ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18) ++# include ++# define CONFIG_MTD ++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,8) ++# include ++# ifdef CONFIG_MTD ++# include ++# else ++# include ++# endif + #else +-#include ++# include + #endif + #if defined(CONFIG_NFTL_RW) && !defined(NFTL_MAJOR) +- #define NFTL_MAJOR 93 +- #include ++# define NFTL_MAJOR 93 ++# include + #endif + #include + diff --git a/uclinux-libpcap-config.patch b/uclinux-libpcap-config.patch new file mode 100644 index 0000000..6112533 --- /dev/null +++ b/uclinux-libpcap-config.patch @@ -0,0 +1,14 @@ +Index: uClinux-dist/lib/libpcap/config.h.in +=================================================================== +RCS file: /var/cvs/uClinux-dist/lib/libpcap/config.h.in,v +retrieving revision 1.1.1.2 +diff -u -p -r1.1.1.2 config.h.in +--- uClinux-dist/lib/libpcap/config.h.in 12 Jul 2006 04:55:20 -0000 1.1.1.2 ++++ uClinux-dist/lib/libpcap/config.h.in 26 Nov 2006 22:44:20 -0000 +@@ -184,6 +184,3 @@ + + /* if we have u_int8_t */ + #undef u_int8_t +- +-#include +-#include diff --git a/uclinux-libpcap-host.patch b/uclinux-libpcap-host.patch new file mode 100644 index 0000000..190517e --- /dev/null +++ b/uclinux-libpcap-host.patch @@ -0,0 +1,13 @@ +Index: uClinux-dist/lib/libpcap/makefile +=================================================================== +RCS file: /var/cvs/uClinux-dist/lib/libpcap/makefile,v +retrieving revision 1.1.1.2 +diff -u -p -r1.1.1.2 makefile +--- uClinux-dist/lib/libpcap/makefile 12 Jul 2006 04:55:20 -0000 1.1.1.2 ++++ uClinux-dist/lib/libpcap/makefile 26 Nov 2006 22:37:08 -0000 +@@ -1,4 +1,4 @@ +-CONFOPTS = --with-pcap=linux --with-headers=$(ROOTDIR)/include ++CONFOPTS = --host=$(CONFIGURE_HOST) --with-pcap=linux --with-headers=$(ROOTDIR)/include + ifdef CONFIG_IPV6 + CONFOPTS += --enable-ipv6 + endif diff --git a/uclinux-makefile-cksum.patch b/uclinux-makefile-cksum.patch new file mode 100644 index 0000000..2970f26 --- /dev/null +++ b/uclinux-makefile-cksum.patch @@ -0,0 +1,12 @@ +--- uClinux-dist/Makefile ++++ uClinux-dist/Makefile +@@ -89,7 +89,8 @@ + ln -sf $(ROOTDIR)/tools/ucfront/ucfront-ld tools/ucfront-ld + + .PHONY: cksum +-cksum: tools/sg-cksum/*.c ++cksum: tools/cksum ++tools/cksum: tools/sg-cksum/*.c + $(MAKE) -C tools/sg-cksum + ln -sf $(ROOTDIR)/tools/sg-cksum/cksum tools/cksum + diff --git a/uclinux-makefile-makearch.patch b/uclinux-makefile-makearch.patch new file mode 100644 index 0000000..3858ae5 --- /dev/null +++ b/uclinux-makefile-makearch.patch @@ -0,0 +1,11 @@ +--- uClinux-dist/Makefile.cvs ++++ uClinux-dist/Makefile.cvs +@@ -70,7 +70,7 @@ + MAKEARCH_KERNEL = $(MAKE) ARCH=$(ARCH) SUBARCH=$(SUBARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) + else + MAKEARCH = $(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) +-MAKEARCH_KERNEL = $(MAKEARCH) ARCH=$(ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) ++MAKEARCH_KERNEL = $(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) + endif + + DIRS = $(VENDOR_TOPDIRS) include lib include user diff --git a/uclinux-no-autoconf-included-define.patch b/uclinux-no-autoconf-included-define.patch new file mode 100644 index 0000000..2cd03d6 --- /dev/null +++ b/uclinux-no-autoconf-included-define.patch @@ -0,0 +1,43 @@ +--- config/setconfig ++++ config/setconfig +@@ -97,10 +97,6 @@ fix_conf_files() + config/autoconf.h + replace_line CONFIG_LANGUAGE "#define CONFIG_LANGUAGE \"$LANGUAGE\"" \ + config/autoconf.h +- replace_line VENDORS_AUTOCONF_INCLUDED \ +- "#define VENDORS_AUTOCONF_INCLUDED" config/autoconf.h +- replace_line "#undef AUTOCONF_INCLUDED" "#undef AUTOCONF_INCLUDED" \ +- config/autoconf.h + + replace_line OLD_VENDOR "OLD_VENDOR=\"$VENDOR\"" ./.oldconfig + replace_line OLD_PRODUCT "OLD_PRODUCT=\"$PRODUCT\"" ./.oldconfig +--- config/scripts/Configure ++++ config/scripts/Configure +@@ -537,7 +537,6 @@ echo "#" >> $CONFIG + echo "/*" > $CONFIG_H + echo " * Automatically generated C config: don't edit" >> $CONFIG_H + echo " */" >> $CONFIG_H +-echo "#define AUTOCONF_INCLUDED" >> $CONFIG_H + + DEFAULT="" + if [ "$1" = "-d" ] ; then +--- config/scripts/Menuconfig ++++ config/scripts/Menuconfig +@@ -1279,7 +1279,6 @@ save_configuration () { + echo "/*" >$CONFIG_H + echo " * Automatically generated by make menuconfig: don't edit" >>$CONFIG_H + echo " */" >>$CONFIG_H +- echo "#define AUTOCONF_INCLUDED" >> $CONFIG_H + + echo -n "." + if . $CONFIG_IN >>.menuconfig.log 2>&1 +--- config/scripts/tkgen.c ++++ config/scripts/tkgen.c +@@ -1452,7 +1452,6 @@ void dump_tk_script( struct kconfig * sc + printf( "\tputs $autocfg \"/*\"\n" ); + printf( "\tputs $autocfg \" * Automatically generated C config: don't edit\"\n" ); + printf( "\tputs $autocfg \" */\"\n" ); +- printf( "\tputs $autocfg \"#define AUTOCONF_INCLUDED\"\n" ); + + clear_globalflags(); + for ( cfg = scfg; cfg != NULL; cfg = cfg->next ) diff --git a/uclinux-ntp-makefile.patch b/uclinux-ntp-makefile.patch new file mode 100644 index 0000000..92543f1 --- /dev/null +++ b/uclinux-ntp-makefile.patch @@ -0,0 +1,45 @@ +Index: user/ntp/makefile +=================================================================== +RCS file: /var/cvs/uClinux-dist/user/ntp/makefile,v +retrieving revision 1.1.1.3 +diff -u -p -r1.1.1.3 makefile +--- user/ntp/makefile 12 Sep 2006 05:38:10 -0000 1.1.1.3 ++++ user/ntp/makefile 27 Jan 2007 03:21:16 -0000 +@@ -39,7 +39,7 @@ CONFOPTIONS= \ + --$(NTPDC)-ntpdc --$(NTPQ)-ntpq + + +-all: builddir ++all: builddir/Makefile + $(MAKE) -C builddir CFLAGS='$(CFLAGS) -DCONFIG_FILE=\"/etc/config/ntp.conf\"' + + romfs: +@@ -48,18 +48,18 @@ romfs: + $(ROMFSINST) -e CONFIG_USER_NTPD_NTPDC builddir/ntpdc/ntpdc /bin/ntpdc + $(ROMFSINST) -e CONFIG_USER_NTPD_NTPQ builddir/ntpq/ntpq /bin/ntpq + +- +-builddir: makefile ++builddir/Makefile: makefile ++ find . -type f -print0 | xargs -0 touch -r configure + rm -rf builddir + mkdir builddir +- ( \ +- cd builddir; \ +- CC="$(CC) $(CFLAGS)" LDFLAGS="$(LDFLAGS)" LIBS="$(LDLIBS)" \ +- MISSING="true" \ +- ../configure --prefix= \ +- --with-headers=$(ROOTDIR)/$(LINUXDIR)/include \ +- $(CONFIGURE_OPTS) $(CONFOPTIONS) \ +- ) ++ cd builddir && \ ++ CC="$(CC) $(CFLAGS)" LDFLAGS="$(LDFLAGS)" LIBS="$(LDLIBS)" \ ++ MISSING="true" \ ++ ../configure --prefix= \ ++ --with-headers=$(ROOTDIR)/$(LINUXDIR)/include \ ++ $(CONFIGURE_OPTS) $(CONFOPTIONS) + + clean: + rm -rf builddir ++ ++.PHONY: all clean romfs diff --git a/uclinux-picocom.patch b/uclinux-picocom.patch new file mode 100644 index 0000000..31505bb --- /dev/null +++ b/uclinux-picocom.patch @@ -0,0 +1,5202 @@ +Index: config/config-blackfin.in +=================================================================== +--- config/config-blackfin.in (revision 5006) ++++ config/config-blackfin.in (working copy) +@@ -116,6 +116,7 @@ bool 'Bluez-utils' CONFIG_USER_BLUEZ + if [ "$CONFIG_USER_BLUEZ" = "y" ]; then + define_bool CONFIG_LIB_BLUEZ y + fi ++bool 'picocom' CONFIG_USER_PICOCOM + endmenu + + + +Property changes on: user/blkfin-apps/picocom +___________________________________________________________________ +Name: svn:ignore + + picocom + + +Index: user/blkfin-apps/picocom/picocom.8.ps +=================================================================== +--- user/blkfin-apps/picocom/picocom.8.ps (revision 0) ++++ user/blkfin-apps/picocom/picocom.8.ps (revision 0) +@@ -0,0 +1,578 @@ ++%!PS-Adobe-3.0 ++%%Creator: groff version 1.18.1 ++%%CreationDate: Fri Aug 13 14:26:12 2004 ++%%DocumentNeededResources: font Times-Roman ++%%+ font Times-Bold ++%%+ font Times-Italic ++%%DocumentSuppliedResources: procset grops 1.18 1 ++%%Pages: 4 ++%%PageOrder: Ascend ++%%Orientation: Portrait ++%%EndComments ++%%BeginProlog ++%%BeginResource: procset grops 1.18 1 ++/setpacking where{ ++pop ++currentpacking ++true setpacking ++}if ++/grops 120 dict dup begin ++/SC 32 def ++/A/show load def ++/B{0 SC 3 -1 roll widthshow}bind def ++/C{0 exch ashow}bind def ++/D{0 exch 0 SC 5 2 roll awidthshow}bind def ++/E{0 rmoveto show}bind def ++/F{0 rmoveto 0 SC 3 -1 roll widthshow}bind def ++/G{0 rmoveto 0 exch ashow}bind def ++/H{0 rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def ++/I{0 exch rmoveto show}bind def ++/J{0 exch rmoveto 0 SC 3 -1 roll widthshow}bind def ++/K{0 exch rmoveto 0 exch ashow}bind def ++/L{0 exch rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def ++/M{rmoveto show}bind def ++/N{rmoveto 0 SC 3 -1 roll widthshow}bind def ++/O{rmoveto 0 exch ashow}bind def ++/P{rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def ++/Q{moveto show}bind def ++/R{moveto 0 SC 3 -1 roll widthshow}bind def ++/S{moveto 0 exch ashow}bind def ++/T{moveto 0 exch 0 SC 5 2 roll awidthshow}bind def ++/SF{ ++findfont exch ++[exch dup 0 exch 0 exch neg 0 0]makefont ++dup setfont ++[exch/setfont cvx]cvx bind def ++}bind def ++/MF{ ++findfont ++[5 2 roll ++0 3 1 roll ++neg 0 0]makefont ++dup setfont ++[exch/setfont cvx]cvx bind def ++}bind def ++/level0 0 def ++/RES 0 def ++/PL 0 def ++/LS 0 def ++/MANUAL{ ++statusdict begin/manualfeed true store end ++}bind def ++/PLG{ ++gsave newpath clippath pathbbox grestore ++exch pop add exch pop ++}bind def ++/BP{ ++/level0 save def ++1 setlinecap ++1 setlinejoin ++72 RES div dup scale ++LS{ ++90 rotate ++}{ ++0 PL translate ++}ifelse ++1 -1 scale ++}bind def ++/EP{ ++level0 restore ++showpage ++}bind def ++/DA{ ++newpath arcn stroke ++}bind def ++/SN{ ++transform ++.25 sub exch .25 sub exch ++round .25 add exch round .25 add exch ++itransform ++}bind def ++/DL{ ++SN ++moveto ++SN ++lineto stroke ++}bind def ++/DC{ ++newpath 0 360 arc closepath ++}bind def ++/TM matrix def ++/DE{ ++TM currentmatrix pop ++translate scale newpath 0 0 .5 0 360 arc closepath ++TM setmatrix ++}bind def ++/RC/rcurveto load def ++/RL/rlineto load def ++/ST/stroke load def ++/MT/moveto load def ++/CL/closepath load def ++/Fr{ ++setrgbcolor fill ++}bind def ++/Fk{ ++setcmykcolor fill ++}bind def ++/Fg{ ++setgray fill ++}bind def ++/FL/fill load def ++/LW/setlinewidth load def ++/Cr/setrgbcolor load def ++/Ck/setcmykcolor load def ++/Cg/setgray load def ++/RE{ ++findfont ++dup maxlength 1 index/FontName known not{1 add}if dict begin ++{ ++1 index/FID ne{def}{pop pop}ifelse ++}forall ++/Encoding exch def ++dup/FontName exch def ++currentdict end definefont pop ++}bind def ++/DEFS 0 def ++/EBEGIN{ ++moveto ++DEFS begin ++}bind def ++/EEND/end load def ++/CNT 0 def ++/level1 0 def ++/PBEGIN{ ++/level1 save def ++translate ++div 3 1 roll div exch scale ++neg exch neg exch translate ++0 setgray ++0 setlinecap ++1 setlinewidth ++0 setlinejoin ++10 setmiterlimit ++[]0 setdash ++/setstrokeadjust where{ ++pop ++false setstrokeadjust ++}if ++/setoverprint where{ ++pop ++false setoverprint ++}if ++newpath ++/CNT countdictstack def ++userdict begin ++/showpage{}def ++}bind def ++/PEND{ ++clear ++countdictstack CNT sub{end}repeat ++level1 restore ++}bind def ++end def ++/setpacking where{ ++pop ++setpacking ++}if ++%%EndResource ++%%IncludeResource: font Times-Roman ++%%IncludeResource: font Times-Bold ++%%IncludeResource: font Times-Italic ++grops begin/DEFS 1 dict def DEFS begin/u{.001 mul}bind def end/RES 72 ++def/PL 841.89 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron ++/Zcaron/scaron/zcaron/Ydieresis/trademark/quotesingle/Euro/.notdef ++/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef ++/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef ++/.notdef/.notdef/.notdef/space/exclam/quotedbl/numbersign/dollar/percent ++/ampersand/quoteright/parenleft/parenright/asterisk/plus/comma/hyphen ++/period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon ++/semicolon/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O ++/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/circumflex ++/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y ++/z/braceleft/bar/braceright/tilde/.notdef/quotesinglbase/guillemotleft ++/guillemotright/bullet/florin/fraction/perthousand/dagger/daggerdbl ++/endash/emdash/ff/fi/fl/ffi/ffl/dotlessi/dotlessj/grave/hungarumlaut ++/dotaccent/breve/caron/ring/ogonek/quotedblleft/quotedblright/oe/lslash ++/quotedblbase/OE/Lslash/.notdef/exclamdown/cent/sterling/currency/yen ++/brokenbar/section/dieresis/copyright/ordfeminine/guilsinglleft ++/logicalnot/minus/registered/macron/degree/plusminus/twosuperior ++/threesuperior/acute/mu/paragraph/periodcentered/cedilla/onesuperior ++/ordmasculine/guilsinglright/onequarter/onehalf/threequarters ++/questiondown/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE ++/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex ++/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis ++/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn ++/germandbls/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla ++/egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis ++/eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide/oslash ++/ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis]def ++/Times-Italic@0 ENC0/Times-Italic RE/Times-Bold@0 ENC0/Times-Bold RE ++/Times-Roman@0 ENC0/Times-Roman RE ++%%EndProlog ++%%Page: 1 1 ++%%BeginPageSetup ++BP ++%%EndPageSetup ++/F0 10/Times-Roman@0 SF 373.3 ++<7069636f636f6d283829207069636f636f6d283829>72 48 R/F1 10.95 ++/Times-Bold@0 SF -.219<4e41>72 84 S<4d45>.219 E F0<7069636f636f6d20ad20 ++6d696e696d616c2064756d622d7465726d696e616c20656d756c6174696f6e2070726f67 ++72616d>108 96 Q F1<53594e4f50534953>72 112.8 Q/F2 10/Times-Bold@0 SF ++<7069636f636f6d205b>108 124.8 Q/F3 10/Times-Italic@0 SF<6f7074696f6e73> ++2.73 E F2<5d>2.77 E F3<6465>2.85 E<76696365>-.15 E F1 ++<4445534352495054494f4e>72 141.6 Q F0 1.423 ++<417320697473206e616d652073756767657374732c>108 153.6 R F2 ++<7069636f636f6d>3.923 E F0 1.423<69732061206d696e696d616c2064756d622d74 ++65726d696e616c20656d756c6174696f6e2070726f6772616d2e2049742069732c20696e ++207072696e6369706c652c2076>3.923 F<657279>-.15 E .938<6d756368206c696b> ++108 165.6 R<65>-.1 E F2<6d696e69636f6d283129>3.438 E F0 3.439<2c6f>3.439 ++G .939<6e6c7920697427>-3.439 F 3.439<7322>-.55 G .939 ++<7069636f2220696e7374656164206f6620226d696e6922212049742077>-3.439 F ++.939<61732064657369676e656420746f2073657276>-.1 F 3.439<6561>-.15 G ++3.439<736173>-3.439 G .939<696d706c652c206d616e75616c2c>-3.439 F .757<6d ++6f64656d20636f6e8c6775726174696f6e2c2074657374696e672c20616e6420646562> ++108 177.6 R .757 ++<756767696e6720746f6f6c2e2049742068617320616c736f2073657276>-.2 F .756 ++<6564202871756974652077656c6c292061732061206c6f>-.15 F .756 ++<772d7465636820227465726d696e616c2d>-.25 F<77696e646f>108 189.6 Q .865 ++<772220746f20616c6c6f>-.25 F 3.365<776f>-.25 G .865 ++<70657261746f7220696e74657276>-3.365 F .865<656e74696f6e20696e2050505020 ++636f6e6e656374696f6e20736372697074732028736f6d657468696e67206c696b>-.15 ++F 3.366<6574>-.1 G .866<6865206d732d77696e646f>-3.366 F .866 ++<777320226f70656e>-.25 F<7465726d696e616c2077696e646f>108 201.6 Q 2.5 ++<7762>-.25 G<65666f7265202f206166746572206469616c696e672220666561747572 ++65292e20497420636f756c6420616c736f2070726f>-2.5 E .3 -.15<76652075>-.15 ++H<736566756c20696e206d616e>.15 E 2.5<796f>-.15 G ++<746865722073696d696c6172207461736b732e>-2.5 E<5768656e>108 220.8 Q F2 ++<7069636f636f6d>3.989 E F0 1.489<737461727473206974206f70656e7320746865 ++207465726d696e616c202873657269616c206465>3.989 F 1.489<7669636529206769> ++-.25 F -.15<7665>-.25 G 3.989<6e61>.15 G 3.988<7369>-3.989 G 1.488 ++<7473206e6f6e2d6f7074696f6e206172>-3.988 F 1.488 ++<67756d656e742e20556e6c65737320746865>-.18 F F3<2d2d6e6f696e6974>108.01 ++232.8 Q F0 1.333<6f7074696f6e206973206769>4.513 F -.15<7665>-.25 G 1.333 ++<6e2c20697420636f6e8c677572657320746865206465>.15 F 1.333<7669636520746f ++207468652073657474696e67732073706563698c656420627920746865206f7074696f6e ++2d6172>-.25 F 1.334<67756d656e747320286f7220746f>-.18 F .487 ++<736f6d6520646566>108 244.8 R .487 ++<61756c742073657474696e6773292c20616e64207365747320697420746f20227261> ++-.1 F .487<7722206d6f64652e204966>-.15 F F3<2d2d6e6f696e6974>2.996 E F0 ++.486<6973206769>3.666 F -.15<7665>-.25 G .486<6e2c2074686520696e69746961 ++6c697a6174696f6e20616e6420636f6e8c6775726174696f6e206973>.15 F .667 ++<736b69707065643b20746865206465>108 256.8 R .667 ++<76696365206973206a757374206f70656e65642e2046>-.25 F<6f6c6c6f>-.15 E ++.667<77696e6720746869732c>-.25 F F2<7069636f636f6d>3.167 E F0 .667<7365 ++747320746865207374616e646172642d696e70757420616e64207374616e646172642d6f ++757470757420746f>3.167 F<7261>108 268.8 Q 3.289<776d>-.15 G .789 ++<6f64652e204861>-3.289 F .789<76696e6720646f6e6520736f2c20697420676f6573 ++20696e2061206c6f6f70207768657265206974206c697374656e7320666f7220696e7075 ++742066726f6d20737464696e2c206f722066726f6d207468652073657269616c20706f72 ++742e>-.2 F .589<496e7075742066726f6d207468652073657269616c20706f72742069 ++7320636f7069656420746f20746865207374616e64617264206f7574707574207768696c ++6520696e7075742066726f6d20746865207374616e6461726420696e7075742069732063 ++6f7069656420746f>108 280.8 R .105<7468652073657269616c20706f72742e>108 ++292.8 R F2<7069636f636f6d>5.105 E F0 .105<616c736f207363616e732069747320 ++696e7075742073747265616d20666f7220612075736572>2.605 F .105 ++<2d73706563698c656420636f6e74726f6c20636861726163746572>-.2 F 2.605 ++<2c63>-.4 G .105<616c6c6564207468652022657363617065>-2.605 F .554 ++<6368617261637465722220286265696e6720627920646566>108 304.8 R .555<6175 ++6c742022432d6122292e2049662074686520657363617065206368617261637465722069 ++73207365656e2c207468656e20696e7374656164206f662073656e64696e672069742074 ++6f207468652073657269616c2d>-.1 F<6465>108 316.8 Q .179<766963652c207468 ++652070726f6772616d20656e746572732022636f6d6d616e64206d6f64652220616e6420 ++77>-.25 F .179<6169747320666f7220746865206e65>-.1 F .178<78742063686172 ++6163746572202877686963682069732063616c6c656420746865202266756e6374696f6e> ++-.15 F 1.572 ++<63686172616374657222292e20446570656e64696e67206f6e207468652076>108 ++328.8 R 1.573 ++<616c7565206f66207468652066756e6374696f6e20636861726163746572>-.25 F<2c> ++-.4 E F2<7069636f636f6d>4.073 E F0 1.573 ++<706572666f726d73206f6e65206f6620746865206f7065726174696f6e73>4.073 F<64 ++657363726962656420696e207468652022436f6d6d616e6473222073656374696f6e2062 ++656c6f>108 340.8 Q -.65<772e>-.25 G F1<434f4d4d414e4453>72 364.8 Q F0 ++1.588<436f6d6d616e647320617265206769>108 376.8 R -.15<7665>-.25 G 4.088 ++<6e74>.15 G<6f>-4.088 E F2<7069636f636f6d>4.088 E F0 1.588 ++<6279208c727374206b>4.088 F -.15<6579>-.1 G 1.587<696e672074686520226573 ++70616365206368617261637465722220776869636820627920646566>.15 F 1.587 ++<61756c742069732022432d61222028736565>-.1 F .671 ++<224f7074696f6e73222062656c6f>108 388.8 R 3.171<776f>-.25 G 3.172<6e68> ++-3.171 G 1.172 -.25<6f772074>-3.172 H 3.172<6f63>.25 G .672 ++<68616e6765206974292c20616e64207468656e206b>-3.172 F -.15<6579>-.1 G ++.672<696e67206f6e6520666f72207468652066756e6374696f6e2028636f6d6d616e64 ++2920636861726163746572732073686f>.15 F<776e>-.25 E<686572652e>108 400.8 ++Q F2<5b657363617065206368617261637465725d>108 417.6 Q F0 1.244<53656e64 ++20746865206573636170652063686172616374657220746f207468652073657269616c20 ++706f727420616e642072657475726e20746f20227472616e73706172656e7422206d6f64 ++652e2054686973206d65616e73207468617420696620746865>123 429.6 R .358 ++<65736361706520636861726163746572202822432d61222c20627920646566>123 ++441.6 R .359<61756c74292069732074797065642074776963652c207468652070726f ++6772616d2073656e647320746865206573636170652063686172616374657220746f2074 ++68652073657269616c>-.1 F .054<706f72742c20616e642072656d61696e7320696e20 ++7472616e73706172656e74206d6f64652e20546869732069732061206e65>123 453.6 R ++2.553<7762>-.25 G<656861>-2.553 E .053 ++<76696f7220696d706c656d656e74656420696e2076312e342e20507265>-.2 F .053 ++<76696f75736c79207069636f636f6d>-.25 F<7573656420746f2069676e6f72652074 ++6865206573636170652d636861726163746572207768656e2069742077>123 465.6 Q ++<617320656e746572656420617320612066756e6374696f6e20636861726163746572> ++-.1 E<2e>-.55 E F2<432d78>108 482.4 Q F0 .567<45786974207468652070726f67 ++72616d3a2069662074686520222d2d6e6f726573657422206f7074696f6e2077>123 ++494.4 R .567<6173206e6f74206769>-.1 F -.15<7665>-.25 G 3.067<6e74>.15 G ++.567<68656e207468652073657269616c20706f727420697320726573657420746f2069 ++7473206f726967696e616c207365742d>-3.067 F<74696e6773206265666f72652065> ++123 506.4 Q<786974696e673b2069662069742077>-.15 E<6173206769>-.1 E -.15 ++<7665>-.25 G 2.5<6e74>.15 G ++<68652073657269616c20706f7274206973206e6f742072657365742e>-2.5 E F2 ++<432d71>108 523.2 Q F0<51756974207468652070726f6772616d202a776974686f75 ++742a207265736574696e67207468652073657269616c20706f72742c207265>123 535.2 ++Q -.05<6761>-.15 G ++<72646c657373206f662074686520222d2d6e6f726573657422206f7074696f6e2e>.05 ++E F2<432d70>108 552 Q F0<50756c73652074686520445452206c696e652e204c6f> ++123 564 Q<77657220697420666f722031207365632c20616e64207468656e2072616973 ++65206974206167>-.25 E<61696e2e>-.05 E F2<432d74>108 580.8 Q F0 -.8<546f> ++123 592.8 S<67676c652074686520445452206c696e652e204966204454522069732075 ++702c207468656e206c6f>.8 E<7765722069742e20496620697420697320646f>-.25 E ++<776e2c207468656e2072616973652069742e>-.25 E F2<432d5c>108 609.6 Q F0 ++.026<47656e6572617465206120627265616b2073657175656e6365206f6e2074686520 ++73657269616c206c696e652e204120627265616b2073657175656e636520697320757375 ++616c6c792067656e657261746564206279206d61726b696e672028647269>123 621.6 R ++<76696e67>-.25 E<746f206c6f676963616c206f6e6529207468652073657269616c20 ++5478206c696e6520666f7220616e20616d6f756e74206f662074696d6520636f72657370 ++6f6e64696e6720746f207365>123 633.6 Q -.15<7665>-.25 G ++<72616c20636861726163746572206475726174696f6e732e>.15 E F2<432d75>108 ++650.4 Q F0 .601<426175642075702e20496e6372656173652074686520626175642d72 ++6174652e20546865206c697374206f6620626175642d726174657320737465707065642d ++7468726f756768206279207468697320636f6d6d616e642069733a203330302c20363030 ++2c>123 662.4 R<313230302c20323430302c20343830302c20393630302c2031393230 ++302c2033383430302c2035373630302c203131353230302e>123 674.4 Q F2<432d64> ++108 691.2 Q F0 1.555<4261756420646f>123 703.2 R 1.555<776e2e204465637265 ++6173652074686520626175642d726174652e20546865206c697374206f6620626175642d ++726174657320737465707065642d7468726f756768206279207468697320636f6d6d616e ++6420697320746865>-.25 F ++<73616d6520617320666f72207468652022626175642d75702220636f6d6d616e642e> ++123 715.2 Q<31>535 768 Q 0 Cg EP ++%%Page: 2 2 ++%%BeginPageSetup ++BP ++%%EndPageSetup ++/F0 10/Times-Roman@0 SF 373.3 ++<7069636f636f6d283829207069636f636f6d283829>72 48 R/F1 10/Times-Bold@0 ++SF<432d66>108 84 Q F0<4379636c65207468726f756768208d6f>123 96 Q ++<772d636f6e74726f6c2073657474696e6773202852>-.25 E ++<54532f4354532c20584f4e2f584f4646>-.6 E 2.5<2c6e>-.8 G<6f6e65292e>-2.5 E ++F1<432d79>108 112.8 Q F0 ++<4379636c65207468726f756768207061726974792073657474696e6773202865>123 ++124.8 Q -.15<7665>-.25 G<6e2c206f64642c206e6f6e65292e>.15 E F1<432d62> ++108 141.6 Q F0<4379636c65207468726f7567682064617461626974732d6e756d6265 ++722073657474696e67732028352c20362c20372c2038292e>123 153.6 Q F1<432d76> ++108 170.4 Q F0<53686f>123 182.4 Q 4.02<7770>-.25 G 1.52 ++<726f6772616d206f7074696f6e7320286c696b>-4.02 F 4.02<6562>-.1 G 1.521<61 ++756420726174652c206461746120626974732c20657463292e204f6e6c7920746865206f ++7074696f6e7320746861742063616e206265206d6f64698c6564206f6e6c696e65>-4.02 ++F<287468726f75676820636f6d6d616e647329206172652073686f>123 194.4 Q<776e ++2c206e6f742074686f736520746861742063616e206f6e6c792062652073657420617420 ++74686520636f6d6d616e642d6c696e652e>-.25 E F1<432d73>108 211.2 Q F0<5365 ++6e64202875706c6f6164292061208c6c652028736565202253656e64696e6720616e6420 ++5265636569>123 223.2 Q<76696e672046696c6573222062656c6f>-.25 E<7729>-.25 ++E F1<432d72>108 240 Q F0<5265636569>123 252 Q .3 -.15<76652028>-.25 H ++<646f>.15 E<776e6c6f6164292061208c6c652028736565202253656e64696e6720616e ++64205265636569>-.25 E<76696e672046696c6573222062656c6f>-.25 E<7729>-.25 ++E .054<416674657220706572666f726d696e67206f6e65206f66207468652061626f> ++108 268.8 R .354 -.15<7665206f>-.15 H .054 ++<7065726174696f6e73207468652070726f6772616d206c6561>.15 F -.15<7665>-.2 ++G 2.554<7374>.15 G .054<686520636f6d6d616e64206d6f646520616e6420656e7465 ++7273207472616e73706172656e74>-2.554 F<6d6f64652e204578616d706c653a2054> ++108 280.8 Q 2.5<6f69>-.8 G ++<6e6372656173652074686520626175642d72617465206279207477>-2.5 E 2.5<6f73> ++-.1 G<746570732c20796f75206861>-2.5 E .3 -.15<76652074>-.2 H 2.5<6f74> ++.15 G<7970653a>-2.5 E<432d612c20432d752c20432d612c20432d75>108 300 Q<61 ++7373756d696e67206f662d636f7572736520746861742022432d61222069732074686520 ++65736361706520636861726163746572>108 319.2 Q<2e>-.55 E/F2 10.95 ++/Times-Bold@0 SF<53454e44494e4720414e4420524543454956494e472046494c4553> ++72 343.2 Q F1<7069636f636f6d>108 355.2 Q F0 .427 ++<63616e2073656e6420616e64207265636569>2.926 F .727 -.15<7665208c>-.25 H ++.427<6c6573206f>.15 F -.15<7665>-.15 G 2.927<7274>.15 G .427 ++<68652073657269616c20706f7274207573696e672065>-2.927 F .427<787465726e61 ++6c2070726f6772616d73207468617420696d706c656d656e742074686520726573706563 ++2d>-.15 F<7469>108 367.2 Q .3 -.15<76652070>-.25 H<726f746f636f6c732e20 ++496e204c696e7578207479706963616c2070726f6772616d7320666f7220746869732070 ++7572706f7365206172653a>.15 E<8a>108 384 Q F1<7278283129>5 E F0 2.5<2d72> ++2.5 G<65636569>-2.5 E .3 -.15<76652075>-.25 H ++<73696e672074686520582d4d4f44454d2070726f746f636f6c>.15 E<8a>108 400.8 Q ++F1<7262283129>5 E F0 2.5<2d72>2.5 G<65636569>-2.5 E .3 -.15<76652075> ++-.25 H<73696e67207468652059>.15 E<2d4d4f44454d2070726f746f636f6c>-1.11 E ++<8a>108 417.6 Q F1<727a283129>5 E F0 2.5<2d72>2.5 G<65636569>-2.5 E .3 ++-.15<76652075>-.25 H<73696e6720746865205a2d4d4f44454d2070726f746f636f6c> ++.15 E<8a>108 434.4 Q F1<7378283129>5 E F0 2.5<2d73>2.5 G ++<656e64207573696e672074686520582d4d4f44454d2070726f746f636f6c>-2.5 E<8a> ++108 451.2 Q F1<7362283129>5 E F0 2.5<2d73>2.5 G ++<656e64207573696e67207468652059>-2.5 E<2d4d4f44454d2070726f746f636f6c> ++-1.11 E<8a>108 468 Q F1<737a283129>5 E F0 2.5<2d73>2.5 G ++<656e64207573696e6720746865205a2d4d4f44454d2070726f746f636f6c>-2.5 E<8a> ++108 484.8 Q F1<61736369692d786672283129>5 E F0 2.5<2d72>2.5 G<65636569> ++-2.5 E .3 -.15<7665206f>-.25 H 2.5<7274>.15 G ++<72616e736d6974204153434949208c6c6573>-2.5 E .692<546865206e616d65206f66 ++2c20616e642074686520636f6d6d616e642d6c696e65206f7074696f6e7320746f2c2074 ++68652070726f6772616d20746f206265207573656420666f72207472616e736d69747469 ++6e67208c6c657320617265206769>108 501.6 R -.15<7665>-.25 G 3.191<6e62>.15 ++G<79>-3.191 E 2.843<74686520222d2d73656e642d636d6422206f7074696f6e2e2053 ++696d696c61726c79207468652070726f6772616d20746f207265636569>108 513.6 R ++3.143 -.15<7665208c>-.25 H 2.843<6c65732c20616e6420697473206172>.15 F ++2.844<67756d6574732c20617265206769>-.18 F -.15<7665>-.25 G 5.344<6e62> ++.15 G 5.344<7974>-5.344 G<6865>-5.344 E<222d2d7265636569>108 525.6 Q ++-.15<7665>-.25 G .118<2d636d6422206f7074696f6e2e2046>.15 F .117 ++<6f722065>-.15 F .117 ++<78616d706c652c20696e206f7264657220746f2073746172742061>-.15 F F1 ++<7069636f636f6d>2.617 E F0 .117<73657373696f6e20746861742075736573202273 ++7a2220746f207472616e736d6974208c6c65732c20616e64>2.617 F ++<22727a2220746f207265636569>108 537.6 Q -.15<7665>-.25 G 2.5<2c79>.15 G ++<6f75206861>-2.5 E .3 -.15<76652074>-.2 H 2.5<6f73>.15 G ++<617920736f6d657468696e67206c696b>-2.5 E 2.5<6574>-.1 G<6869733a>-2.5 E ++<7069636f636f6d202d2d73656e642d636d642022737a202d767622202d2d7265636569> ++108 556.8 Q -.15<7665>-.25 G<2d636d642022727a202d767622>.15 E .309<4475 ++72696e6720746865207069636f636f6d2073657373696f6e2c20696620796f75206b>108 ++576 R .609 -.15<65792074>-.1 H .309 ++<6865202273656e6422206f7220227265636569>.15 F -.15<7665>-.25 G 2.809 ++<2263>.15 G .309<6f6d6d616e64732028652e672e206279207072657373696e672043 ++2d612c20432d732c206f7220432d>-2.809 F .431<612c20432d722920796f75207769 ++6c6c2062652070726f6d7074656420666f722061208c6c656e616d652e20417420746869 ++732070726f6d707420796f752063616e20656e746572206f6e65206f72206d6f7265208c ++6c652d6e616d65732c20616e6420616e>108 588 R<79>-.15 E .487 ++<6164646974696f6e616c206172>108 600 R .487<67756d656e747320746f20746865 ++207472616e736d697373696f6e206f7220726563657074696f6e2070726f6772616d2e20 ++416674657220746861742c207069636f636f6d2077696c6c207374617274207468652074 ++68652065>-.18 F<78746572>-.15 E<2d>-.2 E .403<6e616c2070726f6772616d2061 ++732073706563698c65642062792074686520222d2d73656e642d636d64222c206f722022 ++2d2d7265636569>108 612 R -.15<7665>-.25 G .403 ++<2d636d6422206f7074696f6e2c20616e64207769746820616e>.15 F 2.902<798c> ++-.15 G .402<6c656e616d657320616e6420616464692d>-2.902 F 1.195 ++<74696f6e616c206172>108 624 R 1.195 ++<67756d656e747320796f75206d6179206861>-.18 F 1.495 -.15<76652073>-.2 H ++1.195<7570706c6965642e20546865207374616e6461726420696e70757420616e64206f ++7574707574206f66207468652065>.15 F 1.195 ++<787465726e616c2070726f6772616d2077696c6c206265>-.15 F .851<636f6e6e6563 ++74656420746f207468652073657269616c20706f72742e20546865207374616e64617264 ++206572726f72206f66207468652065>108 636 R .851<787465726e616c2070726f6772 ++616d2077696c6c20626520636f6e6e656374656420746f20746865207465726d696e616c> ++-.15 F 1.399<77686963682d2d2d7768696c65207468652070726f6772616d20697320 ++72756e6e696e672d2d2d77696c6c207265>108 648 R -.15<7665>-.25 G 1.399<7274 ++20746f2063616e6f6e6963616c206d6f64652e205072657373696e672027432d63272077 ++68696c65207468652065>.15 F<787465726e616c>-.15 E<70726f6772616d20697320 ++72756e6e696e672077696c6c207072656d61747572656c79207465726d696e6174652069 ++742c20616e642072657475726e20636f6e74726f6c20746f>108 660 Q F1 ++<7069636f636f6d>2.5 E F2<4f5054494f4e53>72 684 Q F1<7069636f636f6d>108 ++696 Q F0<616363657074732074686520666f6c6c6f>2.5 E ++<77696e6720636f6d6d616e642d6c696e65206f7074696f6e73>-.25 E<32>535 768 Q ++0 Cg EP ++%%Page: 3 3 ++%%BeginPageSetup ++BP ++%%EndPageSetup ++/F0 10/Times-Roman@0 SF 373.3 ++<7069636f636f6d283829207069636f636f6d283829>72 48 R/F1 10/Times-Bold@0 ++SF<2d2d62617564207c202d62>108 84 Q F0<44658c6e65732074686520626175642d72 ++61746520746f20736574207468652073657269616c2d706f727420287465726d696e616c ++2920746f2e>123 96 Q F1<2d2d8d6f>108 112.8 Q 2.5<777c2d>-.1 G<66>-2.5 E ++F0<44658c6e657320746865208d6f>123 124.8 Q<772d636f6e74726f6c206d6f646520 ++746f20736574207468652073657269616c2d706f727420746f2e204d757374206265206f ++6e65206f663a>-.25 E 5<8ab4>123 141.6 S<782720666f7220786f6e2f786f66>-5 E ++2.5<6628>-.25 G<736f667477>-2.5 E<61726529206d6f6465>-.1 E 5<8ab4>123 ++158.4 S<682720666f72206861726477>-5 E<617265208d6f>-.1 E 2.5<7763>-.25 G ++<6f6e74726f6c202852>-2.5 E<54532f43545329>-.6 E 5<8ab4>123 175.2 S ++<6e2720666f72206e6f208d6f>-5 E 2.5<7763>-.25 G<6f6e74726f6c>-2.5 E ++<28446566>123 192 Q<61756c743a20276e2729>-.1 E F1 ++<2d2d706172697479207c202d70>108 208.8 Q F0<44658c6e65732074686520706172 ++697479206d6f646520746f20736574207468652073657269616c2d706f727420746f2e20 ++4d757374206265206f6e65206f663a>123 220.8 Q 5<8ab4>123 237.6 S ++<6f2720666f72206f646420706172697479206d6f64652e>-5 E 5<8ab4>123 254.4 S ++<652720666f722065>-5 E -.15<7665>-.25 G 2.5<6e70>.15 G ++<6172697479206d6f64652e>-2.5 E 5<8ab4>123 271.2 S ++<6e2720666f72206e6f20706172697479>-5 E 2.5<2c6d>-.65 G<6f64652e>-2.5 E ++<28446566>123 288 Q<61756c743a20276e2729>-.1 E F1 ++<2d2d6461746162697473207c202d64>108 304.8 Q F0 ++<44658c6e657320746865206e756d626572206f662064617461206269747320696e2065> ++123 316.8 Q -.15<7665>-.25 G<727920636861726163746572>.15 E 2.5<2e4d> ++-.55 G<757374206265206f6e65206f663a20352c20362c20372c2038>-2.5 E ++<28446566>123 336 Q<61756c743a203829>-.1 E F1 ++<2d2d657361637065207c202d65>108 352.8 Q F0 1.151 ++<44658c6e6573207468652063686172616374657220746861742077696c6c206d616b> ++123 364.8 R 3.651<6570>-.1 G 1.151<69636f636f6d20656e74657220636f6d6d61 ++6e642d6d6f64652028736565206465736372697074696f6e2061626f>-3.651 F -.15 ++<7665>-.15 G 1.15<292e20496620277827206973>.15 F<6769>123 376.8 Q -.15 ++<7665>-.25 G<6e2c207468656e20432d782077696c6c206d616b>.15 E 2.5<6570>-.1 ++G<69636f636f6d20656e74657220636f6d6d616e64206d6f64652e>-2.5 E<28446566> ++123 396 Q<61756c743a2027612729>-.1 E F1<2d2d6e6f696e6974207c202d69>108 ++412.8 Q F0 .846<4966206769>123 424.8 R -.15<7665>-.25 G<6e2c>.15 E F1 ++<7069636f636f6d>3.346 E F0 .847<77696c6c206e6f7420696e697469616c697a652c ++2072657365742c206f72206f7468657277697365206d6564646c65207769746820746865 ++2073657269616c20706f72742061742073746172742d75702e2049742077696c6c>3.346 ++F 1.706 ++<6a757374206f70656e2069742e20546869732069732075736566756c2c20666f722065> ++123 436.8 R 1.706<78616d706c652c20666f7220636f6e6e656374696e67>-.15 F F1 ++<7069636f636f6d>4.206 E F0 1.705 ++<746f20616c72656164792d636f6e6e6563746564206d6f64656d732c206f72>4.205 F ++.864<616c726561647920636f6e8c677572656420706f72747320776974686f75742074 ++65726d696e6174696e672074686520636f6e6e656374696f6e2c206f7220616c74657269 ++6e67207468652073657474696e67732e2049662072657175697265642073657269616c> ++123 448.8 R<706f727420706172616d65746572732063616e207468656e206265206164 ++6a75737465642061742072756e2d74696d6520627920636f6d6d616e64732e>123 460.8 ++Q F1<2d2d6e6f72>108 477.6 Q<65736574207c202d72>-.18 E F0 .18<4966206769> ++123 489.6 R -.15<7665>-.25 G<6e2c>.15 E F1<7069636f636f6d>2.68 E F0 .18< ++77696c6c206e6f74202a72657365742a207468652073657269616c20706f727420776865 ++6e2065>2.68 F .18<786974696e672e2049742077696c6c206a75737420636c6f736520 ++746865208c6c6564657320616e6420646f206e6f74682d>-.15 F .798 ++<696e67206d6f72652e20546869732069732075736566756c2c20666f722065>123 ++501.6 R .798<78616d706c652c20666f72206c6561>-.15 F .798 ++<76696e67206d6f64656d7320636f6e6e6563746564207768656e2065>-.2 F ++<786974696e67>-.15 E F1 .798<7069636f636f6d207069636f636f6d>3.298 F F0 ++.42<7573696e67207468652022517569742220636f6d6d616e642028696e737465616420 ++6f6620224578697422292c207768696368206e65>123 513.6 R -.15<7665>-.25 G ++2.92<7272>.15 G .42<6573657473207468652073657269616c20706f72742e20496620 ++222d2d6e6f726573657422206973206769>-2.92 F -.15<7665>-.25 G<6e>.15 E ++<7468656e2022517569742220616e64202245786974222062656861>123 525.6 Q .3 ++-.15<76652065>-.2 H<7373656e7469616c6c79207468652073616d652e>.15 E F1 ++<2d2d6e6f6c6f636b207c202d6c>108 542.4 Q F0 2.07<4966206769>123 554.4 R ++-.15<7665>-.25 G<6e2c>.15 E F1<7069636f636f6d>4.57 E F0 2.07<77696c6c20 ++2a6e6f742a20617474656d707420746f206c6f636b207468652073657269616c20706f72 ++74206265666f7265206f70656e696e672069742e204e6f726d616c6c79207069636f636f ++6d>4.57 F .456<617474656d70747320746f20676574206120555543502d7374796c65 ++206c6f636b2d8c6c652028652e672e20222f76>123 566.4 R .456<61722f6c6f636b2f ++4c434b2e2e74747953302229206265666f7265206f70656e696e672074686520706f7274 ++2e2046>-.25 F .456<61696c696e6720746f>-.15 F .913 ++<646f20736f2c20726573756c747320696e207468652070726f6772616d2065>123 ++578.4 R .914 ++<786974696e6720616674657220656d697474696e6720616e206572726f72>-.15 F ++.914<2d6d6573736167652e20497420697320706f737369626c65207468617420796f75 ++72207069636f636f6d>-.2 F<62696e61727920697320636f6d70696c65642077697468 ++6f75742074686973206f7074696f6e2e>123 590.4 Q F1 ++<2d2d73656e642d636d64207c202d73>108 607.2 Q F0 ++<53706563698c6573207468652065>123 619.2 Q ++<787465726e616c2070726f6772616d2028616e6420616e>-.15 E 2.5<7961>-.15 G ++-.18<7267>-2.5 G<756d656e747320746f2069742920746861742077696c6c20626520 ++7573656420666f72207472616e736d697474696e67208c6c65732e>.18 E<446566>123 ++638.4 Q<61756c743a2022737a202d767622>-.1 E F1<2d2d72>108 655.2 Q ++<65636569>-.18 E -.1<7665>-.1 G<2d636d64207c202d76>.1 E F0 ++<53706563698c6573207468652065>123 667.2 Q ++<787465726e616c2070726f6772616d2028616e6420616e>-.15 E 2.5<7961>-.15 G ++-.18<7267>-2.5 G<756d656e747320746f2069742920746861742077696c6c20626520 ++7573656420666f72207265636569>.18 E<76696e67208c6c65732e>-.25 E<28446566> ++123 686.4 Q<61756c743a2022727a202d76762229>-.1 E F1 ++<2d2d68656c70207c202d68>108 703.2 Q F0<5072696e7420612073686f7274206865 ++6c70206d6573736167652064657363726962696e672074686520636f6d6d616e642d6c69 ++6e65206f7074696f6e732e>123 715.2 Q<33>535 768 Q 0 Cg EP ++%%Page: 4 4 ++%%BeginPageSetup ++BP ++%%EndPageSetup ++/F0 10/Times-Roman@0 SF 373.3 ++<7069636f636f6d283829207069636f636f6d283829>72 48 R/F1 10.95 ++/Times-Bold@0 SF -.548<4155>72 84 S<54484f52>.548 E F0 ++<7069636f636f6d2077>108 96 Q<6173207772697474656e206279204e69636b2050> ++-.1 E<617461>-.15 E -.25<7661>-.2 G<6c697320286e706174406566>.25 E ++<61756c742e6e657429>-.1 E F1 -1.04 -1.588<41562041>72 120 T ++<494c4142494c495459>1.588 E F0<546865206c61746573742076>108 132 Q ++<657273696f6e206f6620227069636f636f6d222063616e20626520646f>-.15 E ++<776e6c6f616465642066726f6d3a>-.25 E/F2 10/Times-Bold@0 SF<687474703a2f ++2f656661756c742e6e65742f6e7061742f6861636b732f7069636f636f6d2f>2.5 E F0 ++<34>535 768 Q 0 Cg EP ++%%Trailer ++end ++%%EOF +Index: user/blkfin-apps/picocom/term.c +=================================================================== +--- user/blkfin-apps/picocom/term.c (revision 0) ++++ user/blkfin-apps/picocom/term.c (revision 0) +@@ -0,0 +1,1193 @@ ++/* vi: set sw=4 ts=4: ++ * ++ * term.c ++ * ++ * General purpose terminal handling library. ++ * ++ * Nick Patavalis (npat@inaccessnetworks.com) ++ * ++ * originaly by Pantelis Antoniou (panto@intranet.gr), Nick Patavalis ++ * ++ * Documentation can be found in the header file "term.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. ++ * ++ * You 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 ++ * ++ * $Id$ ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#ifdef __linux__ ++#include ++#else ++#include ++#endif /* of __linux__ */ ++ ++#include "term.h" ++ ++/***************************************************************************/ ++ ++static struct term_s { ++ int init; ++ int fd[MAX_TERMS]; ++ struct termios origtermios[MAX_TERMS]; ++ struct termios currtermios[MAX_TERMS]; ++ struct termios nexttermios[MAX_TERMS]; ++} term; ++ ++/***************************************************************************/ ++ ++int term_errno; ++ ++static const char * const term_err_str[] = { ++ [TERM_EOK] = "No error", ++ [TERM_ENOINIT] = "Framework is uninitialized", ++ [TERM_EFULL] = "Framework is full", ++ [TERM_ENOTFOUND] = "Filedes not in the framework", ++ [TERM_EEXISTS] = "Filedes already in the framework", ++ [TERM_EATEXIT] = "Cannot install atexit handler", ++ [TERM_EISATTY] = "Filedes is not a tty", ++ [TERM_EFLUSH] = "Cannot flush the device", ++ [TERM_EGETATTR] = "Cannot get the device attributes", ++ [TERM_ESETATTR] = "Cannot set the device attributes", ++ [TERM_EBAUD] = "Invalid baud rate", ++ [TERM_ESETOSPEED] = "Cannot set the output speed", ++ [TERM_ESETISPEED] = "Cannot set the input speed", ++ [TERM_EPARITY] = "Invalid parity mode", ++ [TERM_EDATABITS] = "Invalid number of databits", ++ [TERM_EFLOW] = "Invalid flowcontrol mode", ++ [TERM_EDTRDOWN] = "Cannot lower DTR", ++ [TERM_EDTRUP] = "Cannot raise DTR", ++ [TERM_EDRAIN] = "Cannot drain the device", ++ [TERM_EBREAK] = "Cannot send break sequence" ++}; ++ ++static char term_err_buff[1024]; ++ ++const char * ++term_strerror (int terrnum, int errnum) ++{ ++ const char *rval; ++ ++ switch(terrnum) { ++ case TERM_EFLUSH: ++ case TERM_EGETATTR: ++ case TERM_ESETATTR: ++ case TERM_ESETOSPEED: ++ case TERM_ESETISPEED: ++ case TERM_EDRAIN: ++ case TERM_EBREAK: ++ snprintf(term_err_buff, sizeof(term_err_buff), ++ "%s: %s", term_err_str[terrnum], strerror(errnum)); ++ rval = term_err_buff; ++ break; ++ case TERM_EOK: ++ case TERM_ENOINIT: ++ case TERM_EFULL: ++ case TERM_ENOTFOUND: ++ case TERM_EEXISTS: ++ case TERM_EATEXIT: ++ case TERM_EISATTY: ++ case TERM_EBAUD: ++ case TERM_EPARITY: ++ case TERM_EDATABITS: ++ case TERM_EFLOW: ++ case TERM_EDTRDOWN: ++ case TERM_EDTRUP: ++ snprintf(term_err_buff, sizeof(term_err_buff), ++ "%s", term_err_str[terrnum]); ++ rval = term_err_buff; ++ break; ++ default: ++ rval = NULL; ++ break; ++ } ++ ++ return rval; ++} ++ ++int ++term_perror (const char *prefix) ++{ ++ return fprintf(stderr, "%s %s\n", ++ prefix, term_strerror(term_errno, errno)); ++} ++ ++/***************************************************************************/ ++ ++static int ++term_find_next_free (void) ++{ ++ int rval, i; ++ ++ do { /* dummy */ ++ if ( ! term.init ) { ++ term_errno = TERM_ENOINIT; ++ rval = -1; ++ break; ++ } ++ ++ for (i = 0; i < MAX_TERMS; i++) ++ if ( term.fd[i] == -1 ) break; ++ ++ if ( i == MAX_TERMS ) { ++ term_errno = TERM_EFULL; ++ rval = -1; ++ break; ++ } ++ ++ rval = i; ++ } while (0); ++ ++ return rval; ++} ++ ++/***************************************************************************/ ++ ++static int ++term_find (int fd) ++{ ++ int rval, i; ++ ++ do { /* dummy */ ++ if ( ! term.init ) { ++ term_errno = TERM_ENOINIT; ++ rval = -1; ++ break; ++ } ++ ++ for (i = 0; i < MAX_TERMS; i++) ++ if (term.fd[i] == fd) break; ++ ++ if ( i == MAX_TERMS ) { ++ term_errno = TERM_ENOTFOUND; ++ rval = -1; ++ break; ++ } ++ ++ rval = i; ++ } while (0); ++ ++ return rval; ++} ++ ++/***************************************************************************/ ++ ++static void ++term_exitfunc (void) ++{ ++ int r, i; ++ ++ do { /* dummy */ ++ if ( ! term.init ) ++ break; ++ ++ for (i = 0; i < MAX_TERMS; i++) { ++ if (term.fd[i] == -1) ++ continue; ++ do { /* dummy */ ++ r = tcflush(term.fd[i], TCIOFLUSH); ++ if ( r < 0 ) break; ++ r = tcsetattr(term.fd[i], TCSAFLUSH, &term.origtermios[i]); ++ if ( r < 0 ) break; ++ } while (0); ++ if ( r < 0 ) { ++ char *tname; ++ ++ tname = ttyname(term.fd[i]); ++ if ( ! tname ) tname = "UNKNOWN"; ++ fprintf(stderr, "%s: reset failed for dev %s: %s\n", ++ __FUNCTION__, tname, strerror(errno)); ++ } ++ term.fd[i] = -1; ++ } ++ } while (0); ++} ++ ++/***************************************************************************/ ++ ++int ++term_lib_init (void) ++{ ++ int rval, r, i; ++ ++ rval = 0; ++ ++ do { /* dummy */ ++ if ( term.init ) { ++ /* reset all terms back to their original settings */ ++ for (i = 0; i < MAX_TERMS; i++) { ++ if (term.fd[i] == -1) ++ continue; ++ do { ++ r = tcflush(term.fd[i], TCIOFLUSH); ++ if ( r < 0 ) break; ++ r = tcsetattr(term.fd[i], TCSAFLUSH, &term.origtermios[i]); ++ if ( r < 0 ) break; ++ } while (0); ++ if ( r < 0 ) { ++ char *tname; ++ ++ tname = ttyname(term.fd[i]); ++ if ( ! tname ) tname = "UNKNOWN"; ++ fprintf(stderr, "%s: reset failed for dev %s: %s\n", ++ __FUNCTION__, tname, strerror(errno)); ++ } ++ term.fd[i] = -1; ++ } ++ } else { ++ /* initialize term structure. */ ++ for (i = 0; i < MAX_TERMS; i++) ++ term.fd[i] = -1; ++ if ( atexit(term_exitfunc) != 0 ) { ++ term_errno = TERM_EATEXIT; ++ rval = -1; ++ break; ++ } ++ /* ok. term struct is now initialized. */ ++ term.init = 1; ++ } ++ } while(0); ++ ++ return rval; ++} ++ ++/***************************************************************************/ ++ ++int ++term_add (int fd) ++{ ++ int rval, r, i; ++ ++ rval = 0; ++ ++ do { /* dummy */ ++ i = term_find(fd); ++ if ( i >= 0 ) { ++ term_errno = TERM_EEXISTS; ++ rval = -1; ++ break; ++ } ++ ++ if ( ! isatty(fd) ) { ++ term_errno = TERM_EISATTY; ++ rval = -1; ++ break; ++ } ++ ++ i = term_find_next_free(); ++ if ( i < 0 ) { ++ rval = -1; ++ break; ++ } ++ ++ r = tcgetattr(fd, &term.origtermios[i]); ++ if ( r < 0 ) { ++ term_errno = TERM_EGETATTR; ++ rval = -1; ++ break; ++ } ++ ++ term.currtermios[i] = term.origtermios[i]; ++ term.nexttermios[i] = term.origtermios[i]; ++ term.fd[i] = fd; ++ } while (0); ++ ++ return rval; ++} ++ ++/***************************************************************************/ ++ ++int ++term_remove(int fd) ++{ ++ int rval, r, i; ++ ++ rval = 0; ++ ++ do { /* dummy */ ++ i = term_find(fd); ++ if ( i < 0 ) { ++ rval = -1; ++ break; ++ } ++ ++ do { /* dummy */ ++ r = tcflush(term.fd[i], TCIOFLUSH); ++ if ( r < 0 ) { ++ term_errno = TERM_EFLUSH; ++ rval = -1; ++ break; ++ } ++ r = tcsetattr(term.fd[i], TCSAFLUSH, &term.origtermios[i]); ++ if ( r < 0 ) { ++ term_errno = TERM_ESETATTR; ++ rval = -1; ++ break; ++ } ++ } while (0); ++ ++ term.fd[i] = -1; ++ } while (0); ++ ++ return rval; ++} ++ ++/***************************************************************************/ ++ ++int ++term_erase(int fd) ++{ ++ int rval, i; ++ ++ rval = 0; ++ ++ do { /* dummy */ ++ i = term_find(fd); ++ if ( i < 0 ) { ++ rval = -1; ++ break; ++ } ++ ++ term.fd[i] = -1; ++ } while (0); ++ ++ return rval; ++} ++ ++/***************************************************************************/ ++ ++int ++term_replace (int oldfd, int newfd) ++{ ++ int rval, r, i; ++ ++ rval = 0; ++ ++ do { /* dummy */ ++ ++ i = term_find(oldfd); ++ if ( i < 0 ) { ++ rval = -1; ++ break; ++ } ++ ++ r = tcsetattr(newfd, TCSAFLUSH, &term.currtermios[i]); ++ if ( r < 0 ) { ++ term_errno = TERM_ESETATTR; ++ rval = -1; ++ break; ++ } ++ ++ term.fd[i] = newfd; ++ ++ } while (0); ++ ++ return rval; ++} ++ ++/***************************************************************************/ ++ ++int ++term_reset (int fd) ++{ ++ int rval, r, i; ++ ++ rval = 0; ++ ++ do { /* dummy */ ++ ++ i = term_find(fd); ++ if ( i < 0 ) { ++ rval = -1; ++ break; ++ } ++ ++ r = tcflush(term.fd[i], TCIOFLUSH); ++ if ( r < 0 ) { ++ term_errno = TERM_EFLUSH; ++ rval = -1; ++ break; ++ } ++ r = tcsetattr(term.fd[i], TCSAFLUSH, &term.origtermios[i]); ++ if ( r < 0 ) { ++ term_errno = TERM_ESETATTR; ++ rval = -1; ++ break; ++ } ++ ++ term.currtermios[i] = term.origtermios[i]; ++ term.nexttermios[i] = term.origtermios[i]; ++ } while (0); ++ ++ return rval; ++} ++ ++/***************************************************************************/ ++ ++int ++term_revert (int fd) ++{ ++ int rval, i; ++ ++ rval = 0; ++ ++ do { /* dummy */ ++ ++ i = term_find(fd); ++ if ( i < 0 ) { ++ rval = -1; ++ break; ++ } ++ ++ term.nexttermios[i] = term.currtermios[i]; ++ ++ } while (0); ++ ++ return rval; ++} ++ ++/***************************************************************************/ ++ ++int ++term_refresh (int fd) ++{ ++ int rval, r, i; ++ ++ rval = 0; ++ ++ do { /* dummy */ ++ ++ i = term_find(fd); ++ if ( i < 0 ) { ++ rval = -1; ++ break; ++ } ++ ++ r = tcgetattr(fd, &term.currtermios[i]); ++ if ( r < 0 ) { ++ term_errno = TERM_EGETATTR; ++ rval = -1; ++ break; ++ } ++ ++ } while (0); ++ ++ return rval; ++} ++ ++/***************************************************************************/ ++ ++int ++term_apply (int fd) ++{ ++ int rval, r, i; ++ ++ rval = 0; ++ ++ do { /* dummy */ ++ ++ i = term_find(fd); ++ if ( i < 0 ) { ++ rval = -1; ++ break; ++ } ++ ++ r = tcsetattr(term.fd[i], TCSAFLUSH, &term.nexttermios[i]); ++ if ( r < 0 ) { ++ term_errno = TERM_ESETATTR; ++ rval = -1; ++ break; ++ } ++ ++ term.currtermios[i] = term.nexttermios[i]; ++ ++ } while (0); ++ ++ return rval; ++} ++ ++/***************************************************************************/ ++ ++int ++term_set_raw (int fd) ++{ ++ int rval, i; ++ ++ rval = 0; ++ ++ do { /* dummy */ ++ ++ i = term_find(fd); ++ if ( i < 0 ) { ++ rval = -1; ++ break; ++ } ++ ++ /* BSD raw mode */ ++ cfmakeraw(&term.nexttermios[i]); ++ /* one byte at a time, no timer */ ++ term.nexttermios[i].c_cc[VMIN] = 1; ++ term.nexttermios[i].c_cc[VTIME] = 0; ++ ++ } while (0); ++ ++ return rval; ++} ++ ++/***************************************************************************/ ++ ++int ++term_set_baudrate (int fd, int baudrate) ++{ ++ int rval, r, i; ++ speed_t spd; ++ struct termios tio; ++ ++ rval = 0; ++ ++ do { /* dummy */ ++ ++ i = term_find(fd); ++ if ( i < 0 ) { ++ rval = -1; ++ break; ++ } ++ ++ tio = term.nexttermios[i]; ++ ++ switch (baudrate) { ++ case 0: ++ spd = B0; ++ break; ++ case 50: ++ spd = B50; ++ break; ++ case 75: ++ spd = B75; ++ break; ++ case 110: ++ spd = B110; ++ break; ++ case 134: ++ spd = B134; ++ break; ++ case 150: ++ spd = B150; ++ break; ++ case 200: ++ spd = B200; ++ break; ++ case 300: ++ spd = B300; ++ break; ++ case 600: ++ spd = B600; ++ break; ++ case 1200: ++ spd = B1200; ++ break; ++ case 1800: ++ spd = B1800; ++ break; ++ case 2400: ++ spd = B2400; ++ break; ++ case 4800: ++ spd = B4800; ++ break; ++ case 9600: ++ spd = B9600; ++ break; ++ case 19200: ++ spd = B19200; ++ break; ++ case 38400: ++ spd = B38400; ++ break; ++ case 57600: ++ spd = B57600; ++ break; ++ case 115200: ++ spd = B115200; ++ break; ++ case 230400: ++ spd = B230400; ++ break; ++ default: ++ term_errno = TERM_EBAUD; ++ rval = -1; ++ break; ++ } ++ if ( rval < 0 ) break; ++ ++ r = cfsetospeed(&tio, spd); ++ if ( r < 0 ) { ++ term_errno = TERM_ESETOSPEED; ++ rval = -1; ++ break; ++ } ++ ++ r = cfsetispeed(&tio, spd); ++ if ( r < 0 ) { ++ term_errno = TERM_ESETISPEED; ++ rval = -1; ++ break; ++ } ++ ++ term.nexttermios[i] = tio; ++ ++ } while (0); ++ ++ return rval; ++} ++ ++/***************************************************************************/ ++ ++int ++term_set_parity (int fd, enum parity_e parity) ++{ ++ int rval, i; ++ struct termios *tiop; ++ ++ rval = 0; ++ ++ do { /* dummy */ ++ ++ i = term_find(fd); ++ if ( i < 0 ) { ++ rval = -1; ++ break; ++ } ++ ++ tiop = &term.nexttermios[i]; ++ ++ switch (parity) { ++ case P_EVEN: ++ tiop->c_cflag = (tiop->c_cflag & ~(PARENB | PARODD)) | PARENB; ++ break; ++ case P_ODD: ++ tiop->c_cflag = (tiop->c_cflag & ~(PARENB | PARODD)) | PARODD; ++ break; ++ case P_NONE: ++ tiop->c_cflag = (tiop->c_cflag & ~(PARENB | PARODD)); ++ break; ++ default: ++ term_errno = TERM_EPARITY; ++ rval = -1; ++ break; ++ } ++ if ( rval < 0 ) break; ++ ++ } while (0); ++ ++ return rval; ++} ++ ++/***************************************************************************/ ++ ++int ++term_set_databits (int fd, int databits) ++{ ++ int rval, i; ++ struct termios *tiop; ++ ++ rval = 0; ++ ++ do { /* dummy */ ++ ++ i = term_find(fd); ++ if ( i < 0 ) { ++ rval = -1; ++ break; ++ } ++ ++ tiop = &term.nexttermios[i]; ++ ++ switch (databits) { ++ case 5: ++ tiop->c_cflag = (tiop->c_cflag & ~CSIZE) | CS5; ++ break; ++ case 6: ++ tiop->c_cflag = (tiop->c_cflag & ~CSIZE) | CS6; ++ break; ++ case 7: ++ tiop->c_cflag = (tiop->c_cflag & ~CSIZE) | CS7; ++ break; ++ case 8: ++ tiop->c_cflag = (tiop->c_cflag & ~CSIZE) | CS8; ++ break; ++ default: ++ term_errno = TERM_EDATABITS; ++ rval = -1; ++ break; ++ } ++ if ( rval < 0 ) break; ++ ++ } while (0); ++ ++ return rval; ++} ++ ++/***************************************************************************/ ++ ++int ++term_set_flowcntrl (int fd, enum flowcntrl_e flowcntl) ++{ ++ int rval, i; ++ struct termios *tiop; ++ ++ rval = 0; ++ ++ do { /* dummy */ ++ ++ i = term_find(fd); ++ if ( i < 0 ) { ++ rval = -1; ++ break; ++ } ++ ++ tiop = &term.nexttermios[i]; ++ ++ switch (flowcntl) { ++ case FC_RTSCTS: ++ tiop->c_cflag |= CRTSCTS; ++ tiop->c_iflag &= ~(IXON | IXOFF | IXANY); ++ break; ++ case FC_XONXOFF: ++ tiop->c_cflag &= ~(CRTSCTS); ++ tiop->c_iflag |= IXON | IXOFF; ++ break; ++ case FC_NONE: ++ tiop->c_cflag &= ~(CRTSCTS); ++ tiop->c_iflag &= ~(IXON | IXOFF | IXANY); ++ break; ++ default: ++ term_errno = TERM_EFLOW; ++ rval = -1; ++ break; ++ } ++ if ( rval < 0 ) break; ++ ++ } while (0); ++ ++ return rval; ++} ++ ++/***************************************************************************/ ++ ++int ++term_set_local(int fd, int local) ++{ ++ int rval, i; ++ struct termios *tiop; ++ ++ rval = 0; ++ ++ do { /* dummy */ ++ ++ i = term_find(fd); ++ if ( i < 0 ) { ++ rval = -1; ++ break; ++ } ++ ++ tiop = &term.nexttermios[i]; ++ ++ if ( local ) ++ tiop->c_cflag |= CLOCAL; ++ else ++ tiop->c_cflag &= ~CLOCAL; ++ ++ } while (0); ++ ++ return rval; ++} ++ ++/***************************************************************************/ ++ ++int ++term_set_hupcl (int fd, int on) ++{ ++ int rval, i; ++ struct termios *tiop; ++ ++ rval = 0; ++ ++ do { /* dummy */ ++ ++ i = term_find(fd); ++ if ( i < 0 ) { ++ rval = -1; ++ break; ++ } ++ ++ tiop = &term.nexttermios[i]; ++ ++ if ( on ) ++ tiop->c_cflag |= HUPCL; ++ else ++ tiop->c_cflag &= ~HUPCL; ++ ++ } while (0); ++ ++ return rval; ++} ++ ++/***************************************************************************/ ++ ++int ++term_set(int fd, ++ int raw, ++ int baud, enum parity_e parity, int bits, enum flowcntrl_e fc, ++ int local, int hup_close) ++{ ++ int rval, r, i, ni; ++ struct termios tio; ++ ++ rval = 0; ++ ++ do { /* dummy */ ++ ++ i = term_find(fd); ++ if ( i < 0 ) { ++ ni = term_add(fd); ++ if ( ni < 0 ) { ++ rval = -1; ++ break; ++ } ++ } else { ++ ni = i; ++ } ++ ++ tio = term.nexttermios[ni]; ++ ++ do { /* dummy */ ++ ++ if (raw) { ++ r = term_set_raw(fd); ++ if ( r < 0 ) { rval = -1; break; } ++ } ++ ++ r = term_set_baudrate(fd, baud); ++ if ( r < 0 ) { rval = -1; break; } ++ ++ r = term_set_parity(fd, parity); ++ if ( r < 0 ) { rval = -1; break; } ++ ++ r = term_set_databits(fd, bits); ++ if ( r < 0 ) { rval = -1; break; } ++ ++ r = term_set_flowcntrl(fd, fc); ++ if ( r < 0 ) { rval = -1; break; } ++ ++ r = term_set_local(fd, local); ++ if ( r < 0 ) { rval = -1; break; } ++ ++ r = term_set_hupcl(fd, hup_close); ++ if ( r < 0 ) { rval = -1; break; } ++ ++ } while (0); ++ ++ if ( rval < 0 ) { ++ if ( i < 0 ) ++ /* new addition. must be removed */ ++ term.fd[ni] = -1; ++ else ++ /* just revert to previous settings */ ++ term.nexttermios[ni] = tio; ++ } ++ ++ } while (0); ++ ++ return rval; ++} ++ ++/***************************************************************************/ ++ ++int ++term_pulse_dtr (int fd) ++{ ++ int rval, r, i; ++ ++ rval = 0; ++ ++ do { /* dummy */ ++ ++ i = term_find(fd); ++ if ( i < 0 ) { ++ rval = -1; ++ break; ++ } ++ ++#ifdef __linux__ ++ { ++ int opins = TIOCM_DTR; ++ ++ r = ioctl(fd, TIOCMBIC, &opins); ++ if ( r < 0 ) { ++ term_errno = TERM_EDTRDOWN; ++ rval = -1; ++ break; ++ } ++ ++ sleep(1); ++ ++ r = ioctl(fd, TIOCMBIS, &opins); ++ if ( r < 0 ) { ++ term_errno = TERM_EDTRUP; ++ rval = -1; ++ break; ++ } ++ } ++#else ++ { ++ struct termios tio, tioold; ++ ++ r = tcgetattr(fd, &tio); ++ if ( r < 0 ) { ++ term_errno = TERM_ESETATTR; ++ rval = -1; ++ break; ++ } ++ ++ tioold = tio; ++ ++ cfsetospeed(&tio, B0); ++ cfsetispeed(&tio, B0); ++ r = tcsetattr(fd, TCSANOW, &tio); ++ if ( r < 0 ) { ++ term_errno = TERM_ESETATTR; ++ rval = -1; ++ break; ++ } ++ ++ sleep(1); ++ ++ r = tcsetattr(fd, TCSANOW, &tioold); ++ if ( r < 0 ) { ++ term.currtermios[i] = tio; ++ term_errno = TERM_ESETATTR; ++ rval = -1; ++ break; ++ } ++ } ++#endif /* of __linux__ */ ++ ++ } while (0); ++ ++ return rval; ++} ++ ++/***************************************************************************/ ++ ++int ++term_raise_dtr(int fd) ++{ ++ int rval, r, i; ++ ++ rval = 0; ++ ++ do { /* dummy */ ++ ++ i = term_find(fd); ++ if ( i < 0 ) { ++ rval = -1; ++ break; ++ } ++ ++#ifdef __linux__ ++ { ++ int opins = TIOCM_DTR; ++ ++ r = ioctl(fd, TIOCMBIS, &opins); ++ if ( r < 0 ) { ++ term_errno = TERM_EDTRUP; ++ rval = -1; ++ break; ++ } ++ } ++#else ++ r = tcsetattr(fd, TCSANOW, &term.currtermios[i]); ++ if ( r < 0 ) { ++ /* FIXME: perhaps try to update currtermios */ ++ term_errno = TERM_ESETATTR; ++ rval = -1; ++ break; ++ } ++#endif /* of __linux__ */ ++ } while (0); ++ ++ return rval; ++} ++ ++/***************************************************************************/ ++ ++ ++int ++term_lower_dtr(int fd) ++{ ++ int rval, r, i; ++ ++ rval = 0; ++ ++ do { /* dummy */ ++ ++ i = term_find(fd); ++ if ( i < 0 ) { ++ rval = -1; ++ break; ++ } ++ ++#ifdef __linux__ ++ { ++ int opins = TIOCM_DTR; ++ ++ r = ioctl(fd, TIOCMBIC, &opins); ++ if ( r < 0 ) { ++ term_errno = TERM_EDTRDOWN; ++ rval = -1; ++ break; ++ } ++ } ++#else ++ { ++ struct termios tio; ++ ++ r = tcgetattr(fd, &tio); ++ if ( r < 0 ) { ++ term_errno = TERM_EGETATTR; ++ rval = -1; ++ break; ++ } ++ term.currtermios[i] = tio; ++ ++ cfsetospeed(&tio, B0); ++ cfsetispeed(&tio, B0); ++ ++ r = tcsetattr(fd, TCSANOW, &tio); ++ if ( r < 0 ) { ++ term_errno = TERM_ESETATTR; ++ rval = -1; ++ break; ++ } ++ } ++#endif /* of __linux__ */ ++ } while (0); ++ ++ return rval; ++} ++ ++/***************************************************************************/ ++ ++int ++term_drain(int fd) ++{ ++ int rval, r; ++ ++ rval = 0; ++ ++ do { /* dummy */ ++ ++ r = term_find(fd); ++ if ( r < 0 ) { ++ rval = -1; ++ break; ++ } ++ ++ do { ++ r = tcdrain(fd); ++ } while ( r < 0 && errno == EINTR); ++ if ( r < 0 ) { ++ term_errno = TERM_EDRAIN; ++ rval = -1; ++ break; ++ } ++ ++ } while (0); ++ ++ return rval; ++} ++ ++/***************************************************************************/ ++ ++int ++term_flush(int fd) ++{ ++ int rval, r; ++ ++ rval = 0; ++ ++ do { /* dummy */ ++ ++ r = term_find(fd); ++ if ( r < 0 ) { ++ rval = -1; ++ break; ++ } ++ ++ r = tcflush(fd, TCIOFLUSH); ++ if ( r < 0 ) { ++ rval = -1; ++ break; ++ } ++ ++ } while (0); ++ ++ return rval; ++} ++ ++/***************************************************************************/ ++ ++int ++term_break(int fd) ++{ ++ int rval, r; ++ ++ rval = 0; ++ ++ do { /* dummy */ ++ ++ r = term_find(fd); ++ if ( r < 0 ) { ++ rval = -1; ++ break; ++ } ++ ++ r = tcsendbreak(fd, 0); ++ if ( r < 0 ) { ++ term_errno = TERM_EBREAK; ++ rval = -1; ++ break; ++ } ++ ++ } while (0); ++ ++ return rval; ++} ++ ++/**************************************************************************/ ++ ++/* ++ * Local Variables: ++ * mode:c ++ * tab-width: 4 ++ * c-basic-offset: 4 ++ * End: ++ */ +Index: user/blkfin-apps/picocom/pcasc +=================================================================== +--- user/blkfin-apps/picocom/pcasc (revision 0) ++++ user/blkfin-apps/picocom/pcasc (revision 0) +@@ -0,0 +1,4 @@ ++#!/bin/sh ++exec picocom \ ++ --send-cmd="ascii-xfr -sv -l5" \ ++ --receive-cmd="ascii-xfr -rv" "$@" +Index: user/blkfin-apps/picocom/CONTRIBUTORS +=================================================================== +--- user/blkfin-apps/picocom/CONTRIBUTORS (revision 0) ++++ user/blkfin-apps/picocom/CONTRIBUTORS (revision 0) +@@ -0,0 +1,11 @@ ++ ++The following people contributed suggestions, comments, and fixes: ++ ++- Oliver Kurth (oku@debian.org) contributed bug fixes and the manual ++ page for picocm. ++ ++- Julius P. Malkiewicz (julius@sonartech.com.au) contributed FreeBSD ++ portablity fixes, the C-\ command implementation, the UUCP locks ++ implementation, and other minor fixes ++ ++ +Index: user/blkfin-apps/picocom/README +=================================================================== +--- user/blkfin-apps/picocom/README (revision 0) ++++ user/blkfin-apps/picocom/README (revision 0) +@@ -0,0 +1,37 @@ ++ ++picocom ++ ++by Nick Patavalis (npat@efault.net) ++ ++As its name suggests, [picocom] is a minimal dumb-terminal emulation ++program. It is, in principle, very much like minicom, only it's "pico" ++instead of "mini"! It was designed to serve as a simple, manual, modem ++configuration, testing, and debugging tool. It has also served (quite ++well) as a low-tech "terminal-window" to allow operator intervention ++in PPP connection scripts (something like the ms-windows "open ++terminal window before / after dialing" feature). It could also prove ++useful in many other similar tasks. It is ideal for embedded systems ++since its memory footprint is minimal (less than 20K, when ++stripped). Apart from being a handy little tool, [picocom] source ++distribution includes a simple, easy to use, and thoroughly documented ++terminal-management library, which could serve other projects as ++well. This library hides the termios(3) calls, and provides a less ++complex and safer (though certainly less feature-rich) ++interface. [picocom] runs on Linux, and with minor modifications it ++could run on any Unix system with the termios(3) library. ++ ++For a description of picocom's operation, its command line options, ++and usage examples, see the manual page included in the source ++distribution as "picocom.8", and also html-ized as "picocom.8.html". ++ ++People who have contibuted to picocom, by offering feature ++implementations, bug-fixes, corrections, and suggestions are listed in ++the "CONTRIBUTORS" file. ++ ++The latest version of "picocom" can be downloaded from: ++ ++ http://efault.net/npat/hacks/picocom/ ++ ++Please feel free to send comments, requests for new features (no ++promisses, though!), bug-fixes and rants, to the author's email ++address shown at the top of this file. +Index: user/blkfin-apps/picocom/term.h +=================================================================== +--- user/blkfin-apps/picocom/term.h (revision 0) ++++ user/blkfin-apps/picocom/term.h (revision 0) +@@ -0,0 +1,543 @@ ++/* vi: set sw=4 ts=4: ++ * ++ * term.h ++ * ++ * Simple terminal management library. Wraps termios(3), and ++ * simplifies the logistics required for the reliable management and ++ * control of terminals. ++ * ++ * Principles of operation: ++ * ++ * After the library is initialized one or more file-descriptors, can ++ * be added to (and latter removed from) the list managed by the ++ * library (framework). These file descriptos must be opened on ++ * terminal devices. For every fd, the original settings of the ++ * associated terminal device are saved by the library. These settings ++ * are restored when the fd is removed from the framework, or at ++ * porgram termination [by means of an atexit(3) handler installed by ++ * the library], or at user request. The library maintains three ++ * structures for every fd in the framework: The original settings ++ * structure ("origtermios"), keeping the setings of the terminal ++ * device when the respective filedes was added to the framework. The ++ * current settings structure ("currtermios"), keeping the current ++ * setings of the associated terminal device; and the next settings ++ * structure ("nexttermios") which keeps settings to be applied to the ++ * associated terminal device at a latter time, upon user request. ++ * The "term_set_*" functions can be used to modify the device ++ * settings stored in the nexttermios structure. Using functions ++ * provided by the library the user can: Apply the nexttermios ++ * settings to the device. Revert all changes made on nexttermios by ++ * copying the currtermios structure to nexttermios. Reset the device, ++ * by configuring it to the original settings, and copying origtermios ++ * to currtermios and nexttermios. Refresh the device by rereading the ++ * current settings from it and updating currtermios (to catch up with ++ * changes made to the device by means outside of this framework). ++ * ++ * Interface summary: ++ * ++ * F term_lib_init - library initialization ++ * F term_add - add a filedes to the framework ++ * F term_remove - remove a filedes from the framework ++ * F term_erase - remove a filedes from the framework without reset ++ * F term_replace - replace a fd w/o affecting the settings stuctures ++ * F term_reset - revert a device to the settings in "origtermios" ++ * F term_apply - configure a device to the settings in "nexttermios" ++ * F term_revert - discard "nexttermios" by copying-over "currtermios" ++ * F term_refresh - update "currtermios" from the device ++ * F term_set_raw - set "nexttermios" to raw mode ++ * F term_set_baudrate - set the baudrate in "nexttermios" ++ * F term_set_parity - set the parity mode in "nexttermios" ++ * F term_set_databits - set the databits in "nexttermios" ++ * F term_set_flowcntrl - set the flowcntl mode in "nexttermios" ++ * F term_set_hupcl - enable or disable hupcl in "nexttermios" ++ * F term_set_local - set "nexttermios" to local or non-local mode ++ * F term_set - set all params of "nexttermios" in a single stroke ++ * F term_pulse_dtr - pulse the DTR line a device ++ * F term_lower_dtr - lower the DTR line of a device ++ * F term_raise_dtr - raise the DTR line of a device ++ * F term_drain - drain the output from the terminal buffer ++ * F term_flush - discard terminal input and output queue contents ++ * F term_break - generate a break condition on a device ++ * F term_strerror - return a string describing current error condition ++ * F term_perror - print a string describing the current error condition ++ * G term_errno - current error condition of the library ++ * E term_errno_e - error condition codes ++ * E parity_t - library supported parity types ++ * E flocntrl_t - library supported folw-control modes ++ * M MAX_TERM - maximum number of fds that can be managed ++ * ++ * by Nick Patavalis (npat@inaccessnetworks.com) ++ * ++ * originaly by Pantelis Antoniou (panto@intranet.gr), Nick Patavalis ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License as ++ * published by the Free Software Foundation; either version 2 of the ++ * License, or (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, but ++ * WITHOUT 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 ++ * ++ * $Id: term.h,v 1.1 2003/05/07 18:00:05 npat Exp $ ++ */ ++ ++ ++#ifndef TERM_H ++#define TERM_H ++ ++/* M MAX_TERMS ++ * ++ * Maximum nuber of terminals that can be managed by the library. Keep ++ * relatively low, since linear searches are used. Reasonable values ++ * would be: 16, 32, 64, etc. ++ */ ++#define MAX_TERMS 16 ++ ++/* ++ * E term_errno_e ++ * ++ * Library error-condition codes. These marked with "see errno" ++ * correspond to system errors, so it makes sense to also check the ++ * system's error-condition code (errno) in order to fully determine ++ * what went wrong. ++ * ++ * See the error strings in "term.c" for a description of each. ++ */ ++enum term_errno_e { ++ TERM_EOK = 0, ++ TERM_ENOINIT, ++ TERM_EFULL, ++ TERM_ENOTFOUND, ++ TERM_EEXISTS, ++ TERM_EATEXIT, ++ TERM_EISATTY, ++ TERM_EFLUSH, /* see errno */ ++ TERM_EGETATTR, /* see errno */ ++ TERM_ESETATTR, /* see errno */ ++ TERM_EBAUD, ++ TERM_ESETOSPEED, ++ TERM_ESETISPEED, ++ TERM_EPARITY, ++ TERM_EDATABITS, ++ TERM_EFLOW, ++ TERM_EDTRDOWN, ++ TERM_EDTRUP, ++ TERM_EDRAIN, /* see errno */ ++ TERM_EBREAK ++}; ++ ++/* E parity_e ++ * ++ * Parity modes supported by the library: ++ * ++ * P_NONE - no patiry ++ * P_EVEN - even parity ++ * P_ODD - odd parity ++ */ ++enum parity_e { ++ P_NONE, ++ P_EVEN, ++ P_ODD ++}; ++ ++/* ++ * E flowcntrl_e ++ * ++ * Flow control modes, supported by the library. ++ * ++ * FC_NONE - no flow control ++ * FC_RTSCTS - RTS/CTS handshaking, also known as hardware ++ * flow-control. ++ * FC_XONXOFF - xon/xoff flow control. ++ */ ++enum flowcntrl_e { ++ FC_NONE, ++ FC_RTSCTS, ++ FC_XONXOFF ++}; ++ ++/***************************************************************************/ ++ ++/* ++ * G term_errno ++ * ++ * Keeps the current library error-condtion code ++ */ ++extern int term_errno; ++ ++/***************************************************************************/ ++ ++/* ++ * F term_strerror ++ * ++ * Return a string descibing the current library error condition. If ++ * the error condition reflects a system error, then the respective ++ * system-error description is appended at the end of the returned ++ * string. The returned string points to a statically allocated buffer ++ * that is overwritten with every call to term_strerror() ++ * ++ * Returns a string describing the current library (and possibly ++ * system) error condition. ++ */ ++const char *term_strerror (int terrnum, int errnum); ++ ++/* ++ * F term_perror ++ * ++ * Emit a description of the current library (and possibly system) ++ * error condition to the standard-error stream. The description is ++ * prefixed by a user-supplied string. What is actually emmited is: ++ * ++ * \n ++ * ++ * The description emitted is the string returned by term_strerror(). ++ * ++ * Returns the number of characters emmited to the standard-error ++ * stream or a neagative on failure. ++ */ ++int term_perror (const char *prefix); ++ ++/* F term_lib_init ++ * ++ * Initialize the library ++ * ++ * Initialize the library. This function must be called before any ++ * attemt to use the library. If this function is called and the ++ * library is already initialized, all terminals associated with the ++ * file-descriptors in the framework will be reset to their original ++ * settings, and the file-descriptors will be removed from the ++ * framework. An atexit(3) handler is installed by the library which ++ * resets and removes all managed terminals. ++ * ++ * Returns negative on failure, non-negative on success. This function ++ * will only fail if the atexit(3) handler cannot be ++ * installed. Failure to reset a terminal to the original settings is ++ * not considered an error. ++ */ ++int term_lib_init (void); ++ ++/* F term_add ++ * ++ * Add the filedes "fd" to the framework. The filedes must be opened ++ * on a terminal device or else the addition will fail. The settings ++ * of the terminal device associated with the filedes are read and ++ * stored in the origtermios structure. ++ * ++ * Returns negative on failure, non-negative on success. ++ */ ++int term_add (int fd); ++ ++/* F term_remove ++ * ++ * Remove the filedes "fd" from the framework. The device associated ++ * with the filedes is reset to its original settings (those it had ++ * when it was added to the framework) ++ * ++ * Return negative on failure, non-negative on success. The filedes is ++ * always removed form the framework even if this function returns ++ * failure, indicating that the device reset failed. ++ */ ++int term_remove (int fd); ++ ++/* F term_erase ++ * ++ * Remove the filedes "fd" from the framework. The device associated ++ * with the filedes is *not* reset to its original settings. ++ * ++ * Return negative on failure, non-negative on success. The only ++ * reason for failure is the filedes not to be found. ++ */ ++int term_erase (int fd); ++ ++/* F term_replace ++ * ++ * Replace a managed filedes without affecting the associated settings ++ * structures. The "newfd" takes the place of "oldfd". "oldfd" is ++ * removed from the framework without the associated device beign ++ * reset (it is most-likely no longer connected to a device anyway, ++ * and reset would fail). The device associated with "newfd" is ++ * configured with "oldfd"s current settings. ++ * ++ * Returns negative on failure, non-negative on success. In case of ++ * failure "oldfd" is not removed from the framework, and no ++ * replacement takes place. ++ * ++ * The usual reason to replace the filedes of a managed terminal is ++ * because the device was closed and re-opened. This function gives ++ * you a way to do transparent "open"s and "close"s: Before you close ++ * a device, it has certain settings managed by the library. When you ++ * close it and then re-open it many of these settings are lost, since ++ * the device reverts to system-default settings. By calling movefd, ++ * you conceptually _maintain_ the old (pre-close) settings to the new ++ * (post-open) filedes. ++ */ ++int term_replace (int oldfd, int newfd); ++ ++/* ++ * F term_apply ++ * ++ * Applies the settings stored in the nexttermios structure associated ++ * with the managed filedes "fd", to the respective terminal device. ++ * It then copies nexttermios to currtermios. ++ * ++ * Returns negative on failure, non negative on success. In case of ++ * failure the currtermios structure is not affected. ++ */ ++int term_apply (int fd); ++ ++/* ++ * F term_revert ++ * ++ * Discards all the changes made to the nexttermios structure ++ * associated with the managed filedes "fd" that have not been applied ++ * to the device. It does this by copying currtermios to nexttermios. ++ * ++ * Returns negative on failure, non negative on success. Returns ++ * failure only to indicate invalid arguments, so the return value can ++ * be safely ignored. ++ */ ++int term_revert (int fd); ++ ++/* F term_reset ++ * ++ * Reset the terminal device associated with the managed filedes "fd" ++ * to its "original" settings. This function applies the settings in ++ * the "origtermios" structure to the actual device. It also discards ++ * the settings in the "currtermios" and "nexttermios" stuctures by ++ * making them equal to "origtermios". ++ * ++ * Returns negative on failure, non-negative of success. On failure ++ * the the "origtermios", "currtermios", and "nexttermios" stuctures ++ * associated with the filedes remain unaffected. ++ */ ++int term_reset (int fd); ++ ++/* ++ * F term_refresh ++ * ++ * Updates the contents of the currtermios structure associated with ++ * the managed filedes "fd", by reading the settings from the ++ * respective terminal device. ++ * ++ * Returns negative on failure, non negative on success. On failure ++ * the currtermios structure remains unaffected. ++ */ ++int term_refresh (int fd); ++ ++/* F term_set_raw ++ * ++ * Sets the "nexttermios" structure associated with the managed ++ * filedes "fd" to raw mode. The effective settings of the device are ++ * not affected by this function. ++ * ++ * Returns negative on failure, non-negative on success. Returns ++ * failure only to indicate invalid arguments, so the return value can ++ * be safely ignored. ++ * ++ * When in raw mode, no characters are processed by the terminal ++ * driver and there is no line-discipline or buffering. More ++ * technically setting to raw mode means, affecting the following ++ * terminal settings as indicated: ++ * ++ * -ignbrk -brkint -parmrk -istrip -inlcr -igncr -icrnl -ixon ++ * -opost -echo -echonl -icannon -isig -iexten -csize -parenb ++ * cs8 min=1 time=0 ++ */ ++int term_set_raw (int fd); ++ ++/* F term_set_baudrate ++ * ++ * Sets the baudrate in the "nexttermios" structure associated with ++ * the managed filedes "fd" to "baudrate". The effective settings of ++ * the device are not affected by this function. ++ * ++ * Supported baudrates: 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, ++ * 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400 ++ * ++ * Returns negative on failure, non negative on success. Returns ++ * failure only to indicate invalid arguments, so the return value can ++ * be safely ignored. ++ */ ++int term_set_baudrate (int fd, int baudrate); ++ ++/* F term_set_parity ++ * ++ * Sets the parity mode in the "nexttermios" structure associated with ++ * the managed filedes "fd" to "parity". The effective settings of the ++ * device are not affected by this function. ++ * ++ * Supported parity modes are: p_even, p_odd, p_none. ++ * ++ * Returns negative on failure, non negative on success. Returns ++ * failure only to indicate invalid arguments, so the return value can ++ * be safely ignored. ++ */ ++int term_set_parity (int fd, enum parity_e parity); ++ ++/* F term_set_databits ++ * ++ * Sets the databits number in the "nexttermios" structure associated ++ * with the managed filedes "fd" to "databits". The effective settings ++ * of the device are not affected by this function. ++ * ++ * 5, 6, 7, and 8 databits are supported by the library. ++ * ++ * Returns negative on failure, non negative on success. Returns ++ * failure only to indicate invalid arguments, so the return value can ++ * be safely ignored. ++ */ ++int term_set_databits (int fd, int databits); ++ ++/* F term_set_flowcntrl ++ * ++ * Sets the folwcontrol mode in the "nexttermios" structure associated ++ * with the managed filedes "fd" to "flowcntl". The effective settings ++ * of the device are not affected by this function. ++ * ++ * The following flow control modes are supportd by the library: ++ * FC_NONE, FC_RTSCTS, FC_XONXOFF. ++ * ++ * Returns negative on failure, non negative on success. Returns ++ * failure only to indicate invalid arguments, so the return value can ++ * be safely ignored. ++ */ ++int term_set_flowcntrl (int fd, enum flowcntrl_e flowcntl); ++ ++/* F term_set_hupcl ++ * ++ * Enables ("on" = nonzero) or disables ("on" = zero) the ++ * "HUP-on-close" setting in the "nexttermios" structure associated ++ * with the managed filedes "fd". The effective settings of the device ++ * are not affected by this function. ++ * ++ * Returns negative on failure, non negative on success. Returns ++ * failure only to indicate invalid arguments, so the return value can ++ * be safely ignored. ++ */ ++int term_set_hupcl (int fd, int on); ++ ++/* F term_set_local. ++ * ++ * Enables ("local" = nonzero) or disables ("local" = zero) the ++ * "local-mode" setting in the "nexttermios" structure associated with ++ * the managed filedes "fd". The effective settings of the device are ++ * not affected by this function. ++ * ++ * Returns negative on failure, non negative on success. Returns ++ * failure only to indicate invalid arguments, so the return value can ++ * be safely ignored. ++ */ ++int term_set_local (int fd, int local); ++ ++/* F temr_set ++ * ++ * Sets most of the parameters in the "nexttermios" structure ++ * associated with the managed filedes "fd". Actually sets the ++ * following: ++ * ++ * Raw mode if "raw" is nonzero. ++ * Baudrate to "baud". ++ * Parity mode to "parity". ++ * Flow control mode to "fc". ++ * Enables local mode if "local" is nonzero, dis. otherwise. ++ * Enables HUP-on-close if "hupcl" is nonzero, dis. otherwise ++ * ++ * The effective settings of the device are not affected by this ++ * function. Additionally if the filedes "fd" is not managed, it is ++ * added to the framework. ++ * ++ * Returns negative on failure, non negative on success. On failure ++ * none of the settings of "nexttermios" is affected. *If* the filedes ++ * "fd" is already in the framework, then the function returns failure ++ * only to indicate invalid arguments, so, in this case, the return ++ * value can be safely ignored. If the function successfully adds the ++ * filedes to the framework, and following this it fails, then it will ++ * remove the filedes before returning. ++ */ ++int term_set (int fd, ++ int raw, ++ int baud, ++ enum parity_e parity, int bits, enum flowcntrl_e fc, ++ int local, int hupcl); ++ ++/* F term_pulse_dtr ++ * ++ * Pulses the DTR line of the device associated with the managed ++ * filedes "fd". The DTR line is lowered for 1sec and then raised ++ * again. ++ * ++ * Returns negative on failure, non negative on success. ++ */ ++int term_pulse_dtr (int fd); ++ ++/* F term_lower_dtr ++ * ++ * Lowers the DTR line of the device associated with the managed ++ * filedes "fd". ++ * ++ * Returns negative on failure, non negative on success. ++ */ ++int term_lower_dtr (int fd); ++ ++/* F term_raise_dtr ++ * ++ * Raises the DTR line of the device associated with the managed ++ * filedes "fd". ++ * ++ * Returns negative on failure, non negative on success. ++ */ ++int term_raise_dtr (int fd); ++ ++/* F term_drain ++ * ++ * Drains (flushes) the output queue of the device associated with the ++ * managed filedes "fd". This functions blocks until all the contents ++ * of output queue have been transmited. ++ * ++ * Returns negative on failure, non negative on success. ++ */ ++int term_drain (int fd); ++ ++/* F term_flush ++ * ++ * Discards all the contents of the input AND output queues of the ++ * device associated with the managed filedes "fd". Although it is ++ * called flush this functions does NOT FLUSHES the terminal ++ * queues. It just DISCARDS their contents. The name has stuck from ++ * the POSIX terminal call: "tcflush". ++ * ++ * Returns negative on failure, non negative on success. ++ */ ++int term_flush (int fd); ++ ++/* F term_break ++ * ++ * This function generates a break condition on the device associated ++ * with the managed filedes "fd", by transmiting a stream of ++ * zero-bits. The stream of zero-bits has a duriation typically ++ * between 0.25 and 0.5 seconds. ++ * ++ * Returns negative on failure, non negative on success. ++ */ ++int term_break(int fd); ++ ++/***************************************************************************/ ++ ++#endif /* of TERM_H */ ++ ++/***************************************************************************/ ++ ++/* ++ * Local Variables: ++ * mode:c ++ * tab-width: 4 ++ * c-basic-offset: 4 ++ * End: ++ */ +Index: user/blkfin-apps/picocom/picocom.8.xml +=================================================================== +--- user/blkfin-apps/picocom/picocom.8.xml (revision 0) ++++ user/blkfin-apps/picocom/picocom.8.xml (revision 0) +@@ -0,0 +1,403 @@ ++ ++ ++ ++ ++ ++ ++ ++ picocom [ options ] device ++ ++ ++ ++ ++ ++

++ As its name suggests, picocom is a minimal ++ dumb-terminal emulation program. It is, in principle, very much ++ like , only it's "pico" ++ instead of "mini"! It was designed to serve as a simple, manual, ++ modem configuration, testing, and debugging tool. It has also ++ served (quite well) as a low-tech "terminal-window" to allow ++ operator intervention in PPP connection scripts (something like ++ the ms-windows "open terminal window before / after dialing" ++ feature). It could also prove useful in many other similar ++ tasks. ++

++ ++

++ When picocom starts it opens the terminal (serial ++ device) given as its non-option argument. Unless the ++ --noinit option is given, it configures the device to ++ the settings specified by the option-arguments (or to some ++ default settings), and sets it to "raw" mode. If ++ --noinit is given, the initialization and ++ configuration is skipped; the device is just opened. Following ++ this, picocom sets the standard-input and ++ standard-output to raw mode. Having done so, it goes in a loop ++ where it listens for input from stdin, or from the serial ++ port. Input from the serial port is copied to the standard ++ output while input from the standard input is copied to the ++ serial port. picocom also scans its input stream for ++ a user-specified control character, called the "escape ++ character" (being by default "C-a"). If the escape character is ++ seen, then instead of sending it to the serial-device, the ++ program enters "command mode" and waits for the next character ++ (which is called the "function character"). Depending on the ++ value of the function character, picocom performs one ++ of the operations described in the "Commands" section below. ++

++
++ ++
++ ++

++ Commands are given to picocom by first keying the ++ "espace character" which by default is "C-a" (see "Options" ++ below on how to change it), and then keying one for the function ++ (command) characters shown here. ++

++ ++
++
[escape character]
++
++

++ Send the escape character to the serial port and return to ++ "transparent" mode. This means that if the escape character ++ ("C-a", by default) is typed twice, the program sends the ++ escape character to the serial port, and remains in ++ transparent mode. This is a new behavior implemented in ++ v1.4. Previously picocom used to ignore the escape-character ++ when it was entered as a function character. ++

++
++ ++
C-x
++
++

++ Exit the program: if the "--noreset" option was not given ++ then the serial port is reset to its original settings ++ before exiting; if it was given the serial port is not ++ reset. ++

++
++ ++
C-q
++
++

++ Quit the program *without* reseting the serial port, ++ regardless of the "--noreset" option. ++

++
++ ++
C-p
++
++

++ Pulse the DTR line. Lower it for 1 sec, and then raise it ++ again. ++

++
++ ++
C-t
++
++

++ Toggle the DTR line. If DTR is up, then lower it. If it is ++ down, then raise it. ++

++
++ ++
C-\e
++
++

++ Generate a break sequence on the serial line. A break ++ sequence is usually generated by marking (driving to logical ++ one) the serial Tx line for an amount of time coresponding ++ to several character durations. ++

++
++ ++
C-u
++
++

++ Baud up. Increase the baud-rate. The list of baud-rates ++ stepped-through by this command is: 300, 600, 1200, 2400, ++ 4800, 9600, 19200, 38400, 57600, 115200. ++

++
++ ++
C-d
++
++

++ Baud down. Decrease the baud-rate. The list of baud-rates ++ stepped-through by this command is the same as for the ++ "baud-up" command. ++

++
++ ++
C-f
++
++

++ Cycle through flow-control settings (RTS/CTS, XON/XOFF, none). ++

++
++ ++
C-y
++
++

++ Cycle through parity settings (even, odd, none). ++

++
++ ++
C-b
++
++

++ Cycle through databits-number settings (5, 6, 7, 8). ++

++
++ ++
C-v
++
++

++ Show program options (like baud rate, data bits, etc). Only ++ the options that can be modified online (through commands) ++ are shown, not those that can only be set at the ++ command-line. ++

++
++ ++
C-s
++
++

++ Send (upload) a file (see "Sending and Receiving Files" ++ below) ++

++
++ ++
C-r
++
++

++ Receive (download) a file (see "Sending and Receiving Files" ++ below) ++

++
++
++ ++

++ After performing one of the above operations the program leaves ++ the command mode and enters transparent mode. Example: To ++ increase the baud-rate by two steps, you have to type: ++

++

++ C-a, C-u, C-a, C-u ++

++

++ assuming of-course that "C-a" is the escape character. ++

++
++ ++
++

++ picocom can send and receive files over the serial ++ port using external programs that implement the respective ++ protocols. In Linux typical programs for this purpose are: ++

++ ++
    ++
  • ++ - receive using the X-MODEM protocol

  • ++
  • ++ - receive using the Y-MODEM protocol

  • ++
  • ++ - receive using the Z-MODEM protocol

  • ++
  • ++ - send using the X-MODEM protocol

  • ++
  • ++ - send using the Y-MODEM protocol

  • ++
  • ++ - send using the Z-MODEM protocol

  • ++
  • ++ - receive or transmit ASCII files

  • ++
++ ++

++ The name of, and the command-line options to, the program to be ++ used for transmitting files are given by the "--send-cmd" ++ option. Similarly the program to receive files, and its ++ argumets, are given by the "--receive-cmd" option. For example, ++ in order to start a picocom session that uses "sz" to ++ transmit files, and "rz" to receive, you have to say something ++ like this: ++

++ ++

++ picocom --send-cmd "sz -vv" --receive-cmd "rz -vv" ++

++ ++

++ During the picocom session, if you key the "send" or "receive" ++ commands (e.g. by pressing C-a, C-s, or C-a, C-r) you will be ++ prompted for a filename. At this prompt you can enter one or ++ more file-names, and any additional arguments to the ++ transmission or reception program. After that, picocom will ++ start the the external program as specified by the "--send-cmd", ++ or "--receive-cmd" option, and with any filenames and additional ++ arguments you may have supplied. The standard input and output ++ of the external program will be connected to the serial ++ port. The standard error of the external program will be ++ connected to the terminal which---while the program is ++ running---will revert to canonical mode. Pressing 'C-c' while ++ the external program is running will prematurely terminate it, ++ and return control to picocom. Pressing 'C-c' at any other ++ time, has no special effect; the character is normally passed to ++ the serial port. ++

++ ++
++ ++
++

++ picocom accepts the following command-line options ++

++ ++
++
--baud | -b
++
++

++ Defines the baud-rate to set the serial-port (terminal) to. ++

++
++ ++
--flow | -f
++
++

++ Defines the flow-control mode to set the serial-port to. Must be ++ one of: ++

++
    ++
  • \'x' for xon/xoff (software) mode

  • ++
  • \'h' for hardware flow control (RTS/CTS)

  • ++
  • \'n' for no flow control

  • ++
++

(Default: 'n')

++
++ ++
--parity | -p
++
++

++ Defines the parity mode to set the serial-port to. ++ Must be one of: ++

++
    ++
  • \'o' for odd parity mode.

  • ++
  • \'e' for even parity mode.

  • ++
  • \'n' for no parity, mode.

  • ++
++

(Default: 'n')

++
++ ++
--databits | -d
++
++

++ Defines the number of data bits in every character. Must be one of: ++ 5, 6, 7, 8 ++

++

(Default: 8)

++
++ ++
--esacpe | -e
++
++

++ Defines the character that will make picocom enter command-mode ++ (see description above). If 'x' is given, then C-x will ++ make picocom enter command mode. ++

++

++ (Default: 'a') ++

++
++ ++
--noinit | -i
++
++

++ If given, picocom will not initialize, reset, or ++ otherwise meddle with the serial port at start-up. It will ++ just open it. This is useful, for example, for connecting ++ picocom to already-connected modems, or already ++ configured ports without terminating the connection, or ++ altering the settings. If required serial port parameters ++ can then be adjusted at run-time by commands. ++

++
++ ++
--noreset | -r
++
++

++ If given, picocom will not *reset* the serial ++ port when exiting. It will just close the filedes and do ++ nothing more. This is useful, for example, for leaving ++ modems connected when exiting picocom. Regardless ++ whether the "--noreset" option is given the user can exit ++ picocom using the "Quit" command (instead of ++ "Exit"), which never resets the serial port. If "--noreset" ++ is given then "Quit" and "Exit" behave essentially the same. ++

++
++ ++
--nolock | -l
++
++

++ If given, picocom will *not* attempt to lock the ++ serial port before opening it. Normally picocom attempts to ++ get a UUCP-style lock-file (e.g. "/var/lock/LCK..ttyS0") ++ before opening the port. Failing to do so, results in the ++ program exiting after emitting an error-message. It is ++ possible that your picocom binary is compiled without this ++ option. ++

++
++ ++
--send-cmd | -s
++
++

++ Specifies the external program (and any arguments to it) ++ that will be used for transmitting files. ++

++

++ Default: "sz -vv" ++

++
++ ++
--receive-cmd | -v
++
++

++ Specifies the external program (and any arguments to it) ++ that will be used for receiving files. ++

++

++ (Default: "rz -vv") ++

++
++ ++
--help | -h
++
++

++ Print a short help message describing the command-line ++ options. ++

++
++
++
++ ++
++

picocom was written by Nick Patavalis (npat@efault.net)

++
++ ++
++

The latest version of "picocom" can be downloaded from: ++

++
++ ++
+\ No newline at end of file +Index: user/blkfin-apps/picocom/picocom.8 +=================================================================== +--- user/blkfin-apps/picocom/picocom.8 (revision 0) ++++ user/blkfin-apps/picocom/picocom.8 (revision 0) +@@ -0,0 +1,214 @@ ++.TH "picocom" "8" "" "" "" ++.SH NAME ++picocom \- minimal dumb-terminal emulation program ++.SH SYNOPSIS ++.B picocom [ ++.I options ++.B ] ++.I device ++.br ++.SH DESCRIPTION ++As its name suggests, ++.B picocom ++is a minimal dumb-terminal emulation program. It is, in principle, very much like ++.B minicom(1) ++, only it's "pico" instead of "mini"! It was designed to serve as a simple, manual, modem configuration, testing, and debugging tool. It has also served (quite well) as a low-tech "terminal-window" to allow operator intervention in PPP connection scripts (something like the ms-windows "open terminal window before / after dialing" feature). It could also prove useful in many other similar tasks. ++.br ++.sp 0.6v ++When ++.B picocom ++starts it opens the terminal (serial device) given as its non-option argument. Unless the ++.I --noinit ++option is given, it configures the device to the settings specified by the option-arguments (or to some default settings), and sets it to "raw" mode. If ++.I --noinit ++is given, the initialization and configuration is skipped; the device is just opened. Following this, ++.B picocom ++sets the standard-input and standard-output to raw mode. Having done so, it goes in a loop where it listens for input from stdin, or from the serial port. Input from the serial port is copied to the standard output while input from the standard input is copied to the serial port. ++.B picocom ++also scans its input stream for a user-specified control character, called the "escape character" (being by default "C-a"). If the escape character is seen, then instead of sending it to the serial-device, the program enters "command mode" and waits for the next character (which is called the "function character"). Depending on the value of the function character, ++.B picocom ++performs one of the operations described in the "Commands" section below. ++.br ++.sp 0.6v ++.SH COMMANDS ++Commands are given to ++.B picocom ++by first keying the "espace character" which by default is "C-a" (see "Options" below on how to change it), and then keying one for the function (command) characters shown here. ++.TP 3 ++.B [escape character] ++Send the escape character to the serial port and return to "transparent" mode. This means that if the escape character ("C-a", by default) is typed twice, the program sends the escape character to the serial port, and remains in transparent mode. This is a new behavior implemented in v1.4. Previously picocom used to ignore the escape-character when it was entered as a function character. ++.TP 3 ++.B C-x ++Exit the program: if the "--noreset" option was not given then the serial port is reset to its original settings before exiting; if it was given the serial port is not reset. ++.TP 3 ++.B C-q ++Quit the program *without* reseting the serial port, regardless of the "--noreset" option. ++.TP 3 ++.B C-p ++Pulse the DTR line. Lower it for 1 sec, and then raise it again. ++.TP 3 ++.B C-t ++Toggle the DTR line. If DTR is up, then lower it. If it is down, then raise it. ++.TP 3 ++.B C-\e ++Generate a break sequence on the serial line. A break sequence is usually generated by marking (driving to logical one) the serial Tx line for an amount of time coresponding to several character durations. ++.TP 3 ++.B C-u ++Baud up. Increase the baud-rate. The list of baud-rates stepped-through by this command is: 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200. ++.TP 3 ++.B C-d ++Baud down. Decrease the baud-rate. The list of baud-rates stepped-through by this command is the same as for the "baud-up" command. ++.TP 3 ++.B C-f ++Cycle through flow-control settings (RTS/CTS, XON/XOFF, none). ++.TP 3 ++.B C-y ++Cycle through parity settings (even, odd, none). ++.TP 3 ++.B C-b ++Cycle through databits-number settings (5, 6, 7, 8). ++.TP 3 ++.B C-v ++Show program options (like baud rate, data bits, etc). Only the options that can be modified online (through commands) are shown, not those that can only be set at the command-line. ++.TP 3 ++.B C-s ++Send (upload) a file (see "Sending and Receiving Files" below) ++.TP 3 ++.B C-r ++Receive (download) a file (see "Sending and Receiving Files" below) ++.PP ++After performing one of the above operations the program leaves the command mode and enters transparent mode. Example: To increase the baud-rate by two steps, you have to type: ++.br ++.sp 0.6v ++C-a, C-u, C-a, C-u ++.br ++.sp 0.6v ++assuming of-course that "C-a" is the escape character. ++.br ++.sp 0.6v ++.SH SENDING AND RECEIVING FILES ++.B picocom ++can send and receive files over the serial port using external programs that implement the respective protocols. In Linux typical programs for this purpose are: ++.IP \(em 3 ++.B rx(1) ++- receive using the X-MODEM protocol ++.IP \(em 3 ++.B rb(1) ++- receive using the Y-MODEM protocol ++.IP \(em 3 ++.B rz(1) ++- receive using the Z-MODEM protocol ++.IP \(em 3 ++.B sx(1) ++- send using the X-MODEM protocol ++.IP \(em 3 ++.B sb(1) ++- send using the Y-MODEM protocol ++.IP \(em 3 ++.B sz(1) ++- send using the Z-MODEM protocol ++.IP \(em 3 ++.B ascii-xfr(1) ++- receive or transmit ASCII files ++.PP ++The name of, and the command-line options to, the program to be used for transmitting files are given by the "--send-cmd" option. Similarly the program to receive files, and its argumets, are given by the "--receive-cmd" option. For example, in order to start a ++.B picocom ++session that uses "sz" to transmit files, and "rz" to receive, you have to say something like this: ++.br ++.sp 0.6v ++picocom --send-cmd "sz -vv" --receive-cmd "rz -vv" ++.br ++.sp 0.6v ++During the picocom session, if you key the "send" or "receive" commands (e.g. by pressing C-a, C-s, or C-a, C-r) you will be prompted for a filename. At this prompt you can enter one or more file-names, and any additional arguments to the transmission or reception program. After that, picocom will start the the external program as specified by the "--send-cmd", or "--receive-cmd" option, and with any filenames and additional arguments you may have supplied. The standard input and output of the external program will be connected to the serial port. The standard error of the external program will be connected to the terminal which---while the program is running---will revert to canonical mode. Pressing 'C-c' while the external program is running will prematurely terminate it, and return control to ++.B picocom ++. Pressing 'C-c' at any other time, has no special effect; the character is normally passed to the serial port. ++.br ++.sp 0.6v ++.SH OPTIONS ++.B picocom ++accepts the following command-line options ++.TP 3 ++.B --baud | -b ++Defines the baud-rate to set the serial-port (terminal) to. ++.TP 3 ++.B --flow | -f ++Defines the flow-control mode to set the serial-port to. Must be one of: ++.RS 3 ++.IP \(em 3 ++\'x' for xon/xoff (software) mode ++.IP \(em 3 ++\'h' for hardware flow control (RTS/CTS) ++.IP \(em 3 ++\'n' for no flow control ++.PP ++(Default: 'n') ++.RE ++.TP 3 ++.B --parity | -p ++Defines the parity mode to set the serial-port to. Must be one of: ++.RS 3 ++.IP \(em 3 ++\'o' for odd parity mode. ++.IP \(em 3 ++\'e' for even parity mode. ++.IP \(em 3 ++\'n' for no parity, mode. ++.PP ++(Default: 'n') ++.RE ++.TP 3 ++.B --databits | -d ++Defines the number of data bits in every character. Must be one of: 5, 6, 7, 8 ++.br ++.sp 0.6v ++(Default: 8) ++.TP 3 ++.B --esacpe | -e ++Defines the character that will make picocom enter command-mode (see description above). If 'x' is given, then C-x will make picocom enter command mode. ++.br ++.sp 0.6v ++(Default: 'a') ++.TP 3 ++.B --noinit | -i ++If given, ++.B picocom ++will not initialize, reset, or otherwise meddle with the serial port at start-up. It will just open it. This is useful, for example, for connecting ++.B picocom ++to already-connected modems, or already configured ports without terminating the connection, or altering the settings. If required serial port parameters can then be adjusted at run-time by commands. ++.TP 3 ++.B --noreset | -r ++If given, ++.B picocom ++will not *reset* the serial port when exiting. It will just close the filedes and do nothing more. This is useful, for example, for leaving modems connected when exiting ++.B picocom ++. Regardless whether the "--noreset" option is given the user can exit ++.B picocom ++using the "Quit" command (instead of "Exit"), which never resets the serial port. If "--noreset" is given then "Quit" and "Exit" behave essentially the same. ++.TP 3 ++.B --nolock | -l ++If given, ++.B picocom ++will *not* attempt to lock the serial port before opening it. Normally picocom attempts to get a UUCP-style lock-file (e.g. "/var/lock/LCK..ttyS0") before opening the port. Failing to do so, results in the program exiting after emitting an error-message. It is possible that your picocom binary is compiled without this option. ++.TP 3 ++.B --send-cmd | -s ++Specifies the external program (and any arguments to it) that will be used for transmitting files. ++.br ++.sp 0.6v ++Default: "sz -vv" ++.TP 3 ++.B --receive-cmd | -v ++Specifies the external program (and any arguments to it) that will be used for receiving files. ++.br ++.sp 0.6v ++(Default: "rz -vv") ++.TP 3 ++.B --help | -h ++Print a short help message describing the command-line options. ++.PP ++.SH AUTHOR ++picocom was written by Nick Patavalis (npat@efault.net) ++.br ++.sp 0.6v ++.SH AVAILABILITY ++The latest version of "picocom" can be downloaded from: ++.B http://efault.net/npat/hacks/picocom/ +Index: user/blkfin-apps/picocom/LICENSE.txt +=================================================================== +--- user/blkfin-apps/picocom/LICENSE.txt (revision 0) ++++ user/blkfin-apps/picocom/LICENSE.txt (revision 0) +@@ -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. ++ ++ ++ Copyright (C) ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 2 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT 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. ++ ++ , 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. +Index: user/blkfin-apps/picocom/picocom.8.html +=================================================================== +--- user/blkfin-apps/picocom/picocom.8.html (revision 0) ++++ user/blkfin-apps/picocom/picocom.8.html (revision 0) +@@ -0,0 +1,495 @@ ++ ++ ++picocom(8) ++ ++ ++ ++ ++
++ ++ ++ ++
picocom(8)picocom(8)
++ ++

NAME

++
++picocom -- minimal dumb-terminal emulation program ++
++ ++

SYNOPSIS

++
++
    ++
  • ++ picocom [ options ] device ++
  • ++
++
++ ++

DESCRIPTION

++
++

++ As its name suggests, picocom is a minimal dumb-terminal ++ emulation program. It is, in principle, very much like ++ minicom(1), only it's "pico" instead of ++ "mini"! It was designed to serve as a simple, manual, modem ++ configuration, testing, and debugging tool. It has also served ++ (quite well) as a low-tech "terminal-window" to allow operator ++ intervention in PPP connection scripts (something like the ++ ms-windows "open terminal window before / after dialing" feature). ++ It could also prove useful in many other similar tasks. ++

++

++ When picocom starts it opens the terminal (serial device) ++ given as its non-option argument. Unless the --noinit ++ option is given, it configures the device to the settings ++ specified by the option-arguments (or to some default settings), ++ and sets it to "raw" mode. If --noinit is given, the ++ initialization and configuration is skipped; the device is just ++ opened. Following this, picocom sets the standard-input and ++ standard-output to raw mode. Having done so, it goes in a loop ++ where it listens for input from stdin, or from the serial port. ++ Input from the serial port is copied to the standard output while ++ input from the standard input is copied to the serial port. picocom ++ also scans its input stream for a user-specified control ++ character, called the "escape character" (being by default "C-a"). ++ If the escape character is seen, then instead of sending it to the ++ serial-device, the program enters "command mode" and waits for the ++ next character (which is called the "function character"). ++ Depending on the value of the function character, picocom ++ performs one of the operations described in the "Commands" section ++ below. ++

++
++ ++

COMMANDS

++
++

++ Commands are given to picocom by first keying the "espace ++ character" which by default is "C-a" (see "Options" below on how ++ to change it), and then keying one for the function (command) ++ characters shown here. ++

++
++
++ [escape character] ++
++
++

++ Send the escape character to the serial port and return to ++ "transparent" mode. This means that if the escape character ++ ("C-a", by default) is typed twice, the program sends the ++ escape character to the serial port, and remains in ++ transparent mode. This is a new behavior implemented in v1.4. ++ Previously picocom used to ignore the escape-character when it ++ was entered as a function character. ++

++
++
++ C-x ++
++
++

++ Exit the program: if the "--noreset" option was not given then ++ the serial port is reset to its original settings before ++ exiting; if it was given the serial port is not reset. ++

++
++
++ C-q ++
++
++

++ Quit the program *without* reseting the serial port, ++ regardless of the "--noreset" option. ++

++
++
++ C-p ++
++
++

++ Pulse the DTR line. Lower it for 1 sec, and then raise it ++ again. ++

++
++
++ C-t ++
++
++

++ Toggle the DTR line. If DTR is up, then lower it. If it is ++ down, then raise it. ++

++
++
++ C-\e ++
++
++

++ Generate a break sequence on the serial line. A break sequence ++ is usually generated by marking (driving to logical one) the ++ serial Tx line for an amount of time coresponding to several ++ character durations. ++

++
++
++ C-u ++
++
++

++ Baud up. Increase the baud-rate. The list of baud-rates ++ stepped-through by this command is: 300, 600, 1200, 2400, ++ 4800, 9600, 19200, 38400, 57600, 115200. ++

++
++
++ C-d ++
++
++

++ Baud down. Decrease the baud-rate. The list of baud-rates ++ stepped-through by this command is the same as for the ++ "baud-up" command. ++

++
++
++ C-f ++
++
++

++ Cycle through flow-control settings (RTS/CTS, XON/XOFF, none). ++

++
++
++ C-y ++
++
++

++ Cycle through parity settings (even, odd, none). ++

++
++
++ C-b ++
++
++

++ Cycle through databits-number settings (5, 6, 7, 8). ++

++
++
++ C-v ++
++
++

++ Show program options (like baud rate, data bits, etc). Only ++ the options that can be modified online (through commands) are ++ shown, not those that can only be set at the command-line. ++

++
++
++ C-s ++
++
++

++ Send (upload) a file (see "Sending and Receiving Files" below) ++

++
++
++ C-r ++
++
++

++ Receive (download) a file (see "Sending and Receiving Files" ++ below) ++

++
++
++

++ After performing one of the above operations the program leaves ++ the command mode and enters transparent mode. Example: To increase ++ the baud-rate by two steps, you have to type: ++

++

++ C-a, C-u, C-a, C-u ++

++

++ assuming of-course that "C-a" is the escape character. ++

++
++ ++

SENDING AND RECEIVING FILES

++
++

++ picocom can send and receive files over the serial port ++ using external programs that implement the respective protocols. ++ In Linux typical programs for this purpose are: ++

++
    ++
  • ++

    ++ rx(1) - receive using the X-MODEM ++ protocol ++

    ++
  • ++
  • ++

    ++ rb(1) - receive using the Y-MODEM ++ protocol ++

    ++
  • ++
  • ++

    ++ rz(1) - receive using the Z-MODEM ++ protocol ++

    ++
  • ++
  • ++

    ++ sx(1) - send using the X-MODEM protocol ++

    ++
  • ++
  • ++

    ++ sb(1) - send using the Y-MODEM protocol ++

    ++
  • ++
  • ++

    ++ sz(1) - send using the Z-MODEM protocol ++

    ++
  • ++
  • ++

    ++ ascii-xfr(1) - receive or transmit ASCII ++ files ++

    ++
  • ++
++

++ The name of, and the command-line options to, the program to be ++ used for transmitting files are given by the "--send-cmd" option. ++ Similarly the program to receive files, and its argumets, are ++ given by the "--receive-cmd" option. For example, in order to ++ start a picocom session that uses "sz" to transmit files, ++ and "rz" to receive, you have to say something like this: ++

++

++ picocom --send-cmd "sz -vv" --receive-cmd "rz -vv" ++

++

++ During the picocom session, if you key the "send" or "receive" ++ commands (e.g. by pressing C-a, C-s, or C-a, C-r) you will be ++ prompted for a filename. At this prompt you can enter one or more ++ file-names, and any additional arguments to the transmission or ++ reception program. After that, picocom will start the the external ++ program as specified by the "--send-cmd", or "--receive-cmd" ++ option, and with any filenames and additional arguments you may ++ have supplied. The standard input and output of the external ++ program will be connected to the serial port. The standard error ++ of the external program will be connected to the terminal ++ which---while the program is running---will revert to canonical ++ mode. Pressing 'C-c' while the external program is running will ++ prematurely terminate it, and return control to picocom. ++ Pressing 'C-c' at any other time, has no special effect; the ++ character is normally passed to the serial port. ++

++
++ ++

OPTIONS

++
++

++ picocom accepts the following command-line options ++

++
++
++ --baud | -b ++
++
++

++ Defines the baud-rate to set the serial-port (terminal) to. ++

++
++
++ --flow | -f ++
++
++

++ Defines the flow-control mode to set the serial-port to. Must ++ be one of: ++

++
    ++
  • ++

    ++ \'x' for xon/xoff (software) mode ++

    ++
  • ++
  • ++

    ++ \'h' for hardware flow control (RTS/CTS) ++

    ++
  • ++
  • ++

    ++ \'n' for no flow control ++

    ++
  • ++
++

++ (Default: 'n') ++

++
++
++ --parity | -p ++
++
++

++ Defines the parity mode to set the serial-port to. Must be one ++ of: ++

++
    ++
  • ++

    ++ \'o' for odd parity mode. ++

    ++
  • ++
  • ++

    ++ \'e' for even parity mode. ++

    ++
  • ++
  • ++

    ++ \'n' for no parity, mode. ++

    ++
  • ++
++

++ (Default: 'n') ++

++
++
++ --databits | -d ++
++
++

++ Defines the number of data bits in every character. Must be ++ one of: 5, 6, 7, 8 ++

++

++ (Default: 8) ++

++
++
++ --esacpe | -e ++
++
++

++ Defines the character that will make picocom enter ++ command-mode (see description above). If 'x' is given, then ++ C-x will make picocom enter command mode. ++

++

++ (Default: 'a') ++

++
++
++ --noinit | -i ++
++
++

++ If given, picocom will not initialize, reset, or ++ otherwise meddle with the serial port at start-up. It will ++ just open it. This is useful, for example, for connecting picocom ++ to already-connected modems, or already configured ports ++ without terminating the connection, or altering the settings. ++ If required serial port parameters can then be adjusted at ++ run-time by commands. ++

++
++
++ --noreset | -r ++
++
++

++ If given, picocom will not *reset* the serial port when ++ exiting. It will just close the filedes and do nothing more. ++ This is useful, for example, for leaving modems connected when ++ exiting picocom. Regardless whether the "--noreset" ++ option is given the user can exit picocom using the ++ "Quit" command (instead of "Exit"), which never resets the ++ serial port. If "--noreset" is given then "Quit" and "Exit" ++ behave essentially the same. ++

++
++
++ --nolock | -l ++
++
++

++ If given, picocom will *not* attempt to lock the serial ++ port before opening it. Normally picocom attempts to get a ++ UUCP-style lock-file (e.g. "/var/lock/LCK..ttyS0") before ++ opening the port. Failing to do so, results in the program ++ exiting after emitting an error-message. It is possible that ++ your picocom binary is compiled without this option. ++

++
++
++ --send-cmd | -s ++
++
++

++ Specifies the external program (and any arguments to it) that ++ will be used for transmitting files. ++

++

++ Default: "sz -vv" ++

++
++
++ --receive-cmd | -v ++
++
++

++ Specifies the external program (and any arguments to it) that ++ will be used for receiving files. ++

++

++ (Default: "rz -vv") ++

++
++
++ --help | -h ++
++
++

++ Print a short help message describing the command-line ++ options. ++

++
++
++
++ ++

AUTHOR

++
++

++ picocom was written by Nick Patavalis (npat@efault.net) ++

++
++ ++

AVAILABILITY

++
++

++ The latest version of "picocom" can be downloaded from: ++ http://efault.net/npat/hacks/picocom/ ++

++
++ ++
++ ++ ++ ++
picocom(8)
++ ++ ++ +Index: user/blkfin-apps/picocom/TODO +=================================================================== +--- user/blkfin-apps/picocom/TODO (revision 0) ++++ user/blkfin-apps/picocom/TODO (revision 0) +@@ -0,0 +1 @@ ++ +Index: user/blkfin-apps/picocom/pcxm +=================================================================== +--- user/blkfin-apps/picocom/pcxm (revision 0) ++++ user/blkfin-apps/picocom/pcxm (revision 0) +@@ -0,0 +1,4 @@ ++#!/bin/sh ++exec picocom \ ++ --send-cmd="sx -vv" \ ++ --receive-cmd="rx -vv" "$@" +Index: user/blkfin-apps/picocom/CHANGES +=================================================================== +--- user/blkfin-apps/picocom/CHANGES (revision 0) ++++ user/blkfin-apps/picocom/CHANGES (revision 0) +@@ -0,0 +1,157 @@ ++------------------------------------------------------------------------ ++r35 | npat | 2004-08-13 14:18:38 +0300 (Fri, 13 Aug 2004) | 3 lines ++Changed paths: ++ M /picocom/trunk/Makefile ++ ++picocom version 1.4 ++ ++ ++------------------------------------------------------------------------ ++r34 | npat | 2004-08-13 14:15:23 +0300 (Fri, 13 Aug 2004) | 4 lines ++Changed paths: ++ M /picocom/trunk/Makefile ++ ++Added the "changes" target that generates the CHANGES file from the ++svn (version control) commit logs. ++ ++ ++------------------------------------------------------------------------ ++r33 | npat | 2004-08-13 05:48:26 +0300 (Fri, 13 Aug 2004) | 4 lines ++Changed paths: ++ M /picocom/trunk/Makefile ++ M /picocom/trunk/picocom.8.xml ++ ++Converted the manpage sources to use the xmlmp-1.1 DTD, and hence the ++xmlmp tools (see http://npat.efault.net/hacks/xmlmp) ++ ++ ++------------------------------------------------------------------------ ++r28 | npat | 2004-08-12 15:17:54 +0300 (Thu, 12 Aug 2004) | 2 lines ++Changed paths: ++ M /picocom/trunk/TODO ++ ++Removed stale tasks from TODO. (Now it's empty). ++ ++------------------------------------------------------------------------ ++r27 | npat | 2004-08-12 15:16:03 +0300 (Thu, 12 Aug 2004) | 5 lines ++Changed paths: ++ M /picocom/trunk/CONTRIBUTORS ++ M /picocom/trunk/picocom.8.xml ++ ++Added Julius P. Malkiewicz in the contributors list ++ ++Updated documentation to comply with the changes made since r13 ++ ++ ++------------------------------------------------------------------------ ++r26 | npat | 2004-08-12 14:45:11 +0300 (Thu, 12 Aug 2004) | 9 lines ++Changed paths: ++ M /picocom/trunk/Makefile ++ M /picocom/trunk/picocom.c ++ ++Added support for UUCP-style locks. Lock handling is compiled-in if ++the macro UUCP_LOCK_DIR is defined; if it is, it must contain the name ++of the lock directory. Locking can be disabled at runtime using the ++"--noock" option. ++ ++UUCP-locks support is based on a patch submitted by Julius ++P. Malkiewicz ++ ++ ++------------------------------------------------------------------------ ++r25 | npat | 2004-08-12 11:55:56 +0300 (Thu, 12 Aug 2004) | 4 lines ++Changed paths: ++ M /picocom/trunk/picocom.c ++ ++Implemented th C-\ command, which generates a break sequence. Patch ++submitted by Julius P. Malkiewicz ++ ++ ++------------------------------------------------------------------------ ++r24 | npat | 2004-08-12 11:52:39 +0300 (Thu, 12 Aug 2004) | 5 lines ++Changed paths: ++ M /picocom/trunk/picocom.c ++ ++If two escape-characters are sent in a row, the second is ++passed-through, and picocom returns to transparrent mode. Patch ++submitteb by Julius P. Malkiewicz ++ ++ ++------------------------------------------------------------------------ ++r23 | npat | 2004-08-12 11:45:57 +0300 (Thu, 12 Aug 2004) | 7 lines ++Changed paths: ++ M /picocom/trunk/term.c ++ ++Fixed "term.c" to compile under FreeBSD (and probably other BSDs ++also). "term.c" now includes "termios.h" instead of "termio.h" in ++non-linux system. Added a declaration for "tioold"---that was ++missing---in the non-linux part of the DTR toggling code. Patch ++submitted by Julius P. Malkiewicz ++ ++ ++------------------------------------------------------------------------ ++r12 | npat | 2004-08-11 19:03:48 +0300 (Wed, 11 Aug 2004) | 2 lines ++Changed paths: ++ M /picocom/trunk/CONTRIBUTORS ++ M /picocom/trunk/Makefile ++ M /picocom/trunk/README ++ A /picocom/trunk/picocom.8.xml ++ ++Added r1.3 ++ ++------------------------------------------------------------------------ ++r10 | npat | 2004-08-11 19:02:35 +0300 (Wed, 11 Aug 2004) | 3 lines ++Changed paths: ++ A /picocom/trunk/CONTRIBUTORS ++ M /picocom/trunk/Makefile ++ A /picocom/trunk/TODO ++ M /picocom/trunk/picocom.c ++ ++Added r1.2 ++ ++ ++------------------------------------------------------------------------ ++r8 | npat | 2004-08-11 19:01:25 +0300 (Wed, 11 Aug 2004) | 2 lines ++Changed paths: ++ M /picocom/trunk/Makefile ++ A /picocom/trunk/NEWS ++ M /picocom/trunk/README ++ A /picocom/trunk/pcasc ++ A /picocom/trunk/pcxm ++ A /picocom/trunk/pcym ++ A /picocom/trunk/pczm ++ M /picocom/trunk/picocom.c ++ ++Added r1.1 ++ ++------------------------------------------------------------------------ ++r6 | npat | 2004-08-11 18:59:25 +0300 (Wed, 11 Aug 2004) | 2 lines ++Changed paths: ++ A /picocom/trunk/LICENSE.txt ++ A /picocom/trunk/Makefile ++ A /picocom/trunk/README ++ A /picocom/trunk/picocom.c ++ A /picocom/trunk/term.c ++ A /picocom/trunk/term.h ++ ++Imported r1.0 sources ++ ++------------------------------------------------------------------------ ++r1 | svn | 2004-08-11 08:02:59 +0300 (Wed, 11 Aug 2004) | 2 lines ++Changed paths: ++ A /mu0 ++ A /mu0/branches ++ A /mu0/tags ++ A /mu0/trunk ++ A /picocom ++ A /picocom/branches ++ A /picocom/tags ++ A /picocom/trunk ++ A /ppgplot ++ A /ppgplot/branches ++ A /ppgplot/tags ++ A /ppgplot/trunk ++ ++Imported initial projects directory structure. ++ ++------------------------------------------------------------------------ +Index: user/blkfin-apps/picocom/pcym +=================================================================== +--- user/blkfin-apps/picocom/pcym (revision 0) ++++ user/blkfin-apps/picocom/pcym (revision 0) +@@ -0,0 +1,4 @@ ++#!/bin/sh ++exec picocom \ ++ --send-cmd="sb -vv" \ ++ --receive-cmd="rb -vvv" "$@" +Index: user/blkfin-apps/picocom/pczm +=================================================================== +--- user/blkfin-apps/picocom/pczm (revision 0) ++++ user/blkfin-apps/picocom/pczm (revision 0) +@@ -0,0 +1,4 @@ ++#!/bin/sh ++exec picocom \ ++ --send-cmd="sz -vv -b" \ ++ --receive-cmd="rz -vvv -b" "$@" +Index: user/blkfin-apps/picocom/picocom.c +=================================================================== +--- user/blkfin-apps/picocom/picocom.c (revision 0) ++++ user/blkfin-apps/picocom/picocom.c (revision 0) +@@ -0,0 +1,1022 @@ ++/* vi: set sw=4 ts=4: ++ * ++ * picocom.c ++ * ++ * simple dumb-terminal program. Helps you manually configure and test ++ * stuff like modems, devices w. serial ports etc. ++ * ++ * by Nick Patavalis (npat@efault.net) ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License as ++ * published by the Free Software Foundation; either version 2 of the ++ * License, or (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, but ++ * WITHOUT 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 ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define _GNU_SOURCE ++#include ++ ++#include "term.h" ++ ++/**********************************************************************/ ++ ++#define KEY_EXIT '\x18' /* C-x: exit picocom */ ++#define KEY_QUIT '\x11' /* C-q: exit picocom without reseting port */ ++#define KEY_PULSE '\x10' /* C-p: pulse DTR */ ++#define KEY_TOGGLE '\x14' /* C-t: toggle DTR */ ++#define KEY_BAUD_UP '\x15' /* C-u: increase baudrate (up) */ ++#define KEY_BAUD_DN '\x04' /* C-d: decrase baudrate (down) */ ++#define KEY_FLOW '\x06' /* C-f: change flowcntrl mode */ ++#define KEY_PARITY '\x19' /* C-y: change parity mode */ ++#define KEY_BITS '\x02' /* C-b: change number of databits */ ++#define KEY_STATUS '\x16' /* C-v: show program option */ ++#define KEY_SEND '\x13' /* C-s: send file */ ++#define KEY_RECEIVE '\x12' /* C-r: receive file */ ++#define KEY_BREAK '\x1c' /* C-\: break */ ++ ++#define STO STDOUT_FILENO ++#define STI STDIN_FILENO ++ ++/**********************************************************************/ ++ ++struct { ++ char port[128]; ++ int baud; ++ enum flowcntrl_e flow; ++ char *flow_str; ++ enum parity_e parity; ++ char *parity_str; ++ int databits; ++ int noinit; ++ int noreset; ++#ifdef UUCP_LOCK_DIR ++ int nolock; ++#endif ++ unsigned char escape; ++ char send_cmd[128]; ++ char receive_cmd[128]; ++} opts = { ++ .port = "", ++ .baud = 9600, ++ .flow = FC_NONE, ++ .flow_str = "none", ++ .parity = P_NONE, ++ .parity_str = "none", ++ .databits = 8, ++ .noinit = 0, ++ .noreset = 0, ++#ifdef UUCP_LOCK_DIR ++ .nolock = 0, ++#endif ++ .escape = '\x01', ++ .send_cmd = "ascii_xfr -s -v -l10", ++ .receive_cmd = "rz -vv" ++}; ++ ++int tty_fd; ++ ++/**********************************************************************/ ++ ++#ifdef UUCP_LOCK_DIR ++ ++/* use HDB UUCP locks .. see ++ * for details ++ */ ++ ++char lockname[_POSIX_PATH_MAX] = ""; ++ ++int ++uucp_lockname(const char *dir, const char *file) ++{ ++ char *p, *cp; ++ struct stat sb; ++ ++ if ( ! dir || *dir == '\0' || stat(dir, &sb) != 0 ) ++ return -1; ++ ++ /* cut-off initial "/dev/" from file-name */ ++ p = strchr(file + 1, '/'); ++ p = p ? p + 1 : (char *)file; ++ /* replace '/'s with '_'s in what remains (after making a copy) */ ++ p = cp = strdup(p); ++ do { if ( *p == '/' ) *p = '_'; } while(*p++); ++ /* build lockname */ ++ snprintf(lockname, sizeof(lockname), "%s/LCK..%s", dir, cp); ++ /* destroy the copy */ ++ free(cp); ++ ++ return 0; ++} ++ ++int ++uucp_lock(void) ++{ ++ int r, fd, pid; ++ char buf[16]; ++ mode_t m; ++ ++ if ( lockname[0] == '\0' ) return 0; ++ ++ fd = open(lockname, O_RDONLY); ++ if ( fd >= 0 ) { ++ r = read(fd, buf, sizeof(buf)); ++ close(fd); ++ /* if r == 4, lock file is binary (old-style) */ ++ pid = (r == 4) ? *(int *)buf : strtol(buf, NULL, 10); ++ if ( pid > 0 ++ && kill((pid_t)pid, 0) < 0 ++ && errno == ESRCH ) { ++ /* stale lock file */ ++ printf("Removing stale lock: %s\n", lockname); ++ sleep(1); ++ unlink(lockname); ++ } else { ++ lockname[0] = '\0'; ++ errno = EEXIST; ++ return -1; ++ } ++ } ++ /* lock it */ ++ m = umask(022); ++ fd = open(lockname, O_WRONLY|O_CREAT|O_EXCL, 0666); ++ if ( fd < 0 ) { lockname[0] = '\0'; return -1; } ++ umask(m); ++ snprintf(buf, sizeof(buf), "%04d\n", getpid()); ++ write(fd, buf, strlen(buf)); ++ close(fd); ++ ++ return 0; ++} ++ ++int ++uucp_unlock(void) ++{ ++ if ( lockname[0] ) unlink(lockname); ++ return 0; ++} ++ ++#endif /* of UUCP_LOCK_DIR */ ++ ++/**********************************************************************/ ++ ++ssize_t ++writen_ni(int fd, const void *buff, size_t n) ++{ ++ size_t nl; ++ ssize_t nw; ++ const char *p; ++ ++ p = buff; ++ nl = n; ++ while (nl > 0) { ++ do { ++ nw = write(fd, p, nl); ++ } while ( nw < 0 && errno == EINTR ); ++ if ( nw <= 0 ) break; ++ nl -= nw; ++ p += nw; ++ } ++ ++ return n - nl; ++} ++ ++int ++fd_printf (int fd, const char *format, ...) ++{ ++ char buf[256]; ++ va_list args; ++ int len; ++ ++ va_start(args, format); ++ len = vsnprintf(buf, sizeof(buf), format, args); ++ buf[sizeof(buf) - 1] = '\0'; ++ va_end(args); ++ ++ return writen_ni(fd, buf, len); ++} ++ ++void ++fatal (const char *format, ...) ++{ ++ char *s, buf[256]; ++ va_list args; ++ int len; ++ ++ term_reset(STO); ++ term_reset(STI); ++ ++ va_start(args, format); ++ len = vsnprintf(buf, sizeof(buf), format, args); ++ buf[sizeof(buf) - 1] = '\0'; ++ va_end(args); ++ ++ s = "\r\nFATAL: "; ++ writen_ni(STO, s, strlen(s)); ++ writen_ni(STO, buf, len); ++ s = "\r\n"; ++ writen_ni(STO, s, strlen(s)); ++ ++ /* wait a bit for output to drain */ ++ sleep(1); ++ ++#ifdef UUCP_LOCK_DIR ++ uucp_unlock(); ++#endif ++ ++ exit(EXIT_FAILURE); ++} ++ ++#define cput(fd, c) do { int cl = c; write((fd), &(cl), 1); } while(0) ++ ++int ++fd_readline (int fdi, int fdo, char *b, int bsz) ++{ ++ int r; ++ unsigned char c; ++ unsigned char *bp, *bpe; ++ ++ bp = b; ++ bpe = b + bsz - 1; ++ ++ while (1) { ++ r = read(fdi, &c, 1); ++ if ( r <= 0 ) { r--; goto out; } ++ ++ switch (c) { ++ case '\b': ++ if ( bp > (unsigned char *)b ) { ++ bp--; ++ cput(fdo, c); cput(fdo, ' '); cput(fdo, c); ++ } else { ++ cput(fdo, '\x07'); ++ } ++ break; ++ case '\r': ++ *bp = '\0'; ++ r = bp - (unsigned char *)b; ++ goto out; ++ default: ++ if ( bp < bpe ) { *bp++ = c; cput(fdo, c); } ++ else { cput(fdo, '\x07'); } ++ break; ++ } ++ } ++ ++out: ++ return r; ++} ++ ++#undef cput ++ ++/**********************************************************************/ ++ ++int ++baud_up (int baud) ++{ ++ if ( baud < 300 ) ++ baud = 300; ++ else if ( baud == 38400 ) ++ baud = 57600; ++ else ++ baud = baud * 2; ++ if ( baud > 115200 ) ++ baud = 115200; ++ ++ return baud; ++} ++ ++int ++baud_down (int baud) ++{ ++ if ( baud > 115200 ) ++ baud = 115200; ++ else if ( baud == 57600 ) ++ baud = 38400; ++ else ++ baud = baud / 2; ++ ++ if ( baud < 300) ++ baud = 300; ++ ++ return baud; ++} ++ ++int ++flow_next (int flow, char **flow_str) ++{ ++ switch(flow) { ++ case FC_NONE: ++ flow = FC_RTSCTS; ++ *flow_str = "RTS/CTS"; ++ break; ++ case FC_RTSCTS: ++ flow = FC_XONXOFF; ++ *flow_str = "xon/xoff"; ++ break; ++ case FC_XONXOFF: ++ flow = FC_NONE; ++ *flow_str = "none"; ++ break; ++ default: ++ flow = FC_NONE; ++ *flow_str = "none"; ++ break; ++ } ++ ++ return flow; ++} ++ ++int ++parity_next (int parity, char **parity_str) ++{ ++ switch(parity) { ++ case P_NONE: ++ parity = P_EVEN; ++ *parity_str = "even"; ++ break; ++ case P_EVEN: ++ parity = P_ODD; ++ *parity_str = "odd"; ++ break; ++ case P_ODD: ++ parity = P_NONE; ++ *parity_str = "none"; ++ break; ++ default: ++ parity = P_NONE; ++ *parity_str = "none"; ++ break; ++ } ++ ++ return parity; ++} ++ ++int ++bits_next (int bits) ++{ ++ bits++; ++ if (bits > 8) bits = 5; ++ ++ return bits; ++} ++ ++/**********************************************************************/ ++ ++void ++child_empty_handler (int signum) ++{ ++} ++ ++void ++establish_child_signal_handlers (void) ++{ ++ struct sigaction empty_action; ++ ++ /* Set up the structure to specify the "empty" action. */ ++ empty_action.sa_handler = child_empty_handler; ++ sigemptyset (&empty_action.sa_mask); ++ empty_action.sa_flags = 0; ++ ++ sigaction (SIGINT, &empty_action, NULL); ++ sigaction (SIGTERM, &empty_action, NULL); ++} ++ ++int ++run_cmd(int fd, ...) ++{ ++ pid_t pid; ++ sigset_t sigm, sigm_old; ++ ++ /* block signals, let child establish its own handlers */ ++ sigemptyset(&sigm); ++ sigaddset(&sigm, SIGTERM); ++ sigprocmask(SIG_BLOCK, &sigm, &sigm_old); ++ ++ pid = fork(); ++ if ( pid < 0 ) { ++ sigprocmask(SIG_SETMASK, &sigm_old, NULL); ++ fd_printf(STO, "*** cannot fork: %s\n", strerror(errno)); ++ return -1; ++ } else if ( pid ) { ++ /* father: picocom */ ++ int r; ++ ++ /* reset the mask */ ++ sigprocmask(SIG_SETMASK, &sigm_old, NULL); ++ /* wait for child to finish */ ++ waitpid(pid, &r, 0); ++ /* reset terminal (back to raw mode) */ ++ term_apply(STI); ++ /* check and report child return status */ ++ if ( WIFEXITED(r) ) { ++ fd_printf(STO, "\r\n*** exit status: %d\r\n", ++ WEXITSTATUS(r)); ++ return WEXITSTATUS(r); ++ } else { ++ fd_printf(STO, "\r\n*** abnormal termination: 0x%x\r\n", r); ++ return -1; ++ } ++ } else { ++ /* child: external program */ ++ int r; ++ long fl; ++ char cmd[512]; ++ ++ establish_child_signal_handlers(); ++ sigprocmask(SIG_SETMASK, &sigm_old, NULL); ++ /* unmanage terminal, and reset it to canonical mode */ ++ term_remove(STI); ++ /* unmanage serial port fd, without reset */ ++ term_erase(fd); ++ /* set serial port fd to blocking mode */ ++ fl = fcntl(fd, F_GETFL); ++ fl &= ~O_NONBLOCK; ++ fcntl(fd, F_SETFL, fl); ++ /* connect stdin and stdout to serial port */ ++ close(STI); ++ close(STO); ++ dup2(fd, STI); ++ dup2(fd, STO); ++ { ++ /* build command-line */ ++ char *c, *ce; ++ const char *s; ++ int n; ++ va_list vls; ++ ++ c = cmd; ++ ce = cmd + sizeof(cmd) - 1; ++ va_start(vls, fd); ++ while ( (s = va_arg(vls, const char *)) ) { ++ n = strlen(s); ++ if ( c + n + 1 >= ce ) break; ++ memcpy(c, s, n); c += n; ++ *c++ = ' '; ++ } ++ va_end(vls); ++ *c = '\0'; ++ } ++ /* run extenral command */ ++ fd_printf(STDERR_FILENO, "%s\n", cmd); ++ r = system(cmd); ++ if ( WIFEXITED(r) ) exit(WEXITSTATUS(r)); ++ else exit(128); ++ } ++} ++ ++/**********************************************************************/ ++ ++#define TTY_Q_SZ 256 ++ ++struct tty_q { ++ int len; ++ unsigned char buff[TTY_Q_SZ]; ++} tty_q; ++ ++/**********************************************************************/ ++ ++void ++loop(void) ++{ ++ enum { ++ ST_COMMAND, ++ ST_TRANSPARENT ++ } state; ++ int dtr_up; ++ fd_set rdset, wrset; ++ int newbaud, newflow, newparity, newbits; ++ char *newflow_str, *newparity_str; ++ char fname[128]; ++ int r, n; ++ unsigned char c; ++ ++ ++ tty_q.len = 0; ++ state = ST_TRANSPARENT; ++ dtr_up = 0; ++ ++ for (;;) { ++ FD_ZERO(&rdset); ++ FD_ZERO(&wrset); ++ FD_SET(STI, &rdset); ++ FD_SET(tty_fd, &rdset); ++ if ( tty_q.len ) FD_SET(tty_fd, &wrset); ++ ++ if (select(FD_SETSIZE, &rdset, &wrset, NULL, NULL) < 0) ++ fatal("select failed: %d : %s", errno, strerror(errno)); ++ ++ if ( FD_ISSET(STI, &rdset) ) { ++ ++ /* read from terminal */ ++ ++ do { ++ n = read(STI, &c, 1); ++ } while (n < 0 && errno == EINTR); ++ if (n == 0) ++ fatal("stdin closed"); ++ else if (n < 0) ++ fatal("read from stdin failed: %s", strerror(errno)); ++ ++ switch (state) { ++ ++ case ST_COMMAND: ++ if ( c == opts.escape ) { ++ state = ST_TRANSPARENT; ++ /* pass the escape character down */ ++ if (tty_q.len <= TTY_Q_SZ) ++ tty_q.buff[tty_q.len++] = c; ++ else ++ fd_printf(STO, "\x07"); ++ break; ++ } ++ state = ST_TRANSPARENT; ++ switch (c) { ++ case KEY_EXIT: ++ return; ++ case KEY_QUIT: ++ term_set_hupcl(tty_fd, 0); ++ term_flush(tty_fd); ++ term_apply(tty_fd); ++ term_erase(tty_fd); ++ return; ++ case KEY_STATUS: ++ fd_printf(STO, "\r\n"); ++ fd_printf(STO, "*** baud: %d\r\n", opts.baud); ++ fd_printf(STO, "*** flow: %s\r\n", opts.flow_str); ++ fd_printf(STO, "*** parity: %s\r\n", opts.parity_str); ++ fd_printf(STO, "*** databits: %d\r\n", opts.databits); ++ fd_printf(STO, "*** dtr: %s\r\n", dtr_up ? "up" : "down"); ++ break; ++ case KEY_PULSE: ++ fd_printf(STO, "\r\n*** pulse DTR ***\r\n"); ++ if ( term_pulse_dtr(tty_fd) < 0 ) ++ fd_printf(STO, "*** FAILED\r\n"); ++ break; ++ case KEY_TOGGLE: ++ if ( dtr_up ) ++ r = term_lower_dtr(tty_fd); ++ else ++ r = term_raise_dtr(tty_fd); ++ if ( r >= 0 ) dtr_up = ! dtr_up; ++ fd_printf(STO, "\r\n*** DTR: %s ***\r\n", ++ dtr_up ? "up" : "down"); ++ break; ++ case KEY_BAUD_UP: ++ newbaud = baud_up(opts.baud); ++ term_set_baudrate(tty_fd, newbaud); ++ tty_q.len = 0; term_flush(tty_fd); ++ if ( term_apply(tty_fd) >= 0 ) opts.baud = newbaud; ++ fd_printf(STO, "\r\n*** baud: %d ***\r\n", opts.baud); ++ break; ++ case KEY_BAUD_DN: ++ newbaud = baud_down(opts.baud); ++ term_set_baudrate(tty_fd, newbaud); ++ tty_q.len = 0; term_flush(tty_fd); ++ if ( term_apply(tty_fd) >= 0 ) opts.baud = newbaud; ++ fd_printf(STO, "\r\n*** baud: %d ***\r\n", opts.baud); ++ break; ++ case KEY_FLOW: ++ newflow = flow_next(opts.flow, &newflow_str); ++ term_set_flowcntrl(tty_fd, newflow); ++ tty_q.len = 0; term_flush(tty_fd); ++ if ( term_apply(tty_fd) >= 0 ) { ++ opts.flow = newflow; ++ opts.flow_str = newflow_str; ++ } ++ fd_printf(STO, "\r\n*** flow: %s ***\r\n", opts.flow_str); ++ break; ++ case KEY_PARITY: ++ newparity = parity_next(opts.parity, &newparity_str); ++ term_set_parity(tty_fd, newparity); ++ tty_q.len = 0; term_flush(tty_fd); ++ if ( term_apply(tty_fd) >= 0 ) { ++ opts.parity = newparity; ++ opts.parity_str = newparity_str; ++ } ++ fd_printf(STO, "\r\n*** parity: %s ***\r\n", ++ opts.parity_str); ++ break; ++ case KEY_BITS: ++ newbits = bits_next(opts.databits); ++ term_set_databits(tty_fd, newbits); ++ tty_q.len = 0; term_flush(tty_fd); ++ if ( term_apply(tty_fd) >= 0 ) opts.databits = newbits; ++ fd_printf(STO, "\r\n*** databits: %d ***\r\n", ++ opts.databits); ++ break; ++ case KEY_SEND: ++ fd_printf(STO, "\r\n*** file: "); ++ r = fd_readline(STI, STO, fname, sizeof(fname)); ++ fd_printf(STO, "\r\n"); ++ if ( r < -1 && errno == EINTR ) break; ++ if ( r <= -1 ) ++ fatal("cannot read filename: %s", strerror(errno)); ++ run_cmd(tty_fd, opts.send_cmd, fname, NULL); ++ break; ++ case KEY_RECEIVE: ++ fd_printf(STO, "*** file: "); ++ r = fd_readline(STI, STO, fname, sizeof(fname)); ++ fd_printf(STO, "\r\n"); ++ if ( r < -1 && errno == EINTR ) break; ++ if ( r <= -1 ) ++ fatal("cannot read filename: %s", strerror(errno)); ++ if ( fname[0] ) ++ run_cmd(tty_fd, opts.send_cmd, fname, NULL); ++ else ++ run_cmd(tty_fd, opts.receive_cmd, NULL); ++ break; ++ case KEY_BREAK: ++ term_break(tty_fd); ++ fd_printf(STO, "\r\n*** break sent ***\r\n"); ++ break; ++ default: ++ break; ++ } ++ break; ++ ++ case ST_TRANSPARENT: ++ if ( c == opts.escape ) { ++ state = ST_COMMAND; ++ } else { ++ if (tty_q.len <= TTY_Q_SZ) ++ tty_q.buff[tty_q.len++] = c; ++ else ++ fd_printf(STO, "\x07"); ++ } ++ break; ++ ++ default: ++ assert(0); ++ break; ++ } ++ } ++ ++ if ( FD_ISSET(tty_fd, &rdset) ) { ++ ++ /* read from port */ ++ ++ do { ++ n = read(tty_fd, &c, 1); ++ } while (n < 0 && errno == EINTR); ++ if (n == 0) ++ fatal("term closed"); ++ else if ( n < 0 ) ++ fatal("read from term failed: %s", strerror(errno)); ++ ++ do { ++ n = write(STO, &c, 1); ++ } while ( errno == EAGAIN ++ || errno == EWOULDBLOCK ++ || errno == EINTR ); ++ if ( n <= 0 ) ++ fatal("write to stdout failed: %s", strerror(errno)); ++ } ++ ++ if ( FD_ISSET(tty_fd, &wrset) ) { ++ ++ /* write to port */ ++ ++ do { ++ n = write(tty_fd, tty_q.buff, tty_q.len); ++ } while ( n < 0 && errno == EINTR ); ++ if ( n <= 0 ) ++ fatal("write to term failed: %s", strerror(errno)); ++ memcpy(tty_q.buff, tty_q.buff + n, tty_q.len - n); ++ tty_q.len -= n; ++ } ++ } ++} ++ ++/**********************************************************************/ ++ ++void ++deadly_handler(int signum) ++{ ++ kill(0, SIGTERM); ++ sleep(1); ++#ifdef UUCP_LOCK_DIR ++ uucp_unlock(); ++#endif ++ exit(EXIT_FAILURE); ++} ++ ++void ++establish_signal_handlers (void) ++{ ++ struct sigaction exit_action, ign_action; ++ ++ /* Set up the structure to specify the exit action. */ ++ exit_action.sa_handler = deadly_handler; ++ sigemptyset (&exit_action.sa_mask); ++ exit_action.sa_flags = 0; ++ ++ /* Set up the structure to specify the ignore action. */ ++ ign_action.sa_handler = SIG_IGN; ++ sigemptyset (&ign_action.sa_mask); ++ ign_action.sa_flags = 0; ++ ++ sigaction (SIGTERM, &exit_action, NULL); ++ ++ sigaction (SIGINT, &ign_action, NULL); ++ sigaction (SIGHUP, &ign_action, NULL); ++ sigaction (SIGALRM, &ign_action, NULL); ++ sigaction (SIGUSR1, &ign_action, NULL); ++ sigaction (SIGUSR2, &ign_action, NULL); ++ sigaction (SIGPIPE, &ign_action, NULL); ++} ++ ++/**********************************************************************/ ++ ++void ++show_usage(char *name) ++{ ++ char *s; ++ ++ s = strrchr(name, '/'); ++ s = s ? s+1 : name; ++ ++ printf("picocom v%s\n", VERSION_STR); ++ printf("Usage is: %s [options] \n", s); ++ printf("Options are:\n"); ++ printf(" --aud \n"); ++ printf(" --low s (=soft) | h (=hard) | n (=none)\n"); ++ printf(" --

arity o (=odd) | e (=even) | n (=none)\n"); ++ printf(" --atabits 5 | 6 | 7 | 8\n"); ++ printf(" --scape \n"); ++ printf(" --nonit\n"); ++ printf(" --noeset\n"); ++ printf(" --noock\n"); ++ printf(" --end-cmd \n"); ++ printf(" --receie-cmd \n"); ++ printf(" --elp\n"); ++ printf(" indicates the equivalent short option.\n"); ++ printf("Short options are prefixed by \"-\" instead of by \"--\".\n"); ++} ++ ++/**********************************************************************/ ++ ++void ++parse_args(int argc, char *argv[]) ++{ ++ static struct option longOptions[] = ++ { ++ {"receive-cmd", required_argument, 0, 'v'}, ++ {"send-cmd", required_argument, 0, 's'}, ++ {"escape", required_argument, 0, 'e'}, ++ {"noinit", no_argument, 0, 'i'}, ++ {"noreset", no_argument, 0, 'r'}, ++ {"nolock", no_argument, 0, 'l'}, ++ {"flow", required_argument, 0, 'f'}, ++ {"baud", required_argument, 0, 'b'}, ++ {"parity", required_argument, 0, 'p'}, ++ {"databits", required_argument, 0, 'd'}, ++ {"help", no_argument, 0, 'h'}, ++ {0, 0, 0, 0} ++ }; ++ ++ while (1) { ++ int optionIndex = 0; ++ int c; ++ ++ /* no default error messages printed. */ ++ opterr = 0; ++ ++ c = getopt_long(argc, argv, "hirls:r:e:f:b:p:d:", ++ longOptions, &optionIndex); ++ ++ if (c < 0) ++ break; ++ ++ switch (c) { ++ case 's': ++ strncpy(opts.send_cmd, optarg, sizeof(opts.send_cmd)); ++ opts.send_cmd[sizeof(opts.send_cmd) - 1] = '\0'; ++ break; ++ case 'v': ++ strncpy(opts.receive_cmd, optarg, sizeof(opts.receive_cmd)); ++ opts.receive_cmd[sizeof(opts.receive_cmd) - 1] = '\0'; ++ break; ++ case 'i': ++ opts.noinit = 1; ++ break; ++ case 'r': ++ opts.noreset = 1; ++ break; ++ case 'l': ++ opts.nolock = 1; ++ break; ++ case 'e': ++ if ( isupper(optarg[0]) ) ++ opts.escape = optarg[0] - 'A' + 1; ++ else ++ opts.escape = optarg[0] - 'a' + 1; ++ break; ++ case 'f': ++ switch (optarg[0]) { ++ case 'X': ++ case 'x': ++ opts.flow_str = "xon/xoff"; ++ opts.flow = FC_XONXOFF; ++ break; ++ case 'H': ++ case 'h': ++ opts.flow_str = "RTS/CTS"; ++ opts.flow = FC_RTSCTS; ++ break; ++ case 'N': ++ case 'n': ++ opts.flow_str = "none"; ++ opts.flow = FC_NONE; ++ break; ++ default: ++ fprintf(stderr, "--flow '%c' ignored.\n", optarg[0]); ++ fprintf(stderr, "--flow can be one off: 'x', 'h', or 'n'\n"); ++ break; ++ } ++ break; ++ case 'b': ++ opts.baud = atoi(optarg); ++ break; ++ case 'p': ++ switch (optarg[0]) { ++ case 'e': ++ opts.parity_str = "even"; ++ opts.parity = P_EVEN; ++ break; ++ case 'o': ++ opts.parity_str = "odd"; ++ opts.parity = P_ODD; ++ break; ++ case 'n': ++ opts.parity_str = "none"; ++ opts.parity = P_NONE; ++ break; ++ default: ++ fprintf(stderr, "--parity '%c' ignored.\n", optarg[0]); ++ fprintf(stderr, "--parity can be one off: 'o', 'e', or 'n'\n"); ++ break; ++ } ++ break; ++ case 'd': ++ switch (optarg[0]) { ++ case '5': ++ opts.databits = 5; ++ break; ++ case '6': ++ opts.databits = 6; ++ break; ++ case '7': ++ opts.databits = 7; ++ break; ++ case '8': ++ opts.databits = 8; ++ break; ++ default: ++ fprintf(stderr, "--databits '%c' ignored.\n", optarg[0]); ++ fprintf(stderr, "--databits can be one off: 5, 6, 7 or 8\n"); ++ break; ++ } ++ break; ++ case 'h': ++ show_usage(argv[0]); ++ exit(EXIT_SUCCESS); ++ case '?': ++ default: ++ fprintf(stderr, "Unrecognized option.\n"); ++ fprintf(stderr, "Run with '--help'.\n"); ++ exit(EXIT_FAILURE); ++ } ++ } /* while */ ++ ++ if ( (argc - optind) < 1) { ++ fprintf(stderr, "No port given\n"); ++ exit(EXIT_FAILURE); ++ } ++ strncpy(opts.port, argv[optind], sizeof(opts.port) - 1); ++ opts.port[sizeof(opts.port) - 1] = '\0'; ++ ++ printf("picocom v%s\n", VERSION_STR); ++ printf("\n"); ++ printf("port is : %s\n", opts.port); ++ printf("flowcontrol : %s\n", opts.flow_str); ++ printf("baudrate is : %d\n", opts.baud); ++ printf("parity is : %s\n", opts.parity_str); ++ printf("databits are : %d\n", opts.databits); ++ printf("escape is : C-%c\n", 'a' + opts.escape - 1); ++ printf("noinit is : %s\n", opts.noinit ? "yes" : "no"); ++ printf("noreset is : %s\n", opts.noreset ? "yes" : "no"); ++ printf("nolock is : %s\n", opts.nolock ? "yes" : "no"); ++ printf("send_cmd is : %s\n", opts.send_cmd); ++ printf("receive_cmd is : %s\n", opts.receive_cmd); ++ printf("\n"); ++} ++ ++/**********************************************************************/ ++ ++int ++main(int argc, char *argv[]) ++{ ++ int r; ++ ++ parse_args(argc, argv); ++ ++ establish_signal_handlers(); ++ ++ r = term_lib_init(); ++ if ( r < 0 ) ++ fatal("term_init failed: %s", term_strerror(term_errno, errno)); ++ ++#ifdef UUCP_LOCK_DIR ++ if ( ! opts.nolock ) uucp_lockname(UUCP_LOCK_DIR, opts.port); ++ if ( uucp_lock() < 0 ) ++ fatal("cannot lock %s: %s", opts.port, strerror(errno)); ++#endif ++ ++ tty_fd = open(opts.port, O_RDWR | O_NONBLOCK); ++ if (tty_fd < 0) ++ fatal("cannot open %s: %s", opts.port, strerror(errno)); ++ ++ if ( opts.noinit ) { ++ r = term_add(tty_fd); ++ } else { ++ r = term_set(tty_fd, ++ 1, /* raw mode. */ ++ opts.baud, /* baud rate. */ ++ opts.parity, /* parity. */ ++ opts.databits, /* data bits. */ ++ opts.flow, /* flow control. */ ++ 1, /* local or modem */ ++ !opts.noreset); /* hup-on-close. */ ++ } ++ if ( r < 0 ) ++ fatal("failed to add device %s: %s", ++ opts.port, term_strerror(term_errno, errno)); ++ r = term_apply(tty_fd); ++ if ( r < 0 ) ++ fatal("failed to config device %s: %s", ++ opts.port, term_strerror(term_errno, errno)); ++ ++ r = term_add(STI); ++ if ( r < 0 ) ++ fatal("failed to add I/O device: %s", ++ term_strerror(term_errno, errno)); ++ term_set_raw(STI); ++ r = term_apply(STI); ++ if ( r < 0 ) ++ fatal("failed to set I/O device to raw mode: %s", ++ term_strerror(term_errno, errno)); ++ ++ fd_printf(STO, "Terminal ready\r\n"); ++ loop(); ++ ++ fd_printf(STO, "\r\n"); ++ if ( opts.noreset ) { ++ fd_printf(STO, "Skipping tty reset...\r\n"); ++ term_erase(tty_fd); ++ } ++ ++ fd_printf(STO, "Thanks for using picocom\r\n"); ++ /* wait a bit for output to drain */ ++ sleep(1); ++ ++#ifdef UUCP_LOCK_DIR ++ uucp_unlock(); ++#endif ++ ++ return EXIT_SUCCESS; ++} ++ ++/**********************************************************************/ ++ ++/* ++ * Local Variables: ++ * mode:c ++ * tab-width: 4 ++ * c-basic-offset: 4 ++ * End: ++ */ +Index: user/blkfin-apps/picocom/NEWS +=================================================================== +--- user/blkfin-apps/picocom/NEWS (revision 0) ++++ user/blkfin-apps/picocom/NEWS (revision 0) +@@ -0,0 +1,24 @@ ++ ++version 1.1 ++ ++ - Added example shell-scripts that start picocom preconfigured for ++ ASCII, Z-MODEM, Y-MODEM, and X-MODEM file transfers. ++ ++ - Better signal handling. ++ ++ - Added the "send" and "receive" commands. They can be used to ++ transmit and receive files via external programs that implement ++ the respective protocols (like the programs "sz", "rz", etc). ++ ++ - Added the "status" command, which shows the currently active ++ program options, like the current baud rate, the current ++ flow-control settings, etc. Only options that can be controlled ++ online are shown. ++ ++ - Slight code restructuring. ++ ++ - Minor bug fixes. ++ ++version 1.0 ++ ++ - Initial release. +Index: user/blkfin-apps/picocom/Makefile +=================================================================== +--- user/blkfin-apps/picocom/Makefile (revision 0) ++++ user/blkfin-apps/picocom/Makefile (revision 0) +@@ -0,0 +1,46 @@ ++ ++VERSION=1.4 ++ ++# CC = gcc ++CPPFLAGS+=-DVERSION_STR=\"$(VERSION)\" -DUUCP_LOCK_DIR=\"/var/lock\" ++CFLAGS += -Wall ++ ++# LD = gcc ++ ++all: picocom ++ ++picocom : picocom.o term.o ++# $(LD) $(LDFLAGS) -o $@ $+ $(LDLIBS) ++ ++picocom.o : picocom.c term.h ++term.o : term.c term.h ++ ++doc : picocom.8 picocom.8.html picocom.8.ps ++ ++changes : ++ svn log -v . > CHANGES ++ ++picocom.8 : picocom.8.xml ++ xmlmp2man < $< > $@ ++ ++picocom.8.html : picocom.8.xml ++ xmlmp2html < $< > $@ ++ ++picocom.8.ps : picocom.8 ++ groff -mandoc -Tps $< > $@ ++ ++clean: ++ rm -f picocom.o term.o ++ rm -f *~ ++ rm -f \#*\# ++ rm -f *.gdb ++ rm -f picocom ++ ++realclean: distclean ++ rm -f picocom.8 ++ rm -f picocom.8.html ++ rm -f picocom.8.ps ++ rm -f CHANGES ++ ++romfs: ++ $(ROMFSINST) picocom /bin +Index: user/blkfin-apps/Makefile +=================================================================== +--- user/blkfin-apps/Makefile (revision 5006) ++++ user/blkfin-apps/Makefile (working copy) +@@ -26,6 +26,7 @@ dir_$(CONFIG_USER_THREADSTACK) + dir_$(CONFIG_USER_BLACKFIN_ASTERISK) += asterisk + dir_$(CONFIG_USER_USBUTILS) += usbutils + dir_$(CONFIG_USER_BLUEZ) += bluez-utils ++dir_$(CONFIG_USER_PICOCOM) += picocom + + all %:: + for i in $(dir_y) ; do make -C $$i $@ || exit $$? ; done diff --git a/uclinux-sash-cleanup.patch b/uclinux-sash-cleanup.patch new file mode 100644 index 0000000..e4d1ca9 --- /dev/null +++ b/uclinux-sash-cleanup.patch @@ -0,0 +1,50 @@ +Index: user/sash/reboot.c +=================================================================== +RCS file: /var/cvs/uClinux-dist/user/sash/reboot.c,v +retrieving revision 1.1.1.2 +diff -u -p -r1.1.1.2 reboot.c +--- user/sash/reboot.c 12 Jul 2006 05:03:28 -0000 1.1.1.2 ++++ user/sash/reboot.c 7 Jan 2007 11:55:38 -0000 +@@ -12,7 +12,6 @@ + * AUG/99 -- added delay option to reboot + */ + +-#include + #include + + #include +Index: user/sash/shutdown.c +=================================================================== +RCS file: /var/cvs/uClinux-dist/user/sash/shutdown.c,v +retrieving revision 1.1.1.2 +diff -u -p -r1.1.1.2 shutdown.c +--- user/sash/shutdown.c 26 Feb 2003 01:54:21 -0000 1.1.1.2 ++++ user/sash/shutdown.c 7 Jan 2007 11:55:38 -0000 +@@ -10,9 +10,9 @@ + + #include "sash.h" + +-#include +- +- ++#include ++#include ++#include + #include + #include + #include +Index: user/sash/libsash/utils.c +=================================================================== +RCS file: /var/cvs/uClinux-dist/user/sash/libsash/utils.c,v +retrieving revision 1.1.1.4 +diff -u -p -r1.1.1.4 utils.c +--- user/sash/libsash/utils.c 10 Aug 2005 00:15:04 -0000 1.1.1.4 ++++ user/sash/libsash/utils.c 7 Jan 2007 11:55:38 -0000 +@@ -8,6 +8,7 @@ + + #include "sash.h" + ++#include + #include + #include + #include diff --git a/uclinux-search-LINUXDIR-for-defconfig.patch b/uclinux-search-LINUXDIR-for-defconfig.patch new file mode 100644 index 0000000..587fbdf --- /dev/null +++ b/uclinux-search-LINUXDIR-for-defconfig.patch @@ -0,0 +1,37 @@ +--- uClinux-dist/config/setconfig ++++ uClinux-dist/config/setconfig +@@ -225,17 +225,23 @@ + + if [ ! -f $LINUXDIR/.config ] || var_isset CONFIG_DEFAULTS_OVERRIDE; then + if [ ! -f "vendors/$VENDOR/$PRODUCT/config.$LINUXDIR" ]; then +- echo; echo; echo; echo +- echo "*********************** NOTICE ****************************" +- echo "There is no preset config for $LINUXDIR on platform $VENDOR/$PRODUCT." +- echo "If you choose to continue you will have to setup a linux" +- echo "config from scratch which is a very complex task." +- echo "You will find it easier if you can copy a config.$LINUXDIR" +- echo "from another platform that is similar." +- echo +- echo "If you know what you are doing press otherwise" +- echo "Type ^C to abort." +- read dummy ++ ARCH=$(echo -e "e:\\n\\t@echo \$(ARCH)\\ninclude config.arch" | \ ++ ROOTDIR=$PWD make --no-print-directory -s -f - 2>/dev/null) ++ if [ ! -f "$LINUXDIR/arch/$ARCH/configs/${PRODUCT}_defconfig" ]; then ++ echo; echo; echo; echo ++ echo "*********************** NOTICE ****************************" ++ echo "There is no preset config for $LINUXDIR on platform $VENDOR/$PRODUCT." ++ echo "If you choose to continue you will have to setup a linux" ++ echo "config from scratch which is a very complex task." ++ echo "You will find it easier if you can copy a config.$LINUXDIR" ++ echo "from another platform that is similar." ++ echo ++ echo "If you know what you are doing press otherwise" ++ echo "Type ^C to abort." ++ read dummy ++ else ++ cp "$LINUXDIR/arch/$ARCH/configs/${PRODUCT}_defconfig" $LINUXDIR/.config ++ fi + else + cp "vendors/$VENDOR/$PRODUCT/config.$LINUXDIR" $LINUXDIR/.config + fi diff --git a/uclinux-sysutils-cleanup.patch b/uclinux-sysutils-cleanup.patch new file mode 100644 index 0000000..5ea0d69 --- /dev/null +++ b/uclinux-sysutils-cleanup.patch @@ -0,0 +1,163 @@ +Index: user/sysutils/df.c +=================================================================== +RCS file: /var/cvs/uClinux-dist/user/sysutils/df.c,v +retrieving revision 1.1.1.1 +diff -u -p -r1.1.1.1 df.c +--- user/sysutils/df.c 19 Sep 2002 04:26:06 -0000 1.1.1.1 ++++ user/sysutils/df.c 7 Jan 2007 08:36:51 -0000 +@@ -9,22 +9,15 @@ + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ +-#include +- + #include + #include + #include + #include +- ++#include ++#include + #include +-#include +-#include +-#include + #include +-#include +-#include + #include +-#include + #include + + int +Index: user/sysutils/free.c +=================================================================== +RCS file: /var/cvs/uClinux-dist/user/sysutils/free.c,v +retrieving revision 1.1.1.1 +diff -u -p -r1.1.1.1 free.c +--- user/sysutils/free.c 19 Sep 2002 04:26:06 -0000 1.1.1.1 ++++ user/sysutils/free.c 7 Jan 2007 08:36:51 -0000 +@@ -10,17 +10,9 @@ + * (at your option) any later version. + */ + +-#include +- + #include ++#include + #include +-#include +- +-#include +-#include +-#include +-#include +-#include + + char buf[256]; + +Index: user/sysutils/hostname.c +=================================================================== +RCS file: /var/cvs/uClinux-dist/user/sysutils/hostname.c,v +retrieving revision 1.1.1.1 +diff -u -p -r1.1.1.1 hostname.c +--- user/sysutils/hostname.c 19 Sep 2002 04:26:06 -0000 1.1.1.1 ++++ user/sysutils/hostname.c 7 Jan 2007 08:36:51 -0000 +@@ -3,6 +3,8 @@ + #include + #include + #include ++#include ++#include + #include + + int main(int argc, char *argv[]) +Index: user/sysutils/ps.c +=================================================================== +RCS file: /var/cvs/uClinux-dist/user/sysutils/ps.c,v +retrieving revision 1.1.1.2 +diff -u -p -r1.1.1.2 ps.c +--- user/sysutils/ps.c 10 Aug 2005 00:23:03 -0000 1.1.1.2 ++++ user/sysutils/ps.c 7 Jan 2007 08:36:51 -0000 +@@ -10,13 +10,12 @@ + * (at your option) any later version. + */ + +-#include +- + #include + #include + #include + #include + #include ++#include + #include + #include + #include +@@ -64,7 +63,6 @@ main(argc, argv) + { + int i; + int h; +- int max; + FILE * f; + DIR * d; + unsigned long bytes, sbytes; +@@ -73,7 +71,6 @@ main(argc, argv) + int l; + time_t time_now; + long uptime_secs; +- float idle_secs; + float seconds, start, total_time; + int utime, stime, start_time; + int pcpu; +@@ -114,9 +111,9 @@ main(argc, argv) + + d = opendir("/proc"); + if (!d) +- return; ++ return 1; + +- while (de = readdir(d)) { ++ while ((de = readdir(d)) != NULL) { + + + for(i=0;id_name);i++) +Index: user/sysutils/reboot.c +=================================================================== +RCS file: /var/cvs/uClinux-dist/user/sysutils/reboot.c,v +retrieving revision 1.1.1.1 +diff -u -p -r1.1.1.1 reboot.c +--- user/sysutils/reboot.c 19 Sep 2002 04:26:06 -0000 1.1.1.1 ++++ user/sysutils/reboot.c 7 Jan 2007 08:36:51 -0000 +@@ -12,10 +12,10 @@ + * AUG/99 -- added delay option to reboot + */ + +-#include +- ++#include + #include + #include ++#include + #include + #include + +Index: user/sysutils/shutdown.c +=================================================================== +RCS file: /var/cvs/uClinux-dist/user/sysutils/shutdown.c,v +retrieving revision 1.1.1.1 +diff -u -p -r1.1.1.1 shutdown.c +--- user/sysutils/shutdown.c 19 Sep 2002 04:26:06 -0000 1.1.1.1 ++++ user/sysutils/shutdown.c 7 Jan 2007 08:36:51 -0000 +@@ -10,8 +10,10 @@ + * (at your option) any later version. + */ + +-#include + ++#include ++#include ++#include + #include + #include + #include diff --git a/uclinux-user-makefile-customize.patch b/uclinux-user-makefile-customize.patch new file mode 100644 index 0000000..910a74e --- /dev/null +++ b/uclinux-user-makefile-customize.patch @@ -0,0 +1,21 @@ +Index: user/Makefile +=================================================================== +RCS file: /var/cvs/uClinux-dist/user/Makefile,v +retrieving revision 1.13 +diff -u -p -r1.13 Makefile +--- user/Makefile 1 Feb 2007 14:56:29 -0000 1.13 ++++ user/Makefile 17 May 2007 14:07:18 -0000 +@@ -10,7 +10,7 @@ + # + + ifndef ROOTDIR +-ROOTDIR=.. ++ROOTDIR=$(PWD)/.. + endif + + UCLINUX_BUILD_USER=1 +@@ -474,3 +474,4 @@ prune_openswan: + cp -R $@/* .; \ + rm -fr $@ + ++-include Makefile.local diff --git a/uclinux-vendors-eat-dos-gremlins.patch b/uclinux-vendors-eat-dos-gremlins.patch new file mode 100644 index 0000000..74f5374 --- /dev/null +++ b/uclinux-vendors-eat-dos-gremlins.patch @@ -0,0 +1,340 @@ +Index: AtmarkTechno/SUZAKU/hardware/etc/fast_runtime.opt +=================================================================== +RCS file: /var/cvs/uClinux-dist/vendors/AtmarkTechno/SUZAKU/hardware/etc/fast_runtime.opt,v +retrieving revision 1.1.1.1 +diff -u -p -r1.1.1.1 fast_runtime.opt +--- AtmarkTechno/SUZAKU/hardware/etc/fast_runtime.opt 16 Nov 2004 10:51:27 -0000 1.1.1.1 ++++ AtmarkTechno/SUZAKU/hardware/etc/fast_runtime.opt 6 Jan 2007 09:05:57 -0000 +@@ -1,81 +1,81 @@ +-FLOWTYPE = FPGA; +-############################################################### +-## Filename: fast_runtime.opt +-## +-## Option File For Xilinx FPGA Implementation Flow for Fast +-## Runtime. +-## +-## Version: 4.1.1 +-## $Header: /cvs/sw/new-wave/vendors/AtmarkTechno/SUZAKU/hardware/etc/fast_runtime.opt,v 1.1 2004/04/30 11:02:52 davidm Exp $ +-############################################################### +-# +-# Options for Translator +-# +-# Type "ngdbuild -h" for a detailed list of ngdbuild command line options +-# +-Program ngdbuild +--p ; # Partname to use - picked from xflow commandline +--nt timestamp; # NGO File generation. Regenerate only when +- # source netlist is newer than existing +- # NGO file (default) +--bm .bmm # Block RAM memory map file +-; # User design - pick from xflow command line +--uc .ucf; # ucf constraints +-.ngd; # Name of NGD file. Filebase same as design filebase +-End Program ngdbuild +- +-# +-# Options for Mapper +-# +-# Type "map -h " for a detailed list of map command line options +-# +-Program map +--o _map.ncd; # Output Mapped ncd file +-#-fp .mfp; # Floorplan file +-.ngd; # Input NGD file +-.pcf; # Physical constraints file +-END Program map +- +-# +-# Options for Post Map Trace +-# +-# Type "trce -h" for a detailed list of trce command line options +-# +-Program post_map_trce +--e 3; # Produce error report limited to 3 items per constraint +-#-o _map.twr; # Output trace report file +--xml _map.twx; # Output XML version of the timing report +-#-tsi _map.tsi; # Produce Timing Specification Interaction report +-_map.ncd; # Input mapped ncd +-.pcf; # Physical constraints file +-END Program post_map_trce +- +-# +-# Options for Place and Route +-# +-# Type "par -h" for a detailed list of par command line options +-# +-Program par +--w; # Overwrite existing placed and routed ncd +--ol 4; # Overall effort level +--d 0; # Number of delay based cleanup passes +-_map.ncd; # Input mapped NCD file +-.ncd; # Output placed and routed NCD +-.pcf; # Input physical constraints file +-END Program par +- +-# +-# Options for Post Par Trace +-# +-# Type "trce -h" for a detailed list of trce command line options +-# +-Program post_par_trce +--e 3; # Produce error report limited to 3 items per constraint +-#-o .twr; # Output trace report file +--xml .twx; # Output XML version of the timing report +-#-tsi .tsi; # Produce Timing Specification Interaction report +-.ncd; # Input placed and routed ncd +-.pcf; # Physical constraints file +-END Program post_par_trce +- +- ++FLOWTYPE = FPGA; ++############################################################### ++## Filename: fast_runtime.opt ++## ++## Option File For Xilinx FPGA Implementation Flow for Fast ++## Runtime. ++## ++## Version: 4.1.1 ++## $Header: /cvs/sw/new-wave/vendors/AtmarkTechno/SUZAKU/hardware/etc/fast_runtime.opt,v 1.1 2004/04/30 11:02:52 davidm Exp $ ++############################################################### ++# ++# Options for Translator ++# ++# Type "ngdbuild -h" for a detailed list of ngdbuild command line options ++# ++Program ngdbuild ++-p ; # Partname to use - picked from xflow commandline ++-nt timestamp; # NGO File generation. Regenerate only when ++ # source netlist is newer than existing ++ # NGO file (default) ++-bm .bmm # Block RAM memory map file ++; # User design - pick from xflow command line ++-uc .ucf; # ucf constraints ++.ngd; # Name of NGD file. Filebase same as design filebase ++End Program ngdbuild ++ ++# ++# Options for Mapper ++# ++# Type "map -h " for a detailed list of map command line options ++# ++Program map ++-o _map.ncd; # Output Mapped ncd file ++#-fp .mfp; # Floorplan file ++.ngd; # Input NGD file ++.pcf; # Physical constraints file ++END Program map ++ ++# ++# Options for Post Map Trace ++# ++# Type "trce -h" for a detailed list of trce command line options ++# ++Program post_map_trce ++-e 3; # Produce error report limited to 3 items per constraint ++#-o _map.twr; # Output trace report file ++-xml _map.twx; # Output XML version of the timing report ++#-tsi _map.tsi; # Produce Timing Specification Interaction report ++_map.ncd; # Input mapped ncd ++.pcf; # Physical constraints file ++END Program post_map_trce ++ ++# ++# Options for Place and Route ++# ++# Type "par -h" for a detailed list of par command line options ++# ++Program par ++-w; # Overwrite existing placed and routed ncd ++-ol 4; # Overall effort level ++-d 0; # Number of delay based cleanup passes ++_map.ncd; # Input mapped NCD file ++.ncd; # Output placed and routed NCD ++.pcf; # Input physical constraints file ++END Program par ++ ++# ++# Options for Post Par Trace ++# ++# Type "trce -h" for a detailed list of trce command line options ++# ++Program post_par_trce ++-e 3; # Produce error report limited to 3 items per constraint ++#-o .twr; # Output trace report file ++-xml .twx; # Output XML version of the timing report ++#-tsi .tsi; # Produce Timing Specification Interaction report ++.ncd; # Input placed and routed ncd ++.pcf; # Physical constraints file ++END Program post_par_trce ++ ++ +Index: Insight/XC2V1K_Microblaze/hardware/etc/fast_runtime.opt +=================================================================== +RCS file: /var/cvs/uClinux-dist/vendors/Insight/XC2V1K_Microblaze/hardware/etc/fast_runtime.opt,v +retrieving revision 1.1.1.1 +diff -u -p -r1.1.1.1 fast_runtime.opt +--- Insight/XC2V1K_Microblaze/hardware/etc/fast_runtime.opt 23 May 2003 00:47:23 -0000 1.1.1.1 ++++ Insight/XC2V1K_Microblaze/hardware/etc/fast_runtime.opt 6 Jan 2007 09:05:58 -0000 +@@ -1,81 +1,81 @@ +-FLOWTYPE = FPGA; +-############################################################### +-## Filename: fast_runtime.opt +-## +-## Option File For Xilinx FPGA Implementation Flow for Fast +-## Runtime. +-## +-## Version: 4.1.1 +-## $Header: /cvs/sw/new-wave/vendors/Insight/XC2V1K_Microblaze/hardware/etc/fast_runtime.opt,v 1.1 2003/04/02 04:59:57 gerg Exp $ +-############################################################### +-# +-# Options for Translator +-# +-# Type "ngdbuild -h" for a detailed list of ngdbuild command line options +-# +-Program ngdbuild +--p ; # Partname to use - picked from xflow commandline +--nt timestamp; # NGO File generation. Regenerate only when +- # source netlist is newer than existing +- # NGO file (default) +--bm .bmm # Block RAM memory map file +-; # User design - pick from xflow command line +--uc .ucf; # ucf constraints +-.ngd; # Name of NGD file. Filebase same as design filebase +-End Program ngdbuild +- +-# +-# Options for Mapper +-# +-# Type "map -h " for a detailed list of map command line options +-# +-Program map +--o _map.ncd; # Output Mapped ncd file +-#-fp .mfp; # Floorplan file +-.ngd; # Input NGD file +-.pcf; # Physical constraints file +-END Program map +- +-# +-# Options for Post Map Trace +-# +-# Type "trce -h" for a detailed list of trce command line options +-# +-Program post_map_trce +--e 3; # Produce error report limited to 3 items per constraint +-#-o _map.twr; # Output trace report file +--xml _map.twx; # Output XML version of the timing report +-#-tsi _map.tsi; # Produce Timing Specification Interaction report +-_map.ncd; # Input mapped ncd +-.pcf; # Physical constraints file +-END Program post_map_trce +- +-# +-# Options for Place and Route +-# +-# Type "par -h" for a detailed list of par command line options +-# +-Program par +--w; # Overwrite existing placed and routed ncd +--ol 4; # Overall effort level +--d 0; # Number of delay based cleanup passes +-_map.ncd; # Input mapped NCD file +-.ncd; # Output placed and routed NCD +-.pcf; # Input physical constraints file +-END Program par +- +-# +-# Options for Post Par Trace +-# +-# Type "trce -h" for a detailed list of trce command line options +-# +-Program post_par_trce +--e 3; # Produce error report limited to 3 items per constraint +-#-o .twr; # Output trace report file +--xml .twx; # Output XML version of the timing report +-#-tsi .tsi; # Produce Timing Specification Interaction report +-.ncd; # Input placed and routed ncd +-.pcf; # Physical constraints file +-END Program post_par_trce +- +- ++FLOWTYPE = FPGA; ++############################################################### ++## Filename: fast_runtime.opt ++## ++## Option File For Xilinx FPGA Implementation Flow for Fast ++## Runtime. ++## ++## Version: 4.1.1 ++## $Header: /cvs/sw/new-wave/vendors/Insight/XC2V1K_Microblaze/hardware/etc/fast_runtime.opt,v 1.1 2003/04/02 04:59:57 gerg Exp $ ++############################################################### ++# ++# Options for Translator ++# ++# Type "ngdbuild -h" for a detailed list of ngdbuild command line options ++# ++Program ngdbuild ++-p ; # Partname to use - picked from xflow commandline ++-nt timestamp; # NGO File generation. Regenerate only when ++ # source netlist is newer than existing ++ # NGO file (default) ++-bm .bmm # Block RAM memory map file ++; # User design - pick from xflow command line ++-uc .ucf; # ucf constraints ++.ngd; # Name of NGD file. Filebase same as design filebase ++End Program ngdbuild ++ ++# ++# Options for Mapper ++# ++# Type "map -h " for a detailed list of map command line options ++# ++Program map ++-o _map.ncd; # Output Mapped ncd file ++#-fp .mfp; # Floorplan file ++.ngd; # Input NGD file ++.pcf; # Physical constraints file ++END Program map ++ ++# ++# Options for Post Map Trace ++# ++# Type "trce -h" for a detailed list of trce command line options ++# ++Program post_map_trce ++-e 3; # Produce error report limited to 3 items per constraint ++#-o _map.twr; # Output trace report file ++-xml _map.twx; # Output XML version of the timing report ++#-tsi _map.tsi; # Produce Timing Specification Interaction report ++_map.ncd; # Input mapped ncd ++.pcf; # Physical constraints file ++END Program post_map_trce ++ ++# ++# Options for Place and Route ++# ++# Type "par -h" for a detailed list of par command line options ++# ++Program par ++-w; # Overwrite existing placed and routed ncd ++-ol 4; # Overall effort level ++-d 0; # Number of delay based cleanup passes ++_map.ncd; # Input mapped NCD file ++.ncd; # Output placed and routed NCD ++.pcf; # Input physical constraints file ++END Program par ++ ++# ++# Options for Post Par Trace ++# ++# Type "trce -h" for a detailed list of trce command line options ++# ++Program post_par_trce ++-e 3; # Produce error report limited to 3 items per constraint ++#-o .twr; # Output trace report file ++-xml .twx; # Output XML version of the timing report ++#-tsi .tsi; # Produce Timing Specification Interaction report ++.ncd; # Input placed and routed ncd ++.pcf; # Physical constraints file ++END Program post_par_trce ++ ++ diff --git a/uclinux-vplay-mixer.patch b/uclinux-vplay-mixer.patch new file mode 100644 index 0000000..7814bc4 --- /dev/null +++ b/uclinux-vplay-mixer.patch @@ -0,0 +1,29 @@ +--- uClinux/user/vplay/mixer.c ++++ uClinux/user/vplay/mixer.c +@@ -10,8 +10,11 @@ + */ + + #include ++#include + #include + #include ++#include ++#include + #include + + char *names[SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_NAMES; +@@ -105,6 +108,8 @@ main(int argc, char *argv[]) + for (foo = 0; foo < SOUND_MIXER_NRDEVICES && strcmp(names[foo], argv[1]); foo++); + + if (foo >= SOUND_MIXER_NRDEVICES) { ++ if (argc <= 2) ++ usage(); + + if (!strcmp("+rec", argv[1]) || !strcmp("-rec", argv[1])) { + for (dev = 0; dev < SOUND_MIXER_NRDEVICES && strcmp(names[dev], argv[2]); dev++); +@@ -159,4 +164,5 @@ main(int argc, char *argv[]) + } + + close(baz); ++ return 0; + } diff --git a/udev-ccw-renaming.patch b/udev-ccw-renaming.patch new file mode 100644 index 0000000..55a1ebf --- /dev/null +++ b/udev-ccw-renaming.patch @@ -0,0 +1,10 @@ +--- /root/origs/75-persistent-net-generator.rules 2007-04-07 20:26:53.000000000 +0200 ++++ /etc/udev/rules.d/75-persistent-net-generator.rules 2007-04-08 11:11:19.000000000 +0200 +@@ -1,6 +1,6 @@ + # these rules generate rules for persistent network device naming + +-ACTION=="add", SUBSYSTEM=="net", SUBSYSTEMS!="xen", \ ++ACTION=="add", SUBSYSTEM=="net", SUBSYSTEMS!="xen", SUBSYSTEMS!="ccwgroup",\ + KERNEL=="eth*|ath*|wlan*|ra*|sta*", \ + NAME!="?*", DRIVERS=="?*", GOTO="persistent_net_generator_do" + diff --git a/udev-restart.patch b/udev-restart.patch new file mode 100644 index 0000000..4a1f3f5 --- /dev/null +++ b/udev-restart.patch @@ -0,0 +1,61 @@ +diff --git a/udevcontrol.c b/udevcontrol.c +index a983f22..4220eda 100644 +--- a/udevcontrol.c ++++ b/udevcontrol.c +@@ -83,6 +83,8 @@ int main(int argc, char *argv[], char *e + ctrl_msg.type = UDEVD_CTRL_START_EXEC_QUEUE; + else if (!strcmp(arg, "reload_rules")) + ctrl_msg.type = UDEVD_CTRL_RELOAD_RULES; ++ else if (!strcmp(arg, "restart")) ++ ctrl_msg.type = UDEVD_CTRL_RESTART; + else if (!strncmp(arg, "log_priority=", strlen("log_priority="))) { + intval = (int *) ctrl_msg.buf; + val = &arg[strlen("log_priority=")]; +@@ -123,6 +125,7 @@ int main(int argc, char *argv[], char *e + " stop_exec_queue keep udevd from executing events, queue only\n" + " start_exec_queue execute events, flush queue\n" + " reload_rules reloads the rules files\n" ++ " restart tells udevd to restart itself\n" + " max_childs= maximum number of childs\n" + " max_childs_running= maximum number of childs running at the same time\n" + " --help print this help text\n\n"); +diff --git a/udevd.c b/udevd.c +index bb956b5..6e8f6df 100644 +--- a/udevd.c ++++ b/udevd.c +@@ -703,6 +703,13 @@ static void get_ctrl_msg(void) + info("udevd message (RELOAD_RULES) received"); + reload_config = 1; + break; ++ case UDEVD_CTRL_RESTART: { ++ char *argv[2] = { "/proc/self/exe", NULL }; ++ info("udevd message (RESTART) received"); ++ if (execve(argv[0], argv, environ) == -1) ++ err("unable to restart udevd: %s", strerror(errno)); ++ break; ++ } + default: + err("unknown control message type"); + } +@@ -847,6 +854,9 @@ static int init_udevd_socket(void) + + /* enable receiving of the sender credentials */ + setsockopt(udevd_sock, SOL_SOCKET, SO_PASSCRED, &feature_on, sizeof(feature_on)); ++ retval = fcntl(udevd_sock, F_GETFD); ++ if (retval != -1) ++ fcntl(udevd_sock, F_SETFD, retval | FD_CLOEXEC); + + return 0; + } +diff --git a/udevd.h b/udevd.h +index fce86e7..d681da5 100644 +--- a/udevd.h ++++ b/udevd.h +@@ -46,6 +46,7 @@ enum udevd_ctrl_msg_type { + UDEVD_CTRL_SET_MAX_CHILDS, + UDEVD_CTRL_SET_MAX_CHILDS_RUNNING, + UDEVD_CTRL_RELOAD_RULES, ++ UDEVD_CTRL_RESTART, + }; + + struct udevd_ctrl_msg { diff --git a/udev-state.patch b/udev-state.patch new file mode 100644 index 0000000..c8ab155 --- /dev/null +++ b/udev-state.patch @@ -0,0 +1,64 @@ +Index: udev-096-r1.ebuild +=================================================================== +RCS file: /var/cvsroot/gentoo-x86/sys-fs/udev/udev-096-r1.ebuild,v +retrieving revision 1.2 +diff -u -p -r1.2 udev-096-r1.ebuild +--- udev-096-r1.ebuild 19 Jul 2006 17:13:39 -0000 1.2 ++++ udev-096-r1.ebuild 27 Aug 2006 20:58:56 -0000 +@@ -2,7 +2,7 @@ + # Distributed under the terms of the GNU General Public License v2 + # $Header: /var/cvsroot/gentoo-x86/sys-fs/udev/udev-096-r1.ebuild,v 1.2 2006/07/19 17:13:39 azarah Exp $ + +-inherit eutils flag-o-matic ++inherit eutils flag-o-matic multilib + + DESCRIPTION="Linux dynamic and persistent device naming support (aka userspace devfs)" + HOMEPAGE="http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html" +@@ -94,7 +94,7 @@ src_install() { + dosbin udevcontrol || die "Required binary not installed properly" + dosbin udevsettle || die "Required binary not installed properly" + # Helpers +- exeinto /lib/udev ++ exeinto /$(get_libdir)/udev + doexe extras/run_directory/udev_run_devd || die "Required helper not installed properly" + doexe extras/run_directory/udev_run_hotplugd || die "Required helper not installed properly" + doexe extras/ata_id/ata_id || die "Required helper not installed properly" +@@ -105,6 +105,7 @@ src_install() { + doexe extras/cdrom_id/cdrom_id || die "Required helper not installed properly" + doexe extras/dasd_id/dasd_id || die "Required helper not installed properly" + doexe extras/edd_id/edd_id || die "Required helper not installed properly" ++ keepdir /$(get_libdir)/udev/state + + # vol_id library (needed by mount and HAL) + dolib extras/volume_id/lib/*.a extras/volume_id/lib/*.so* +@@ -174,6 +175,11 @@ src_install() { + } + + pkg_preinst() { ++ if [[ -d ${ROOT}/$(get_libdir)/udev-state ]] ; then ++ mv -f "${ROOT}"/$(get_libdir)/udev-state/* "${D}"/$(get_libdir)/udev/state/ ++ rm -r "${ROOT}"/$(get_libdir)/udev-state ++ fi ++ + if [ -f "${ROOT}/etc/udev/udev.config" -a \ + ! -f "${ROOT}/etc/udev/udev.rules" ] + then +Index: files/udev-start-096.sh +=================================================================== +RCS file: /var/cvsroot/gentoo-x86/sys-fs/udev/files/udev-start-096.sh,v +retrieving revision 1.1 +diff -u -p -r1.1 udev-start-096.sh +--- files/udev-start-096.sh 15 Jul 2006 17:16:52 -0000 1.1 ++++ files/udev-start-096.sh 27 Aug 2006 20:58:56 -0000 +@@ -94,9 +94,9 @@ main() { + + # Actually get udev rolling + if [[ ${RC_DEVICE_TARBALL} == "yes" && \ +- -s /lib/udev-state/devices.tar.bz2 ]] ; then ++ -s /lib/udev/state/devices.tar.bz2 ]] ; then + ebegin "Populating /dev with saved device nodes" +- try tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev ++ try tar -jxpf /lib/udev/state/devices.tar.bz2 -C /dev + eend $? + fi + diff --git a/util-linux-autogen-set.patch b/util-linux-autogen-set.patch new file mode 100644 index 0000000..96eade2 --- /dev/null +++ b/util-linux-autogen-set.patch @@ -0,0 +1,12 @@ +diff --git a/autogen.sh b/autogen.sh +index d730a96..5ef9e8b 100755 +--- a/autogen.sh ++++ b/autogen.sh +@@ -60,6 +60,7 @@ test -f mount/mount.c || { + exit 1 + } + ++set -e + autopoint --force + libtoolize --copy --force + aclocal -I m4 diff --git a/util-linux-fdisk-check-change-return.patch b/util-linux-fdisk-check-change-return.patch new file mode 100644 index 0000000..3cf3558 --- /dev/null +++ b/util-linux-fdisk-check-change-return.patch @@ -0,0 +1,121 @@ +diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c +index 292b7a8..56ea38d 100644 +--- a/fdisk/fdisk.c ++++ b/fdisk/fdisk.c +@@ -1414,17 +1414,21 @@ change_sysid(void) { + if (sys == origsys) + break; + if (sun_label) { +- sun_change_sysid(i, sys); ++ ptes[i].changed = sun_change_sysid(i, sys); + } else + if (sgi_label) { +- sgi_change_sysid(i, sys); +- } else ++ ptes[i].changed = sgi_change_sysid(i, sys); ++ } else { + p->sys_ind = sys; +- printf (_("Changed system type of partition %d " +- "to %x (%s)\n"), i + 1, sys, +- (temp = partition_type(sys)) ? temp : +- _("Unknown")); +- ptes[i].changed = 1; ++ ptes[i].changed = 1; ++ } ++ temp = partition_type(sys) ? : _("Unknown"); ++ if (ptes[i].changed) ++ printf (_("Changed system type of partition %d " ++ "to %x (%s)\n"), i + 1, sys, temp); ++ else ++ printf (_("System type of partition %d is unchanged" ++ "to %x (%s)\n"), i + 1, sys, temp); + if (is_dos_partition(origsys) || + is_dos_partition(sys)) + dos_changed = 1; +diff --git a/fdisk/fdisksgilabel.c b/fdisk/fdisksgilabel.c +index e1b3829..7e189fb 100644 +--- a/fdisk/fdisksgilabel.c ++++ b/fdisk/fdisksgilabel.c +@@ -537,12 +537,12 @@ verify_sgi(int verbose) + return (gap > 0) ? 1 : (gap == 0) ? 0 : -1; + } + +-void ++int + sgi_change_sysid(int i, int sys) + { + if (sgi_get_num_sectors(i) == 0) /* caught already before, ... */ { + printf(_("Sorry You may change the Tag of non-empty partitions.\n")); +- return; ++ return 0; + } + if (((sys != ENTIRE_DISK) && (sys != SGI_VOLHDR)) + && (sgi_get_start_sector(i)<1)) { +@@ -553,9 +553,10 @@ sgi_change_sysid(int i, int sys) + "Only the \"SGI volume\" entire disk section may violate this.\n" + "Type YES if you are sure about tagging this partition differently.\n")); + if (strcmp (line_ptr, _("YES\n"))) +- return; ++ return 0; + } + sgilabel->partitions[i].id = SSWAP32(sys); ++ return 1; + } + + /* returns partition index of first entry marked as entire disk */ +diff --git a/fdisk/fdisksgilabel.h b/fdisk/fdisksgilabel.h +index fe757bf..02b3e9d 100644 +--- a/fdisk/fdisksgilabel.h ++++ b/fdisk/fdisksgilabel.h +@@ -112,7 +112,7 @@ extern struct systypes sgi_sys_types[]; + extern void sgi_nolabel( void ); + extern int check_sgi_label( void ); + extern void sgi_list_table( int xtra ); +-extern void sgi_change_sysid( int i, int sys ); ++extern int sgi_change_sysid( int i, int sys ); + extern unsigned int sgi_get_start_sector( int i ); + extern unsigned int sgi_get_num_sectors( int i ); + extern int sgi_get_sysid( int i ); +diff --git a/fdisk/fdisksunlabel.c b/fdisk/fdisksunlabel.c +index f67aa26..60ade06 100644 +--- a/fdisk/fdisksunlabel.c ++++ b/fdisk/fdisksunlabel.c +@@ -530,7 +530,7 @@ void sun_delete_partition(int i) + part->num_sectors = 0; + } + +-void sun_change_sysid(int i, __u16 sys) ++int sun_change_sysid(int i, __u16 sys) + { + struct sun_partition *part = &sunlabel->partitions[i]; + struct sun_tag_flag *tag = &sunlabel->part_tags[i]; +@@ -543,7 +543,7 @@ void sun_change_sysid(int i, __u16 sys) + "Type YES if you're very sure you would like that partition\n" + "tagged with 82 (Linux swap): ")); + if (strcmp (line_ptr, _("YES\n"))) +- return; ++ return 0; + } + switch (sys) { + case SUN_TAG_SWAP: +@@ -558,6 +558,7 @@ void sun_change_sysid(int i, __u16 sys) + break; + } + tag->tag = SSWAP16(sys); ++ return 1; + } + + void sun_list_table(int xtra) +diff --git a/fdisk/fdisksunlabel.h b/fdisk/fdisksunlabel.h +index c8e0698..fba67f7 100644 +--- a/fdisk/fdisksunlabel.h ++++ b/fdisk/fdisksunlabel.h +@@ -82,7 +82,7 @@ extern int check_sun_label(void); + extern void sun_nolabel(void); + extern void create_sunlabel(void); + extern void sun_delete_partition(int i); +-extern void sun_change_sysid(int i, __u16 sys); ++extern int sun_change_sysid(int i, __u16 sys); + extern void sun_list_table(int xtra); + extern void verify_sun(void); + extern void add_sun_partition(int n, int sys); diff --git a/util-linux-mount-bg-fstab.patch b/util-linux-mount-bg-fstab.patch new file mode 100644 index 0000000..e6d79c2 --- /dev/null +++ b/util-linux-mount-bg-fstab.patch @@ -0,0 +1,97 @@ +--- util-linux-2.13-pre6/mount/mount.c 2005-08-14 11:16:33.000000000 -0400 ++++ util-linux-2.13-pre6-new/mount/mount.c 2006-03-18 00:25:50.000000000 -0500 +@@ -100,9 +100,10 @@ struct opt_map { + #define MS_GROUP 0x08000000 + #define MS_COMMENT 0x00020000 + #define MS_LOOP 0x00010000 ++#define MS_BG 0x04000000 + + /* Options that we keep the mount system call from seeing. */ +-#define MS_NOSYS (MS_NOAUTO|MS_USERS|MS_USER|MS_COMMENT|MS_LOOP) ++#define MS_NOSYS (MS_NOAUTO|MS_USERS|MS_USER|MS_COMMENT|MS_LOOP|MS_BG) + + /* Options that we keep from appearing in the options field in the mtab. */ + #define MS_NOMTAB (MS_REMOUNT|MS_NOAUTO|MS_USERS|MS_USER) +@@ -143,6 +144,7 @@ static const struct opt_map opt_map[] = + { "comment", 0, 0, MS_COMMENT}, /* fstab comment only (kudzu,_netdev)*/ + + /* add new options here */ ++ { "bg", 1, 0, MS_BG }, /* fork this mount into the background */ + #ifdef MS_NOSUB + { "sub", 0, 1, MS_NOSUB }, /* allow submounts */ + { "nosub", 0, 0, MS_NOSUB }, /* don't allow submounts */ +@@ -791,6 +793,7 @@ try_mount_one (const char *spec0, const + const char *loopdev = 0, *loopfile = 0; + struct stat statbuf; + int nfs_mount_version = 0; /* any version */ ++ pid_t pid = -1; + + /* copies for freeing on exit */ + const char *opts1, *spec1, *node1, *types1, *extra_opts1; +@@ -850,28 +853,41 @@ retry_nfs: + + block_signals (SIG_BLOCK); + +- if (!fake) +- mnt5_res = guess_fstype_and_mount (spec, node, &types, flags & ~MS_NOSYS, +- mount_opts); ++ if (!fake) { ++ /* Don't bother checking if fork failed because if it does, we will just ++ * act as if MS_BG was not specified in the first place */ ++ if (flags & MS_BG) ++ pid = fork(); ++ if (pid == -1 || pid == 0) ++ mnt5_res = guess_fstype_and_mount (spec, node, &types, flags & ~MS_NOSYS, ++ mount_opts); ++ } + + if (fake || mnt5_res == 0) { + /* Mount succeeded, report this (if verbose) and write mtab entry. */ + if (loop) + opt_loopdev = loopdev; + +- update_mtab_entry(loop ? loopfile : spec, ++ if (pid == -1 || pid == 0) { ++ update_mtab_entry(loop ? loopfile : spec, + node, + types ? types : "unknown", + fix_opts_string (flags & ~MS_NOMTAB, extra_opts, user), + flags, + freq, + pass); ++ if (pid == 0) ++ exit(mnt5_res); ++ } + + block_signals (SIG_UNBLOCK); + res = 0; + goto out; + } + ++ if (pid == 0) ++ exit(mnt5_res); ++ + mnt_err = errno; + + if (loop) +@@ -1335,9 +1351,8 @@ do_mount_all (char *types, char *options + if (optfork) { + p = fork(); + if (p == -1) { +- int errsv = errno; + error(_("mount: cannot fork: %s"), +- strerror (errsv)); ++ strerror (errno)); + } + else if (p != 0) + cp->pid = p; +@@ -1368,7 +1383,8 @@ do_mount_all (char *types, char *options + if(waitpid(cp->pid, &ret, 0) == -1) { + if (errno == EINTR) + goto keep_waiting; +- perror("waitpid"); ++ error(_("mount: cannot waitpid: %s"), ++ strerror (errno)); + } else if (WIFEXITED(ret)) + status |= WEXITSTATUS(ret); + else diff --git a/util-linux-no-error-on-fake-mount.patch b/util-linux-no-error-on-fake-mount.patch new file mode 100644 index 0000000..b2f2d57 --- /dev/null +++ b/util-linux-no-error-on-fake-mount.patch @@ -0,0 +1,13 @@ +diff --git a/mount/mount.c b/mount/mount.c +index 63e6731..309fa10 100644 +--- a/mount/mount.c ++++ b/mount/mount.c +@@ -1746,7 +1746,7 @@ main(int argc, char *argv[]) { + case 0: + /* mount -a */ + result = do_mount_all (types, options, test_opts); +- if (result == 0 && verbose) ++ if (result == 0 && verbose && !fake) + error(_("nothing was mounted")); + break; + diff --git a/util-linux-readprofile-stext.patch b/util-linux-readprofile-stext.patch new file mode 100644 index 0000000..bf6246e --- /dev/null +++ b/util-linux-readprofile-stext.patch @@ -0,0 +1,14 @@ +diff --git a/sys-utils/readprofile.c b/sys-utils/readprofile.c +index 43991f2..978e6c1 100644 +--- a/sys-utils/readprofile.c ++++ b/sys-utils/readprofile.c +@@ -306,7 +306,8 @@ main(int argc, char **argv) { + prgname, mapFile, maplineno); + exit(1); + } +- if (!strcmp(fn_name,"_stext")) /* only elf works like this */ { ++ /* only elf works like this */ ++ if (!strcmp(fn_name,"_stext") || !strcmp(fn_name,"__stext")) { + add0 = fn_add; + break; + } diff --git a/util-linux-swapon-cleanup.patch b/util-linux-swapon-cleanup.patch new file mode 100644 index 0000000..b7d67dc --- /dev/null +++ b/util-linux-swapon-cleanup.patch @@ -0,0 +1,85 @@ +diff --git a/mount/swapon.c b/mount/swapon.c +index a8e5cc1..e5f945e 100644 +--- a/mount/swapon.c ++++ b/mount/swapon.c +@@ -11,24 +11,29 @@ + #include + #include + #include ++#include + #include "xmalloc.h" + #include "swap_constants.h" + #include "nls.h" + #include "fsprobe.h" + #include "realpath.h" + ++#ifdef HAVE_SYS_SWAP_H ++# include ++#endif ++ ++#ifndef SWAPON_HAS_TWO_ARGS ++/* libc is insane, let's call the kernel */ ++# include ++# define swapon(path, flags) syscall(SYS_swapon, path, flags) ++# define swapoff(path) syscall(SYS_swapoff, path) ++#endif ++ + #define streq(s, t) (strcmp ((s), (t)) == 0) + + #define _PATH_FSTAB "/etc/fstab" + #define PROC_SWAPS "/proc/swaps" + +-#ifdef SWAPON_HAS_TWO_ARGS +-# include +-# include +-#endif +- +-#define SWAPON_NEEDS_TWO_ARGS +- + #define QUIET 1 + + int all = 0; +@@ -75,24 +80,6 @@ swapoff_usage(FILE *fp, int n) { + exit(n); + } + +-#ifdef SWAPON_HAS_TWO_ARGS +-#define SWAPON_NEEDS_TWO_ARGS +-#endif +- +-#if defined(SWAPON_NEEDS_TWO_ARGS) && !defined(SWAPON_HAS_TWO_ARGS) +-/* We want a swapon with two args, but have an old libc. +- Build the kernel call by hand. */ +-#include +-static +-_syscall2(int, swapon, const char *, path, int, flags); +-static +-_syscall1(int, swapoff, const char *, path); +-#else +-/* just do as libc says */ +-#include +-#endif +- +- + /* + * contents of /proc/swaps + */ +@@ -219,7 +206,6 @@ do_swapon(const char *orig_special, int prio) { + } + } + +-#ifdef SWAPON_NEEDS_TWO_ARGS + { + int flags = 0; + +@@ -234,9 +220,7 @@ do_swapon(const char *orig_special, int prio) { + #endif + status = swapon(special, flags); + } +-#else +- status = swapon(special); +-#endif ++ + if (status < 0) { + int errsv = errno; + fprintf(stderr, "%s: %s: %s\n", diff --git a/util-linux-swapon-headers.patch b/util-linux-swapon-headers.patch new file mode 100644 index 0000000..51cbb0e --- /dev/null +++ b/util-linux-swapon-headers.patch @@ -0,0 +1,16 @@ +diff --git a/mount/swapon.c b/mount/swapon.c +index a8e5cc1..54b1178 100644 +--- a/mount/swapon.c ++++ b/mount/swapon.c +@@ -22,8 +22,10 @@ + #define _PATH_FSTAB "/etc/fstab" + #define PROC_SWAPS "/proc/swaps" + +-#ifdef SWAPON_HAS_TWO_ARGS ++#ifdef HAVE_ASM_PAGE_H + # include ++#endif ++#ifdef HAVE_SYS_SWAP_H + # include + #endif + diff --git a/util-linux-tests-source.patch b/util-linux-tests-source.patch new file mode 100644 index 0000000..21e9784 --- /dev/null +++ b/util-linux-tests-source.patch @@ -0,0 +1,514 @@ +diff --git a/tests/run.sh b/tests/run.sh +index 51b7f73..a731cc1 100755 +--- a/tests/run.sh ++++ b/tests/run.sh +@@ -1,6 +1,6 @@ + #!/bin/bash + +-. commands.sh ++. ./commands.sh + + echo + echo "------------------ Utils-linux-ng regression tests ------------------" +diff --git a/tests/ts-cal-1 b/tests/ts-cal-1 +index 0924201..14aa269 100755 +--- a/tests/ts-cal-1 ++++ b/tests/ts-cal-1 +@@ -15,8 +15,8 @@ + # GNU General Public License for more details. + # + +-. commands.sh +-. functions.sh ++. ./commands.sh ++. ./functions.sh + + TS_COMPONENT="cal" + TS_DESC="1 month" +diff --git a/tests/ts-cal-3 b/tests/ts-cal-3 +index e8da56f..6a6ad89 100755 +--- a/tests/ts-cal-3 ++++ b/tests/ts-cal-3 +@@ -15,8 +15,8 @@ + # GNU General Public License for more details. + # + +-. commands.sh +-. functions.sh ++. ./commands.sh ++. ./functions.sh + + TS_COMPONENT="cal" + TS_DESC="3 months" +diff --git a/tests/ts-cal-y b/tests/ts-cal-y +index f9c60bd..e70eb15 100755 +--- a/tests/ts-cal-y ++++ b/tests/ts-cal-y +@@ -15,8 +15,8 @@ + # GNU General Public License for more details. + # + +-. commands.sh +-. functions.sh ++. ./commands.sh ++. ./functions.sh + + TS_COMPONENT="cal" + TS_DESC="year" +diff --git a/tests/ts-col-multibyte b/tests/ts-col-multibyte +index 4ca11cc..cc478df 100755 +--- a/tests/ts-col-multibyte ++++ b/tests/ts-col-multibyte +@@ -1,7 +1,7 @@ + #!/bin/bash + +-. commands.sh +-. functions.sh ++. ./commands.sh ++. ./functions.sh + + TS_COMPONENT="col" + TS_DESC="multibyte" +diff --git a/tests/ts-cramfs-mkfs b/tests/ts-cramfs-mkfs +index 4d7ca23..1738382 100755 +--- a/tests/ts-cramfs-mkfs ++++ b/tests/ts-cramfs-mkfs +@@ -17,8 +17,8 @@ + + # Test cramfs + +-. commands.sh +-. functions.sh ++. ./commands.sh ++. ./functions.sh + + TS_COMPONENT="mkfs.cramfs" + TS_DESC="mkfs" +diff --git a/tests/ts-fstab-devname b/tests/ts-fstab-devname +index 64ab8e5..20fe24f 100755 +--- a/tests/ts-fstab-devname ++++ b/tests/ts-fstab-devname +@@ -15,8 +15,8 @@ + # GNU General Public License for more details. + # + +-. commands.sh +-. functions.sh ++. ./commands.sh ++. ./functions.sh + + TS_COMPONENT="fstab" + TS_DESC="devname" +diff --git a/tests/ts-fstab-devname2label b/tests/ts-fstab-devname2label +index 96ce9ac..40d83e0 100755 +--- a/tests/ts-fstab-devname2label ++++ b/tests/ts-fstab-devname2label +@@ -19,8 +19,8 @@ + # mount by devname -- with an LABEL in fstab + # + +-. commands.sh +-. functions.sh ++. ./commands.sh ++. ./functions.sh + + TS_COMPONENT="fstab" + TS_DESC="devname2label" +diff --git a/tests/ts-fstab-devname2uuid b/tests/ts-fstab-devname2uuid +index e81897e..ead5793 100755 +--- a/tests/ts-fstab-devname2uuid ++++ b/tests/ts-fstab-devname2uuid +@@ -19,8 +19,8 @@ + # mount by devname -- with an UUID in fstab + # + +-. commands.sh +-. functions.sh ++. ./commands.sh ++. ./functions.sh + + TS_COMPONENT="fstab" + TS_DESC="devname2uuid" +diff --git a/tests/ts-fstab-label b/tests/ts-fstab-label +index b6be12d..97b0684 100755 +--- a/tests/ts-fstab-label ++++ b/tests/ts-fstab-label +@@ -15,8 +15,8 @@ + # GNU General Public License for more details. + # + +-. commands.sh +-. functions.sh ++. ./commands.sh ++. ./functions.sh + + TS_COMPONENT="fstab" + TS_DESC="label" +diff --git a/tests/ts-fstab-label2devname b/tests/ts-fstab-label2devname +index 569e0a0..788b755 100755 +--- a/tests/ts-fstab-label2devname ++++ b/tests/ts-fstab-label2devname +@@ -19,8 +19,8 @@ + # mount by LABEL -- with an devname in fstab + # + +-. commands.sh +-. functions.sh ++. ./commands.sh ++. ./functions.sh + + TS_COMPONENT="fstab" + TS_DESC="label2devname" +diff --git a/tests/ts-fstab-label2uuid b/tests/ts-fstab-label2uuid +index 9579a42..1635b15 100755 +--- a/tests/ts-fstab-label2uuid ++++ b/tests/ts-fstab-label2uuid +@@ -19,8 +19,8 @@ + # mount by LABEL -- with an UUID in fstab + # + +-. commands.sh +-. functions.sh ++. ./commands.sh ++. ./functions.sh + + TS_COMPONENT="fstab" + TS_DESC="label2uuid" +diff --git a/tests/ts-fstab-symlink b/tests/ts-fstab-symlink +index d8174fd..ab0573b 100755 +--- a/tests/ts-fstab-symlink ++++ b/tests/ts-fstab-symlink +@@ -15,8 +15,8 @@ + # GNU General Public License for more details. + # + +-. commands.sh +-. functions.sh ++. ./commands.sh ++. ./functions.sh + + TS_COMPONENT="fstab" + TS_DESC="symlink" +diff --git a/tests/ts-fstab-uuid b/tests/ts-fstab-uuid +index f8a8d5c..37e14d7 100755 +--- a/tests/ts-fstab-uuid ++++ b/tests/ts-fstab-uuid +@@ -15,8 +15,8 @@ + # GNU General Public License for more details. + # + +-. commands.sh +-. functions.sh ++. ./commands.sh ++. ./functions.sh + + TS_COMPONENT="fstab" + TS_DESC="uuid" +diff --git a/tests/ts-fstab-uuid2devname b/tests/ts-fstab-uuid2devname +index da0e03c..ba3c6d7 100755 +--- a/tests/ts-fstab-uuid2devname ++++ b/tests/ts-fstab-uuid2devname +@@ -19,8 +19,8 @@ + # mount by UUID -- with an devname in fstab + # + +-. commands.sh +-. functions.sh ++. ./commands.sh ++. ./functions.sh + + TS_COMPONENT="fstab" + TS_DESC="uuid2devname" +diff --git a/tests/ts-fstab-uuid2label b/tests/ts-fstab-uuid2label +index 7f4c0af..b82c776 100755 +--- a/tests/ts-fstab-uuid2label ++++ b/tests/ts-fstab-uuid2label +@@ -19,8 +19,8 @@ + # mount by UUID -- with an LABEL in fstab + # + +-. commands.sh +-. functions.sh ++. ./commands.sh ++. ./functions.sh + + TS_COMPONENT="fstab" + TS_DESC="uuid2label" +diff --git a/tests/ts-hwclock-systohc b/tests/ts-hwclock-systohc +index 6375864..56d600b 100755 +--- a/tests/ts-hwclock-systohc ++++ b/tests/ts-hwclock-systohc +@@ -17,8 +17,8 @@ + + # Test cramfs + +-. commands.sh +-. functions.sh ++. ./commands.sh ++. ./functions.sh + + TS_COMPONENT="hwclock" + TS_DESC="systohc" +diff --git a/tests/ts-ipcs-headers b/tests/ts-ipcs-headers +index 601bea8..f8dca77 100755 +--- a/tests/ts-ipcs-headers ++++ b/tests/ts-ipcs-headers +@@ -1,7 +1,7 @@ + #!/bin/bash + +-. commands.sh +-. functions.sh ++. ./commands.sh ++. ./functions.sh + + TS_COMPONENT="ipcs" + TS_DESC="headers" +diff --git a/tests/ts-ipcs-limits b/tests/ts-ipcs-limits +index 33624de..a6dcb93 100755 +--- a/tests/ts-ipcs-limits ++++ b/tests/ts-ipcs-limits +@@ -1,7 +1,7 @@ + #!/bin/bash + +-. commands.sh +-. functions.sh ++. ./commands.sh ++. ./functions.sh + + TS_COMPONENT="ipcs" + TS_DESC="limits overflow" +@@ -11,7 +11,7 @@ if [ $UID != 0 ]; then + ts_skip_nonroot + fi + +-. ts-ipcs.sh ++. ./ts-ipcs.sh + + ts_init "$*" + +diff --git a/tests/ts-ipcs-limits2 b/tests/ts-ipcs-limits2 +index 1c8307f..4ac0d6b 100755 +--- a/tests/ts-ipcs-limits2 ++++ b/tests/ts-ipcs-limits2 +@@ -1,12 +1,12 @@ + #!/bin/bash + +-. commands.sh +-. functions.sh ++. ./commands.sh ++. ./functions.sh + + TS_COMPONENT="ipcs" + TS_DESC="basic limits" + +-. ts-ipcs.sh ++. ./ts-ipcs.sh + + ts_init "$*" + +diff --git a/tests/ts-login-checktty b/tests/ts-login-checktty +index f31efab..8f375fb 100755 +--- a/tests/ts-login-checktty ++++ b/tests/ts-login-checktty +@@ -1,7 +1,7 @@ + #!/bin/bash + +-. commands.sh +-. functions.sh ++. ./commands.sh ++. ./functions.sh + + TS_COMPONENT="login" + TS_DESC="checktty" +diff --git a/tests/ts-look-separator b/tests/ts-look-separator +index 0a43df8..dfd1bb6 100755 +--- a/tests/ts-look-separator ++++ b/tests/ts-look-separator +@@ -12,8 +12,8 @@ + # uniq > words + # + +-. commands.sh +-. functions.sh ++. ./commands.sh ++. ./functions.sh + + TS_COMPONENT="look" + TS_DESC="separator" +diff --git a/tests/ts-mount-devname b/tests/ts-mount-devname +index cf7450c..2d96ea7 100755 +--- a/tests/ts-mount-devname ++++ b/tests/ts-mount-devname +@@ -15,8 +15,8 @@ + # GNU General Public License for more details. + # + +-. commands.sh +-. functions.sh ++. ./commands.sh ++. ./functions.sh + + TS_COMPONENT="mount" + TS_DESC="devname" +diff --git a/tests/ts-mount-label b/tests/ts-mount-label +index f5d0bef..39afd7e 100755 +--- a/tests/ts-mount-label ++++ b/tests/ts-mount-label +@@ -15,8 +15,8 @@ + # GNU General Public License for more details. + # + +-. commands.sh +-. functions.sh ++. ./commands.sh ++. ./functions.sh + + TS_COMPONENT="mount" + TS_DESC="label" +diff --git a/tests/ts-mount-move b/tests/ts-mount-move +index 522b634..badc583 100755 +--- a/tests/ts-mount-move ++++ b/tests/ts-mount-move +@@ -4,8 +4,8 @@ + # test for mount --move and --bind + # + +-. commands.sh +-. functions.sh ++. ./commands.sh ++. ./functions.sh + + TS_COMPONENT="mount" + TS_DESC="move " +diff --git a/tests/ts-mount-mtablock b/tests/ts-mount-mtablock +index edcf723..35bbda0 100755 +--- a/tests/ts-mount-mtablock ++++ b/tests/ts-mount-mtablock +@@ -1,7 +1,7 @@ + #!/bin/bash + +-. commands.sh +-. functions.sh ++. ./commands.sh ++. ./functions.sh + + TS_COMPONENT="mount" + TS_DESC="mtablock" +diff --git a/tests/ts-mount-paths b/tests/ts-mount-paths +index 7a8e9ff..2a9b63a 100755 +--- a/tests/ts-mount-paths ++++ b/tests/ts-mount-paths +@@ -1,7 +1,7 @@ + #!/bin/bash + +-. commands.sh +-. functions.sh ++. ./commands.sh ++. ./functions.sh + + TS_COMPONENT="mount" + TS_DESC="basic paths" +diff --git a/tests/ts-mount-remount b/tests/ts-mount-remount +index 8a2e59e..7ed3447 100755 +--- a/tests/ts-mount-remount ++++ b/tests/ts-mount-remount +@@ -3,8 +3,8 @@ + # + # test for mount -o remount,ro + # +-. commands.sh +-. functions.sh ++. ./commands.sh ++. ./functions.sh + + TS_COMPONENT="mount" + TS_DESC="remount" +diff --git a/tests/ts-mount-special b/tests/ts-mount-special +index aeffc25..0e5206f 100755 +--- a/tests/ts-mount-special ++++ b/tests/ts-mount-special +@@ -4,8 +4,8 @@ + # test for /sbin/mount. suuport + # + +-. commands.sh +-. functions.sh ++. ./commands.sh ++. ./functions.sh + + TS_COMPONENT="mount" + TS_DESC="special program" +diff --git a/tests/ts-mount-uuid b/tests/ts-mount-uuid +index 64d934c..84dbe05 100755 +--- a/tests/ts-mount-uuid ++++ b/tests/ts-mount-uuid +@@ -15,8 +15,8 @@ + # GNU General Public License for more details. + # + +-. commands.sh +-. functions.sh ++. ./commands.sh ++. ./functions.sh + + TS_COMPONENT="mount" + TS_DESC="uuid" +diff --git a/tests/ts-namei-logic b/tests/ts-namei-logic +index 2c44c60..2afdb39 100755 +--- a/tests/ts-namei-logic ++++ b/tests/ts-namei-logic +@@ -1,7 +1,7 @@ + #!/bin/bash + +-. commands.sh +-. functions.sh ++. ./commands.sh ++. ./functions.sh + + TS_COMPONENT="namei" + TS_DESC="logic" +diff --git a/tests/ts-swapon-devname b/tests/ts-swapon-devname +index 4193fb0..4ec540d 100755 +--- a/tests/ts-swapon-devname ++++ b/tests/ts-swapon-devname +@@ -15,8 +15,8 @@ + # GNU General Public License for more details. + # + +-. commands.sh +-. functions.sh ++. ./commands.sh ++. ./functions.sh + + TS_COMPONENT="swapon" + TS_DESC="devname" +diff --git a/tests/ts-swapon-label b/tests/ts-swapon-label +index 0f79340..0706ee9 100755 +--- a/tests/ts-swapon-label ++++ b/tests/ts-swapon-label +@@ -15,8 +15,8 @@ + # GNU General Public License for more details. + # + +-. commands.sh +-. functions.sh ++. ./commands.sh ++. ./functions.sh + + TS_COMPONENT="swapon" + TS_DESC="label" +diff --git a/tests/ts-swapon-uuid b/tests/ts-swapon-uuid +index 14d79ca..30f5021 100755 +--- a/tests/ts-swapon-uuid ++++ b/tests/ts-swapon-uuid +@@ -15,8 +15,8 @@ + # GNU General Public License for more details. + # + +-. commands.sh +-. functions.sh ++. ./commands.sh ++. ./functions.sh + + TS_COMPONENT="swapon" + TS_DESC="uuid" diff --git a/vfb-module-kconfig-docs.patch b/vfb-module-kconfig-docs.patch new file mode 100644 index 0000000..942e9b8 --- /dev/null +++ b/vfb-module-kconfig-docs.patch @@ -0,0 +1,16 @@ +Document required module options in Kconfig for loading the vfb module. + +diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig +index 6533b0f..6a68a43 100644 +--- a/drivers/video/Kconfig ++++ b/drivers/video/Kconfig +@@ -1609,7 +1609,8 @@ config FB_VIRTUAL + kernel option `video=vfb:'. + + To compile this driver as a module, choose M here: the +- module will be called vfb. ++ module will be called vfb. In order to load it, you must use ++ the vfb_enable=1 option. + + If unsure, say N. + if VT diff --git a/visibility_hidden.m4-AC_DEFINE.patch b/visibility_hidden.m4-AC_DEFINE.patch new file mode 100644 index 0000000..dc551d8 --- /dev/null +++ b/visibility_hidden.m4-AC_DEFINE.patch @@ -0,0 +1,30 @@ +Index: ./acl/m4/visibility_hidden.m4 +=================================================================== +RCS file: /cvs/xfs-cmds/acl/m4/visibility_hidden.m4,v +retrieving revision 1.1 +diff -u -p -r1.1 visibility_hidden.m4 +--- ./acl/m4/visibility_hidden.m4 20 Feb 2003 03:31:38 -0000 1.1 ++++ ./acl/m4/visibility_hidden.m4 10 Aug 2006 02:56:00 -0000 +@@ -17,6 +17,6 @@ EOF + rm -f conftest.[cs] + ]) + if test $libc_cv_visibility_attribute = yes; then +- AC_DEFINE(HAVE_VISIBILITY_ATTRIBUTE) ++ AC_DEFINE(HAVE_VISIBILITY_ATTRIBUTE, [], [GCC supports visibility attributes]) + fi + ]) +Index: ./xfstests/m4/visibility_hidden.m4 +=================================================================== +RCS file: /cvs/xfs-cmds/xfstests/m4/visibility_hidden.m4,v +retrieving revision 1.1 +diff -u -p -r1.1 visibility_hidden.m4 +--- ./xfstests/m4/visibility_hidden.m4 19 May 2003 05:14:50 -0000 1.1 ++++ ./xfstests/m4/visibility_hidden.m4 10 Aug 2006 02:56:00 -0000 +@@ -17,6 +17,6 @@ EOF + rm -f conftest.[cs] + ]) + if test $libc_cv_visibility_attribute = yes; then +- AC_DEFINE(HAVE_VISIBILITY_ATTRIBUTE) ++ AC_DEFINE(HAVE_VISIBILITY_ATTRIBUTE, [], [GCC supports visibility attributes]) + fi + ]) diff --git a/watchdog-headers.patch b/watchdog-headers.patch new file mode 100644 index 0000000..bd705ee --- /dev/null +++ b/watchdog-headers.patch @@ -0,0 +1,98 @@ +--- src/nfsmount.c ++++ src/nfsmount.c +@@ -39,6 +39,7 @@ + #include + #include + #include ++#include + #include + #include + #include +--- src/pidfile.c ++++ src/pidfile.c +@@ -6,6 +6,10 @@ + + #include + #include ++#include ++#include ++#include ++#include + #include "extern.h" + #include "watch_err.h" + +--- src/shutdown.c ++++ src/shutdown.c +@@ -4,6 +4,10 @@ + #include "config.h" + #endif + ++#ifndef _GNU_SOURCE ++#define _GNU_SOURCE /* for getsid() */ ++#endif ++ + #include + #include + #include +@@ -14,6 +18,7 @@ + #include + #include + #include ++#include + #include + #include + #include +--- src/test_binary.c ++++ src/test_binary.c +@@ -7,6 +7,7 @@ + #include + #include + #include ++#include + #include + #include "extern.h" + #include "watch_err.h" +--- src/watchdog.c ++++ src/watchdog.c +@@ -11,6 +11,10 @@ + #include "config.h" + #endif + ++#ifndef _GNU_SOURCE ++#define _GNU_SOURCE ++#endif ++ + #include "extern.h" + + #include +@@ -22,8 +26,8 @@ + #include + #include + #include ++#include + #include +-#define __USE_GNU + #include + + #if !defined(__GLIBC__) /* __GLIBC__ */ +--- src/wd_keepalive.c ++++ src/wd_keepalive.c +@@ -15,6 +15,10 @@ + #include "config.h" + #endif + ++#ifndef _GNU_SOURCE ++#define _GNU_SOURCE ++#endif ++ + #include + #include + #include +@@ -24,7 +28,6 @@ + #include + #include + #include +-#define __USE_GNU + #include + #include + diff --git a/wine-debug-checks.patch b/wine-debug-checks.patch new file mode 100644 index 0000000..e96b65f --- /dev/null +++ b/wine-debug-checks.patch @@ -0,0 +1,62 @@ +2006-04-15 Mike Frysinger + + * libs/wine/Makefile.in (EXTRADEFS): Add @DLLDEFS@. + * libs/wine/debug.c: (parse_options): Compare WINEDEBUG runtime envvar to + WINE_NO_TRACE_MSGS and WINE_NO_DEBUG_MSGS compile time defines. + +--- libs/wine/Makefile.in ++++ libs/wine/Makefile.in +@@ -5,7 +5,7 @@ VPATH = @srcdir@ + LIBRARY = wine + SOVERSION = 1 + VERSCRIPT = $(SRCDIR)/wine.map +-EXTRADEFS = -D__WINESRC__ ++EXTRADEFS = -D__WINESRC__ @DLLDEFS@ + EXTRALIBS = $(LIBPORT) @DLLIBS@ @CRTLIBS@ + + C_SRCS = \ +--- libs/wine/debug.c ++++ libs/wine/debug.c +@@ -138,6 +138,26 @@ static void parse_options( const char *s + if (len != (p - opt)) continue; + if (!memcmp( opt, debug_classes[i], len )) /* found it */ + { ++#ifdef WINE_NO_DEBUG_MSGS ++ if (memcmp( opt, "trace", len ) != 0) ++ { ++ static const char error_msg[] = ++ "Unable to trace as Wine was configured without debug support.\n" ++ "You will need to rebuild wine with the --enable-debug configure option.\n"; ++ write( 2, error_msg, sizeof(error_msg) - 1 ); ++ exit(1); ++ } ++#endif ++#ifdef WINE_NO_TRACE_MSGS ++ if (memcmp( opt, "trace", len ) == 0) ++ { ++ static const char error_msg[] = ++ "Unable to trace as Wine was configured without trace support.\n" ++ "You will need to rebuild wine with the --enable-trace configure option.\n"; ++ write( 2, error_msg, sizeof(error_msg) - 1 ); ++ exit(1); ++ } ++#endif + if (*p == '+') set |= 1 << i; + else clear |= 1 << i; + break; +@@ -171,7 +191,14 @@ static void debug_usage(void) + " WINEDEBUG=[class]+xxx,[class]-yyy,...\n\n" + "Example: WINEDEBUG=+all,warn-heap\n" + " turns on all messages except warning heap messages\n" +- "Available message classes: err, warn, fixme, trace\n"; ++ "Available message classes: err, warn, fixme, trace\n" ++#ifdef WINE_NO_DEBUG_MSGS ++ "\n* err/warn/fixme support has been disabled due to --disable-debug\n" ++#endif ++#ifdef WINE_NO_TRACE_MSGS ++ "\n* trace support has been disabled due to --disable-trace\n" ++#endif ++ ; + write( 2, usage, sizeof(usage) - 1 ); + exit(1); + } diff --git a/xiptech-sdl-1.2.9.patch b/xiptech-sdl-1.2.9.patch new file mode 100644 index 0000000..14c9656 --- /dev/null +++ b/xiptech-sdl-1.2.9.patch @@ -0,0 +1,286 @@ +diff -Nur SDL-1.2.9.orig/config.sub SDL-1.2.9/config.sub +--- SDL-1.2.9.orig/config.sub 2004-05-06 11:55:06.000000000 -0400 ++++ SDL-1.2.9/config.sub 2006-05-08 08:01:42.000000000 -0400 +@@ -135,6 +135,9 @@ + ### recognize some manufacturers as not being operating systems, so we + ### can provide default operating systems below. + case $os in ++ -uclinux*) ++ os=-linux-gnu ++ ;; + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; +@@ -224,7 +227,8 @@ + case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. +- 1750a | 580 \ ++ bfin \ ++ | 1750a | 580 \ + | a29k \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ +diff -Nur SDL-1.2.9.orig/readme.537 SDL-1.2.9/readme.537 +--- SDL-1.2.9.orig/readme.537 1969-12-31 19:00:00.000000000 -0500 ++++ SDL-1.2.9/readme.537 2006-05-08 06:53:08.000000000 -0400 +@@ -0,0 +1,5 @@ ++1.configure ++CFLAGS="-Dunix" ./configure --host=bfin-uclinux --disable-threads --disable-pth --disable-pthreads --disable-sdl-dlopen --disable-esd --disable-video-x11 --disable-cdrom --with-pic=no --disable-arts --disable-shared ++ ++2.make ++./make +--- SDL-1.2.9.orig/src/video/fbcon/SDL_fbevents.c 2005-01-04 14:04:14.000000000 -0500 ++++ SDL-1.2.9/src/video/fbcon/SDL_fbevents.c 2006-05-08 08:02:28.000000000 -0400 +@@ -159,7 +159,7 @@ + int FB_EnterGraphicsMode(_THIS) + { + struct termios keyboard_termios; +- ++ int ret; + /* Set medium-raw keyboard mode */ + if ( (keyboard_fd >= 0) && !FB_InGraphicsMode(this) ) { + +@@ -184,6 +185,7 @@ + keyboard_fd = -1; + return(-1); + } ++ #if 0 //lee + if ( ioctl(keyboard_fd, KDGKBMODE, &saved_kbd_mode) < 0 ) { + SDL_SetError("Unable to get current keyboard mode"); + if ( keyboard_fd > 0 ) { +@@ -192,27 +194,31 @@ + keyboard_fd = -1; + return(-1); + } ++ #endif //lee + keyboard_termios = saved_kbd_termios; + keyboard_termios.c_lflag &= ~(ICANON | ECHO | ISIG); + keyboard_termios.c_iflag &= ~(ISTRIP | IGNCR | ICRNL | INLCR | IXOFF | IXON); + keyboard_termios.c_cc[VMIN] = 0; + keyboard_termios.c_cc[VTIME] = 0; ++ + if (tcsetattr(keyboard_fd, TCSAFLUSH, &keyboard_termios) < 0) { + FB_CloseKeyboard(this); + SDL_SetError("Unable to set terminal attributes"); + return(-1); + } ++ #if 0 //lee + /* This will fail if we aren't root or this isn't our tty */ +- if ( ioctl(keyboard_fd, KDSKBMODE, K_MEDIUMRAW) < 0 ) { ++ if ( (ret = ioctl(keyboard_fd, KDSKBMODE, K_MEDIUMRAW)) < 0 ) { + FB_CloseKeyboard(this); +- SDL_SetError("Unable to set keyboard in raw mode"); ++ SDL_SetError("Unable to set keyboard in raw mode %d",ret); + return(-1); + } +- if ( ioctl(keyboard_fd, KDSETMODE, KD_GRAPHICS) < 0 ) { ++ if ( (ret = ioctl(keyboard_fd, KDSETMODE, KD_GRAPHICS)) < 0 ) { + FB_CloseKeyboard(this); +- SDL_SetError("Unable to set keyboard in graphics mode"); ++ SDL_SetError("Unable to set keyboard in graphics mode %d",ret); + return(-1); + } ++ #endif //lee + } + return(keyboard_fd); + } +@@ -288,6 +299,8 @@ + /* Last resort, maybe our tty is a usable VT */ + current_vt = 0; + keyboard_fd = open("/dev/tty", O_RDWR); ++ //keyboard_fd = dup(0); ++ fprintf(stderr,"Last resort open /dev/tty=%d\n",keyboard_fd); + } + #ifdef DEBUG_KEYBOARD + fprintf(stderr, "Current VT: %d\n", current_vt); +@@ -295,14 +308,15 @@ + saved_kbd_mode = -1; + + /* Make sure that our input is a console terminal */ +- { int dummy; ++ //lee 2006-4-22 ++ /*{ int dummy; + if ( ioctl(keyboard_fd, KDGKBMODE, &dummy) < 0 ) { + close(keyboard_fd); + keyboard_fd = -1; + SDL_SetError("Unable to open a console terminal"); + } +- } +- ++ }*/ ++ + /* Set up keymap */ + FB_vgainitkeymaps(keyboard_fd); + } +@@ -891,7 +906,11 @@ + int scancode; + SDL_keysym keysym; + ++ ++ SDL_ResetKeyboard();//lee 5-5 ++ + nread = read(keyboard_fd, keybuf, BUFSIZ); ++ + for ( i=0; iscancode = scancode; ++ #if 0 ++ + keysym->sym = keymap[scancode]; ++ ++ #else //lee ++ ++ keysym->sym = 0; ++ if(scancode == 0x31) ++ keysym->sym = SDLK_1; ++ if(scancode == 0x35) ++ keysym->sym = SDLK_5; ++ else if(scancode == 0x44) ++ keysym->sym = SDLK_LEFT; ++ else if(scancode == 0x43) ++ keysym->sym = SDLK_RIGHT; ++ else if(scancode == 0x41) ++ keysym->sym = SDLK_UP; ++ else if(scancode == 0x42) ++ keysym->sym = SDLK_DOWN; ++ else if(scancode == 0x6f) ++ keysym->sym = SDLK_o; ++ else if(scancode == 0x6b) ++ keysym->sym = SDLK_k; ++ else if(scancode == 0x71) ++ keysym->sym = SDLK_q; ++ ++ #endif ++ + keysym->mod = KMOD_NONE; + ++ + /* If UNICODE is on, get the UNICODE value for the key */ + keysym->unicode = 0; + if ( SDL_TranslateUNICODE ) { +diff -Nur SDL-1.2.9.orig/src/video/fbcon/SDL_fbvideo.c SDL-1.2.9/src/video/fbcon/SDL_fbvideo.c +--- SDL-1.2.9.orig/src/video/fbcon/SDL_fbvideo.c 2005-02-12 13:03:54.000000000 -0500 ++++ SDL-1.2.9/src/video/fbcon/SDL_fbvideo.c 2006-05-08 08:02:26.000000000 -0400 +@@ -79,7 +79,8 @@ + { 0, 0, 640, 400 }, /* 8 bpp: 0x100, or 256 */ + { 0, 0, 512, 384 }, + { 0, 0, 320, 240 }, +- { 0, 0, 320, 200 } ++ { 0, 0, 320, 200 }, ++ { 0, 0, 240, 320 } //lee 2006-4-22:to support 240*320 display mode + }; + static const struct { + int xres; +@@ -123,6 +124,7 @@ + { 1280, 1024, 9369, 224, 32, 32, 4, 136, 4, 0, 0 }, /* 60 Hz */ + { 1408, 1056, 8214, 256, 40, 32, 5, 144, 5, 0, 0 }, /* 60 Hz */ + { 1600, 1200,/*?*/0, 272, 48, 32, 5, 152, 5, 0, 0 }, /* 60 Hz */ ++ { 240, 320,63492, 16, 16, 16, 4, 48, 2, 0, 2 }, //lee 2006-4-22:to support 240*320 display mode + #endif + }; + +@@ -279,6 +281,9 @@ + /* Only allow a mode if we have a valid timing for it */ + next_mode = -1; + for ( i=0; i<(sizeof(vesa_timings)/sizeof(vesa_timings[0])); ++i ) { ++ #ifdef USE_VESA_TIMINGS ++ fprintf(stderr,"USE_VESA_TIMINGS\n"); ++ #endif + if ( (w == vesa_timings[i].xres) && + (h == vesa_timings[i].yres) && vesa_timings[i].pixclock ) { + next_mode = i; +@@ -408,7 +413,7 @@ + (((long)finfo.smem_start)&~(PAGE_SIZE-1))); + mapped_memlen = finfo.smem_len+mapped_offset; + mapped_mem = mmap(NULL, mapped_memlen, +- PROT_READ|PROT_WRITE, MAP_SHARED, console_fd, 0); ++ PROT_READ|PROT_WRITE, /*MAP_SHARED*/MAP_PRIVATE, console_fd, 0); + if ( mapped_mem == (char *)-1 ) { + SDL_SetError("Unable to memory map the video hardware"); + mapped_mem = NULL; +@@ -452,7 +457,7 @@ + if ( finfo.accel && finfo.mmio_len ) { + mapped_iolen = finfo.mmio_len; + mapped_io = mmap(NULL, mapped_iolen, PROT_READ|PROT_WRITE, +- MAP_SHARED, console_fd, mapped_memlen); ++ /*MAP_SHARED*/MAP_PRIVATE, console_fd, mapped_memlen); + if ( mapped_io == (char *)-1 ) { + /* Hmm, failed to memory map I/O registers */ + mapped_io = NULL; +@@ -725,12 +730,12 @@ + Uint32 Bmask; + char *surfaces_mem; + int surfaces_len; +- ++ + /* Set the terminal into graphics mode */ + if ( FB_EnterGraphicsMode(this) < 0 ) { + return(NULL); + } +- ++ + /* Restore the original palette */ + FB_RestorePalette(this); + +@@ -769,6 +774,7 @@ + fprintf(stderr, "Printing wanted vinfo:\n"); + print_vinfo(&vinfo); + #endif ++#if 0 //lee + if ( ioctl(console_fd, FBIOPUT_VSCREENINFO, &vinfo) < 0 ) { + vinfo.yres_virtual = height; + if ( ioctl(console_fd, FBIOPUT_VSCREENINFO, &vinfo) < 0 ) { +@@ -776,6 +782,7 @@ + return(NULL); + } + } ++#endif + } else { + int maxheight; + +@@ -817,11 +824,12 @@ + /* Get the fixed information about the console hardware. + This is necessary since finfo.line_length changes. + */ ++ + if ( ioctl(console_fd, FBIOGET_FSCREENINFO, &finfo) < 0 ) { + SDL_SetError("Couldn't get console hardware info"); + return(NULL); + } +- ++ + /* Save hardware palette, if needed */ + FB_SavePalette(this, &finfo, &vinfo); + +@@ -1107,10 +1115,12 @@ + FB_WaitBusySurfaces(this); + } + wait_vbl(this); ++ #if 0 //lee 5-1 + if ( ioctl(console_fd, FBIOPAN_DISPLAY, &cache_vinfo) < 0 ) { + SDL_SetError("ioctl(FBIOPAN_DISPLAY) failed"); + return(-1); + } ++ #endif + flip_page = !flip_page; + + surface->pixels = flip_address[flip_page]; diff --git a/xiptech-xmame-0.105.patch b/xiptech-xmame-0.105.patch new file mode 100644 index 0000000..32b8bd8 --- /dev/null +++ b/xiptech-xmame-0.105.patch @@ -0,0 +1,807 @@ +diff -Nur xmame-0.104.orig/Makefile xmame-0.104/Makefile +--- xmame-0.104.orig/Makefile 2006-02-10 11:21:08.000000000 -0500 ++++ xmame-0.104/Makefile 2006-05-08 08:03:45.000000000 -0400 +@@ -33,12 +33,12 @@ + ########################################################################### + + # Uncomment one of these. +-TARGET = mame ++# TARGET = mame + # TARGET = mess + # TARGET = mage + # TARGET = mmsnd + # example for a tiny compile +-# TARGET = tiny ++ TARGET = tiny + + + ########################################################################### +@@ -96,8 +96,16 @@ + # means fewer frames to be skipped and better graphics, but `gcc' works + # just as well. However, stay away from the `cc' Ultrix compiler if + # possible. ++RANLIB = bfin-uclinux-ranlib ++AR = bfin-uclinux-ar ++CC = bfin-uclinux-gcc ++MY_CPU = bf537 ++ ++#RANLIB = ranlib ++#AR = ar ++#CC = gcc ++#MY_CPU = i386 + +-CC = gcc + # CC = cc + # CC = icc + # CC = c89 +@@ -108,8 +116,8 @@ + + # Compiler for host compilations in cross-compiling environments (used + # in src/unix/unix.mak for m68k). +-HOST_CC = $(CC) +-# HOST_CC = gcc ++#HOST_CC = $(CC) ++ HOST_CC = gcc + + + ########################################################################### +@@ -127,7 +135,8 @@ + ########################################################################### + + # GCC on x86 +-CFLAGS = -O2 ++#CFLAGS = -O2 ++CFLAGS = -Wall -O2 + + # GCC on x86 with some optimizations + # CFLAGS = -O2 -mtune=i686 -fomit-frame-pointer -fstrength-reduce -ffast-math +@@ -183,13 +192,13 @@ + ######################################################################### + + # Check for C89 + GNU extensions compliance. +- CFLAGS += -std=gnu89 ++ #CFLAGS += -std=gnu89 + + # Show all warnings. +- CFLAGS += -Wall ++ #CFLAGS += -Wall + + # Don't warn about unused variables. +- CFLAGS += -Wno-unused ++ #CFLAGS += -Wno-unused + + # Warn about declarations after statements. + # CFLAGS += -Wdeclaration-after-statement +@@ -396,6 +405,8 @@ + endif + endif + ++#lee edit here ++CFLAGS += -w + ########################################################################### + # Inlining + ########################################################################### +@@ -417,7 +428,11 @@ + ########################################################################### + + # Normal linking. ++ifeq ($(MY_CPU), bf537) ++LD = $(CC) -Wl,-elf2flt="-s 262144" ++else + LD = $(CC) -Wl,-s ++endif + + # For a Linux/PowerPC system. + # LD = $(CC) -Wl,-s,--relax +@@ -458,7 +473,6 @@ + + # Does your platform have ranlib? Leave this untouched unless you are + # using IRIX, Unixware 7, or the Intel C++ Compiler. +-RANLIB = ranlib + # RANLIB = true + + +@@ -502,10 +516,10 @@ + ########################################################################### + + # Uncomment next line to build expat as part of the build. +-# BUILD_EXPAT = 1 ++ BUILD_EXPAT = 1 + + # Uncomment next line to build zlib as part of the build. +-# BUILD_ZLIB = 1 ++ BUILD_ZLIB = 1 + + # Does your system support the gettimeofday() function? If so, we + # encourage you to enable this feature. Otherwise, comment it out. +@@ -540,8 +554,11 @@ + BINDIR = $(PREFIX)/bin + MANDIR = $(PREFIX)/man/man6 + ++#lee edit ++MYROOT=/home/lee/mame/xmame-0.104/root + # This is the default path for ROMs and other data files. +-XMAMEROOT = $(PREFIX)/share/x$(TARGET) ++#XMAMEROOT = $(PREFIX)/share/x$(TARGET) ++XMAMEROOT = $(MYROOT)/x$(TARGET) + # This is the default path for system-wide configuration files. + SYSCONFDIR = $(XMAMEROOT) + +@@ -549,9 +566,9 @@ + ########################################################################### + # Architecture; choose your CPU (only one!!) + ########################################################################### +- ++#MY_CPU = bf537 + # i386, GNU asm +-MY_CPU = i386 ++#MY_CPU = i386 + + # i386, no asm -- needed for the Intel C++ compiler, which does not fully + # understand GCC's inline assembly syntax, though you may still enable +@@ -658,7 +675,7 @@ + # JOY_PS2 = 1 + + # SDL joystick support. +-# JOY_SDL = 1 ++JOY_SDL = 1 + + # This will enable the use of the Happ Controls UGCI(tm) USB devices' + # Coin/Start inputs using the libugci library available from +@@ -689,7 +706,7 @@ + # SOUND_ALSA = 1 + # SOUND_ARTS_TEIRA = 1 + # SOUND_ARTS_SMOTEK = 1 +-# SOUND_SDL = 1 ++ SOUND_SDL = 1 + # SOUND_WAVEOUT = 1 + + +@@ -701,10 +718,10 @@ + # use SDL. + + # X11 (including Glide & OpenGL if enabled below) +-DISPLAY_METHOD = x11 ++# DISPLAY_METHOD = x11 + + # SDL library +-# DISPLAY_METHOD = SDL ++ DISPLAY_METHOD = SDL + + # SVGALib, only supported under Linux + # DISPLAY_METHOD = svgalib +@@ -729,10 +746,10 @@ + # Uncomment any extensions you wish to use. + + # MIT-Shared Memory X Extensions +-X11_MITSHM = 1 ++#X11_MITSHM = 1 + + # Use Xv extension for hardware scaling. +-X11_XV = 1 ++#X11_XV = 1 + + # Enable XFree86 DGA. This also causes "make install" to set the suid bit + # on the executable. +@@ -756,8 +773,8 @@ + # X11LIB = -L/usr/lib/X11 + + # Standard location for XFree86 +-X11INC = -I/usr/X11R6/include +-X11LIB = -L/usr/X11R6/lib ++#X11INC = -I/usr/X11R6/include ++#X11LIB = -L/usr/X11R6/lib + + # Standard location for Sun systems + # X11INC = -I/usr/openwin/include +@@ -784,8 +801,8 @@ + ############################################################################## + + # The name of your sdl-config executable +-SDL_CONFIG = sdl-config +- ++#SDL_CONFIG = sdl-config ++SDL_CONFIG = './sdl_fake_config.sh' + + ############################################################################## + # 3Dfx options (only needed when xfx or svgafx is the display method) +@@ -815,7 +832,7 @@ + # + # If you wish you can add -DNOGLCHECKS for a small speedup, but this is not + # advised, or you can add -DGLDEBUG to get more verbose debugging messages. +-GLCFLAGS += -D_X11_ ++#GLCFLAGS += -D_X11_ + + # Uncomment to add more libraries that Mesa may require. + # GLLIBS += -lXmu -lXi +diff -Nur xmame-0.104.orig/makefile.unix xmame-0.104/makefile.unix +--- xmame-0.104.orig/makefile.unix 2006-02-10 11:21:08.000000000 -0500 ++++ xmame-0.104/makefile.unix 2006-05-08 08:03:45.000000000 -0400 +@@ -33,12 +33,12 @@ + ########################################################################### + + # Uncomment one of these. +-TARGET = mame ++# TARGET = mame + # TARGET = mess + # TARGET = mage + # TARGET = mmsnd + # example for a tiny compile +-# TARGET = tiny ++ TARGET = tiny + + + ########################################################################### +@@ -96,8 +96,16 @@ + # means fewer frames to be skipped and better graphics, but `gcc' works + # just as well. However, stay away from the `cc' Ultrix compiler if + # possible. ++RANLIB = bfin-uclinux-ranlib ++AR = bfin-uclinux-ar ++CC = bfin-uclinux-gcc ++MY_CPU = bf537 ++ ++#RANLIB = ranlib ++#AR = ar ++#CC = gcc ++#MY_CPU = i386 + +-CC = gcc + # CC = cc + # CC = icc + # CC = c89 +@@ -108,8 +116,8 @@ + + # Compiler for host compilations in cross-compiling environments (used + # in src/unix/unix.mak for m68k). +-HOST_CC = $(CC) +-# HOST_CC = gcc ++#HOST_CC = $(CC) ++ HOST_CC = gcc + + + ########################################################################### +@@ -127,7 +135,8 @@ + ########################################################################### + + # GCC on x86 +-CFLAGS = -O2 ++#CFLAGS = -O2 ++CFLAGS = -Wall -O2 + + # GCC on x86 with some optimizations + # CFLAGS = -O2 -mtune=i686 -fomit-frame-pointer -fstrength-reduce -ffast-math +@@ -183,13 +192,13 @@ + ######################################################################### + + # Check for C89 + GNU extensions compliance. +- CFLAGS += -std=gnu89 ++ #CFLAGS += -std=gnu89 + + # Show all warnings. +- CFLAGS += -Wall ++ #CFLAGS += -Wall + + # Don't warn about unused variables. +- CFLAGS += -Wno-unused ++ #CFLAGS += -Wno-unused + + # Warn about declarations after statements. + # CFLAGS += -Wdeclaration-after-statement +@@ -396,6 +405,8 @@ + endif + endif + ++#lee edit here ++CFLAGS += -w + ########################################################################### + # Inlining + ########################################################################### +@@ -417,7 +428,11 @@ + ########################################################################### + + # Normal linking. ++ifeq ($(MY_CPU), bf537) ++LD = $(CC) -Wl,-elf2flt="-s 262144" ++else + LD = $(CC) -Wl,-s ++endif + + # For a Linux/PowerPC system. + # LD = $(CC) -Wl,-s,--relax +@@ -458,7 +473,6 @@ + + # Does your platform have ranlib? Leave this untouched unless you are + # using IRIX, Unixware 7, or the Intel C++ Compiler. +-RANLIB = ranlib + # RANLIB = true + + +@@ -502,10 +516,10 @@ + ########################################################################### + + # Uncomment next line to build expat as part of the build. +-# BUILD_EXPAT = 1 ++ BUILD_EXPAT = 1 + + # Uncomment next line to build zlib as part of the build. +-# BUILD_ZLIB = 1 ++ BUILD_ZLIB = 1 + + # Does your system support the gettimeofday() function? If so, we + # encourage you to enable this feature. Otherwise, comment it out. +@@ -540,8 +554,11 @@ + BINDIR = $(PREFIX)/bin + MANDIR = $(PREFIX)/man/man6 + ++#lee edit ++MYROOT=/home/lee/mame/xmame-0.104/root + # This is the default path for ROMs and other data files. +-XMAMEROOT = $(PREFIX)/share/x$(TARGET) ++#XMAMEROOT = $(PREFIX)/share/x$(TARGET) ++XMAMEROOT = $(MYROOT)/x$(TARGET) + # This is the default path for system-wide configuration files. + SYSCONFDIR = $(XMAMEROOT) + +@@ -549,9 +566,9 @@ + ########################################################################### + # Architecture; choose your CPU (only one!!) + ########################################################################### +- ++#MY_CPU = bf537 + # i386, GNU asm +-MY_CPU = i386 ++#MY_CPU = i386 + + # i386, no asm -- needed for the Intel C++ compiler, which does not fully + # understand GCC's inline assembly syntax, though you may still enable +@@ -658,7 +675,7 @@ + # JOY_PS2 = 1 + + # SDL joystick support. +-# JOY_SDL = 1 ++JOY_SDL = 1 + + # This will enable the use of the Happ Controls UGCI(tm) USB devices' + # Coin/Start inputs using the libugci library available from +@@ -689,7 +706,7 @@ + # SOUND_ALSA = 1 + # SOUND_ARTS_TEIRA = 1 + # SOUND_ARTS_SMOTEK = 1 +-# SOUND_SDL = 1 ++ SOUND_SDL = 1 + # SOUND_WAVEOUT = 1 + + +@@ -701,10 +718,10 @@ + # use SDL. + + # X11 (including Glide & OpenGL if enabled below) +-DISPLAY_METHOD = x11 ++# DISPLAY_METHOD = x11 + + # SDL library +-# DISPLAY_METHOD = SDL ++ DISPLAY_METHOD = SDL + + # SVGALib, only supported under Linux + # DISPLAY_METHOD = svgalib +@@ -729,10 +746,10 @@ + # Uncomment any extensions you wish to use. + + # MIT-Shared Memory X Extensions +-X11_MITSHM = 1 ++#X11_MITSHM = 1 + + # Use Xv extension for hardware scaling. +-X11_XV = 1 ++#X11_XV = 1 + + # Enable XFree86 DGA. This also causes "make install" to set the suid bit + # on the executable. +@@ -756,8 +773,8 @@ + # X11LIB = -L/usr/lib/X11 + + # Standard location for XFree86 +-X11INC = -I/usr/X11R6/include +-X11LIB = -L/usr/X11R6/lib ++#X11INC = -I/usr/X11R6/include ++#X11LIB = -L/usr/X11R6/lib + + # Standard location for Sun systems + # X11INC = -I/usr/openwin/include +@@ -784,8 +801,8 @@ + ############################################################################## + + # The name of your sdl-config executable +-SDL_CONFIG = sdl-config +- ++#SDL_CONFIG = sdl-config ++SDL_CONFIG = './sdl_fake_config.sh' + + ############################################################################## + # 3Dfx options (only needed when xfx or svgafx is the display method) +@@ -815,7 +832,7 @@ + # + # If you wish you can add -DNOGLCHECKS for a small speedup, but this is not + # advised, or you can add -DGLDEBUG to get more verbose debugging messages. +-GLCFLAGS += -D_X11_ ++#GLCFLAGS += -D_X11_ + + # Uncomment to add more libraries that Mesa may require. + # GLLIBS += -lXmu -lXi +diff -Nur xmame-0.104.orig/readme.537 xmame-0.104/readme.537 +--- xmame-0.104.orig/readme.537 1969-12-31 19:00:00.000000000 -0500 ++++ xmame-0.104/readme.537 2006-05-08 06:54:54.000000000 -0400 +@@ -0,0 +1,4 @@ ++1.edit sdl_fake_config.sh ++set your SDL_PATH ++2.make ++./make +\ No newline at end of file +diff -Nur xmame-0.104.orig/src/drivers/pacman.c xmame-0.104/src/drivers/pacman.c +--- xmame-0.104.orig/src/drivers/pacman.c 2006-02-10 11:20:48.000000000 -0500 ++++ xmame-0.104/src/drivers/pacman.c 2006-05-08 08:05:51.000000000 -0400 +@@ -4951,7 +4951,7 @@ + GAME( 1983, sprglobp, suprglob, theglobp, theglobp, 0, ROT90, "Epos Corporation", "Super Glob (Pac-Man hardware)", GAME_SUPPORTS_SAVE ) + GAME( 1984, beastf, suprglob, theglobp, theglobp, 0, ROT90, "Epos Corporation", "Beastie Feastie", GAME_SUPPORTS_SAVE ) + GAME( 1984, drivfrcp, 0, drivfrcp, drivfrcp, 0, ROT90, "Shinkai Inc. (Magic Eletronics Inc. licence)", "Driving Force (Pac-Man conversion)", GAME_SUPPORTS_SAVE ) +-GAME( 1985, 8bpm, 8ballact, 8bpm, 8bpm, 8bpm, ROT90, "Seatongrove Ltd (Magic Eletronics USA licence)", "Eight Ball Action (Pac-Man conversion)", GAME_SUPPORTS_SAVE ) ++//GAME( 1985, 8bpm, 8ballact, 8bpm, 8bpm, 8bpm, ROT90, "Seatongrove Ltd (Magic Eletronics USA licence)", "Eight Ball Action (Pac-Man conversion)", GAME_SUPPORTS_SAVE ) + GAME( 1985, porky, 0, porky, porky, porky, ROT90, "Shinkai Inc. (Magic Eletronics Inc. licence)", "Porky", GAME_NO_SOUND ) + GAME( 1986, rocktrv2, 0, rocktrv2, rocktrv2, rocktrv2, ROT90, "Triumph Software Inc.", "MTV Rock-N-Roll Trivia (Part 2)", GAME_SUPPORTS_SAVE ) + GAME( 1986, bigbucks, 0, bigbucks, bigbucks, 0, ROT90, "Dynasoft Inc.", "Big Bucks", GAME_SUPPORTS_SAVE ) +diff -Nur xmame-0.104.orig/src/mame.mak xmame-0.104/src/mame.mak +--- xmame-0.104.orig/src/mame.mak 2006-02-10 11:20:48.000000000 -0500 ++++ xmame-0.104/src/mame.mak 2006-05-08 08:04:44.000000000 -0400 +@@ -41,25 +41,25 @@ + CPUS += DECO16 + #CPUS += M4510 + CPUS += H6280 +-CPUS += I86 +-CPUS += I88 +-CPUS += I186 ++#CPUS += I86 ++#CPUS += I88 ++#CPUS += I186 + #CPUS += I188 + #CPUS += I286 +-CPUS += V20 +-CPUS += V30 +-CPUS += V33 +-CPUS += V60 +-CPUS += V70 +-CPUS += I8035 +-CPUS += I8039 +-CPUS += I8048 +-CPUS += N7751 +-CPUS += I8X41 +-CPUS += I8051 +-CPUS += I8052 +-CPUS += I8751 +-CPUS += I8752 ++#CPUS += V20 ++#CPUS += V30 ++#CPUS += V33 ++#CPUS += V60 ++#CPUS += V70 ++#CPUS += I8035 ++#CPUS += I8039 ++#CPUS += I8048 ++#CPUS += N7751 ++#CPUS += I8X41 ++#CPUS += I8051 ++#CPUS += I8052 ++#CPUS += I8751 ++#CPUS += I8752 + CPUS += M6800 + CPUS += M6801 + CPUS += M6802 +@@ -103,57 +103,57 @@ + CPUS += ADSP2105 + CPUS += ADSP2115 + CPUS += ADSP2181 +-CPUS += PSXCPU ++#CPUS += PSXCPU + CPUS += ASAP + CPUS += UPD7810 + CPUS += UPD7807 +-CPUS += ARM +-CPUS += ARM7 ++#CPUS += ARM ++#CPUS += ARM7 + CPUS += JAGUAR +-CPUS += R3000 +-CPUS += R4600 +-CPUS += R4700 +-CPUS += R5000 +-CPUS += QED5271 +-CPUS += RM7000 ++#CPUS += R3000 ++#CPUS += R4600 ++#CPUS += R4700 ++#CPUS += R5000 ++#CPUS += QED5271 ++#CPUS += RM7000 + CPUS += SH2 + CPUS += DSP32C + #CPUS += PIC16C54 +-CPUS += PIC16C55 ++#CPUS += PIC16C55 + #CPUS += PIC16C56 +-CPUS += PIC16C57 ++#CPUS += PIC16C57 + #CPUS += PIC16C58 +-CPUS += G65816 +-CPUS += SPC700 +-CPUS += E116T ++#CPUS += G65816 ++##CPUS += SPC700 ++#CPUS += E116T + #CPUS += E116XT + #CPUS += E116XS + #CPUS += E116XSR +-CPUS += E132N ++#CPUS += E132N + #CPUS += E132T + #CPUS += E132XN +-CPUS += E132XT ++#CPUS += E132XT + #CPUS += E132XS + #CPUS += E132XSR +-CPUS += GMS30C2116 ++#CPUS += GMS30C2116 + #CPUS += GMS30C2132 + #CPUS += GMS30C2216 + #CPUS += GMS30C2232 +-CPUS += I386 ++#CPUS += I386 + #CPUS += I486 +-CPUS += PENTIUM +-CPUS += MEDIAGX +-CPUS += I960 +-CPUS += H83002 +-CPUS += V810 +-CPUS += M37710 +-CPUS += PPC403 +-CPUS += PPC602 +-CPUS += PPC603 +-CPUS += SE3208 +-CPUS += MC68HC11 +-CPUS += ADSP21062 +-CPUS += DSP56156 ++#CPUS += PENTIUM ++#CPUS += MEDIAGX ++#CPUS += I960 ++#CPUS += H83002 ++#CPUS += V810 ++#CPUS += M37710 ++#CPUS += PPC403 ++#CPUS += PPC602 ++#CPUS += PPC603 ++#CPUS += SE3208 ++#CPUS += MC68HC11 ++#CPUS += ADSP21062 ++#CPUS += DSP56156 + + + +diff -Nur xmame-0.104.orig/src/tiny.mak xmame-0.104/src/tiny.mak +--- xmame-0.104.orig/src/tiny.mak 2006-02-10 11:20:48.000000000 -0500 ++++ xmame-0.104/src/tiny.mak 2006-05-08 08:04:44.000000000 -0400 +@@ -1,16 +1,23 @@ + # a tiny compile is without Neogeo games +-COREDEFS += -DTINY_NAME="driver_robby,driver_gridlee,driver_polyplay" +-COREDEFS += -DTINY_POINTER="&driver_robby,&driver_gridlee,&driver_polyplay" ++COREDEFS += -DTINY_NAME="driver_robby,driver_gridlee,driver_polyplay,driver_puckman,driver_mspacman,driver_pacman" ++COREDEFS += -DTINY_POINTER="&driver_robby,&driver_gridlee,&driver_polyplay,&driver_puckman,&driver_mspacman,&driver_pacman" + + # uses these CPUs + CPUS+=Z80 + CPUS+=M6809 ++CPUS += I8035 ++CPUS += N2A03 + + # uses these SOUNDs + SOUNDS+=CUSTOM + SOUNDS+=SN76496 + SOUNDS+=SAMPLES + SOUNDS+=ASTROCADE ++#SOUNDS += SAMPLES ++SOUNDS+=NAMCO ++#SOUNDS += SN76496 ++SOUNDS += AY8910 ++SOUNDS += DAC + + DRVLIBS = \ + $(OBJ)/machine/astrocde.o $(OBJ)/vidhrdw/astrocde.o \ +@@ -18,6 +25,16 @@ + $(OBJ)/vidhrdw/gridlee.o $(OBJ)/sndhrdw/gridlee.o $(OBJ)/drivers/gridlee.o \ + $(OBJ)/vidhrdw/polyplay.o $(OBJ)/sndhrdw/polyplay.o $(OBJ)/drivers/polyplay.o \ + $(OBJ)/machine/random.o \ ++ $(OBJ)/drivers/pacman.o $(OBJ)/vidhrdw/pacman.o \ ++ $(OBJ)/machine/mspacman.o \ ++ $(OBJ)/machine/pacplus.o \ ++ $(OBJ)/machine/theglobp.o \ ++ $(OBJ)/machine/acitya.o \ ++ $(OBJ)/machine/jumpshot.o \ ++ $(OBJ)/drivers/epos.o $(OBJ)/vidhrdw/epos.o \ ++ $(OBJ)/machine/8255ppi.o \ + ++ ++ + # MAME specific core objs +-COREOBJS += $(OBJ)/tiny.o $(OBJ)/cheat.o ++COREOBJS += $(OBJ)/tiny.o +diff -Nur xmame-0.104.orig/src/unix/config.c xmame-0.104/src/unix/config.c +--- xmame-0.104.orig/src/unix/config.c 2006-02-16 23:32:44.000000000 -0500 ++++ xmame-0.104/src/unix/config.c 2006-05-08 08:05:13.000000000 -0400 +@@ -230,6 +230,9 @@ + /* + * get configuration from configfile and env. + */ ++ ++static char my_dir[]="/var";//lee 2006-4-22 ++ + int xmame_config_init(int argc, char *argv[]) + { + char buffer[BUF_SIZE]; +@@ -280,7 +283,10 @@ + /* get the homedir */ + if(!(home_dir = get_home_dir())) + return OSD_NOT_OK; +- ++ ++ home_dir = my_dir;//lee 2006-4-22 ++ ++ fprintf(stderr,"PATH_LEADER:%s,home_dir:%s,NAME:%s\n",PATH_LEADER,home_dir,NAME); + /* check that the required dirs exist, and create them if necessary */ + snprintf(buffer, BUF_SIZE, "%s/"PATH_LEADER"%s", home_dir, NAME); + if (check_and_create_dir(buffer)) +diff -Nur xmame-0.104.orig/src/unix/devices.c xmame-0.104/src/unix/devices.c +--- xmame-0.104.orig/src/unix/devices.c 2006-02-10 11:20:58.000000000 -0500 ++++ xmame-0.104/src/unix/devices.c 2006-05-08 08:05:14.000000000 -0400 +@@ -591,7 +591,8 @@ + joy_ps2_init(); + break; + #endif +-#if defined SDL || defined SDL_JOYSTICK ++//#if defined SDL || defined SDL_JOYSTICK/*lee 06-4-30*/ ++#if defined SDL_JOYSTICK + case JOY_SDL: + joy_SDL_init(); + break; +diff -Nur xmame-0.104.orig/src/unix/unix.mak xmame-0.104/src/unix/unix.mak +--- xmame-0.104.orig/src/unix/unix.mak 2006-02-15 01:45:51.000000000 -0500 ++++ xmame-0.104/src/unix/unix.mak 2006-05-08 08:05:30.000000000 -0400 +@@ -4,7 +4,7 @@ + + # *** Comment out this line to get verbose make output, for debugging build + # problems +-QUIET = 1 ++#QUIET = 1 + + + ############################################################################## +@@ -21,7 +21,7 @@ + CFLAGS.risc = -DALIGN_INTS -DALIGN_SHORTS + CFLAGS.risc_lsb = -DALIGN_INTS -DALIGN_SHORTS -DLSB_FIRST + CFLAGS.mips = -DALIGN_INTS -DALIGN_SHORTS -DSGI_FIX_MWA_NOP +- ++CFLAGS.bf537 = -DLSB_FIRST -DALIGN_INTS -DALIGN_SHORTS + ############################################################################## + # Architecture-dependent settings + ############################################################################## +@@ -230,6 +230,10 @@ + ifeq ($(TARGET), mess) + include mess/$(TARGET).mak + endif ++#lee add ++ifeq ($(TARGET), tiny) ++include src/$(TARGET).mak ++endif + + include src/cpu/cpu.mak + include src/sound/sound.mak +@@ -255,9 +259,9 @@ + -DHAVE_UNISTD_H=1 \ + $(COREDEFS) $(SOUNDDEFS) $(CPUDEFS) $(ASMDEFS) \ + $(INCLUDES) $(INCLUDE_PATH) +- +-MY_LIBS = $(LIBS) $(LIBS.$(ARCH)) $(LIBS.$(DISPLAY_METHOD)) -lz +- ++#lee ++#MY_LIBS = $(LIBS) $(LIBS.$(ARCH)) $(LIBS.$(DISPLAY_METHOD)) -lz ++MY_LIBS = $(LIBS) $(LIBS.$(ARCH)) $(LIBS.$(DISPLAY_METHOD)) + ifdef SEPARATE_LIBM + MY_LIBS += -lm + endif +@@ -288,8 +292,8 @@ + + # The SDL target automatically includes the SDL joystick and audio drivers. + ifeq ($(DISPLAY_METHOD),SDL) +-JOY_SDL = 1 +-SOUND_SDL = 1 ++JOY_SDL = 0 ++SOUND_SDL = 0 + endif + + ############################################################################## +@@ -433,7 +437,11 @@ + ############################################################################## + + # per arch ++ifeq ($(MY_CPU), bf537) ++CFLAGS.linux = -DSYSDEP_DSP_OSS -DSYSDEP_MIXER_OSS -DHAVE_SNPRINTF -DHAVE_VSNPRINTF -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=32 ++else + CFLAGS.linux = -DSYSDEP_DSP_OSS -DSYSDEP_MIXER_OSS -DHAVE_SNPRINTF -DHAVE_VSNPRINTF -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 ++endif + CFLAGS.freebsd = -DSYSDEP_DSP_OSS -DSYSDEP_MIXER_OSS -DHAVE_SNPRINTF -DHAVE_VSNPRINTF -DHAVE_STRLCAT + CFLAGS.netbsd = -DSYSDEP_DSP_NETBSD -DHAVE_SNPRINTF -DHAVE_VSNPRINTF -DHAVE_STRLCAT + CFLAGS.openbsd = -DSYSDEP_DSP_NETBSD -DHAVE_SNPRINTF -DHAVE_VSNPRINTF -DHAVE_STRLCAT +@@ -558,9 +566,9 @@ + ############################################################################## + + $(NAME).$(DISPLAY_METHOD): $(EXPAT) $(ZLIB) $(OBJS) $(UNIX_OBJS) $(OSDEPEND) +- $(CC_COMMENT) @echo 'Linking $@ ...' +- $(CC_COMPILE) $(LD) $(LDFLAGS) -o $@ $(OBJS) $(EXPAT) $(ZLIB) $(UNIX_OBJS) $(OSDEPEND) $(MY_LIBS) +- ++ $(CC_COMMENT) @echo 'Linkinging $@ ...' ++ $(CC_COMPILE) $(LD) $(LDFLAGS) -o $@ $(OBJS) $(EXPAT) $(ZLIB) $(UNIX_OBJS) $(OSDEPEND) $(MY_LIBS) ++ + maketree: $(sort $(OBJDIRS)) + + $(sort $(OBJDIRS)): +@@ -592,8 +600,9 @@ + + imgtool: $(IMGTOOL_OBJS) $(ZLIB) $(PLATFORM_IMGTOOL_OBJS) + $(CC_COMMENT) @echo 'Compiling $@...' +- $(CC_COMPILE) $(LD) $(LDFLAGS) $^ -lz -o $@ +- ++#lee ++# $(CC_COMPILE) $(LD) $(LDFLAGS) $^ -lz -o $@ ++ $(CC_COMPILE) $(LD) $(LDFLAGS) $^ -o $@ + messtest: $(OBJS) $(MESSTEST_OBJS) \ + $(OBJDIR)/dirio.o \ + $(OBJDIR)/fileio.o \ +@@ -638,12 +647,12 @@ + + $(OBJ)/%.a: + $(CC_COMMENT) @echo 'Archiving $@ ...' +- $(CC_COMPILE) ar $(AR_OPTS) $@ $^ ++ $(CC_COMPILE) $(AR) $(AR_OPTS) $@ $^ + $(CC_COMPILE) $(RANLIB) $@ + + $(OSDEPEND): $(UNIX_OBJS) + $(CC_COMMENT) @echo '[OSDEPEND] Archiving $@ ...' +- $(CC_COMPILE) ar $(AR_OPTS) $@ $(UNIX_OBJS) ++ $(CC_COMPILE) $(AR) $(AR_OPTS) $@ $(UNIX_OBJS) + $(CC_COMPILE) $(RANLIB) $@ + + $(UNIX_OBJDIR)/%.o: src/unix/%.c src/unix/xmame.h +diff -Nur xmame-0.104.orig/src/unix/video-drivers/SDL.c xmame-0.104/src/unix/video-drivers/SDL.c +--- xmame-0.104.orig/src/unix/video-drivers/SDL.c 2006-02-10 11:21:07.000000000 -0500 ++++ xmame-0.104/src/unix/video-drivers/SDL.c 2006-05-08 08:06:30.000000000 -0400 +@@ -547,17 +553,22 @@ + case SDL_KEYDOWN: + kevent.press = 1; + case SDL_KEYUP: + kevent.scancode = klookup[event.key.keysym.sym]; + kevent.unicode = event.key.keysym.unicode; + sysdep_display_params.keyboard_handler(&kevent); + if(!kevent.scancode) + fprintf (stderr, "Unknown symbol 0x%x\n", + event.key.keysym.sym); + #ifdef SDL_DEBUG + fprintf (stderr, "Key %s %ssed\n", + SDL_GetKeyName(event.key.keysym.sym), + kevent.press? "pres":"relea"); + #endif ++ ++ ++if (event.key.keysym.sym == SDLK_q)/*lee 5-4:tmp exit*/ ++ exit(0); ++ + break; + case SDL_QUIT: + retval |= SYSDEP_DISPLAY_QUIT_REQUESTED; diff --git a/xmame-0.104-6.8.patch b/xmame-0.104-6.8.patch new file mode 100644 index 0000000..22d4313 --- /dev/null +++ b/xmame-0.104-6.8.patch @@ -0,0 +1,25 @@ +diff -Naur xmame-0.104_pre/src/unix/unix.mak xmame-0.104/src/unix/unix.mak +--- xmame-0.104_pre/src/unix/unix.mak 2006-05-22 13:28:19.000000000 +0800 ++++ xmame-0.104/src/unix/unix.mak 2006-05-08 20:05:30.000000000 +0800 +@@ -296,9 +296,6 @@ + SOUND_SDL = 0 + endif + +-#lee :we don't need any effect +-MY_CFLAGS += -DDISABLE_EFFECTS +- + ############################################################################## + # Object listings + ############################################################################## +diff -Naur xmame-0.104_pre/src/unix/video-drivers/SDL.c xmame-0.104/src/unix/video-drivers/SDL.c +--- xmame-0.104_pre/src/unix/video-drivers/SDL.c 2006-05-22 13:25:00.000000000 +0800 ++++ xmame-0.104/src/unix/video-drivers/SDL.c 2006-05-20 17:49:44.000000000 +0800 +@@ -59,7 +59,7 @@ + /* name, shortname, type, dest, deflt, min, max, func, help */ + { NULL, NULL, rc_link, aspect_opts, NULL, 0, 0, NULL, NULL }, + { "SDL Related", NULL, rc_seperator, NULL, NULL, 0, 0, NULL, NULL }, +- { "doublebuf", NULL, rc_bool, &doublebuf, "0", 0, 0, NULL, ++ { "doublebuf", NULL, rc_bool, &doublebuf, "1", 0, 0, NULL, + "Use double buffering to reduce flicker/tearing" }, + { "grabinput", "gi", rc_bool, &sdl_grab_input, "0", 0, 0, NULL, "Select input grabbing (left-ctrl + delete)" }, + { "alwaysusemouse", "aum", rc_bool, &sdl_always_use_mouse, "0", 0, 0, NULL, "Always use mouse movements as input, even when not grabbed and not fullscreen (default disabled)" }, diff --git a/zziplib-doc-typo.patch b/zziplib-doc-typo.patch new file mode 100644 index 0000000..ba2c45e --- /dev/null +++ b/zziplib-doc-typo.patch @@ -0,0 +1,16 @@ +Index: docs/functions.htm +=================================================================== +RCS file: /cvsroot/zziplib/zzip-0/docs/functions.htm,v +retrieving revision 1.1 +diff -u -p -r1.1 functions.htm +--- docs/functions.htm 22 Sep 2006 00:34:11 -0000 1.1 ++++ docs/functions.htm 20 Jan 2007 12:11:31 -0000 +@@ -2,7 +2,7 @@ + 2006-09-21 + +

+- The ZZipLib Project does already profive THREE libraries. The classic ++ The ZZipLib Project does already provide THREE libraries. The classic + zziplib.so (via "zzip/lib.h") is the most prominent one and used in + a number of different projects. The zzipfseeko.so ("zzip/fseeko.html") + and zzipmmapped.so ("zzip/mmapped.html") are technology demonstrations. diff --git a/zziplib-read-void.patch b/zziplib-read-void.patch new file mode 100644 index 0000000..f337c9a --- /dev/null +++ b/zziplib-read-void.patch @@ -0,0 +1,49 @@ +Index: zzip/file.c +=================================================================== +RCS file: /cvsroot/zziplib/zzip-0/zzip/file.c,v +retrieving revision 1.8 +diff -u -p -r1.8 file.c +--- zzip/file.c 22 Sep 2006 00:33:23 -0000 1.8 ++++ zzip/file.c 20 Jan 2007 12:23:09 -0000 +@@ -339,7 +339,7 @@ zzip_close(ZZIP_FILE* fp) + * a smaller buffer. + */ + zzip_ssize_t +-zzip_file_read(ZZIP_FILE * fp, char * buf, zzip_size_t len) ++zzip_file_read(ZZIP_FILE * fp, void * buf, zzip_size_t len) + { + ZZIP_DIR * dir; + zzip_size_t l; +@@ -429,7 +429,7 @@ zzip_file_read(ZZIP_FILE * fp, char * bu + * to decompress the data stream and any error is mapped to => errno(3). + */ + zzip_ssize_t +-zzip_read(ZZIP_FILE * fp, char * buf, zzip_size_t len) ++zzip_read(ZZIP_FILE * fp, void * buf, zzip_size_t len) + { + if (! fp) return 0; + if (! fp->dir) +Index: zzip/zzip.h +=================================================================== +RCS file: /cvsroot/zziplib/zzip-0/zzip/zzip.h,v +retrieving revision 1.6 +diff -u -p -r1.6 zzip.h +--- zzip/zzip.h 18 Sep 2006 02:07:15 -0000 1.6 ++++ zzip/zzip.h 20 Jan 2007 12:23:09 -0000 +@@ -176,14 +176,14 @@ ZZIP_FILE * zzip_file_open(ZZIP_DIR * d + _zzip_export + int zzip_file_close(ZZIP_FILE * fp); + _zzip_export +-zzip_ssize_t zzip_file_read(ZZIP_FILE * fp, char* buf, zzip_size_t len); ++zzip_ssize_t zzip_file_read(ZZIP_FILE * fp, void* buf, zzip_size_t len); + + _zzip_export + ZZIP_FILE * zzip_open(zzip_char_t* name, int flags); + _zzip_export + int zzip_close(ZZIP_FILE * fp); + _zzip_export +-zzip_ssize_t zzip_read(ZZIP_FILE * fp, char * buf, zzip_size_t len); ++zzip_ssize_t zzip_read(ZZIP_FILE * fp, void * buf, zzip_size_t len); + + /* + * the stdc variant to open/read/close files. - Take note of the freopen() -- 2.39.2