gnu.cfg: Add buffer-size to xmalloc; add some __builtin_*() functions.

This commit is contained in:
versat 2019-03-19 15:24:02 +01:00
parent 6cbe818f1a
commit 9b6b94336c
2 changed files with 44 additions and 2 deletions

View File

@ -9,7 +9,7 @@
<dealloc>free</dealloc>
</memory>
<memory>
<alloc init="false">xmalloc</alloc>
<alloc init="false" buffer-size="arg-value:1">xmalloc</alloc>
<alloc init="true">xcalloc</alloc>
<dealloc>free</dealloc>
</memory>
@ -23,7 +23,7 @@
<dealloc>free</dealloc>
</memory>
<!-- https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html -->
<define name="__builtin_alloca" value="alloca"/>
<define name="__builtin_alloca(size)" value="alloca(size)"/>
<!-- void xexit(int status); -->
<function name="xexit">
<noreturn>true</noreturn>
@ -811,6 +811,7 @@
</function>
<!-- see https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html -->
<define name="__builtin_expect(X,Y)" value="(X)"/>
<define name="__builtin_expect_with_probability(exp,c,probability)" value="(exp)"/>
<!-- see http://kernelnewbies.org/FAQ/LikelyUnlikely -->
<define name="likely(X)" value="(X)"/>
<define name="unlikely(X)" value="(X)"/>
@ -964,6 +965,40 @@
<not-bool/>
</arg>
</function>
<!-- https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html -->
<!-- void __builtin_trap (void) -->
<function name="__builtin_trap">
<noreturn>true</noreturn>
</function>
<!-- int __builtin_constant_p (exp) -->
<function name="__builtin_constant_p">
<noreturn>false</noreturn>
<returnValue type="int"/>
<arg nr="1"/>
</function>
<!-- https://gcc.gnu.org/onlinedocs/gcc/Return-Address.html -->
<!-- void * __builtin_return_address (unsigned int level) -->
<!-- void * __builtin_frame_address (unsigned int level) -->
<function name="__builtin_return_address,__builtin_frame_address">
<noreturn>false</noreturn>
<returnValue type="void *"/>
<use-retval/>
<arg nr="1" direction="in">
<not-uninit/>
<not-bool/>
</arg>
</function>
<!-- void * __builtin_extract_return_addr (void *addr) -->
<!-- void * __builtin_frob_return_address (void *addr) -->
<function name="__builtin_extract_return_addr,__builtin_frob_return_address">
<noreturn>false</noreturn>
<returnValue type="void *"/>
<use-retval/>
<arg nr="1" direction="in">
<not-bool/>
</arg>
</function>
<!-- ########## Resource allocation ########## -->
<resource>
<dealloc>close</dealloc>
<alloc init="true">epoll_create</alloc>

View File

@ -15,6 +15,13 @@
#include <sys/epoll.h>
#endif
void valid_code(int argInt1)
{
if (__builtin_expect(argInt1, 0)) {}
if (__builtin_expect_with_probability(argInt1 + 1, 2, 0.5)) {}
}
void ignoreleak(void)
{
char *p = (char *)malloc(10);