text stringlengths 1 1.05M |
|---|
dnl Alpha mpn_add_n -- Add two limb vectors of the same length > 0 and
dnl store sum in a third limb vector.
dnl Copyright (C) 1995, 2000 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU Library General Public License as published by
dnl the Free Software Foundation; either version 2 of the License, or (at your
dnl option) any later version.
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
dnl License for more details.
dnl You should have received a copy of the GNU Library General Public License
dnl along with the GNU MP Library; see the file COPYING.LIB. If not, write to
dnl the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
dnl MA 02111-1307, USA.
include(`../config.m4')
dnl INPUT PARAMETERS
dnl res_ptr r16
dnl s1_ptr r17
dnl s2_ptr r18
dnl size r19
ASM_START()
PROLOGUE(mpn_add_n)
ldq r3,0(r17)
ldq r4,0(r18)
subq r19,1,r19
and r19,4-1,r2 C number of limbs in first loop
bis r31,r31,r0
beq r2,$L0 C if multiple of 4 limbs, skip first loop
subq r19,r2,r19
$Loop0: subq r2,1,r2
ldq r5,8(r17)
addq r4,r0,r4
ldq r6,8(r18)
cmpult r4,r0,r1
addq r3,r4,r4
cmpult r4,r3,r0
stq r4,0(r16)
bis r0,r1,r0
addq r17,8,r17
addq r18,8,r18
bis r5,r5,r3
bis r6,r6,r4
addq r16,8,r16
bne r2,$Loop0
$L0: beq r19,$Lend
ALIGN(8)
$Loop: subq r19,4,r19
ldq r5,8(r17)
addq r4,r0,r4
ldq r6,8(r18)
cmpult r4,r0,r1
addq r3,r4,r4
cmpult r4,r3,r0
stq r4,0(r16)
bis r0,r1,r0
ldq r3,16(r17)
addq r6,r0,r6
ldq r4,16(r18)
cmpult r6,r0,r1
addq r5,r6,r6
cmpult r6,r5,r0
stq r6,8(r16)
bis r0,r1,r0
ldq r5,24(r17)
addq r4,r0,r4
ldq r6,24(r18)
cmpult r4,r0,r1
addq r3,r4,r4
cmpult r4,r3,r0
stq r4,16(r16)
bis r0,r1,r0
ldq r3,32(r17)
addq r6,r0,r6
ldq r4,32(r18)
cmpult r6,r0,r1
addq r5,r6,r6
cmpult r6,r5,r0
stq r6,24(r16)
bis r0,r1,r0
addq r17,32,r17
addq r18,32,r18
addq r16,32,r16
bne r19,$Loop
$Lend: addq r4,r0,r4
cmpult r4,r0,r1
addq r3,r4,r4
cmpult r4,r3,r0
stq r4,0(r16)
bis r0,r1,r0
ret r31,(r26),1
EPILOGUE(mpn_add_n)
ASM_END()
|
.data
newline:.asciiz "\n"
.text
main:
li $t0,0
li $t1,0
li $t3,0
loop:
li $v0,1
addi $a0,$t0,0
syscall
li $v0,4
la $a0,newline
syscall
addi $t0,$t0,1
bgt $t0,14,exit
j loop
exit:
li $v0,0
|
map_header UndergroundPathWestEast, UNDERGROUND_PATH_WEST_EAST, UNDERGROUND, 0
end_map_header
|
GRAPHICS=1
ADAMS=0
EXITCOL=0
OBJCOL=0
MESSCOL=0
SYSCOL=0
TEXTCOL=39
INPUTCOL=0
include "engine.asm"
include "samessages.asm"
.objsep
equb ". ",0
.end
save "ENGINE",start,end
; add game files - disk1
putfile "MAdisc1\G.TGB","G.TGB",datastart
putfile "MAdisc1\G.TIME","G.TIME",datastart
putfile "MAdisc1\G.AOD1","G.AOD1",datastart
putfile "MAdisc1\G.AOD2","G.AOD2",datastart
putfile "MAdisc1\L.TGB","L.TGB",graphics
putfile "MAdisc1\L.TIME","L.TIME",graphics
putfile "MAdisc1\L.AOD1","L.AOD1",graphics
putfile "MAdisc1\L.AOD2","L.AOD2",graphics
putbasic "MAdisc1\MENU","MENU"
putbasic "MAdisc1\B.TGB","B.TGB"
puttext "MAdisc1\!BOOT","!BOOT",0
|
j L0
add $v0, $a0, $t0
L0:
beqz $v0, L1
add $v0, $a0, $t0
L1:
add $v0, $a0, $t0
|
; Licensed to the .NET Foundation under one or more agreements.
; The .NET Foundation licenses this file to you under the MIT license.
; See the LICENSE file in the project root for more information.
;
#include "ksarm.h"
TEXTAREA
EXTERN start_runtime_and_get_target_address
;; Common code called from a bootstrap_thunk to call start_runtime_and_get_target_address and obtain the
;; real target address to which to tail call.
;;
;; On entry:
;; r12 : parameter provided by the thunk that points back into the thunk itself
;; other argument registers and possibly stack locations set up ready to make the real call
;;
;; On exit:
;; tail calls to the real target method
;;
CFG_ALIGN
NESTED_ENTRY start_runtime_thunk_stub
PROLOG_PUSH {r0-r3} ; Save general argument registers
PROLOG_PUSH {r4,lr} ; Save return address (r4 is saved simply to preserve stack alignment)
PROLOG_VPUSH {d0-d7} ; Save floating point argument registers
mov r0, r12 ; Only argument to start_runtime_and_get_target_address is the hidden thunk parameter
bl start_runtime_and_get_target_address
mov r12, r0 ; Preserve result (real target address)
EPILOG_VPOP {d0-d7} ; Restore floating point argument registers
EPILOG_POP {r4,lr} ; Restore return address
EPILOG_POP {r0-r3} ; Restore general argument registers
EPILOG_BRANCH_REG r12 ; Tail call to real target
NESTED_END
END
|
; A317303: Numbers k with the property that both Dyck paths of the symmetric representation of sigma(k) have a central peak.
; 2,7,8,9,16,17,18,19,20,29,30,31,32,33,34,35,46,47,48,49,50,51,52,53,54,67,68,69,70,71,72,73,74,75,76,77,92,93,94,95,96,97,98,99,100,101,102,103,104,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,154,155,156,157,158,159,160
mov $1,$0
add $0,1
lpb $0,1
add $0,2
add $2,2
sub $0,$2
trn $0,1
add $1,$2
lpe
|
object_const_def ; object_event constants
const RADIOTOWER2F_SUPER_NERD
const RADIOTOWER2F_TEACHER
const RADIOTOWER2F_ROCKET1
const RADIOTOWER2F_ROCKET2
const RADIOTOWER2F_ROCKET3
const RADIOTOWER2F_ROCKET_GIRL
const RADIOTOWER2F_BLACK_BELT1
const RADIOTOWER2F_BLACK_BELT2
const RADIOTOWER2F_JIGGLYPUFF
const RADIOTOWER2F_BUENA
const RADIOTOWER2F_RECEPTIONIST
RadioTower2F_MapScripts:
db 0 ; scene scripts
db 0 ; callbacks
RadioTower2FUnusedDummyScene:
; unused
end
RadioTower2FSuperNerdScript:
jumptextfaceplayer RadioTower2FSuperNerdText
RadioTower2FTeacherScript:
faceplayer
opentext
checkflag ENGINE_ROCKETS_IN_RADIO_TOWER
iftrue .Rockets
writetext RadioTower2FTeacherText
waitbutton
closetext
end
.Rockets:
writetext RadioTower2FTeacherText_Rockets
waitbutton
closetext
end
RadioTowerJigglypuff:
opentext
writetext RadioTowerJigglypuffText
cry JIGGLYPUFF
waitbutton
closetext
end
RadioTower2FBlackBelt1Script:
jumptextfaceplayer RadioTower2FBlackBelt1Text
RadioTower2FBlackBelt2Script:
jumptextfaceplayer RadioTower2FBlackBelt2Text
TrainerGruntM4:
trainer GRUNTM, GRUNTM_4, EVENT_BEAT_ROCKET_GRUNTM_4, GruntM4SeenText, GruntM4BeatenText, 0, .Script
.Script:
endifjustbattled
opentext
writetext GruntM4AfterBattleText
waitbutton
closetext
end
TrainerGruntM5:
trainer GRUNTM, GRUNTM_5, EVENT_BEAT_ROCKET_GRUNTM_5, GruntM5SeenText, GruntM5BeatenText, 0, .Script
.Script:
endifjustbattled
opentext
writetext GruntM5AfterBattleText
waitbutton
closetext
end
TrainerGruntM6:
trainer GRUNTM, GRUNTM_6, EVENT_BEAT_ROCKET_GRUNTM_6, GruntM6SeenText, GruntM6BeatenText, 0, .Script
.Script:
endifjustbattled
opentext
writetext GruntM6AfterBattleText
waitbutton
closetext
end
TrainerGruntF2:
trainer GRUNTF, GRUNTF_2, EVENT_BEAT_ROCKET_GRUNTF_2, GruntF2SeenText, GruntF2BeatenText, 0, .Script
.Script:
endifjustbattled
opentext
writetext GruntF2AfterBattleText
waitbutton
closetext
end
Buena:
faceplayer
opentext
checkflag ENGINE_ROCKETS_IN_RADIO_TOWER
iftrue .MidRocketTakeover
checkevent EVENT_MET_BUENA
iffalse .Introduction
checkflag ENGINE_BUENAS_PASSWORD_2
iftrue .PlayedAlready
readvar VAR_HOUR
ifless 18, .TooEarly
checkflag ENGINE_BUENAS_PASSWORD
iffalse .TuneIn
checkitem BLUE_CARD
iffalse .NoBlueCard
readvar VAR_BLUECARDBALANCE
ifequal 30, .BlueCardCapped0
playmusic MUSIC_BUENAS_PASSWORD
writetext RadioTower2FBuenaDoYouKnowPasswordText
special AskRememberPassword
iffalse .ForgotPassword
writetext RadioTower2FBuenaJoinTheShowText
waitbutton
closetext
turnobject RADIOTOWER2F_BUENA, RIGHT
readvar VAR_FACING
ifnotequal RIGHT, .DontNeedToMove
applymovement PLAYER, RadioTower2FPlayerWalksToMicrophoneMovement
.DontNeedToMove:
turnobject PLAYER, RIGHT
opentext
writetext RadioTower2FBuenaEveryoneSayPasswordText
waitbutton
closetext
turnobject RADIOTOWER2F_BUENA, DOWN
refreshscreen
special BuenasPassword
closetext
iffalse .WrongAnswer
opentext
writetext RadioTower2FBuenaCorrectAnswerText
waitbutton
closetext
readvar VAR_BLUECARDBALANCE
addval 1
writevar VAR_BLUECARDBALANCE
waitsfx
playsound SFX_TRANSACTION
setflag ENGINE_BUENAS_PASSWORD_2
pause 20
turnobject RADIOTOWER2F_BUENA, RIGHT
opentext
writetext RadioTower2FBuenaThanksForComingText
waitbutton
closetext
special FadeOutMusic
pause 20
special RestartMapMusic
readvar VAR_BLUECARDBALANCE
ifequal 30, .BlueCardCapped1
end
.Introduction:
writetext RadioTower2FBuenaShowIntroductionText
buttonsound
setevent EVENT_MET_BUENA
verbosegiveitem BLUE_CARD
.TuneIn:
writetext RadioTower2FBuenaTuneInToMyShowText
waitbutton
closetext
checkcellnum PHONE_BUENA
iftrue .Registered0
checkevent EVENT_BUENA_OFFERED_HER_PHONE_NUMBER
iftrue .OfferedNumberBefore
.Registered0:
turnobject RADIOTOWER2F_BUENA, RIGHT
end
.ForgotPassword:
writetext RadioTower2FBuenaComeBackAfterListeningText
waitbutton
closetext
turnobject RADIOTOWER2F_BUENA, RIGHT
special FadeOutMusic
pause 20
special RestartMapMusic
end
.PlayedAlready:
writetext RadioTower2FBuenaAlreadyPlayedText
waitbutton
closetext
checkcellnum PHONE_BUENA
iftrue .Registered1
checkevent EVENT_BUENA_OFFERED_HER_PHONE_NUMBER
iftrue .OfferedNumberBefore
.Registered1:
turnobject RADIOTOWER2F_BUENA, RIGHT
pause 10
end
.WrongAnswer:
setflag ENGINE_BUENAS_PASSWORD_2
opentext
writetext RadioTower2FBuenaDidYouForgetText
waitbutton
closetext
turnobject RADIOTOWER2F_BUENA, RIGHT
pause 20
opentext
writetext RadioTower2FBuenaThanksForComingText
waitbutton
closetext
turnobject RADIOTOWER2F_BUENA, RIGHT
special FadeOutMusic
pause 20
special RestartMapMusic
end
.MidRocketTakeover:
writetext RadioTower2FBuenaPasswordIsHelpText
waitbutton
closetext
end
.NoBlueCard:
writetext RadioTower2FBuenaNoBlueCardText
waitbutton
closetext
checkcellnum PHONE_BUENA
iftrue .Registered2
checkevent EVENT_BUENA_OFFERED_HER_PHONE_NUMBER_NO_BLUE_CARD
iftrue .OfferedNumberBefore
.Registered2:
turnobject RADIOTOWER2F_BUENA, RIGHT
end
.BlueCardCapped0:
writetext RadioTower2FBuenaCardIsFullText
waitbutton
closetext
checkcellnum PHONE_BUENA
iftrue .Registered3
checkevent EVENT_BUENA_OFFERED_HER_PHONE_NUMBER_NO_BLUE_CARD
iftrue .OfferedNumberBefore
.Registered3:
turnobject RADIOTOWER2F_BUENA, RIGHT
end
.TooEarly:
writetext RadioTower2FBuenaTuneInAfterSixText
waitbutton
closetext
checkcellnum PHONE_BUENA
iftrue .Registered4
checkevent EVENT_BUENA_OFFERED_HER_PHONE_NUMBER
iftrue .OfferedNumberBefore
.Registered4:
end
.BlueCardCapped1:
checkcellnum PHONE_BUENA
iftrue .HasNumber
pause 20
turnobject RADIOTOWER2F_BUENA, DOWN
pause 15
turnobject PLAYER, UP
pause 15
checkevent EVENT_BUENA_OFFERED_HER_PHONE_NUMBER_NO_BLUE_CARD
iftrue .OfferedNumberBefore
showemote EMOTE_SHOCK, RADIOTOWER2F_BUENA, 15
setevent EVENT_BUENA_OFFERED_HER_PHONE_NUMBER_NO_BLUE_CARD
setevent EVENT_BUENA_OFFERED_HER_PHONE_NUMBER
opentext
writetext RadioTower2FBuenaOfferPhoneNumberText
sjump .AskForNumber
.OfferedNumberBefore:
opentext
writetext RadioTower2FBuenaOfferNumberAgainText
.AskForNumber:
askforphonenumber PHONE_BUENA
ifequal PHONE_CONTACTS_FULL, .PhoneFull
ifequal PHONE_CONTACT_REFUSED, .NumberDeclined
writetext RadioTower2FRegisteredBuenasNumberText
playsound SFX_REGISTER_PHONE_NUMBER
waitsfx
buttonsound
writetext RadioTower2FBuenaCallMeText
waitbutton
closetext
turnobject RADIOTOWER2F_BUENA, RIGHT
addcellnum PHONE_BUENA
end
.NumberDeclined:
writetext RadioTower2FBuenaSadRejectedText
waitbutton
closetext
turnobject RADIOTOWER2F_BUENA, RIGHT
end
.PhoneFull:
writetext RadioTower2FBuenaYourPhoneIsFullText
waitbutton
closetext
turnobject RADIOTOWER2F_BUENA, RIGHT
.HasNumber:
end
RadioTowerBuenaPrizeReceptionist:
faceplayer
opentext
checkitem BLUE_CARD
iffalse .NoCard
writetext RadioTower2FBuenaReceptionistPointsForPrizesText
buttonsound
special BuenaPrize
closetext
end
.NoCard:
writetext RadioTower2FBuenaReceptionistNoCardText
buttonsound
closetext
end
RadioTower2FSalesSign:
jumptext RadioTower2FSalesSignText
RadioTower2FOaksPKMNTalkSign:
jumptext RadioTower2FOaksPKMNTalkSignText
RadioTower2FPokemonRadioSign:
jumptext RadioTower2FPokemonRadioSignText
RadioTower2FBookshelf:
jumpstd magazinebookshelf
RadioTower2FPlayerWalksToMicrophoneMovement:
slow_step DOWN
slow_step RIGHT
step_end
RadioTower2FSuperNerdText:
text "You can listen to"
line "the radio any-"
cont "where. Tune in!"
done
RadioTower2FTeacherText:
text "Lullabies on the"
line "radio may make"
cont "#MON sleep."
done
RadioTower2FTeacherText_Rockets:
text "Why would they"
line "want to take over"
cont "the RADIO TOWER?"
done
RadioTowerJigglypuffText:
text "JIGGLYPUFF:"
line "Jiggly…"
done
RadioTower2FBlackBelt1Text:
text "Sorry. Authorized"
line "personnel only"
cont "beyond this point."
para "It wasn't that way"
line "before."
para "There's something"
line "wrong with the"
cont "DIRECTOR…"
done
RadioTower2FBlackBelt2Text:
text "Feel free to look"
line "around anywhere."
para "The DIRECTOR is"
line "nice again, just"
cont "as he was before."
done
GruntM4SeenText:
text "Three years ago,"
line "TEAM ROCKET was"
cont "forced to disband."
para "But we're making a"
line "comeback here!"
done
GruntM4BeatenText:
text "Gwah! Don't get"
line "cute!"
done
GruntM4AfterBattleText:
text "We won't let you"
line "ruin our plans"
cont "for our comeback!"
done
GruntM5SeenText:
text "We're TEAM ROCKET,"
line "the exploiters of"
cont "#MON!"
para "We love being"
line "evil! Scared?"
done
GruntM5BeatenText:
text "You think you're a"
line "hero?"
done
GruntM5AfterBattleText:
text "We're not always"
line "evil. We just do"
cont "whatever we like."
done
GruntM6SeenText:
text "Hey, hey! Keep out"
line "of our way!"
done
GruntM6BeatenText:
text "Arggh. I give up."
done
GruntM6AfterBattleText:
text "Our EXECUTIVES are"
line "trying to take"
cont "this place over."
para "They have some big"
line "plan. I wonder"
cont "what that is?"
done
GruntF2SeenText:
text "Hahaha!"
para "How boring."
line "It was far too"
para "easy to take over"
line "this place!"
para "Come on, keep me"
line "amused!"
done
GruntF2BeatenText:
text "Wh-who are you?"
done
GruntF2AfterBattleText:
text "You beat me, and"
line "I won't forget it!"
done
RadioTower2FBuenaShowIntroductionText:
text "BUENA: Hi! I'm"
line "BUENA!"
para "Do you know about"
line "a radio program"
cont "called PASSWORD?"
para "If you can tell me"
line "the password from"
para "the program, you"
line "will earn points."
para "Save up those"
line "points and trade"
para "them to that sweet"
line "young lady over"
para "there for some"
line "choice prizes!"
para "Here you go!"
para "It's your very own"
line "point card!"
done
RadioTower2FBuenaTuneInToMyShowText:
text "BUENA: Tune in to"
line "my PASSWORD SHOW!"
done
RadioTower2FBuenaDoYouKnowPasswordText:
text "BUENA: Hi!"
line "Did you tune in to"
cont "my radio show?"
para "Do you remember"
line "today's password?"
done
RadioTower2FBuenaJoinTheShowText:
text "BUENA: Oh, wow!"
line "Thank you!"
para "What was your name"
line "again?"
para "…<PLAY_G>, OK!"
para "Come on, <PLAY_G>."
line "Join the show."
done
RadioTower2FBuenaEveryoneSayPasswordText:
text "BUENA: Everyone"
line "ready?"
para "I want to hear you"
line "shout out today's"
para "password for"
line "<PLAY_G>!"
done
RadioTower2FBuenaComeBackAfterListeningText:
text "BUENA: Come back"
line "after you listen"
para "to my show, OK?"
line "Catch ya later!"
done
RadioTower2FBuenaAlreadyPlayedText:
text "BUENA: Sorry…"
para "You get just one"
line "chance each day."
para "Come back tomorrow"
line "for another try!"
done
RadioTower2FBuenaCorrectAnswerText:
text "BUENA: YIPPEE!"
line "That's right!"
para "You did tune in!"
line "I'm so happy!"
para "You earned one"
line "point! Congrats!"
done
RadioTower2FBuenaDidYouForgetText:
text "BUENA: Aww…"
line "That's not it…"
para "Did you forget the"
line "password?"
done
RadioTower2FBuenaThanksForComingText:
text "BUENA: Yup! Our"
line "contestant was"
para "<PLAY_G>."
line "Thanks for coming!"
para "I hope all you"
line "listeners will"
para "come too!"
line "I'll be waiting!"
done
RadioTower2FBuenaPasswordIsHelpText:
text "BUENA: Huh?"
line "Today's password?"
para "HELP, of course!"
done
RadioTower2FBuenaCardIsFullText:
text "BUENA: Your BLUE"
line "CARD's full."
para "Trade it in for a"
line "fabulous prize!"
done
RadioTower2FBuenaTuneInAfterSixText:
text "BUENA: Tune in to"
line "PASSWORD every"
para "night from six to"
line "midnight!"
para "Tune in, then drop"
line "in for a visit!"
done
RadioTower2FBuenaNoBlueCardText:
text "BUENA: Oh? You"
line "forgot to bring"
cont "your BLUE CARD?"
para "I can't give you"
line "points if you"
cont "don't have it."
done
RadioTower2FBuenaOfferPhoneNumberText:
text "BUENA: Oh! Your"
line "BLUE CARD reached"
para "30 points today!"
line "That's so wild!"
para "Hmm… There isn't a"
line "prize for hitting"
cont "30 points, but…"
para "You came by so"
line "often, <PLAY_G>."
para "I'll make you a"
line "special deal!"
para "How would you like"
line "my phone number?"
done
RadioTower2FBuenaOfferNumberAgainText:
text "BUENA: <PLAY_G>,"
line "do you want to"
para "register my phone"
line "number?"
done
RadioTower2FRegisteredBuenasNumberText:
text "<PLAYER> registered"
line "BUENA's number."
done
RadioTower2FBuenaCallMeText:
text "BUENA: I look"
line "forward to hearing"
cont "from you!"
done
RadioTower2FBuenaSadRejectedText:
text "BUENA: Aww… It's a"
line "special prize…"
done
RadioTower2FBuenaYourPhoneIsFullText:
text "BUENA: <PLAY_G>,"
line "your phone list"
para "has no room left"
line "for me…"
done
RadioTower2FBuenaReceptionistPointsForPrizesText:
text "You can cash in"
line "your saved points"
para "for a lovely prize"
line "of your choice!"
done
RadioTower2FBuenaReceptionistNoCardText:
text "You can't trade in"
line "points without"
cont "your BLUE CARD."
para "Don't forget your"
line "BLUE CARD!"
done
RadioTower2FSalesSignText:
text "2F SALES"
done
RadioTower2FOaksPKMNTalkSignText:
text "PROF.OAK'S #MON"
line "TALK"
para "The Hottest Show"
line "on the Air!"
done
RadioTower2FPokemonRadioSignText:
text "Anywhere, Anytime"
line "#MON Radio"
done
RadioTower2F_MapEvents:
db 0, 0 ; filler
db 2 ; warp events
warp_event 0, 0, RADIO_TOWER_3F, 1
warp_event 15, 0, RADIO_TOWER_1F, 3
db 0 ; coord events
db 6 ; bg events
bg_event 3, 0, BGEVENT_READ, RadioTower2FSalesSign
bg_event 5, 0, BGEVENT_READ, RadioTower2FOaksPKMNTalkSign
bg_event 9, 1, BGEVENT_READ, RadioTower2FBookshelf
bg_event 10, 1, BGEVENT_READ, RadioTower2FBookshelf
bg_event 11, 1, BGEVENT_READ, RadioTower2FBookshelf
bg_event 13, 0, BGEVENT_READ, RadioTower2FPokemonRadioSign
db 11 ; object events
object_event 6, 6, SPRITE_SUPER_NERD, SPRITEMOVEDATA_STANDING_LEFT, 0, 0, -1, -1, PAL_NPC_GREEN, OBJECTTYPE_SCRIPT, 0, RadioTower2FSuperNerdScript, EVENT_GOLDENROD_CITY_CIVILIANS
object_event 17, 2, SPRITE_TEACHER, SPRITEMOVEDATA_WALK_LEFT_RIGHT, 1, 0, -1, -1, PAL_NPC_RED, OBJECTTYPE_SCRIPT, 0, RadioTower2FTeacherScript, -1
object_event 1, 4, SPRITE_ROCKET, SPRITEMOVEDATA_STANDING_UP, 0, 0, -1, -1, 0, OBJECTTYPE_TRAINER, 3, TrainerGruntM4, EVENT_RADIO_TOWER_ROCKET_TAKEOVER
object_event 8, 4, SPRITE_ROCKET, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, 0, OBJECTTYPE_TRAINER, 3, TrainerGruntM5, EVENT_RADIO_TOWER_ROCKET_TAKEOVER
object_event 4, 1, SPRITE_ROCKET, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, 0, OBJECTTYPE_TRAINER, 2, TrainerGruntM6, EVENT_RADIO_TOWER_ROCKET_TAKEOVER
object_event 10, 5, SPRITE_ROCKET_GIRL, SPRITEMOVEDATA_STANDING_UP, 0, 0, -1, -1, PAL_NPC_RED, OBJECTTYPE_TRAINER, 3, TrainerGruntF2, EVENT_RADIO_TOWER_ROCKET_TAKEOVER
object_event 0, 1, SPRITE_BLACK_BELT, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, RadioTower2FBlackBelt1Script, EVENT_RADIO_TOWER_BLACKBELT_BLOCKS_STAIRS
object_event 1, 1, SPRITE_BLACK_BELT, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, RadioTower2FBlackBelt2Script, EVENT_RADIO_TOWER_CIVILIANS_AFTER
object_event 12, 1, SPRITE_JIGGLYPUFF, SPRITEMOVEDATA_POKEMON, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, RadioTowerJigglypuff, -1
object_event 14, 5, SPRITE_BUENA, SPRITEMOVEDATA_STANDING_RIGHT, 0, 0, -1, -1, PAL_NPC_RED, OBJECTTYPE_SCRIPT, 0, Buena, -1
object_event 12, 7, SPRITE_RECEPTIONIST, SPRITEMOVEDATA_STANDING_RIGHT, 0, 0, -1, -1, PAL_NPC_GREEN, OBJECTTYPE_SCRIPT, 0, RadioTowerBuenaPrizeReceptionist, EVENT_GOLDENROD_CITY_CIVILIANS
|
; A242891: Beginning with a centrally symmetric 'Sun' configuration of 8 rhombi with rotational symmetry, number of tiles that can be added to the free edges of the tiling.
; 8,8,8,16,24,24,40,32,48,48,40
sub $3,$0
seq $0,47384 ; Numbers that are congruent to {0, 1, 5} mod 7.
dif $0,6
add $3,1
mov $2,$3
cmp $2,0
add $3,$2
mod $0,$3
mul $0,8
add $0,8
|
.data
theArray:
.word 0 33 123 -66 332 -1 -223 453 9 45 -78
sp_sanity_check_prompt_1:
.asciiz "\nSP ENTER VALUE: "
sp_sanity_check_prompt_2:
.asciiz "\nSP EXIT VALUE: "
print_s_register_prompt:
.asciiz "\nS REGISTERS: "
convention:
.asciiz "\nMy Convention Check\n"
space:
.asciiz " "
newline:
.asciiz "\n"
.text
ConventionCheck:
addi $t0, $0, -1
addi $t1, $0, -1
addi $t2, $0, -1
addi $t3, $0, -1
addi $t4, $0, -1
addi $t5, $0, -1
addi $t6, $0, -1
addi $t7, $0, -1
ori $v0, $0, 4
la $a0, convention
syscall
addi $v0, $zero, -1
addi $v1, $zero, -1
addi $a0, $zero, -1
addi $a1, $zero, -1
addi $a2, $zero, -1
addi $a3, $zero, -1
addi $k0, $zero, -1
addi $k1, $zero, -1
jr $ra
print_s_registers:
la $a0, print_s_register_prompt
li $v0, 4
syscall
# print s0, followed by a space
move $a0, $s0
li $v0, 1
syscall
la $a0, space
li $v0, 4
syscall
# print s1, followed by a space
move $a0, $s1
li $v0, 1
syscall
la $a0, space
li $v0, 4
syscall
# print s2, followed by a space
move $a0, $s2
li $v0, 1
syscall
la $a0, space
li $v0, 4
syscall
# print s3, followed by a space
move $a0, $s3
li $v0, 1
syscall
la $a0, space
li $v0, 4
syscall
# print s4, followed by a space
move $a0, $s4
li $v0, 1
syscall
la $a0, space
li $v0, 4
syscall
# print s5, followed by a space
move $a0, $s5
li $v0, 1
syscall
la $a0, space
li $v0, 4
syscall
# print s6, followed by a space
move $a0, $s6
li $v0, 1
syscall
la $a0, space
li $v0, 4
syscall
# print s7, followed by a newline
move $a0, $s7
li $v0, 1
syscall
la $a0, newline
li $v0, 4
syscall
jr $ra
# Doesn't take any parameters
sp_sanity_check_1:
la $a0, sp_sanity_check_prompt_1
li $v0, 4
syscall
move $a0, $sp
li $v0, 1
syscall
jr $ra
sp_sanity_check_2:
la $a0, sp_sanity_check_prompt_2
li $v0, 4
syscall
move $a0, $sp
li $v0, 1
syscall
jr $ra
sanity_check_end:
# save ra
addi $sp, $sp, -4
sw $ra, 0($sp)
jal sp_sanity_check_2
jal print_s_registers
# restore $ra and return
lw $ra, 0($sp)
addi $sp, $sp, 4
jr $ra
sanity_check_start:
# save ra
addi $sp, $sp, -4
sw $ra, 0($sp)
jal sp_sanity_check_1
jal print_s_registers
# restore $ra and return
lw $ra, 0($sp)
addi $sp, $sp, 4
jr $ra
main:
jal sanity_check_start
la $a0, theArray
li $a1, 11
jal PrintReverse
jal sanity_check_end
li $v0, 10
syscall
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "txdb.h"
#include "walletdb.h"
#include "rpcserver.h"
#include "net.h"
#include "init.h"
#include "state.h"
#include "sync.h"
#include "util.h"
#include "ui_interface.h"
#include "checkpoints.h"
#include "smessage.h"
#include "ringsig.h"
#include "miner.h"
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/filesystem/convenience.hpp>
#include <boost/interprocess/sync/file_lock.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <openssl/crypto.h>
#ifndef WIN32
#include <signal.h>
#endif
namespace fs = boost::filesystem;
CWallet* pwalletMain;
CClientUIInterface uiInterface;
//////////////////////////////////////////////////////////////////////////////
//
// Shutdown
//
//
// Thread management and startup/shutdown:
//
// The network-processing threads are all part of a thread group
// created by AppInit() or the Qt main() function.
//
// A clean exit happens when StartShutdown() or the SIGTERM
// signal handler sets fRequestShutdown, which triggers
// the DetectShutdownThread(), which interrupts the main thread group.
// DetectShutdownThread() then exits, which causes AppInit() to
// continue (it .joins the shutdown thread).
// Shutdown() is then
// called to clean up database connections, and stop other
// threads that should only be stopped after the main network-processing
// threads have exited.
//
// Note that if running -daemon the parent process returns from AppInit2
// before adding any threads to the threadGroup, so .join_all() returns
// immediately and the parent exits from main().
//
// Shutdown for Qt is very similar, only it uses a QTimer to detect
// fRequestShutdown getting set, and then does the normal Qt
// shutdown thing.
//
volatile bool fRequestShutdown = false;
//boost::atomic<bool> fRequestShutdown(false);
void StartShutdown()
{
fRequestShutdown = true;
};
bool ShutdownRequested()
{
return fRequestShutdown;
};
//////////////////////////////////////////////////////////////////////////////
//
// Shutdown
//
bool Finalise()
{
LogPrintf("Finalise()\n");
StopRPCThreads();
ShutdownRPCMining();
SecureMsgShutdown();
mempool.AddTransactionsUpdated(1);
if (pwalletMain)
bitdb.Flush(false);
StopNode();
{
LOCK(cs_main);
if (pwalletMain)
pwalletMain->SetBestChain(CBlockLocator(pindexBest));
}
if (pwalletMain)
bitdb.Flush(true);
UnregisterWallet(pwalletMain);
delete pwalletMain;
pwalletMain = NULL;
finaliseRingSigs();
if (nNodeMode == NT_FULL)
{
std::map<uint256, CBlockIndex*>::iterator it;
for (it = mapBlockIndex.begin(); it != mapBlockIndex.end(); ++it)
{
delete it->second;
};
mapBlockIndex.clear();
if (fDebug)
LogPrintf("mapBlockIndex cleared.\n");
} else
{
std::map<uint256, CBlockThinIndex*>::iterator it;
for (it = mapBlockThinIndex.begin(); it != mapBlockThinIndex.end(); ++it)
{
delete it->second;
};
mapBlockThinIndex.clear();
if (fDebug)
LogPrintf("mapBlockThinIndex cleared.\n");
};
CTxDB().Close();
fs::remove(GetPidFile());
return true;
}
void Shutdown()
{
static CCriticalSection cs_Shutdown;
TRY_LOCK(cs_Shutdown, lockShutdown);
if (!lockShutdown) return;
Finalise();
LogPrintf("Shutdown complete.\n\n");
}
void HandleSIGTERM(int)
{
fRequestShutdown = true;
}
void HandleSIGHUP(int)
{
fReopenDebugLog = true;
}
bool static InitError(const std::string &str)
{
uiInterface.ThreadSafeMessageBox(str, _("ShadowCoin"), CClientUIInterface::BTN_OK | CClientUIInterface::MODAL);
return false;
}
bool static InitWarning(const std::string &str)
{
uiInterface.ThreadSafeMessageBox(str, _("ShadowCoin"), CClientUIInterface::BTN_OK | CClientUIInterface::ICON_WARNING | CClientUIInterface::MODAL);
return true;
}
bool static Bind(const CService &addr, bool fError = true)
{
if (IsLimited(addr))
return false;
std::string strError;
if (!BindListenPort(addr, strError))
{
if (fError)
return InitError(strError);
return false;
};
return true;
}
// Core-specific options shared between UI and daemon
std::string HelpMessage()
{
std::string strUsage = _("Options:") + "\n";
strUsage += " -? " + _("This help message") + "\n";
strUsage += " -conf=<file> " + _("Specify configuration file (default: shadowcoin.conf)") + "\n";
strUsage += " -pid=<file> " + _("Specify pid file (default: shadowcoind.pid)") + "\n";
strUsage += " -datadir=<dir> " + _("Specify data directory") + "\n";
strUsage += " -wallet=<dir> " + _("Specify wallet file (within data directory)") + "\n";
strUsage += " -dbcache=<n> " + _("Set database cache size in megabytes (default: 25)") + "\n";
strUsage += " -dblogsize=<n> " + _("Set database disk log size in megabytes (default: 100)") + "\n";
strUsage += " -timeout=<n> " + _("Specify connection timeout in milliseconds (default: 5000)") + "\n";
strUsage += " -proxy=<ip:port> " + _("Connect through socks proxy") + "\n";
strUsage += " -socks=<n> " + _("Select the version of socks proxy to use (4-5, default: 5)") + "\n";
strUsage += " -tor=<ip:port> " + _("Use proxy to reach tor hidden services (default: same as -proxy)") + "\n";
strUsage += " -dns " + _("Allow DNS lookups for -addnode, -seednode and -connect") + "\n";
strUsage += " -port=<port> " + _("Listen for connections on <port> (default: 51737 or testnet: 51997)") + "\n";
strUsage += " -maxconnections=<n> " + _("Maintain at most <n> connections to peers (default: 125)") + "\n";
strUsage += " -addnode=<ip> " + _("Add a node to connect to and attempt to keep the connection open") + "\n";
strUsage += " -connect=<ip> " + _("Connect only to the specified node(s)") + "\n";
strUsage += " -seednode=<ip> " + _("Connect to a node to retrieve peer addresses, and disconnect") + "\n";
strUsage += " -externalip=<ip> " + _("Specify your own public address") + "\n";
strUsage += " -onlynet=<net> " + _("Only connect to nodes in network <net> (IPv4, IPv6 or Tor)") + "\n";
strUsage += " -discover " + _("Discover own IP address (default: 1 when listening and no -externalip)") + "\n";
strUsage += " -irc " + _("Find peers using internet relay chat (default: 0)") + "\n";
strUsage += " -listen " + _("Accept connections from outside (default: 1 if no -proxy or -connect)") + "\n";
strUsage += " -bind=<addr> " + _("Bind to given address. Use [host]:port notation for IPv6") + "\n";
strUsage += " -dnsseed " + _("Find peers using DNS lookup (default: 1)") + "\n";
strUsage += " -staking " + _("Stake your coins to support network and gain reward (default: 1)") + "\n";
strUsage += " -minstakeinterval=<n> " + _("Minimum time in seconds between successful stakes (default: 30)") + "\n";
strUsage += " -minersleep=<n> " + _("Milliseconds between stake attempts. Lowering this param will not result in more stakes. (default: 500)") + "\n";
strUsage += " -synctime " + _("Sync time with other nodes. Disable if time on your system is precise e.g. syncing with NTP (default: 1)") + "\n";
strUsage += " -cppolicy " + _("Sync checkpoints policy (default: strict)") + "\n";
strUsage += " -banscore=<n> " + _("Threshold for disconnecting misbehaving peers (default: 100)") + "\n";
strUsage += " -bantime=<n> " + _("Number of seconds to keep misbehaving peers from reconnecting (default: 86400)") + "\n";
strUsage += " -softbantime=<n> " + _("Number of seconds to keep soft banned peers from reconnecting (default: 3600)") + "\n";
strUsage += " -maxreceivebuffer=<n> " + _("Maximum per-connection receive buffer, <n>*1000 bytes (default: 5000)") + "\n";
strUsage += " -maxsendbuffer=<n> " + _("Maximum per-connection send buffer, <n>*1000 bytes (default: 1000)") + "\n";
#ifdef USE_UPNP
#if USE_UPNP
strUsage += " -upnp " + _("Use UPnP to map the listening port (default: 1 when listening)") + "\n";
#else
strUsage += " -upnp " + _("Use UPnP to map the listening port (default: 0)") + "\n";
#endif
#endif
strUsage += " -detachdb " + _("Detach block and address databases. Increases shutdown time (default: 0)") + "\n";
strUsage += " -paytxfee=<amt> " + _("Fee per KB to add to transactions you send") + "\n";
strUsage += " -mininput=<amt> " + _("When creating transactions, ignore inputs with value less than this (default: 0.01)") + "\n";
if (fHaveGUI)
strUsage += " -server " + _("Accept command line and JSON-RPC commands") + "\n";
#if !defined(WIN32)
if (fHaveGUI)
strUsage += " -daemon " + _("Run in the background as a daemon and accept commands") + "\n";
#endif
strUsage += " -testnet " + _("Use the test network") + "\n";
strUsage += " -debug " + _("Output extra debugging information. Implies all other -debug* options") + "\n";
strUsage += " -debugnet " + _("Output extra network debugging information") + "\n";
strUsage += " -debugchain " + _("Output extra blockchain debugging information") + "\n";
strUsage += " -debugpos " + _("Output extra Proof of Stake debugging information") + "\n";
strUsage += " -logtimestamps " + _("Prepend debug output with timestamp") + "\n";
strUsage += " -shrinkdebugfile " + _("Shrink debug.log file on client startup (default: 1 when no -debug)") + "\n";
strUsage += " -printtoconsole " + _("Send trace/debug info to console instead of debug.log file") + "\n";
strUsage += " -printtodebuglog " + _("Send trace/debug info to debug.log file") + "\n";
strUsage += " -rpcuser=<user> " + _("Username for JSON-RPC connections") + "\n";
strUsage += " -rpcpassword=<pw> " + _("Password for JSON-RPC connections") + "\n";
strUsage += " -rpcport=<port> " + _("Listen for JSON-RPC connections on <port> (default: 51736 or testnet: 51996)") + "\n";
strUsage += " -rpcallowip=<ip> " + _("Allow JSON-RPC connections from specified IP address") + "\n";
if (!fHaveGUI)
{
strUsage += " -rpcconnect=<ip> " + _("Send commands to node running on <ip> (default: 127.0.0.1)") + "\n";
strUsage += " -rpcwait " + _("Wait for RPC server to start") + "\n";
}
strUsage += " -blocknotify=<cmd> " + _("Execute command when the best block changes (%s in cmd is replaced by block hash)") + "\n";
strUsage += " -walletnotify=<cmd> " + _("Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)") + "\n";
strUsage += " -confchange " + _("Require a confirmations for change (default: 0)") + "\n";
strUsage += " -enforcecanonical " + _("Enforce transaction scripts to use canonical PUSH operators (default: 1)") + "\n";
strUsage += " -alertnotify=<cmd> " + _("Execute command when a relevant alert is received (%s in cmd is replaced by message)") + "\n";
strUsage += " -upgradewallet " + _("Upgrade wallet to latest format") + "\n";
strUsage += " -keypool=<n> " + _("Set key pool size to <n> (default: 100)") + "\n";
strUsage += " -rescan " + _("Rescan the block chain for missing wallet transactions") + "\n";
strUsage += " -salvagewallet " + _("Attempt to recover private keys from a corrupt wallet.dat") + "\n";
strUsage += " -checkblocks=<n> " + _("How many blocks to check at startup (default: 2500, 0 = all)") + "\n";
strUsage += " -checklevel=<n> " + _("How thorough the block verification is (0-6, default: 1)") + "\n";
strUsage += " -loadblock=<file> " + _("Imports blocks from external blk000?.dat file") + "\n";
strUsage += " -reindex " + _("Rebuild block chain index from current blk000?.dat files on startup") + "\n";
strUsage += "\n" + _("Thin options:") + "\n";
strUsage += " -thinmode " + _("Operate in less secure, less resource hungry 'thin' mode") + "\n";
strUsage += " -thinfullindex " + _("Keep the entire block index in memory. (default: 0)") + "\n";
strUsage += " -thinindexmax=<n> " + _("When not thinfullindex, the max number of block headers to keep in memory. (default: 4096)") + "\n";
strUsage += " -nothinssupport " + _("Disable supporting thin nodes. (default: 0)") + "\n";
strUsage += " -nothinstealth " + _("Disable forwarding, or requesting all stealth txns. (default: 0)") + "\n";
strUsage += " -maxthinpeers=<n> " + _("Don't connect to more than <n> thin peers (default: 8)") + "\n";
strUsage += "\n" + _("Block creation options:") + "\n";
strUsage += " -blockminsize=<n> " + _("Set minimum block size in bytes (default: 0)") + "\n";
strUsage += " -blockmaxsize=<n> " + _("Set maximum block size in bytes (default: 250000)") + "\n";
strUsage += " -blockprioritysize=<n> " + _("Set maximum size of high-priority/low-fee transactions in bytes (default: 27000)") + "\n";
strUsage += "\n" + _("SSL options: (see the Bitcoin Wiki for SSL setup instructions)") + "\n";
strUsage += " -rpcssl " + _("Use OpenSSL (https) for JSON-RPC connections") + "\n";
strUsage += " -rpcsslcertificatechainfile=<file.cert> " + _("Server certificate file (default: server.cert)") + "\n";
strUsage += " -rpcsslprivatekeyfile=<file.pem> " + _("Server private key (default: server.pem)") + "\n";
strUsage += " -rpcsslciphers=<ciphers> " + _("Acceptable ciphers (default: TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH)") + "\n";
strUsage += "\n" + _("Secure messaging options:") + "\n";
strUsage += " -nosmsg " + _("Disable secure messaging.") + "\n";
strUsage += " -debugsmsg " + _("Log extra debug messages.") + "\n";
strUsage += " -smsgscanchain " + _("Scan the block chain for public key addresses on startup.") + "\n";
return strUsage;
}
/** Sanity checks
* Ensure that Bitcoin is running in a usable environment with all
* necessary library support.
*/
bool InitSanityCheck(void)
{
if (!ECC_InitSanityCheck())
{
InitError("OpenSSL appears to lack support for elliptic curve cryptography. For more "
"information, visit https://en.bitcoin.it/wiki/OpenSSL_and_EC_Libraries");
return false;
};
// TODO: remaining sanity checks, see #4081
return true;
}
/** Initialize bitcoin.
* @pre Parameters should be parsed and config file should be read.
*/
bool AppInit2(boost::thread_group& threadGroup)
{
// ********************************************************* Step 1: setup
#ifdef _MSC_VER
// Turn off Microsoft heap dump noise
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_WARN, CreateFileA("NUL", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0));
#endif
#if _MSC_VER >= 1400
// Disable confusing "helpful" text message on abort, Ctrl-C
_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
#endif
#ifdef WIN32
// Enable Data Execution Prevention (DEP)
// Minimum supported OS versions: WinXP SP3, WinVista >= SP1, Win Server 2008
// A failure is non-critical and needs no further attention!
#ifndef PROCESS_DEP_ENABLE
// We define this here, because GCCs winbase.h limits this to _WIN32_WINNT >= 0x0601 (Windows 7),
// which is not correct. Can be removed, when GCCs winbase.h is fixed!
#define PROCESS_DEP_ENABLE 0x00000001
#endif
typedef BOOL (WINAPI *PSETPROCDEPPOL)(DWORD);
PSETPROCDEPPOL setProcDEPPol = (PSETPROCDEPPOL)GetProcAddress(GetModuleHandleA("Kernel32.dll"), "SetProcessDEPPolicy");
if (setProcDEPPol != NULL) setProcDEPPol(PROCESS_DEP_ENABLE);
#endif
#ifndef WIN32
umask(077);
// Clean shutdown on SIGTERM
struct sigaction sa;
sa.sa_handler = HandleSIGTERM;
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sigaction(SIGTERM, &sa, NULL);
sigaction(SIGINT, &sa, NULL);
// Reopen debug.log on SIGHUP
struct sigaction sa_hup;
sa_hup.sa_handler = HandleSIGHUP;
sigemptyset(&sa_hup.sa_mask);
sa_hup.sa_flags = 0;
sigaction(SIGHUP, &sa_hup, NULL);
#endif
if (!CheckDiskSpace())
return false;
// ********************************************************* Step 2: parameter interactions
nNodeLifespan = GetArg("-addrlifespan", 7);
nMinStakeInterval = GetArg("-minstakeinterval", 0);
nMinerSleep = GetArg("-minersleep", 500);
// Largest block you're willing to create.
// Limit to betweeen 1K and MAX_BLOCK_SIZE-1K for sanity:
nBlockMaxSize = GetArg("-blockmaxsize", MAX_BLOCK_SIZE_GEN/2);
nBlockMaxSize = std::max((unsigned int)1000, std::min((unsigned int)(MAX_BLOCK_SIZE-1000), nBlockMaxSize));
// How much of the block should be dedicated to high-priority transactions,
// included regardless of the fees they pay
nBlockPrioritySize = GetArg("-blockprioritysize", 27000);
nBlockPrioritySize = std::min(nBlockMaxSize, nBlockPrioritySize);
// Minimum block size you want to create; block will be filled with free transactions
// until there are no more or the block reaches this size:
nBlockMinSize = GetArg("-blockminsize", 0);
nBlockMinSize = std::min(nBlockMaxSize, nBlockMinSize);
// Fee-per-kilobyte amount considered the same as "free"
// Be careful setting this: if you set it to zero then
// a transaction spammer can cheaply fill blocks using
// 1-satoshi-fee transactions. It should be set above the real
// cost to you of processing a transaction.
if (mapArgs.count("-mintxfee"))
ParseMoney(mapArgs["-mintxfee"], nMinTxFee);
if (fDebug)
LogPrintf("nMinerSleep %u\n", nMinerSleep);
CheckpointsMode = Checkpoints::STRICT;
std::string strCpMode = GetArg("-cppolicy", "strict");
if (strCpMode == "strict")
CheckpointsMode = Checkpoints::STRICT;
if (strCpMode == "advisory")
CheckpointsMode = Checkpoints::ADVISORY;
if (strCpMode == "permissive")
CheckpointsMode = Checkpoints::PERMISSIVE;
nDerivationMethodIndex = 0;
fTestNet = GetBoolArg("-testnet");
if (!SelectParamsFromCommandLine())
return InitError("Invalid combination of -testnet and -regtest.");
if (GetBoolArg("-thinmode"))
nNodeMode = NT_THIN;
if (fTestNet)
{
SoftSetBoolArg("-irc", true);
}
if (mapArgs.count("-bind"))
{
// when specifying an explicit binding address, you want to listen on it
// even when -connect or -proxy is specified
SoftSetBoolArg("-listen", true);
}
if (mapArgs.count("-connect") && mapMultiArgs["-connect"].size() > 0)
{
// when only connecting to trusted nodes, do not seed via DNS, or listen by default
SoftSetBoolArg("-dnsseed", false);
SoftSetBoolArg("-listen", false);
}
if (mapArgs.count("-proxy"))
{
// to protect privacy, do not listen by default if a proxy server is specified
SoftSetBoolArg("-listen", false);
}
if (!GetBoolArg("-listen", true))
{
// do not map ports or try to retrieve public IP when not listening (pointless)
SoftSetBoolArg("-upnp", false);
SoftSetBoolArg("-discover", false);
}
if (mapArgs.count("-externalip"))
{
// if an explicit public IP is specified, do not try to find others
SoftSetBoolArg("-discover", false);
}
if (GetBoolArg("-salvagewallet"))
{
// Rewrite just private keys: rescan to find transactions
SoftSetBoolArg("-rescan", true);
}
if (fTestNet)
{
nStakeMinAge = 1 * 60 * 60; // test net min age is 1 hour
nCoinbaseMaturity = 10; // test maturity is 10 blocks
};
// ********************************************************* Step 3: parameter-to-internal-flags
fDebug = !mapMultiArgs["-debug"].empty();
// Special-case: if -debug=0/-nodebug is set, turn off debugging messages
const std::vector<std::string>& categories = mapMultiArgs["-debug"];
if (GetBoolArg("-nodebug", false) || std::find(categories.begin(), categories.end(), std::string("0")) != categories.end())
fDebug = false;
// -debug implies fDebug*, unless otherwise specified
if (fDebug)
{
SoftSetBoolArg("-debugnet", true);
SoftSetBoolArg("-debugsmsg", true);
SoftSetBoolArg("-debugchain", true);
SoftSetBoolArg("-debugringsig", true);
};
fDebugNet = GetBoolArg("-debugnet");
fDebugSmsg = GetBoolArg("-debugsmsg");
fDebugChain = GetBoolArg("-debugchain");
fDebugRingSig = GetBoolArg("-debugringsig");
fDebugPoS = GetBoolArg("-debugpos");
fNoSmsg = GetBoolArg("-nosmsg");
// Check for -socks - as this is a privacy risk to continue, exit here
if (mapArgs.count("-socks"))
return InitError(_("Error: Unsupported argument -socks found. Setting SOCKS version isn't possible anymore, only SOCKS5 proxies are supported."));
bitdb.SetDetach(GetBoolArg("-detachdb", false));
if (fDaemon)
fServer = true;
else
fServer = GetBoolArg("-server", false);
/* force fServer when running without GUI */
if (!fHaveGUI)
fServer = true;
fPrintToConsole = GetBoolArg("-printtoconsole");
fPrintToDebugLog = SoftSetBoolArg("-printtodebuglog", true);
fLogTimestamps = GetBoolArg("-logtimestamps");
if (mapArgs.count("-timeout"))
{
int nNewTimeout = GetArg("-timeout", 5000);
if (nNewTimeout > 0 && nNewTimeout < 600000)
nConnectTimeout = nNewTimeout;
};
if (mapArgs.count("-paytxfee"))
{
if (!ParseMoney(mapArgs["-paytxfee"], nTransactionFee))
return InitError(strprintf(_("Invalid amount for -paytxfee=<amount>: '%s'"), mapArgs["-paytxfee"].c_str()));
if (nTransactionFee > 0.25 * COIN)
InitWarning(_("Warning: -paytxfee is set very high! This is the transaction fee you will pay if you send a transaction."));
};
fConfChange = GetBoolArg("-confchange", false);
fEnforceCanonical = GetBoolArg("-enforcecanonical", true);
if (mapArgs.count("-mininput"))
{
if (!ParseMoney(mapArgs["-mininput"], nMinimumInputValue))
return InitError(strprintf(_("Invalid amount for -mininput=<amount>: '%s'"), mapArgs["-mininput"].c_str()));
};
// ********************************************************* Step 4: application initialization: dir lock, daemonize, pidfile, debug log
// Sanity check
if (!InitSanityCheck())
return InitError(_("Initialization sanity check failed. ShadowCoin is shutting down."));
std::string strDataDir = GetDataDir().string();
std::string strWalletFileName = GetArg("-wallet", "wallet.dat");
// strWalletFileName must be a plain filename without a directory
if (strWalletFileName != fs::basename(strWalletFileName) + fs::extension(strWalletFileName))
return InitError(strprintf(_("Wallet %s resides outside data directory %s."), strWalletFileName.c_str(), strDataDir.c_str()));
// Make sure only a single Bitcoin process is using the data directory.
fs::path pathLockFile = GetDataDir() / ".lock";
FILE* file = fopen(pathLockFile.string().c_str(), "a"); // empty lock file; created if it doesn't exist.
if (file)
fclose(file);
static boost::interprocess::file_lock lock(pathLockFile.string().c_str());
if (!lock.try_lock())
return InitError(strprintf(_("Cannot obtain a lock on data directory %s. ShadowCoin is probably already running."), strDataDir.c_str()));
if (GetBoolArg("-shrinkdebugfile", !fDebug))
ShrinkDebugFile();
LogPrintf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
LogPrintf("ShadowCoin version %s (%s)\n", FormatFullVersion().c_str(), CLIENT_DATE.c_str());
LogPrintf("Operating in %s mode.\n", GetNodeModeName(nNodeMode));
LogPrintf("Using OpenSSL version %s\n", SSLeay_version(SSLEAY_VERSION));
if (!fLogTimestamps)
LogPrintf("Startup time: %s\n", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str());
LogPrintf("Default data directory %s\n", GetDefaultDataDir().string().c_str());
LogPrintf("Used data directory %s\n", strDataDir.c_str());
std::ostringstream strErrors;
if (fDaemon)
{
fprintf(stdout, "ShadowCoin server starting\n");
fflush(stdout);
};
int64_t nStart;
/* *********************************************************
Step 4.5: adjust parameters for nNodeMode
********************************************************* */
switch (nNodeMode)
{
case NT_FULL:
if (GetBoolArg("-nothinssupport"))
{
LogPrintf("Thin support disabled.\n");
nLocalServices &= ~(THIN_SUPPORT);
};
if (GetBoolArg("-nothinstealth"))
{
LogPrintf("Thin stealth support disabled.\n");
nLocalServices &= ~(THIN_STEALTH);
};
break;
case NT_THIN:
SetBoolArg("-staking", false);
// -- clear services
nLocalServices &= ~(NODE_NETWORK);
nLocalServices &= ~(THIN_SUPPORT);
nLocalServices &= ~(THIN_STAKE);
nLocalServices &= ~(THIN_STEALTH);
nLocalRequirements |= (THIN_SUPPORT);
if (GetBoolArg("-thinfullindex"))
{
LogPrintf("Thin full index enabled.\n");
fThinFullIndex = true;
} else
{
nThinIndexWindow = GetArg("-thinindexmax", 4096);
if (nThinIndexWindow < 4096)
{
LogPrintf("Thin index window minimum size is %d.\n", 4096);
nThinIndexWindow = 4096;
};
LogPrintf("Thin index window size %d.\n", nThinIndexWindow);
};
if (GetBoolArg("-nothinstealth"))
{
LogPrintf("Thin stealth disabled.\n");
} else
{
nLocalRequirements |= (THIN_STEALTH);
};
break;
default:
break;
};
// -- thin and full
if (fNoSmsg)
nLocalServices &= ~(SMSG_RELAY);
if (initialiseRingSigs() != 0)
return InitError("initialiseRingSigs() failed.");
// ********************************************************* Step 5: verify database integrity
uiInterface.InitMessage(_("Verifying database integrity..."));
if (!bitdb.Open(GetDataDir()))
{
std::string msg = strprintf(_("Error initializing database environment %s!"
" To recover, BACKUP THAT DIRECTORY, then remove"
" everything from it except for wallet.dat."), strDataDir.c_str());
return InitError(msg);
};
if (GetBoolArg("-salvagewallet"))
{
// Recover readable keypairs:
if (!CWalletDB::Recover(bitdb, strWalletFileName, true))
return false;
};
if (fs::exists(GetDataDir() / strWalletFileName))
{
CDBEnv::VerifyResult r = bitdb.Verify(strWalletFileName, CWalletDB::Recover);
if (r == CDBEnv::RECOVER_OK)
{
std::string msg = strprintf(_("Warning: wallet.dat corrupt, data salvaged!"
" Original wallet.dat saved as wallet.{timestamp}.bak in %s; if"
" your balance or transactions are incorrect you should"
" restore from a backup."), strDataDir.c_str());
uiInterface.ThreadSafeMessageBox(msg, _("ShadowCoin"), CClientUIInterface::BTN_OK | CClientUIInterface::ICON_WARNING | CClientUIInterface::MODAL);
};
if (r == CDBEnv::RECOVER_FAIL)
return InitError(_("wallet.dat corrupt, salvage failed"));
};
// ********************************************************* Step 6: network initialization
nMaxThinPeers = GetArg("-maxthinpeers", 8);
nBloomFilterElements = GetArg("-bloomfilterelements", 1536);
if (mapArgs.count("-onlynet"))
{
std::set<enum Network> nets;
BOOST_FOREACH(std::string snet, mapMultiArgs["-onlynet"])
{
enum Network net = ParseNetwork(snet);
if (net == NET_UNROUTABLE)
return InitError(strprintf(_("Unknown network specified in -onlynet: '%s'"), snet.c_str()));
nets.insert(net);
};
for (int n = 0; n < NET_MAX; n++)
{
enum Network net = (enum Network)n;
if (!nets.count(net))
SetLimited(net);
};
};
CService addrProxy;
bool fProxy = false;
if (mapArgs.count("-proxy")) {
addrProxy = CService(mapArgs["-proxy"], 9050);
if (!addrProxy.IsValid())
return InitError(strprintf(_("Invalid -proxy address: '%s'"), mapArgs["-proxy"]));
SetProxy(NET_IPV4, addrProxy);
SetProxy(NET_IPV6, addrProxy);
SetNameProxy(addrProxy);
fProxy = true;
}
// -tor can override normal proxy, -notor disables tor entirely
if (!(mapArgs.count("-tor") && mapArgs["-tor"] == "0") &&
(fProxy || mapArgs.count("-tor"))) {
CService addrOnion;
if (!mapArgs.count("-tor"))
addrOnion = addrProxy;
else
addrOnion = CService(mapArgs["-tor"], 9050);
if (!addrOnion.IsValid())
return InitError(strprintf(_("Invalid -tor address: '%s'"), mapArgs["-tor"]));
SetProxy(NET_TOR, addrOnion);
SetReachable(NET_TOR);
}
// see Step 2: parameter interactions for more information about these
fNoListen = !GetBoolArg("-listen", true);
fDiscover = GetBoolArg("-discover", true);
fNameLookup = GetBoolArg("-dns", true);
#ifdef USE_UPNP
fUseUPnP = GetBoolArg("-upnp", USE_UPNP);
#endif
bool fBound = false;
if (!fNoListen)
{
std::string strError;
if (mapArgs.count("-bind"))
{
BOOST_FOREACH(std::string strBind, mapMultiArgs["-bind"])
{
CService addrBind;
if (!Lookup(strBind.c_str(), addrBind, GetListenPort(), false))
return InitError(strprintf(_("Cannot resolve -bind address: '%s'"), strBind.c_str()));
fBound |= Bind(addrBind);
};
} else
{
struct in_addr inaddr_any;
inaddr_any.s_addr = INADDR_ANY;
if (!IsLimited(NET_IPV6))
fBound |= Bind(CService(in6addr_any, GetListenPort()), false);
if (!IsLimited(NET_IPV4))
fBound |= Bind(CService(inaddr_any, GetListenPort()), !fBound);
};
if (!fBound)
return InitError(_("Failed to listen on any port. Use -listen=0 if you want this."));
};
if (mapArgs.count("-externalip"))
{
BOOST_FOREACH(std::string strAddr, mapMultiArgs["-externalip"])
{
CService addrLocal(strAddr, GetListenPort(), fNameLookup);
if (!addrLocal.IsValid())
return InitError(strprintf(_("Cannot resolve -externalip address: '%s'"), strAddr.c_str()));
AddLocal(CService(strAddr, GetListenPort(), fNameLookup), LOCAL_MANUAL);
};
};
if (mapArgs.count("-reservebalance")) // ppcoin: reserve balance amount
{
if (!ParseMoney(mapArgs["-reservebalance"], nReserveBalance))
{
InitError(_("Invalid amount for -reservebalance=<amount>"));
return false;
};
};
// TODO: posv2 remove
if (mapArgs.count("-checkpointkey")) // ppcoin: checkpoint master priv key
{
if (!Checkpoints::SetCheckpointPrivKey(GetArg("-checkpointkey", "")))
InitError(_("Unable to sign checkpoint, wrong checkpointkey?\n"));
};
BOOST_FOREACH(std::string strDest, mapMultiArgs["-seednode"])
AddOneShot(strDest);
// ********************************************************* Step 7: load blockchain
if (!bitdb.Open(GetDataDir()))
{
std::string msg = strprintf(_("Error initializing database environment %s!"
" To recover, BACKUP THAT DIRECTORY, then remove"
" everything from it except for wallet.dat."), strDataDir.c_str());
return InitError(msg);
};
if (GetBoolArg("-loadblockindextest"))
{
CTxDB txdb("r");
txdb.LoadBlockIndex();
PrintBlockTree();
return false;
};
uiInterface.InitMessage(_("Loading block index..."));
LogPrintf("Loading block index...\n");
nStart = GetTimeMillis();
// -- wipe the txdb if a reindex is queued
if (mapArgs.count("-reindex"))
{
LOCK(cs_main);
CTxDB txdb("cr+");
txdb.RecreateDB();
};
switch (LoadBlockIndex())
{
case 1:
return InitError(_("Error loading blkindex.dat"));
case 2:
if (nNodeMode == NT_FULL)
{
LogPrintf("TxDb wiped, reindex requested.\n");
mapArgs["-reindex"] = 1;
};
break;
};
// as LoadBlockIndex can take several minutes, it's possible the user
// requested to kill bitcoin-qt during the last operation. If so, exit.
// As the program has not fully started yet, Shutdown() is possibly overkill.
if (fRequestShutdown)
{
LogPrintf("Shutdown requested. Exiting.\n");
return false;
};
LogPrintf(" block index %15dms\n", GetTimeMillis() - nStart);
if (GetBoolArg("-printblockindex") || GetBoolArg("-printblocktree"))
{
PrintBlockTree();
return false;
};
if (mapArgs.count("-printblock"))
{
std::string strMatch = mapArgs["-printblock"];
int nFound = 0;
for (std::map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.begin(); mi != mapBlockIndex.end(); ++mi)
{
uint256 hash = (*mi).first;
if (strncmp(hash.ToString().c_str(), strMatch.c_str(), strMatch.size()) == 0)
{
CBlockIndex* pindex = (*mi).second;
CBlock block;
block.ReadFromDisk(pindex);
block.BuildMerkleTree();
block.print();
LogPrintf("\n");
nFound++;
};
};
if (nFound == 0)
LogPrintf("No blocks matching %s were found\n", strMatch.c_str());
return false;
};
// ********************************************************* Step 8: load wallet
uiInterface.InitMessage(_("Loading wallet..."));
LogPrintf("Loading wallet...\n");
nStart = GetTimeMillis();
bool fFirstRun = true;
pwalletMain = new CWallet(strWalletFileName);
DBErrors nLoadWalletRet = pwalletMain->LoadWallet(fFirstRun);
if (nLoadWalletRet != DB_LOAD_OK)
{
if (nLoadWalletRet == DB_CORRUPT)
{
strErrors << _("Error loading wallet.dat: Wallet corrupted") << "\n";
} else
if (nLoadWalletRet == DB_NONCRITICAL_ERROR)
{
std::string msg(_("Warning: error reading wallet.dat! All keys read correctly, but transaction data"
" or address book entries might be missing or incorrect."));
uiInterface.ThreadSafeMessageBox(msg, _("ShadowCoin"), CClientUIInterface::BTN_OK | CClientUIInterface::ICON_WARNING | CClientUIInterface::MODAL);
} else
if (nLoadWalletRet == DB_TOO_NEW)
{
strErrors << _("Error loading wallet.dat: Wallet requires newer version of ShadowCoin") << "\n";
} else
if (nLoadWalletRet == DB_NEED_REWRITE)
{
strErrors << _("Wallet needed to be rewritten: restart ShadowCoin to complete") << "\n";
LogPrintf("%s", strErrors.str().c_str());
return InitError(strErrors.str());
} else
{
strErrors << _("Error loading wallet.dat") << "\n";
};
};
if (GetBoolArg("-upgradewallet", fFirstRun))
{
int nMaxVersion = GetArg("-upgradewallet", 0);
if (nMaxVersion == 0) // the -upgradewallet without argument case
{
LogPrintf("Performing wallet upgrade to %i\n", FEATURE_LATEST);
nMaxVersion = CLIENT_VERSION;
pwalletMain->SetMinVersion(FEATURE_LATEST); // permanently upgrade the wallet immediately
} else
{
LogPrintf("Allowing wallet upgrade up to %i\n", nMaxVersion);
};
if (nMaxVersion < pwalletMain->GetVersion())
strErrors << _("Cannot downgrade wallet") << "\n";
pwalletMain->SetMaxVersion(nMaxVersion);
};
if (fFirstRun)
{
// Create new keyUser and set as default key
RandAddSeedPerfmon();
CPubKey newDefaultKey;
if (pwalletMain->GetKeyFromPool(newDefaultKey, false))
{
pwalletMain->SetDefaultKey(newDefaultKey);
if (!pwalletMain->SetAddressBookName(pwalletMain->vchDefaultKey.GetID(), ""))
strErrors << _("Cannot write default address") << "\n";
};
};
LogPrintf("%s", strErrors.str().c_str());
LogPrintf(" wallet %15dms\n", GetTimeMillis() - nStart);
RegisterWallet(pwalletMain);
CBlockIndex *pindexRescan = pindexBest;
if (GetBoolArg("-rescan"))
{
pindexRescan = pindexGenesisBlock;
} else
{
CWalletDB walletdb(strWalletFileName);
CBlockLocator locator;
if (walletdb.ReadBestBlock(locator))
pindexRescan = locator.GetBlockIndex();
};
if (pindexBest != pindexRescan && pindexBest && pindexRescan && pindexBest->nHeight > pindexRescan->nHeight)
{
uiInterface.InitMessage(_("Rescanning..."));
LogPrintf("Rescanning last %i blocks (from block %i)...\n", pindexBest->nHeight - pindexRescan->nHeight, pindexRescan->nHeight);
nStart = GetTimeMillis();
pwalletMain->ScanForWalletTransactions(pindexRescan, true);
LogPrintf(" rescan %15dms\n", GetTimeMillis() - nStart);
};
// ********************************************************* Step 9: import blocks
if (mapArgs.count("-loadblock"))
{
uiInterface.InitMessage(_("Importing blockchain data file."));
BOOST_FOREACH(std::string strFile, mapMultiArgs["-loadblock"])
{
FILE* file = fopen(strFile.c_str(), "rb");
if (file)
LoadExternalBlockFile(0, file);
else
LogPrintf("Error: -loadblock '%s' - file not found.\n", strFile.c_str());
};
LogPrintf("Terminating: loadblock completed.\n");
Finalise();
exit(0);
};
fs::path pathBootstrap = GetDataDir() / "bootstrap.dat";
if (fs::exists(pathBootstrap))
{
uiInterface.InitMessage(_("Importing bootstrap blockchain data file."));
FILE* file = fopen(pathBootstrap.string().c_str(), "rb");
if (file)
{
fs::path pathBootstrapOld = GetDataDir() / "bootstrap.dat.old";
LoadExternalBlockFile(0, file);
RenameOver(pathBootstrap, pathBootstrapOld);
};
};
if (mapArgs.count("-reindex"))
{
uiInterface.InitMessage(_("Reindexing from blk000?.dat files."));
fReindexing = true;
int nFile = 1;
while (true)
{
FILE* file = OpenBlockFile(false, nFile, 0, "rb");
if (!file)
break;
LogPrintf("Reindexing block file blk%04u.dat...\n", (unsigned int)nFile);
LoadExternalBlockFile(nFile, file);
nFile++;
};
LogPrintf("Terminating: reindex completed.\n");
Finalise();
exit(0);
};
// ********************************************************* Step 10: load peers
uiInterface.InitMessage(_("Loading addresses..."));
LogPrintf("Loading addresses...\n");
nStart = GetTimeMillis();
{
CAddrDB adb;
if (!adb.Read(addrman))
LogPrintf("Invalid or missing peers.dat; recreating\n");
}
LogPrintf("Loaded %i addresses from peers.dat %dms\n",
addrman.size(), GetTimeMillis() - nStart);
// ********************************************************* Step 10.1: startup secure messaging
SecureMsgStart(fNoSmsg, GetBoolArg("-smsgscanchain"));
// ********************************************************* Step 11: start node
if (!CheckDiskSpace())
return false;
RandAddSeedPerfmon();
//// debug print
LogPrintf("mapBlockIndex.size() = %u\n", mapBlockIndex.size());
LogPrintf("mapBlockThinIndex.size() = %u\n", mapBlockThinIndex.size());
LogPrintf("nBestHeight = %d\n", nBestHeight);
LogPrintf("setKeyPool.size() = %u\n", pwalletMain->setKeyPool.size());
LogPrintf("mapWallet.size() = %u\n", pwalletMain->mapWallet.size());
LogPrintf("mapAddressBook.size() = %u\n", pwalletMain->mapAddressBook.size());
StartNode(threadGroup);
if (fServer)
StartRPCThreads();
// ********************************************************* Step 12: finished
// Add wallet transactions that aren't already in a block to mapTransactions
pwalletMain->ReacceptWalletTransactions();
// Run a thread to flush wallet periodically
threadGroup.create_thread(boost::bind(&TraceThread<void (*)(const std::string&), const std::string&>, "wflush", &ThreadFlushWalletDB, boost::ref(pwalletMain->strWalletFile)));
InitRPCMining();
// Mine proof-of-stake blocks in the background
if (!GetBoolArg("-staking", true))
LogPrintf("Staking disabled\n");
else
threadGroup.create_thread(boost::bind(&TraceThread<void (*)(CWallet*), CWallet*>, "miner", &ThreadStakeMiner, pwalletMain));
if (nNodeMode != NT_FULL)
pwalletMain->InitBloomFilter();
uiInterface.InitMessage(_("Done loading"));
LogPrintf("Done loading\n");
if (!strErrors.str().empty())
return InitError(strErrors.str());
LogPrintf("Params().GetDefaultPort() %d\n", Params().GetDefaultPort());
return !fRequestShutdown;
}
|
#include "procedural_object_system.h"
#include "common/assertions.h"
#include "common/logger.h"
#include "common/profiler.h"
#include "procedural_component_system.h"
#include "procedural_object.h"
namespace pagoda
{
ProceduralObjectSystem::ProceduralObjectSystem() { LOG_TRACE(Core, "Creating ProceduralObjectSystem"); }
ProceduralObjectSystem::~ProceduralObjectSystem() { LOG_TRACE(Core, "Destroying ProceduralObjectSystem"); }
std::shared_ptr<ProceduralObject> ProceduralObjectSystem::CreateProceduralObject()
{
START_PROFILE;
auto object = std::make_shared<ProceduralObject>();
m_proceduralObjects.insert(object);
return object;
}
bool ProceduralObjectSystem::RegisterProceduralComponentSystem(std::shared_ptr<ProceduralComponentSystemBase> system)
{
START_PROFILE;
LOG_TRACE(Core, "Registering ProceduralComponentSystem with name " << system->GetComponentSystemTypeName().c_str());
auto system_type = system->GetComponentSystemTypeName();
if (m_proceduralComponentSystems.find(system_type) != std::end(m_proceduralComponentSystems))
{
return false;
}
m_proceduralComponentSystems.insert(std::make_pair(system_type, system));
return true;
}
bool ProceduralObjectSystem::UnregisterProceduralComponentSystem(std::shared_ptr<ProceduralComponentSystemBase> system)
{
START_PROFILE;
auto system_type = system->GetComponentSystemTypeName();
DBG_ASSERT_MSG(m_proceduralObjects.size() == 0,
"Unregistering a ComponentSystem while there are procedural objects may cause incorrect behaviour.");
auto iteratorToSystems = m_proceduralComponentSystems.find(system_type);
if (iteratorToSystems == std::end(m_proceduralComponentSystems))
{
return false;
}
m_proceduralComponentSystems.erase(iteratorToSystems);
return true;
}
std::shared_ptr<ProceduralComponentSystemBase> ProceduralObjectSystem::GetComponentSystem(const std::string& systemName)
{
START_PROFILE;
auto iteratorToSystems = m_proceduralComponentSystems.find(systemName);
if (iteratorToSystems == std::end(m_proceduralComponentSystems))
{
return nullptr;
}
return iteratorToSystems->second;
}
void ProceduralObjectSystem::KillProceduralObject(std::shared_ptr<ProceduralObject>& proceduralObject)
{
START_PROFILE;
if (proceduralObject == nullptr)
{
return;
}
for (auto& system : m_proceduralComponentSystems)
{
system.second->KillProceduralComponent(proceduralObject);
}
m_proceduralObjects.erase(proceduralObject);
}
} // namespace pagoda
|
;/*
; * Microsoft Confidential
; * Copyright (C) Microsoft Corporation 1991
; * All Rights Reserved.
; */
; The following are all of the segments used in the load order
;
;SR; We switch the order of the CODE and DATA segments since we will have to
;move the CODE segment for HIMEM COMMAND
;
DATARES segment public byte ; resident data
DATARES ends
;
;Dummy segment to align the code segment on a paragraph boundary
;
DUMMY segment public para
DUMMY ENDS
CODERES segment public byte ; resident code
CODERES ends
;SR;
;No environment segments
;
;;ENVARENA segment public para ; space for DOS ALLOCATE header
;;ENVARENA ends
;;ENVIRONMENT segment public para ; default COMMAND environment
;;ENVIRONMENT ends
INIT segment public para ; initialization code
INIT ends
TAIL segment public para ; end of init - start of transient
TAIL ends
TRANCODE segment public byte ; transient code
TRANCODE ends
TRANDATA segment public byte ; transient data area
TRANDATA ends
TRANSPACE segment public byte ; transient modifiable data area
TRANSPACE ends
TRANTAIL segment public para ; end of transient
TRANTAIL ends
;SR;
; We still keep the CODE and DATA in a group. This is to make addressability
;easy during init. This will not work for COMMAND in ROM but it is fine for
;HIMEM COMMAND. However, the resident code will not refer to any data using
;RESGROUP
;
RESGROUP group CODERES,DATARES,INIT,TAIL
TRANGROUP group TRANCODE,TRANDATA,TRANSPACE,TRANTAIL
|
format PE console
entry start
include 'win32a.inc'
section '.idata' import data readable writeable
library kernel32, 'kernel32.dll', \
msvcrt, 'MSVCRT.DLL'
import kernel32, \
ExitProcess, 'ExitProcess'
import msvcrt, \
printf, 'printf'
section '.data' data readable
szHelloWorld db 'Hello World',10,0
section '.text' code readable executable
start:
push szHelloWorld
call [printf]
add esp, 4
exit:
push 0
call [ExitProcess] |
db 0 ; species ID placeholder
db 100, 90, 130, 55, 45, 65
; hp atk def spd sat sdf
db WATER, ROCK ; type
db 25 ; catch rate
db 198 ; base exp
db NO_ITEM, DEEPSEASCALE ; items
db GENDER_F12_5 ; gender ratio
db 40 ; step cycles to hatch
INCBIN "gfx/pokemon/relicanth/front.dimensions"
db GROWTH_SLOW ; growth rate
dn EGG_WATER_1, EGG_WATER_2 ; egg groups
db 70 ; happiness
; tm/hm learnset
tmhm WATER_PULSE, CALM_MIND, TOXIC, HAIL, HIDDEN_POWER, ICE_BEAM, BLIZZARD, HYPER_BEAM, PROTECT, RAIN_DANCE, SAFEGUARD, FRUSTRATION, EARTHQUAKE, RETURN, DOUBLE_TEAM, SANDSTORM, ROCK_TOMB, FACADE, SECRET_POWER, REST, ATTRACT, BRINE, ENDURE, GIGA_IMPACT, ROCK_POLISH, STONE_EDGE, STEALTH_ROCK, PSYCH_UP, CAPTIVATE, ROCK_SLIDE, SLEEP_TALK, NATURAL_GIFT, SWAGGER, SUBSTITUTE, SURF, ROCK_SMASH, WATERFALL, ANCIENTPOWER, AQUA_TAIL, BOUNCE, DIVE, EARTH_POWER, ICY_WIND, MUD_SLAP, SNORE
; end
|
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) Berkeley Softworks 1990 -- All Rights Reserved
PROJECT: PC GEOS
MODULE: Epson 9-pin print drivers
FILE: printcomEpsonMXGraphics.asm
AUTHOR: Dave Durran 1 March 1990
ROUTINES:
Name Description
---- -----------
REVISION HISTORY:
Name Date Description
---- ---- -----------
Dave 3/1/90 Initial revision
Dave 3/92 moved from epson9
DESCRIPTION:
This file contains most of the code to implement the epson MX type
print driver graphics mode support
$Id: printcomEpsonMXGraphics.asm,v 1.1 97/04/18 11:50:27 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
include Graphics/graphicsCommon.asm ;common graphic print routines
include Graphics/graphics3Resolutions.asm ;PrPrintABand routine.
include Graphics/graphicsEpsonCommon.asm ;common Epson graphic rout.
include Graphics/graphicsPrintSwath216.asm ;PrintSwath routine.
include Graphics/graphicsHi8IntY.asm ;Hi res routine,
include Graphics/graphicsMed8Int3Y.asm ;Medium res. routine,
include Graphics/Rotate/rotate3x4.asm ;and rotate routine.
include Graphics/graphicsLo8.asm ;Lo res routine,
include Graphics/Rotate/rotate8.asm ;and rotate routine.
|
###############################################################################
# Copyright 2019 Intel Corporation
# All Rights Reserved.
#
# If this software was obtained under the Intel Simplified Software License,
# the following terms apply:
#
# The source code, information and material ("Material") contained herein is
# owned by Intel Corporation or its suppliers or licensors, and title to such
# Material remains with Intel Corporation or its suppliers or licensors. The
# Material contains proprietary information of Intel or its suppliers and
# licensors. The Material is protected by worldwide copyright laws and treaty
# provisions. No part of the Material may be used, copied, reproduced,
# modified, published, uploaded, posted, transmitted, distributed or disclosed
# in any way without Intel's prior express written permission. No license under
# any patent, copyright or other intellectual property rights in the Material
# is granted to or conferred upon you, either expressly, by implication,
# inducement, estoppel or otherwise. Any license under such intellectual
# property rights must be express and approved by Intel in writing.
#
# Unless otherwise agreed by Intel in writing, you may not remove or alter this
# notice or any other notice embedded in Materials by Intel or Intel's
# suppliers or licensors in any way.
#
#
# If this software was obtained under the Apache License, Version 2.0 (the
# "License"), the following terms apply:
#
# 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.
###############################################################################
.section .note.GNU-stack,"",%progbits
.text
.p2align 4, 0x90
.globl s8_PurgeBlock
.type s8_PurgeBlock, @function
s8_PurgeBlock:
push %ebp
mov %esp, %ebp
push %edi
movl (8)(%ebp), %edi
movl (12)(%ebp), %ecx
xor %eax, %eax
sub $(4), %ecx
jl .Ltest_purgegas_1
.Lpurge4gas_1:
movl %eax, (%edi)
add $(4), %edi
sub $(4), %ecx
jge .Lpurge4gas_1
.Ltest_purgegas_1:
add $(4), %ecx
jz .Lquitgas_1
.Lpurge1gas_1:
movb %al, (%edi)
add $(1), %edi
sub $(1), %ecx
jg .Lpurge1gas_1
.Lquitgas_1:
pop %edi
pop %ebp
ret
.Lfe1:
.size s8_PurgeBlock, .Lfe1-(s8_PurgeBlock)
|
class Solution {
public:
int strStr(string haystack, string needle) {
return haystack.find(needle);
}
}; |
; void *memalign_unlocked(size_t alignment, size_t size)
PUBLIC memalign_unlocked_callee
EXTERN aligned_alloc_unlocked_callee
defc memalign_unlocked_callee = aligned_alloc_unlocked_callee
INCLUDE "alloc/malloc/z80/asm_memalign_unlocked.asm"
|
#include <iostream>
using namespace std;
int MaxSubseqsum(int *a,int k)
{
int This_Sum = 0;
int Max_Sum = 0 ;
for ( int i = 0 ; i < k ; i++ )
{
This_Sum += a[i];
if ( This_Sum > Max_Sum )
Max_Sum = This_Sum;
else if ( This_Sum < 0 )
This_Sum = 0;
}
return Max_Sum;
}
int main()
{
int k;
cin>>k;
int a[k];
for (int i = 0 ; i < k ; i++ )
cin>>a[i];
int Max = MaxSubseqsum(a,k);
cout<< Max;
return 0;
}
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r8
push %rax
push %rcx
push %rdi
push %rsi
lea addresses_normal_ht+0x1a4d1, %rsi
lea addresses_WC_ht+0xcc2d, %rdi
nop
nop
nop
sub $56150, %r8
mov $49, %rcx
rep movsl
mfence
lea addresses_WT_ht+0x1db39, %r10
nop
nop
xor %rax, %rax
mov (%r10), %ecx
nop
nop
nop
xor $25586, %r10
pop %rsi
pop %rdi
pop %rcx
pop %rax
pop %r8
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r12
push %r8
push %r9
push %rax
push %rdx
// Store
lea addresses_WC+0x1257b, %r8
clflush (%r8)
nop
nop
nop
add %rax, %rax
mov $0x5152535455565758, %r11
movq %r11, %xmm3
movups %xmm3, (%r8)
nop
nop
dec %r10
// Store
lea addresses_D+0xae1, %r10
nop
cmp %r11, %r11
movb $0x51, (%r10)
nop
xor $60281, %r10
// Store
lea addresses_WC+0xda85, %rax
nop
nop
nop
nop
nop
add %r12, %r12
movw $0x5152, (%rax)
nop
nop
nop
nop
nop
dec %r10
// Store
mov $0x799, %r11
nop
nop
nop
nop
mfence
movw $0x5152, (%r11)
nop
sub %r9, %r9
// Store
lea addresses_RW+0x37f9, %r10
clflush (%r10)
nop
nop
nop
nop
nop
xor $55831, %r9
movb $0x51, (%r10)
and %r9, %r9
// Store
lea addresses_RW+0x8bc6, %r12
nop
nop
inc %r9
movb $0x51, (%r12)
xor %r12, %r12
// Store
lea addresses_D+0x7d91, %rax
nop
cmp $9720, %r12
mov $0x5152535455565758, %rdx
movq %rdx, %xmm2
vmovups %ymm2, (%rax)
nop
inc %rax
// Store
lea addresses_WT+0x15cb9, %rdx
nop
nop
nop
nop
add %r10, %r10
mov $0x5152535455565758, %r11
movq %r11, %xmm7
vmovups %ymm7, (%rdx)
nop
xor $27470, %r11
// Store
mov $0x1a39c70000000f51, %r9
nop
inc %r10
mov $0x5152535455565758, %r8
movq %r8, %xmm4
movups %xmm4, (%r9)
nop
nop
and $6856, %r10
// Store
lea addresses_normal+0x183d1, %r12
and $40948, %r10
mov $0x5152535455565758, %rax
movq %rax, (%r12)
nop
nop
nop
nop
and %r10, %r10
// Store
lea addresses_D+0x15c4d, %r10
nop
nop
nop
nop
nop
and %rax, %rax
mov $0x5152535455565758, %r12
movq %r12, %xmm1
movups %xmm1, (%r10)
nop
add %rax, %rax
// Store
mov $0x3b1, %r10
sub $43270, %rax
movw $0x5152, (%r10)
cmp %r9, %r9
// Store
lea addresses_UC+0x84d1, %r8
nop
nop
nop
inc %rdx
mov $0x5152535455565758, %r12
movq %r12, %xmm4
movups %xmm4, (%r8)
cmp %rax, %rax
// Store
lea addresses_US+0x109d1, %r8
nop
nop
nop
nop
add $58556, %rdx
mov $0x5152535455565758, %r9
movq %r9, (%r8)
nop
inc %r11
// Faulty Load
lea addresses_D+0x3cd1, %rdx
clflush (%rdx)
nop
nop
nop
nop
nop
and $21170, %r8
mov (%rdx), %rax
lea oracles, %r11
and $0xff, %rax
shlq $12, %rax
mov (%r11,%rax,1), %rax
pop %rdx
pop %rax
pop %r9
pop %r8
pop %r12
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0, 'same': False, 'type': 'addresses_D'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 1, 'same': False, 'type': 'addresses_WC'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 4, 'same': False, 'type': 'addresses_D'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 1, 'same': False, 'type': 'addresses_WC'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 3, 'same': False, 'type': 'addresses_P'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 2, 'same': False, 'type': 'addresses_RW'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0, 'same': False, 'type': 'addresses_RW'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 5, 'same': False, 'type': 'addresses_D'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 3, 'same': False, 'type': 'addresses_WT'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 7, 'same': False, 'type': 'addresses_NC'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': True, 'size': 8, 'congruent': 7, 'same': False, 'type': 'addresses_normal'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 2, 'same': False, 'type': 'addresses_D'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 5, 'same': False, 'type': 'addresses_P'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 7, 'same': False, 'type': 'addresses_UC'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 8, 'same': False, 'type': 'addresses_US'}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0, 'same': True, 'type': 'addresses_D'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'congruent': 9, 'same': False, 'type': 'addresses_normal_ht'}, 'dst': {'congruent': 2, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM'}
{'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 2, 'same': False, 'type': 'addresses_WT_ht'}, '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
*/
|
#include "dialogMakeRevol.h"
#include "ui_dialogMakeExtrusion.h"
#include "ui_dialogMakeRevol.h"
#include "mainWindow/mainWindow.h"
#include "moduleBase/ModuleType.h"
#include "MainWidgets/preWindow.h"
#include "settings/busAPI.h"
#include "settings/GraphOption.h"
#include "GeometryCommand/GeoCommandCreateChamfer.h"
#include "GeometryCommand/GeoCommandList.h"
#include "GeometryCommand/GeoCommandMakeRevol.h"
#include <vtkProperty.h>
#include <vtkActor.h>
#include <QMessageBox>
#include <QDebug>
#include <QColor>
#include <TopoDS.hxx>
#include <TopExp_Explorer.hxx>
#include <BRep_Tool.hxx>
#include "geometry/geometrySet.h"
#include <BRepAdaptor_Curve.hxx>
#include <gp_Lin.hxx>
#include "python/PyAgent.h"
#include "geometry/geometryParaRevol.h"
namespace GeometryWidget
{
CreateRevolDialog::CreateRevolDialog(GUI::MainWindow* m, MainWidget::PreWindow* p)
: GeoDialogBase(m, p)
{
_ui = new Ui::CreateRevol;
_ui->setupUi(this);
init();
connect(_ui->radioButtonUser, SIGNAL(toggled(bool)), this, SLOT(on_radioButtonUser()));
connect(_ui->comboBoxOption, SIGNAL(currentIndexChanged(int)), this, SLOT(on_TypeChanged(int)));
on_radioButtonUser();
this->translateButtonBox(_ui->buttonBox);
}
CreateRevolDialog::CreateRevolDialog(GUI::MainWindow* m, MainWidget::PreWindow* pre, Geometry::GeometrySet* set)
: GeoDialogBase(m, pre)
{
_ui = new Ui::CreateRevol;
_ui->setupUi(this);
this->setWindowTitle("Edit Revol");
init();
connect(_ui->radioButtonUser, SIGNAL(toggled(bool)), this, SLOT(on_radioButtonUser()));
connect(_ui->comboBoxOption, SIGNAL(currentIndexChanged(int)), this, SLOT(on_TypeChanged(int)));
on_radioButtonUser();
this->translateButtonBox(_ui->buttonBox);
_isEdit = true;
_editSet = set;
if (_editSet == nullptr) return;
Geometry::GeometryModelParaBase* bp = _editSet->getParameter();
Geometry::GeometryParaRevol* p = dynamic_cast<Geometry::GeometryParaRevol*>(bp);
if (p == nullptr) return;
emit hideGeometry(_editSet);
QMultiHash<Geometry::GeometrySet*, int> shapeHash;
shapeHash = p->getShapeHash();
_shapeHash = shapeHash;
QList<Geometry::GeometrySet*> setList = shapeHash.uniqueKeys();
for (int i = 0; i < setList.size(); ++i)
{
QList<int> edlist = shapeHash.values(setList[i]);
Geometry::GeometrySet* set = setList.at(i);
if (set == nullptr) return;
for (int var : edlist)
{
emit highLightGeometryEdge(set, var, &_edgeActors);
}
}
QString edgestr = QString("Select edge(%1)").arg(_shapeHash.size());
_ui->edgelabel->setText(edgestr);
double basicpt[3]{};
p->getBasicPoint(basicpt);
_baseWidget->setCoordinate(basicpt);
double degree = p->getDegree();
_ui->lineEditDegree->setText(QString::number(degree));
_ui->comboBoxOption->setCurrentIndex(p->getMethod());
_ui->tabWidget->setCurrentIndex(p->getMethod());
if (p->getMethod()==0)
{
_axisSet = p->getAxisEdge().first;
_axisIndex = p->getAxisEdge().second;
QList<vtkActor*> templist;
emit highLightGeometryEdge(_axisSet, _axisIndex, &templist);
if (_axisSet != nullptr)
_ui->edgelabel_2->setText(QString("Selected edge(1)"));
}
else
{
double dir[3]{};
p->getCoor(dir);
if (dir[0] == 1 && dir[1] == 0 && dir[2] == 0)
{
_ui->radioButtonX->setChecked(true);
}
else if (dir[0] == 0 && dir[1] == 1 && dir[2] == 0)
{
_ui->radioButtonY->setChecked(true);
}
else if (dir[0] == 0 && dir[1] == 0 && dir[2] == 1)
{
_ui->radioButtonZ->setChecked(true);
}
else
{
_ui->radioButtonUser->setChecked(true);
_ui->doubleSpinBoxX->setVisible(true);
_ui->doubleSpinBoxY->setVisible(true);
_ui->doubleSpinBoxZ->setVisible(true);
_ui->doubleSpinBoxX->setValue(dir[0]);
_ui->doubleSpinBoxY->setValue(dir[1]);
_ui->doubleSpinBoxZ->setValue(dir[2]);
}
}
bool reverse = p->getReverse();
_ui->reversecheckBox->setChecked(reverse);
bool solid = p->getSolid();
_ui->solidCheckBox->setChecked(solid);
}
void CreateRevolDialog::init()
{
_ui->tabWidget->tabBar()->hide();
_baseWidget = new GeoPointWidget(_mainWindow, _preWindow);
_ui->basicPointLayout->addWidget(_baseWidget);
connect(_baseWidget, SIGNAL(buttonCkicked(GeoPointWidget*)), this, SLOT(pointWidgetClicked(GeoPointWidget*)));
}
CreateRevolDialog::~CreateRevolDialog()
{
if (_ui != nullptr) delete _ui;
emit setSelectMode((int)ModuleBase::None);
emit updateGraphOptions();
}
void CreateRevolDialog::selectActorShape(vtkActor* ac, int index, Geometry::GeometrySet* set)
{
if (_selectEdge)
{
QColor color;
if (_edgeActors.contains(ac))
{
color = Setting::BusAPI::instance()->getGraphOption()->getGeometryCurveColor();
_edgeActors.removeOne(ac);
_shapeHash.remove(set, index);
}
else
{
color = Setting::BusAPI::instance()->getGraphOption()->getHighLightColor();
_edgeActors.append(ac);
_shapeHash.insert(set, index);
}
int n = _edgeActors.size();
QString label = QString(tr("Selected edge(%1)")).arg(_edgeActors.size());
_ui->edgelabel->setText(label);
ac->GetProperty()->SetColor(color.redF(), color.greenF(), color.blueF());
}
else if (_selectAxisEdge)
{
QColor color;
if (_axisActor != nullptr)
{
color = Setting::BusAPI::instance()->getGraphOption()->getGeometryCurveColor();
_axisActor->GetProperty()->SetColor(color.redF(), color.greenF(), color.blueF());
}
color = Setting::BusAPI::instance()->getGraphOption()->getHighLightColor();
_axisActor = ac;
_axisActor->GetProperty()->SetColor(color.redF(), color.greenF(), color.blueF());
_axisSet = set;
_axisIndex = index;
_ui->edgelabel_2->setText(tr("Selected Axis_edge(1)"));
}
}
void CreateRevolDialog::on_geoSelectCurve_clicked()
{
emit setSelectMode(int(ModuleBase::GeometryCurve));
_baseWidget->handleProcess(false);
_selectEdge = true;
_selectAxisEdge = false;
QColor c = Setting::BusAPI::instance()->getGraphOption()->getGeometryCurveColor();
if (_axisActor != nullptr)
_axisActor->GetProperty()->SetColor(c.redF(), c.greenF(), c.blueF());
c = Setting::BusAPI::instance()->getGraphOption()->getHighLightColor();
for (int i = 0; i < _edgeActors.size(); ++i)
{
auto ac = _edgeActors.at(i);
ac->GetProperty()->SetColor(c.redF(), c.greenF(), c.blueF());
}
}
void CreateRevolDialog::on_geoSelectCurve_1_clicked()
{
_selectEdge = false;
_baseWidget->handleProcess(false);
_selectAxisEdge = true;
QColor c = Setting::BusAPI::instance()->getGraphOption()->getHighLightColor();
if (_axisActor != nullptr)
_axisActor->GetProperty()->SetColor(c.redF(), c.greenF(), c.blueF());
c = Setting::BusAPI::instance()->getGraphOption()->getGeometryCurveColor();
for (int i = 0; i < _edgeActors.size(); ++i)
{
auto ac = _edgeActors.at(i);
ac->GetProperty()->SetColor(c.redF(), c.greenF(), c.blueF());
}
emit setSelectMode((int)ModuleBase::GeometryCurve);
}
void CreateRevolDialog::on_radioButtonUser()
{
bool checked = _ui->radioButtonUser->isChecked();
_ui->doubleSpinBoxX->setVisible(checked);
_ui->doubleSpinBoxY->setVisible(checked);
_ui->doubleSpinBoxZ->setVisible(checked);
}
void CreateRevolDialog::pointWidgetClicked(GeoPointWidget* w)
{
w->handleProcess(true);
_selectAxisEdge = false;
_selectEdge = false;
}
void CreateRevolDialog::on_TypeChanged(int index)
{
_ui->tabWidget->setCurrentIndex(index);
}
void CreateRevolDialog::closeEvent(QCloseEvent *e)
{
QDialog::closeEvent(e);
delete this;
}
void CreateRevolDialog::accept()
{
double basicPoint[3] = { 0.0 };
double degree{ 0.0 };
bool isSolid = _ui->solidCheckBox->isChecked();
bool ok = _baseWidget->getCoordinate(basicPoint);
if (_shapeHash.size() < 1) ok = false;
if (ok)
{
QString text = _ui->lineEditDegree->text();
degree = text.toDouble(&ok);
if (ok)
ok = fabs(degree) < 0.0000001 ? false : true;
}
if (_ui->comboBoxOption->currentIndex() == 0 && _axisSet == nullptr)
ok = false;
if (!ok)
{
QMessageBox::warning(this, tr("Warning"), tr("Input Wrong !"));
return;
}
int id = Geometry::GeometrySet::getMaxID() + 1;
QString name = QString("Revol_%1").arg(id);
/*
Command::GeoCommandMakeRevol* command = new Command::GeoCommandMakeRevol(_mainWindow, _preWindow);
command->setShapeList(_shapeHash);
command->setVector(vec);
command->setName(name);
command->setDegree(degree);
command->setBasicPoint(basicPoint);
command->isSolid(isSolid);
bool success = Command::GeoComandList::getInstance()->executeCommand(command);
if (!success)
{
QMessageBox::warning(this, tr("Warning"), tr("Create failed ! "));
return;
}*/
QStringList codes{};
codes += QString("revol = CAD.Revol()");
if (_isEdit)
codes += QString("revol.setEditID(%1)").arg(_editSet->getID());
codes += QString("revol.setName('%1')").arg(name);
QList<Geometry::GeometrySet*> sets = _shapeHash.uniqueKeys();
for (int i = 0; i < sets.size(); ++i)
{
auto s = sets.at(i);
int id = s->getID();
QList<int> indexs = _shapeHash.values(s);
for(int var : indexs)
codes += QString("revol.appendEdge(%1,%2)").arg(id).arg(var);
}
codes += QString("revol.setBasicPoint(%1,%2,%3)").arg(basicPoint[0]).arg(basicPoint[1]).arg(basicPoint[2]);
codes += QString("revol.setDegree(%1)").arg(degree);
int optionindex = _ui->comboBoxOption->currentIndex();
QString optionindexstr{};
if (optionindex == 1) optionindexstr = "Coordinate";
else optionindexstr = "Select On Geometry";
codes += QString("revol.setAxisMethod('%1')").arg(optionindexstr);
if (optionindex == 1)
{
double coor[3]{0.0};
if (_ui->radioButtonX->isChecked())
coor[0] = 1.0;
else if (_ui->radioButtonY->isChecked())
coor[1] = 1.0;
else if (_ui->radioButtonZ->isChecked())
coor[2] = 1.0;
else
{
coor[0] = _ui->doubleSpinBoxX->value();
coor[1] = _ui->doubleSpinBoxY->value();
coor[2] = _ui->doubleSpinBoxZ->value();
}
codes += QString("revol.setCoordinate(%1,%2,%3)").arg(coor[0]).arg(coor[1]).arg(coor[2]);
}
else
codes += QString("revol.selectAxisOnGeo(%1,%2)").arg(_axisSet->getID()).arg(_axisIndex);
bool reverse = _ui->reversecheckBox->isChecked();
QString revesestr{};
if (reverse) revesestr = "Yes";
else revesestr = "No";
codes += QString("revol.Reverse('%1')").arg(revesestr);
QString solidstr{};
if (isSolid == 1) solidstr = "Yes";
else solidstr = "No";
codes += QString("revol.GenerateSolid('%1')").arg(solidstr);
if (_isEdit)
codes += QString("revol.edit()");
else
codes += QString("revol.create()");
_pyAgent->submit(codes);
QDialog::accept();
this->close();
}
void CreateRevolDialog::reject()
{
if (_isEdit)
{
if (_editSet == nullptr) return;
emit showGeometry(_editSet);
}
QDialog::reject();
this->close();
}
}
|
; A158413: 961n^2 + 2n.
; 963,3848,8655,15384,24035,34608,47103,61520,77859,96120,116303,138408,162435,188384,216255,246048,277763,311400,346959,384440,423843,465168,508415,553584,600675,649688,700623,753480,808259,864960,923583,984128,1046595,1110984,1177295,1245528,1315683,1387760,1461759,1537680,1615523,1695288,1776975,1860584,1946115,2033568,2122943,2214240,2307459,2402600,2499663,2598648,2699555,2802384,2907135,3013808,3122403,3232920,3345359,3459720,3576003,3694208,3814335,3936384,4060355,4186248,4314063,4443800,4575459,4709040,4844543,4981968,5121315,5262584,5405775,5550888,5697923,5846880,5997759,6150560,6305283,6461928,6620495,6780984,6943395,7107728,7273983,7442160,7612259,7784280,7958223,8134088,8311875,8491584,8673215,8856768,9042243,9229640,9418959,9610200
mul $0,961
add $0,1
mov $1,961
add $1,$0
pow $1,2
sub $1,925444
div $1,961
add $1,963
mov $0,$1
|
; A180031: Number of n-move paths on a 3 X 3 chessboard of a queen starting or ending in the central square.
; Submitted by Jamie Morken(s4)
; 1,8,48,304,1904,11952,74992,470576,2952816,18528688,116265968,729559344,4577924464,28726097072,180253881072,1131078181936,7097421958256,44535735246768,279458051899888,1753576141473584,11003545122567024,69046334744623792,433260034703655152,2718670851475266096,17059434535005571696,107046539486829987248,671708173714194509808,4214913184465612447024,26448231312041618313584,165960462035932991144112,1041388160675997902229232,6534624499667453440299056,41004227783745250419329136
mov $1,1
mov $3,1
lpb $0
sub $0,1
mov $2,$3
mul $2,8
mul $3,5
add $3,$1
mov $1,$2
lpe
mov $0,$1
|
; A315468: Coordination sequence Gal.5.300.5 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,6,11,16,21,26,31,36,41,46,52,58,63,68,73,78,83,88,93,98,104,110,115,120,125,130,135,140,145,150,156,162,167,172,177,182,187,192,197,202,208,214,219,224,229,234,239,244,249,254
mov $2,$0
mov $3,$0
add $3,1
lpb $3
mov $0,$2
sub $3,1
sub $0,$3
lpb $0
div $0,2
mov $4,$0
min $4,1
add $4,4
mod $0,$4
lpe
mov $5,$4
add $5,1
add $1,$5
lpe
mov $0,$1
|
;;; generated by ../../BootSetup/BootSetup.rb (2018-02-18 11:55:47 +0100)
.include "ports.atmega8.inc"
;;; ========================================================================
;;; Interrupt Table
;;; ========================================================================
.org 0
rjmp RESET
reti ; INT0
reti ; INT1
reti ; Timer2 Compare
reti ; Timer2 Overflow
reti ; Timer1 Capture
reti ; Timer1 Compare A
reti ; Timer1 Compare B
reti ; Timer1 Overflow
reti ; Timer0 Overflow
reti ; SPI
reti ; USART RX Complete
reti ; USART UDR Empty
reti ; USART TX Complete
reti ; ADC Conversion Complete
reti ; EEPROM Ready
reti ; Analog Compare
reti ; 2-wire Serial Interface
reti ; Store Program Memory Ready
;;; ========================================================================
;;; Boot Setup
;;; ========================================================================
RESET: ldi r16, 0x00 ; 0
out TWBR, r16 ; TWI Bit Rate Register [0x00]
out TWSR, r16 ; TWI Status Register [0x01]
ldi r17, 0xfe ; 254
out TWAR, r17 ; TWI (Slave) Address Register [0x02]
out UBRRL, r16 ; USART Baud Rate Register Low [0x09]
out UCSRB, r16 ; USART Control and Status Register B [0x0a]
out UCSRA, r16 ; USART Control and Status Register A [0x0b]
out SPCR, r16 ; SPI Control Register [0x0d]
out SPSR, r16 ; SPI Status Register [0x0e]
out DDRD, r16 ; Port D Data Direction Register [0x11]
out PORTD, r16 ; Port D Data Register [0x12]
out DDRC, r16 ; Port C Data Direction Register [0x14]
out PORTC, r16 ; Port C Data Register [0x15]
out DDRB, r16 ; Port B Data Direction Register [0x17]
out PORTB, r16 ; Port B Data Register [0x18]
out UBRRH, r16 ; USART Baud Rate Register High [0x20]
ldi r17, 0x86 ; 134
out UCSRC, r17 ; USART Control and Status Register 0 C [0x20]
out TCNT0, r16 ; Timer/Counter Register [0x32]
out TCCR0, r16 ; Timer/Counter Control Register [0x33]
out MCUCR, r16 ; MCU Control Register [0x35]
out TWCR, r16 ; TWI Control Register [0x36]
out TIFR, r16 ; Timer/Counter Interrupt Flag Register [0x38]
out TIMSK, r16 ; Timer/Counter Interrupt Mask Register [0x39]
out GICR, r16 ; General Interrupt Control Register [0x3b]
ldi r17, lo8(RAMEND)
out SPL, r17 ; Stack Pointer Low [0x3d]
ldi r17, hi8(RAMEND)
out SPH, r17 ; Stack Pointer High [0x3e]
out SREG, r16 ; Status Register [0x3f]
rjmp Main
;;; generated by ../../BootSetup/BootSetup.rb (2018-02-18 11:55:47 +0100)
|
<%
import collections
import pwnlib.abi
import pwnlib.constants
import pwnlib.shellcraft
import six
%>
<%docstring>pkey_free(vararg_0, vararg_1, vararg_2, vararg_3, vararg_4) -> str
Invokes the syscall pkey_free.
See 'man 2 pkey_free' for more information.
Arguments:
vararg(int): vararg
Returns:
long
</%docstring>
<%page args="vararg_0=None, vararg_1=None, vararg_2=None, vararg_3=None, vararg_4=None"/>
<%
abi = pwnlib.abi.ABI.syscall()
stack = abi.stack
regs = abi.register_arguments[1:]
allregs = pwnlib.shellcraft.registers.current()
can_pushstr = []
can_pushstr_array = []
argument_names = ['vararg_0', 'vararg_1', 'vararg_2', 'vararg_3', 'vararg_4']
argument_values = [vararg_0, vararg_1, vararg_2, vararg_3, vararg_4]
# Load all of the arguments into their destination registers / stack slots.
register_arguments = dict()
stack_arguments = collections.OrderedDict()
string_arguments = dict()
dict_arguments = dict()
array_arguments = dict()
syscall_repr = []
for name, arg in zip(argument_names, argument_values):
if arg is not None:
syscall_repr.append('%s=%s' % (name, pwnlib.shellcraft.pretty(arg, False)))
# If the argument itself (input) is a register...
if arg in allregs:
index = argument_names.index(name)
if index < len(regs):
target = regs[index]
register_arguments[target] = arg
elif arg is not None:
stack_arguments[index] = arg
# The argument is not a register. It is a string value, and we
# are expecting a string value
elif name in can_pushstr and isinstance(arg, (six.binary_type, six.text_type)):
if isinstance(arg, six.text_type):
arg = arg.encode('utf-8')
string_arguments[name] = arg
# The argument is not a register. It is a dictionary, and we are
# expecting K:V paris.
elif name in can_pushstr_array and isinstance(arg, dict):
array_arguments[name] = ['%s=%s' % (k,v) for (k,v) in arg.items()]
# The arguent is not a register. It is a list, and we are expecting
# a list of arguments.
elif name in can_pushstr_array and isinstance(arg, (list, tuple)):
array_arguments[name] = arg
# The argument is not a register, string, dict, or list.
# It could be a constant string ('O_RDONLY') for an integer argument,
# an actual integer value, or a constant.
else:
index = argument_names.index(name)
if index < len(regs):
target = regs[index]
register_arguments[target] = arg
elif arg is not None:
stack_arguments[target] = arg
# Some syscalls have different names on various architectures.
# Determine which syscall number to use for the current architecture.
for syscall in ['SYS_pkey_free']:
if hasattr(pwnlib.constants, syscall):
break
else:
raise Exception("Could not locate any syscalls: %r" % syscalls)
%>
/* pkey_free(${', '.join(syscall_repr)}) */
%for name, arg in string_arguments.items():
${pwnlib.shellcraft.pushstr(arg, append_null=(b'\x00' not in arg))}
${pwnlib.shellcraft.mov(regs[argument_names.index(name)], abi.stack)}
%endfor
%for name, arg in array_arguments.items():
${pwnlib.shellcraft.pushstr_array(regs[argument_names.index(name)], arg)}
%endfor
%for name, arg in stack_arguments.items():
${pwnlib.shellcraft.push(arg)}
%endfor
${pwnlib.shellcraft.setregs(register_arguments)}
${pwnlib.shellcraft.syscall(syscall)}
|
; A157080: 32805000n^2 - 16200n + 1.
; 32788801,131187601,295196401,524815201,820044001,1180882801,1607331601,2099390401,2657059201,3280338001,3969226801,4723725601,5543834401,6429553201,7380882001,8397820801,9480369601,10628528401,11842297201,13121676001,14466664801,15877263601,17353472401,18895291201,20502720001,22175758801,23914407601,25718666401,27588535201,29524014001,31525102801,33591801601,35724110401,37922029201,40185558001,42514696801,44909445601,47369804401,49895773201,52487352001,55144540801,57867339601,60655748401,63509767201,66429396001,69414634801,72465483601,75581942401,78764011201,82011690001,85324978801,88703877601,92148386401,95658505201,99234234001,102875572801,106582521601,110355080401,114193249201,118097028001,122066416801,126101415601,130202024401,134368243201,138600072001,142897510801,147260559601,151689218401,156183487201,160743366001,165368854801,170059953601,174816662401,179638981201,184526910001,189480448801,194499597601,199584356401,204734725201,209950704001,215232292801,220579491601,225992300401,231470719201,237014748001,242624386801,248299635601,254040494401,259846963201,265719042001,271656730801,277660029601,283728938401,289863457201,296063586001,302329324801,308660673601,315057632401,321520201201,328048380001
seq $0,156867 ; 729000n - 180.
pow $0,2
mul $0,3
sub $0,1593535777200
div $0,48600
add $0,32788801
|
; A141571: Decimal expansion of 11999/99900.
; 1,2,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0
add $0,1
lpb $0
mod $0,3
pow $0,2
lpe
mov $1,$0
|
; A016845: (4n+3)^9.
; 19683,40353607,2357947691,38443359375,322687697779,1801152661463,7625597484987,26439622160671,78815638671875,208728361158759,502592611936843,1119130473102767,2334165173090451,4605366583984375
mul $0,4
add $0,3
pow $0,9
|
.data
array: .space 128 #maximum member is 32
str_space: .asciiz " "
head: .asciiz "The sorted array is:\n"
.text
la $s0, array
li $v0, 5
syscall
move $s1, $v0
beqz $v0, end
li $t0, 0
get: bge $t0, $s1, calc
sll $t1, $t0, 2
add $t1, $t1, $s0
li $v0, 5
syscall
sw $v0, 0($t1)
addi $t0, $t0, 1
j get
calc: li $t0, 0
loop_1: bge $t0, $s1, loop_1_end
addi $t1, $t0, 1
loop_2: bge, $t1, $s1, loop_2_end
sll $t2, $t0, 2
add $t2, $t2, $s0
sll $t3, $t1, 2
add $t3, $t3, $s0
lw $t4, 0($t2)
lw $t5, 0($t3)
ble $t4, $t5, replace_pass
sw $t4, 0($t3)
sw $t5, 0($t2)
replace_pass:
addi $t1, $t1, 1
j loop_2
loop_2_end:
addi $t0, $t0, 1
j loop_1
loop_1_end:
la $a0, head
li $v0, 4
syscall
li $t0, 0
print: bge $t0, $s1, end
sll $t1, $t0, 2
add $t1, $t1, $s0
lw $a0, 0($t1)
li $v0, 1
syscall
la $a0, str_space
li $v0, 4
syscall
addi $t0, $t0, 1
j print
end: li $v0, 10
syscall
|
// Copyright 2021 Intel Corporation
//
// 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.
#pragma once
namespace pybind11 {
class bytes;
class capsule;
class object;
class str;
class dict;
} // namespace pybind11
void init_compiler(pybind11::dict settings);
pybind11::capsule create_module();
pybind11::capsule lower_function(const pybind11::object &compilation_context,
const pybind11::capsule &py_mod,
const pybind11::object &func_ir);
pybind11::bytes compile_module(const pybind11::object &compilation_context,
const pybind11::capsule &py_mod);
pybind11::str module_str(const pybind11::capsule &py_mod);
|
// $OpenLDAP$
/*
* Copyright 2000-2019 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
#include "config.h"
#include "debug.h"
#include "LDAPMessageQueue.h"
#include "LDAPRequest.h"
#include "LDAPResult.h"
#include "LDAPSearchReference.h"
#include "LDAPSearchRequest.h"
#include "LDAPUrl.h"
#include "LDAPUrlList.h"
#include "LDAPException.h"
using namespace std;
// TODO: How to handle unsolicited notifications, like notice of
// disconnection
LDAPMessageQueue::LDAPMessageQueue(LDAPRequest *req){
DEBUG(LDAP_DEBUG_CONSTRUCT, "LDAPMessageQueue::LDAPMessageQueue()" << endl);
m_activeReq.push(req);
m_issuedReq.push_back(req);
}
LDAPMessageQueue::~LDAPMessageQueue(){
DEBUG(LDAP_DEBUG_DESTROY, "LDAPMessageQueue::~LDAPMessageQueue()" << endl);
for(LDAPRequestList::iterator i=m_issuedReq.begin();
i != m_issuedReq.end(); i++){
delete *i;
}
m_issuedReq.clear();
}
LDAPMsg *LDAPMessageQueue::getNext(){
DEBUG(LDAP_DEBUG_TRACE,"LDAPMessageQueue::getNext()" << endl);
if ( m_activeReq.empty() ) {
return 0;
}
LDAPRequest *req=m_activeReq.top();
LDAPMsg *ret=0;
try{
ret = req->getNextMessage();
}catch(LDAPException e){
//do some clean up
m_activeReq.pop();
throw;
}
const LDAPConstraints *constr=req->getConstraints();
switch (ret->getMessageType()) {
case LDAPMsg::SEARCH_REFERENCE :
if (constr->getReferralChase() ){
//throws Exception (limit Exceeded)
LDAPRequest *refReq=chaseReferral(ret);
if(refReq != 0){
m_activeReq.push(refReq);
m_issuedReq.push_back(refReq);
delete ret;
return getNext();
}
}
return ret;
break;
case LDAPMsg::SEARCH_ENTRY :
return ret;
break;
case LDAPMsg::SEARCH_DONE :
if(req->isReferral()){
req->unbind();
}
switch ( ((LDAPResult*)ret)->getResultCode()) {
case LDAPResult::REFERRAL :
if(constr->getReferralChase()){
//throws Exception (limit Exceeded)
LDAPRequest *refReq=chaseReferral(ret);
if(refReq != 0){
m_activeReq.pop();
m_activeReq.push(refReq);
m_issuedReq.push_back(refReq);
delete ret;
return getNext();
}
}
return ret;
break;
case LDAPResult::SUCCESS :
if(req->isReferral()){
delete ret;
m_activeReq.pop();
return getNext();
}else{
m_activeReq.pop();
return ret;
}
break;
default:
m_activeReq.pop();
return ret;
break;
}
break;
//must be some kind of LDAPResultMessage
default:
if(req->isReferral()){
req->unbind();
}
LDAPResult* res_p=(LDAPResult*)ret;
switch (res_p->getResultCode()) {
case LDAPResult::REFERRAL :
if(constr->getReferralChase()){
//throws Exception (limit Exceeded)
LDAPRequest *refReq=chaseReferral(ret);
if(refReq != 0){
m_activeReq.pop();
m_activeReq.push(refReq);
m_issuedReq.push_back(refReq);
delete ret;
return getNext();
}
}
return ret;
break;
default:
m_activeReq.pop();
return ret;
}
break;
}
}
// TODO Maybe moved to LDAPRequest::followReferral seems more reasonable
//there
LDAPRequest* LDAPMessageQueue::chaseReferral(LDAPMsg* ref){
DEBUG(LDAP_DEBUG_TRACE,"LDAPMessageQueue::chaseReferral()" << endl);
LDAPRequest *req=m_activeReq.top();
LDAPRequest *refReq=req->followReferral(ref);
if(refReq !=0){
if(refReq->getConstraints()->getHopLimit() < refReq->getHopCount()){
delete(refReq);
throw LDAPException(LDAP_REFERRAL_LIMIT_EXCEEDED);
}
if(refReq->isCycle()){
delete(refReq);
throw LDAPException(LDAP_CLIENT_LOOP);
}
try {
refReq->sendRequest();
return refReq;
}catch (LDAPException e){
DEBUG(LDAP_DEBUG_TRACE," caught exception" << endl);
return 0;
}
}else{
return 0;
}
}
LDAPRequestStack* LDAPMessageQueue::getRequestStack(){
DEBUG(LDAP_DEBUG_TRACE,"LDAPMessageQueue::getRequestStack()" << endl);
return &m_activeReq;
}
|
/* Copyright 2016 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.
==============================================================================*/
#define EIGEN_USE_THREADS
#include "tensorflow/core/kernels/tile_functor_cpu.h"
namespace tensorflow {
namespace functor {
typedef Eigen::ThreadPoolDevice CPUDevice;
template struct Tile<CPUDevice, int32, int32>;
template struct Tile<CPUDevice, int32, int64_t>;
} // end namespace functor
} // end namespace tensorflow
|
#include "html.h"
#include "el_font.h"
using namespace litehtml;
el_font::el_font(const std::shared_ptr<document> &doc) : html_tag(doc) { }
el_font::~el_font() { }
void el_font::parse_attributes()
{
const tchar_t *str = get_attr(_t("color"));
if (str)
_style.add_property(_t("color"), str, 0, false);
str = get_attr(_t("face"));
if (str)
_style.add_property(_t("font-face"), str, 0, false);
str = get_attr(_t("size"));
if (str) {
int sz = t_atoi(str);
if (sz <= 1)
_style.add_property(_t("font-size"), _t("x-small"), 0, false);
else if (sz >= 6)
_style.add_property(_t("font-size"), _t("xx-large"), 0, false);
else
switch (sz) {
case 2: _style.add_property(_t("font-size"), _t("small"), 0, false); break;
case 3: _style.add_property(_t("font-size"), _t("medium"), 0, false); break;
case 4: _style.add_property(_t("font-size"), _t("large"), 0, false); break;
case 5: _style.add_property(_t("font-size"), _t("x-large"), 0, false); break;
}
}
html_tag::parse_attributes();
}
|
# xSpim Demo Program
#
# CPE 315
# fall 2001
#
# By: Dan Stearns
# Date:
# Modifications:
# 4/10/03 knico Tabbed code
# 4/10/03 knico Modified to use s registers instead of t registers
#
#
# declare global so programmer can see actual addresses.
.globl welcome
.globl prompt
.globl sumText
.globl myArray
# Data Area - allocate and initialize variables
.data
welcome:
.asciiz " This program adds two numbers \n\n"
prompt:
.asciiz " Enter an integer: "
sumText:
.asciiz " \n Sum = "
# MyArray declaration allocates a 9 integer array,
# initialized to the values listed below
# note - this is not used in the program
# this is here to illustrate how to declare it
myArray:
.word 0x20040002 0x20080001 0x200b0001 0x8b502a
.word 0x15400003 0x1084020 0x20840000 0x800fffa
.word 0x1001020
#Text Area (i.e. instructions)
.text
main:
# Display the welcome message;
ori $v0, $zero, 4
la $a0, welcome
syscall
# Display prompt
ori $v0, $zero, 4
la $a0, prompt
syscall
# Read 1st integer
ori $v0, $zero, 5
syscall
# Put 1st integer into $s0, keeping a running
# sum in $s0
addu $s0, $v0, $zero
# Display prompt
ori $v0, $zero, 4
la $a0, prompt
syscall
# Read 2nd integer
ori $v0, $zero, 5
syscall
# $v0 now has the value of the second integer
# Add 2nd integer to sum
addu $s0, $v0, $s0
# Display the sum text
ori $v0, $zero, 4
la $a0, sumText
syscall
# Display the sum
ori $v0, $zero, 1
add $a0, $s0, $zero
syscall
# Exit
ori $v0, $zero, 10
syscall
|
extern m7_ippsTDESEncryptCFB:function
extern n8_ippsTDESEncryptCFB:function
extern y8_ippsTDESEncryptCFB:function
extern e9_ippsTDESEncryptCFB:function
extern l9_ippsTDESEncryptCFB:function
extern n0_ippsTDESEncryptCFB:function
extern k0_ippsTDESEncryptCFB:function
extern ippcpJumpIndexForMergedLibs
extern ippcpSafeInit:function
segment .data
align 8
dq .Lin_ippsTDESEncryptCFB
.Larraddr_ippsTDESEncryptCFB:
dq m7_ippsTDESEncryptCFB
dq n8_ippsTDESEncryptCFB
dq y8_ippsTDESEncryptCFB
dq e9_ippsTDESEncryptCFB
dq l9_ippsTDESEncryptCFB
dq n0_ippsTDESEncryptCFB
dq k0_ippsTDESEncryptCFB
segment .text
global ippsTDESEncryptCFB:function (ippsTDESEncryptCFB.LEndippsTDESEncryptCFB - ippsTDESEncryptCFB)
.Lin_ippsTDESEncryptCFB:
db 0xf3, 0x0f, 0x1e, 0xfa
call ippcpSafeInit wrt ..plt
align 16
ippsTDESEncryptCFB:
db 0xf3, 0x0f, 0x1e, 0xfa
mov rax, qword [rel ippcpJumpIndexForMergedLibs wrt ..gotpc]
movsxd rax, dword [rax]
lea r11, [rel .Larraddr_ippsTDESEncryptCFB]
mov r11, qword [r11+rax*8]
jmp r11
.LEndippsTDESEncryptCFB:
|
//
// setjmp.asm
//
#include "setjmp_offsets.h"
.text
//
// Standard setjmp(). Save the current execution context for a subsequent
// longjmp(). Signal state/mask is not saved; floating-point context is
// not saved.
//
// Standard C prototype --
// int
// setjmp(jmp_buf env);
//
// Returns zero on initial invocation; or nonzero if restarted via longjmp()
//
.align 4
.global setjmp
setjmp:
// Locate the jmp_buf
pushl %edi
movl 8(%esp), %edi
// Stack is now:
// *(esp) = caller's context; longjmp() returns here
// 8(esp) = pointer to jmp_buf
// 4(esp) = return address
// 0(esp) = previous value of %edi
// Save the general registers. No need to save %eax, since it's
// overwritten on each invocation
movl %ebx, EBX_OFFSET(%edi)
movl %ecx, ECX_OFFSET(%edi)
movl %edx, EDX_OFFSET(%edi)
movl %esi, ESI_OFFSET(%edi)
movl %ebp, EBP_OFFSET(%edi)
// Save the cached value of %edi
movl 0(%esp), %eax
movl %eax, EDI_OFFSET(%edi)
// Compute + save the value of %esp. The longjmp() logic must push the
// jmp_buf pointer and the address of the original setjmp() callsite
// back onto the stack
movl %esp, %eax
addl $12, %eax // Discard: %edi, return address, jmp_buf
movl %eax, ESP_OFFSET(%edi)
// Save the return address; this is where execution will resume after
// the next longjmp()
movl 4(%esp), %eax
movl %eax, EIP_OFFSET(%edi)
// Return zero after the initial invocation of setjmp()
xorl %eax, %eax
popl %edi
ret
|
/*
Given an integer array (of length n), find and print all the subsets of input array.
Subsets are of length varying from 0 to n, that contain elements of the array. But the order of elements should remain same as in the input array.
Note : The order of subsets are not important. Just print the subsets in different lines.
Input format :
Line 1 : Integer n, Size of array
Line 2 : Array elements (separated by space)
Constraints :
1 <= n <= 15
Sample Input:
3
15 20 12
Sample Output:
[] (this just represents an empty array, don't worry about the square brackets)
12
20
20 12
15
15 12
15 20
15 20 12
*/
#include <bits/stdc++.h>
using namespace std;
void printVector(vector <int> &temp){
for(int i=0;i<temp.size();i++)
cout<<temp[i]<<" ";
cout<<endl;
}
void helper(int input[],int n,vector<int> &temp){
if(n==0){
printVector(temp);
return;
}
//First call to include the current element indicated by input[0]
temp.push_back(input[0]);
helper(input+1,n-1,temp);
//Second call for not including the current element
temp.pop_back();
helper(input+1,n-1,temp);
}
void printSubsetsOfArray(int input[], int size) {
// Write your code here
vector<int>temp;
helper(input,size,temp);
}
int main() {
int input[1000],length;
cin >> length;
for(int i=0; i < length; i++)
cin >> input[i];
printSubsetsOfArray(input, length);
}
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2017 The Bitcoin Core developers
// Copyright (c) 2020 The Pesium Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <script/sign.h>
#include <key.h>
#include <keystore.h>
#include <policy/policy.h>
#include <primitives/transaction.h>
#include <script/standard.h>
#include <uint256.h>
typedef std::vector<unsigned char> valtype;
TransactionSignatureCreator::TransactionSignatureCreator(const CKeyStore* keystoreIn, const CTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn, int nHashTypeIn) : BaseSignatureCreator(keystoreIn), txTo(txToIn), nIn(nInIn), nHashType(nHashTypeIn), amount(amountIn), checker(txTo, nIn, amountIn) {}
bool TransactionSignatureCreator::CreateSig(std::vector<unsigned char>& vchSig, const CKeyID& address, const CScript& scriptCode, SigVersion sigversion) const
{
CKey key;
if (!keystore->GetKey(address, key))
return false;
// Signing with uncompressed keys is disabled in witness scripts
if (sigversion == SIGVERSION_WITNESS_V0 && !key.IsCompressed())
return false;
uint256 hash = SignatureHash(scriptCode, *txTo, nIn, nHashType, amount, sigversion);
if (!key.Sign(hash, vchSig))
return false;
vchSig.push_back((unsigned char)nHashType);
return true;
}
static bool Sign1(const CKeyID& address, const BaseSignatureCreator& creator, const CScript& scriptCode, std::vector<valtype>& ret, SigVersion sigversion)
{
std::vector<unsigned char> vchSig;
if (!creator.CreateSig(vchSig, address, scriptCode, sigversion))
return false;
ret.push_back(vchSig);
return true;
}
static bool SignN(const std::vector<valtype>& multisigdata, const BaseSignatureCreator& creator, const CScript& scriptCode, std::vector<valtype>& ret, SigVersion sigversion)
{
int nSigned = 0;
int nRequired = multisigdata.front()[0];
for (unsigned int i = 1; i < multisigdata.size()-1 && nSigned < nRequired; i++)
{
const valtype& pubkey = multisigdata[i];
CKeyID keyID = CPubKey(pubkey).GetID();
if (Sign1(keyID, creator, scriptCode, ret, sigversion))
++nSigned;
}
return nSigned==nRequired;
}
/**
* Sign scriptPubKey using signature made with creator.
* Signatures are returned in scriptSigRet (or returns false if scriptPubKey can't be signed),
* unless whichTypeRet is TX_SCRIPTHASH, in which case scriptSigRet is the redemption script.
* Returns false if scriptPubKey could not be completely satisfied.
*/
static bool SignStep(const BaseSignatureCreator& creator, const CScript& scriptPubKey,
std::vector<valtype>& ret, txnouttype& whichTypeRet, SigVersion sigversion)
{
CScript scriptRet;
uint160 h160;
ret.clear();
std::vector<valtype> vSolutions;
if (!Solver(scriptPubKey, whichTypeRet, vSolutions))
return false;
CKeyID keyID;
switch (whichTypeRet)
{
case TX_NONSTANDARD:
case TX_NULL_DATA:
case TX_WITNESS_UNKNOWN:
return false;
case TX_PUBKEY:
keyID = CPubKey(vSolutions[0]).GetID();
return Sign1(keyID, creator, scriptPubKey, ret, sigversion);
case TX_PUBKEYHASH:
keyID = CKeyID(uint160(vSolutions[0]));
if (!Sign1(keyID, creator, scriptPubKey, ret, sigversion))
return false;
else
{
CPubKey vch;
creator.KeyStore().GetPubKey(keyID, vch);
ret.push_back(ToByteVector(vch));
}
return true;
case TX_SCRIPTHASH:
if (creator.KeyStore().GetCScript(uint160(vSolutions[0]), scriptRet)) {
ret.push_back(std::vector<unsigned char>(scriptRet.begin(), scriptRet.end()));
return true;
}
return false;
case TX_MULTISIG:
ret.push_back(valtype()); // workaround CHECKMULTISIG bug
return (SignN(vSolutions, creator, scriptPubKey, ret, sigversion));
case TX_WITNESS_V0_KEYHASH:
ret.push_back(vSolutions[0]);
return true;
case TX_WITNESS_V0_SCRIPTHASH:
CRIPEMD160().Write(&vSolutions[0][0], vSolutions[0].size()).Finalize(h160.begin());
if (creator.KeyStore().GetCScript(h160, scriptRet)) {
ret.push_back(std::vector<unsigned char>(scriptRet.begin(), scriptRet.end()));
return true;
}
return false;
default:
return false;
}
}
static CScript PushAll(const std::vector<valtype>& values)
{
CScript result;
for (const valtype& v : values) {
if (v.size() == 0) {
result << OP_0;
} else if (v.size() == 1 && v[0] >= 1 && v[0] <= 16) {
result << CScript::EncodeOP_N(v[0]);
} else {
result << v;
}
}
return result;
}
bool ProduceSignature(const BaseSignatureCreator& creator, const CScript& fromPubKey, SignatureData& sigdata)
{
CScript script = fromPubKey;
std::vector<valtype> result;
txnouttype whichType;
bool solved = SignStep(creator, script, result, whichType, SIGVERSION_BASE);
bool P2SH = false;
CScript subscript;
sigdata.scriptWitness.stack.clear();
if (solved && whichType == TX_SCRIPTHASH)
{
// Solver returns the subscript that needs to be evaluated;
// the final scriptSig is the signatures from that
// and then the serialized subscript:
script = subscript = CScript(result[0].begin(), result[0].end());
solved = solved && SignStep(creator, script, result, whichType, SIGVERSION_BASE) && whichType != TX_SCRIPTHASH;
P2SH = true;
}
if (solved && whichType == TX_WITNESS_V0_KEYHASH)
{
CScript witnessscript;
witnessscript << OP_DUP << OP_HASH160 << ToByteVector(result[0]) << OP_EQUALVERIFY << OP_CHECKSIG;
txnouttype subType;
solved = solved && SignStep(creator, witnessscript, result, subType, SIGVERSION_WITNESS_V0);
sigdata.scriptWitness.stack = result;
result.clear();
}
else if (solved && whichType == TX_WITNESS_V0_SCRIPTHASH)
{
CScript witnessscript(result[0].begin(), result[0].end());
txnouttype subType;
solved = solved && SignStep(creator, witnessscript, result, subType, SIGVERSION_WITNESS_V0) && subType != TX_SCRIPTHASH && subType != TX_WITNESS_V0_SCRIPTHASH && subType != TX_WITNESS_V0_KEYHASH;
result.push_back(std::vector<unsigned char>(witnessscript.begin(), witnessscript.end()));
sigdata.scriptWitness.stack = result;
result.clear();
}
if (P2SH) {
result.push_back(std::vector<unsigned char>(subscript.begin(), subscript.end()));
}
sigdata.scriptSig = PushAll(result);
// Test solution
return solved && VerifyScript(sigdata.scriptSig, fromPubKey, &sigdata.scriptWitness, STANDARD_SCRIPT_VERIFY_FLAGS, creator.Checker());
}
SignatureData DataFromTransaction(const CMutableTransaction& tx, unsigned int nIn)
{
SignatureData data;
assert(tx.vin.size() > nIn);
data.scriptSig = tx.vin[nIn].scriptSig;
data.scriptWitness = tx.vin[nIn].scriptWitness;
return data;
}
void UpdateTransaction(CMutableTransaction& tx, unsigned int nIn, const SignatureData& data)
{
assert(tx.vin.size() > nIn);
tx.vin[nIn].scriptSig = data.scriptSig;
tx.vin[nIn].scriptWitness = data.scriptWitness;
}
bool SignSignature(const CKeyStore &keystore, const CScript& fromPubKey, CMutableTransaction& txTo, unsigned int nIn, const CAmount& amount, int nHashType)
{
assert(nIn < txTo.vin.size());
CTransaction txToConst(txTo);
TransactionSignatureCreator creator(&keystore, &txToConst, nIn, amount, nHashType);
SignatureData sigdata;
bool ret = ProduceSignature(creator, fromPubKey, sigdata);
UpdateTransaction(txTo, nIn, sigdata);
return ret;
}
bool SignSignature(const CKeyStore &keystore, const CTransaction& txFrom, CMutableTransaction& txTo, unsigned int nIn, int nHashType)
{
assert(nIn < txTo.vin.size());
CTxIn& txin = txTo.vin[nIn];
assert(txin.prevout.n < txFrom.vout.size());
const CTxOut& txout = txFrom.vout[txin.prevout.n];
return SignSignature(keystore, txout.scriptPubKey, txTo, nIn, txout.nValue, nHashType);
}
static std::vector<valtype> CombineMultisig(const CScript& scriptPubKey, const BaseSignatureChecker& checker,
const std::vector<valtype>& vSolutions,
const std::vector<valtype>& sigs1, const std::vector<valtype>& sigs2, SigVersion sigversion)
{
// Combine all the signatures we've got:
std::set<valtype> allsigs;
for (const valtype& v : sigs1)
{
if (!v.empty())
allsigs.insert(v);
}
for (const valtype& v : sigs2)
{
if (!v.empty())
allsigs.insert(v);
}
// Build a map of pubkey -> signature by matching sigs to pubkeys:
assert(vSolutions.size() > 1);
unsigned int nSigsRequired = vSolutions.front()[0];
unsigned int nPubKeys = vSolutions.size()-2;
std::map<valtype, valtype> sigs;
for (const valtype& sig : allsigs)
{
for (unsigned int i = 0; i < nPubKeys; i++)
{
const valtype& pubkey = vSolutions[i+1];
if (sigs.count(pubkey))
continue; // Already got a sig for this pubkey
if (checker.CheckSig(sig, pubkey, scriptPubKey, sigversion))
{
sigs[pubkey] = sig;
break;
}
}
}
// Now build a merged CScript:
unsigned int nSigsHave = 0;
std::vector<valtype> result; result.push_back(valtype()); // pop-one-too-many workaround
for (unsigned int i = 0; i < nPubKeys && nSigsHave < nSigsRequired; i++)
{
if (sigs.count(vSolutions[i+1]))
{
result.push_back(sigs[vSolutions[i+1]]);
++nSigsHave;
}
}
// Fill any missing with OP_0:
for (unsigned int i = nSigsHave; i < nSigsRequired; i++)
result.push_back(valtype());
return result;
}
namespace
{
struct Stacks
{
std::vector<valtype> script;
std::vector<valtype> witness;
Stacks() {}
explicit Stacks(const std::vector<valtype>& scriptSigStack_) : script(scriptSigStack_), witness() {}
explicit Stacks(const SignatureData& data) : witness(data.scriptWitness.stack) {
EvalScript(script, data.scriptSig, SCRIPT_VERIFY_STRICTENC, BaseSignatureChecker(), SIGVERSION_BASE);
}
SignatureData Output() const {
SignatureData result;
result.scriptSig = PushAll(script);
result.scriptWitness.stack = witness;
return result;
}
};
}
static Stacks CombineSignatures(const CScript& scriptPubKey, const BaseSignatureChecker& checker,
const txnouttype txType, const std::vector<valtype>& vSolutions,
Stacks sigs1, Stacks sigs2, SigVersion sigversion)
{
switch (txType)
{
case TX_NONSTANDARD:
case TX_NULL_DATA:
case TX_WITNESS_UNKNOWN:
// Don't know anything about this, assume bigger one is correct:
if (sigs1.script.size() >= sigs2.script.size())
return sigs1;
return sigs2;
case TX_PUBKEY:
case TX_PUBKEYHASH:
// Signatures are bigger than placeholders or empty scripts:
if (sigs1.script.empty() || sigs1.script[0].empty())
return sigs2;
return sigs1;
case TX_WITNESS_V0_KEYHASH:
// Signatures are bigger than placeholders or empty scripts:
if (sigs1.witness.empty() || sigs1.witness[0].empty())
return sigs2;
return sigs1;
case TX_SCRIPTHASH:
if (sigs1.script.empty() || sigs1.script.back().empty())
return sigs2;
else if (sigs2.script.empty() || sigs2.script.back().empty())
return sigs1;
else
{
// Recur to combine:
valtype spk = sigs1.script.back();
CScript pubKey2(spk.begin(), spk.end());
txnouttype txType2;
std::vector<std::vector<unsigned char> > vSolutions2;
Solver(pubKey2, txType2, vSolutions2);
sigs1.script.pop_back();
sigs2.script.pop_back();
Stacks result = CombineSignatures(pubKey2, checker, txType2, vSolutions2, sigs1, sigs2, sigversion);
result.script.push_back(spk);
return result;
}
case TX_MULTISIG:
return Stacks(CombineMultisig(scriptPubKey, checker, vSolutions, sigs1.script, sigs2.script, sigversion));
case TX_WITNESS_V0_SCRIPTHASH:
if (sigs1.witness.empty() || sigs1.witness.back().empty())
return sigs2;
else if (sigs2.witness.empty() || sigs2.witness.back().empty())
return sigs1;
else
{
// Recur to combine:
CScript pubKey2(sigs1.witness.back().begin(), sigs1.witness.back().end());
txnouttype txType2;
std::vector<valtype> vSolutions2;
Solver(pubKey2, txType2, vSolutions2);
sigs1.witness.pop_back();
sigs1.script = sigs1.witness;
sigs1.witness.clear();
sigs2.witness.pop_back();
sigs2.script = sigs2.witness;
sigs2.witness.clear();
Stacks result = CombineSignatures(pubKey2, checker, txType2, vSolutions2, sigs1, sigs2, SIGVERSION_WITNESS_V0);
result.witness = result.script;
result.script.clear();
result.witness.push_back(valtype(pubKey2.begin(), pubKey2.end()));
return result;
}
default:
return Stacks();
}
}
SignatureData CombineSignatures(const CScript& scriptPubKey, const BaseSignatureChecker& checker,
const SignatureData& scriptSig1, const SignatureData& scriptSig2)
{
txnouttype txType;
std::vector<std::vector<unsigned char> > vSolutions;
Solver(scriptPubKey, txType, vSolutions);
return CombineSignatures(scriptPubKey, checker, txType, vSolutions, Stacks(scriptSig1), Stacks(scriptSig2), SIGVERSION_BASE).Output();
}
namespace {
/** Dummy signature checker which accepts all signatures. */
class DummySignatureChecker : public BaseSignatureChecker
{
public:
DummySignatureChecker() {}
bool CheckSig(const std::vector<unsigned char>& scriptSig, const std::vector<unsigned char>& vchPubKey, const CScript& scriptCode, SigVersion sigversion) const override
{
return true;
}
};
const DummySignatureChecker dummyChecker;
} // namespace
const BaseSignatureChecker& DummySignatureCreator::Checker() const
{
return dummyChecker;
}
bool DummySignatureCreator::CreateSig(std::vector<unsigned char>& vchSig, const CKeyID& keyid, const CScript& scriptCode, SigVersion sigversion) const
{
// Create a dummy signature that is a valid DER-encoding
vchSig.assign(72, '\000');
vchSig[0] = 0x30;
vchSig[1] = 69;
vchSig[2] = 0x02;
vchSig[3] = 33;
vchSig[4] = 0x01;
vchSig[4 + 33] = 0x02;
vchSig[5 + 33] = 32;
vchSig[6 + 33] = 0x01;
vchSig[6 + 33 + 32] = SIGHASH_ALL;
return true;
}
bool IsSolvable(const CKeyStore& store, const CScript& script)
{
// This check is to make sure that the script we created can actually be solved for and signed by us
// if we were to have the private keys. This is just to make sure that the script is valid and that,
// if found in a transaction, we would still accept and relay that transaction. In particular,
// it will reject witness outputs that require signing with an uncompressed public key.
DummySignatureCreator creator(&store);
SignatureData sigs;
// Make sure that STANDARD_SCRIPT_VERIFY_FLAGS includes SCRIPT_VERIFY_WITNESS_PUBKEYTYPE, the most
// important property this function is designed to test for.
static_assert(STANDARD_SCRIPT_VERIFY_FLAGS & SCRIPT_VERIFY_WITNESS_PUBKEYTYPE, "IsSolvable requires standard script flags to include WITNESS_PUBKEYTYPE");
if (ProduceSignature(creator, script, sigs)) {
// VerifyScript check is just defensive, and should never fail.
assert(VerifyScript(sigs.scriptSig, script, &sigs.scriptWitness, STANDARD_SCRIPT_VERIFY_FLAGS, creator.Checker()));
return true;
}
return false;
}
|
;
; Grundy Newbrain Specific libraries
;
; Stefano Bodrato - 05/04/2007
;
;
; warm reset: foolishly jump to BASIC entry
;
;
;
; $Id: warm_reset.asm,v 1.4 2016-06-19 20:33:40 dom Exp $
;
SECTION code_clib
PUBLIC warm_reset
PUBLIC _warm_reset
.warm_reset
._warm_reset
jp 49373
|
; A341250: a(n) = 5*a(n-1) - 4*a(n-3) for n >= 4, where a(1) = 1, a(2) = 3, a(3) = 13.
; Submitted by Jamie Morken(w4)
; 1,3,13,61,293,1413,6821,32933,159013,767781,3707173,17899813,86427941,417311013,2014955813,9729067301,46976092453,226820639013,1095186925861,5288030259493,25532868741413,123283596003621,595265858980133,2874197819935013
lpb $0
sub $0,1
mov $3,$2
mul $4,4
add $4,1
mov $2,$4
add $4,$3
lpe
mov $0,$4
mul $0,2
add $0,1
|
// Generated by genprov 2.0.1
#include "CIMPLE_Exception_Provider.h"
CIMPLE_NAMESPACE_BEGIN
CIMPLE_Exception_Provider::CIMPLE_Exception_Provider()
{
}
CIMPLE_Exception_Provider::~CIMPLE_Exception_Provider()
{
}
Load_Status CIMPLE_Exception_Provider::load()
{
_exception = 0;
return LOAD_OK;
}
Unload_Status CIMPLE_Exception_Provider::unload()
{
return UNLOAD_OK;
}
Get_Instance_Status CIMPLE_Exception_Provider::get_instance(
const CIMPLE_Exception* model,
CIMPLE_Exception*& instance)
{
//
// if the default flag set, simple return unsupported
//
if (_getInstanceDefault)
{
printf("get_instance using default return\n");
return GET_INSTANCE_UNSUPPORTED;
}
//
// Execute return code based on the current _exception code provided
//
Get_Instance_Status status = (Get_Instance_Status)_exception;
printf("get_instance status = %u\n", status);
switch (status)
{
case GET_INSTANCE_NOT_FOUND:
case GET_INSTANCE_UNSUPPORTED:
case GET_INSTANCE_ACCESS_DENIED:
case GET_INSTANCE_FAILED:
case GET_INSTANCE_INVALID_PARAMETER:
return status;
break;
case GET_INSTANCE_OK:
instance->Key.set(1);
return GET_INSTANCE_OK;
break;
}
printf("ERROR: get_instance received invalid code %u\n", _exception);
return GET_INSTANCE_FAILED;
}
Enum_Instances_Status CIMPLE_Exception_Provider::enum_instances(
const CIMPLE_Exception* model,
Enum_Instances_Handler<CIMPLE_Exception>* handler)
{
Enum_Instances_Status status = (Enum_Instances_Status)_exception;
printf("get_instance status = %u\n", status);
switch (status)
{
case ENUM_INSTANCES_OK:
case ENUM_INSTANCES_FAILED:
case ENUM_INSTANCES_ACCESS_DENIED:
return status;
break;
}
printf("enum_instance received invalid code %u\n", status);
return ENUM_INSTANCES_FAILED;
}
Create_Instance_Status CIMPLE_Exception_Provider::create_instance(
CIMPLE_Exception* instance)
{
Create_Instance_Status status = (Create_Instance_Status)_exception;
printf("create_instance status = %u\n", status);
switch (status)
{
case CREATE_INSTANCE_OK:
case CREATE_INSTANCE_DUPLICATE:
case CREATE_INSTANCE_UNSUPPORTED:
case CREATE_INSTANCE_INVALID_PARAMETER:
case CREATE_INSTANCE_ACCESS_DENIED:
case CREATE_INSTANCE_FAILED:
return status;
break;
}
printf("create_instance received invalid code %u\n", status);
return CREATE_INSTANCE_FAILED;
}
Delete_Instance_Status CIMPLE_Exception_Provider::delete_instance(
const CIMPLE_Exception* instance)
{
printf("get_instance. send code %u\n", _exception);
//return (Get_Instance_Status)_exception;
Delete_Instance_Status status = (Delete_Instance_Status)_exception;
printf("get_instance status = %u\n", status);
switch (status)
{
case DELETE_INSTANCE_OK:
case DELETE_INSTANCE_NOT_FOUND:
case DELETE_INSTANCE_UNSUPPORTED:
case DELETE_INSTANCE_ACCESS_DENIED:
case DELETE_INSTANCE_FAILED:
return status;
break;
}
printf("delete_instance received invalid code %u\n", status);
return DELETE_INSTANCE_FAILED;
}
Modify_Instance_Status CIMPLE_Exception_Provider::modify_instance(
const CIMPLE_Exception* model,
const CIMPLE_Exception* instance)
{
Modify_Instance_Status status = (Modify_Instance_Status)_exception;
printf("get_instance status = %u\n", status);
switch (status)
{
case MODIFY_INSTANCE_NOT_FOUND:
case MODIFY_INSTANCE_UNSUPPORTED:
case MODIFY_INSTANCE_INVALID_PARAMETER:
case MODIFY_INSTANCE_ACCESS_DENIED:
case MODIFY_INSTANCE_OK:
case MODIFY_INSTANCE_FAILED:
return status;
break;
}
printf("modify_instance received invalid code %u\n", status);
return MODIFY_INSTANCE_FAILED;
}
const char * _print(boolean x)
{
return(x? "true" : "false");
}
Invoke_Method_Status CIMPLE_Exception_Provider::setException(
const CIMPLE_Exception* self,
const Property<uint32>& Exception,
const Property<boolean>& getInstanceDefault,
const Property<boolean>& associatorsDefault,
Property<uint32>& return_value)
{
printf("Enter setException\n");
_exception = Exception.value;
_getInstanceDefault = getInstanceDefault.value;
_associatorsDefault = associatorsDefault.value;
printf("setException Exception Value = %u\n", _exception);
printf(" getInstanceDefault Value = %s\n", _print(_getInstanceDefault));
printf(" associatorsDefault Value = %s\n", _print(_associatorsDefault));
CIMPLE_INFO(("setException Exception Value = %u\n", _exception));
return_value.set(0);
return INVOKE_METHOD_OK;
}
Invoke_Method_Status CIMPLE_Exception_Provider::testException(
const CIMPLE_Exception* self,
Property<uint32>& return_value)
{
return INVOKE_METHOD_UNSUPPORTED;
}
/*@END@*/
CIMPLE_NAMESPACE_END
|
db 0 ; species ID placeholder
db 80, 105, 105, 80, 105, 105
; hp atk def spd sat sdf
db PSYCHIC, PSYCHIC ; type
db 3 ; catch rate
db 255 ; base exp
db NO_ITEM, NO_ITEM ; items
db GENDER_UNKNOWN ; gender ratio
db 100 ; unknown 1
db 80 ; step cycles to hatch
db 5 ; unknown 2
INCBIN "gfx/pokemon/mesprit/front.dimensions"
db 0, 0, 0, 0 ; padding
db GROWTH_SLOW ; growth rate
dn EGG_NONE, EGG_NONE ; egg groups
; tm/hm learnset
tmhm HEADBUTT, CURSE, TOXIC, ZAP_CANNON, PSYCH_UP, HIDDEN_POWER, SUNNY_DAY, SNORE, BLIZZARD, HYPER_BEAM, PROTECT, RAIN_DANCE, ENDURE, FRUSTRATION, IRON_TAIL, THUNDER, RETURN, PSYCHIC_M, SHADOW_BALL, MUD_SLAP, DOUBLE_TEAM, ICE_PUNCH, SWAGGER, SLEEP_TALK, SANDSTORM, SWIFT, DEFENSE_CURL, THUNDERPUNCH, DREAM_EATER, DETECT, REST, ATTRACT, FIRE_PUNCH, NIGHTMARE, FLASH, THUNDERBOLT, ICE_BEAM
; end
|
; A216831: a(n) = Sum_{k=0..n} binomial(n,k)^3 * k!.
; Submitted by Christian Krause
; 1,2,11,88,905,11246,162607,2668436,48830273,983353690,21570885011,511212091952,13001401709881,352856328962918,10170853073795975,310093415465876716,9964607161173899777,336439048405066012466,11902368222382731461083,440122520333417057761160,16973419052349012919597481,681328337465245767957395422,28415225236988848576776114911,1229246345988279812640322719428,55076469728871250933257829162945,2552300756135285911847276443455626,122174961462188867335119306087753827,6033991117769469702434553189210365536
mov $1,1
mov $2,$0
lpb $0
mul $1,$0
sub $0,1
mov $3,$2
bin $3,$0
pow $3,3
add $1,$3
lpe
mov $0,$1
|
; A014437: Odd Fibonacci numbers.
; 1,1,3,5,13,21,55,89,233,377,987,1597,4181,6765,17711,28657,75025,121393,317811,514229,1346269,2178309,5702887,9227465,24157817,39088169,102334155,165580141,433494437,701408733,1836311903,2971215073,7778742049,12586269025,32951280099,53316291173,139583862445,225851433717,591286729879,956722026041,2504730781961,4052739537881,10610209857723,17167680177565,44945570212853,72723460248141,190392490709135,308061521170129,806515533049393,1304969544928657,3416454622906707,5527939700884757
mov $3,1
mul $3,$0
add $0,$3
add $0,$3
div $0,2
mov $1,1
mov $3,1
lpb $0,1
sub $0,1
add $1,$3
mov $2,$3
mov $3,$1
mov $1,$2
lpe
mul $1,4
div $1,8
mul $1,2
add $1,1
|
; A249101: p(n,1), where p(n,x) is defined in Comments; sum of numbers in row n of the array at A249100.
; Submitted by Jamie Morken(s3)
; 1,4,9,37,118,525,2059,9934,44937,233683,1177360,6552069,35986069,212891932,1256487933,7856137825,49320239614,324285063489,2149133929207,14796251405278,102910742502765,739149552929719,5370132965554144,40110161953250937
mul $0,2
add $0,2
mov $1,3
mov $2,2
mov $4,1
lpb $0
mov $3,$0
sub $0,2
add $2,$4
sub $3,1
mul $3,$1
mov $1,$2
mov $4,$2
mov $2,$3
lpe
mov $0,$4
div $0,3
|
SECTION code_clib
PUBLIC pointxy
EXTERN pointxy_MODE0
EXTERN pointxy_MODE1
EXTERN __sv8000_mode
INCLUDE "target/sv8000/def/sv8000.def"
pointxy:
ld a,(__sv8000_mode)
cp MODE_1
jp z,pointxy_MODE1
and a
ret nz
jp pointxy_MODE0
|
<%
from pwnlib.shellcraft.powerpc.linux import syscall
%>
<%page args="rgid, egid, sgid"/>
<%docstring>
Invokes the syscall setresgid. See 'man 2 setresgid' for more information.
Arguments:
rgid(gid_t): rgid
egid(gid_t): egid
sgid(gid_t): sgid
</%docstring>
${syscall('SYS_setresgid', rgid, egid, sgid)}
|
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <stack>
/**
Algorithms from the book Introduction to the Designs and Analysis of Algorithms by Anany Levitin
**/
struct Point2D;
struct Node;
void PrintArray(const std::vector<int>& array);
void SelectionSort(std::vector<int> &array);
void BubbleSort(std::vector<int> &array);
int SequentialSearch2(std::vector<int> &array, int key);
int BruteForceStringMatch(const std::string &text, const std::string &pattern);
int Min(float a, float b);
float BruteForceClosestPair(const std::vector<Point2D>& points);
void DepthFirstSearch(std::stack<Node*> &stack);
void CreateDFSTree(std::vector<Node*> &graph);
Node *CreateBFSTree(Node *start, Node *end);
void PrintShortestPath(Node *start, Node *end);
int main()
{
Node a('a'), b('b'), c('c'), d('d'), e('e'), f('f'), g('g');
a.AddAdjacencies({ &b, &c, &d });
b.AddAdjacencies({ &a, &f, &g });
c.AddAdjacencies({ &a, &e });
d.AddAdjacencies({ &a, &e });
e.AddAdjacencies({ &d, &c });
f.AddAdjacencies({ &b, &g });
g.AddAdjacencies({ &b, &f });
std::vector<Node*> graph = { &a, &b, &c, &d, &e, &f, &g };
CreateDFSTree(graph);
std::cin.get();
return 0;
}
void PrintArray(const std::vector<int>& array)
{
for(const int element : array)
{
std::cout << element << " ";
}
std::cout << std::endl;
}
//Sorts in nondecreasing order
void SelectionSort(std::vector<int> &array)
{
int min = 0;
for (int i = 0; i < array.size() - 1; ++i)
{
min = i;
for (int j = i + 1; j < array.size(); ++j)
{
if (array[j] < array[min])
{
min = j;
}
}
int temp = array[i];
array[i] = array[min];
array[min] = temp;
}
}
//Sorts in nondecreasing order
void BubbleSort(std::vector<int> &array)
{
for (int i = 0; i < array.size() - 1; ++i)
{
for (int j = 0; j < array.size() - 1 - i; ++j)
{
if (array[j + 1] < array[j])
{
int temp = array[j];
array[j] = array[j+1];
array[j + 1] = temp;
}
}
}
}
int SequentialSearch2(std::vector<int> &array, int key)
{
int length = array.size();
array.push_back(key);
int i = 0;
while (array[i] != key)
{
++i;
}
array.erase(array.end() - 1);
if (i < length)
return i;
else
return -1;
}
int BruteForceStringMatch(const std::string &text, const std::string &pattern)
{
int iMax = text.size() - pattern.size();
for (int i = 0; i < iMax; ++i)
{
int j = 0;
while (j < pattern.size() && pattern[j] == text[i + j])
{
++j;
}
if (j == pattern.size())
return i;
}
return -1;
}
struct Point2D
{
float x, y;
Point2D(float x, float y) : x(x), y(y) {}
};
int Min(float a, float b)
{
if (a < b)
return a;
else
return b;
}
float BruteForceClosestPair(const std::vector<Point2D>& points)
{
float d = 100;
int size = points.size();
for (int i = 0; i < size-2; ++i)
{
for (int j = i + 1; j <= size-1; ++j)
{
float x2 = (points[i].x - points[j].x) * (points[i].x - points[j].x);
float y2 = (points[i].y - points[j].y) * (points[i].y - points[j].y);
d = Min(d, x2 + y2);
}
}
return d;
}
struct Node
{
char mName;
int mCount = 0;
std::vector<Node*> mAdjacencies;
Node *mParent = nullptr;
Node(char name) : mName(name){}
void AddAdjacencies(const std::initializer_list<Node*> &adj)
{
mAdjacencies = adj;
}
};
void DepthFirstSearch(std::stack<Node*> &stack)
{
static int count = 0;
Node *node = stack.top();
if (node->mCount == 0)
{
node->mCount = ++count;
std::cout << node->mName << " ";
for (Node *node : node->mAdjacencies)
{
if (node->mCount == 0)
{
stack.push(node);
DepthFirstSearch(stack);
}
}
stack.pop();
}
}
void CreateDFSTree(std::vector<Node*> &graph)
{
std::stack<Node*> stack;
stack.push(graph[0]);
for (Node* node : graph)
{
if (node->mCount == 0)
{
DepthFirstSearch(stack);
}
}
}
Node *CreateBFSTree(Node *start, Node *end)
{
static int count = 1;
std::queue<Node*> nodes;
start->mCount = count;
nodes.push(start);
while (!nodes.empty())
{
Node *front = nodes.front();
for (Node *adj : front->mAdjacencies)
{
if (adj->mCount == 0)
{
adj->mCount = ++count;
adj->mParent = front;
if (adj->mName == end->mName)
{
return adj;
}
nodes.push(adj);
}
}
nodes.pop();
}
}
void PrintShortestPath(Node *start, Node *end)
{
Node *currentNode = end;
while (currentNode->mParent != nullptr)
{
std::cout << currentNode->mName << " <- ";
currentNode = currentNode->mParent;
}
std::cout << start->mName << std::endl;
}
|
SECTION code_clib
SECTION code_l
PUBLIC l_fast_ultoo
EXTERN l_fast_utoo, l_setmem_de
EXTERN l1_fast_utoo_lz, l1_fast_utoo_nlz
EXTERN l2_fast_utoo_lz, l2_fast_utoo_nlz
EXTERN l3_fast_utoo_lz, l3_fast_utoo_nlz
l_fast_ultoo:
; write unsigned octal long to ascii buffer
;
; enter : dehl = unsigned long
; bc = char *buffer
; carry set to write leading zeroes
;
; exit : de = char *buffer (one byte past last char written)
; carry set if in write loop
;
; uses : af, bc, de, hl
inc d
dec d
jr nz, _32_bit
inc e
dec e
jr nz, _24_bit
_16_bit:
ld e,c
ld d,b ; de = char *buffer
jp nc, l_fast_utoo
ld a,'0'
call l_setmem_de - 10 ; write five leading zeroes
jp l_fast_utoo
_24_bit:
push hl ; save LSW
ld h,e
ld e,c
ld d,b ; de = char *buffer
ld c,h
ld b,2
jr c, leading_zeroes_24
xor a
call l1_fast_utoo_nlz
rejoin_24:
pop hl
ld b,6
jr c, rejoin_24_lz
ld a,c
and $03
dec de
jp l3_fast_utoo_nlz
rejoin_24_lz:
ld a,c
and $03
jp l3_fast_utoo_lz
leading_zeroes_24:
ld a,'0'
call l_setmem_de - 6
xor a
call l1_fast_utoo_lz
jr rejoin_24
_32_bit:
push hl ; save LSW
ex de,hl
ld e,c
ld d,b ; de = char *buffer
ld c,l
ld b,5
ld a,0
call c, l2_fast_utoo_lz
call nc, l2_fast_utoo_nlz
jr rejoin_24
|
// TwinkleFOX by Mark Kriegsman: https://gist.github.com/kriegsman/756ea6dcae8e30845b5a
//
// TwinkleFOX: Twinkling 'holiday' lights that fade in and out.
// Colors are chosen from a palette; a few palettes are provided.
//
// This December 2015 implementation improves on the December 2014 version
// in several ways:
// - smoother fading, compatible with any colors and any palettes
// - easier control of twinkle speed and twinkle density
// - supports an optional 'background color'
// - takes even less RAM: zero RAM overhead per pixel
// - illustrates a couple of interesting techniques (uh oh...)
//
// The idea behind this (new) implementation is that there's one
// basic, repeating pattern that each pixel follows like a waveform:
// The brightness rises from 0..255 and then falls back down to 0.
// The brightness at any given point in time can be determined as
// as a function of time, for example:
// brightness = sine( time ); // a sine wave of brightness over time
//
// So the way this implementation works is that every pixel follows
// the exact same wave function over time. In this particular case,
// I chose a sawtooth triangle wave (triwave8) rather than a sine wave,
// but the idea is the same: brightness = triwave8( time ).
//
// Of course, if all the pixels used the exact same wave form, and
// if they all used the exact same 'clock' for their 'time base', all
// the pixels would brighten and dim at once -- which does not look
// like twinkling at all.
//
// So to achieve random-looking twinkling, each pixel is given a
// slightly different 'clock' signal. Some of the clocks run faster,
// some run slower, and each 'clock' also has a random offset from zero.
// The net result is that the 'clocks' for all the pixels are always out
// of sync from each other, producing a nice random distribution
// of twinkles.
//
// The 'clock speed adjustment' and 'time offset' for each pixel
// are generated randomly. One (normal) approach to implementing that
// would be to randomly generate the clock parameters for each pixel
// at startup, and store them in some arrays. However, that consumes
// a great deal of precious RAM, and it turns out to be totally
// unnessary! If the random number generate is 'seeded' with the
// same starting value every time, it will generate the same sequence
// of values every time. So the clock adjustment parameters for each
// pixel are 'stored' in a pseudo-random number generator! The PRNG
// is reset, and then the first numbers out of it are the clock
// adjustment parameters for the first pixel, the second numbers out
// of it are the parameters for the second pixel, and so on.
// In this way, we can 'store' a stable sequence of thousands of
// random clock adjustment parameters in literally two bytes of RAM.
//
// There's a little bit of fixed-point math involved in applying the
// clock speed adjustments, which are expressed in eighths. Each pixel's
// clock speed ranges from 8/8ths of the system clock (i.e. 1x) to
// 23/8ths of the system clock (i.e. nearly 3x).
//
// On a basic Arduino Uno or Leonardo, this code can twinkle 300+ pixels
// smoothly at over 50 updates per seond.
//
// -Mark Kriegsman, December 2015
#include "pixelstick.h"
extern CRGB leds[];
extern PresetInfo presetList[];
extern const CRGBPalette16 palettes[];
// Overall twinkle speed.
// 0 (VERY slow) to 8 (VERY fast).
// 4, 5, and 6 are recommended, default is 4.
// uint8_t twinkleSpeed = 4;
// Overall twinkle density.
// 0 (NONE lit) to 8 (ALL lit at once).
// Default is 5.
// uint8_t twinkleDensity = 5;
// Background color for 'unlit' pixels
// Can be set to CRGB::Black if desired.
CRGB gBackgroundColor = CRGB::Black;
// Example of dim incandescent fairy light background color
// CRGB gBackgroundColor = CRGB(CRGB::FairyLight).nscale8_video(16);
// If AUTO_SELECT_BACKGROUND_COLOR is set to 1,
// then for any palette where the first two entries
// are the same, a dimmed version of that color will
// automatically be used as the background color.
#define AUTO_SELECT_BACKGROUND_COLOR 0
// If COOL_LIKE_INCANDESCENT is set to 1, colors will
// fade out slighted 'reddened', similar to how
// incandescent bulbs change color as they get dim down.
#define COOL_LIKE_INCANDESCENT 1
CRGBPalette16 twinkleFoxPalette;
// This function is like 'triwave8', which produces a
// symmetrical up-and-down triangle sawtooth waveform, except that this
// function produces a triangle wave with a faster attack and a slower decay:
//
// / \
// / \
// / \
// / \
//
uint8_t attackDecayWave8(uint8_t i)
{
if (i < 86)
{
return i * 3;
}
else
{
i -= 86;
return 255 - (i + (i / 2));
}
}
// This function takes a pixel, and if its in the 'fading down'
// part of the cycle, it adjusts the color a little bit like the
// way that incandescent bulbs fade toward 'red' as they dim.
void coolLikeIncandescent(CRGB &c, uint8_t phase)
{
if (phase < 128)
return;
uint8_t cooling = (phase - 128) >> 4;
c.g = qsub8(c.g, cooling);
c.b = qsub8(c.b, cooling * 2);
}
// This function takes a time in pseudo-milliseconds,
// figures out brightness = f( time ), and also hue = f( time )
// The 'low digits' of the millisecond time are used as
// input to the brightness wave function.
// The 'high digits' are used to select a color, so that the color
// does not change over the course of the fade-in, fade-out
// of one cycle of the brightness wave function.
// The 'high digits' are also used to determine whether this pixel
// should light at all during this cycle, based on the twinkleDensity.
CRGB computeOneTwinkle(uint32_t ms, uint8_t salt)
{
uint16_t ticks = ms >> (8 - presetList[getConfig().presetIndex].parms[0].values[2]);
uint8_t fastcycle8 = ticks;
uint16_t slowcycle16 = (ticks >> 8) + salt;
slowcycle16 += sin8(slowcycle16);
slowcycle16 = (slowcycle16 * 2053) + 1384;
uint8_t slowcycle8 = (slowcycle16 & 0xFF) + (slowcycle16 >> 8);
uint8_t bright = 0;
if (((slowcycle8 & 0x0E) / 2) < presetList[getConfig().presetIndex].parms[1].values[2])
{
bright = attackDecayWave8(fastcycle8);
}
uint8_t hue = slowcycle8 - salt;
CRGB c;
if (bright > 0)
{
c = ColorFromPalette(twinkleFoxPalette, hue, bright, NOBLEND);
if (COOL_LIKE_INCANDESCENT == 1)
{
coolLikeIncandescent(c, fastcycle8);
}
}
else
{
c = CRGB::Black;
}
return c;
}
// This function loops over each pixel, calculates the
// adjusted 'clock' that this pixel should use, and calls
// "CalculateOneTwinkle" on each pixel. It then displays
// either the twinkle color of the background color,
// whichever is brighter.
void drawTwinkles()
{
twinkleFoxPalette = palettes[presetList[getConfig().presetIndex].paletteIndex];
// "PRNG16" is the pseudorandom number generator
// It MUST be reset to the same starting value each time
// this function is called, so that the sequence of 'random'
// numbers that it generates is (paradoxically) stable.
uint16_t PRNG16 = 11337;
uint32_t clock32 = millis();
// Set up the background color, "bg".
// if AUTO_SELECT_BACKGROUND_COLOR == 1, and the first two colors of
// the current palette are identical, then a deeply faded version of
// that color is used for the background color
CRGB bg;
if ((AUTO_SELECT_BACKGROUND_COLOR == 1) &&
(twinkleFoxPalette[0] == twinkleFoxPalette[1]))
{
bg = twinkleFoxPalette[0];
uint8_t bglight = bg.getAverageLight();
if (bglight > 64)
{
bg.nscale8_video(16); // very bright, so scale to 1/16th
}
else if (bglight > 16)
{
bg.nscale8_video(64); // not that bright, so scale to 1/4th
}
else
{
bg.nscale8_video(86); // dim, scale to 1/3rd.
}
}
else
{
bg = gBackgroundColor; // just use the explicitly defined background color
}
uint8_t backgroundBrightness = bg.getAverageLight();
for (uint16_t i = 0; i < NUM_LEDS; i++)
{
CRGB &pixel = leds[i];
PRNG16 = (uint16_t)(PRNG16 * 2053) + 1384; // next 'random' number
uint16_t myclockoffset16 = PRNG16; // use that number as clock offset
PRNG16 = (uint16_t)(PRNG16 * 2053) + 1384; // next 'random' number
// use that number as clock speed adjustment factor (in 8ths, from 8/8ths to 23/8ths)
uint8_t myspeedmultiplierQ5_3 = ((((PRNG16 & 0xFF) >> 4) + (PRNG16 & 0x0F)) & 0x0F) + 0x08;
uint32_t myclock30 = (uint32_t)((clock32 * myspeedmultiplierQ5_3) >> 3) + myclockoffset16;
uint8_t myunique8 = PRNG16 >> 8; // get 'salt' value for this pixel
// We now have the adjusted 'clock' for this pixel, now we call
// the function that computes what color the pixel should be based
// on the "brightness = f( time )" idea.
CRGB c = computeOneTwinkle(myclock30, myunique8);
uint8_t cbright = c.getAverageLight();
int16_t deltabright = cbright - backgroundBrightness;
if (deltabright >= 32 || (!bg))
{
// If the new pixel is significantly brighter than the background color,
// use the new color.
pixel = c;
}
else if (deltabright > 0)
{
// If the new pixel is just slightly brighter than the background color,
// mix a blend of the new color and the background color
pixel = blend(bg, c, deltabright * 8);
}
else
{
// if the new pixel is not at all brighter than the background color,
// just use the background color.
pixel = bg;
}
}
}
// A mostly red palette with green accents and white trim.
// "CRGB::Gray" is used as white to keep the brightness more uniform.
extern const TProgmemRGBPalette16 RedGreenWhite_p FL_PROGMEM =
{CRGB::Red, CRGB::Red, CRGB::Red, CRGB::Red,
CRGB::Red, CRGB::Red, CRGB::Red, CRGB::Red,
CRGB::Red, CRGB::Red, CRGB::Gray, CRGB::Gray,
CRGB::Green, CRGB::Green, CRGB::Green, CRGB::Green};
// A mostly (dark) green palette with red berries.
#define Holly_Green 0x00580c
#define Holly_Red 0xB00402
extern const TProgmemRGBPalette16 Holly_p FL_PROGMEM =
{Holly_Green, Holly_Green, Holly_Green, Holly_Green,
Holly_Green, Holly_Green, Holly_Green, Holly_Green,
Holly_Green, Holly_Green, Holly_Green, Holly_Green,
Holly_Green, Holly_Green, Holly_Green, Holly_Red};
// A red and white striped palette
// "CRGB::Gray" is used as white to keep the brightness more uniform.
extern const TProgmemRGBPalette16 RedWhite_p FL_PROGMEM =
{CRGB::Red, CRGB::Red, CRGB::Gray, CRGB::Gray,
CRGB::Red, CRGB::Red, CRGB::Gray, CRGB::Gray,
CRGB::Red, CRGB::Red, CRGB::Gray, CRGB::Gray,
CRGB::Red, CRGB::Red, CRGB::Gray, CRGB::Gray};
// A mostly blue palette with white accents.
// "CRGB::Gray" is used as white to keep the brightness more uniform.
extern const TProgmemRGBPalette16 BlueWhite_p FL_PROGMEM =
{CRGB::Blue, CRGB::Blue, CRGB::Blue, CRGB::Blue,
CRGB::Blue, CRGB::Blue, CRGB::Blue, CRGB::Blue,
CRGB::Blue, CRGB::Blue, CRGB::Blue, CRGB::Blue,
CRGB::Blue, CRGB::Gray, CRGB::Gray, CRGB::Gray};
// A pure "fairy light" palette with some brightness variations
#define HALFFAIRY ((CRGB::FairyLight & 0xFEFEFE) / 2)
#define QUARTERFAIRY ((CRGB::FairyLight & 0xFCFCFC) / 4)
extern const TProgmemRGBPalette16 FairyLight_p FL_PROGMEM =
{CRGB::FairyLight, CRGB::FairyLight, CRGB::FairyLight, CRGB::FairyLight,
HALFFAIRY, HALFFAIRY, CRGB::FairyLight, CRGB::FairyLight,
QUARTERFAIRY, QUARTERFAIRY, CRGB::FairyLight, CRGB::FairyLight,
CRGB::FairyLight, CRGB::FairyLight, CRGB::FairyLight, CRGB::FairyLight};
// A palette of soft snowflakes with the occasional bright one
extern const TProgmemRGBPalette16 Snow_p FL_PROGMEM =
{0x304048, 0x304048, 0x304048, 0x304048,
0x304048, 0x304048, 0x304048, 0x304048,
0x304048, 0x304048, 0x304048, 0x304048,
0x304048, 0x304048, 0x304048, 0xE0F0FF};
// A palette reminiscent of large 'old-school' C9-size tree lights
// in the five classic colors: red, orange, green, blue, and white.
#define C9_Red 0xB80400
#define C9_Orange 0x902C02
#define C9_Green 0x046002
#define C9_Blue 0x070758
#define C9_White 0x606820
extern const TProgmemRGBPalette16 RetroC9_p FL_PROGMEM =
{C9_Red, C9_Orange, C9_Red, C9_Orange,
C9_Orange, C9_Red, C9_Orange, C9_Red,
C9_Green, C9_Green, C9_Green, C9_Green,
C9_Blue, C9_Blue, C9_Blue,
C9_White};
// A cold, icy pale blue palette
#define Ice_Blue1 0x0C1040
#define Ice_Blue2 0x182080
#define Ice_Blue3 0x5080C0
extern const TProgmemRGBPalette16 Ice_p FL_PROGMEM =
{Ice_Blue1, Ice_Blue1, Ice_Blue1, Ice_Blue1,
Ice_Blue1, Ice_Blue1, Ice_Blue1, Ice_Blue1,
Ice_Blue1, Ice_Blue1, Ice_Blue1, Ice_Blue1,
Ice_Blue2, Ice_Blue2, Ice_Blue2, Ice_Blue3};
|
// Copyright 2021 Master Kenth
#include "MainController.h"
#include "Components/InputComponent.h"
#include "MainCharacter.h"
void AMainController::OnPossess(APawn* aPawn)
{
Super::OnPossess(aPawn);
AMainCharacter* pawnAsMainCharacter = Cast<AMainCharacter>(aPawn);
if (pawnAsMainCharacter)
{
MainCharacter = pawnAsMainCharacter;
}
}
void AMainController::SetupInputComponent()
{
Super::SetupInputComponent();
InputComponent->BindAxis(TEXT("LookUp"), this, &AMainController::OnLookUp);
InputComponent->BindAxis(TEXT("LookRight"), this, &AMainController::OnLookRight);
InputComponent->BindAxis(TEXT("MoveForward"), this, &AMainController::OnMoveForward);
InputComponent->BindAxis(TEXT("MoveRight"), this, &AMainController::OnMoveRight);
}
void AMainController::OnLookUp(float Val)
{
AddPitchInput(Val);
}
void AMainController::OnLookRight(float Val)
{
AddYawInput(Val);
}
void AMainController::OnMoveForward(float Val)
{
if (MainCharacter)
{
MainCharacter->AddMovementInput(MainCharacter->GetActorForwardVector() * Val);
}
}
void AMainController::OnMoveRight(float Val)
{
if (MainCharacter)
{
MainCharacter->AddMovementInput(MainCharacter->GetActorRightVector() * Val);
}
}
|
org #0000
;; texture "i" will be in address "textures+i*256"
walltexture1:
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db #C0,#C0,#C0,#C0, 0, 0,#20,#20,#C0,#C0,#C0,#C0, 0, 0,#20,#90
db #C0,#C0,#C0,#C0, 0, 0,#C0,#C0,#C0,#C0,#C0,#C0, 0, 0,#C0,#80
db #C0,#C0,#C0,#C0, 0, 0,#C0,#C0,#C0,#C0,#C0,#C0, 0, 0,#C0,#80
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0,#20,#20,#C0,#C0,#C0,#C0, 0, 0,#20,#20,#C0,#C0,#C0,#80
db 0, 0,#C0,#C0,#C0,#C0,#C0,#C0, 0, 0,#C0,#C0,#C0,#C0,#C0,#80
db 0, 0,#C0,#C0,#C0,#C0,#C0,#C0, 0, 0,#C0,#C0,#C0,#C0,#C0,#80
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db #C0,#C0,#C0,#C0, 0, 0,#20,#20,#C0,#C0,#C0,#C0, 0, 0,#20,#90
db #C0,#C0,#C0,#C0, 0, 0,#C0,#C0,#C0,#C0,#C0,#C0, 0, 0,#C0,#80
db #C0,#C0,#C0,#C0, 0, 0,#C0,#C0,#C0,#C0,#C0,#C0, 0, 0,#C0,#80
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0,#20,#20,#C0,#C0,#C0,#C0, 0, 0,#20,#20,#C0,#C0,#C0,#80
db 0, 0,#C0,#C0,#C0,#C0,#C0,#C0, 0, 0,#C0,#C0,#C0,#C0,#C0,#80
db 0, 0,#C0,#C0,#C0,#C0,#C0,#C0, 0, 0,#C0,#C0,#C0,#C0,#C0,#80
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db #C0,#C0,#C0,#C0, 0, 0,#20,#20,#C0,#C0,#C0,#C0, 0, 0,#20,#90
db #C0,#C0,#C0,#C0, 0, 0,#C0,#C0,#C0,#C0,#C0,#C0, 0, 0,#C0,#80
db #C0,#C0,#C0,#C0, 0, 0,#C0,#C0,#C0,#C0,#C0,#C0, 0, 0,#C0,#80
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0,#20,#20,#C0,#C0,#C0,#C0, 0, 0,#20,#20,#C0,#C0,#C0,#80
db 0, 0,#C0,#C0,#C0,#C0,#C0,#C0, 0, 0,#C0,#C0,#C0,#C0,#C0,#80
db 0, 0,#C0,#C0,#C0,#C0,#C0,#C0, 0, 0,#C0,#C0,#C0,#C0,#C0,#80
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
walltexture2:
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db #D0,#D0,#D0,#D0, 0, 0,#50,#50,#D0,#D0,#D0,#D0, 0, 0,#50,#90
db #D0,#D0,#D0,#D0, 0, 0,#D0,#D0,#D0,#D0,#D0,#D0, 0, 0,#D0,#80
db #D0,#D0,#D0,#D0, 0, 0,#D0,#D0,#D0,#D0,#D0,#D0, 0, 0,#D0,#80
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0,#50,#50,#D0,#D0,#D0,#D0, 0, 0,#50,#50,#D0,#D0,#D0,#80
db 0, 0,#D0,#D0,#D0,#D0,#D0,#D0, 0, 0,#D0,#D0,#D0,#D0,#D0,#80
db 0, 0,#D0,#D0,#D0,#D0,#D0,#D0, 0, 0,#D0,#D0,#D0,#D0,#D0,#80
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db #D0,#D0,#D0,#D0, 0, 0,#50,#50,#D0,#D0,#D0,#D0, 0, 0,#50,#90
db #D0,#D0,#D0,#D0, 0, 0,#D0,#D0,#D0,#D0,#D0,#D0, 0, 0,#D0,#80
db #D0,#D0,#D0,#D0, 0, 0,#D0,#D0,#D0,#D0,#D0,#D0, 0, 0,#D0,#80
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0,#50,#50,#D0,#D0,#D0,#D0, 0, 0,#50,#50,#D0,#D0,#D0,#80
db 0, 0,#D0,#D0,#D0,#D0,#D0,#D0, 0, 0,#D0,#D0,#D0,#D0,#D0,#80
db 0, 0,#D0,#D0,#D0,#D0,#D0,#D0, 0, 0,#D0,#D0,#D0,#D0,#D0,#80
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db #D0,#D0,#D0,#D0, 0, 0,#50,#50,#D0,#D0,#D0,#D0, 0, 0,#50,#90
db #D0,#D0,#D0,#D0, 0, 0,#D0,#D0,#D0,#D0,#D0,#D0, 0, 0,#D0,#80
db #D0,#D0,#D0,#D0, 0, 0,#D0,#D0,#D0,#D0,#D0,#D0, 0, 0,#D0,#80
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0,#50,#50,#D0,#D0,#D0,#D0, 0, 0,#50,#50,#D0,#D0,#D0,#80
db 0, 0,#D0,#D0,#D0,#D0,#D0,#D0, 0, 0,#D0,#D0,#D0,#D0,#D0,#80
db 0, 0,#D0,#D0,#D0,#D0,#D0,#D0, 0, 0,#D0,#D0,#D0,#D0,#D0,#80
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
statuetexture:
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, #00
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, #00
db 0, 0, 0, 0, 0, 0, #50, #50, #50, 0, 0, 0, 0, 0, 0, #00
db 0, 0, 0, 0, 0, #50, #50, #50, #50, #50, 0, 0, 0, 0, 0, #00
db 0, 0, 0, 0, #50, 0, 0, 0, 0, 0, #50, 0, 0, 0, #f0, #00
db 0, 0, 0, 0, 0, #50, #50, #50, #50, #50, 0, 0, 0, 0, #f0, #00
db 0, 0, 0, 0, #50, 0, #50, 0, #50, 0, #50, 0, 0, 0, 0, #00
db 0, 0, 0, 0, #50, 0, #50, 0, #50, 0, #50, 0, 0, 0, #50, #00
db 0, 0, 0, 0, #50, 0, #50, 0, #50, 0, #50, 0, 0, 0, #50, #00
db 0, 0, 0, 0, #50, 0, #50, 0, #50, 0, #50, 0, 0, 0, #50, #00
db 0, 0, #E0, #E0, 0, #50, #50, #50, #50, #50, 0, #E0, 0, 0, #50, #00
db 0, #E0, #E0, #E0, #E0, 0, 0, 0, 0, 0, #E0, #E0, #E0, 0, #50, #00
db 0, #E0, #E0, #E0, #E0, #E0, #E0, 0, #E0, #E0, #E0, #E0, #E0, 0, #50, #00
db 0, #E0, #E0, 0, #E0, #E0, #E0, #E0, #E0, #E0, #E0, 0, #E0, 0, #50, #00
db 0, #E0, #E0, 0, 0, 0, 0, #E0, 0, 0, 0, 0, #E0, #E0, 0, #00
db 0, #E0, #E0, 0, #E0, #E0, #E0, 0, #E0, #E0, #E0, 0, #E0, #E0, #E0, #00
db 0, #E0, 0, 0, 0, #E0, #E0, #E0, #E0, #E0, 0, 0, 0, #E0, #E0, #00
db 0, #E0, 0, 0, 0, #E0, #E0, #E0, #E0, #E0, 0, 0, 0, 0, 0, #00
db 0, #E0, #E0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, #50, #00
db 0, #E0, #E0, 0, 0, #50, #50, #50, #50, #50, 0, 0, 0, 0, #50, #00
db 0, 0, #E0, 0, #E0, 0, #50, #50, #50, 0, #E0, 0, 0, 0, #50, #00
db 0, 0, 0, 0, #E0, #E0, 0, #50, 0, #E0, #E0, 0, 0, 0, #50, #00
db 0, 0, 0, #E0, #E0, #E0, 0, 0, 0, #E0, #E0, #E0, 0, 0, #50, #00
db 0, 0, 0, #E0, #E0, 0, 0, 0, 0, 0, #E0, #E0, 0, 0, #50, #00
db 0, 0, 0, 0, #50, #50, 0, 0, 0, #50, #50, 0, 0, 0, #50, #00
db 0, 0, 0, 0, #50, #50, 0, 0, 0, #50, #50, 0, 0, 0, #50, #00
db 0, 0, #50, #50, #50, #50, 0, 0, 0, #50, #50, #50, #50, 0, #50, #00
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, #00
db 0, 0, #f0, #f0, #f0, #f0, #f0, #f0, #f0, #f0, #f0, #f0, #f0, #f0, 0, #00
db 0, 0, 0, 0, #f0, #f0, #f0, #f0, #f0, #f0, #f0, #f0, #f0, 0, 0, #00
db 0, 0, #f0, #f0, #f0, #f0, #f0, #f0, #f0, #f0, #f0, #f0, #f0, #f0, 0, #00
db 0, #f0, #f0, #f0, #f0, #f0, #f0, #f0, #f0, #f0, #f0, #f0, #f0, #f0, #f0, #00
|
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// Increment local_iterator past end.
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <unordered_map>
#include <string>
#include <cassert>
#include <iterator>
#include <exception>
#include <cstdlib>
#include "min_allocator.h"
int main()
{
{
typedef std::unordered_multimap<int, std::string> C;
C c(1);
C::local_iterator i = c.begin(0);
++i;
++i;
assert(false);
}
#if TEST_STD_VER >= 11
{
typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
min_allocator<std::pair<const int, std::string>>> C;
C c(1);
C::local_iterator i = c.begin(0);
++i;
++i;
assert(false);
}
#endif
}
#else
int main()
{
}
#endif
|
// Boost noncopyable.hpp header file --------------------------------------//
// (C) Copyright Beman Dawes 1999-2003. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org/libs/utility for documentation.
#ifndef BOOST_NONCOPYABLE_HPP_INCLUDED
#define BOOST_NONCOPYABLE_HPP_INCLUDED
namespace riakboost{} namespace boost = riakboost; namespace riakboost{
// Private copy constructor and copy assignment ensure classes derived from
// class noncopyable cannot be copied.
// Contributed by Dave Abrahams
namespace noncopyable_ // protection from unintended ADL
{
class noncopyable
{
protected:
noncopyable() {}
~noncopyable() {}
private: // emphasize the following members are private
noncopyable( const noncopyable& );
const noncopyable& operator=( const noncopyable& );
};
}
typedef noncopyable_::noncopyable noncopyable;
} // namespace riakboost
#endif // BOOST_NONCOPYABLE_HPP_INCLUDED
|
//: ----------------------------------------------------------------------------
//: Copyright Verizon.
//:
//: \file: host_info.cc
//: \details: TODO
//:
//: Licensed under the terms of the Apache 2.0 open source license.
//: Please refer to the LICENSE file in the project root for the terms.
//: ----------------------------------------------------------------------------
//: ----------------------------------------------------------------------------
//: includes
//: ----------------------------------------------------------------------------
#include "host_info.h"
#include <netinet/in.h>
#include <sys/socket.h>
#include <netdb.h>
#include <stdio.h>
#include <string.h>
#include "host_info.h"
#include "def.h"
namespace ns_tlsscan {
//: ----------------------------------------------------------------------------
//: \details: TODO
//: \return: TODO
//: \param: TODO
//: ----------------------------------------------------------------------------
host_info::host_info():
m_host(),
m_sa(),
m_sa_len(16),
m_sock_family(AF_INET),
m_sock_type(SOCK_STREAM),
m_sock_protocol(IPPROTO_TCP)
{
((struct sockaddr_in *)(&m_sa))->sin_family = AF_INET;
};
//: ----------------------------------------------------------------------------
//: \details: TODO
//: \return: TODO
//: \param: TODO
//: ----------------------------------------------------------------------------
void host_info::show(void)
{
char l_hoststr[NI_MAXHOST] = "";
char l_portstr[NI_MAXSERV] = "";
int32_t l_s;
l_s = getnameinfo((struct sockaddr *)&m_sa,
sizeof(struct sockaddr_storage),
l_hoststr,
sizeof(l_hoststr),
l_portstr,
sizeof(l_portstr),
NI_NUMERICHOST | NI_NUMERICSERV);
if (l_s != 0)
{
// TODO???
}
printf("+-----------+\n");
printf("| Host Info |\n");
printf("+-----------+-------------------------\n");
printf(": address: %s:%s\n", l_hoststr, l_portstr);
printf(": m_sock_family: %d\n", m_sock_family);
printf(": m_sock_type: %d\n", m_sock_type);
printf(": m_sock_protocol: %d\n", m_sock_protocol);
printf(": m_sa_len: %d\n", m_sa_len);
printf("+-------------------------------------\n");
}
//: ----------------------------------------------------------------------------
//: \details: slow resolution
//: \return: TODO
//: \param: TODO
//: ----------------------------------------------------------------------------
int32_t lookup(const std::string &a_host,
uint16_t a_port,
host_info &ao_host_info,
int a_ai_family)
{
//NDBG_PRINT("%sRESOLVE%s: a_host: %s a_port: %d\n",
// ANSI_COLOR_BG_RED, ANSI_COLOR_OFF,
// a_host.c_str(), a_port);
// Initialize...
ao_host_info.m_host = a_host;
ao_host_info.m_sa_len = sizeof(ao_host_info.m_sa);
memset((void*) &(ao_host_info.m_sa), 0, ao_host_info.m_sa_len);
// -------------------------------------------------
// get address...
// -------------------------------------------------
struct addrinfo l_hints;
memset(&l_hints, 0, sizeof(l_hints));
l_hints.ai_family = a_ai_family;
l_hints.ai_socktype = SOCK_STREAM;
char portstr[10];
snprintf(portstr, sizeof(portstr), "%d", (int) a_port);
struct addrinfo* l_addrinfo;
int l_gaierr;
l_gaierr = getaddrinfo(a_host.c_str(), portstr, &l_hints, &l_addrinfo);
if(l_gaierr != 0)
{
//NDBG_PRINT("Error getaddrinfo '%s': %s\n", a_host.c_str(), gai_strerror(l_gaierr));
return STATUS_ERROR;
}
// -------------------------------------------------
// Find the first IPv4 and IPv6 entries.
// -------------------------------------------------
struct addrinfo* l_addrinfo_v4 = NULL;
struct addrinfo* l_addrinfo_v6 = NULL;
for (struct addrinfo* i_addrinfo = l_addrinfo;
i_addrinfo != (struct addrinfo*) 0;
i_addrinfo = i_addrinfo->ai_next)
{
switch (i_addrinfo->ai_family)
{
case AF_INET:
{
if(l_addrinfo_v4 == (struct addrinfo*) 0)
{
l_addrinfo_v4 = i_addrinfo;
}
break;
}
case AF_INET6:
{
if(l_addrinfo_v6 == (struct addrinfo*) 0)
{
l_addrinfo_v6 = i_addrinfo;
}
break;
}
}
// hack to force to check all lookups for localhost...
if((a_host != "localhost") &&
(l_addrinfo_v4 ||
l_addrinfo_v6))
{
break;
}
}
// -------------------------------------------------
// if IPv4 address, else try IPv6.
// -------------------------------------------------
if(l_addrinfo_v4 != NULL)
{
if(sizeof(ao_host_info.m_sa) < l_addrinfo_v4->ai_addrlen)
{
//NDBG_PRINT("Error %s - sockaddr too small (%lu < %lu)\n",
// a_host.c_str(),
// (unsigned long) sizeof(ao_host_info.m_sa),
// (unsigned long) l_addrinfo_v4->ai_addrlen);
return STATUS_ERROR;
}
ao_host_info.m_sock_family = l_addrinfo_v4->ai_family;
ao_host_info.m_sock_type = l_addrinfo_v4->ai_socktype;
ao_host_info.m_sock_protocol = l_addrinfo_v4->ai_protocol;
ao_host_info.m_sa_len = l_addrinfo_v4->ai_addrlen;
//NDBG_PRINT("memmove: addrlen: %d\n", l_addrinfo_v4->ai_addrlen);
//mem_display((const uint8_t *)l_addrinfo_v4->ai_addr,
// l_addrinfo_v4->ai_addrlen,
// true);
memmove(&(ao_host_info.m_sa),
l_addrinfo_v4->ai_addr,
l_addrinfo_v4->ai_addrlen);
// Set the port
((sockaddr_in *)(&(ao_host_info.m_sa)))->sin_port = htons(a_port);
freeaddrinfo(l_addrinfo);
}
// -------------------------------------------------
// ipv6
// -------------------------------------------------
else if(l_addrinfo_v6 != NULL)
{
if(sizeof(ao_host_info.m_sa) < l_addrinfo_v6->ai_addrlen)
{
//NDBG_PRINT("Error %s - sockaddr too small (%lu < %lu)\n",
// a_host.c_str(),
// (unsigned long) sizeof(ao_host_info.m_sa),
// (unsigned long) l_addrinfo_v6->ai_addrlen);
return STATUS_ERROR;
}
ao_host_info.m_sock_family = l_addrinfo_v6->ai_family;
ao_host_info.m_sock_type = l_addrinfo_v6->ai_socktype;
ao_host_info.m_sock_protocol = l_addrinfo_v6->ai_protocol;
ao_host_info.m_sa_len = l_addrinfo_v6->ai_addrlen;
//NDBG_PRINT("memmove: addrlen: %d\n", l_addrinfo_v6->ai_addrlen);
//ns_tlsscan::mem_display((const uint8_t *)l_addrinfo_v6->ai_addr,
// l_addrinfo_v6->ai_addrlen,
// true);
memmove(&ao_host_info.m_sa,
l_addrinfo_v6->ai_addr,
l_addrinfo_v6->ai_addrlen);
// Set the port
((sockaddr_in6 *)(&(ao_host_info.m_sa)))->sin6_port = htons(a_port);
freeaddrinfo(l_addrinfo);
}
// -------------------------------------------------
// else error...
// -------------------------------------------------
else
{
//NDBG_PRINT("Error no valid address found for host %s\n", a_host.c_str());
return STATUS_ERROR;
}
return STATUS_OK;
}
} //namespace ns_tlsscan {
|
; A095998: n! * (fractional part of n-th harmonic number).
; Submitted by Jon Maiga
; 0,1,5,2,34,324,2988,28944,300816,3371040,793440,49438080,1121696640,21930773760,416139897600,7965912729600,156343306291200,3169866941337600,66629845591142400,1454242012231680000
mov $1,1
mov $2,1
lpb $0
sub $0,1
add $2,1
mul $3,$2
add $3,$1
mul $1,$2
lpe
mod $3,$1
mov $0,$3
|
INCLUDE "clib_cfg.asm"
SECTION code_driver
SECTION code_driver_terminal_input
PUBLIC console_01_input_proc_echo, console_01_input_proc_oterm
EXTERN ITERM_MSG_PUTC, l_jpix
console_01_input_proc_echo:
; a = char to output to oterm
bit 7,(ix+6)
ret z ; if echo off
ld c,a
ld a,ITERM_MSG_PUTC
bit 6,(ix+6)
jr z, console_01_input_proc_oterm ; if not password mode
ld c,CHAR_PASSWORD
console_01_input_proc_oterm:
; a = message to output terminal
; bc = parameter
; de = parameter
; ix = & FDSTRUCT.JP (input terminal)
ld l,(ix+14)
ld h,(ix+15) ; hl = FDSTRUCT *oterm
inc h
dec h
jr nz, cont
inc l
dec l
ret z ; silently fail if output terminal is not connected
cont:
push hl
ex (sp),ix ; ix = FDSTRUCT *oterm
call l_jpix ; deliver message to oterm
pop ix ; ix = & FDSTRUCT.JP (input terminal)
ret
|
/* Copyright (c) 2016 PaddlePaddle 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 "paddle/fluid/operators/mul_op.h"
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>
#ifdef PADDLE_WITH_MKLDNN
#include "paddle/fluid/platform/mkldnn_helper.h"
#endif
namespace paddle {
namespace operators {
using framework::OpKernelType;
using framework::Tensor;
class MulOp : public framework::OperatorWithKernel {
public:
using framework::OperatorWithKernel::OperatorWithKernel;
void InferShape(framework::InferShapeContext* ctx) const override {
PADDLE_ENFORCE(ctx->HasInput("X"), "Input(X) of MulOp should not be null.");
PADDLE_ENFORCE(ctx->HasInput("Y"), "Input(Y) of MulOp should not be null.");
PADDLE_ENFORCE(ctx->HasOutput("Out"),
"Output(Out) of MulOp should not be null.");
auto x_dims = ctx->GetInputDim("X");
auto y_dims = ctx->GetInputDim("Y");
int x_num_col_dims = ctx->Attrs().Get<int>("x_num_col_dims");
int y_num_col_dims = ctx->Attrs().Get<int>("y_num_col_dims");
VLOG(3) << "mul operator x.shape=" << x_dims << " y.shape=" << y_dims
<< " x_num_col_dims=" << x_num_col_dims
<< " y_num_col_dims=" << y_num_col_dims;
PADDLE_ENFORCE_GT(
x_dims.size(), x_num_col_dims,
"The input tensor X's rank of MulOp should be larger than "
"x_num_col_dims.");
PADDLE_ENFORCE_GT(
y_dims.size(), y_num_col_dims,
"The input tensor Y's rank of MulOp should be larger than "
"y_num_col_dims: %ld vs %ld",
y_dims.size(), y_num_col_dims);
auto x_mat_dims = framework::flatten_to_2d(x_dims, x_num_col_dims);
auto y_mat_dims = framework::flatten_to_2d(y_dims, y_num_col_dims);
PADDLE_ENFORCE_EQ(x_mat_dims[1], y_mat_dims[0],
"First matrix's width must be equal with second matrix's "
"height. %s, %s",
x_mat_dims[1], y_mat_dims[0]);
std::vector<int64_t> output_dims;
output_dims.reserve(
static_cast<size_t>(x_num_col_dims + y_dims.size() - y_num_col_dims));
for (int i = 0; i < x_num_col_dims; ++i) {
output_dims.push_back(x_dims[i]);
}
for (int i = y_num_col_dims; i < y_dims.size(); ++i) {
output_dims.push_back(y_dims[i]);
}
ctx->SetOutputDim("Out", framework::make_ddim(output_dims));
ctx->ShareLoD("X", /*->*/ "Out");
}
framework::OpKernelType GetExpectedKernelType(
const framework::ExecutionContext& ctx) const {
framework::LibraryType library = framework::LibraryType::kPlain;
framework::DataLayout layout = framework::DataLayout::kAnyLayout;
int customized_type_value =
framework::OpKernelType::kDefaultCustomizedTypeValue;
auto input_data_type = ctx.Input<Tensor>("X")->type();
#ifdef PADDLE_WITH_MKLDNN
if (library == framework::LibraryType::kPlain &&
platform::CanMKLDNNBeUsed(ctx)) {
library = framework::LibraryType::kMKLDNN;
layout = framework::DataLayout::kMKLDNN;
if (input_data_type == framework::DataTypeTrait<int8_t>::DataType() ||
input_data_type == framework::DataTypeTrait<uint8_t>::DataType()) {
customized_type_value = kMULMKLDNNINT8;
}
}
#endif
return framework::OpKernelType(input_data_type, ctx.GetPlace(), layout,
library, customized_type_value);
}
};
class MulOpMaker : public framework::OpProtoAndCheckerMaker {
public:
void Make() override {
AddInput("X", "(Tensor), The first input tensor of mul op.");
AddInput("Y", "(Tensor), The second input tensor of mul op.");
AddOutput("Out", "(Tensor), The output tensor of mul op.");
AddAttr<bool>("use_mkldnn",
"(bool, default false) Only used in mkldnn kernel")
.SetDefault(false);
AddAttr<int>(
"x_num_col_dims",
R"DOC((int, default 1), The mul_op can take tensors with more than two
dimensions as its inputs. If the input $X$ is a tensor with more
than two dimensions, $X$ will be flattened into a two-dimensional
matrix first. The flattening rule is: the first `num_col_dims`
will be flattened to form the first dimension of the final matrix
(the height of the matrix), and the rest `rank(X) - num_col_dims`
dimensions are flattened to form the second dimension of the final
matrix (the width of the matrix). As a result, height of the
flattened matrix is equal to the product of $X$'s first
`x_num_col_dims` dimensions' sizes, and width of the flattened
matrix is equal to the product of $X$'s last `rank(x) - num_col_dims`
dimensions' size. For example, suppose $X$ is a 6-dimensional
tensor with the shape [2, 3, 4, 5, 6], and `x_num_col_dims` = 3.
Thus, the flattened matrix will have a shape [2 x 3 x 4, 5 x 6] =
[24, 30].
)DOC")
.SetDefault(1)
.EqualGreaterThan(1);
AddAttr<int>(
"y_num_col_dims",
R"DOC((int, default 1), The mul_op can take tensors with more than two,
dimensions as its inputs. If the input $Y$ is a tensor with more
than two dimensions, $Y$ will be flattened into a two-dimensional
matrix first. The attribute `y_num_col_dims` determines how $Y$ is
flattened. See comments of `x_num_col_dims` for more details.
)DOC")
.SetDefault(1)
.EqualGreaterThan(1);
AddAttr<float>(
"scale_x",
"scale_x to be used for int8 mul input data x. scale_x has the"
"same purpose as scale_in in OPs that support quantization."
"Only to be used with MKL-DNN INT8")
.SetDefault(1.0f);
AddAttr<std::vector<float>>(
"scale_y",
"scale_y to be used for int8 mul input data y. scale_y has the"
"same purpose as scale_weights in OPs that support quantization."
"Only to be used with MKL-DNN INT8")
.SetDefault({1.0f});
AddAttr<float>("scale_out",
"scale_out to be used for int8 output data."
"Only used with MKL-DNN INT8")
.SetDefault(1.0f);
AddAttr<bool>(
"force_fp32_output",
"(bool, default false) Force quantize kernel output FP32, only "
"used in quantized MKL-DNN.")
.SetDefault(false);
AddComment(R"DOC(
Mul Operator.
This operator is used to perform matrix multiplication for input $X$ and $Y$.
The equation is:
$$Out = X * Y$$
Both the input $X$ and $Y$ can carry the LoD (Level of Details) information,
or not. But the output only shares the LoD information with input $X$.
)DOC");
}
};
class MulOpInferVarType : public framework::PassInDtypeAndVarTypeToOutput {
protected:
std::unordered_map<std::string, std::string> GetInputOutputWithSameType()
const override {
return std::unordered_map<std::string, std::string>{{"X", /*->*/ "Out"}};
}
};
class MulGradOp : public framework::OperatorWithKernel {
public:
using framework::OperatorWithKernel::OperatorWithKernel;
void InferShape(framework::InferShapeContext* ctx) const override {
PADDLE_ENFORCE(ctx->HasInput("X"), "Input(X) should not be null");
PADDLE_ENFORCE(ctx->HasInput("Y"), "Input(Y) should not be null");
PADDLE_ENFORCE(ctx->HasInput(framework::GradVarName("Out")),
"Input(Out@GRAD) should not be null");
auto x_dims = ctx->GetInputDim("X");
auto y_dims = ctx->GetInputDim("Y");
auto x_grad_name = framework::GradVarName("X");
auto y_grad_name = framework::GradVarName("Y");
if (ctx->HasOutput(x_grad_name)) {
ctx->SetOutputDim(x_grad_name, x_dims);
}
if (ctx->HasOutput(y_grad_name)) {
ctx->SetOutputDim(y_grad_name, y_dims);
}
}
};
class MulOpGradMaker : public framework::SingleGradOpDescMaker {
public:
using framework::SingleGradOpDescMaker::SingleGradOpDescMaker;
protected:
std::unique_ptr<framework::OpDesc> Apply() const override {
std::unique_ptr<framework::OpDesc> retv(new framework::OpDesc());
retv->SetType("mul_grad");
retv->SetInput("X", Input("X"));
retv->SetInput("Y", Input("Y"));
retv->SetInput(framework::GradVarName("Out"), OutputGrad("Out"));
retv->SetOutput(framework::GradVarName("X"), InputGrad("X"));
retv->SetOutput(framework::GradVarName("Y"), InputGrad("Y"));
retv->SetAttrMap(Attrs());
return retv;
}
};
class MulDoubleGradOp : public framework::OperatorWithKernel {
public:
using framework::OperatorWithKernel::OperatorWithKernel;
void InferShape(framework::InferShapeContext* ctx) const override {
PADDLE_ENFORCE(ctx->HasInput("X"), "Input(X) should not be null");
PADDLE_ENFORCE(ctx->HasInput("Y"), "Input(Y) should not be null");
PADDLE_ENFORCE(ctx->HasInput("DOut"), "Input(DOut) should not be null");
if (ctx->HasOutput("DDOut") && ctx->HasInput("DDX")) {
ctx->ShareDim("DOut", "DDOut");
}
if (ctx->HasOutput("DX") && ctx->HasInput("DDY")) {
ctx->ShareDim("X", "DX");
}
if (ctx->HasOutput("DY") && ctx->HasInput("DDX")) {
ctx->ShareDim("Y", "DY");
}
}
};
class MulDoubleGradMaker : public framework::SingleGradOpDescMaker {
public:
using framework::SingleGradOpDescMaker::SingleGradOpDescMaker;
protected:
std::unique_ptr<framework::OpDesc> Apply() const override {
std::unique_ptr<framework::OpDesc> retv(new framework::OpDesc());
retv->SetType("mul_grad_grad");
retv->SetInput("X", Input("X"));
retv->SetInput("Y", Input("Y"));
retv->SetInput("DOut", Input(framework::GradVarName("Out")));
retv->SetInput("DDX", OutputGrad(framework::GradVarName("X")));
retv->SetInput("DDY", OutputGrad(framework::GradVarName("Y")));
auto ddx = OutputGrad(framework::GradVarName("X"));
auto ddw = OutputGrad(framework::GradVarName("Y"));
std::vector<std::string> empty_str = {};
retv->SetOutput("DDOut", (ddx.empty())
? empty_str
: InputGrad(framework::GradVarName("Out")));
retv->SetOutput("DX", ddw.empty() ? empty_str : InputGrad("X"));
retv->SetOutput("DY", ddx.empty() ? empty_str : InputGrad("Y"));
retv->SetAttrMap(Attrs());
return retv;
}
};
} // namespace operators
} // namespace paddle
namespace ops = paddle::operators;
REGISTER_OPERATOR(mul, ops::MulOp, ops::MulOpMaker, ops::MulOpInferVarType,
ops::MulOpGradMaker);
REGISTER_OPERATOR(mul_grad, ops::MulGradOp, ops::MulDoubleGradMaker);
REGISTER_OPERATOR(mul_grad_grad, ops::MulDoubleGradOp);
REGISTER_OP_CPU_KERNEL(
mul, ops::MulKernel<paddle::platform::CPUDeviceContext, float>,
ops::MulKernel<paddle::platform::CPUDeviceContext, double>);
REGISTER_OP_CPU_KERNEL(
mul_grad, ops::MulGradKernel<paddle::platform::CPUDeviceContext, float>,
ops::MulGradKernel<paddle::platform::CPUDeviceContext, double>);
REGISTER_OP_CPU_KERNEL(
mul_grad_grad,
ops::MulDoubleGradKernel<paddle::platform::CPUDeviceContext, float>,
ops::MulDoubleGradKernel<paddle::platform::CPUDeviceContext, double>);
|
_ln: 檔案格式 elf32-i386
Disassembly of section .text:
00000000 <main>:
#include "stat.h"
#include "user.h"
int
main(int argc, char *argv[])
{
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
if(argc != 3){
7: 83 39 03 cmpl $0x3,(%ecx)
#include "stat.h"
#include "user.h"
int
main(int argc, char *argv[])
{
a: ff 71 fc pushl -0x4(%ecx)
d: 55 push %ebp
e: 89 e5 mov %esp,%ebp
10: 53 push %ebx
11: 51 push %ecx
12: 8b 59 04 mov 0x4(%ecx),%ebx
if(argc != 3){
15: 74 14 je 2b <main+0x2b>
printf(2, "Usage: ln old new\n");
17: 83 ec 08 sub $0x8,%esp
1a: 68 20 07 00 00 push $0x720
1f: 6a 02 push $0x2
21: e8 da 03 00 00 call 400 <printf>
exit();
26: e8 77 02 00 00 call 2a2 <exit>
}
if(link(argv[1], argv[2]) < 0)
2b: 50 push %eax
2c: 50 push %eax
2d: ff 73 08 pushl 0x8(%ebx)
30: ff 73 04 pushl 0x4(%ebx)
33: e8 ca 02 00 00 call 302 <link>
38: 83 c4 10 add $0x10,%esp
3b: 85 c0 test %eax,%eax
3d: 78 05 js 44 <main+0x44>
printf(2, "link %s %s: failed\n", argv[1], argv[2]);
exit();
3f: e8 5e 02 00 00 call 2a2 <exit>
if(argc != 3){
printf(2, "Usage: ln old new\n");
exit();
}
if(link(argv[1], argv[2]) < 0)
printf(2, "link %s %s: failed\n", argv[1], argv[2]);
44: ff 73 08 pushl 0x8(%ebx)
47: ff 73 04 pushl 0x4(%ebx)
4a: 68 33 07 00 00 push $0x733
4f: 6a 02 push $0x2
51: e8 aa 03 00 00 call 400 <printf>
56: 83 c4 10 add $0x10,%esp
59: eb e4 jmp 3f <main+0x3f>
5b: 66 90 xchg %ax,%ax
5d: 66 90 xchg %ax,%ax
5f: 90 nop
00000060 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
60: 55 push %ebp
61: 89 e5 mov %esp,%ebp
63: 53 push %ebx
64: 8b 45 08 mov 0x8(%ebp),%eax
67: 8b 4d 0c mov 0xc(%ebp),%ecx
char *os;
os = s;
while((*s++ = *t++) != 0)
6a: 89 c2 mov %eax,%edx
6c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
70: 83 c1 01 add $0x1,%ecx
73: 0f b6 59 ff movzbl -0x1(%ecx),%ebx
77: 83 c2 01 add $0x1,%edx
7a: 84 db test %bl,%bl
7c: 88 5a ff mov %bl,-0x1(%edx)
7f: 75 ef jne 70 <strcpy+0x10>
;
return os;
}
81: 5b pop %ebx
82: 5d pop %ebp
83: c3 ret
84: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
8a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000090 <strcmp>:
int
strcmp(const char *p, const char *q)
{
90: 55 push %ebp
91: 89 e5 mov %esp,%ebp
93: 56 push %esi
94: 53 push %ebx
95: 8b 55 08 mov 0x8(%ebp),%edx
98: 8b 4d 0c mov 0xc(%ebp),%ecx
while(*p && *p == *q)
9b: 0f b6 02 movzbl (%edx),%eax
9e: 0f b6 19 movzbl (%ecx),%ebx
a1: 84 c0 test %al,%al
a3: 75 1e jne c3 <strcmp+0x33>
a5: eb 29 jmp d0 <strcmp+0x40>
a7: 89 f6 mov %esi,%esi
a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
p++, q++;
b0: 83 c2 01 add $0x1,%edx
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
b3: 0f b6 02 movzbl (%edx),%eax
p++, q++;
b6: 8d 71 01 lea 0x1(%ecx),%esi
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
b9: 0f b6 59 01 movzbl 0x1(%ecx),%ebx
bd: 84 c0 test %al,%al
bf: 74 0f je d0 <strcmp+0x40>
c1: 89 f1 mov %esi,%ecx
c3: 38 d8 cmp %bl,%al
c5: 74 e9 je b0 <strcmp+0x20>
p++, q++;
return (uchar)*p - (uchar)*q;
c7: 29 d8 sub %ebx,%eax
}
c9: 5b pop %ebx
ca: 5e pop %esi
cb: 5d pop %ebp
cc: c3 ret
cd: 8d 76 00 lea 0x0(%esi),%esi
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
d0: 31 c0 xor %eax,%eax
p++, q++;
return (uchar)*p - (uchar)*q;
d2: 29 d8 sub %ebx,%eax
}
d4: 5b pop %ebx
d5: 5e pop %esi
d6: 5d pop %ebp
d7: c3 ret
d8: 90 nop
d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
000000e0 <strlen>:
uint
strlen(char *s)
{
e0: 55 push %ebp
e1: 89 e5 mov %esp,%ebp
e3: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
e6: 80 39 00 cmpb $0x0,(%ecx)
e9: 74 12 je fd <strlen+0x1d>
eb: 31 d2 xor %edx,%edx
ed: 8d 76 00 lea 0x0(%esi),%esi
f0: 83 c2 01 add $0x1,%edx
f3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
f7: 89 d0 mov %edx,%eax
f9: 75 f5 jne f0 <strlen+0x10>
;
return n;
}
fb: 5d pop %ebp
fc: c3 ret
uint
strlen(char *s)
{
int n;
for(n = 0; s[n]; n++)
fd: 31 c0 xor %eax,%eax
;
return n;
}
ff: 5d pop %ebp
100: c3 ret
101: eb 0d jmp 110 <memset>
103: 90 nop
104: 90 nop
105: 90 nop
106: 90 nop
107: 90 nop
108: 90 nop
109: 90 nop
10a: 90 nop
10b: 90 nop
10c: 90 nop
10d: 90 nop
10e: 90 nop
10f: 90 nop
00000110 <memset>:
void*
memset(void *dst, int c, uint n)
{
110: 55 push %ebp
111: 89 e5 mov %esp,%ebp
113: 57 push %edi
114: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
117: 8b 4d 10 mov 0x10(%ebp),%ecx
11a: 8b 45 0c mov 0xc(%ebp),%eax
11d: 89 d7 mov %edx,%edi
11f: fc cld
120: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
122: 89 d0 mov %edx,%eax
124: 5f pop %edi
125: 5d pop %ebp
126: c3 ret
127: 89 f6 mov %esi,%esi
129: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000130 <strchr>:
char*
strchr(const char *s, char c)
{
130: 55 push %ebp
131: 89 e5 mov %esp,%ebp
133: 53 push %ebx
134: 8b 45 08 mov 0x8(%ebp),%eax
137: 8b 5d 0c mov 0xc(%ebp),%ebx
for(; *s; s++)
13a: 0f b6 10 movzbl (%eax),%edx
13d: 84 d2 test %dl,%dl
13f: 74 1d je 15e <strchr+0x2e>
if(*s == c)
141: 38 d3 cmp %dl,%bl
143: 89 d9 mov %ebx,%ecx
145: 75 0d jne 154 <strchr+0x24>
147: eb 17 jmp 160 <strchr+0x30>
149: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
150: 38 ca cmp %cl,%dl
152: 74 0c je 160 <strchr+0x30>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
154: 83 c0 01 add $0x1,%eax
157: 0f b6 10 movzbl (%eax),%edx
15a: 84 d2 test %dl,%dl
15c: 75 f2 jne 150 <strchr+0x20>
if(*s == c)
return (char*)s;
return 0;
15e: 31 c0 xor %eax,%eax
}
160: 5b pop %ebx
161: 5d pop %ebp
162: c3 ret
163: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
169: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000170 <gets>:
char*
gets(char *buf, int max)
{
170: 55 push %ebp
171: 89 e5 mov %esp,%ebp
173: 57 push %edi
174: 56 push %esi
175: 53 push %ebx
int i, cc;
char c;
for(i=0; i+1 < max; ){
176: 31 f6 xor %esi,%esi
cc = read(0, &c, 1);
178: 8d 7d e7 lea -0x19(%ebp),%edi
return 0;
}
char*
gets(char *buf, int max)
{
17b: 83 ec 1c sub $0x1c,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
17e: eb 29 jmp 1a9 <gets+0x39>
cc = read(0, &c, 1);
180: 83 ec 04 sub $0x4,%esp
183: 6a 01 push $0x1
185: 57 push %edi
186: 6a 00 push $0x0
188: e8 2d 01 00 00 call 2ba <read>
if(cc < 1)
18d: 83 c4 10 add $0x10,%esp
190: 85 c0 test %eax,%eax
192: 7e 1d jle 1b1 <gets+0x41>
break;
buf[i++] = c;
194: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
198: 8b 55 08 mov 0x8(%ebp),%edx
19b: 89 de mov %ebx,%esi
if(c == '\n' || c == '\r')
19d: 3c 0a cmp $0xa,%al
for(i=0; i+1 < max; ){
cc = read(0, &c, 1);
if(cc < 1)
break;
buf[i++] = c;
19f: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1)
if(c == '\n' || c == '\r')
1a3: 74 1b je 1c0 <gets+0x50>
1a5: 3c 0d cmp $0xd,%al
1a7: 74 17 je 1c0 <gets+0x50>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
1a9: 8d 5e 01 lea 0x1(%esi),%ebx
1ac: 3b 5d 0c cmp 0xc(%ebp),%ebx
1af: 7c cf jl 180 <gets+0x10>
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
1b1: 8b 45 08 mov 0x8(%ebp),%eax
1b4: c6 04 30 00 movb $0x0,(%eax,%esi,1)
return buf;
}
1b8: 8d 65 f4 lea -0xc(%ebp),%esp
1bb: 5b pop %ebx
1bc: 5e pop %esi
1bd: 5f pop %edi
1be: 5d pop %ebp
1bf: c3 ret
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
1c0: 8b 45 08 mov 0x8(%ebp),%eax
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
1c3: 89 de mov %ebx,%esi
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
1c5: c6 04 30 00 movb $0x0,(%eax,%esi,1)
return buf;
}
1c9: 8d 65 f4 lea -0xc(%ebp),%esp
1cc: 5b pop %ebx
1cd: 5e pop %esi
1ce: 5f pop %edi
1cf: 5d pop %ebp
1d0: c3 ret
1d1: eb 0d jmp 1e0 <stat>
1d3: 90 nop
1d4: 90 nop
1d5: 90 nop
1d6: 90 nop
1d7: 90 nop
1d8: 90 nop
1d9: 90 nop
1da: 90 nop
1db: 90 nop
1dc: 90 nop
1dd: 90 nop
1de: 90 nop
1df: 90 nop
000001e0 <stat>:
int
stat(char *n, struct stat *st)
{
1e0: 55 push %ebp
1e1: 89 e5 mov %esp,%ebp
1e3: 56 push %esi
1e4: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
1e5: 83 ec 08 sub $0x8,%esp
1e8: 6a 00 push $0x0
1ea: ff 75 08 pushl 0x8(%ebp)
1ed: e8 f0 00 00 00 call 2e2 <open>
if(fd < 0)
1f2: 83 c4 10 add $0x10,%esp
1f5: 85 c0 test %eax,%eax
1f7: 78 27 js 220 <stat+0x40>
return -1;
r = fstat(fd, st);
1f9: 83 ec 08 sub $0x8,%esp
1fc: ff 75 0c pushl 0xc(%ebp)
1ff: 89 c3 mov %eax,%ebx
201: 50 push %eax
202: e8 f3 00 00 00 call 2fa <fstat>
207: 89 c6 mov %eax,%esi
close(fd);
209: 89 1c 24 mov %ebx,(%esp)
20c: e8 b9 00 00 00 call 2ca <close>
return r;
211: 83 c4 10 add $0x10,%esp
214: 89 f0 mov %esi,%eax
}
216: 8d 65 f8 lea -0x8(%ebp),%esp
219: 5b pop %ebx
21a: 5e pop %esi
21b: 5d pop %ebp
21c: c3 ret
21d: 8d 76 00 lea 0x0(%esi),%esi
int fd;
int r;
fd = open(n, O_RDONLY);
if(fd < 0)
return -1;
220: b8 ff ff ff ff mov $0xffffffff,%eax
225: eb ef jmp 216 <stat+0x36>
227: 89 f6 mov %esi,%esi
229: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000230 <atoi>:
return r;
}
int
atoi(const char *s)
{
230: 55 push %ebp
231: 89 e5 mov %esp,%ebp
233: 53 push %ebx
234: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
n = 0;
while('0' <= *s && *s <= '9')
237: 0f be 11 movsbl (%ecx),%edx
23a: 8d 42 d0 lea -0x30(%edx),%eax
23d: 3c 09 cmp $0x9,%al
23f: b8 00 00 00 00 mov $0x0,%eax
244: 77 1f ja 265 <atoi+0x35>
246: 8d 76 00 lea 0x0(%esi),%esi
249: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
n = n*10 + *s++ - '0';
250: 8d 04 80 lea (%eax,%eax,4),%eax
253: 83 c1 01 add $0x1,%ecx
256: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
25a: 0f be 11 movsbl (%ecx),%edx
25d: 8d 5a d0 lea -0x30(%edx),%ebx
260: 80 fb 09 cmp $0x9,%bl
263: 76 eb jbe 250 <atoi+0x20>
n = n*10 + *s++ - '0';
return n;
}
265: 5b pop %ebx
266: 5d pop %ebp
267: c3 ret
268: 90 nop
269: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000270 <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
270: 55 push %ebp
271: 89 e5 mov %esp,%ebp
273: 56 push %esi
274: 53 push %ebx
275: 8b 5d 10 mov 0x10(%ebp),%ebx
278: 8b 45 08 mov 0x8(%ebp),%eax
27b: 8b 75 0c mov 0xc(%ebp),%esi
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
27e: 85 db test %ebx,%ebx
280: 7e 14 jle 296 <memmove+0x26>
282: 31 d2 xor %edx,%edx
284: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
*dst++ = *src++;
288: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx
28c: 88 0c 10 mov %cl,(%eax,%edx,1)
28f: 83 c2 01 add $0x1,%edx
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
292: 39 da cmp %ebx,%edx
294: 75 f2 jne 288 <memmove+0x18>
*dst++ = *src++;
return vdst;
}
296: 5b pop %ebx
297: 5e pop %esi
298: 5d pop %ebp
299: c3 ret
0000029a <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
29a: b8 01 00 00 00 mov $0x1,%eax
29f: cd 40 int $0x40
2a1: c3 ret
000002a2 <exit>:
SYSCALL(exit)
2a2: b8 02 00 00 00 mov $0x2,%eax
2a7: cd 40 int $0x40
2a9: c3 ret
000002aa <wait>:
SYSCALL(wait)
2aa: b8 03 00 00 00 mov $0x3,%eax
2af: cd 40 int $0x40
2b1: c3 ret
000002b2 <pipe>:
SYSCALL(pipe)
2b2: b8 04 00 00 00 mov $0x4,%eax
2b7: cd 40 int $0x40
2b9: c3 ret
000002ba <read>:
SYSCALL(read)
2ba: b8 05 00 00 00 mov $0x5,%eax
2bf: cd 40 int $0x40
2c1: c3 ret
000002c2 <write>:
SYSCALL(write)
2c2: b8 10 00 00 00 mov $0x10,%eax
2c7: cd 40 int $0x40
2c9: c3 ret
000002ca <close>:
SYSCALL(close)
2ca: b8 15 00 00 00 mov $0x15,%eax
2cf: cd 40 int $0x40
2d1: c3 ret
000002d2 <kill>:
SYSCALL(kill)
2d2: b8 06 00 00 00 mov $0x6,%eax
2d7: cd 40 int $0x40
2d9: c3 ret
000002da <exec>:
SYSCALL(exec)
2da: b8 07 00 00 00 mov $0x7,%eax
2df: cd 40 int $0x40
2e1: c3 ret
000002e2 <open>:
SYSCALL(open)
2e2: b8 0f 00 00 00 mov $0xf,%eax
2e7: cd 40 int $0x40
2e9: c3 ret
000002ea <mknod>:
SYSCALL(mknod)
2ea: b8 11 00 00 00 mov $0x11,%eax
2ef: cd 40 int $0x40
2f1: c3 ret
000002f2 <unlink>:
SYSCALL(unlink)
2f2: b8 12 00 00 00 mov $0x12,%eax
2f7: cd 40 int $0x40
2f9: c3 ret
000002fa <fstat>:
SYSCALL(fstat)
2fa: b8 08 00 00 00 mov $0x8,%eax
2ff: cd 40 int $0x40
301: c3 ret
00000302 <link>:
SYSCALL(link)
302: b8 13 00 00 00 mov $0x13,%eax
307: cd 40 int $0x40
309: c3 ret
0000030a <mkdir>:
SYSCALL(mkdir)
30a: b8 14 00 00 00 mov $0x14,%eax
30f: cd 40 int $0x40
311: c3 ret
00000312 <chdir>:
SYSCALL(chdir)
312: b8 09 00 00 00 mov $0x9,%eax
317: cd 40 int $0x40
319: c3 ret
0000031a <dup>:
SYSCALL(dup)
31a: b8 0a 00 00 00 mov $0xa,%eax
31f: cd 40 int $0x40
321: c3 ret
00000322 <getpid>:
SYSCALL(getpid)
322: b8 0b 00 00 00 mov $0xb,%eax
327: cd 40 int $0x40
329: c3 ret
0000032a <sbrk>:
SYSCALL(sbrk)
32a: b8 0c 00 00 00 mov $0xc,%eax
32f: cd 40 int $0x40
331: c3 ret
00000332 <sleep>:
SYSCALL(sleep)
332: b8 0d 00 00 00 mov $0xd,%eax
337: cd 40 int $0x40
339: c3 ret
0000033a <uptime>:
SYSCALL(uptime)
33a: b8 0e 00 00 00 mov $0xe,%eax
33f: cd 40 int $0x40
341: c3 ret
00000342 <cps>:
SYSCALL(cps)
342: b8 16 00 00 00 mov $0x16,%eax
347: cd 40 int $0x40
349: c3 ret
0000034a <chpr>:
SYSCALL(chpr)
34a: b8 17 00 00 00 mov $0x17,%eax
34f: cd 40 int $0x40
351: c3 ret
352: 66 90 xchg %ax,%ax
354: 66 90 xchg %ax,%ax
356: 66 90 xchg %ax,%ax
358: 66 90 xchg %ax,%ax
35a: 66 90 xchg %ax,%ax
35c: 66 90 xchg %ax,%ax
35e: 66 90 xchg %ax,%ax
00000360 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
360: 55 push %ebp
361: 89 e5 mov %esp,%ebp
363: 57 push %edi
364: 56 push %esi
365: 53 push %ebx
366: 89 c6 mov %eax,%esi
368: 83 ec 3c sub $0x3c,%esp
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
36b: 8b 5d 08 mov 0x8(%ebp),%ebx
36e: 85 db test %ebx,%ebx
370: 74 7e je 3f0 <printint+0x90>
372: 89 d0 mov %edx,%eax
374: c1 e8 1f shr $0x1f,%eax
377: 84 c0 test %al,%al
379: 74 75 je 3f0 <printint+0x90>
neg = 1;
x = -xx;
37b: 89 d0 mov %edx,%eax
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
neg = 1;
37d: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp)
x = -xx;
384: f7 d8 neg %eax
386: 89 75 c0 mov %esi,-0x40(%ebp)
} else {
x = xx;
}
i = 0;
389: 31 ff xor %edi,%edi
38b: 8d 5d d7 lea -0x29(%ebp),%ebx
38e: 89 ce mov %ecx,%esi
390: eb 08 jmp 39a <printint+0x3a>
392: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
do{
buf[i++] = digits[x % base];
398: 89 cf mov %ecx,%edi
39a: 31 d2 xor %edx,%edx
39c: 8d 4f 01 lea 0x1(%edi),%ecx
39f: f7 f6 div %esi
3a1: 0f b6 92 50 07 00 00 movzbl 0x750(%edx),%edx
}while((x /= base) != 0);
3a8: 85 c0 test %eax,%eax
x = xx;
}
i = 0;
do{
buf[i++] = digits[x % base];
3aa: 88 14 0b mov %dl,(%ebx,%ecx,1)
}while((x /= base) != 0);
3ad: 75 e9 jne 398 <printint+0x38>
if(neg)
3af: 8b 45 c4 mov -0x3c(%ebp),%eax
3b2: 8b 75 c0 mov -0x40(%ebp),%esi
3b5: 85 c0 test %eax,%eax
3b7: 74 08 je 3c1 <printint+0x61>
buf[i++] = '-';
3b9: c6 44 0d d8 2d movb $0x2d,-0x28(%ebp,%ecx,1)
3be: 8d 4f 02 lea 0x2(%edi),%ecx
3c1: 8d 7c 0d d7 lea -0x29(%ebp,%ecx,1),%edi
3c5: 8d 76 00 lea 0x0(%esi),%esi
3c8: 0f b6 07 movzbl (%edi),%eax
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
3cb: 83 ec 04 sub $0x4,%esp
3ce: 83 ef 01 sub $0x1,%edi
3d1: 6a 01 push $0x1
3d3: 53 push %ebx
3d4: 56 push %esi
3d5: 88 45 d7 mov %al,-0x29(%ebp)
3d8: e8 e5 fe ff ff call 2c2 <write>
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
3dd: 83 c4 10 add $0x10,%esp
3e0: 39 df cmp %ebx,%edi
3e2: 75 e4 jne 3c8 <printint+0x68>
putc(fd, buf[i]);
}
3e4: 8d 65 f4 lea -0xc(%ebp),%esp
3e7: 5b pop %ebx
3e8: 5e pop %esi
3e9: 5f pop %edi
3ea: 5d pop %ebp
3eb: c3 ret
3ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
neg = 0;
if(sgn && xx < 0){
neg = 1;
x = -xx;
} else {
x = xx;
3f0: 89 d0 mov %edx,%eax
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
3f2: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp)
3f9: eb 8b jmp 386 <printint+0x26>
3fb: 90 nop
3fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00000400 <printf>:
}
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
400: 55 push %ebp
401: 89 e5 mov %esp,%ebp
403: 57 push %edi
404: 56 push %esi
405: 53 push %ebx
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
406: 8d 45 10 lea 0x10(%ebp),%eax
}
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
409: 83 ec 2c sub $0x2c,%esp
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
40c: 8b 75 0c mov 0xc(%ebp),%esi
}
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
40f: 8b 7d 08 mov 0x8(%ebp),%edi
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
412: 89 45 d0 mov %eax,-0x30(%ebp)
415: 0f b6 1e movzbl (%esi),%ebx
418: 83 c6 01 add $0x1,%esi
41b: 84 db test %bl,%bl
41d: 0f 84 b0 00 00 00 je 4d3 <printf+0xd3>
423: 31 d2 xor %edx,%edx
425: eb 39 jmp 460 <printf+0x60>
427: 89 f6 mov %esi,%esi
429: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
430: 83 f8 25 cmp $0x25,%eax
433: 89 55 d4 mov %edx,-0x2c(%ebp)
state = '%';
436: ba 25 00 00 00 mov $0x25,%edx
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
43b: 74 18 je 455 <printf+0x55>
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
43d: 8d 45 e2 lea -0x1e(%ebp),%eax
440: 83 ec 04 sub $0x4,%esp
443: 88 5d e2 mov %bl,-0x1e(%ebp)
446: 6a 01 push $0x1
448: 50 push %eax
449: 57 push %edi
44a: e8 73 fe ff ff call 2c2 <write>
44f: 8b 55 d4 mov -0x2c(%ebp),%edx
452: 83 c4 10 add $0x10,%esp
455: 83 c6 01 add $0x1,%esi
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
458: 0f b6 5e ff movzbl -0x1(%esi),%ebx
45c: 84 db test %bl,%bl
45e: 74 73 je 4d3 <printf+0xd3>
c = fmt[i] & 0xff;
if(state == 0){
460: 85 d2 test %edx,%edx
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
c = fmt[i] & 0xff;
462: 0f be cb movsbl %bl,%ecx
465: 0f b6 c3 movzbl %bl,%eax
if(state == 0){
468: 74 c6 je 430 <printf+0x30>
if(c == '%'){
state = '%';
} else {
putc(fd, c);
}
} else if(state == '%'){
46a: 83 fa 25 cmp $0x25,%edx
46d: 75 e6 jne 455 <printf+0x55>
if(c == 'd'){
46f: 83 f8 64 cmp $0x64,%eax
472: 0f 84 f8 00 00 00 je 570 <printf+0x170>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
478: 81 e1 f7 00 00 00 and $0xf7,%ecx
47e: 83 f9 70 cmp $0x70,%ecx
481: 74 5d je 4e0 <printf+0xe0>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
483: 83 f8 73 cmp $0x73,%eax
486: 0f 84 84 00 00 00 je 510 <printf+0x110>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
48c: 83 f8 63 cmp $0x63,%eax
48f: 0f 84 ea 00 00 00 je 57f <printf+0x17f>
putc(fd, *ap);
ap++;
} else if(c == '%'){
495: 83 f8 25 cmp $0x25,%eax
498: 0f 84 c2 00 00 00 je 560 <printf+0x160>
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
49e: 8d 45 e7 lea -0x19(%ebp),%eax
4a1: 83 ec 04 sub $0x4,%esp
4a4: c6 45 e7 25 movb $0x25,-0x19(%ebp)
4a8: 6a 01 push $0x1
4aa: 50 push %eax
4ab: 57 push %edi
4ac: e8 11 fe ff ff call 2c2 <write>
4b1: 83 c4 0c add $0xc,%esp
4b4: 8d 45 e6 lea -0x1a(%ebp),%eax
4b7: 88 5d e6 mov %bl,-0x1a(%ebp)
4ba: 6a 01 push $0x1
4bc: 50 push %eax
4bd: 57 push %edi
4be: 83 c6 01 add $0x1,%esi
4c1: e8 fc fd ff ff call 2c2 <write>
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
4c6: 0f b6 5e ff movzbl -0x1(%esi),%ebx
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
4ca: 83 c4 10 add $0x10,%esp
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
4cd: 31 d2 xor %edx,%edx
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
4cf: 84 db test %bl,%bl
4d1: 75 8d jne 460 <printf+0x60>
putc(fd, c);
}
state = 0;
}
}
}
4d3: 8d 65 f4 lea -0xc(%ebp),%esp
4d6: 5b pop %ebx
4d7: 5e pop %esi
4d8: 5f pop %edi
4d9: 5d pop %ebp
4da: c3 ret
4db: 90 nop
4dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
} else if(state == '%'){
if(c == 'd'){
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
printint(fd, *ap, 16, 0);
4e0: 83 ec 0c sub $0xc,%esp
4e3: b9 10 00 00 00 mov $0x10,%ecx
4e8: 6a 00 push $0x0
4ea: 8b 5d d0 mov -0x30(%ebp),%ebx
4ed: 89 f8 mov %edi,%eax
4ef: 8b 13 mov (%ebx),%edx
4f1: e8 6a fe ff ff call 360 <printint>
ap++;
4f6: 89 d8 mov %ebx,%eax
4f8: 83 c4 10 add $0x10,%esp
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
4fb: 31 d2 xor %edx,%edx
if(c == 'd'){
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
printint(fd, *ap, 16, 0);
ap++;
4fd: 83 c0 04 add $0x4,%eax
500: 89 45 d0 mov %eax,-0x30(%ebp)
503: e9 4d ff ff ff jmp 455 <printf+0x55>
508: 90 nop
509: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
} else if(c == 's'){
s = (char*)*ap;
510: 8b 45 d0 mov -0x30(%ebp),%eax
513: 8b 18 mov (%eax),%ebx
ap++;
515: 83 c0 04 add $0x4,%eax
518: 89 45 d0 mov %eax,-0x30(%ebp)
if(s == 0)
s = "(null)";
51b: b8 47 07 00 00 mov $0x747,%eax
520: 85 db test %ebx,%ebx
522: 0f 44 d8 cmove %eax,%ebx
while(*s != 0){
525: 0f b6 03 movzbl (%ebx),%eax
528: 84 c0 test %al,%al
52a: 74 23 je 54f <printf+0x14f>
52c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
530: 88 45 e3 mov %al,-0x1d(%ebp)
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
533: 8d 45 e3 lea -0x1d(%ebp),%eax
536: 83 ec 04 sub $0x4,%esp
539: 6a 01 push $0x1
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
53b: 83 c3 01 add $0x1,%ebx
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
53e: 50 push %eax
53f: 57 push %edi
540: e8 7d fd ff ff call 2c2 <write>
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
545: 0f b6 03 movzbl (%ebx),%eax
548: 83 c4 10 add $0x10,%esp
54b: 84 c0 test %al,%al
54d: 75 e1 jne 530 <printf+0x130>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
54f: 31 d2 xor %edx,%edx
551: e9 ff fe ff ff jmp 455 <printf+0x55>
556: 8d 76 00 lea 0x0(%esi),%esi
559: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
560: 83 ec 04 sub $0x4,%esp
563: 88 5d e5 mov %bl,-0x1b(%ebp)
566: 8d 45 e5 lea -0x1b(%ebp),%eax
569: 6a 01 push $0x1
56b: e9 4c ff ff ff jmp 4bc <printf+0xbc>
} else {
putc(fd, c);
}
} else if(state == '%'){
if(c == 'd'){
printint(fd, *ap, 10, 1);
570: 83 ec 0c sub $0xc,%esp
573: b9 0a 00 00 00 mov $0xa,%ecx
578: 6a 01 push $0x1
57a: e9 6b ff ff ff jmp 4ea <printf+0xea>
57f: 8b 5d d0 mov -0x30(%ebp),%ebx
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
582: 83 ec 04 sub $0x4,%esp
585: 8b 03 mov (%ebx),%eax
587: 6a 01 push $0x1
589: 88 45 e4 mov %al,-0x1c(%ebp)
58c: 8d 45 e4 lea -0x1c(%ebp),%eax
58f: 50 push %eax
590: 57 push %edi
591: e8 2c fd ff ff call 2c2 <write>
596: e9 5b ff ff ff jmp 4f6 <printf+0xf6>
59b: 66 90 xchg %ax,%ax
59d: 66 90 xchg %ax,%ax
59f: 90 nop
000005a0 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
5a0: 55 push %ebp
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
5a1: a1 ec 09 00 00 mov 0x9ec,%eax
static Header base;
static Header *freep;
void
free(void *ap)
{
5a6: 89 e5 mov %esp,%ebp
5a8: 57 push %edi
5a9: 56 push %esi
5aa: 53 push %ebx
5ab: 8b 5d 08 mov 0x8(%ebp),%ebx
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
5ae: 8b 10 mov (%eax),%edx
void
free(void *ap)
{
Header *bp, *p;
bp = (Header*)ap - 1;
5b0: 8d 4b f8 lea -0x8(%ebx),%ecx
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
5b3: 39 c8 cmp %ecx,%eax
5b5: 73 19 jae 5d0 <free+0x30>
5b7: 89 f6 mov %esi,%esi
5b9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
5c0: 39 d1 cmp %edx,%ecx
5c2: 72 1c jb 5e0 <free+0x40>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
5c4: 39 d0 cmp %edx,%eax
5c6: 73 18 jae 5e0 <free+0x40>
static Header base;
static Header *freep;
void
free(void *ap)
{
5c8: 89 d0 mov %edx,%eax
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
5ca: 39 c8 cmp %ecx,%eax
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
5cc: 8b 10 mov (%eax),%edx
free(void *ap)
{
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
5ce: 72 f0 jb 5c0 <free+0x20>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
5d0: 39 d0 cmp %edx,%eax
5d2: 72 f4 jb 5c8 <free+0x28>
5d4: 39 d1 cmp %edx,%ecx
5d6: 73 f0 jae 5c8 <free+0x28>
5d8: 90 nop
5d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
break;
if(bp + bp->s.size == p->s.ptr){
5e0: 8b 73 fc mov -0x4(%ebx),%esi
5e3: 8d 3c f1 lea (%ecx,%esi,8),%edi
5e6: 39 d7 cmp %edx,%edi
5e8: 74 19 je 603 <free+0x63>
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
5ea: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
5ed: 8b 50 04 mov 0x4(%eax),%edx
5f0: 8d 34 d0 lea (%eax,%edx,8),%esi
5f3: 39 f1 cmp %esi,%ecx
5f5: 74 23 je 61a <free+0x7a>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
5f7: 89 08 mov %ecx,(%eax)
freep = p;
5f9: a3 ec 09 00 00 mov %eax,0x9ec
}
5fe: 5b pop %ebx
5ff: 5e pop %esi
600: 5f pop %edi
601: 5d pop %ebp
602: c3 ret
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
bp->s.size += p->s.ptr->s.size;
603: 03 72 04 add 0x4(%edx),%esi
606: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
609: 8b 10 mov (%eax),%edx
60b: 8b 12 mov (%edx),%edx
60d: 89 53 f8 mov %edx,-0x8(%ebx)
} else
bp->s.ptr = p->s.ptr;
if(p + p->s.size == bp){
610: 8b 50 04 mov 0x4(%eax),%edx
613: 8d 34 d0 lea (%eax,%edx,8),%esi
616: 39 f1 cmp %esi,%ecx
618: 75 dd jne 5f7 <free+0x57>
p->s.size += bp->s.size;
61a: 03 53 fc add -0x4(%ebx),%edx
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
freep = p;
61d: a3 ec 09 00 00 mov %eax,0x9ec
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
if(p + p->s.size == bp){
p->s.size += bp->s.size;
622: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
625: 8b 53 f8 mov -0x8(%ebx),%edx
628: 89 10 mov %edx,(%eax)
} else
p->s.ptr = bp;
freep = p;
}
62a: 5b pop %ebx
62b: 5e pop %esi
62c: 5f pop %edi
62d: 5d pop %ebp
62e: c3 ret
62f: 90 nop
00000630 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
630: 55 push %ebp
631: 89 e5 mov %esp,%ebp
633: 57 push %edi
634: 56 push %esi
635: 53 push %ebx
636: 83 ec 0c sub $0xc,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
639: 8b 45 08 mov 0x8(%ebp),%eax
if((prevp = freep) == 0){
63c: 8b 15 ec 09 00 00 mov 0x9ec,%edx
malloc(uint nbytes)
{
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
642: 8d 78 07 lea 0x7(%eax),%edi
645: c1 ef 03 shr $0x3,%edi
648: 83 c7 01 add $0x1,%edi
if((prevp = freep) == 0){
64b: 85 d2 test %edx,%edx
64d: 0f 84 a3 00 00 00 je 6f6 <malloc+0xc6>
653: 8b 02 mov (%edx),%eax
655: 8b 48 04 mov 0x4(%eax),%ecx
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
658: 39 cf cmp %ecx,%edi
65a: 76 74 jbe 6d0 <malloc+0xa0>
65c: 81 ff 00 10 00 00 cmp $0x1000,%edi
662: be 00 10 00 00 mov $0x1000,%esi
667: 8d 1c fd 00 00 00 00 lea 0x0(,%edi,8),%ebx
66e: 0f 43 f7 cmovae %edi,%esi
671: ba 00 80 00 00 mov $0x8000,%edx
676: 81 ff ff 0f 00 00 cmp $0xfff,%edi
67c: 0f 46 da cmovbe %edx,%ebx
67f: eb 10 jmp 691 <malloc+0x61>
681: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
688: 8b 02 mov (%edx),%eax
if(p->s.size >= nunits){
68a: 8b 48 04 mov 0x4(%eax),%ecx
68d: 39 cf cmp %ecx,%edi
68f: 76 3f jbe 6d0 <malloc+0xa0>
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
691: 39 05 ec 09 00 00 cmp %eax,0x9ec
697: 89 c2 mov %eax,%edx
699: 75 ed jne 688 <malloc+0x58>
char *p;
Header *hp;
if(nu < 4096)
nu = 4096;
p = sbrk(nu * sizeof(Header));
69b: 83 ec 0c sub $0xc,%esp
69e: 53 push %ebx
69f: e8 86 fc ff ff call 32a <sbrk>
if(p == (char*)-1)
6a4: 83 c4 10 add $0x10,%esp
6a7: 83 f8 ff cmp $0xffffffff,%eax
6aa: 74 1c je 6c8 <malloc+0x98>
return 0;
hp = (Header*)p;
hp->s.size = nu;
6ac: 89 70 04 mov %esi,0x4(%eax)
free((void*)(hp + 1));
6af: 83 ec 0c sub $0xc,%esp
6b2: 83 c0 08 add $0x8,%eax
6b5: 50 push %eax
6b6: e8 e5 fe ff ff call 5a0 <free>
return freep;
6bb: 8b 15 ec 09 00 00 mov 0x9ec,%edx
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
if((p = morecore(nunits)) == 0)
6c1: 83 c4 10 add $0x10,%esp
6c4: 85 d2 test %edx,%edx
6c6: 75 c0 jne 688 <malloc+0x58>
return 0;
6c8: 31 c0 xor %eax,%eax
6ca: eb 1c jmp 6e8 <malloc+0xb8>
6cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
if(p->s.size == nunits)
6d0: 39 cf cmp %ecx,%edi
6d2: 74 1c je 6f0 <malloc+0xc0>
prevp->s.ptr = p->s.ptr;
else {
p->s.size -= nunits;
6d4: 29 f9 sub %edi,%ecx
6d6: 89 48 04 mov %ecx,0x4(%eax)
p += p->s.size;
6d9: 8d 04 c8 lea (%eax,%ecx,8),%eax
p->s.size = nunits;
6dc: 89 78 04 mov %edi,0x4(%eax)
}
freep = prevp;
6df: 89 15 ec 09 00 00 mov %edx,0x9ec
return (void*)(p + 1);
6e5: 83 c0 08 add $0x8,%eax
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
}
6e8: 8d 65 f4 lea -0xc(%ebp),%esp
6eb: 5b pop %ebx
6ec: 5e pop %esi
6ed: 5f pop %edi
6ee: 5d pop %ebp
6ef: c3 ret
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
if(p->s.size == nunits)
prevp->s.ptr = p->s.ptr;
6f0: 8b 08 mov (%eax),%ecx
6f2: 89 0a mov %ecx,(%edx)
6f4: eb e9 jmp 6df <malloc+0xaf>
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
6f6: c7 05 ec 09 00 00 f0 movl $0x9f0,0x9ec
6fd: 09 00 00
700: c7 05 f0 09 00 00 f0 movl $0x9f0,0x9f0
707: 09 00 00
base.s.size = 0;
70a: b8 f0 09 00 00 mov $0x9f0,%eax
70f: c7 05 f4 09 00 00 00 movl $0x0,0x9f4
716: 00 00 00
719: e9 3e ff ff ff jmp 65c <malloc+0x2c>
|
; This program shows how an unconditional jump works.
global asm_func
section .text
asm_func: ; this is our entry point
mov rax, 1024 ; set RAX to 1024
jmp a_place_to_jump ; Jump to label a_place_to_jump.
; try to comment this jmp line and see what happens.
this_is_not_executed: ; this has been skipped...
mov rax, 512 ; so RAX is not altered
another_jump: ; we will jump here later...
inc rax ; increment RAX
ret ; and exit the program.
a_place_to_jump: ; the first jump land us here...
add rax, rax ; we double RAX
jmp another_jump ; and now we jump to the
; label another_jump above
|
; Initialize the stack pointer and the base pointer
MOV XL, 0xFF
MOV XH, 0xFF
MOV SP, X
MOV XL, 0
MOV XH, 0
MOV BP, X
; Initialize an address register
MOV XL, 0x00
MOV XH, 0xFF
MOV Y, X
; SHL the 1st byte
MOV D, [Y]
SHL D
PUSHF
MOV F, D
; Write register F to the Output Port
OUTB F
; RCL the 2nd byte
MOV E, [Y + 1]
POPF
RCL E
MOV F, E
; Write register F to the Output Port
OUTB F
; Stops CPU execution
HLT
DATA 1111111100000000b, 11010010b ; Low-Byte
DATA 1111111100000001b, 00000100b ; High-Byte
; High-Byte Low-Byte Carry
; =======================================
; 00000100 11010010 0 Initial
; 00000100 10100100 1 After SHL
; 00001001 10100100 0 After RCL |
;------------------------------------------------------------------------------ ;
; Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>
; SPDX-License-Identifier: BSD-2-Clause-Patent
;
; Module Name:
;
; MpFuncs.nasm
;
; Abstract:
;
; This is the assembly code for MP support
;
;-------------------------------------------------------------------------------
%include "MpEqu.inc"
extern ASM_PFX(InitializeFloatingPointUnits)
SECTION .text
;-------------------------------------------------------------------------------------
;RendezvousFunnelProc procedure follows. All APs execute their procedure. This
;procedure serializes all the AP processors through an Init sequence. It must be
;noted that APs arrive here very raw...ie: real mode, no stack.
;ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC
;IS IN MACHINE CODE.
;-------------------------------------------------------------------------------------
global ASM_PFX(RendezvousFunnelProc)
ASM_PFX(RendezvousFunnelProc):
RendezvousFunnelProcStart:
; At this point CS = 0x(vv00) and ip= 0x0.
BITS 16
mov ebp, eax ; save BIST information
mov ax, cs
mov ds, ax
mov es, ax
mov ss, ax
xor ax, ax
mov fs, ax
mov gs, ax
mov si, BufferStartLocation
mov ebx, [si]
mov si, DataSegmentLocation
mov edx, [si]
;
; Get start address of 32-bit code in low memory (<1MB)
;
mov edi, ModeTransitionMemoryLocation
mov si, GdtrLocation
o32 lgdt [cs:si]
mov si, IdtrLocation
o32 lidt [cs:si]
;
; Switch to protected mode
;
mov eax, cr0 ; Get control register 0
or eax, 000000003h ; Set PE bit (bit #0) & MP
mov cr0, eax
; Switch to 32-bit code in executable memory (>1MB)
o32 jmp far [cs:di]
;
; Following code may be copied to memory with type of EfiBootServicesCode.
; This is required at DXE phase if NX is enabled for EfiBootServicesCode of
; memory.
;
BITS 32
Flat32Start: ; protected mode entry point
mov ds, dx
mov es, dx
mov fs, dx
mov gs, dx
mov ss, dx
mov esi, ebx
mov edi, esi
add edi, EnableExecuteDisableLocation
cmp byte [edi], 0
jz SkipEnableExecuteDisable
;
; Enable IA32 PAE execute disable
;
mov ecx, 0xc0000080
rdmsr
bts eax, 11
wrmsr
mov edi, esi
add edi, Cr3Location
mov eax, dword [edi]
mov cr3, eax
mov eax, cr4
bts eax, 5
mov cr4, eax
mov eax, cr0
bts eax, 31
mov cr0, eax
SkipEnableExecuteDisable:
mov edi, esi
add edi, InitFlagLocation
cmp dword [edi], 1 ; 1 == ApInitConfig
jnz GetApicId
; Increment the number of APs executing here as early as possible
; This is decremented in C code when AP is finished executing
mov edi, esi
add edi, NumApsExecutingLocation
lock inc dword [edi]
; AP init
mov edi, esi
add edi, LockLocation
mov eax, NotVacantFlag
mov edi, esi
add edi, ApIndexLocation
mov ebx, 1
lock xadd dword [edi], ebx ; EBX = ApIndex++
inc ebx ; EBX is CpuNumber
mov edi, esi
add edi, StackSizeLocation
mov eax, [edi]
mov ecx, ebx
inc ecx
mul ecx ; EAX = StackSize * (CpuNumber + 1)
mov edi, esi
add edi, StackStartAddressLocation
add eax, [edi]
mov esp, eax
jmp CProcedureInvoke
GetApicId:
mov eax, 0
cpuid
cmp eax, 0bh
jb NoX2Apic ; CPUID level below CPUID_EXTENDED_TOPOLOGY
mov eax, 0bh
xor ecx, ecx
cpuid
test ebx, 0ffffh
jz NoX2Apic ; CPUID.0BH:EBX[15:0] is zero
; Processor is x2APIC capable; 32-bit x2APIC ID is already in EDX
jmp GetProcessorNumber
NoX2Apic:
; Processor is not x2APIC capable, so get 8-bit APIC ID
mov eax, 1
cpuid
shr ebx, 24
mov edx, ebx
GetProcessorNumber:
;
; Get processor number for this AP
; Note that BSP may become an AP due to SwitchBsp()
;
xor ebx, ebx
lea eax, [esi + CpuInfoLocation]
mov edi, [eax]
GetNextProcNumber:
cmp [edi], edx ; APIC ID match?
jz ProgramStack
add edi, 20
inc ebx
jmp GetNextProcNumber
ProgramStack:
mov esp, [edi + 12]
CProcedureInvoke:
push ebp ; push BIST data at top of AP stack
xor ebp, ebp ; clear ebp for call stack trace
push ebp
mov ebp, esp
mov eax, ASM_PFX(InitializeFloatingPointUnits)
call eax ; Call assembly function to initialize FPU per UEFI spec
push ebx ; Push ApIndex
mov eax, esi
add eax, LockLocation
push eax ; push address of exchange info data buffer
mov edi, esi
add edi, ApProcedureLocation
mov eax, [edi]
call eax ; Invoke C function
jmp $ ; Never reach here
RendezvousFunnelProcEnd:
;-------------------------------------------------------------------------------------
;SwitchToRealProc procedure follows.
;NOT USED IN 32 BIT MODE.
;-------------------------------------------------------------------------------------
global ASM_PFX(SwitchToRealProc)
ASM_PFX(SwitchToRealProc):
SwitchToRealProcStart:
jmp $ ; Never reach here
SwitchToRealProcEnd:
;-------------------------------------------------------------------------------------
; AsmRelocateApLoop (MwaitSupport, ApTargetCState, PmCodeSegment, TopOfApStack, CountTofinish, Pm16CodeSegment, SevEsAPJumpTable, WakeupBuffer);
;
; The last three parameters (Pm16CodeSegment, SevEsAPJumpTable and WakeupBuffer) are
; specific to SEV-ES support and are not applicable on IA32.
;-------------------------------------------------------------------------------------
global ASM_PFX(AsmRelocateApLoop)
ASM_PFX(AsmRelocateApLoop):
AsmRelocateApLoopStart:
mov eax, esp
mov esp, [eax + 16] ; TopOfApStack
push dword [eax] ; push return address for stack trace
push ebp
mov ebp, esp
mov ebx, [eax + 8] ; ApTargetCState
mov ecx, [eax + 4] ; MwaitSupport
mov eax, [eax + 20] ; CountTofinish
lock dec dword [eax] ; (*CountTofinish)--
cmp cl, 1 ; Check mwait-monitor support
jnz HltLoop
MwaitLoop:
cli
mov eax, esp
xor ecx, ecx
xor edx, edx
monitor
mov eax, ebx ; Mwait Cx, Target C-State per eax[7:4]
shl eax, 4
mwait
jmp MwaitLoop
HltLoop:
cli
hlt
jmp HltLoop
AsmRelocateApLoopEnd:
;-------------------------------------------------------------------------------------
; AsmGetAddressMap (&AddressMap);
;-------------------------------------------------------------------------------------
global ASM_PFX(AsmGetAddressMap)
ASM_PFX(AsmGetAddressMap):
pushad
mov ebp,esp
mov ebx, [ebp + 24h]
mov dword [ebx], RendezvousFunnelProcStart
mov dword [ebx + 4h], Flat32Start - RendezvousFunnelProcStart
mov dword [ebx + 8h], RendezvousFunnelProcEnd - RendezvousFunnelProcStart
mov dword [ebx + 0Ch], AsmRelocateApLoopStart
mov dword [ebx + 10h], AsmRelocateApLoopEnd - AsmRelocateApLoopStart
mov dword [ebx + 14h], Flat32Start - RendezvousFunnelProcStart
mov dword [ebx + 18h], SwitchToRealProcEnd - SwitchToRealProcStart ; SwitchToRealSize
mov dword [ebx + 1Ch], SwitchToRealProcStart - RendezvousFunnelProcStart ; SwitchToRealOffset
mov dword [ebx + 20h], SwitchToRealProcStart - Flat32Start ; SwitchToRealNoNxOffset
mov dword [ebx + 24h], 0 ; SwitchToRealPM16ModeOffset
mov dword [ebx + 28h], 0 ; SwitchToRealPM16ModeSize
popad
ret
;-------------------------------------------------------------------------------------
;AsmExchangeRole procedure follows. This procedure executed by current BSP, that is
;about to become an AP. It switches it'stack with the current AP.
;AsmExchangeRole (IN CPU_EXCHANGE_INFO *MyInfo, IN CPU_EXCHANGE_INFO *OthersInfo);
;-------------------------------------------------------------------------------------
global ASM_PFX(AsmExchangeRole)
ASM_PFX(AsmExchangeRole):
; DO NOT call other functions in this function, since 2 CPU may use 1 stack
; at the same time. If 1 CPU try to call a function, stack will be corrupted.
pushad
mov ebp,esp
; esi contains MyInfo pointer
mov esi, [ebp + 24h]
; edi contains OthersInfo pointer
mov edi, [ebp + 28h]
;Store EFLAGS, GDTR and IDTR register to stack
pushfd
mov eax, cr4
push eax ; push cr4 firstly
mov eax, cr0
push eax
sgdt [esi + 8]
sidt [esi + 14]
; Store the its StackPointer
mov [esi + 4],esp
; update its switch state to STORED
mov byte [esi], CPU_SWITCH_STATE_STORED
WaitForOtherStored:
; wait until the other CPU finish storing its state
cmp byte [edi], CPU_SWITCH_STATE_STORED
jz OtherStored
pause
jmp WaitForOtherStored
OtherStored:
; Since another CPU already stored its state, load them
; load GDTR value
lgdt [edi + 8]
; load IDTR value
lidt [edi + 14]
; load its future StackPointer
mov esp, [edi + 4]
; update the other CPU's switch state to LOADED
mov byte [edi], CPU_SWITCH_STATE_LOADED
WaitForOtherLoaded:
; wait until the other CPU finish loading new state,
; otherwise the data in stack may corrupt
cmp byte [esi], CPU_SWITCH_STATE_LOADED
jz OtherLoaded
pause
jmp WaitForOtherLoaded
OtherLoaded:
; since the other CPU already get the data it want, leave this procedure
pop eax
mov cr0, eax
pop eax
mov cr4, eax
popfd
popad
ret
|
Icons: ; used only for BANK(Icons)
NullIcon:
PoliwagIcon: INCBIN "gfx/icons/poliwag.2bpp"
JigglypuffIcon: INCBIN "gfx/icons/jigglypuff.2bpp"
DiglettIcon: INCBIN "gfx/icons/diglett.2bpp"
PikachuIcon: INCBIN "gfx/icons/pikachu.2bpp"
StaryuIcon: INCBIN "gfx/icons/staryu.2bpp"
FishIcon: INCBIN "gfx/icons/fish.2bpp"
BirdIcon: INCBIN "gfx/icons/bird.2bpp"
MonsterIcon: INCBIN "gfx/icons/monster.2bpp"
ClefairyIcon: INCBIN "gfx/icons/clefairy.2bpp"
OddishIcon: INCBIN "gfx/icons/oddish.2bpp"
BugIcon: INCBIN "gfx/icons/bug.2bpp"
GhostIcon: INCBIN "gfx/icons/ghost.2bpp"
LaprasIcon: INCBIN "gfx/icons/lapras.2bpp"
HumanshapeIcon: INCBIN "gfx/icons/humanshape.2bpp"
FoxIcon: INCBIN "gfx/icons/fox.2bpp"
EquineIcon: INCBIN "gfx/icons/equine.2bpp"
ShellIcon: INCBIN "gfx/icons/shell.2bpp"
BlobIcon: INCBIN "gfx/icons/blob.2bpp"
SerpentIcon: INCBIN "gfx/icons/serpent.2bpp"
VoltorbIcon: INCBIN "gfx/icons/voltorb.2bpp"
SquirtleIcon: INCBIN "gfx/icons/squirtle.2bpp"
BulbasaurIcon: INCBIN "gfx/icons/bulbasaur.2bpp"
CharmanderIcon: INCBIN "gfx/icons/charmander.2bpp"
CaterpillarIcon: INCBIN "gfx/icons/caterpillar.2bpp"
UnownIcon: INCBIN "gfx/icons/unown.2bpp"
GeodudeIcon: INCBIN "gfx/icons/geodude.2bpp"
FighterIcon: INCBIN "gfx/icons/fighter.2bpp"
EggIcon: INCBIN "gfx/icons/egg.2bpp"
JellyfishIcon: INCBIN "gfx/icons/jellyfish.2bpp"
MothIcon: INCBIN "gfx/icons/moth.2bpp"
BatIcon: INCBIN "gfx/icons/bat.2bpp"
SnorlaxIcon: INCBIN "gfx/icons/snorlax.2bpp"
HoOhIcon: INCBIN "gfx/icons/ho_oh.2bpp"
LugiaIcon: INCBIN "gfx/icons/lugia.2bpp"
GyaradosIcon: INCBIN "gfx/icons/gyarados.2bpp"
SlowpokeIcon: INCBIN "gfx/icons/slowpoke.2bpp"
SudowoodoIcon: INCBIN "gfx/icons/sudowoodo.2bpp"
BigmonIcon: INCBIN "gfx/icons/bigmon.2bpp"
|
.text
.def demo1_entry;
.scl 2;
.type 32;
.endef
.globl demo1_entry
.align 16, 0x90
demo1_entry: # @demo1_entry
# BB#0: # %driverBlockRaw
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rsi
pushq %rdi
pushq %rbp
pushq %rbx
subq $168, %rsp
movaps %xmm6, 144(%rsp) # 16-byte Spill
movq %rcx, %rax
movl (%rax), %r9d
movups 8(%rax), %xmm0
movups 24(%rax), %xmm1
movq 40(%rax), %r14
movq 48(%rax), %r10
movups 56(%rax), %xmm2
movups 72(%rax), %xmm3
movups 88(%rax), %xmm4
movups 104(%rax), %xmm5
movups 120(%rax), %xmm6
movb 142(%rax), %cl
movb %cl, 15(%rsp) # 1-byte Spill
leaq 143(%rax), %r11
leaq 16(%rsp), %rdi
movl $32, %ecx
movq %rdi, %r15
movq %r11, %rsi
rep;movsl
movb 271(%rax), %cl
movb %cl, 14(%rsp) # 1-byte Spill
movb 272(%rax), %cl
movb %cl, 13(%rsp) # 1-byte Spill
movb 273(%rax), %bpl
movb 274(%rax), %cl
movb %cl, 12(%rsp) # 1-byte Spill
movb 275(%rax), %cl
movb %cl, 11(%rsp) # 1-byte Spill
movb 276(%rax), %r12b
movb 277(%rax), %r13b
movb 278(%rax), %cl
movb %cl, 10(%rsp) # 1-byte Spill
movl %r9d, %esi
addl $1, %esi
setb %dil
movl %esi, %r8d
xorl %r9d, %r8d
movb %r8b, %bl
shrb $4, %bl
xorl $-2147483648, %r9d # imm = 0xFFFFFFFF80000000
movb %sil, %dl
shrb %dl
andb $85, %dl
movb %sil, %cl
subb %dl, %cl
movb %cl, %dl
andb $51, %dl
shrb $2, %cl
andb $51, %cl
addb %dl, %cl
movb %cl, %dl
shrb $4, %dl
addb %cl, %dl
addq $8, %r10
testb $1, %dl
movq %rsi, (%rax)
movups %xmm0, 8(%rax)
movups %xmm1, 24(%rax)
movq %r14, 40(%rax)
movq %r10, 48(%rax)
movups %xmm2, 56(%rax)
movups %xmm3, 72(%rax)
movups %xmm4, 88(%rax)
movups %xmm5, 104(%rax)
movups %xmm6, 120(%rax)
movb %dil, 136(%rax)
sete 137(%rax)
andb $1, %bl
testl %esi, %esi
movb %bl, 138(%rax)
sete 139(%rax)
sets 140(%rax)
testl %r9d, %r8d
sets 141(%rax)
movb 15(%rsp), %cl # 1-byte Reload
movb %cl, 142(%rax)
movl $16, %ecx
movq %r11, %rdi
movq %r15, %rsi
rep;movsq
movb 14(%rsp), %cl # 1-byte Reload
movb %cl, 271(%rax)
movb 13(%rsp), %cl # 1-byte Reload
movb %cl, 272(%rax)
movb %bpl, 273(%rax)
movb 12(%rsp), %cl # 1-byte Reload
movb %cl, 274(%rax)
movb 11(%rsp), %cl # 1-byte Reload
movb %cl, 275(%rax)
movb %r12b, 276(%rax)
movb %r13b, 277(%rax)
movb 10(%rsp), %cl # 1-byte Reload
movb %cl, 278(%rax)
movaps 144(%rsp), %xmm6 # 16-byte Reload
addq $168, %rsp
popq %rbx
popq %rbp
popq %rdi
popq %rsi
popq %r12
popq %r13
popq %r14
popq %r15
retq
|
; A195585: sigma(2*n^2) - sigma(n^2).
; 2,8,26,32,62,104,114,128,242,248,266,416,366,456,806,512,614,968,762,992,1482,1064,1106,1664,1562,1464,2186,1824,1742,3224,1986,2048,3458,2456,3534,3872,2814,3048,4758,3968,3446,5928,3786,4256,7502,4424,4514,6656,5602,6248,7982,5856,5726,8744,8246,7296,9906,6968,7082,12896,7566,7944,13794,8192,11346,13832,9114,9824,14378,14136,10226,15488,10806,11256,20306,12192,15162,19032,12642,15872,19682,13784,13946,23712,19034,15144,22646,17024,16022,30008,20862,17696,25818,18056,23622,26624,19014,22408
add $0,1
pow $0,2
mov $2,$0
lpb $0
mov $3,$2
dif $3,$0
cmp $3,$2
cmp $3,0
mul $3,$0
sub $0,1
dif $3,2
add $1,$3
lpe
mul $1,2
add $1,2
mov $0,$1
|
; A160292: Numerator of Hermite(n, 7/30).
; Submitted by Stefano Spezia
; 1,7,-401,-9107,477601,19735807,-936451601,-59841840107,2530929662401,233147132022007,-8618235208570001,-1109489740559021507,34893836098508354401,6235501451708274618607,-160480431014315950915601,-40407022162862341753633307,800393754206596276404873601,296533315852055034560993925607,-4047279008716076272570325568401,-2430250811462658313852043076395507,17592479844283843933511982075060001,21995404662073911732202971562084983007,-12281101893964943046267429674722128401
add $0,1
mov $3,1
lpb $0
sub $0,1
add $2,$3
mov $3,$1
mov $1,$2
mul $1,18
mul $2,7
mul $3,-25
mul $3,$0
lpe
mov $0,$1
div $0,18
|
;
; Sharp OZ family functions
;
; ported from the OZ-7xx SDK by by Alexander R. Pruss
; by Stefano Bodrato - Oct. 2003
;
;
; void ozinitsound(void)
;
; ------
; $Id: ozinitsound.asm,v 1.1 2003/10/27 17:03:40 stefano Exp $
;
XLIB ozinitsound
ozinitsound:
ld a,1
out (19h),a ; turn tone mode on
ret
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r13
push %r15
push %r8
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_D_ht+0x2104, %r13
nop
dec %rcx
vmovups (%r13), %ymm3
vextracti128 $0, %ymm3, %xmm3
vpextrq $1, %xmm3, %rsi
nop
nop
nop
xor $21623, %r11
lea addresses_D_ht+0x1a8d2, %r15
nop
nop
sub %r8, %r8
mov $0x6162636465666768, %rcx
movq %rcx, %xmm6
movups %xmm6, (%r15)
nop
add %r11, %r11
lea addresses_UC_ht+0x10dd4, %r13
xor $26612, %rdx
movb $0x61, (%r13)
nop
nop
nop
nop
nop
sub $55167, %r15
lea addresses_WT_ht+0x144f, %rsi
lea addresses_WT_ht+0x1b31c, %rdi
nop
nop
nop
add $42269, %rdx
mov $58, %rcx
rep movsq
nop
nop
nop
nop
nop
and %r15, %r15
lea addresses_WT_ht+0x1b304, %rdx
nop
nop
nop
nop
nop
inc %r13
mov $0x6162636465666768, %rdi
movq %rdi, %xmm4
movups %xmm4, (%rdx)
nop
sub $16559, %rdx
lea addresses_normal_ht+0x1584, %rsi
nop
nop
nop
nop
cmp %r8, %r8
mov (%rsi), %edx
cmp %rsi, %rsi
lea addresses_A_ht+0x1d615, %rcx
xor $18608, %r13
movw $0x6162, (%rcx)
nop
nop
dec %r15
lea addresses_WT_ht+0x16a7c, %rdi
clflush (%rdi)
nop
nop
and %r13, %r13
vmovups (%rdi), %ymm4
vextracti128 $0, %ymm4, %xmm4
vpextrq $0, %xmm4, %rsi
nop
nop
nop
inc %rdx
lea addresses_WC_ht+0xa304, %r15
and %rdx, %rdx
mov (%r15), %r13w
nop
nop
add $27091, %rsi
lea addresses_UC_ht+0x19964, %r8
nop
nop
dec %r11
vmovups (%r8), %ymm0
vextracti128 $1, %ymm0, %xmm0
vpextrq $1, %xmm0, %r13
nop
dec %rdx
lea addresses_D_ht+0x176c4, %rdx
nop
nop
nop
nop
sub %r13, %r13
movl $0x61626364, (%rdx)
nop
nop
nop
nop
sub $33759, %rdi
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r8
pop %r15
pop %r13
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r14
push %rax
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
// REPMOV
lea addresses_WC+0x1e130, %rsi
lea addresses_WT+0x3684, %rdi
nop
nop
nop
nop
nop
sub $52971, %rax
mov $50, %rcx
rep movsq
nop
xor $22712, %rsi
// Store
lea addresses_US+0x1d384, %rbx
clflush (%rbx)
nop
nop
sub $17738, %rdx
mov $0x5152535455565758, %rcx
movq %rcx, %xmm5
vmovups %ymm5, (%rbx)
nop
and $63745, %rax
// Store
mov $0x611379000000071c, %rax
nop
nop
nop
nop
nop
sub %rcx, %rcx
mov $0x5152535455565758, %rbx
movq %rbx, %xmm0
movups %xmm0, (%rax)
nop
nop
cmp $352, %rdx
// Store
lea addresses_US+0x1d384, %r14
add %rbx, %rbx
movb $0x51, (%r14)
nop
nop
nop
nop
and $26354, %rbx
// Store
mov $0x384, %rcx
nop
nop
cmp %r14, %r14
movb $0x51, (%rcx)
add $45582, %rax
// Store
lea addresses_WT+0x2ae8, %rbx
nop
nop
nop
nop
nop
add $59931, %rdx
mov $0x5152535455565758, %r14
movq %r14, %xmm1
movups %xmm1, (%rbx)
nop
inc %rax
// Faulty Load
lea addresses_US+0x1d384, %rsi
nop
sub $61068, %rax
movntdqa (%rsi), %xmm0
vpextrq $0, %xmm0, %rdx
lea oracles, %rax
and $0xff, %rdx
shlq $12, %rdx
mov (%rax,%rdx,1), %rdx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r14
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_US', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 2, 'type': 'addresses_WC'}, 'dst': {'same': False, 'congruent': 3, 'type': 'addresses_WT'}}
{'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_US', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_NC', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 2}}
{'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_US', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_P', 'NT': True, 'AVXalign': False, 'size': 1, 'congruent': 4}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 2}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_US', 'NT': True, 'AVXalign': False, 'size': 16, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 5}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 1}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 0, 'type': 'addresses_WT_ht'}, 'dst': {'same': False, 'congruent': 3, 'type': 'addresses_WT_ht'}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 6}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 8}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 3}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 7}}
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 5}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 5}}
{'51': 21618, '00': 211}
51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51
*/
|
; A021676: Decimal expansion of 1/672.
; 0,0,1,4,8,8,0,9,5,2,3,8,0,9,5,2,3,8,0,9,5,2,3,8,0,9,5,2,3,8,0,9,5,2,3,8,0,9,5,2,3,8,0,9,5,2,3,8,0,9,5,2,3,8,0,9,5,2,3,8,0,9,5,2,3,8,0,9,5,2,3,8,0,9,5,2,3,8,0,9,5,2,3,8,0,9,5,2,3,8,0,9,5,2,3,8,0,9,5
add $0,1
mov $1,10
pow $1,$0
mul $1,2
div $1,1344
mod $1,10
mov $0,$1
|
#include<iostream.h>
#include<conio.h>
main()
{
//clrscr();//
float cap, cap_gin, cap_tra, cap_ped;
cout<<"el presupuesto es de: ";
cin>>cap;
cap_gin=cap*0.40;
cap_tra=cap*0.30;
cap_ped=cap*0.30;
cout<<"el presupuesto de ginecologia es: "<<cap_gin;
cout<<endl;
cout<<"el presupuesto de traumatologia es: "<<cap_tra;
cout<<endl;
cout<<"el presupuesto de pediatria es: "<<cap_ped;
getch();
}
|
;
; ZX Spectrum specific routines
; by Stefano Bodrato, Fall 2013
;
; int set_psg(int reg, int val);
;
; Play a sound by PSG
;
;
; $Id: set_psg.asm,v 1.3 2016-06-10 21:13:58 dom Exp $
;
SECTION code_clib
PUBLIC set_psg
PUBLIC _set_psg
EXTERN set_psg_callee
EXTERN ASMDISP_SET_PSG_CALLEE
set_psg:
_set_psg:
pop bc
pop de
pop hl
push hl
push de
push bc
jp set_psg_callee + ASMDISP_SET_PSG_CALLEE
|
.global s_prepare_buffers
s_prepare_buffers:
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r14
push %r15
push %r8
push %rbp
// Faulty Load
lea addresses_WC+0x8dc7, %r14
nop
nop
inc %r11
mov (%r14), %r15w
lea oracles, %r11
and $0xff, %r15
shlq $12, %r15
mov (%r11,%r15,1), %r15
pop %rbp
pop %r8
pop %r15
pop %r14
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_WC', 'congruent': 0}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_WC', '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
*/
|
include mylib.inc
CallDos equ <int 21h>
MyData segment
;-------------键盘输入相关的格式 输入字符串
g_dbSize db 30h ;第一个字节为缓冲区的大小(缓冲区的最大长度) 如果超出范围,DOS不让输入,并发出声音
g_dbLength db 0 ;第二个字节为实际的长度 (键盘输入后,自动填写)
g_strBuffer db 30h dup (0) ;从第三个字节开始,为Buffer
;回车 换行
g_strEnter db 0dh, 0ah, '$'
g_strTip db 'please input hex string:$'
g_strError db 'Error input$'
MyData ends
MyStack segment stack ;stack 声明此处是堆栈段,老的编译器有时候需要此声明
db 80h dup (0cch) ;在g_InitStack前面给同样大小的区域,防止堆栈溢出
g_InitStack db 80h dup (0cch) ;定义80h个字节,即十进制100个字节,作为我们的栈空间,以 cc 进行填充. 汇编中的数值,只要是 a到f开头的,前缀必须给0,否则编译器分不清是变量名还是数值.
MyStack ends
MyCode segment
START:
;数据段给类型 或者说是 声明数据段
assume ds : MyData
;---------设置数据段
mov ax, MyData
mov ds, ax
;---------设置堆栈段
mov ax, MyStack
mov ss, ax
;offset 表示取 g_InitStack标号的首地址
;栈顶设置在栈的中间位置,防止堆栈溢出
mov sp, offset g_InitStack
;在屏幕上输出
mov dx, offset g_strTip
mov ah, 09h
int 21h
;-------------等待用户选择对应的菜单选项
;DS:DX=缓冲区首地址
;(DS:DX+1)=实际输入的字符数
;(DS:DX)=缓冲区最大字符数
mov dx, offset g_dbSize
mov ah, 0ah ;0ah 表示键盘输入到缓冲区
int 21h
;下面要给输入完成的字符串添加结束符$,下面的 bl 存放的是用户实际输入的字符串长度,而加$时,用的是bx,为了将bh置0,这里直接将bx置0.
xor bx,bx
;到这一步时,用户已经输入完成,g_dbLength里面已经存入了我们输入的字符串实际长度
mov bl,g_dbLength ;默认访问的是 ds 段,所以在上面要声明 ds 在哪一个段 -> assume ds : MyData,这里才可以使用
;给我们输入的字符串在末尾添加结束符$
mov si,offset g_strBuffer
mov byte ptr [si+bx],'$'
;回车 换行
mov dx, offset g_strEnter
mov ah, 09h
CallDos
xor cx, cx
mov si, offset g_strBuffer
WHILE_BEGIN:
cmp cx, bx ;当前正在处理的十六进制位置 跟 我们输入的十六进制字符串总长度 进行比较
jae WHILE_END ;当cx 大于 bx 时,说明已经转换到了最后一个字符,跳转到 WHILE_END
mov bp, cx
xor ax, ax
mov al, ds:[si + bp]
;----写法一:
;push ax
;如果 ShowBin 函数内部调用的是 C 约定(外平栈) ,那么,要在 call ShowBin 的下一行再添加上 add sp,2 (堆栈地址是从高到低分配的)
;如果 showBin 函数内部调用的是 stdcall 约定(内平栈),那么,"不需要"在 call ShowBin 的下一行添加 add sp,2
;call ShowBin ;调用 ShowBin 函数 , 这里为内平栈,即在 ShowBin 函数里 ret 2
;----写法二:
;invoke是一个宏指令(编译器的内置宏),参数一是我们要调用的函数,参数二是我们要提交的参数,编译器会自动生成平栈的代码.
invoke ShowBin,ax
cmp ax, 0 ;此时的 ax 为 ShowBin 的返回标识, 1:表示当前处理的为正常的十六进制字符 0:表示当前处理的不为十六进制字符
jnz NEXT
;当前处理的字符如果不为十六进制字符,在屏幕上输出 Error input 并跳转到EXIT_PROC标识,结束程序
mov dx, offset g_strError
mov ah, 9
int 21h
jmp EXIT_PROC
NEXT:
inc cx
jmp WHILE_BEGIN
WHILE_END:
EXIT_PROC:
mov ax, 4c00h
int 21h
MyCode ends
end START |
#include "JavascriptComboButtonContext.h"
#include "Components/Widget.h"
TSharedRef<SWidget> UJavascriptComboButtonContext::Public_OnGetWidget()
{
if (OnGetWidget.IsBound())
{
UWidget* Widget = OnGetWidget.Execute();
if (Widget)
{
return Widget->TakeWidget();
}
}
return SNullWidget::NullWidget;
}
FSlateIcon UJavascriptComboButtonContext::Public_OnGetSlateIcon()
{
return OnGetIcon.IsBound() ? OnGetIcon.Execute() : FSlateIcon();
}
bool UJavascriptComboButtonContext::Public_CanExecute()
{
return OnCanExecute.IsBound() ? OnCanExecute.Execute() : true;
}
FText UJavascriptComboButtonContext::Public_OnGetTooltip()
{
return OnGetTooltip.IsBound() ? OnGetTooltip.Execute() : FText();
}
FText UJavascriptComboButtonContext::Public_OnGetLabel()
{
return OnGetLabel.IsBound() ? OnGetLabel.Execute() : FText();
}
|
; A168843: Number of reduced words of length n in Coxeter group on 22 generators S_i with relations (S_i)^2 = (S_i S_j)^20 = I.
; 1,22,462,9702,203742,4278582,89850222,1886854662,39623947902,832102905942,17474161024782,366957381520422,7706105011928862,161828205250506102,3398392310260628142,71366238515473190982
add $0,1
mov $3,1
lpb $0
sub $0,1
add $2,$3
div $3,$2
mul $2,21
lpe
mov $0,$2
div $0,21
|
// Copyright (c) 2017-2018 The Popchain Core Developers
#include "walletmodel.h"
#include "addresstablemodel.h"
#include "guiconstants.h"
#include "guiutil.h"
#include "paymentserver.h"
#include "recentrequeststablemodel.h"
#include "transactiontablemodel.h"
#include "base58.h"
#include "keystore.h"
#include "main.h"
#include "sync.h"
#include "ui_interface.h"
#include "wallet/wallet.h"
#include "wallet/walletdb.h" // for BackupWallet
#include "darksend.h"
#include "instantx.h"
#include "spork.h"
#include <stdint.h>
#include <QDebug>
#include <QSet>
#include <QTimer>
#include <boost/foreach.hpp>
WalletModel::WalletModel(const PlatformStyle *platformStyle, CWallet *wallet, OptionsModel *optionsModel, QObject *parent) :
QObject(parent), wallet(wallet), optionsModel(optionsModel), addressTableModel(0),
transactionTableModel(0),
recentRequestsTableModel(0),
cachedBalance(0), cachedUnconfirmedBalance(0), cachedImmatureBalance(0),
cachedEncryptionStatus(Unencrypted),
cachedNumBlocks(0)
{
fHaveWatchOnly = wallet->HaveWatchOnly();
fForceCheckBalanceChanged = false;
addressTableModel = new AddressTableModel(wallet, this);
transactionTableModel = new TransactionTableModel(platformStyle, wallet, this);
recentRequestsTableModel = new RecentRequestsTableModel(wallet, this);
// This timer will be fired repeatedly to update the balance
pollTimer = new QTimer(this);
connect(pollTimer, SIGNAL(timeout()), this, SLOT(pollBalanceChanged()));
pollTimer->start(MODEL_UPDATE_DELAY);
subscribeToCoreSignals();
}
WalletModel::~WalletModel()
{
unsubscribeFromCoreSignals();
}
CAmount WalletModel::getBalance(const CCoinControl *coinControl) const
{
if (coinControl)
{
CAmount nBalance = 0;
std::vector<COutput> vCoins;
wallet->AvailableCoins(vCoins, true, coinControl);
BOOST_FOREACH(const COutput& out, vCoins)
if(out.fSpendable)
nBalance += out.tx->vout[out.i].nValue;
return nBalance;
}
return wallet->GetBalance();
}
CAmount WalletModel::getAnonymizedBalance() const
{
return wallet->GetAnonymizedBalance();
}
CAmount WalletModel::getUnconfirmedBalance() const
{
return wallet->GetUnconfirmedBalance();
}
CAmount WalletModel::getImmatureBalance() const
{
return wallet->GetImmatureBalance();
}
bool WalletModel::haveWatchOnly() const
{
return fHaveWatchOnly;
}
CAmount WalletModel::getWatchBalance() const
{
return wallet->GetWatchOnlyBalance();
}
CAmount WalletModel::getWatchUnconfirmedBalance() const
{
return wallet->GetUnconfirmedWatchOnlyBalance();
}
CAmount WalletModel::getWatchImmatureBalance() const
{
return wallet->GetImmatureWatchOnlyBalance();
}
void WalletModel::updateStatus()
{
EncryptionStatus newEncryptionStatus = getEncryptionStatus();
if(cachedEncryptionStatus != newEncryptionStatus)
Q_EMIT encryptionStatusChanged(newEncryptionStatus);
}
void WalletModel::pollBalanceChanged()
{
// Get required locks upfront. This avoids the GUI from getting stuck on
// periodical polls if the core is holding the locks for a longer time -
// for example, during a wallet rescan.
TRY_LOCK(cs_main, lockMain);
if(!lockMain)
return;
TRY_LOCK(wallet->cs_wallet, lockWallet);
if(!lockWallet)
return;
if(fForceCheckBalanceChanged || chainActive.Height() != cachedNumBlocks || nPrivateSendRounds != cachedPrivateSendRounds || cachedTxLocks != nCompleteTXLocks)
{
fForceCheckBalanceChanged = false;
// Balance and number of transactions might have changed
cachedNumBlocks = chainActive.Height();
cachedPrivateSendRounds = nPrivateSendRounds;
checkBalanceChanged();
if(transactionTableModel)
transactionTableModel->updateConfirmations();
}
}
void WalletModel::checkBalanceChanged()
{
CAmount newBalance = getBalance();
CAmount newUnconfirmedBalance = getUnconfirmedBalance();
CAmount newImmatureBalance = getImmatureBalance();
CAmount newAnonymizedBalance = getAnonymizedBalance();
CAmount newWatchOnlyBalance = 0;
CAmount newWatchUnconfBalance = 0;
CAmount newWatchImmatureBalance = 0;
if (haveWatchOnly())
{
newWatchOnlyBalance = getWatchBalance();
newWatchUnconfBalance = getWatchUnconfirmedBalance();
newWatchImmatureBalance = getWatchImmatureBalance();
}
if(cachedBalance != newBalance || cachedUnconfirmedBalance != newUnconfirmedBalance || cachedImmatureBalance != newImmatureBalance ||
cachedAnonymizedBalance != newAnonymizedBalance || cachedTxLocks != nCompleteTXLocks ||
cachedWatchOnlyBalance != newWatchOnlyBalance || cachedWatchUnconfBalance != newWatchUnconfBalance || cachedWatchImmatureBalance != newWatchImmatureBalance)
{
cachedBalance = newBalance;
cachedUnconfirmedBalance = newUnconfirmedBalance;
cachedImmatureBalance = newImmatureBalance;
cachedAnonymizedBalance = newAnonymizedBalance;
cachedTxLocks = nCompleteTXLocks;
cachedWatchOnlyBalance = newWatchOnlyBalance;
cachedWatchUnconfBalance = newWatchUnconfBalance;
cachedWatchImmatureBalance = newWatchImmatureBalance;
Q_EMIT balanceChanged(newBalance, newUnconfirmedBalance, newImmatureBalance, newAnonymizedBalance,
newWatchOnlyBalance, newWatchUnconfBalance, newWatchImmatureBalance);
}
}
void WalletModel::updateTransaction()
{
// Balance and number of transactions might have changed
fForceCheckBalanceChanged = true;
}
void WalletModel::updateAddressBook(const QString &address, const QString &label,
bool isMine, const QString &purpose, int status)
{
if(addressTableModel)
addressTableModel->updateEntry(address, label, isMine, purpose, status);
}
void WalletModel::updateWatchOnlyFlag(bool fHaveWatchonly)
{
fHaveWatchOnly = fHaveWatchonly;
Q_EMIT notifyWatchonlyChanged(fHaveWatchonly);
}
bool WalletModel::validateAddress(const QString &address)
{
CBitcoinAddress addressParsed(address.toStdString());
return addressParsed.IsValid();
}
WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransaction &transaction, const CCoinControl *coinControl)
{
CAmount total = 0;
bool fSubtractFeeFromAmount = false;
QList<SendCoinsRecipient> recipients = transaction.getRecipients();
std::vector<CRecipient> vecSend;
if(recipients.empty())
{
return OK;
}
// This should never really happen, yet another safety check, just in case.
if(wallet->IsLocked()) {
return TransactionCreationFailed;
}
QSet<QString> setAddress; // Used to detect duplicates
int nAddresses = 0;
// Pre-check input data for validity
Q_FOREACH(const SendCoinsRecipient &rcp, recipients)
{
if (rcp.fSubtractFeeFromAmount)
fSubtractFeeFromAmount = true;
if (rcp.paymentRequest.IsInitialized())
{ // PaymentRequest...
CAmount subtotal = 0;
const payments::PaymentDetails& details = rcp.paymentRequest.getDetails();
for (int i = 0; i < details.outputs_size(); i++)
{
const payments::Output& out = details.outputs(i);
if (out.amount() <= 0) continue;
subtotal += out.amount();
const unsigned char* scriptStr = (const unsigned char*)out.script().data();
CScript scriptPubKey(scriptStr, scriptStr+out.script().size());
CAmount nAmount = out.amount();
CRecipient recipient = {scriptPubKey, nAmount, rcp.fSubtractFeeFromAmount};
vecSend.push_back(recipient);
}
if (subtotal <= 0)
{
return InvalidAmount;
}
total += subtotal;
}
else
{ // User-entered pop address / amount:
if(!validateAddress(rcp.address))
{
return InvalidAddress;
}
if(rcp.amount <= 0)
{
return InvalidAmount;
}
setAddress.insert(rcp.address);
++nAddresses;
CScript scriptPubKey = GetScriptForDestination(CBitcoinAddress(rcp.address.toStdString()).Get());
CRecipient recipient = {scriptPubKey, rcp.amount, rcp.fSubtractFeeFromAmount};
vecSend.push_back(recipient);
total += rcp.amount;
}
}
if(setAddress.size() != nAddresses)
{
return DuplicateAddress;
}
CAmount nBalance = getBalance(coinControl);
if(total > nBalance)
{
return AmountExceedsBalance;
}
{
LOCK2(cs_main, wallet->cs_wallet);
transaction.newPossibleKeyChange(wallet);
CAmount nFeeRequired = 0;
int nChangePosRet = -1;
std::string strFailReason;
CWalletTx *newTx = transaction.getTransaction();
CReserveKey *keyChange = transaction.getPossibleKeyChange();
if(recipients[0].fUseInstantSend && total > sporkManager.GetSporkValue(SPORK_5_INSTANTSEND_MAX_VALUE)*COIN){
Q_EMIT message(tr("Send Coins"), tr("InstantSend doesn't support sending values that high yet. Transactions are currently limited to %1 PCH.").arg(sporkManager.GetSporkValue(SPORK_5_INSTANTSEND_MAX_VALUE)),
CClientUIInterface::MSG_ERROR);
return TransactionCreationFailed;
}
bool fCreated = wallet->CreateTransaction(vecSend, *newTx, *keyChange, nFeeRequired, nChangePosRet, strFailReason, coinControl, true, recipients[0].inputType, recipients[0].fUseInstantSend);
transaction.setTransactionFee(nFeeRequired);
if (fSubtractFeeFromAmount && fCreated)
transaction.reassignAmounts(nChangePosRet);
if(recipients[0].fUseInstantSend) {
if(newTx->GetValueOut() > sporkManager.GetSporkValue(SPORK_5_INSTANTSEND_MAX_VALUE)*COIN) {
Q_EMIT message(tr("Send Coins"), tr("InstantSend doesn't support sending values that high yet. Transactions are currently limited to %1 PCH.").arg(sporkManager.GetSporkValue(SPORK_5_INSTANTSEND_MAX_VALUE)),
CClientUIInterface::MSG_ERROR);
return TransactionCreationFailed;
}
if(newTx->vin.size() > CTxLockRequest::WARN_MANY_INPUTS) {
Q_EMIT message(tr("Send Coins"), tr("Used way too many inputs (>%1) for this InstantSend transaction, fees could be huge.").arg(CTxLockRequest::WARN_MANY_INPUTS),
CClientUIInterface::MSG_WARNING);
}
}
if(!fCreated)
{
if(!fSubtractFeeFromAmount && (total + nFeeRequired) > nBalance)
{
return SendCoinsReturn(AmountWithFeeExceedsBalance);
}
Q_EMIT message(tr("Send Coins"), QString::fromStdString(strFailReason),
CClientUIInterface::MSG_ERROR);
return TransactionCreationFailed;
}
// reject absurdly high fee. (This can never happen because the
// wallet caps the fee at maxTxFee. This merely serves as a
// belt-and-suspenders check)
if (nFeeRequired > maxTxFee)
return AbsurdFee;
}
return SendCoinsReturn(OK);
}
WalletModel::SendCoinsReturn WalletModel::sendCoins(WalletModelTransaction &transaction)
{
QByteArray transaction_array; /* store serialized transaction */
{
LOCK2(cs_main, wallet->cs_wallet);
CWalletTx *newTx = transaction.getTransaction();
QList<SendCoinsRecipient> recipients = transaction.getRecipients();
Q_FOREACH(const SendCoinsRecipient &rcp, recipients)
{
if (rcp.paymentRequest.IsInitialized())
{
// Make sure any payment requests involved are still valid.
if (PaymentServer::verifyExpired(rcp.paymentRequest.getDetails())) {
return PaymentRequestExpired;
}
// Store PaymentRequests in wtx.vOrderForm in wallet.
std::string key("PaymentRequest");
std::string value;
rcp.paymentRequest.SerializeToString(&value);
newTx->vOrderForm.push_back(make_pair(key, value));
}
else if (!rcp.message.isEmpty()) // Message from normal pop:URI (pop:XyZ...?message=example)
{
newTx->vOrderForm.push_back(make_pair("Message", rcp.message.toStdString()));
}
}
CReserveKey *keyChange = transaction.getPossibleKeyChange();
if(!wallet->CommitTransaction(*newTx, *keyChange, recipients[0].fUseInstantSend ? NetMsgType::TXLOCKREQUEST : NetMsgType::TX))
return TransactionCommitFailed;
CTransaction* t = (CTransaction*)newTx;
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
ssTx << *t;
transaction_array.append(&(ssTx[0]), ssTx.size());
}
// Add addresses / update labels that we've sent to to the address book,
// and emit coinsSent signal for each recipient
Q_FOREACH(const SendCoinsRecipient &rcp, transaction.getRecipients())
{
// Don't touch the address book when we have a payment request
if (!rcp.paymentRequest.IsInitialized())
{
std::string strAddress = rcp.address.toStdString();
CTxDestination dest = CBitcoinAddress(strAddress).Get();
std::string strLabel = rcp.label.toStdString();
{
LOCK(wallet->cs_wallet);
std::map<CTxDestination, CAddressBookData>::iterator mi = wallet->mapAddressBook.find(dest);
// Check if we have a new address or an updated label
if (mi == wallet->mapAddressBook.end())
{
wallet->SetAddressBook(dest, strLabel, "send");
}
else if (mi->second.name != strLabel)
{
wallet->SetAddressBook(dest, strLabel, ""); // "" means don't change purpose
}
}
}
Q_EMIT coinsSent(wallet, rcp, transaction_array);
}
checkBalanceChanged(); // update balance immediately, otherwise there could be a short noticeable delay until pollBalanceChanged hits
return SendCoinsReturn(OK);
}
OptionsModel *WalletModel::getOptionsModel()
{
return optionsModel;
}
AddressTableModel *WalletModel::getAddressTableModel()
{
return addressTableModel;
}
TransactionTableModel *WalletModel::getTransactionTableModel()
{
return transactionTableModel;
}
RecentRequestsTableModel *WalletModel::getRecentRequestsTableModel()
{
return recentRequestsTableModel;
}
WalletModel::EncryptionStatus WalletModel::getEncryptionStatus() const
{
if(!wallet->IsCrypted())
{
return Unencrypted;
}
else if(wallet->IsLocked(true))
{
return Locked;
}
else if (wallet->IsLocked())
{
return UnlockedForMixingOnly;
}
else
{
return Unlocked;
}
}
bool WalletModel::setWalletEncrypted(bool encrypted, const SecureString &passphrase)
{
if(encrypted)
{
// Encrypt
return wallet->EncryptWallet(passphrase);
}
else
{
// Decrypt -- TODO; not supported yet
return false;
}
}
bool WalletModel::setWalletLocked(bool locked, const SecureString &passPhrase, bool fMixing)
{
if(locked)
{
// Lock
return wallet->Lock(fMixing);
}
else
{
// Unlock
return wallet->Unlock(passPhrase, fMixing);
}
}
bool WalletModel::changePassphrase(const SecureString &oldPass, const SecureString &newPass)
{
bool retval;
{
LOCK(wallet->cs_wallet);
wallet->Lock(); // Make sure wallet is locked before attempting pass change
retval = wallet->ChangeWalletPassphrase(oldPass, newPass);
}
return retval;
}
bool WalletModel::backupWallet(const QString &filename)
{
return BackupWallet(*wallet, filename.toLocal8Bit().data());
}
// Handlers for core signals
static void NotifyKeyStoreStatusChanged(WalletModel *walletmodel, CCryptoKeyStore *wallet)
{
qDebug() << "NotifyKeyStoreStatusChanged";
QMetaObject::invokeMethod(walletmodel, "updateStatus", Qt::QueuedConnection);
}
static void NotifyAddressBookChanged(WalletModel *walletmodel, CWallet *wallet,
const CTxDestination &address, const std::string &label, bool isMine,
const std::string &purpose, ChangeType status)
{
QString strAddress = QString::fromStdString(CBitcoinAddress(address).ToString());
QString strLabel = QString::fromStdString(label);
QString strPurpose = QString::fromStdString(purpose);
qDebug() << "NotifyAddressBookChanged: " + strAddress + " " + strLabel + " isMine=" + QString::number(isMine) + " purpose=" + strPurpose + " status=" + QString::number(status);
QMetaObject::invokeMethod(walletmodel, "updateAddressBook", Qt::QueuedConnection,
Q_ARG(QString, strAddress),
Q_ARG(QString, strLabel),
Q_ARG(bool, isMine),
Q_ARG(QString, strPurpose),
Q_ARG(int, status));
}
static void NotifyTransactionChanged(WalletModel *walletmodel, CWallet *wallet, const uint256 &hash, ChangeType status)
{
Q_UNUSED(wallet);
Q_UNUSED(hash);
Q_UNUSED(status);
QMetaObject::invokeMethod(walletmodel, "updateTransaction", Qt::QueuedConnection);
}
static void ShowProgress(WalletModel *walletmodel, const std::string &title, int nProgress)
{
// emits signal "showProgress"
QMetaObject::invokeMethod(walletmodel, "showProgress", Qt::QueuedConnection,
Q_ARG(QString, QString::fromStdString(title)),
Q_ARG(int, nProgress));
}
static void NotifyWatchonlyChanged(WalletModel *walletmodel, bool fHaveWatchonly)
{
QMetaObject::invokeMethod(walletmodel, "updateWatchOnlyFlag", Qt::QueuedConnection,
Q_ARG(bool, fHaveWatchonly));
}
void WalletModel::subscribeToCoreSignals()
{
// Connect signals to wallet
wallet->NotifyStatusChanged.connect(boost::bind(&NotifyKeyStoreStatusChanged, this, _1));
wallet->NotifyAddressBookChanged.connect(boost::bind(NotifyAddressBookChanged, this, _1, _2, _3, _4, _5, _6));
wallet->NotifyTransactionChanged.connect(boost::bind(NotifyTransactionChanged, this, _1, _2, _3));
wallet->ShowProgress.connect(boost::bind(ShowProgress, this, _1, _2));
wallet->NotifyWatchonlyChanged.connect(boost::bind(NotifyWatchonlyChanged, this, _1));
}
void WalletModel::unsubscribeFromCoreSignals()
{
// Disconnect signals from wallet
wallet->NotifyStatusChanged.disconnect(boost::bind(&NotifyKeyStoreStatusChanged, this, _1));
wallet->NotifyAddressBookChanged.disconnect(boost::bind(NotifyAddressBookChanged, this, _1, _2, _3, _4, _5, _6));
wallet->NotifyTransactionChanged.disconnect(boost::bind(NotifyTransactionChanged, this, _1, _2, _3));
wallet->ShowProgress.disconnect(boost::bind(ShowProgress, this, _1, _2));
wallet->NotifyWatchonlyChanged.disconnect(boost::bind(NotifyWatchonlyChanged, this, _1));
}
// WalletModel::UnlockContext implementation
WalletModel::UnlockContext WalletModel::requestUnlock(bool fForMixingOnly)
{
EncryptionStatus encStatusOld = getEncryptionStatus();
// Wallet was completely locked
bool was_locked = (encStatusOld == Locked);
// Wallet was unlocked for mixing
bool was_mixing = (encStatusOld == UnlockedForMixingOnly);
// Wallet was unlocked for mixing and now user requested to fully unlock it
bool fMixingToFullRequested = !fForMixingOnly && was_mixing;
if(was_locked || fMixingToFullRequested) {
// Request UI to unlock wallet
Q_EMIT requireUnlock(fForMixingOnly);
}
EncryptionStatus encStatusNew = getEncryptionStatus();
// Wallet was locked, user requested to unlock it for mixing and failed to do so
bool fMixingUnlockFailed = fForMixingOnly && !(encStatusNew == UnlockedForMixingOnly);
// Wallet was unlocked for mixing, user requested to fully unlock it and failed
bool fMixingToFullFailed = fMixingToFullRequested && !(encStatusNew == Unlocked);
// If wallet is still locked, unlock failed or was cancelled, mark context as invalid
bool fInvalid = (encStatusNew == Locked) || fMixingUnlockFailed || fMixingToFullFailed;
// Wallet was not locked in any way or user tried to unlock it for mixing only and succeeded, keep it unlocked
bool fKeepUnlocked = !was_locked || (fForMixingOnly && !fMixingUnlockFailed);
return UnlockContext(this, !fInvalid, !fKeepUnlocked, was_mixing);
}
WalletModel::UnlockContext::UnlockContext(WalletModel *wallet, bool valid, bool was_locked, bool was_mixing):
wallet(wallet),
valid(valid),
was_locked(was_locked),
was_mixing(was_mixing)
{
}
WalletModel::UnlockContext::~UnlockContext()
{
if(valid && (was_locked || was_mixing))
{
wallet->setWalletLocked(true, "", was_mixing);
}
}
void WalletModel::UnlockContext::CopyFrom(const UnlockContext& rhs)
{
// Transfer context; old object no longer relocks wallet
*this = rhs;
rhs.was_locked = false;
rhs.was_mixing = false;
}
bool WalletModel::getPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const
{
return wallet->GetPubKey(address, vchPubKeyOut);
}
bool WalletModel::havePrivKey(const CKeyID &address) const
{
return wallet->HaveKey(address);
}
// returns a list of COutputs from COutPoints
void WalletModel::getOutputs(const std::vector<COutPoint>& vOutpoints, std::vector<COutput>& vOutputs)
{
LOCK2(cs_main, wallet->cs_wallet);
BOOST_FOREACH(const COutPoint& outpoint, vOutpoints)
{
if (!wallet->mapWallet.count(outpoint.hash)) continue;
int nDepth = wallet->mapWallet[outpoint.hash].GetDepthInMainChain();
if (nDepth < 0) continue;
COutput out(&wallet->mapWallet[outpoint.hash], outpoint.n, nDepth, true);
vOutputs.push_back(out);
}
}
bool WalletModel::isSpent(const COutPoint& outpoint) const
{
LOCK2(cs_main, wallet->cs_wallet);
return wallet->IsSpent(outpoint.hash, outpoint.n);
}
// AvailableCoins + LockedCoins grouped by wallet address (put change in one group with wallet address)
void WalletModel::listCoins(std::map<QString, std::vector<COutput> >& mapCoins) const
{
std::vector<COutput> vCoins;
wallet->AvailableCoins(vCoins);
LOCK2(cs_main, wallet->cs_wallet); // ListLockedCoins, mapWallet
std::vector<COutPoint> vLockedCoins;
wallet->ListLockedCoins(vLockedCoins);
// add locked coins
BOOST_FOREACH(const COutPoint& outpoint, vLockedCoins)
{
if (!wallet->mapWallet.count(outpoint.hash)) continue;
int nDepth = wallet->mapWallet[outpoint.hash].GetDepthInMainChain();
if (nDepth < 0) continue;
COutput out(&wallet->mapWallet[outpoint.hash], outpoint.n, nDepth, true);
if (outpoint.n < out.tx->vout.size() && wallet->IsMine(out.tx->vout[outpoint.n]) == ISMINE_SPENDABLE)
vCoins.push_back(out);
}
BOOST_FOREACH(const COutput& out, vCoins)
{
COutput cout = out;
while (wallet->IsChange(cout.tx->vout[cout.i]) && cout.tx->vin.size() > 0 && wallet->IsMine(cout.tx->vin[0]))
{
if (!wallet->mapWallet.count(cout.tx->vin[0].prevout.hash)) break;
cout = COutput(&wallet->mapWallet[cout.tx->vin[0].prevout.hash], cout.tx->vin[0].prevout.n, 0, true);
}
CTxDestination address;
if(!out.fSpendable || !ExtractDestination(cout.tx->vout[cout.i].scriptPubKey, address))
continue;
mapCoins[QString::fromStdString(CBitcoinAddress(address).ToString())].push_back(out);
}
}
bool WalletModel::isLockedCoin(uint256 hash, unsigned int n) const
{
LOCK2(cs_main, wallet->cs_wallet);
return wallet->IsLockedCoin(hash, n);
}
void WalletModel::lockCoin(COutPoint& output)
{
LOCK2(cs_main, wallet->cs_wallet);
wallet->LockCoin(output);
}
void WalletModel::unlockCoin(COutPoint& output)
{
LOCK2(cs_main, wallet->cs_wallet);
wallet->UnlockCoin(output);
}
void WalletModel::listLockedCoins(std::vector<COutPoint>& vOutpts)
{
LOCK2(cs_main, wallet->cs_wallet);
wallet->ListLockedCoins(vOutpts);
}
void WalletModel::loadReceiveRequests(std::vector<std::string>& vReceiveRequests)
{
LOCK(wallet->cs_wallet);
BOOST_FOREACH(const PAIRTYPE(CTxDestination, CAddressBookData)& item, wallet->mapAddressBook)
BOOST_FOREACH(const PAIRTYPE(std::string, std::string)& item2, item.second.destdata)
if (item2.first.size() > 2 && item2.first.substr(0,2) == "rr") // receive request
vReceiveRequests.push_back(item2.second);
}
bool WalletModel::saveReceiveRequest(const std::string &sAddress, const int64_t nId, const std::string &sRequest)
{
CTxDestination dest = CBitcoinAddress(sAddress).Get();
std::stringstream ss;
ss << nId;
std::string key = "rr" + ss.str(); // "rr" prefix = "receive request" in destdata
LOCK(wallet->cs_wallet);
if (sRequest.empty())
return wallet->EraseDestData(dest, key);
else
return wallet->AddDestData(dest, key, sRequest);
}
|
#define CATCH_CONFIG_MAIN
#include "../third-party/catch2/single_include/catch2/catch.hpp"
#include "test-utilties.h"
using Catch::Matchers::Contains;
class UniqueTestsFixture {
protected:
std::string getOutputSbsPath() { return std::to_string(++uniqueId) + "_output.sbs"; }
std::string getOutputNlpPath() { return std::to_string(++uniqueId) + "_output.nlp"; }
private:
static size_t uniqueId;
};
size_t UniqueTestsFixture::uniqueId = 0;
// there just to setup the loggers
TEST_CASE("STATIC_REQUIRE showcase", "[traits]") {
logger::InitLoggers("");
STATIC_REQUIRE(std::is_void<void>::value);
STATIC_REQUIRE_FALSE(std::is_void<int>::value);
}
TEST_CASE_METHOD(UniqueTestsFixture, "main-standard-composition()") {
// setup (before each test) -- done sequentially before each test gets spawned off in parallel
const auto sbs_output = getOutputSbsPath();
const auto nlp_output = getOutputNlpPath();
auto logger = logger::GetOrCreateLogger("main()");
const char *approach = "--composition-approach standard";
SECTION("empty_hyp_ctm") {
const auto result = exec(command("wer", approach, "empty.ref.txt", "empty.hyp.ctm", sbs_output));
REQUIRE_THAT(result, Contains("WER: 3/3 = 1.0000"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:3 SUB:0"));
}
SECTION("empty_hyp_nlp") {
const auto result = exec(command("wer", approach, "empty.ref.txt", "empty.hyp.nlp", sbs_output));
REQUIRE_THAT(result, Contains("WER: 3/3 = 1.0000"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:3 SUB:0"));
}
SECTION("empty_hyp_txt") {
const auto result = exec(command("wer", approach, "empty.ref.txt", "empty.hyp.txt", sbs_output));
REQUIRE_THAT(result, Contains("WER: 3/3 = 1.0000"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:3 SUB:0"));
}
SECTION("empty_ref_ctm") {
const auto result = exec(command("wer", approach, "empty.hyp.ctm", "empty.ref.txt", sbs_output));
REQUIRE_THAT(result, Contains("WER: 3/0 ="));
REQUIRE_THAT(result, Contains("WER: INS:3 DEL:0 SUB:0"));
}
SECTION("empty_ref_nlp") {
const auto result = exec(command("wer", approach, "empty.hyp.nlp", "empty.ref.txt", sbs_output));
REQUIRE_THAT(result, Contains("WER: 3/0 ="));
REQUIRE_THAT(result, Contains("WER: INS:3 DEL:0 SUB:0"));
}
SECTION("empty_ref_txt") {
const auto result = exec(command("wer", approach, "empty.hyp.txt", "empty.ref.txt", sbs_output));
REQUIRE_THAT(result, Contains("WER: 3/0 ="));
REQUIRE_THAT(result, Contains("WER: INS:3 DEL:0 SUB:0"));
}
SECTION("syn_1") {
const auto result = exec(command("wer", approach, "syn_1.ref.txt", "syn_1.hyp.txt", sbs_output));
const auto testFile = std::string{TEST_DATA} + "syn_1.hyp.sbs";
REQUIRE_THAT(result, Contains("WER: 8/21 = 0.3810"));
REQUIRE_THAT(result, Contains("WER: INS:3 DEL:2 SUB:3"));
REQUIRE(compareFiles(sbs_output.c_str(), testFile.c_str()));
}
SECTION("syn_1 (with synonyms)") {
const auto result = exec(command("wer", approach, "syn_1.ref.txt", "syn_1.hyp.txt", sbs_output, "", TEST_SYNONYMS));
REQUIRE_THAT(result, Contains("WER: 5/21 = 0.2381"));
REQUIRE_THAT(result, Contains("WER: INS:3 DEL:2 SUB:0"));
}
SECTION("syn_2") {
const auto result = exec(command("wer", approach, "syn_2.ref.txt", "syn_2.hyp.txt", sbs_output, "", TEST_SYNONYMS));
REQUIRE_THAT(result, Contains("WER: 0/1 = 0.0000"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:0 SUB:0"));
}
SECTION("syn_3") {
const auto result = exec(command("wer", approach, "syn_3.ref.txt", "syn_3.hyp.txt", sbs_output, "", TEST_SYNONYMS));
REQUIRE_THAT(result, Contains("WER: 0/2 = 0.0000"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:0 SUB:0"));
}
SECTION("syn_4") {
const auto result = exec(command("wer", approach, "syn_4.ref.txt", "syn_4.hyp.txt", sbs_output, "", TEST_SYNONYMS));
REQUIRE_THAT(result, Contains("WER: 2/2 = 1.0000"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:1 SUB:1"));
}
SECTION("syn_5") {
const auto result = exec(command("wer", approach, "syn_5.ref.txt", "syn_5.hyp.txt", sbs_output, "", TEST_SYNONYMS));
REQUIRE_THAT(result, Contains("WER: 1/2 = 0.5"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:1 SUB:0"));
}
SECTION("syn_6") {
const auto result = exec(command("wer", approach, "syn_6.ref.txt", "syn_6.hyp.txt", sbs_output, "", TEST_SYNONYMS));
REQUIRE_THAT(result, Contains("WER: 1/5 = 0.2"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:1 SUB:0"));
}
SECTION("syn_6 (with cutoffs disabled)") {
const auto result =
exec(command("wer", approach, "syn_6.ref.txt", "syn_6.hyp.txt", sbs_output, "", TEST_SYNONYMS, nullptr, true));
REQUIRE_THAT(result, Contains("WER: 2/5 = 0.4"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:1 SUB:1"));
}
// synonyms inside a label
SECTION("syn_7 (hyp1)") {
const auto result = exec(command("wer", approach, "syn_7.ref.nlp", "syn_7.hyp.txt", sbs_output, "",
"syn_7.synonym.rules.txt", "syn_7.norm.json"));
REQUIRE_THAT(result, Contains("WER: 1/20 = 0.0500"));
REQUIRE_THAT(result, Contains("WER: INS:1 DEL:0 SUB:0"));
}
SECTION("syn_7 (hyp2)") {
const auto result = exec(command("wer", approach, "syn_7.ref.nlp", "syn_7.hyp2.txt", sbs_output, "",
"syn_7.synonym.rules.txt", "syn_7.norm.json"));
REQUIRE_THAT(result, Contains("WER: 2/20 = 0.1000"));
REQUIRE_THAT(result, Contains("WER: INS:1 DEL:1 SUB:0"));
}
SECTION("syn_7 (hyp3)") {
const auto result = exec(command("wer", approach, "syn_7.ref.nlp", "syn_7.hyp3.txt", sbs_output, "",
"syn_7.synonym.rules.txt", "syn_7.norm.json"));
REQUIRE_THAT(result, Contains("WER: 1/19 = 0.0526"));
REQUIRE_THAT(result, Contains("WER: INS:1 DEL:0 SUB:0"));
}
SECTION("syn_7 (hyp4)") {
const auto result = exec(command("wer", approach, "syn_7_ref4.nlp", "syn_7.hyp4.txt", sbs_output, "",
"syn_7.synonym.rules.txt", "syn_7.norm.json"));
REQUIRE_THAT(result, Contains("WER: 0/2 = 0.0000"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:0 SUB:0"));
REQUIRE_THAT(result, Contains("MONEY WER: 0/0 = -nan"));
}
SECTION("syn_9") {
const auto result =
exec(command("wer", approach, "syn_9.ref.txt", "syn_9.hyp.txt", sbs_output, "", "syn_9.synonym.rules.txt"));
REQUIRE_THAT(result, Contains("WER: 0/6 = 0.0"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:0 SUB:0"));
}
SECTION("syn_10") {
const auto result =
exec(command("wer", approach, "syn_10.ref.txt", "syn_10.hyp.txt", sbs_output, "", "syn_9.synonym.rules.txt"));
REQUIRE_THAT(result, Contains("WER: 1/6 = 0.1667"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:0 SUB:1"));
}
// synonyms for noise codes
SECTION("noise_1 (wer -- hyp1)") {
const auto result =
exec(command("wer", approach, "noise_1.ref.nlp", "noise.hyp1.ctm", sbs_output, "", TEST_SYNONYMS));
REQUIRE_THAT(result, Contains("WER: 2/12 = 0.1667"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:2 SUB:0"));
}
SECTION("noise_1 (wer -- hyp2)") {
const auto result =
exec(command("wer", approach, "noise_1.ref.nlp", "noise.hyp2.ctm", sbs_output, "", TEST_SYNONYMS));
REQUIRE_THAT(result, Contains("WER: 0/12 = 0.0"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:0 SUB:0"));
}
SECTION("noise_1 (align - hyp1)") {
const auto result =
exec(command("align", approach, "noise_1.ref.nlp", "noise.hyp1.ctm", "", nlp_output, TEST_SYNONYMS));
const auto testFile = std::string{TEST_DATA} + "noise_1.hyp1.aligned";
REQUIRE(compareFiles(nlp_output.c_str(), testFile.c_str()));
}
SECTION("noise_1 (align - hyp2)") {
const auto result =
exec(command("align", approach, "noise_1.ref.nlp", "noise.hyp2.ctm", "", nlp_output, TEST_SYNONYMS));
const auto testFile = std::string{TEST_DATA} + "noise_1.hyp2.aligned";
REQUIRE(compareFiles(nlp_output.c_str(), testFile.c_str()));
}
// wer around speaker information
SECTION("speaker_1") {
const auto result = exec(command("wer", approach, "speaker_1.ref.nlp", "speaker_1.hyp.txt", sbs_output, "",
TEST_SYNONYMS, nullptr, false, 3));
REQUIRE_THAT(result, Contains("Speaker switch WER: 1/6 = 0.1667"));
REQUIRE_THAT(result, Contains("speaker 1 WER: 1/10 = 0.1000"));
REQUIRE_THAT(result, Contains("speaker 2 WER: 4/11 = 0.3636"));
}
SECTION("speaker_2") {
const auto result = exec(command("wer", approach, "speaker_2.ref.nlp", "speaker_2.hyp.txt", sbs_output, "",
TEST_SYNONYMS, nullptr, false, 2));
REQUIRE_THAT(result, Contains("WER: 6/19 = 0.3158"));
REQUIRE_THAT(result, Contains("Speaker switch WER: 4/13 = 0.3077"));
REQUIRE_THAT(result, Contains("speaker 1 WER: 1/7 = 0.1429"));
REQUIRE_THAT(result, Contains("speaker 2 WER: 2/6 = 0.3333"));
REQUIRE_THAT(result, Contains("speaker 3 WER: 3/6 = 0.5000"));
}
SECTION("speaker_3") {
const auto result = exec(command("wer", approach, "noise_1.ref.nlp", "noise.hyp2.ctm", sbs_output, "",
TEST_SYNONYMS, nullptr, false, 25));
// Single speaker and super high context, should be nan
REQUIRE_THAT(result, Contains("Speaker switch WER: 0/0"));
REQUIRE_THAT(result, Contains("speaker 1 WER: 0/12 = 0.0000"));
}
SECTION("short file") {
const auto result = exec(command("wer", approach, "short.ref.nlp", "short.hyp.nlp", sbs_output, "", TEST_SYNONYMS));
REQUIRE_THAT(result, Contains("WER: 5/31 = 0.1613"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:2 SUB:2"));
}
SECTION("wer (nlp output)") {
const auto result =
exec(command("wer", approach, "short.ref.nlp", "short.hyp.nlp", sbs_output, nlp_output, TEST_SYNONYMS, nullptr, false, -1, "--disable-approx-alignment"));
const auto testFile = std::string{TEST_DATA} + "short.aligned.nlp";
REQUIRE(compareFiles(nlp_output.c_str(), testFile.c_str()));
REQUIRE_THAT(result, Contains("WER: 5/31 = 0.1613"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:2 SUB:2"));
}
SECTION("Case Metrics") {
const auto result = exec(command("wer", approach, "short.ref.nlp", "short.hyp.txt", sbs_output, nlp_output,
TEST_SYNONYMS, nullptr, false, -1, "--record-case-stats"));
const auto testFile = std::string{TEST_DATA} + "short.aligned.nlp";
REQUIRE(compareFiles(nlp_output.c_str(), testFile.c_str()));
REQUIRE_THAT(result, Contains("case WER, (matching words only): Precision:1.0"));
REQUIRE_THAT(result, Contains("case WER, (all including substitutions): Precision:0.77"));
}
// alignment tests
SECTION("align_1") {
const auto result = exec(command("align", approach, "align_1.ref.nlp", "align_1.hyp.ctm", "", nlp_output,
TEST_SYNONYMS, "align_1.norm.json"));
const auto testFile = std::string{TEST_DATA} + "align_1.ref.aligned.nlp";
REQUIRE(compareFiles(nlp_output.c_str(), testFile.c_str()));
REQUIRE_THAT(result, Contains("WER: 1/12 = 0.0833"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:1 SUB:0"));
}
SECTION("align_2") {
const auto result = exec(command("align", approach, "align_2.ref.nlp", "align_2.hyp.ctm", "", nlp_output,
TEST_SYNONYMS, "align_2.norm.json"));
const auto testFile = std::string{TEST_DATA} + "align_2.ref.aligned.nlp";
REQUIRE(compareFiles(nlp_output.c_str(), testFile.c_str()));
REQUIRE_THAT(result, Contains("WER: 2/10 = 0.2000"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:1 SUB:1"));
}
SECTION("align_3") {
const auto result = exec(command("align", approach, "align_3.ref.nlp", "align_3.hyp.ctm", "", nlp_output,
TEST_SYNONYMS, "align_3.norm.json"));
const auto testFile = std::string{TEST_DATA} + "align_3.ref.aligned.nlp";
REQUIRE(compareFiles(nlp_output.c_str(), testFile.c_str()));
REQUIRE_THAT(result, Contains("WER: 1/13 = 0.0769"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:1 SUB:0"));
}
// insertions and deletions within classes
SECTION("align_4 (insertion -- hyp1)") {
const auto result = exec(command("align", approach, "align_4.ref.nlp", "align_4.hyp1.ctm", "", nlp_output,
TEST_SYNONYMS, "align_4.norm.json"));
const auto testFile = std::string{TEST_DATA} + "align_4.ref.aligned1.nlp";
REQUIRE(compareFiles(nlp_output.c_str(), testFile.c_str()));
REQUIRE_THAT(result, Contains("WER: 1/13 = 0.0769"));
REQUIRE_THAT(result, Contains("WER: INS:1 DEL:0 SUB:0"));
REQUIRE_THAT(result, Contains("class CARDINAL WER: 1/3 = 0.3333"));
}
SECTION("align_4 (deletion -- hyp2)") {
const auto result = exec(command("align", approach, "align_4.ref.nlp", "align_4.hyp2.ctm", "", nlp_output,
TEST_SYNONYMS, "align_4.norm.json"));
const auto testFile = std::string{TEST_DATA} + "align_4.ref.aligned2.nlp";
REQUIRE(compareFiles(nlp_output.c_str(), testFile.c_str()));
REQUIRE_THAT(result, Contains("WER: 1/13 = 0.0769"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:1 SUB:0"));
REQUIRE_THAT(result, Contains("class CARDINAL WER: 1/3 = 0.3333"));
}
// insertions and deletions within synonyms
SECTION("align_5 (insertion -- hyp1)") {
const auto result =
exec(command("align", approach, "align_5.ref.nlp", "align_5.hyp1.ctm", "", nlp_output, TEST_SYNONYMS));
const auto testFile = std::string{TEST_DATA} + "align_5.ref.aligned1.nlp";
REQUIRE(compareFiles(nlp_output.c_str(), testFile.c_str()));
REQUIRE_THAT(result, Contains("WER: 1/12 = 0.0833"));
REQUIRE_THAT(result, Contains("WER: INS:1 DEL:0 SUB:0"));
}
SECTION("align_5 (deletion -- hyp2)") {
const auto result =
exec(command("align", approach, "align_5.ref.nlp", "align_5.hyp2.ctm", "", nlp_output, TEST_SYNONYMS));
const auto testFile = std::string{TEST_DATA} + "align_5.ref.aligned2.nlp";
REQUIRE_THAT(result, Contains("WER: 1/12 = 0.0833"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:1 SUB:0"));
REQUIRE(compareFiles(nlp_output.c_str(), testFile.c_str()));
}
SECTION("wer_tag wer") {
const auto testFile = std::string{TEST_DATA} + "twenty.hyp.sbs";
const auto result = exec(command("wer", approach, "twenty.ref.testing.nlp", "twenty.hyp.txt", sbs_output, "",
TEST_SYNONYMS, "twenty.ref.testing.norm.json"));
REQUIRE_THAT(result, Contains("Wer Entity ID 1 WER: 1/1 = 1.0000"));
REQUIRE_THAT(result, Contains("Wer Entity ID 0 WER: 1/2 = 0.5000"));
REQUIRE_THAT(result, Contains("Wer Entity ID 2 WER: 1/2 = 0.5000"));
REQUIRE_THAT(result, Contains("Wer Entity ID 3 WER: 1/3 = 0.3333"));
}
// Additional WER tests
SECTION("entity precision recall") {
const auto testFile = std::string{TEST_DATA} + "twenty.hyp.sbs";
logger->info("Entity precision recall 2020. sbs = {}", sbs_output);
const auto result = exec(command("wer", approach, "twenty.ref.nlp", "twenty.hyp.txt", sbs_output, "", TEST_SYNONYMS,
"twenty.norm.json", false, -1, "--pr_threshold 1"));
REQUIRE(compareFiles(sbs_output.c_str(), testFile.c_str()));
}
SECTION("bigram_1") {
const auto result = exec(command("wer", approach, "test1.ref.txt", "test1.hyp.txt", sbs_output));
REQUIRE_THAT(result, Contains("WER: 10/76 = 0.1316"));
REQUIRE_THAT(result, Contains("WER: INS:1 DEL:2 SUB:7"));
REQUIRE_THAT(result, Contains("WER: Precision:0.893333 Recall:0.881579"));
}
// test oracle WER calculation with lattice FST archive as hypothesis input
SECTION("oracle_1") {
const auto result = exec(
"./fstalign wer --ref ../sample_data/tests/oracle_1.ref.txt "
"--hyp ../sample_data/tests/oracle_1.hyp.fst "
"--symbols ../sample_data/tests/oracle_1.symbols.txt "
"--output-sbs " +
sbs_output);
REQUIRE_THAT(result, Contains("WER: 1/9 = 0.1111"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:1 SUB:0"));
}
// cleanup (after each test)
remove(sbs_output.c_str());
remove(nlp_output.c_str());
}
/*
Approach 2
*/
TEST_CASE_METHOD(UniqueTestsFixture, "main-adapted-composition()") {
// setup (before each test) -- done sequentially before each test gets spawned off in parallel
const auto sbs_output = getOutputSbsPath();
const auto nlp_output = getOutputNlpPath();
auto logger = logger::GetOrCreateLogger("main()");
const char *approach = "--composition-approach adapted";
SECTION("empty_hyp_ctm") {
const auto result = exec(command("wer", approach, "empty.ref.txt", "empty.hyp.ctm", sbs_output));
REQUIRE_THAT(result, Contains("WER: 3/3 = 1.0000"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:3 SUB:0"));
}
SECTION("empty_hyp_nlp") {
const auto result = exec(command("wer", approach, "empty.ref.txt", "empty.hyp.nlp", sbs_output));
REQUIRE_THAT(result, Contains("WER: 3/3 = 1.0000"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:3 SUB:0"));
}
SECTION("empty_hyp_txt") {
const auto result = exec(command("wer", approach, "empty.ref.txt", "empty.hyp.txt", sbs_output));
REQUIRE_THAT(result, Contains("WER: 3/3 = 1.0000"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:3 SUB:0"));
}
SECTION("empty_ref_ctm") {
const auto result = exec(command("wer", approach, "empty.hyp.ctm", "empty.ref.txt", sbs_output));
REQUIRE_THAT(result, Contains("WER: 3/0 ="));
REQUIRE_THAT(result, Contains("WER: INS:3 DEL:0 SUB:0"));
}
SECTION("empty_ref_nlp") {
const auto result = exec(command("wer", approach, "empty.hyp.nlp", "empty.ref.txt", sbs_output));
REQUIRE_THAT(result, Contains("WER: 3/0 ="));
REQUIRE_THAT(result, Contains("WER: INS:3 DEL:0 SUB:0"));
}
SECTION("empty_ref_txt") {
const auto result = exec(command("wer", approach, "empty.hyp.txt", "empty.ref.txt", sbs_output));
REQUIRE_THAT(result, Contains("WER: 3/0 ="));
REQUIRE_THAT(result, Contains("WER: INS:3 DEL:0 SUB:0"));
}
SECTION("syn_1") {
const auto result = exec(command("wer", approach, "syn_1.ref.txt", "syn_1.hyp.txt", sbs_output));
const auto testFile = std::string{TEST_DATA} + "syn_1.hyp.sbs";
REQUIRE_THAT(result, Contains("WER: 8/21 = 0.3810"));
REQUIRE_THAT(result, Contains("WER: INS:3 DEL:2 SUB:3"));
REQUIRE(compareFiles(sbs_output.c_str(), testFile.c_str()));
}
SECTION("syn_1 (with synonyms)") {
const auto result = exec(command("wer", approach, "syn_1.ref.txt", "syn_1.hyp.txt", sbs_output, "", TEST_SYNONYMS));
REQUIRE_THAT(result, Contains("WER: 5/21 = 0.2381"));
REQUIRE_THAT(result, Contains("WER: INS:3 DEL:2 SUB:0"));
}
SECTION("syn_2") {
const auto result = exec(command("wer", approach, "syn_2.ref.txt", "syn_2.hyp.txt", sbs_output, "", TEST_SYNONYMS));
REQUIRE_THAT(result, Contains("WER: 0/1 = 0.0000"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:0 SUB:0"));
}
SECTION("syn_3") {
const auto result = exec(command("wer", approach, "syn_3.ref.txt", "syn_3.hyp.txt", sbs_output, "", TEST_SYNONYMS));
REQUIRE_THAT(result, Contains("WER: 0/2 = 0.0000"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:0 SUB:0"));
}
SECTION("syn_4") {
const auto result = exec(command("wer", approach, "syn_4.ref.txt", "syn_4.hyp.txt", sbs_output, "", TEST_SYNONYMS));
REQUIRE_THAT(result, Contains("WER: 2/2 = 1.0000"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:1 SUB:1"));
}
SECTION("syn_5") {
const auto result = exec(command("wer", approach, "syn_5.ref.txt", "syn_5.hyp.txt", sbs_output, "", TEST_SYNONYMS));
REQUIRE_THAT(result, Contains("WER: 2/1 = 2.0"));
}
SECTION("syn_6") {
const auto result = exec(command("wer", approach, "syn_6.ref.txt", "syn_6.hyp.txt", sbs_output, "", TEST_SYNONYMS));
REQUIRE_THAT(result, Contains("WER: 1/5 = 0.2"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:1 SUB:0"));
}
SECTION("syn_6 (with cutoffs disabled)") {
const auto result =
exec(command("wer", approach, "syn_6.ref.txt", "syn_6.hyp.txt", sbs_output, "", TEST_SYNONYMS, nullptr, true));
REQUIRE_THAT(result, Contains("WER: 2/5 = 0.4"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:1 SUB:1"));
}
// synonyms inside a label
SECTION("syn_7 (hyp1)") {
const auto result = exec(command("wer", approach, "syn_7.ref.nlp", "syn_7.hyp.txt", sbs_output, "",
"syn_7.synonym.rules.txt", "syn_7.norm.json"));
REQUIRE_THAT(result, Contains("WER: 1/20 = 0.0500"));
REQUIRE_THAT(result, Contains("WER: INS:1 DEL:0 SUB:0"));
}
SECTION("syn_7 (hyp2)") {
const auto result = exec(command("wer", approach, "syn_7.ref.nlp", "syn_7.hyp2.txt", sbs_output, "",
"syn_7.synonym.rules.txt", "syn_7.norm.json"));
REQUIRE_THAT(result, Contains("WER: 4/18 = 0.2222"));
REQUIRE_THAT(result, Contains("WER: INS:2 DEL:0 SUB:2"));
}
SECTION("syn_7 (hyp3)") {
const auto result = exec(command("wer", approach, "syn_7.ref.nlp", "syn_7.hyp3.txt", sbs_output, "",
"syn_7.synonym.rules.txt", "syn_7.norm.json"));
REQUIRE_THAT(result, Contains("WER: 1/19 = 0.0526"));
REQUIRE_THAT(result, Contains("WER: INS:1 DEL:0 SUB:0"));
}
SECTION("syn_7 (hyp4)") {
const auto result = exec(command("wer", approach, "syn_7_ref4.nlp", "syn_7.hyp4.txt", sbs_output, "",
"syn_7.synonym.rules.txt", "syn_7.norm.json"));
REQUIRE_THAT(result, Contains("WER: 0/2 = 0.0000"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:0 SUB:0"));
REQUIRE_THAT(result, Contains("MONEY WER: 0/0 = -nan"));
}
SECTION("syn_9") {
const auto result =
exec(command("wer", approach, "syn_9.ref.txt", "syn_9.hyp.txt", sbs_output, "", "syn_9.synonym.rules.txt"));
REQUIRE_THAT(result, Contains("WER: 0/6 = 0.0"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:0 SUB:0"));
}
SECTION("syn_10") {
const auto result =
exec(command("wer", approach, "syn_10.ref.txt", "syn_10.hyp.txt", sbs_output, "", "syn_9.synonym.rules.txt"));
REQUIRE_THAT(result, Contains("WER: 1/6 = 0.1667"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:0 SUB:1"));
}
// synonyms for noise codes
SECTION("noise_1 (wer -- hyp1)") {
const auto result =
exec(command("wer", approach, "noise_1.ref.nlp", "noise.hyp1.ctm", sbs_output, "", TEST_SYNONYMS));
REQUIRE_THAT(result, Contains("WER: 2/12 = 0.1667"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:2 SUB:0"));
}
SECTION("noise_1 (wer -- hyp2)") {
const auto result =
exec(command("wer", approach, "noise_1.ref.nlp", "noise.hyp2.ctm", sbs_output, "", TEST_SYNONYMS));
REQUIRE_THAT(result, Contains("WER: 0/12 = 0.0"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:0 SUB:0"));
}
SECTION("noise_1 (align - hyp1)") {
const auto result =
exec(command("align", approach, "noise_1.ref.nlp", "noise.hyp1.ctm", "", nlp_output, TEST_SYNONYMS));
const auto testFile = std::string{TEST_DATA} + "noise_1.hyp1.aligned";
REQUIRE(compareFiles(nlp_output.c_str(), testFile.c_str()));
}
SECTION("noise_1 (align - hyp2)") {
const auto result =
exec(command("align", approach, "noise_1.ref.nlp", "noise.hyp2.ctm", "", nlp_output, TEST_SYNONYMS));
const auto testFile = std::string{TEST_DATA} + "noise_1.hyp2.aligned";
REQUIRE(compareFiles(nlp_output.c_str(), testFile.c_str()));
}
// wer around speaker information
SECTION("speaker_1") {
const auto result = exec(command("wer", approach, "speaker_1.ref.nlp", "speaker_1.hyp.txt", sbs_output, "",
TEST_SYNONYMS, nullptr, false, 3));
REQUIRE_THAT(result, Contains("Speaker switch WER: 1/6 = 0.1667"));
REQUIRE_THAT(result, Contains("speaker 1 WER: 1/10 = 0.1000"));
REQUIRE_THAT(result, Contains("speaker 2 WER: 4/11 = 0.3636"));
}
SECTION("speaker_2") {
const auto result = exec(command("wer", approach, "speaker_2.ref.nlp", "speaker_2.hyp.txt", sbs_output, "",
TEST_SYNONYMS, nullptr, false, 2));
REQUIRE_THAT(result, Contains("WER: 6/19 = 0.3158"));
REQUIRE_THAT(result, Contains("Speaker switch WER: 4/13 = 0.3077"));
REQUIRE_THAT(result, Contains("speaker 1 WER: 1/7 = 0.1429"));
REQUIRE_THAT(result, Contains("speaker 2 WER: 2/6 = 0.3333"));
REQUIRE_THAT(result, Contains("speaker 3 WER: 3/6 = 0.5000"));
}
SECTION("speaker_3") {
const auto result = exec(command("wer", approach, "noise_1.ref.nlp", "noise.hyp2.ctm", sbs_output, "",
TEST_SYNONYMS, nullptr, false, 25));
// Single speaker and super high context, should be nan
REQUIRE_THAT(result, Contains("Speaker switch WER: 0/0"));
REQUIRE_THAT(result, Contains("speaker 1 WER: 0/12 = 0.0000"));
}
SECTION("short file") {
const auto result = exec(command("wer", approach, "short.ref.nlp", "short.hyp.nlp", sbs_output, "", TEST_SYNONYMS));
REQUIRE_THAT(result, Contains("WER: 6/32 = 0.1875"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:3 SUB:3"));
}
SECTION("wer (nlp output)") {
const auto result =
exec(command("wer", approach, "short.ref.nlp", "short.hyp.nlp", sbs_output, nlp_output, TEST_SYNONYMS));
const auto testFile = std::string{TEST_DATA} + "short.aligned.strict.nlp";
REQUIRE(compareFiles(nlp_output.c_str(), testFile.c_str()));
REQUIRE_THAT(result, Contains("WER: 6/32 = 0.1875"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:3 SUB:3"));
}
// alignment tests
SECTION("align_1") {
const auto result = exec(command("align", approach, "align_1.ref.nlp", "align_1.hyp.ctm", "", nlp_output,
TEST_SYNONYMS, "align_1.norm.json"));
const auto testFile = std::string{TEST_DATA} + "align_1.ref.aligned.nlp";
REQUIRE(compareFiles(nlp_output.c_str(), testFile.c_str()));
REQUIRE_THAT(result, Contains("WER: 1/12 = 0.0833"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:1 SUB:0"));
}
SECTION("align_2") {
const auto result = exec(command("align", approach, "align_2.ref.nlp", "align_2.hyp.ctm", "", nlp_output,
TEST_SYNONYMS, "align_2.norm.json"));
const auto testFile = std::string{TEST_DATA} + "align_2.ref.aligned.nlp";
REQUIRE(compareFiles(nlp_output.c_str(), testFile.c_str()));
REQUIRE_THAT(result, Contains("WER: 2/10 = 0.2000"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:1 SUB:1"));
}
SECTION("align_3") {
const auto result = exec(command("align", approach, "align_3.ref.nlp", "align_3.hyp.ctm", "", nlp_output,
TEST_SYNONYMS, "align_3.norm.json"));
const auto testFile = std::string{TEST_DATA} + "align_3.ref.aligned.nlp";
REQUIRE(compareFiles(nlp_output.c_str(), testFile.c_str()));
REQUIRE_THAT(result, Contains("WER: 1/13 = 0.0769"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:1 SUB:0"));
}
// insertions and deletions within classes
SECTION("align_4 (insertion -- hyp1)") {
const auto result = exec(command("align", approach, "align_4.ref.nlp", "align_4.hyp1.ctm", "", nlp_output,
TEST_SYNONYMS, "align_4.norm.json"));
const auto testFile = std::string{TEST_DATA} + "align_4.ref.aligned1.nlp";
REQUIRE(compareFiles(nlp_output.c_str(), testFile.c_str()));
REQUIRE_THAT(result, Contains("WER: 1/13 = 0.0769"));
REQUIRE_THAT(result, Contains("WER: INS:1 DEL:0 SUB:0"));
REQUIRE_THAT(result, Contains("class CARDINAL WER: 1/3 = 0.3333"));
}
SECTION("align_4 (deletion -- hyp2)") {
const auto result = exec(command("align", approach, "align_4.ref.nlp", "align_4.hyp2.ctm", "", nlp_output,
TEST_SYNONYMS, "align_4.norm.json"));
const auto testFile = std::string{TEST_DATA} + "align_4.ref.aligned2.nlp";
REQUIRE(compareFiles(nlp_output.c_str(), testFile.c_str()));
REQUIRE_THAT(result, Contains("WER: 1/13 = 0.0769"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:1 SUB:0"));
REQUIRE_THAT(result, Contains("class CARDINAL WER: 1/3 = 0.3333"));
}
// insertions and deletions within synonyms
SECTION("align_5 (insertion -- hyp1)") {
const auto result =
exec(command("align", approach, "align_5.ref.nlp", "align_5.hyp1.ctm", "", nlp_output, TEST_SYNONYMS));
const auto testFile = std::string{TEST_DATA} + "align_5.ref.aligned1-2.nlp";
REQUIRE(compareFiles(nlp_output.c_str(), testFile.c_str()));
REQUIRE_THAT(result, Contains("WER: 3/11 = 0.2727"));
REQUIRE_THAT(result, Contains("WER: INS:2 DEL:0 SUB:1"));
}
SECTION("align_5 (deletion -- hyp2)") {
const auto result =
exec(command("align", approach, "align_5.ref.nlp", "align_5.hyp2.ctm", "", nlp_output, TEST_SYNONYMS));
const auto testFile = std::string{TEST_DATA} + "align_5.ref.aligned2-a2.nlp";
REQUIRE_THAT(result, Contains("WER: 1/11 = 0.0909"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:0 SUB:1"));
REQUIRE(compareFiles(nlp_output.c_str(), testFile.c_str()));
}
SECTION("wer_tag wer") {
const auto testFile = std::string{TEST_DATA} + "twenty.hyp.sbs";
auto cmd = command("wer", approach, "twenty.ref.testing.nlp", "twenty.hyp.txt", sbs_output, "", TEST_SYNONYMS,
"twenty.ref.testing.norm.json");
std::cout << "cmd = " << cmd << std::endl;
const auto result = exec(cmd);
REQUIRE_THAT(result, Contains("Wer Entity ID 1 WER: 1/1 = 1.0000"));
REQUIRE_THAT(result, Contains("Wer Entity ID 0 WER: 1/2 = 0.5000"));
REQUIRE_THAT(result, Contains("Wer Entity ID 2 WER: 1/2 = 0.5000"));
REQUIRE_THAT(result, Contains("Wer Entity ID 3 WER: 1/3 = 0.3333"));
}
// Additional WER tests
SECTION("entity precision recall") {
const auto testFile = std::string{TEST_DATA} + "twenty.hyp-a2.sbs";
logger->info("Entity precision recall 2020. sbs = {}", sbs_output);
const auto result = exec(command("wer", approach, "twenty.ref.nlp", "twenty.hyp.txt", sbs_output, "", TEST_SYNONYMS,
"twenty.norm.json", false, -1, "--pr_threshold 1"));
REQUIRE(compareFiles(sbs_output.c_str(), testFile.c_str()));
}
SECTION("bigram_1") {
const auto result = exec(command("wer", approach, "test1.ref.txt", "test1.hyp.txt", sbs_output));
REQUIRE_THAT(result, Contains("WER: 10/76 = 0.1316"));
REQUIRE_THAT(result, Contains("WER: INS:1 DEL:2 SUB:7"));
REQUIRE_THAT(result, Contains("WER: Precision:0.893333 Recall:0.881579"));
}
// test oracle WER calculation with lattice FST archive as hypothesis input
SECTION("oracle_1") {
const auto result = exec(
"./fstalign wer --ref ../sample_data/tests/oracle_1.ref.txt "
"--hyp ../sample_data/tests/oracle_1.hyp.fst "
"--symbols ../sample_data/tests/oracle_1.symbols.txt "
"--output-sbs " +
sbs_output);
REQUIRE_THAT(result, Contains("WER: 1/9 = 0.1111"));
REQUIRE_THAT(result, Contains("WER: INS:0 DEL:1 SUB:0"));
}
// cleanup (after each test)
remove(sbs_output.c_str());
remove(nlp_output.c_str());
}
|
<?hh // strict
namespace Waffle\Http\Message;
use namespace HH\Lib\Str;
use type Waffle\Contract\Http\Message\StreamInterface;
use type Waffle\Contract\Http\Message\UploadedFileInterface;
use type Waffle\Contract\Http\Message\UploadedFileError;
use function fopen;
class UploadedFile implements UploadedFileInterface
{
private bool $moved = false;
public function __construct(
private StreamInterface $stream,
private ?int $size,
private UploadedFileError $error,
private ?string $clientFilename = null,
private ?string $clientMediaType = null
) {}
/**
* @return bool return true if there is no upload error
*/
private function isOk(): bool
{
return UploadedFileError::ERROR_OK === $this->error;
}
/**
* @throws Exception\ExceptionInterface if is moved or not ok
*/
private function validateActive(): void
{
if (false === $this->isOk()) {
throw Exception\UploadedFileErrorException::dueToStreamUploadError();
}
if ($this->moved) {
throw new Exception\UploadedFileAlreadyMovedException();
}
}
public function getStream(): StreamInterface
{
$this->validateActive();
return $this->stream;
}
public function moveTo(string $targetPath): void
{
$this->validateActive();
if ('' === $targetPath) {
throw new Exception\InvalidArgumentException(
'Invalid path provided for move operation; must be a non-empty string'
);
}
$stream = $this->getStream();
if ($stream->isSeekable()) {
$stream->rewind();
}
$handle = fopen($targetPath, 'w');
if (false === $handle) {
throw Exception\UploadedFileErrorException::dueToUnwritablePath();
}
$this->copyToStream($stream, new Stream($handle));
$this->moved = true;
}
public function getSize(): ?int
{
return $this->size;
}
public function getError(): UploadedFileError
{
return $this->error;
}
public function getClientFilename(): ?string
{
return $this->clientFilename;
}
public function getClientMediaType(): ?string
{
return $this->clientMediaType;
}
/**
* Copy the contents of a stream into another stream until the given number
* of bytes have been read.
*
* @param StreamInterface $source Stream to read from
* @param StreamInterface $dest Stream to write to
* @param int $maxLen Maximum number of bytes to read. Pass -1
* to read the entire stream
*
* @throws \RuntimeException on error
*/
private function copyToStream(StreamInterface $source, StreamInterface $dest,int $maxLen = -1): void
{
if ($maxLen === -1) {
while (!$source->eof()) {
if (!$dest->write($source->read(1048576))) {
break;
}
}
return;
}
$bytes = 0;
while (!$source->eof()) {
$buf = $source->read($maxLen - $bytes);
if (!($len = Str\length($buf))) {
break;
}
$bytes += $len;
$dest->write($buf);
if ($bytes === $maxLen) {
break;
}
}
}
}
|
/* Copyright (C) 2013-2016 David 'Mokon' Bond, All Rights Reserved */
#include <visum/events/repeats/Weekly.hpp>
CEREAL_REGISTER_TYPE(visum::Weekly)
|
SECTION code_fp_math48
PUBLIC cm48_sccz80p_ifix
EXTERN am48_dfix32
; sccz80 float primitive
; Convert math48 float to signed long
;
; enter : AC'(BCDEHL') = double x
;
; exit : DEHL = (long)(x) truncates (round toward zero)
;
; uses : AF, BC, DE, HL, AF', BC', DE', HL'
defc cm48_sccz80p_ifix = am48_dfix32
|
; A136252: a(n) = a(n-1) + 2*a(n-2) - 2*a(n-3).
; 1,3,5,9,13,21,29,45,61,93,125,189,253,381,509,765,1021,1533,2045,3069,4093,6141,8189,12285,16381,24573,32765,49149,65533,98301,131069,196605,262141,393213,524285,786429,1048573,1572861,2097149,3145725,4194301,6291453,8388605,12582909,16777213,25165821,33554429,50331645,67108861,100663293,134217725,201326589,268435453,402653181,536870909,805306365,1073741821,1610612733,2147483645,3221225469,4294967293,6442450941,8589934589,12884901885,17179869181,25769803773,34359738365,51539607549,68719476733
mov $2,$0
div $2,2
lpb $2
sub $0,$2
mul $0,2
sub $2,1
lpe
mul $0,2
add $0,1
|
; A001596: a(n) = 7^n + n^7.
; 1,8,177,2530,18785,94932,397585,1647086,7861953,45136576,292475249,1996813914,13877119009,96951758924,678328486353,4747732369318,33233199005057,232630924325880,1628414210130481,11398896079244882,79792267577612001,558545865884372548,3909821051077345937,27368747343485741790,191581231385152885825,1341068619670068416432,9387480337655786115825,65712362363544740492746,459986536544753453905313,3219905755813196976713916,22539340290692279957863249,157775382034845834127656854,1104427674243920680665037569
mov $1,7
pow $1,$0
pow $0,7
add $1,$0
mov $0,$1
|
; A178487: a(n) = floor(n^(1/5)): integer part of fifth root of n.
; 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
add $0,1
mul $0,16
add $0,2
mov $1,-1
lpb $0
div $0,23
add $1,1
lpe
mov $0,$1
|
/**
* @author : xiaozhuai
* @date : 17/1/5
*/
#include <iostream>
#include <sstream>
#include <cxxurl/cxxurl_all.h>
using namespace std;
using namespace CXXUrl;
int main(int argc, char** argv){
ostringstream contentOutput;
Request request;
request.setUrl("http://localhost:3000/get");
request.setFollowLocation(true);
request.setContentOutput(&contentOutput);
CURLcode res = request.get();
cout << "------------ Code ------------" << endl
<< res << endl
<< "----------- Content ----------" << endl
<< contentOutput.str() << endl
<< flush;
} |
; A168095: a(n) = number of natural numbers m such that n - 5 <= m <= n + 5.
; 5,6,7,8,9,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11
mov $1,$0
trn $0,6
sub $1,$0
add $1,5
|
default rel ; This allows compilation without /largeaddressaware:no
segment .data
a dq 3
b dq 4
c dq 5
segment .text
global main ; tell linker about main
main:
mov rax, [a]
mul rax ; a^2
mov rbx, [b]
imul rbx, rbx ; b^2
mov rcx, [c]
imul rcx, rcx ; c^2
add rax, rbx ; a^2 + b^2
sub rax, rcx ; == c^2 ?
xor eax, eax
ret
|
;; Licensed to the .NET Foundation under one or more agreements.
;; The .NET Foundation licenses this file to you under the MIT license.
;; See the LICENSE file in the project root for more information.
#include "ksarm64.h"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DATA SECTIONS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
__tls_array equ 0x58 ;; offsetof(TEB, ThreadLocalStoragePointer)
POINTER_SIZE equ 0x08
;; TLS variables
AREA |.tls$|, DATA
ThunkParamSlot % 0x8
TEXTAREA
EXTERN _tls_index
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Interop Thunks Helpers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; RhCommonStub
;;
;; INPUT: xip0: thunk's data block
;;
;; TRASHES: x9, x10, x11, xip0
;;
LEAF_ENTRY RhCommonStub
;; There are arbitrary callers passing arguments with arbitrary signatures.
;; Custom calling convention:
;; xip0 pointer to the current thunk's data block (data contains 2 pointer values: context + target pointers)
brk 0xf000 ;; TODO: remove after debugging/testing stub
;; Save context data into the ThunkParamSlot thread-local variable
;; A pointer to the delegate and function pointer for open static delegate should have been saved in the thunk's context cell during thunk allocation
ldr x10, =_tls_index
ldr x10, [x10]
ldr x9, [xpr, #__tls_array]
ldr x9, [x9, x10 lsl #3] ;; x9 <- our TLS base
;; x9 = base address of TLS data
;; x10 = trashed
;; xip0 = address of context cell in thunk's data
;; store thunk address in thread static
ldr x10, [xip0]
ldr x11, =ThunkParamSlot
str x10, [x9, x11] ;; ThunkParamSlot <- context slot data
;; Now load the target address and jump to it.
ldr xip0, [xip0, #POINTER_SIZE]
ret xip0
LEAF_END RhCommonStub
;;
;; IntPtr RhGetCommonStubAddress()
;;
LEAF_ENTRY RhGetCommonStubAddress
ldr x0, =RhCommonStub
ret
LEAF_END RhGetCommonStubAddress
;;
;; IntPtr RhGetCurrentThunkContext()
;;
LEAF_ENTRY RhGetCurrentThunkContext
brk 0xf000 ;; TODO: remove after debugging/testing stub
ldr x1, =_tls_index
ldr x1, [x1]
ldr x0, [xpr, #__tls_array]
ldr x0, [x0, x1 lsl #3] ;; x0 <- our TLS base
ldr x1, =ThunkParamSlot
ldr x0, [x0, x1] ;; x0 <- ThunkParamSlot
ret
LEAF_END RhGetCurrentThunkContext
END
|
/*++
Copyright (c) 2006 Microsoft Corporation
Module Name:
smt_context_pp.cpp
Abstract:
SMT logical context: pretty printing
Author:
Leonardo de Moura (leonardo) 2008-02-21.
Revision History:
--*/
#include "smt/smt_context.h"
#include "ast/ast_ll_pp.h"
#include "ast/ast_pp.h"
#include "ast/ast_pp_util.h"
#include "util/stats.h"
namespace smt {
std::ostream& context::display_last_failure(std::ostream& out) const {
switch(m_last_search_failure) {
case OK:
return out << "OK";
case UNKNOWN:
return out << "UNKNOWN";
case MEMOUT:
return out << "MEMOUT";
case CANCELED:
return out << "CANCELED";
case NUM_CONFLICTS:
return out << "NUM_CONFLICTS";
case RESOURCE_LIMIT:
return out << "RESOURCE_LIMIT";
case THEORY:
if (!m_incomplete_theories.empty()) {
bool first = true;
for (theory* th : m_incomplete_theories) {
if (first) first = false; else out << " ";
out << th->get_name();
}
}
else {
out << "THEORY";
}
return out;
case QUANTIFIERS:
return out << "QUANTIFIERS";
}
UNREACHABLE();
return out << "?";
}
std::string context::last_failure_as_string() const {
std::string r;
switch(m_last_search_failure) {
case OK: r = m_unknown; break;
case MEMOUT: r = "memout"; break;
case CANCELED: r = "canceled"; break;
case NUM_CONFLICTS: r = "max-conflicts-reached"; break;
case THEORY: {
r = "(incomplete (theory";
for (theory* t : m_incomplete_theories) {
r += " ";
r += t->get_name();
}
r += "))";
break;
}
case RESOURCE_LIMIT: r = "(resource limits reached)"; break;
case QUANTIFIERS: r = "(incomplete quantifiers)"; break;
case UNKNOWN: r = m_unknown; break;
}
return r;
}
void context::display_asserted_formulas(std::ostream & out) const {
m_asserted_formulas.display_ll(out, get_pp_visited());
}
std::ostream& context::display_literal(std::ostream & out, literal l) const {
l.display_compact(out, m_bool_var2expr.c_ptr()); return out;
}
std::ostream& context::display_literals(std::ostream & out, unsigned num_lits, literal const * lits) const {
display_compact(out, num_lits, lits, m_bool_var2expr.c_ptr()); return out;
}
std::ostream& context::display_literal_verbose(std::ostream & out, literal lit) const {
return display_literals_verbose(out, 1, &lit);
}
std::ostream& context::display_literals_verbose(std::ostream & out, unsigned num_lits, literal const * lits) const {
display_verbose(out, m_manager, num_lits, lits, m_bool_var2expr.c_ptr(), "\n"); return out;
}
std::ostream& context::display_literal_smt2(std::ostream& out, literal l) const {
if (l.sign())
out << " (not " << mk_bounded_pp(bool_var2expr(l.var()), m_manager, 10) << ") ";
else
out << " " << mk_bounded_pp(bool_var2expr(l.var()), m_manager, 10) << " ";
return out;
}
std::ostream& context::display_literals_smt2(std::ostream& out, unsigned num_lits, literal const* lits) const {
for (unsigned i = 0; i < num_lits; ++i) {
display_literal_smt2(out, lits[i]) << "\n";
}
return out;
}
void context::display_literal_info(std::ostream & out, literal l) const {
l.display_compact(out, m_bool_var2expr.c_ptr());
display_literal_smt2(out, l);
out << "relevant: " << is_relevant(bool_var2expr(l.var())) << ", val: " << get_assignment(l) << "\n";
}
void context::display_watch_list(std::ostream & out, literal l) const {
display_literal(out, l); out << " watch_list:\n";
watch_list & wl = const_cast<watch_list &>(m_watches[l.index()]);
watch_list::clause_iterator it = wl.begin_clause();
watch_list::clause_iterator end = wl.end_clause();
for (; it != end; ++it) {
display_clause(out, *it); out << "\n";
}
}
void context::display_watch_lists(std::ostream & out) const {
unsigned s = m_watches.size();
for (unsigned l_idx = 0; l_idx < s; l_idx++) {
literal l = to_literal(l_idx);
display_watch_list(out, l);
out << "\n";
}
}
void context::display_enode_defs(std::ostream & out) const {
for (enode * x : m_enodes) {
expr * n = x->get_owner();
ast_def_ll_pp(out, m_manager, n, get_pp_visited(), true, false);
}
}
void context::display_bool_var_defs(std::ostream & out) const {
unsigned num = get_num_bool_vars();
for (unsigned v = 0; v < num; v++) {
expr * n = m_bool_var2expr[v];
ast_def_ll_pp(out, m_manager, n, get_pp_visited(), true, false);
}
}
std::ostream& context::display_clause_detail(std::ostream & out, clause const * cls) const {
out << "lemma: " << cls->is_lemma() << "\n";
for (literal l : *cls) {
display_literal(out, l);
out << ", val: " << get_assignment(l) << ", lvl: " << get_assign_level(l)
<< ", ilvl: " << get_intern_level(l.var()) << ", var: " << l.var() << "\n"
<< mk_pp(bool_var2expr(l.var()), m_manager) << "\n\n";
}
return out;
}
std::ostream& context::display_clause(std::ostream & out, clause const * cls) const {
cls->display_compact(out, m_manager, m_bool_var2expr.c_ptr());
return out;
}
std::ostream& context::display_clause_smt2(std::ostream & out, clause const& cls) const {
cls.display_smt2(out, m_manager, m_bool_var2expr.c_ptr());
return out;
}
std::ostream& context::display_clauses(std::ostream & out, ptr_vector<clause> const & v) const {
for (clause* cp : v) {
display_clause_smt2(out, *cp);
out << "\n";
}
return out;
}
std::ostream& context::display_binary_clauses(std::ostream & out) const {
bool first = true;
unsigned l_idx = 0;
for (watch_list const& wl : m_watches) {
literal l1 = to_literal(l_idx++);
literal neg_l1 = ~l1;
literal const * it2 = wl.begin_literals();
literal const * end2 = wl.end_literals();
for (; it2 != end2; ++it2) {
literal l2 = *it2;
if (l1.index() < l2.index()) {
if (first) {
out << "binary clauses:\n";
first = false;
}
expr_ref t1(m_manager), t2(m_manager);
literal2expr(neg_l1, t1);
literal2expr(l2, t2);
expr_ref disj(m_manager.mk_or(t1, t2), m_manager);
out << disj << "\n";
#if 0
out << "(clause ";
display_literal(out, neg_l1);
out << " ";
display_literal(out, l2);
out << ")\n";
#endif
}
}
}
return out;
}
void context::display_assignment(std::ostream & out) const {
if (!m_assigned_literals.empty()) {
out << "current assignment:\n";
for (literal lit : m_assigned_literals) {
display_literal(out, lit);
if (!is_relevant(lit)) out << " n ";
out << ": ";
display_verbose(out, m_manager, 1, &lit, m_bool_var2expr.c_ptr());
out << "\n";
}
}
}
void context::display_assignment_as_smtlib2(std::ostream& out, symbol const& logic) const {
ast_smt_pp pp(m_manager);
pp.set_benchmark_name("lemma");
pp.set_status("unknown");
pp.set_logic(logic);
for (literal lit : m_assigned_literals) {
expr_ref n(m_manager);
literal2expr(lit, n);
pp.add_assumption(n);
}
pp.display_smt2(out, m_manager.mk_true());
}
void context::display_eqc(std::ostream & out) const {
bool first = true;
for (enode * x : m_enodes) {
expr * n = x->get_owner();
expr * r = x->get_root()->get_owner();
if (n != r) {
if (first) {
out << "equivalence classes:\n";
first = false;
}
out << "#" << n->get_id() << " -> #" << r->get_id() << ": ";
out << mk_pp(n, m_manager) << " -> " << mk_pp(r, m_manager) << "\n";
}
}
}
void context::display_app_enode_map(std::ostream & out) const {
if (!m_e_internalized_stack.empty()) {
out << "expression -> enode:\n";
unsigned sz = m_e_internalized_stack.size();
for (unsigned i = 0; i < sz; i++) {
expr * n = m_e_internalized_stack.get(i);
out << "(#" << n->get_id() << " -> e!" << i << ") ";
}
out << "\n";
}
}
void context::display_expr_bool_var_map(std::ostream & out) const {
if (!m_b_internalized_stack.empty()) {
out << "expression -> bool_var:\n";
unsigned sz = m_b_internalized_stack.size();
for (unsigned i = 0; i < sz; i++) {
expr * n = m_b_internalized_stack.get(i);
bool_var v = get_bool_var_of_id(n->get_id());
out << "(#" << n->get_id() << " -> " << literal(v, false) << ") ";
}
out << "\n";
}
}
void context::display_hot_bool_vars(std::ostream & out) const {
out << "hot bool vars:\n";
int num = get_num_bool_vars();
for (bool_var v = 0; v < num; v++) {
double val = get_activity(v)/m_bvar_inc;
if (val > 10.00) {
expr * n = m_b_internalized_stack.get(v);
out << "#";
out.width(5);
out << std::left;
out << n->get_id();
out << " ";
out.width(12);
out << std::right;
out << get_activity(v) << " ";
out.width(12);
out << val;
out << "\n";
}
}
}
void context::display_relevant_exprs(std::ostream & out) const {
m_relevancy_propagator->display(out);
}
void context::display_theories(std::ostream & out) const {
for (theory* th : m_theory_set) {
th->display(out);
}
}
void context::display(std::ostream & out) const {
get_pp_visited().reset();
out << "Logical context:\n";
out << "scope-lvl: " << m_scope_lvl << "\n";
out << "base-lvl: " << m_base_lvl << "\n";
out << "search-lvl: " << m_search_lvl << "\n";
out << "inconsistent(): " << inconsistent() << "\n";
out << "m_asserted_formulas.inconsistent(): " << m_asserted_formulas.inconsistent() << "\n";
display_bool_var_defs(out);
display_enode_defs(out);
display_asserted_formulas(out);
if (!m_aux_clauses.empty()) {
out << "auxiliary clauses:\n";
display_clauses(out, m_aux_clauses);
}
if (!m_lemmas.empty()) {
out << "lemmas:\n";
display_clauses(out, m_lemmas);
}
display_binary_clauses(out);
display_assignment(out);
display_eqc(out);
m_cg_table.display_compact(out);
m_case_split_queue->display(out);
display_expr_bool_var_map(out);
display_app_enode_map(out);
display_relevant_exprs(out);
display_theories(out);
display_decl2enodes(out);
display_hot_bool_vars(out);
}
void context::display_eq_detail(std::ostream & out, enode * n) const {
SASSERT(n->is_eq());
out << "#" << n->get_owner_id()
<< ", root: #" << n->get_root()->get_owner_id()
<< ", cg: #" << n->m_cg->get_owner_id()
<< ", val: " << get_assignment(enode2bool_var(n))
<< ", lhs: #" << n->get_arg(0)->get_owner_id()
<< ", rhs: #" << n->get_arg(1)->get_owner_id()
<< ", lhs->root: #" << n->get_arg(0)->get_root()->get_owner_id()
<< ", rhs->root: #" << n->get_arg(1)->get_root()->get_owner_id()
<< ", is_marked: " << n->is_marked()
<< ", is_relevant: " << is_relevant(n)
<< ", iscope_lvl: " << n->get_iscope_lvl() << "\n";
}
void context::display_parent_eqs(std::ostream & out, enode * n) const {
for (enode* parent : n->get_parents()) {
if (parent->is_eq())
display_eq_detail(out, parent);
}
}
void context::display_unsat_core(std::ostream & out) const {
for (expr* c : m_unsat_core) {
out << mk_pp(c, m_manager) << "\n";
}
}
void context::collect_statistics(::statistics & st) const {
st.update("conflicts", m_stats.m_num_conflicts);
st.update("decisions", m_stats.m_num_decisions);
st.update("propagations", m_stats.m_num_propagations + m_stats.m_num_bin_propagations);
st.update("binary propagations", m_stats.m_num_bin_propagations);
st.update("restarts", m_stats.m_num_restarts);
st.update("final checks", m_stats.m_num_final_checks);
st.update("added eqs", m_stats.m_num_add_eq);
st.update("mk clause", m_stats.m_num_mk_clause);
st.update("del clause", m_stats.m_num_del_clause);
st.update("dyn ack", m_stats.m_num_dyn_ack);
st.update("interface eqs", m_stats.m_num_interface_eqs);
st.update("max generation", m_stats.m_max_generation);
st.update("minimized lits", m_stats.m_num_minimized_lits);
st.update("num checks", m_stats.m_num_checks);
st.update("mk bool var", m_stats.m_num_mk_bool_var);
#if 0
// missing?
st.update("mk lit", m_stats.m_num_mk_lits);
st.update("sat conflicts", m_stats.m_num_sat_conflicts);
st.update("del bool var", m_stats.m_num_del_bool_var);
st.update("mk enode", m_stats.m_num_mk_enode);
st.update("del enode", m_stats.m_num_del_enode);
st.update("mk bin clause", m_stats.m_num_mk_bin_clause);
st.update("backwd subs", m_stats.m_num_bs);
st.update("backwd subs res", m_stats.m_num_bsr);
st.update("frwrd subs res", m_stats.m_num_fsr);
#endif
m_qmanager->collect_statistics(st);
m_asserted_formulas.collect_statistics(st);
for (theory* th : m_theory_set) {
th->collect_statistics(st);
}
}
void context::display_statistics(std::ostream & out) const {
::statistics st;
collect_statistics(st);
st.display(out);
}
void context::display_istatistics(std::ostream & out) const {
::statistics st;
collect_statistics(st);
st.display_internal(out);
}
void context::display_lemma_as_smt_problem(std::ostream & out, unsigned num_antecedents, literal const * antecedents, literal consequent, symbol const& logic) const {
ast_pp_util visitor(m_manager);
expr_ref_vector fmls(m_manager);
visitor.collect(fmls);
expr_ref n(m_manager);
for (unsigned i = 0; i < num_antecedents; i++) {
literal l = antecedents[i];
literal2expr(l, n);
fmls.push_back(std::move(n));
}
if (consequent != false_literal) {
literal2expr(~consequent, n);
fmls.push_back(std::move(n));
}
if (logic != symbol::null) out << "(set-logic " << logic << ")\n";
visitor.collect(fmls);
visitor.display_decls(out);
visitor.display_asserts(out, fmls, true);
out << "(check-sat)\n";
}
unsigned context::display_lemma_as_smt_problem(unsigned num_antecedents, literal const * antecedents, literal consequent, symbol const& logic) const {
std::stringstream strm;
strm << "lemma_" << (++m_lemma_id) << ".smt2";
std::ofstream out(strm.str());
TRACE("lemma", tout << strm.str() << "\n";);
display_lemma_as_smt_problem(out, num_antecedents, antecedents, consequent, logic);
out.close();
return m_lemma_id;
}
void context::display_lemma_as_smt_problem(std::ostream & out, unsigned num_antecedents, literal const * antecedents,
unsigned num_eq_antecedents, enode_pair const * eq_antecedents,
literal consequent, symbol const& logic) const {
ast_pp_util visitor(m_manager);
expr_ref_vector fmls(m_manager);
visitor.collect(fmls);
expr_ref n(m_manager);
for (unsigned i = 0; i < num_antecedents; i++) {
literal l = antecedents[i];
literal2expr(l, n);
fmls.push_back(n);
}
for (unsigned i = 0; i < num_eq_antecedents; i++) {
enode_pair const & p = eq_antecedents[i];
n = m_manager.mk_eq(p.first->get_owner(), p.second->get_owner());
fmls.push_back(n);
}
if (consequent != false_literal) {
literal2expr(~consequent, n);
fmls.push_back(n);
}
if (logic != symbol::null) out << "(set-logic " << logic << ")\n";
visitor.collect(fmls);
visitor.display_decls(out);
visitor.display_asserts(out, fmls, true);
out << "(check-sat)\n";
}
unsigned context::display_lemma_as_smt_problem(unsigned num_antecedents, literal const * antecedents,
unsigned num_eq_antecedents, enode_pair const * eq_antecedents,
literal consequent, symbol const& logic) const {
std::stringstream strm;
strm << "lemma_" << (++m_lemma_id) << ".smt2";
std::ofstream out(strm.str());
TRACE("lemma", tout << strm.str() << "\n";);
display_lemma_as_smt_problem(out, num_antecedents, antecedents, num_eq_antecedents, eq_antecedents, consequent, logic);
out.close();
return m_lemma_id;
}
/**
\brief Display enode definitions #n := (f #i_1 ... #i_n), where #i_k is the root
of the k-th argument of the enode #n.
*/
void context::display_normalized_enodes(std::ostream & out) const {
out << "normalized enodes:\n";
for (enode * n : m_enodes) {
out << "#";
out.width(5);
out << std::left << n->get_owner_id() << " #";
out.width(5);
out << n->get_root()->get_owner_id() << " := " << std::right;
unsigned num = n->get_owner()->get_num_args();
if (num > 0)
out << "(";
out << n->get_decl()->get_name();
if (!n->get_decl()->private_parameters())
display_parameters(out, n->get_decl()->get_num_parameters(), n->get_decl()->get_parameters());
for (unsigned i = 0; i < num; i++) {
expr * arg = n->get_owner()->get_arg(i);
if (e_internalized(arg)) {
enode * n = get_enode(arg)->get_root();
out << " #" << n->get_owner_id();
}
else {
out << " #" << arg->get_id();
}
}
if (num > 0)
out << ")";
if (is_relevant(n))
out << "\t*";
out << "\n";
}
}
void context::display_enodes_lbls(std::ostream & out) const {
for (enode* n : m_enodes) {
n->display_lbls(out);
}
}
void context::display_decl2enodes(std::ostream & out) const {
out << "decl2enodes:\n";
unsigned id = 0;
for (enode_vector const& v : m_decl2enodes) {
if (!v.empty()) {
out << "id " << id << " ->";
for (enode* n : v) {
out << " #" << n->get_owner_id();
}
out << "\n";
}
++id;
}
}
void context::display_subexprs_info(std::ostream & out, expr * n) const {
ptr_buffer<expr> todo;
todo.push_back(n);
while (!todo.empty()) {
expr * n = todo.back();
todo.pop_back();
out << "#";
out.width(6);
out << std::left << n->get_id();
out << ", relevant: " << is_relevant(n);
if (m_manager.is_bool(n)) {
out << ", val: ";
out.width(7);
out << std::right;
if (lit_internalized(n))
out << get_assignment(n);
else
out << "l_undef";
}
if (e_internalized(n)) {
enode * e = get_enode(n);
out << ", root: #" << e->get_root()->get_owner_id();
}
out << "\n";
if (is_app(n)) {
for (expr* arg : *to_app(n)) {
todo.push_back(arg);
}
}
}
}
std::ostream& context::display(std::ostream& out, b_justification j) const {
switch (j.get_kind()) {
case b_justification::AXIOM:
out << "axiom";
break;
case b_justification::BIN_CLAUSE:
out << "bin " << j.get_literal();
break;
case b_justification::CLAUSE: {
clause * cls = j.get_clause();
out << "clause ";
if (cls) out << literal_vector(cls->get_num_literals(), cls->begin());
if (cls) display_literals_smt2(out << "\n", cls->get_num_literals(), cls->begin());
break;
}
case b_justification::JUSTIFICATION: {
literal_vector lits;
const_cast<conflict_resolution&>(*m_conflict_resolution).justification2literals(j.get_justification(), lits);
out << "justification " << j.get_justification()->get_from_theory() << ": " << lits;
break;
}
default:
UNREACHABLE();
break;
}
return out << "\n";
}
void context::trace_assign(literal l, b_justification j, bool decision) const {
SASSERT(m_manager.has_trace_stream());
std::ostream & out = m_manager.trace_stream();
out << "[assign] ";
display_literal(out, l);
if (decision)
out << " decision";
out << " ";
display(out, j);
}
std::ostream& operator<<(std::ostream& out, enode_pp const& p) {
ast_manager& m = p.ctx.get_manager();
enode* n = p.n;
return out << "[#" << n->get_owner_id() << " " << mk_bounded_pp(n->get_owner(), m) << "]";
}
std::ostream& operator<<(std::ostream& out, enode_eq_pp const& p) {
return out << enode_pp(p.p.first, p.ctx) << " = " << enode_pp(p.p.second, p.ctx) << "\n";
}
};
|
; A083085: (2+(-5)^n)/3.
; 1,-1,9,-41,209,-1041,5209,-26041,130209,-651041,3255209,-16276041,81380209,-406901041,2034505209,-10172526041,50862630209,-254313151041,1271565755209,-6357828776041,31789143880209,-158945719401041,794728597005209,-3973642985026041
mov $1,-5
pow $1,$0
add $1,2
div $1,3
|
COMMENT @----------------------------------------------------------------------
Copyright (c) GeoWorks 1988 -- All Rights Reserved
PROJECT: PC GEOS
MODULE: CommonDesktop/CUtil
FILE: cutilManager.asm
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 8/89 Initial version
brianc 9/21/89 removed inclusion of geodeStruct.def
for protected mode changes
DESCRIPTION:
This file assembles the CUtil/ module of the desktop.
$Id: cutilManager.asm,v 1.2 98/06/03 13:51:12 joon Exp $
------------------------------------------------------------------------------@
_CUtil = 1
;-----------------------------------------------------------------------------
; Include common definitions
;-----------------------------------------------------------------------------
include cdesktopGeode.def
;-----------------------------------------------------------------------------
; Include definitions for this module
;-----------------------------------------------------------------------------
include disk.def
include fileEnum.def ; for FileEnum stuff
include vm.def ; for transfer stuff
include char.def ; for C_NONBRKSPACE
include sysstats.def
include initfile.def ; ini stuff for file chaching
include Internal/fileInt.def
include cutilVariable.def
include CFolder/cfolderConstant.def
;-----------------------------------------------------------------------------
; Include code
;-----------------------------------------------------------------------------
include cutilUtil.asm
include cutilCommon.asm
ifdef _VS150
include cutilFileOpRedwood.asm
else
include cutilFileOpHigh.asm
include cutilFileOpMiddle.asm
include cutilFileOpLow.asm
endif
include cutilDummyObj.asm
include cutilError.asm
if ERROR_CHECK
include cutilEC.asm
endif
if _NEWDESK
include cutilSpecialObj.asm
if _NEWDESKBA
include utilEntryLevel.asm
endif ; _NEWDESKBA
endif ; _NEWDESK
end
|
; A217330: The number of integer solutions to the equation x1 + x2 + x3 + x4 = n, with xi >= 0, and with x2 + x3 divisible by 3.
; 1,2,3,8,13,18,30,42,54,76,98,120,155,190,225,276,327,378,448,518,588,680,772,864,981,1098,1215,1360,1505,1650,1826,2002,2178,2388,2598,2808,3055,3302,3549,3836,4123,4410,4740,5070,5400,5776,6152,6528,6953,7378,7803,8280,8757,9234,9766,10298,10830,11420,12010,12600,13251,13902,14553,15268,15983,16698,17480,18262,19044,19896,20748,21600,22525,23450,24375,25376,26377,27378,28458,29538,30618,31780,32942,34104,35351,36598,37845,39180,40515,41850,43276,44702,46128,47648,49168,50688,52305,53922,55539,57256
mov $3,$0
add $3,1
mov $4,$0
lpb $3
mov $0,$4
sub $3,1
sub $0,$3
mov $6,$0
add $6,1
mov $7,0
mov $8,$0
lpb $6
mov $0,$8
mov $2,0
sub $6,1
sub $0,$6
mov $5,$0
mov $0,1
lpb $0
add $0,$5
sub $0,1
mod $0,3
mov $2,$5
add $2,1
lpe
add $7,$2
lpe
add $1,$7
lpe
mov $0,$1
|
; A270868: a(n) = n^4 + 3*n^3 + 8*n^2 + 9*n + 2.
; 2,23,92,263,614,1247,2288,3887,6218,9479,13892,19703,27182,36623,48344,62687,80018,100727,125228,153959,187382,225983,270272,320783,378074,442727,515348,596567,687038,787439,898472,1020863,1155362,1302743,1463804,1639367,1830278,2037407,2261648,2503919,2765162,3046343,3348452,3672503,4019534,4390607,4786808,5209247,5659058,6137399,6645452,7184423,7755542,8360063,8999264,9674447,10386938,11138087,11929268,12761879,13637342,14557103,15522632,16535423,17596994,18708887,19872668,21089927,22362278,23691359,25078832,26526383,28035722,29608583,31246724,32951927,34725998,36570767,38488088,40479839,42547922,44694263,46920812,49229543,51622454,54101567,56668928,59326607,62076698,64921319,67862612,70902743,74043902,77288303,80638184,84095807,87663458,91343447,95138108,99049799
mov $1,$0
add $0,1
pow $1,2
add $1,2
add $1,$0
add $0,$1
sub $0,1
mul $1,$0
mov $0,$1
sub $0,7
|
; A041274: Numerators of continued fraction convergents to sqrt(150).
; Submitted by Jon Maiga
; 12,49,1188,4801,116412,470449,11407188,46099201,1117788012,4517251249,109531817988,442644523201,10733000374812,43374646022449,1051724504913588,4250272665676801,103058268481156812,416483346590304049,10098658586648453988,40811117693184120001,989565483223067334012,3999073050585453456049,96967318697273950279188,391868347839681254572801,9501807666849624060026412,38399099015238177494678449,931080184032565883932309188,3762719835145501713223915201,91236356227524607001306274012
add $0,1
mov $3,1
lpb $0
sub $0,1
add $2,$3
mov $3,$1
mov $1,$2
dif $2,6
mul $2,12
add $3,$2
lpe
mov $0,$3
|
; ===============================================================
; Jun 2007
; ===============================================================
;
; uint zx_saddr2cx(void *saddr)
;
; Character x coordinate corresponding to screen address.
;
; ===============================================================
SECTION code_arch
PUBLIC asm_zx_saddr2cx
asm_zx_saddr2cx:
ld a,l
and $1f
ld l,a
ld h,0
ret
|
10001200: 83 7c 24 04 00 cmp DWORD PTR [esp+0x4],0x0
10001205: b8 10 10 01 10 mov eax,0x10011010
1000120a: 74 05 je 0x10001211
1000120c: b8 10 32 01 10 mov eax,0x10013210
10001211: c2 04 00 ret 0x4
10001214: cc int3
10001215: cc int3
10001216: cc int3
10001217: cc int3
10001218: cc int3
10001219: cc int3
1000121a: cc int3
1000121b: cc int3
1000121c: cc int3
1000121d: cc int3
1000121e: cc int3
1000121f: cc int3
|
FuchsiaPokecenterScript:
call Serial_TryEstablishingExternallyClockedConnection
jp EnableAutoTextBoxDrawing
FuchsiaPokecenterTextPointers:
dw FuchsiaHealNurseText
dw FuchsiaPokecenterText2
dw FuchsiaPokecenterText3
dw FuchsiaTradeNurseText
FuchsiaHealNurseText:
TX_POKECENTER_NURSE
FuchsiaPokecenterText2:
TX_FAR _FuchsiaPokecenterText1
db "@"
FuchsiaPokecenterText3:
TX_FAR _FuchsiaPokecenterText3
db "@"
FuchsiaTradeNurseText:
TX_CABLE_CLUB_RECEPTIONIST
|
; A100088: Expansion of (1-x^2)/((1-2x)(1+x^2)).
; 1,2,2,4,10,20,38,76,154,308,614,1228,2458,4916,9830,19660,39322,78644,157286,314572,629146,1258292,2516582,5033164,10066330,20132660,40265318,80530636,161061274,322122548,644245094,1288490188,2576980378
mov $1,1
mov $2,1
mov $5,1
lpb $0
sub $0,1
mov $1,$2
sub $3,$4
mov $4,$2
mov $2,$3
mov $3,$5
mul $5,2
lpe
add $1,$3
|
//
// Created by suncx on 2020/8/18.
//
#include "ServerSocket.h"
#include "Ext.h"
#include "InetAddress.h"
#include "ConsoleStream.h"
#include <unistd.h>
#include <netinet/tcp.h>
#include <cstring>
using reactor::net::ServerSocket;
ServerSocket::ServerSocket() : listen_fd(create_socket()) {}
ServerSocket::~ServerSocket() {
if (unlikely(::close(listen_fd) < 0))
RC_FATAL << "server socket(" << listen_fd << ") close error: " << ::strerror(errno);
}
int ServerSocket::create_socket() const {
int fd;
if (unlikely((fd = ::socket(PF_INET, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, IPPROTO_TCP)) < 0))
RC_FATAL << "server socket error: " << ::strerror(errno);
return fd;
}
void ServerSocket::bind(const InetAddress &addr) const {
if (unlikely(::bind(listen_fd, addr.get_sockaddr(), sizeof(sockaddr_in)) < 0))
RC_FATAL << "server socket(" << listen_fd << ") bind error: " << ::strerror(errno);
}
void ServerSocket::listen() const {
if (unlikely(::listen(listen_fd, SOMAXCONN) < 0))
RC_FATAL << "server socket(" << listen_fd << ") listen error: " << ::strerror(errno);
RC_DEBUG << "server socket(" << listen_fd << ") is listening...";
}
int ServerSocket::accept(InetAddress &peer_addr) const {
socklen_t len = sizeof(peer_addr);
int con_fd = ::accept4(listen_fd, peer_addr.get_sockaddr(), &len, SOCK_NONBLOCK | SOCK_CLOEXEC);
return con_fd;
}
void ServerSocket::reuse_addr(bool on) const {
const int opt = on ? 1 : 0;
if (unlikely(::setsockopt(listen_fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) < 0))
RC_FATAL << "setsockopt on server socket(" << listen_fd << ") error: " << ::strerror(errno);
}
void ServerSocket::no_delay(bool on) const {
const int opt = on ? 1 : 0;
if (unlikely(setsockopt(listen_fd, IPPROTO_TCP, TCP_NODELAY, &opt, sizeof(opt)) < 0))
RC_FATAL << "setsockopt on server socket(" << listen_fd << ") error: " << ::strerror(errno);
}
void ServerSocket::reuse_port(bool on) const {
const int opt = on ? 1 : 0;
if (unlikely(::setsockopt(listen_fd, SOL_SOCKET, SO_REUSEPORT, &opt, sizeof(opt)) < 0))
RC_FATAL << "setsockopt on server socket(" << listen_fd << ") error: " << ::strerror(errno);
}
int ServerSocket::fd() const {
return listen_fd;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.