Skip to content

Commit

Permalink
Import various libgcc functions from syslinux.
Browse files Browse the repository at this point in the history
Experimentation reveals that gcc ignores -mrtd for the implicit
arithmetic functions (e.g. __udivdi3), but not for the implicit
memcpy() and memset() functions.  Mark the implicit arithmetic
functions with __attribute__((cdecl)) to compensate for this.

(Note: we cannot mark with with __cdecl, because we define __cdecl to
incorporate regparm(0) as well.)
  • Loading branch information
Michael Brown committed Jul 30, 2007
1 parent f62d648 commit 4ce8d61
Show file tree
Hide file tree
Showing 9 changed files with 134 additions and 338 deletions.
1 change: 1 addition & 0 deletions src/Makefile
Expand Up @@ -145,6 +145,7 @@ DEBUG_TARGETS += dbg%.o c s

# SRCDIRS lists all directories containing source files.
#
SRCDIRS += libgcc
SRCDIRS += core
SRCDIRS += proto
SRCDIRS += net net/tcp net/udp
Expand Down
336 changes: 0 additions & 336 deletions src/arch/i386/core/udivmod64.c

This file was deleted.

26 changes: 26 additions & 0 deletions src/libgcc/__divdi3.c
@@ -0,0 +1,26 @@
/*
* arch/i386/libgcc/__divdi3.c
*/

#include "libgcc.h"

LIBGCC int64_t __divdi3(int64_t num, int64_t den)
{
int minus = 0;
int64_t v;

if ( num < 0 ) {
num = -num;
minus = 1;
}
if ( den < 0 ) {
den = -den;
minus ^= 1;
}

v = __udivmoddi4(num, den, NULL);
if ( minus )
v = -v;

return v;
}
26 changes: 26 additions & 0 deletions src/libgcc/__moddi3.c
@@ -0,0 +1,26 @@
/*
* arch/i386/libgcc/__moddi3.c
*/

#include "libgcc.h"

LIBGCC int64_t __moddi3(int64_t num, int64_t den)
{
int minus = 0;
int64_t v;

if ( num < 0 ) {
num = -num;
minus = 1;
}
if ( den < 0 ) {
den = -den;
minus ^= 1;
}

(void) __udivmoddi4(num, den, (uint64_t *)&v);
if ( minus )
v = -v;

return v;
}

0 comments on commit 4ce8d61

Please sign in to comment.