This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH 1/2] Define PTR_MANGLE and PTR_DEMANGLE unconditionally.
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: libc-alpha at sourceware dot org
- Date: Thu, 31 Oct 2013 20:41:13 +0100
- Subject: [PATCH 1/2] Define PTR_MANGLE and PTR_DEMANGLE unconditionally.
- Authentication-results: sourceware.org; auth=none
Hi,
this patch simplifies logic of pointer demangling as these could be
defined as nop when no mangling takes place.
A followup will fix bug 14594.
* iconv/gconv_cache.c (find_module): Define PTR_MANGLE and PTR_DEMANGLE
unconditionally.
* iconv/gconv_db.c (free_derivation, __gconv_release_step, gen_steps,
increment_counter): Likewise.
* iconv/gconv_dl.c (__gconv_find_shlib): Likewise.
* inet/getnetgrent_r.c (setup): Likewise.
* nss/getXXbyYY_r.c (REENTRANT_NAME): Likewise.
* nss/nsswitch.c (nss_load_all_libraries, nss_load_library,
__nss_lookup_function): Likewise.
---
iconv/gconv_cache.c | 12 ++++++++----
iconv/gconv_db.c | 20 ++++++++------------
iconv/gconv_dl.c | 11 +++++++++--
inet/getnetgrent_r.c | 12 ++++++++----
nss/getXXbyYY_r.c | 18 ++++++++++--------
nss/nsswitch.c | 16 ++++++++--------
6 files changed, 51 insertions(+), 38 deletions(-)
diff --git a/iconv/gconv_cache.c b/iconv/gconv_cache.c
index e5a2eeb..a6a000a 100644
--- a/iconv/gconv_cache.c
+++ b/iconv/gconv_cache.c
@@ -33,6 +33,14 @@
#include "../intl/hash-string.h"
+#ifndef PTR_MANGLE
+# define PTR_MANGLE(x)
+#endif
+
+#ifndef PTR_DEMANGLE
+# define PTR_DEMANGLE(x)
+#endif
+
static void *gconv_cache;
static size_t cache_size;
static int cache_malloced;
@@ -211,15 +219,11 @@ find_module (const char *directory, const char *filename,
if (result->__init_fct != NULL)
{
__gconv_init_fct init_fct = result->__init_fct;
-#ifdef PTR_DEMANGLE
PTR_DEMANGLE (init_fct);
-#endif
status = DL_CALL_FCT (init_fct, (result));
-#ifdef PTR_MANGLE
if (result->__btowc_fct != NULL)
PTR_MANGLE (result->__btowc_fct);
-#endif
}
}
diff --git a/iconv/gconv_db.c b/iconv/gconv_db.c
index 6290ae2..45eb36a 100644
--- a/iconv/gconv_db.c
+++ b/iconv/gconv_db.c
@@ -31,6 +31,14 @@
#include <gconv_int.h>
#include <sysdep.h>
+#ifndef PTR_MANGLE
+# define PTR_MANGLE(x)
+#endif
+
+#ifndef PTR_DEMANGLE
+# define PTR_DEMANGLE(x)
+#endif
+
/* Simple data structure for alias mapping. We have two names, `from'
and `to'. */
@@ -186,9 +194,7 @@ free_derivation (void *p)
assert (deriv->steps[cnt].__shlib_handle != NULL);
__gconv_end_fct end_fct = deriv->steps[cnt].__end_fct;
-#ifdef PTR_DEMANGLE
PTR_DEMANGLE (end_fct);
-#endif
DL_CALL_FCT (end_fct, (&deriv->steps[cnt]));
}
@@ -218,9 +224,7 @@ __gconv_release_step (struct __gconv_step *step)
assert (step->__shlib_handle != NULL);
__gconv_end_fct end_fct = step->__end_fct;
-#ifdef PTR_DEMANGLE
PTR_DEMANGLE (end_fct);
-#endif
DL_CALL_FCT (end_fct, (step));
}
@@ -297,9 +301,7 @@ gen_steps (struct derivation_step *best, const char *toset,
{
assert (result[step_cnt].__shlib_handle != NULL);
-# ifdef PTR_DEMANGLE
PTR_DEMANGLE (init_fct);
-# endif
status = DL_CALL_FCT (init_fct, (&result[step_cnt]));
if (__builtin_expect (status, __GCONV_OK) != __GCONV_OK)
@@ -311,10 +313,8 @@ gen_steps (struct derivation_step *best, const char *toset,
break;
}
-# ifdef PTR_MANGLE
if (result[step_cnt].__btowc_fct != NULL)
PTR_MANGLE (result[step_cnt].__btowc_fct);
-# endif
}
}
else
@@ -395,15 +395,11 @@ increment_counter (struct __gconv_step *steps, size_t nsteps)
__gconv_init_fct init_fct = step->__init_fct;
if (init_fct != NULL)
{
-#ifdef PTR_DEMANGLE
PTR_DEMANGLE (init_fct);
-#endif
DL_CALL_FCT (init_fct, (step));
-#ifdef PTR_MANGLE
if (step->__btowc_fct != NULL)
PTR_MANGLE (step->__btowc_fct);
-#endif
}
}
}
diff --git a/iconv/gconv_dl.c b/iconv/gconv_dl.c
index 7c18848..e92876a 100644
--- a/iconv/gconv_dl.c
+++ b/iconv/gconv_dl.c
@@ -29,6 +29,15 @@
#include <gconv_int.h>
#include <sysdep.h>
+#ifndef PTR_MANGLE
+# define PTR_MANGLE(x)
+#endif
+
+#ifndef PTR_DEMANGLE
+# define PTR_DEMANGLE(x)
+#endif
+
+
#ifdef DEBUG
/* For debugging purposes. */
@@ -129,13 +138,11 @@ __gconv_find_shlib (const char *name)
found->init_fct = __libc_dlsym (found->handle, "gconv_init");
found->end_fct = __libc_dlsym (found->handle, "gconv_end");
-#ifdef PTR_MANGLE
PTR_MANGLE (found->fct);
if (found->init_fct != NULL)
PTR_MANGLE (found->init_fct);
if (found->end_fct != NULL)
PTR_MANGLE (found->end_fct);
-#endif
/* We have succeeded in loading the shared object. */
found->counter = 1;
diff --git a/inet/getnetgrent_r.c b/inet/getnetgrent_r.c
index 044e505..450d08e 100644
--- a/inet/getnetgrent_r.c
+++ b/inet/getnetgrent_r.c
@@ -28,6 +28,14 @@
#include <sysdep.h>
#include <nscd/nscd_proto.h>
+#ifndef PTR_MANGLE
+# define PTR_MANGLE(x)
+#endif
+
+#ifndef PTR_DEMANGLE
+# define PTR_DEMANGLE(x)
+#endif
+
/* Protect above variable against multiple uses at the same time. */
__libc_lock_define_initialized (static, lock)
@@ -56,18 +64,14 @@ setup (void **fctp, service_user **nipp)
same result every time. So we need no locking. */
no_more = __nss_netgroup_lookup (nipp, "setnetgrent", fctp);
startp = no_more ? (service_user *) -1 : *nipp;
-#ifdef PTR_MANGLE
PTR_MANGLE (startp);
-#endif
atomic_write_barrier ();
startp_initialized = true;
}
else
{
service_user *nip = startp;
-#ifdef PTR_DEMANGLE
PTR_DEMANGLE (nip);
-#endif
if (nip == (service_user *) -1)
/* No services at all. */
return 1;
diff --git a/nss/getXXbyYY_r.c b/nss/getXXbyYY_r.c
index 33e63d4..0321079 100644
--- a/nss/getXXbyYY_r.c
+++ b/nss/getXXbyYY_r.c
@@ -131,6 +131,16 @@
# define AF_VAL AF_INET
#endif
+#ifndef PTR_MANGLE
+# define PTR_MANGLE(x)
+#endif
+
+#ifndef PTR_DEMANGLE
+# define PTR_DEMANGLE(x)
+#endif
+
+
+
/* Type of the lookup function we need here. */
typedef enum nss_status (*lookup_function) (ADD_PARAMS, LOOKUP_TYPE *, char *,
size_t, int * H_ERRNO_PARM
@@ -207,9 +217,7 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer,
if (no_more)
{
void *tmp_ptr = (service_user *) -1l;
-#ifdef PTR_MANGLE
PTR_MANGLE (tmp_ptr);
-#endif
startp = tmp_ptr;
}
else
@@ -230,14 +238,10 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer,
#endif /* need _res_hconf */
void *tmp_ptr = fct.l;
-#ifdef PTR_MANGLE
PTR_MANGLE (tmp_ptr);
-#endif
start_fct = tmp_ptr;
tmp_ptr = nip;
-#ifdef PTR_MANGLE
PTR_MANGLE (tmp_ptr);
-#endif
startp = tmp_ptr;
}
@@ -250,10 +254,8 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer,
{
fct.l = start_fct;
nip = startp;
-#ifdef PTR_DEMANGLE
PTR_DEMANGLE (fct.l);
PTR_DEMANGLE (nip);
-#endif
no_more = nip == (service_user *) -1l;
}
diff --git a/nss/nsswitch.c b/nss/nsswitch.c
index c927424..6dd1c5e 100644
--- a/nss/nsswitch.c
+++ b/nss/nsswitch.c
@@ -41,6 +41,14 @@
#include "../nscd/nscd_proto.h"
#include <sysdep.h>
+#ifndef PTR_MANGLE
+# define PTR_MANGLE(x)
+#endif
+
+#ifndef PTR_DEMANGLE
+# define PTR_DEMANGLE(x)
+#endif
+
/* Prototypes for the local functions. */
static name_database *nss_parse_file (const char *fname) internal_function;
static name_database_entry *nss_getline (char *line) internal_function;
@@ -382,9 +390,7 @@ nss_load_library (service_user *ni)
if (ifct != NULL)
{
void (*cb) (size_t, struct traced_file *) = nscd_init_cb;
-# ifdef PTR_DEMANGLE
PTR_DEMANGLE (cb);
-# endif
ifct (cb);
}
}
@@ -421,9 +427,7 @@ __nss_lookup_function (service_user *ni, const char *fct_name)
{
/* The search found an existing structure in the tree. */
result = ((known_function *) *found)->fct_ptr;
-#ifdef PTR_DEMANGLE
PTR_DEMANGLE (result);
-#endif
}
else
{
@@ -513,9 +517,7 @@ __nss_lookup_function (service_user *ni, const char *fct_name)
/* Remember function pointer for later calls. Even if null, we
record it so a second try needn't search the library again. */
known->fct_ptr = result;
-#ifdef PTR_MANGLE
PTR_MANGLE (known->fct_ptr);
-#endif
}
}
@@ -838,9 +840,7 @@ nss_load_all_libraries (const char *service, const char *def)
void
__nss_disable_nscd (void (*cb) (size_t, struct traced_file *))
{
-# ifdef PTR_MANGLE
PTR_MANGLE (cb);
-# endif
nscd_init_cb = cb;
is_nscd = true;
--
1.8.4.rc3