summaryrefslogtreecommitdiff
path: root/sysdeps/posix/sprofil.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/posix/sprofil.c')
-rw-r--r--sysdeps/posix/sprofil.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/sysdeps/posix/sprofil.c b/sysdeps/posix/sprofil.c
index d9d639aaad..621771eb40 100644
--- a/sysdeps/posix/sprofil.c
+++ b/sysdeps/posix/sprofil.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2018 Free Software Foundation, Inc.
+/* Copyright (C) 2001-2019 Free Software Foundation, Inc.
Contributed by David Mosberger-Tang <davidm@hpl.hp.com>.
This file is part of the GNU C Library.
@@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
+ <https://www.gnu.org/licenses/>. */
#include <assert.h>
#include <signal.h>
@@ -105,10 +105,10 @@ index_to_pc (unsigned long int n, size_t offset, unsigned int scale,
}
static void
-profil_count (void *pcp, int prof_uint)
+profil_count (uintptr_t pcp, int prof_uint)
{
struct region *region, *r = prof_info.last;
- size_t lo, hi, mid, pc = (unsigned long int) pcp;
+ size_t lo, hi, mid, pc = pcp;
unsigned long int i;
/* Fast path: pc is in same region as before. */
@@ -165,13 +165,13 @@ profil_count (void *pcp, int prof_uint)
}
static inline void
-profil_count_ushort (void *pcp)
+profil_count_ushort (uintptr_t pcp)
{
profil_count (pcp, 0);
}
static inline void
-profil_count_uint (void *pcp)
+profil_count_uint (uintptr_t pcp)
{
profil_count (pcp, 1);
}
@@ -334,11 +334,18 @@ __sprofil (struct prof *profp, int profcnt, struct timeval *tvp,
prof_info.last = prof_info.region;
/* Install SIGPROF handler. */
- if (flags & PROF_UINT)
- act.sa_handler = (sighandler_t) &__profil_counter_uint;
- else
- act.sa_handler = (sighandler_t) &__profil_counter_ushort;
- act.sa_flags = SA_RESTART;
+#ifdef SA_SIGINFO
+ act.sa_sigaction= flags & PROF_UINT
+ ? __profil_counter_uint
+ : __profil_counter_ushort;
+ act.sa_flags = SA_SIGINFO;
+#else
+ act.sa_handler = flags & PROF_UINT
+ ? (sighandler_t) __profil_counter_uint
+ : (sighandler_t) __profil_counter_ushort;
+ act.sa_flags = 0;
+#endif
+ act.sa_flags |= SA_RESTART;
__sigfillset (&act.sa_mask);
if (__sigaction (SIGPROF, &act, &prof_info.saved_action) < 0)
return -1;