Skip to content

Commit 416b250

Browse files
nbourdauzarvox
authored andcommitted
Hides unexported symbols
Mark all non static internal functions with visibility hidden on ELF platform. Declare some internal symbols that were meant to have static linkage as such. On win32 the hidden visibility is no op since it is the default behavior. Signed-off-by: Nicolas Bourdaud <nicolas.bourdaud@gmail.com>
1 parent bbc109a commit 416b250

File tree

6 files changed

+34
-27
lines changed

6 files changed

+34
-27
lines changed

src/cameras.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#define RESERVED_TO_FORMAT(reserved) ((reserved) & 0xff)
3939

4040
#define video_mode_count 12
41-
freenect_frame_mode supported_video_modes[video_mode_count] = {
41+
static freenect_frame_mode supported_video_modes[video_mode_count] = {
4242
// reserved, resolution, format, bytes, width, height, data_bits_per_pixel, padding_bits_per_pixel, framerate, is_valid
4343
{MAKE_RESERVED(FREENECT_RESOLUTION_HIGH, FREENECT_VIDEO_RGB), FREENECT_RESOLUTION_HIGH, {FREENECT_VIDEO_RGB}, 1280*1024*3, 1280, 1024, 24, 0, 10, 1 },
4444
{MAKE_RESERVED(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_RGB), FREENECT_RESOLUTION_MEDIUM, {FREENECT_VIDEO_RGB}, 640*480*3, 640, 480, 24, 0, 30, 1 },
@@ -61,7 +61,7 @@ freenect_frame_mode supported_video_modes[video_mode_count] = {
6161
};
6262

6363
#define depth_mode_count 6
64-
freenect_frame_mode supported_depth_modes[depth_mode_count] = {
64+
static freenect_frame_mode supported_depth_modes[depth_mode_count] = {
6565
// reserved, resolution, format, bytes, width, height, data_bits_per_pixel, padding_bits_per_pixel, framerate, is_valid
6666
{MAKE_RESERVED(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT), FREENECT_RESOLUTION_MEDIUM, {FREENECT_DEPTH_11BIT}, 640*480*2, 640, 480, 11, 5, 30, 1},
6767
{MAKE_RESERVED(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_10BIT), FREENECT_RESOLUTION_MEDIUM, {FREENECT_DEPTH_10BIT}, 640*480*2, 640, 480, 10, 6, 30, 1},
@@ -1323,7 +1323,7 @@ int freenect_set_video_buffer(freenect_device *dev, void *buf)
13231323
return stream_setbuf(dev->parent, &dev->video, buf);
13241324
}
13251325

1326-
int freenect_camera_init(freenect_device *dev)
1326+
FN_INTERNAL int freenect_camera_init(freenect_device *dev)
13271327
{
13281328
freenect_context *ctx = dev->parent;
13291329
int res;
@@ -1347,7 +1347,7 @@ int freenect_camera_init(freenect_device *dev)
13471347
return 0;
13481348
}
13491349

1350-
int freenect_camera_teardown(freenect_device *dev)
1350+
FN_INTERNAL int freenect_camera_teardown(freenect_device *dev)
13511351
{
13521352
freenect_context *ctx = dev->parent;
13531353
int res = 0;

src/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ FREENECTAPI void freenect_set_log_callback(freenect_context *ctx, freenect_log_c
260260
ctx->log_cb = cb;
261261
}
262262

263-
void fn_log(freenect_context *ctx, freenect_loglevel level, const char *fmt, ...)
263+
FN_INTERNAL void fn_log(freenect_context *ctx, freenect_loglevel level, const char *fmt, ...)
264264
{
265265
va_list ap;
266266

src/freenect_internal.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@
3636
#include "libfreenect-audio.h"
3737
#endif
3838

39+
#ifdef __ELF__
40+
#define FN_INTERNAL __attribute__ ((visibility ("hidden")))
41+
#else
42+
#define FN_INTERNAL
43+
#endif
44+
45+
3946
typedef void (*fnusb_iso_cb)(freenect_device *dev, uint8_t *buf, int len);
4047

4148
#include "usb_libusb10.h"

src/loader.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ static int check_version_string(fnusb_dev* dev) {
120120
return res;
121121
}
122122

123-
int upload_firmware(fnusb_dev* dev) {
123+
FN_INTERNAL int upload_firmware(fnusb_dev* dev) {
124124
freenect_context* ctx = dev->parent->parent;
125125
bootloader_command bootcmd;
126126
memset(&bootcmd, 0, sizeof(bootcmd));
@@ -248,7 +248,7 @@ int upload_firmware(fnusb_dev* dev) {
248248
return 0;
249249
}
250250

251-
int upload_cemd_data(fnusb_dev* dev) {
251+
FN_INTERNAL int upload_cemd_data(fnusb_dev* dev) {
252252
// Now we upload the CEMD data.
253253
freenect_context* ctx = dev->parent->parent;
254254
cemdloader_command cemdcmd;

src/registration.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static void freenect_init_depth_to_rgb(int32_t* depth_to_rgb, freenect_zero_plan
7474
}
7575

7676
// unrolled inner loop of the 11-bit unpacker
77-
inline void unpack_8_pixels(uint8_t *raw, uint16_t *frame)
77+
static inline void unpack_8_pixels(uint8_t *raw, uint16_t *frame)
7878
{
7979
uint16_t baseMask = 0x7FF;
8080

@@ -101,7 +101,7 @@ inline void unpack_8_pixels(uint8_t *raw, uint16_t *frame)
101101
}
102102

103103
// apply registration data to a single packed frame
104-
int freenect_apply_registration(freenect_device* dev, uint8_t* input_packed, uint16_t* output_mm)
104+
FN_INTERNAL int freenect_apply_registration(freenect_device* dev, uint8_t* input_packed, uint16_t* output_mm)
105105
{
106106
freenect_registration* reg = &(dev->registration);
107107
// set output buffer to zero using pointer-sized memory access (~ 30-40% faster than memset)
@@ -169,7 +169,7 @@ int freenect_apply_registration(freenect_device* dev, uint8_t* input_packed, uin
169169
}
170170

171171
// Same as freenect_apply_registration, but don't bother aligning to the RGB image
172-
int freenect_apply_depth_to_mm(freenect_device* dev, uint8_t* input_packed, uint16_t* output_mm)
172+
FN_INTERNAL int freenect_apply_depth_to_mm(freenect_device* dev, uint8_t* input_packed, uint16_t* output_mm)
173173
{
174174
freenect_registration* reg = &(dev->registration);
175175
uint16_t unpack[8];
@@ -289,9 +289,9 @@ static void freenect_init_registration_table(int32_t (*registration_table)[2], f
289289
}
290290

291291
// These are just constants.
292-
double parameter_coefficient = 4;
293-
double shift_scale = 10;
294-
double pixel_size_factor = 1;
292+
static double parameter_coefficient = 4;
293+
static double shift_scale = 10;
294+
static double pixel_size_factor = 1;
295295

296296
/// convert raw shift value to metric depth (in mm)
297297
static uint16_t freenect_raw_to_mm(uint16_t raw, freenect_registration* reg)
@@ -332,7 +332,7 @@ void freenect_camera_to_world(freenect_device* dev, int cx, int cy, int wz, doub
332332
/// Allocate and fill registration tables
333333
/// This function should be called every time a new video (not depth!) mode is
334334
/// activated.
335-
int freenect_init_registration(freenect_device* dev)
335+
FN_INTERNAL int freenect_init_registration(freenect_device* dev)
336336
{
337337
freenect_registration* reg = &(dev->registration);
338338

src/usb_libusb10.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include "freenect_internal.h"
3434
#include "loader.h"
3535

36-
int fnusb_num_devices(fnusb_ctx *ctx)
36+
FN_INTERNAL int fnusb_num_devices(fnusb_ctx *ctx)
3737
{
3838
libusb_device **devs;
3939
//pointer to pointer of device, used to retrieve a list of devices
@@ -56,7 +56,7 @@ int fnusb_num_devices(fnusb_ctx *ctx)
5656
return nr;
5757
}
5858

59-
int fnusb_list_device_attributes(fnusb_ctx *ctx, struct freenect_device_attributes** attribute_list)
59+
FN_INTERNAL int fnusb_list_device_attributes(fnusb_ctx *ctx, struct freenect_device_attributes** attribute_list)
6060
{
6161
*attribute_list = NULL; // initialize some return value in case the user is careless.
6262
libusb_device **devs;
@@ -116,7 +116,7 @@ int fnusb_list_device_attributes(fnusb_ctx *ctx, struct freenect_device_attribut
116116
return num_cams;
117117
}
118118

119-
int fnusb_init(fnusb_ctx *ctx, freenect_usb_context *usb_ctx)
119+
FN_INTERNAL int fnusb_init(fnusb_ctx *ctx, freenect_usb_context *usb_ctx)
120120
{
121121
int res;
122122
if (!usb_ctx) {
@@ -137,7 +137,7 @@ int fnusb_init(fnusb_ctx *ctx, freenect_usb_context *usb_ctx)
137137
}
138138
}
139139

140-
int fnusb_shutdown(fnusb_ctx *ctx)
140+
FN_INTERNAL int fnusb_shutdown(fnusb_ctx *ctx)
141141
{
142142
//int res;
143143
if (ctx->should_free_ctx) {
@@ -147,17 +147,17 @@ int fnusb_shutdown(fnusb_ctx *ctx)
147147
return 0;
148148
}
149149

150-
int fnusb_process_events(fnusb_ctx *ctx)
150+
FN_INTERNAL int fnusb_process_events(fnusb_ctx *ctx)
151151
{
152152
return libusb_handle_events(ctx->ctx);
153153
}
154154

155-
int fnusb_process_events_timeout(fnusb_ctx *ctx, struct timeval* timeout)
155+
FN_INTERNAL int fnusb_process_events_timeout(fnusb_ctx *ctx, struct timeval* timeout)
156156
{
157157
return libusb_handle_events_timeout(ctx->ctx, timeout);
158158
}
159159

160-
int fnusb_open_subdevices(freenect_device *dev, int index)
160+
FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index)
161161
{
162162
freenect_context *ctx = dev->parent;
163163

@@ -392,7 +392,7 @@ int fnusb_open_subdevices(freenect_device *dev, int index)
392392
}
393393
}
394394

395-
int fnusb_close_subdevices(freenect_device *dev)
395+
FN_INTERNAL int fnusb_close_subdevices(freenect_device *dev)
396396
{
397397
if (dev->usb_cam.dev) {
398398
libusb_release_interface(dev->usb_cam.dev, 0);
@@ -499,7 +499,7 @@ static void iso_callback(struct libusb_transfer *xfer)
499499
}
500500
}
501501

502-
int fnusb_start_iso(fnusb_dev *dev, fnusb_isoc_stream *strm, fnusb_iso_cb cb, int ep, int xfers, int pkts, int len)
502+
FN_INTERNAL int fnusb_start_iso(fnusb_dev *dev, fnusb_isoc_stream *strm, fnusb_iso_cb cb, int ep, int xfers, int pkts, int len)
503503
{
504504
freenect_context *ctx = dev->parent->parent;
505505
int ret, i;
@@ -537,7 +537,7 @@ int fnusb_start_iso(fnusb_dev *dev, fnusb_isoc_stream *strm, fnusb_iso_cb cb, in
537537

538538
}
539539

540-
int fnusb_stop_iso(fnusb_dev *dev, fnusb_isoc_stream *strm)
540+
FN_INTERNAL int fnusb_stop_iso(fnusb_dev *dev, fnusb_isoc_stream *strm)
541541
{
542542
freenect_context *ctx = dev->parent->parent;
543543
int i;
@@ -568,17 +568,17 @@ int fnusb_stop_iso(fnusb_dev *dev, fnusb_isoc_stream *strm)
568568
return 0;
569569
}
570570

571-
int fnusb_control(fnusb_dev *dev, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint8_t *data, uint16_t wLength)
571+
FN_INTERNAL int fnusb_control(fnusb_dev *dev, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint8_t *data, uint16_t wLength)
572572
{
573573
return libusb_control_transfer(dev->dev, bmRequestType, bRequest, wValue, wIndex, data, wLength, 0);
574574
}
575575

576576
#ifdef BUILD_AUDIO
577-
int fnusb_bulk(fnusb_dev *dev, uint8_t endpoint, uint8_t *data, int len, int *transferred) {
577+
FN_INTERNAL int fnusb_bulk(fnusb_dev *dev, uint8_t endpoint, uint8_t *data, int len, int *transferred) {
578578
return libusb_bulk_transfer(dev->dev, endpoint, data, len, transferred, 0);
579579
}
580580

581-
int fnusb_num_interfaces(fnusb_dev *dev) {
581+
FN_INTERNAL int fnusb_num_interfaces(fnusb_dev *dev) {
582582
int retval = 0;
583583
int res;
584584
libusb_device* d = libusb_get_device(dev->dev);

0 commit comments

Comments
 (0)