Skip to content

Commit

Permalink
compiler:add visibility & constructor keywords in compiler.h
Browse files Browse the repository at this point in the history
Signed-off-by: anjiahao <[email protected]>
  • Loading branch information
anjiahao1 authored and xiaoxiang781216 committed Oct 8, 2024
1 parent e9e0150 commit 4ac2a5a
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions include/nuttx/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,27 @@
# endif
# endif

/* The constructor attribute causes the function to be called
* automatically before execution enters main ().
* Similarly, the destructor attribute causes the function to
* be called automatically after main () has completed or
* exit () has been called. Functions with these attributes are
* useful for initializing data that will be used implicitly
* during the execution of the program.
* See https://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Function-Attributes.html
*/

# define constructor_fuction __attribute__((constructor))
# define destructor_function __attribute__((destructor))

/* Use visibility_hidden to hide symbols by default
* Use visibility_default to make symbols visible
* See https://gcc.gnu.org/wiki/Visibility
*/

# define visibility_hidden __attribute__((visibility("hidden")))
# define visibility_default __attribute__((visibility("default")))

/* The unused code or data */

# define unused_code __attribute__((unused))
Expand Down Expand Up @@ -597,6 +618,11 @@
# define nosanitize_address
# define nosanitize_undefined
# define nostackprotect_function
# define constructor_fuction
# define destructor_function

# define visibility_hidden
# define visibility_default

# define unused_code
# define unused_data
Expand Down Expand Up @@ -744,6 +770,10 @@
# define nosanitize_address
# define nosanitize_undefined
# define nostackprotect_function
# define constructor_fuction
# define destructor_function
# define visibility_hidden
# define visibility_default
# define unused_code
# define unused_data
# define used_code
Expand Down Expand Up @@ -859,6 +889,10 @@
# define nosanitize_address
# define nosanitize_undefined
# define nostackprotect_function
# define constructor_fuction
# define destructor_function
# define visibility_hidden
# define visibility_default
# define unused_code
# define unused_data
# define used_code
Expand Down Expand Up @@ -953,6 +987,10 @@
# define nosanitize_address
# define nosanitize_undefined
# define nostackprotect_function
# define constructor_fuction
# define destructor_function
# define visibility_hidden
# define visibility_default
# define unused_code
# define unused_data
# define used_code
Expand Down Expand Up @@ -1037,6 +1075,10 @@
# define nosanitize_address
# define nosanitize_undefined
# define nostackprotect_function
# define constructor_fuction
# define destructor_function
# define visibility_hidden
# define visibility_default
# define unused_code __attribute__((unused))
# define unused_data __attribute__((unused))
# define used_code __attribute__((used))
Expand Down Expand Up @@ -1106,6 +1148,10 @@
# define nosanitize_address
# define nosanitize_undefined
# define nostackprotect_function
# define constructor_fuction
# define destructor_function
# define visibility_hidden
# define visibility_default
# define unused_code
# define unused_data
# define used_code
Expand Down

0 comments on commit 4ac2a5a

Please sign in to comment.