some doubts in glib code

  • Thread starter ramasubramanian.rahul
  • Start date
R

ramasubramanian.rahul

hi people..
dont know if this the right forum for this doubt ... so sorry if i am
mis-posting...
i was looking at the way glib 2.10.3 does export optimization using a
list of "to be exposed" function names in a file caleed glib.symbols.
this file is used by a perl script to generate a header a .c file
( galias.h and galiasdefs.c). This files essentially enusres default
visibility for these functions (using the __attribute__((default))__
option) , while building the rest of the functions with -
fvisibility=hidden.
i have two doubt regarding this.
1> in the generated header galias.h there is a syntax
#define IN_FILE(x) 1
#define IN_HEADER defined

#if IN_HEADER(__G_ARRAY_H__)
#if IN_FILE(__G_ARRAY_C__)
extern __typeof (g_array_append_vals) IA__g_array_append_vals
__attribute((visibility("hidden")));
#define g_array_append_vals IA__g_array_append_vals
....
......
#endif
#endif

whnat does #define IN_HEADER defined mean.. and how is it used
in this context.

2> secondly , how does glib maintain the glib.symbols list .. is it
manual or does it use some kind of a parser to parse through the
include folder of glib to come up with the list...
hope i have been able to clearly state my doubts....
thanks in advance for the replies and help...
BR
Rahul
 
B

Barry Schwarz

hi people..
dont know if this the right forum for this doubt ... so sorry if i am
mis-posting...
i was looking at the way glib 2.10.3 does export optimization using a
list of "to be exposed" function names in a file caleed glib.symbols.
this file is used by a perl script to generate a header a .c file
( galias.h and galiasdefs.c). This files essentially enusres default
visibility for these functions (using the __attribute__((default))__
option) , while building the rest of the functions with -
fvisibility=hidden.
i have two doubt regarding this.
1> in the generated header galias.h there is a syntax
#define IN_FILE(x) 1
#define IN_HEADER defined

#if IN_HEADER(__G_ARRAY_H__)
#if IN_FILE(__G_ARRAY_C__)
extern __typeof (g_array_append_vals) IA__g_array_append_vals
__attribute((visibility("hidden")));
#define g_array_append_vals IA__g_array_append_vals
...
.....
#endif
#endif

whnat does #define IN_HEADER defined mean.. and how is it used
in this context.

It tells the compiler that whenever it sees the token
IN_HEADER
it should substitute the token
defined

Consequently, the directive
#if IN_HEADER(__G_ARRAY_H__)
is processed as if it were
#if defined(__G_ARRAY_H__)

It takes some reasonably obvious syntax and obfuscates it by adding an
alias. In my opinion, this is one of those bad ideas along the lines
of
#define BEGIN {
2> secondly , how does glib maintain the glib.symbols list .. is it
manual or does it use some kind of a parser to parse through the
include folder of glib to come up with the list...
hope i have been able to clearly state my doubts....

Ask in a glib group.


Remove del for email
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top