_memcpy

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Therx

Re:_memcpy

Post by Therx »

Err. Why does panic() have three arguments and you only give it 2?

Pete
hElPnEeded

Re:_memcpy

Post by hElPnEeded »

that was my old handler, my new gives 2, forget about the char *code... can I prevent the compiler from using memcpy instead of passing the argument?
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:_memcpy

Post by df »

tried passing it as a pointer? GCC does a memcpy if things are bigger than a certain size.

you may need to add -nostdlib and -nodefault-libs

here is info on no-builtin-function

Code: Select all

-fno-builtin
-fno-builtin-function
Don't recognize built-in functions that do not begin with __builtin_ as prefix.

GCC normally generates special code to handle certain built-in functions more efficiently; for instance, calls to "alloca" may become single instructions that adjust the stack directly, and calls to "memcpy" may become inline copy loops.  The resulting code is often both smaller and faster, but since the function calls no longer appear as such, you cannot set a breakpoint on those calls, nor can you change the behavior of the functions by linking with a different library.

With the -fno-builtin-function option only the built-in function function is disabled.  function must not begin with __builtin_.  If a function is named this is not built-in in this version of GCC, this option is ignored.  There is no corresponding -fbuiltin-func- tion option; if you wish to enable built-in functions selectively when using -fno-builtin or -ffreestanding, you may define macros such as:

                   #define abs(n)          __builtin_abs ((n))
                   #define strcpy(d, s)    __builtin_strcpy ((d), (s))
-- Stu --
Dreamsmith

Re:_memcpy

Post by Dreamsmith »

Rewriting panic to take a pointer to the struct rather than a copy of the struct would be the best solution. Passing large structures on the stack is evil. I draw the line at 64 bits myself, and on a 32 bit processor, even that is morally questionable. 64 bytes is right out...
Dreamsmith

Re:_memcpy

Post by Dreamsmith »

BTW, -ffreestanding implies -fno-builtin, no need to be redundant by specifying it again. Here's how my CFLAGS looks:

Code: Select all

CFLAGS = -I${HOME}/dev/leptos -ffreestanding -nostdinc -nostdlib -Wall -Werror -Winline -O2 -fno-strict-aliasing -DCOMPILE_ID='"${COMPILEID}"'
Post Reply