home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 January / Chip_2001-01_cd1.bin / tema / mysql / mysql-3.23.28g-win-source.exe / strings / bmove.c < prev    next >
C/C++ Source or Header  |  2000-10-23  |  2KB  |  64 lines

  1. /*  File   : bmove.c
  2.     Author : Richard A. O'Keefe.
  3.          Michael Widenius;    ifdef MC68000
  4.     Updated: 23 April 1984
  5.     Defines: bmove()
  6.  
  7.     bmove(dst, src, len) moves exactly "len" bytes from the source "src"
  8.     to the destination "dst".  It does not check for NUL characters as
  9.     strncpy() and strnmov() do.  Thus if your C compiler doesn't support
  10.     structure assignment, you can simulate it with
  11.     bmove(&to, &from, sizeof from);
  12.     The standard 4.2bsd routine for this purpose is bcopy.  But as bcopy
  13.     has its first two arguments the other way around you may find this a
  14.     bit easier to get right.
  15.     No value is returned.
  16.  
  17.     Note: the "b" routines are there to exploit certain VAX order codes,
  18.     but the MOVC3 instruction will only move 65535 characters.     The asm
  19.     code is presented for your interest and amusement.
  20. */
  21.  
  22. #include <global.h>
  23. #include "m_string.h"
  24.  
  25. #if !defined(HAVE_BMOVE) && !defined(bmove)
  26.  
  27. #if VaxAsm
  28.  
  29. void bmove(dst, src, len)
  30.     char *dst, *src;
  31.     uint len;
  32.     {
  33.  asm("movc3 12(ap),*8(ap),*4(ap)");
  34.     }
  35.  
  36. #else
  37. #if defined(MC68000) && defined(DS90)
  38.  
  39. void bmove(dst, src, len)
  40. char *dst,*src;
  41. uint len;                /* 0 <= len <= 65535 */
  42. {
  43. asm("        movl    12(a7),d0    ");
  44. asm("        subql    #1,d0        ");
  45. asm("        blt    .L5        ");
  46. asm("        movl    4(a7),a1    ");
  47. asm("        movl    8(a7),a0    ");
  48. asm(".L4:    movb    (a0)+,(a1)+    ");
  49. asm("        dbf    d0,.L4        ");
  50. asm(".L5:                ");
  51. }
  52. #else
  53.  
  54. void bmove(dst, src, len)
  55. register char *dst;
  56. register const char *src;
  57. register uint len;
  58. {
  59.   while (len-- != 0) *dst++ = *src++;
  60. }
  61. #endif
  62. #endif
  63. #endif
  64.