[comp.lang.c] memcpy

chad@lakesys.UUCP (D. Chadwick Gibbons) (02/12/89)

	I am in need of a version of memcpy() that handles alignment
restrictions within pointers.  The few versions of source that I have
work well, except they do not allow you to preform an operation such as:

	char *dst;
	struct magic *src;

	memcpy(dst, src, sizeof(src));

The pointer alignment for the structure does not coincide with that of
the character pointer, and thus the function bombs.

	Why not use the standard library version?  I am running under
XENIX and need to use a far pointer in a small model program...as you
know, you have to write your own versions of the standard library
routines in this situation.  I need to be able to have *dst be a char far
*dst, instead of the normal near pointer.

	I appreciate any information, of course.
-- 
D. Chadwick Gibbons, chad@lakesys.lakesys.com, ...!uunet!marque!lakesys!chad

manning@nntp-server.caltech.edu (Evan Marshall Manning) (11/13/90)

The title about says it.  I need to move data from point A to
point B, where there may be a bit offset as well as a byte offset.
Is there any reasonably portable and/or reasonably fast way to do
this?

If it matters, I'm using a 68030 with a (buggy) "Classic C" compiler under
PDOS.

Yes, I know this is a silly thing to do.  I'm lobbying to restart on
bit slips, but nobody asks me.

Thanks,
-- Evan

***************************************************************************
Your eyes are weary from staring at the CRT for so | Evan M. Manning
long.  You feel sleepy.  Notice how restful it is  |      is
to watch the cursor blink.  Close your eyes.  The  |manning@gap.cco.caltech.edu
opinions stated above are yours.  You cannot       | manning@mars.jpl.nasa.gov
imagine why you ever felt otherwise.               | gleeper@tybalt.caltech.edu

gwyn@smoke.brl.mil (Doug Gwyn) (11/13/90)

In article <1990Nov12.235038.16331@nntp-server.caltech.edu> manning@nntp-server.caltech.edu (Evan Marshall Manning) writes:
>The title about says it.  I need to move data from point A to
>point B, where there may be a bit offset as well as a byte offset.
>Is there any reasonably portable and/or reasonably fast way to do
>this?

This is known as a "bit blit" (special case of "rasterop"), and
algorithms are described in the computer graphics literature.
For example, there was an article in "Software -- Practice and
Experience" by Locanthi and Pike on the method used in the Blit
terminal.