dev builds
themes manual
device status forums
mailing lists
IRC bugs
dev guide

Rockbox mail archive

Subject: Re: char[] assignment in plugin api
From: Nix (
Date: 2004-01-04

On Sun, 28 Dec 2003, stated:
> Funny. When you program a plugin you cannot initialize a string with
> char mystring[] = "mystring";
> because inernally it seems to use memcpy.

Yes, under some circumstances: see e.g. gcc/expr.c:store_expr(),
gcc/expr.c:emit_block_move(), emit_block_move_via_libcall(), and
emit_block_move_libcall_fn(). The latter spits out a libcall to memcpy()
or bcopy().

See <>, and the Standards node in the GCC
manual, which states (as of GCC 3.3.1, but this requirement hasn't
changed for years, just become better-documented):

| GCC requires the
| freestanding environment provide `memcpy', `memmove', `memset' and
| `memcmp'. Some older ports of GCC are configured to use the BSD
| `bcopy', `bzero' and `bcmp' functions instead, but this is deprecated
| for new ports. Finally, if `__builtin_trap' is used, and the target
| does not implement the `trap' pattern, then GCC will emit a call to
| `abort'.

(The sh GCC targets do not emit calls to bcopy(), bzero(), or bcmp().)

> But that function is only
> available via the api pointer. Is that fixable / worth fixing?

You fix it by implementing memcpy(). It's only a few bytes... :)

As they say, build a better mousetrap and the world will beat a
path to your door. But nobody ever got anywhere outlawing mice.

Page was last modified "Jan 10 2012" The Rockbox Crew