diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-03-12 18:50:06 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-03-12 18:50:44 -0700 |
commit | eb92e14f7649656e4ec50c7450bd1aa3740256da (patch) | |
tree | 36d0151c58530a8d1c47c029295d7a03945b0dd2 | |
parent | 645fcab6d33a86749d9f88667ed2cb712ef5e1c9 (diff) |
write strcpy in asm and add some testing
-rw-r--r-- | src/library.js | 12 | ||||
-rwxr-xr-x | tests/runner.py | 5 |
2 files changed, 12 insertions, 5 deletions
diff --git a/src/library.js b/src/library.js index 8bce7a14..185b1187 100644 --- a/src/library.js +++ b/src/library.js @@ -4329,14 +4329,18 @@ LibraryManager.library = { } }, + strcpy__asm: 'true', + strcpy__sig: 'iii', strcpy: function(pdest, psrc) { + pdest = pdest|0; psrc = psrc|0; var i = 0; do { - {{{ makeCopyValues('pdest+i', 'psrc+i', 1, 'i8', null, 1) }}}; - i ++; - } while ({{{ makeGetValue('psrc', 'i-1', 'i8') }}} != 0); - return pdest; + {{{ makeCopyValues('(pdest+i)|0', '(psrc+i)|0', 1, 'i8', null, 1) }}}; + i = (i+1)|0; + } while (({{{ makeGetValue('psrc', 'i-1', 'i8') }}})|0 != 0); + return pdest|0; }, + stpcpy: function(pdest, psrc) { var i = 0; do { diff --git a/tests/runner.py b/tests/runner.py index 89ddf2ac..393d8de4 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -4117,10 +4117,12 @@ The current type of b is: 9 #define CONSTRLEN 32 + char * (*func)(char *, const char *) = NULL; + void conoutfv(const char *fmt) { static char buf[CONSTRLEN]; - strcpy(buf, fmt); + func(buf, fmt); // call by function pointer to make sure we test strcpy here puts(buf); } @@ -4142,6 +4144,7 @@ The current type of b is: 9 }; int main() { + func = &strcpy; conoutfv("*staticccz*"); printf("*%.2f,%.2f,%.2f*\\n", S::getIdentity().x, S::getIdentity().y, S::getIdentity().z); return 0; |