On 09/02/2011 07:03, ali hagigat wrote:
Are memcmp, memset, and memmove built in?
So a built in function may be in the library or the code I write. right?
I have used cross compilers for micro controllers for years. They
translate C/Assembly code you write and produce a final object file.
they are not dependent on operating system, system calls or force our
code to be linked with some unknown strange libraries which programmer
does not know about them at all.
You are comparing apples and fruit baskets here.
As Ian says, gcc is just the compiler - it is not a complete development
toolchain. What you are referring to here is complete toolchains,
including the linker, assembler, and libraries (and normally a debugger
and IDE too). The programs you generate /are/ linked to "strange"
libraries - they are libraries that came with the development toolchain.
They may also include system call support or dependencies on the
operating system, depending on the target.
The libraries provided with the toolchain will be dependent on the
target. For a simple example, a function like memcpy can be implemented
in different ways - for a small target, it will be optimised for space.
For larger targets, it will be optimised for speed and take into
account things like memory alignment, cache line size, etc. This is
dependent on the complete target - not just the basic CPU architecture.
The toolchain supplier will know about these issues, and provide
appropriate libraries.
gcc itself knows about /some/ of these things, given the correct flags
(it will probably know about alignment issues, but is unlikely to know
about cache line sizes). Thus it will sometimes inline memcpy using the
builtin code, such as for small copies where the number of bytes is
fixed at compile time, and it will sometimes call an external function.
There are plenty of complete toolchains based on gcc. A good source of
these is www.codesourcery.com - the developers there do a lot of work on
various embedded gcc targets. When you download a toolchain from them,
you get the assembler, linker and libraries included. There are also
plenty of other ready-packaged gcc-based toolchains for other
microcontrollers.
How they work? Professionals like you can implement the same
functionality for gcc without the weak point of adding mem functions.
It is an idea but I am surprised how you say that it is impossible to
do such a thing.
Besides gcc is dependent to what? operating system or the architecture
of hardware like Intel chipsets, host bridge and I/O bridge in
addition to CPU?