|
From: Kevin's C. B. A. <kev...@pl...> - 2007-03-11 23:32:47
|
Update of /cvsroot/libteklti/libteklti/src In directory planetsaphire.com:/tmp/cvs-serv5703/src Modified Files: TekFileASCIIBare.386.cpp Log Message: FIX: Refactored asm code in ReadLine(). Index: TekFileASCIIBare.386.cpp =================================================================== RCS file: /cvsroot/libteklti/libteklti/src/TekFileASCIIBare.386.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C 2 -d -p -r1.14 -r1.15 *** TekFileASCIIBare.386.cpp 11 Mar 2007 13:14:04 -0000 1.14 --- TekFileASCIIBare.386.cpp 11 Mar 2007 23:40:00 -0000 1.15 *************** TEKERR teklti::FileASCIIBare::ReadLine( *** 404,407 **** --- 404,413 ---- /* Put asciilen into %ebx. */ __asm__ ( " movl %ecx, %ebx " ); + /* and into esp, in case fseek() needs to be called. */ + /* Negate ecx first. */ + __asm__ ( " negl %ecx " ); + /* Then put it in esp. */ + __asm__ ( " movl %ecx, 4(%esp) " ); + /* Put ReadMax into eax. */ __asm__ ( " movl 16(%ebp), %ecx " ); *************** TEKERR teklti::FileASCIIBare::ReadLine( *** 417,421 **** /* Check to see if we have already read the last bit. */ __asm__ ( " testl %ebx, %ebx " ); ! /* If we have, we need to bail out of this loop. */ __asm__ ( " je .FileASCIIBare_ReadLine_readmax_bailout3 " ); --- 423,427 ---- /* Check to see if we have already read the last bit. */ __asm__ ( " testl %ebx, %ebx " ); ! /* If we have, we need to re-read the buffer. */ __asm__ ( " je .FileASCIIBare_ReadLine_readmax_bailout3 " ); *************** TEKERR teklti::FileASCIIBare::ReadLine( *** 437,445 **** __asm__ ( " jmp .FileASCIIBare_ReadLine_readmax_bailout " ); /* This label is used to bail out of the ReadMax loop. */ __asm__ ( " .FileASCIIBare_ReadLine_readmax_bailout2: " ); - /* This label is also used to bail out of the ReadMax loop. */ __asm__ ( " .FileASCIIBare_ReadLine_readmax_bailout3: " ); /* Restore private value's string pointer. */ #ifdef UNICODE --- 443,452 ---- __asm__ ( " jmp .FileASCIIBare_ReadLine_readmax_bailout " ); + /* This label is used to bail out of the ReadMax loop. */ __asm__ ( " .FileASCIIBare_ReadLine_readmax_bailout2: " ); /* This label is also used to bail out of the ReadMax loop. */ __asm__ ( " .FileASCIIBare_ReadLine_readmax_bailout3: " ); + /* Restore private value's string pointer. */ #ifdef UNICODE *************** TEKERR teklti::FileASCIIBare::ReadLine( *** 457,462 **** #endif /* UNICODE */ - /* Restore %ebx from %esp+12. */ - __asm__ ( " movl 12(%esp), %ebx " ); #ifdef USE_386_ASM_ENFORCE_PRIVACY --- 464,467 ---- *************** TEKERR teklti::FileASCIIBare::ReadLine( *** 469,476 **** /* Fry the buffer. */ __asm__ ( " rep stosl " ); ! #endif /* not USE_386_ASM_ENFORCE_PRIVACY */ /* Set %ecx to TEKERR_FILE_EOF. */ ! __asm__ ( " movl %1, %%eax " : "=m" (_tfbtmp) : "i" (TEKERR_FILE_EOF) ); /* Jump to cleanup area. */ __asm__ ( " jmp .FileASCIIBare_ReadLine_ret " ); --- 474,525 ---- /* Fry the buffer. */ __asm__ ( " rep stosl " ); ! /* We need to restore eax. */ ! __asm__ ( " movl 8(%ebp), %eax " ); ! #endif /* USE_386_ASM_ENFORCE_PRIVACY */ ! ! /* Check to see if we need to call fseek(). */ ! __asm__ ( " testl %ebx, %ebx " ); ! /* Test the result; jump if necessary. */ ! __asm__ ( " jne .FileASCIIBare_ReadLine_readmax_nofseek " ); ! ! ! #ifdef UNICODE ! /* Move a section of memory that contains the FILE *. */ ! __asm__ ( " movl 596(%eax), %ecx " ); ! #else /* UNICODE */ ! /* Move a section of memory that contains the FILE *. */ ! __asm__ ( " movl 588(%eax), %ecx " ); ! #endif /* UNICODE */ ! /* Put the FILE * onto the stack. */ ! __asm__ ( " movl %ecx, 8(%esp) " ); ! /* Put SEEK_CUR onto the stack. */ ! __asm__ ( " movl %1, (%%esp) " ! : "=m" (_tfbtmp) : "i" (SEEK_CUR) ); ! /* Call fseek(). */ ! __asm__ ( " call fseek " ); ! /* Test the retval. */ ! __asm__ ( " testl %eax, %eax " ); ! /* Jump if fseek() succeeded. */ ! __asm__ ( " je .FileASCIIBare_ReadLine_readmax_fseekok " ); ! /* If we didn't jump, then fseek() failed. */ ! /* Restore %ebx from %esp+12. */ ! __asm__ ( " movl 12(%esp), %ebx " ); ! /* Report error to caller. */ ! __asm__ ( " movl %1, %%eax " ! : "=m" (_tfbtmp) : "i" (TEKERR_FAIL) ); ! /* Jump to cleanup area. */ ! __asm__ ( " jmp .FileASCIIBare_ReadLine_ret " ); ! /* This label is used when fseek() succeeds. */ ! __asm__ ( " .FileASCIIBare_ReadLine_readmax_fseekok: " ); ! ! ! /* This label is used when we don't need to call fseek(). */ ! __asm__ ( " .FileASCIIBare_ReadLine_readmax_nofseek: " ); ! ! /* Restore %ebx from %esp+12. */ ! __asm__ ( " movl 12(%esp), %ebx " ); /* Set %ecx to TEKERR_FILE_EOF. */ ! TEKLTI_RETVAL_TEKERR_OK /* Jump to cleanup area. */ __asm__ ( " jmp .FileASCIIBare_ReadLine_ret " ); |