z/TPF Program Management - IBM
z/TPF Program Management - IBM
z/TPF Program Management - IBM
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
14 z/<strong>TPF</strong> <strong>Program</strong> <strong>Management</strong><br />
Individual functions can be made visible by using the visibility attribute; add<br />
__attribute__ ((visibility("default")) to the functions you want to make<br />
visible.<br />
Note: Use this option for shared objects that contain only C language code<br />
because runtime problems can occur when you use this option on a<br />
shared object that contains C++ code. For more information about<br />
potential problems when you use visibility with C++ classes, see “Special<br />
considerations for C++ classes” on page 15.<br />
v LIST is used to indicate that the list of visible functions is provided in an export<br />
file. As with ALL, the -fvisibility=default compiler option (used in conjunction<br />
with the -fvisibility inlines=default compiler option for C++ programs) is<br />
used at compile time to make the functions visible; however, at link time, the<br />
export file provides:<br />
– A list of functions that are to be hidden.<br />
– A list of functions that are visible.<br />
Note: You must use the LIST option and export files when hiding functions that<br />
are coded in assembly language, because there is no assembly option<br />
that is equivalent to the -fvisibility option. For more information, see<br />
“Export files” on page 15.<br />
v ENTRY is used to indicate that only the function specified by APP_ENTRY is made<br />
visible. This is also controlled at link time by using the base/exp/app_entry.exp<br />
export file. For more information, see “Export files” on page 15.<br />
Examples<br />
v To make all of the functions for a given program visible except for the<br />
ftpc_get_file function, specify APP_EXPORT := ALL in the makefile for the<br />
program and code the following in your C/C++ application source code:<br />
__attribute__ ((visibility("hidden")))<br />
size_t ftpc_get_file (void *ptr, size_t size, size_t nmemb, void *stream)<br />
{<br />
...<br />
}<br />
Adding the attribute hides the C/C++ function.<br />
v To hide all of the functions for a given program except for the mq_msg function,<br />
specify APP_EXPORT := VISIBILITY in the makefile for the program and code<br />
the following in your C/C++ application source code:<br />
__attribute__ ((visibility("default")))<br />
char *mq_msg(size_t buffer_length);<br />
Adding the attribute makes the C/C++ function visible.<br />
v In this example, the makefile for program ABCD makes all functions visible by<br />
default. However, the application hides uncallableFunction( ) by declaring it as<br />
a static function; the application also hides anotherUncallableFunction( ) by<br />
using the visibility("hidden") attribute. An important distinction to make is that<br />
the scope of the hidden function in terms of visibility is the shared object, while<br />
the scope of the static function is limited to the object.<br />
abcd.mak:<br />
APP := ABCD<br />
APP_EXPORT := ALL<br />
C_SRC := program.c<br />
program.h: