home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snip9707.zip / FMEMOPS.C < prev    next >
C/C++ Source or Header  |  1997-07-05  |  2KB  |  65 lines

  1. /* +++Date last modified: 05-Jul-1997 */
  2.  
  3. /*
  4. **  FMEMOPS.C - Emulate MSC's far memory functions in ZTC++ & early BC++
  5. **
  6. **  Original Copyright 1988-1992 by Bob Stout as part of
  7. **  the MicroFirm Function Library (MFL)
  8. **
  9. **  The user is granted a free limited license to use this source file
  10. **  to create royalty-free programs, subject to the terms of the
  11. **  license restrictions specified in the LICENSE.MFL file.
  12. */
  13.  
  14. #if defined(__ZTC__) && !defined(__SC__)
  15.  
  16. #include <stdlib.h>
  17. #include <dos.h>
  18. #include "fmemops.h"
  19.  
  20. /*
  21. **  Don't #include <string.h> to avoid incompatible prototypes
  22. */
  23.  
  24. #if __cplusplus
  25.  extern "C" {
  26. #endif
  27.  
  28. void CDECL movedata(unsigned,unsigned,unsigned,unsigned,size_t);
  29.  
  30. #if __cplusplus
  31.  }
  32. #endif
  33.  
  34. typedef unsigned char FAR *FarBytePtr;
  35.  
  36. void FAR * _fmemcpy(void FAR *dest, void FAR *src, size_t count)
  37. {
  38.       movedata(FP_SEG(src), FP_OFF(src), FP_SEG(dest), FP_OFF(dest), count);
  39.       return dest;
  40. }
  41.  
  42. void FAR * _fmemmove(void FAR *dest, void FAR *src, size_t count)
  43. {
  44.       void FAR *target =  dest;
  45.       FarBytePtr to = (FarBytePtr)dest, from = (FarBytePtr)src;
  46.  
  47.       if (src >= dest)
  48.             _fmemcpy(dest, src, count);
  49.       else  for (to += count, from += count; count; --count)
  50.                   *--to = *--from;
  51.       return target;
  52. }
  53.  
  54. void FAR * _fmemset(void FAR *dest, int ch, size_t count)
  55. {
  56.       void FAR *target =  dest;
  57.       FarBytePtr to = (FarBytePtr)dest;
  58.  
  59.       for ( ; count; --count)
  60.             *to++ = (unsigned char) ch;
  61.       return target;
  62. }
  63.  
  64. #endif /* __ZTC__ */
  65.