summaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/generic/prof-freq.c59
-rw-r--r--sysdeps/mach/hurd/i386/init-first.c7
-rw-r--r--sysdeps/mach/hurd/prof-freq.c2
-rw-r--r--sysdeps/mach/hurd/profil.c12
-rw-r--r--sysdeps/mach/hurd/sendto.c13
5 files changed, 81 insertions, 12 deletions
diff --git a/sysdeps/generic/prof-freq.c b/sysdeps/generic/prof-freq.c
new file mode 100644
index 0000000000..4e952e781d
--- /dev/null
+++ b/sysdeps/generic/prof-freq.c
@@ -0,0 +1,59 @@
+/* Return frequency of ticks reported by profil. Generic version. */
+/*-
+ * Copyright (c) 1983, 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+
+#include <sys/types.h>
+#include <sys/time.h>
+
+int
+__profile_frequency ()
+{
+ /*
+ * Discover the tick frequency of the machine if something goes wrong,
+ * we return 0, an impossible hertz.
+ */
+ struct itimerval tim;
+
+ tim.it_interval.tv_sec = 0;
+ tim.it_interval.tv_usec = 1;
+ tim.it_value.tv_sec = 0;
+ tim.it_value.tv_usec = 0;
+ setitimer(ITIMER_REAL, &tim, 0);
+ setitimer(ITIMER_REAL, 0, &tim);
+ if (tim.it_interval.tv_usec < 2)
+ return 0;
+ return (1000000 / tim.it_interval.tv_usec);
+}
+
+
diff --git a/sysdeps/mach/hurd/i386/init-first.c b/sysdeps/mach/hurd/i386/init-first.c
index d095580cfd..5203b4c146 100644
--- a/sysdeps/mach/hurd/i386/init-first.c
+++ b/sysdeps/mach/hurd/i386/init-first.c
@@ -31,15 +31,16 @@ extern void __libc_global_ctors (void);
int __libc_multiple_libcs = 1;
+int __libc_argc;
+char **__libc_argv;
+
void *(*_cthread_init_routine) (void); /* Returns new SP to use. */
void (*_cthread_exit_routine) (int status) __attribute__ ((__noreturn__));
-
/* Things that want to be run before _hurd_init or much anything else.
Importantly, these are called before anything tries to use malloc. */
DEFINE_HOOK (_hurd_preinit_hook, (void));
-
static void
init1 (int argc, char *arg0, ...)
{
@@ -47,6 +48,8 @@ init1 (int argc, char *arg0, ...)
char **envp = &argv[argc + 1];
struct hurd_startup_data *d;
+ __libc_argc = argc;
+ __libc_argv = argv;
__environ = envp;
while (*envp)
++envp;
diff --git a/sysdeps/mach/hurd/prof-freq.c b/sysdeps/mach/hurd/prof-freq.c
new file mode 100644
index 0000000000..a3707033a6
--- /dev/null
+++ b/sysdeps/mach/hurd/prof-freq.c
@@ -0,0 +1,2 @@
+/* __profile_frequency is in sysdeps/mach/hurd/profil.c. This file
+is here as a place-holder to prevent the use of sysdeps/generic/prof-freq.c. */
diff --git a/sysdeps/mach/hurd/profil.c b/sysdeps/mach/hurd/profil.c
index 431982e498..41c7c4b956 100644
--- a/sysdeps/mach/hurd/profil.c
+++ b/sysdeps/mach/hurd/profil.c
@@ -36,6 +36,7 @@ static size_t sample_scale;
static sampled_pc_seqno_t seqno;
static struct mutex lock = MUTEX_INITIALIZER;
static mach_msg_timeout_t collector_timeout; /* ms between collections. */
+static int profile_tick;
/* Enable statistical profiling, writing samples of the PC into at most
SIZE bytes of SAMPLE_BUFFER; every processor clock tick while profiling
@@ -62,8 +63,7 @@ update_waiter (u_short *sample_buffer, size_t size, size_t offset, u_int scale)
if (! err)
{
- int tick; /* Microseconds per sample. */
- err = __task_enable_pc_sampling (__mach_task_self (), &tick,
+ err = __task_enable_pc_sampling (__mach_task_self (), &profile_tick,
SAMPLED_PC_PERIODIC);
if (!err && sample_scale == 0)
/* Profiling was not turned on, so the collector thread was
@@ -79,7 +79,7 @@ update_waiter (u_short *sample_buffer, size_t size, size_t offset, u_int scale)
and the kernel buffer size we get the length of time it takes
to fill the buffer; translate that to milliseconds for
mach_msg, and chop it in half for general lag factor. */
- collector_timeout = MAX_PC_SAMPLES * tick / 1000 / 2;
+ collector_timeout = MAX_PC_SAMPLES * profile_tick / 1000 / 2;
}
}
@@ -87,6 +87,12 @@ update_waiter (u_short *sample_buffer, size_t size, size_t offset, u_int scale)
}
int
+__profile_frequency ()
+{
+ return profile_tick;
+}
+
+int
profil (u_short *sample_buffer, size_t size, size_t offset, u_int scale)
{
error_t err;
diff --git a/sysdeps/mach/hurd/sendto.c b/sysdeps/mach/hurd/sendto.c
index 88026b8cf5..1be2cbb6ec 100644
--- a/sysdeps/mach/hurd/sendto.c
+++ b/sysdeps/mach/hurd/sendto.c
@@ -27,13 +27,12 @@ Cambridge, MA 02139, USA. */
/* Send N bytes of BUF on socket FD to peer at address ADDR (which is
ADDR_LEN bytes long). Returns the number sent, or -1 for errors. */
int
-sendto (fd, buf, n, flags, addr, addr_len)
- int fd;
- const void *buf;
- size_t n;
- int flags;
- const struct sockaddr_un *addr;
- size_t addr_len;
+sendto (int fd,
+ const void *buf,
+ size_t n,
+ int flags,
+ const struct sockaddr_un *addr,
+ size_t addr_len)
{
addr_port_t aport;
error_t err;