libgloss/arm/libcfunc.c: alarm [PATCH]

Nick Clifton nickc@redhat.com
Thu Jul 14 08:53:00 GMT 2005


Hi Shaun,

> -void
> +void __attribute__((weak))
>  abort (void)
>  {
> +	extern void _exit (int n);
>  #ifdef ARM_RDI_MONITOR
> -  do_AngelSWI (AngelSWI_Reason_ReportException,
> -	      (void *) ADP_Stopped_RunTimeError);
> +	_exit(ADP_Stopped_RunTimeError);
>  #else
> - asm ("mov r0,#17\nswi %a0" :: "i" (SWI_Exit));
> +	_exit(17);
>  #endif
>  }

Why are you making abort() call _exit() ?  What is wrong with using the 
SWI that is intended for this purpose ?

This matters because the current implementation of _exit() ignores its 
argument and always performs a SWI with ADP_StoppedApplicationExit, so 
the user (or simulator) will never know that an abort has occurred.


> +int __attribute__((weak))
> +pause (void)
>  {
> +	return errno = ENOSYS, -1;
>  }

Ugg!  There is no need for clever coding here.  Use two statements not a 
comma, it is much clearer that way.  (There are several places where 
this applies).


> +int __attribute__((weak))
> +_raise (int sig)
>  {
> -  return;
> +  (void)sig;
> +  return errno = ENOSYS, -1;
>  }

"(void)sig" ?  What on earth ?  If you want to avoid a compile time 
warning about an unused parameter, then why not just have "sig = sig" as 
is used in _exit() for example.  I am not even sure if "(void)sig" is 
portable or even valid C.

Cheers
   Nick



More information about the Newlib mailing list