Skip to content

Commit

Permalink
OpenBSD: arm fix
Browse files Browse the repository at this point in the history
Disable warning softfloat. OpenBSD works fine.
save/restore s0-s15 during memcpy call for structs
update configure script. Works now on raspberry pi/All BSD
Add eabi_mem.. functions in armeabi.c for OpenBSD
Fix fp register in tccrun.c for OpenBSD
  • Loading branch information
hermantb authored and oleavr committed Apr 1, 2022
1 parent aefbb52 commit 23de9d2
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
6 changes: 5 additions & 1 deletion arm-gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ ST_FUNC void arm_init(struct TCCState *s)

float_abi = s->float_abi;
#ifndef TCC_ARM_HARDFLOAT
# warning "soft float ABI currently not supported: default to softfp"
// XXX: Works on OpenBSD
// # warning "soft float ABI currently not supported: default to softfp"
#endif
}
#else
Expand Down Expand Up @@ -1160,7 +1161,10 @@ static int copy_params(int nb_args, struct plan *plan, int todo)
o(0xE28D0000|(intr(r)<<12)|padding); /* add r, sp, padding */
vset(&vtop->type, r | VT_LVAL, 0);
vswap();
/* XXX: optimize. Save all register because memcpy can use them */
o(0xED2D0A00|(0&1)<<22|(0>>1)<<12|16); /* vpush {s0-s15} */
vstore(); /* memcpy to current sp + potential padding */
o(0xECBD0A00|(0&1)<<22|(0>>1)<<12|16); /* vpop {s0-s15} */

/* Homogeneous float aggregate are loaded to VFP registers
immediately since there is no way of loading data in multiple
Expand Down
36 changes: 36 additions & 0 deletions lib/armeabi.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,3 +499,39 @@ void __aeabi_uidivmod(unsigned num, unsigned den)
{
uidiv_t_return(aeabi_uidivmod(num, den));
}

/* Some targets do not have all eabi calls (OpenBSD) */
typedef __SIZE_TYPE__ size_t;
extern void *memcpy(void *dest, const void *src, size_t n);
extern void *memmove(void *dest, const void *src, size_t n);
extern void *memset(void *s, int c, size_t n);

void *
__aeabi_memcpy (void *dest, const void *src, size_t n)
{
return memcpy (dest, src, n);
}

void *
__aeabi_memmove (void *dest, const void *src, size_t n)
{
return memmove (dest, src, n);
}

void *
__aeabi_memmove4 (void *dest, const void *src, size_t n)
{
return memmove (dest, src, n);
}

void *
__aeabi_memmove8 (void *dest, const void *src, size_t n)
{
return memmove (dest, src, n);
}

void *
__aeabi_memset (void *s, size_t n, int c)
{
return memset (s, c, n);
}
2 changes: 1 addition & 1 deletion tccrun.c
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ static void rt_getcontext(ucontext_t *uc, rt_context *rc)
rc->ip = uc->uc_mcontext.__gregs[_REG_PC];
rc->fp = uc->uc_mcontext.__gregs[_REG_FP];
# elif defined(__OpenBSD__)
rc->ip = uc->sc_pc;
rc->fp = uc->sc_r11;
rc->fp = uc->sc_fpreg[29];
# elif defined(__QNX__)
rc->ip = uc->uc_mcontext.cpu.gpr[15];
Expand Down

0 comments on commit 23de9d2

Please sign in to comment.