Skip to contentSkip to conversation

radeon: Hide non-public symbols.

PATCH New Cyril Brulebois 1 participant 2 messages Mar 5, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 radeon: Hide non-public symbols.

There's no reason to export those symbols, since they are only meant to be used internally, so mark them as such. An alternative might be to use a linker script.

---
 radeon/bof.c |   36 ++++++++++++++++++------------------
 radeon/bof.h |   10 ++++++++++
 2 files changed, 28 insertions(+), 18 deletions(-)
radeon/bof.c +18 -18
index 0598cc6..7d178cb 100644
@@ -48,7 +48,7 @@ static int bof_entry_grow(bof_t *bof)
 /*
  * object 
  */
-bof_t *bof_object(void)
+_X_HIDDEN bof_t *bof_object(void)
 {
 	bof_t *object;
 
@@ -61,7 +61,7 @@ bof_t *bof_object(void)
 	return object;
 }
 
-bof_t *bof_object_get(bof_t *object, const char *keyname)
+_X_HIDDEN bof_t *bof_object_get(bof_t *object, const char *keyname)
 {
 	unsigned i;
 
@@ -73,7 +73,7 @@ bof_t *bof_object_get(bof_t *object, const char *keyname)
 	return NULL;
 }
 
-int bof_object_set(bof_t *object, const char *keyname, bof_t *value)
+_X_HIDDEN int bof_object_set(bof_t *object, const char *keyname, bof_t *value)
 {
 	bof_t *key;
 	int r;
@@ -97,7 +97,7 @@ int bof_object_set(bof_t *object, const char *keyname, bof_t *value)
 /*
  * array
  */
-bof_t *bof_array(void)
+_X_HIDDEN bof_t *bof_array(void)
 {
 	bof_t *array = bof_object();
 
@@ -108,7 +108,7 @@ bof_t *bof_array(void)
 	return array;
 }
 
-int bof_array_append(bof_t *array, bof_t *value)
+_X_HIDDEN int bof_array_append(bof_t *array, bof_t *value)
 {
 	int r;
 	if (array->type != BOF_TYPE_ARRAY)
@@ -122,14 +122,14 @@ int bof_array_append(bof_t *array, bof_t *value)
 	return 0;
 }
 
-bof_t *bof_array_get(bof_t *bof, unsigned i)
+_X_HIDDEN bof_t *bof_array_get(bof_t *bof, unsigned i)
 {
 	if (!bof_is_array(bof) || i >= bof->array_size)
 		return NULL;
 	return bof->array[i];
 }
 
-unsigned bof_array_size(bof_t *bof)
+_X_HIDDEN unsigned bof_array_size(bof_t *bof)
 {
 	if (!bof_is_array(bof))
 		return 0;
@@ -139,7 +139,7 @@ unsigned bof_array_size(bof_t *bof)
 /*
  * blob
  */
-bof_t *bof_blob(unsigned size, void *value)
+_X_HIDDEN bof_t *bof_blob(unsigned size, void *value)
 {
 	bof_t *blob = bof_object();
 
@@ -157,14 +157,14 @@ bof_t *bof_blob(unsigned size, void *value)
 	return blob;
 }
 
-unsigned bof_blob_size(bof_t *bof)
+_X_HIDDEN unsigned bof_blob_size(bof_t *bof)
 {
 	if (!bof_is_blob(bof))
 		return 0;
 	return bof->size - 12;
 }
 
-void *bof_blob_value(bof_t *bof)
+_X_HIDDEN void *bof_blob_value(bof_t *bof)
 {
 	if (!bof_is_blob(bof))
 		return NULL;
@@ -174,7 +174,7 @@ void *bof_blob_value(bof_t *bof)
 /*
  * string
  */
-bof_t *bof_string(const char *value)
+_X_HIDDEN bof_t *bof_string(const char *value)
 {
 	bof_t *string = bof_object();
 
@@ -195,7 +195,7 @@ bof_t *bof_string(const char *value)
 /*
  *  int32
  */
-bof_t *bof_int32(int32_t value)
+_X_HIDDEN bof_t *bof_int32(int32_t value)
 {
 	bof_t *int32 = bof_object();
 
@@ -213,7 +213,7 @@ bof_t *bof_int32(int32_t value)
 	return int32;
 }
 
-int32_t bof_int32_value(bof_t *bof)
+_X_HIDDEN int32_t bof_int32_value(bof_t *bof)
 {
 	return *((uint32_t*)bof->value);
 }
@@ -271,7 +271,7 @@ static void bof_print_rec(bof_t *bof, int level, int entry)
 	}
 }
 
-void bof_print(bof_t *bof)
+_X_HIDDEN void bof_print(bof_t *bof)
 {
 	bof_print_rec(bof, 0, 0);
 }
@@ -333,7 +333,7 @@ out_err:
 	return -EINVAL;
 }
 
-bof_t *bof_load_file(const char *filename)
+_X_HIDDEN bof_t *bof_load_file(const char *filename)
 {
 	bof_t *root = bof_object();
 	int r;
@@ -369,12 +369,12 @@ out_err:
 	return NULL;
 }
 
-void bof_incref(bof_t *bof)
+_X_HIDDEN void bof_incref(bof_t *bof)
 {
 	bof->refcount++;
 }
 
-void bof_decref(bof_t *bof)
+_X_HIDDEN void bof_decref(bof_t *bof)
 {
 	unsigned i;
 
@@ -436,7 +436,7 @@ static int bof_file_write(bof_t *bof, FILE *file)
 	return 0;
 }
 
-int bof_dump_file(bof_t *bof, const char *filename)
+_X_HIDDEN int bof_dump_file(bof_t *bof, const char *filename)
 {
 	unsigned i;
 	int r = 0;
radeon/bof.h +10 -0
index 014affb..14cf7e5 100644
@@ -87,4 +87,14 @@ static inline int bof_is_int32(bof_t *bof){return (bof->type == BOF_TYPE_INT32);
 static inline int bof_is_array(bof_t *bof){return (bof->type == BOF_TYPE_ARRAY);}
 static inline int bof_is_string(bof_t *bof){return (bof->type == BOF_TYPE_STRING);}
 
+/* Taken from X11/Xfuncproto.h, keeping only _X_HIDDEN to hide symbols
+ * which shouldn't be exported */
+#if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__CYGWIN__)
+# define _X_HIDDEN      __attribute__((visibility("hidden")))
+#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
+# define _X_HIDDEN      __hidden
+#else /* not gcc >= 4 and not Sun Studio >= 8 */
+# define _X_HIDDEN
+#endif /* GNUC >= 4 */
+
 #endif
Signature · 1 line
1.7.4.1
#1 lore raw

PATCH 2/2 libkms: Hide non-public symbols.

There's no reason to export those symbols, since they are only meant to be used internally, so mark them as such. An alternative might be to use a linker script.

---
 libkms/intel.c   |    2 +-
 libkms/libkms.h  |   10 ++++++++++
 libkms/linux.c   |    2 +-
 libkms/nouveau.c |    2 +-
 libkms/radeon.c  |    2 +-
 libkms/vmwgfx.c  |    2 +-
 6 files changed, 15 insertions(+), 5 deletions(-)
libkms/intel.c +1 -1
index 8b8249b..7b3a915 100644
@@ -214,7 +214,7 @@ intel_bo_destroy(struct kms_bo *_bo)
 	return 0;
 }
 
-int
+_X_HIDDEN int
 intel_create(int fd, struct kms_driver **out)
 {
 	struct kms_driver *kms;
libkms/libkms.h +10 -0
index 4664442..e4c84e7 100644
@@ -71,4 +71,14 @@ int kms_bo_map(struct kms_bo *bo, void **out);
 int kms_bo_unmap(struct kms_bo *bo);
 int kms_bo_destroy(struct kms_bo **bo);
 
+/* Taken from X11/Xfuncproto.h, keeping only _X_HIDDEN to hide symbols
+ * which shouldn't be exported */
+#if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__CYGWIN__)
+# define _X_HIDDEN      __attribute__((visibility("hidden")))
+#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
+# define _X_HIDDEN      __hidden
+#else /* not gcc >= 4 and not Sun Studio >= 8 */
+# define _X_HIDDEN
+#endif /* GNUC >= 4 */
+
 #endif
libkms/linux.c +1 -1
index fc4f205..9eab83d 100644
@@ -213,7 +213,7 @@ linux_from_udev(int fd, struct kms_driver **out)
 }
 #endif
 
-int
+_X_HIDDEN int
 linux_create(int fd, struct kms_driver **out)
 {
 	if (!dumb_create(fd, out))
libkms/nouveau.c +1 -1
index 0e24a15..16eec6d 100644
@@ -196,7 +196,7 @@ nouveau_bo_destroy(struct kms_bo *_bo)
 	return 0;
 }
 
-int
+_X_HIDDEN int
 nouveau_create(int fd, struct kms_driver **out)
 {
 	struct kms_driver *kms;
libkms/radeon.c +1 -1
index f5e382a..3bec92d 100644
@@ -218,7 +218,7 @@ radeon_bo_destroy(struct kms_bo *_bo)
 	return 0;
 }
 
-int
+_X_HIDDEN int
 radeon_create(int fd, struct kms_driver **out)
 {
 	struct kms_driver *kms;
libkms/vmwgfx.c +1 -1
index d594b3b..bcf1b93 100644
@@ -184,7 +184,7 @@ vmwgfx_bo_destroy(struct kms_bo *_bo)
 	return 0;
 }
 
-int
+_X_HIDDEN int
 vmwgfx_create(int fd, struct kms_driver **out)
 {
 	struct kms_driver *kms;
Signature · 1 line
1.7.4.1