Re: [Tinycc-devel] '__builtin_frame_address' warning about suspicious use of this call

2016-11-29 Thread Christian Jullien
Ok I fixed it taking care of gcc version.

http://repo.or.cz/tinycc.git/commitdiff/ed99f3608df3d6dd4c8c7d52d608a8212203
dfe4

Looks good now on Fedora 25.

C.

-Original Message-
From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=orange...@nongnu.org]
On Behalf Of grischka
Sent: mardi 29 novembre 2016 12:20
To: tinycc-devel@nongnu.org
Subject: Re: [Tinycc-devel] '__builtin_frame_address' warning about
suspicious use of this call

Christian Jullien wrote:
> GCC documentation says:

> Calling this function with a nonzero argument can have unpredictable 
> effects, including crashing the calling program. As a result, calls 
> that are considered unsafe are diagnosed when the -Wframe-address 
> option is in effect. Such calls should only be made in debugging
situations.
> 
> ^ This latest sentence makes me afraid!

Actually we are in a "debugging situation" with bcheck.c which is helper
code for the tcc -b switch.

Also, in our case the result is not unpredictable because these functions
are used in a controlled way by calls inserted by the compiler (tcc).

If you use
 #pragma GCC diagnostic ignored "-Wframe-address"
it will probably just trigger another warning
 xxx.c:00: warning: ignoring #pragma GCC diagnostic with most versions
of gcc.

Alternatively we could just use tcc to compile the library which you get by
commenting out the lines
  XCC = $(CC)
near the top of lib/Makefile for i386/x86_84.

Feel free to make such change to mob, if it works.

Thanks,

--- grischka

> Two questions here:
> 
> Q1. Should we really call this function with one arg?
> 
>  
> 
> Q2. If safe, we should make this change to avoid this warning:
> 
>  
> 
> diff --git a/lib/bcheck.c b/lib/bcheck.c
> 
> index 756c539..8a75654 100644
> 
> --- a/lib/bcheck.c
> 
> +++ b/lib/bcheck.c
> 
> @@ -240,6 +240,9 @@ BOUND_PTR_INDIR(16)
> 
>  fp = (size_t)__builtin_frame_address(1);\
> 
> }
> 
> +#pragma GCC diagnostic push
> 
> +#pragma GCC diagnostic ignored "-Wframe-address"
> 
> +
> 
> /* called when entering a function to add all the local regions */
> 
> void FASTCALL __bound_local_new(void *p1)
> 
>  {
> 
> @@ -273,6 +276,7 @@ void FASTCALL __bound_local_delete(void *p1)
> 
>  __bound_delete_region((void *)addr);
> 
>  }
> 
> }
> 
> +#pragma GCC diagnostic pop
> 
>  static BoundEntry *__bound_new_page(void)
> 
> {
> 
> 
> 
> 
> --
> --
> 
> ___
> Tinycc-devel mailing list
> Tinycc-devel@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel



___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] sleep() interprets argument as milliseconds instead of seconds

2016-11-29 Thread Steven G. Messervey
 

 

From: Tinycc-devel [mailto:tinycc-devel-bounces+nuke48386=yahoo@nongnu.org] 
On Behalf Of Hernán J. González
Sent: Tuesday, November 29, 2016 2:53 PM
To: tinycc-devel@nongnu.org
Subject: [Tinycc-devel] sleep() interprets argument as milliseconds instead of 
seconds

 

The POSIX sleep()  function ( ) should interpret is input argument as 
seconds.

TinyC seems to interpret it as milliseconds.

 

Using tcc version 0.9.26

 

/***/

#include

#include 

int main() {

  int i;

  fputs("Looping ...\n",stdout);

  for(i=0;i<10;i++) {

fputs(".",stdout);

fflush(stdout);

sleep(3); // seconds?

  }

  return 0;

}

/***/

 

Expected behaviour: This should print a dot at 3 seconds interval, the loop 
should take 30 seconds.

Result: The 10 dots are printed and the loop ends  almost instanteously. 
Expected behaviour is attained when replacing '3' by '3000'

 

 

I cannot reproduce, tinycc 0.9.26, Debian 8 ‘Jessie’, 

Linux sgmtech8 3.16.0-4-amd64 #1 SMP Debian 3.16.36-1+deb8u2 (2016-10-19) 
x86_64 GNU/Linux,

no ‘configure’ flags at all, just ./configure ; make; sudo make install

 

My simple test was just: 

sl.c

---code---

#include 

#include 

 

int main(int argc, char **argv) {

  sleep(3);

  return 0;

}

--- end code---

$time ./sl

 

real0m3.001s

user0m0.000s

sys 0m0.000s

 

Maybe it’s distro-related?

 

___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


[Tinycc-devel] sleep() interprets argument as milliseconds instead of seconds

2016-11-29 Thread Hernán J . González
The POSIX sleep()  function ( ) should interpret is input
argument as seconds.
TinyC seems to interpret it as milliseconds.

Using tcc version 0.9.26

/***/
#include
#include 
int main() {
  int i;
  fputs("Looping ...\n",stdout);
  for(i=0;i<10;i++) {
fputs(".",stdout);
fflush(stdout);
sleep(3); // seconds?
  }
  return 0;
}
/***/

Expected behaviour: This should print a dot at 3 seconds interval, the loop
should take 30 seconds.
Result: The 10 dots are printed and the loop ends  almost instanteously.
Expected behaviour is attained when replacing '3' by '3000'
___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] '__builtin_frame_address' warning about suspicious use of this call

2016-11-29 Thread grischka

Christian Jullien wrote:

GCC documentation says:



Calling this function with a nonzero argument can have unpredictable
effects, including crashing the calling program. As a result, calls that are
considered unsafe are diagnosed when the -Wframe-address option is in
effect. Such calls should only be made in debugging situations. 


^ This latest sentence makes me afraid!


Actually we are in a "debugging situation" with bcheck.c which
is helper code for the tcc -b switch.

Also, in our case the result is not unpredictable because these
functions are used in a controlled way by calls inserted by the
compiler (tcc).

If you use
#pragma GCC diagnostic ignored "-Wframe-address"
it will probably just trigger another warning
xxx.c:00: warning: ignoring #pragma GCC diagnostic
with most versions of gcc.

Alternatively we could just use tcc to compile the library
which you get by commenting out the lines
 XCC = $(CC)
near the top of lib/Makefile for i386/x86_84.

Feel free to make such change to mob, if it works.

Thanks,

--- grischka


Two questions here:

Q1. Should we really call this function with one arg?

 


Q2. If safe, we should make this change to avoid this warning:

 


diff --git a/lib/bcheck.c b/lib/bcheck.c

index 756c539..8a75654 100644

--- a/lib/bcheck.c

+++ b/lib/bcheck.c

@@ -240,6 +240,9 @@ BOUND_PTR_INDIR(16)

 fp = (size_t)__builtin_frame_address(1);\

}

+#pragma GCC diagnostic push

+#pragma GCC diagnostic ignored "-Wframe-address"

+

/* called when entering a function to add all the local regions */

void FASTCALL __bound_local_new(void *p1) 


 {

@@ -273,6 +276,7 @@ void FASTCALL __bound_local_delete(void *p1)

 __bound_delete_region((void *)addr);

 }

}

+#pragma GCC diagnostic pop

 static BoundEntry *__bound_new_page(void)

{






___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel




___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel