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 committed Oct 8, 2024
1 parent 2fcf7ca commit 175246d
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 @@ -300,6 +300,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 @@ -589,6 +610,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 @@ -735,6 +761,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 @@ -849,6 +879,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 @@ -942,6 +976,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 @@ -1025,6 +1063,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 @@ -1093,6 +1135,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 175246d

Please sign in to comment.