summaryrefslogtreecommitdiff
path: root/i386
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2006-11-05 18:54:52 +0000
committerThomas Schwinge <tschwinge@gnu.org>2009-06-18 00:26:50 +0200
commitffc607f8a4c1c6f1c63a7b61b54f185ada87a9a5 (patch)
tree35fb5835c103b647de4de4a53ba94e4b1b5cb563 /i386
parent7e8b31e61e4bd9207bde37662e757a5988c556df (diff)
2006-11-05 Barry deFreese <bddebian@comcast.net>
memcpy/memset cleanup. * include/string.h: New file. * include/mach/mig_support.h: Include `string.h'. [MACH_KERNEL] (bcopy): Remove extern declaration. [MACH_KERNEL] (memcpy): Remove macro. * device/cirbuf.c: Include `string.h'. (q_to_b, b_to_q): Replace bcopy() with memcpy() and bzero() with memset(), clean memcpy() and memset() invocation. * device/cons.c (cnputc): Likewise. * device/dev_pager.c (device_pager_data_request_done): Likewise. * device/ds_routines.c (device_write_get, ds_read_done): Likewise. * device/kmsg.c: Likewise. * device/net_io.c (net_filter, net_set_filter, net_getstat): Likewise. * i386/i386/fpu.c (fpu_set_state, fpu_get_state) fp_load) (fp_state_alloc): Likewise. * i386/i386/iopb.c (io_tss_init, i386_io_port_list): Likewise. * i386/i386/mp_desc.c (mp_desc_init): Likewise. * i386/i386/pcb.c (pcb_init, thread_setstatus) (thread_getstatus): Likewise. * i386/i386/phys.c (pmap_zero_page, pmap_copy_page, copy_to_phys) (copy_from_phys): Likewise. * i386/i386/trap.c (v86_assist): Likewise. * i386/i386/user_ldt.c (i386_set_ldt, i386_get_ldt): Likewise. * i386/i386at/immc.c (immc_cnputc): Likewise. * i386/i386at/kd_event.c (X_kdb_enter_init, X_kdb_exit_init): Likewise. * i386/intel/pmap.c (pmap_init, pmap_page_table_page_alloc) (pmap_create): Likewise. * ipc/ipc_entry.c (ipc_entry_grow_table): Likewise. * ipc/ipc_kmsg.c (ipc_kmsg_get_from_kernel) (ipc_kmsg_put_to_kernel): Likewise. * ipc/ipc_object.c (ipc_object_alloc, ipc_object_alloc_name): Likewise. * ipc/ipc_port.c (ipc_port_dngrow): Likewise. * ipc/ipc_space.c: Likewise. * ipc/mach_debug.c (mach_port_space_info) (mach_port_space_info): Likewise. * kern/act.c (act_create): Likewise. * kern/boot_script.c: Likewise. * kern/bootstrap.c: Likewise. * kern/eventcount.c (evc_init): Likewise. * kern/host.c (host_info, host_processor_sets): Likewise. * kern/lock.c (lock_init): Likewise. * kern/lock_mon.c (lock_info_clear): Likewise. * kern/mach_clock.c (mapable_time_init): Likewise. * kern/pc_sample.c (get_sampled_pcs): Likewise. * kern/processor.c (processor_set_things): Likewise. * kern/syscall_emulation.c (task_set_emulation_vector_internal) (task_get_emulation_vector, xxx_task_get_emulation_vector): Likewise. * kern/task.c (task_threads): Likewise. * kern/xpr.c (xprbootstrap): Likewise. * kern/zalloc.c (host_zone_info): Likewise. * vm/vm_debug.c (mach_vm_object_pages): Likewise. * vm/vm_kern.c (projected_buffer_allocate, copyinmap) (copyoutmap): Likewise. * vm/vm_object.c (vm_object_bootstrap): Likewise. * vm/vm_resident.c (vm_page_grab_contiguous_pages): Likewise.
Diffstat (limited to 'i386')
-rw-r--r--i386/i386/fpu.c32
-rw-r--r--i386/i386/iopb.c6
-rw-r--r--i386/i386/mp_desc.c16
-rw-r--r--i386/i386/pcb.c16
-rw-r--r--i386/i386/phys.c12
-rw-r--r--i386/i386/trap.c8
-rw-r--r--i386/i386/user_ldt.c22
-rw-r--r--i386/i386at/immc.c6
-rw-r--r--i386/i386at/kd_event.c6
-rw-r--r--i386/intel/pmap.c8
10 files changed, 76 insertions, 56 deletions
diff --git a/i386/i386/fpu.c b/i386/i386/fpu.c
index 9a82d01..350d172 100644
--- a/i386/i386/fpu.c
+++ b/i386/i386/fpu.c
@@ -27,6 +27,8 @@
* Support for 80387 floating point or FP emulator.
*/
+#include <string.h>
+
#include <mach/exception.h>
#include <mach/machine/thread_status.h>
#include <mach/machine/fp_reg.h>
@@ -262,7 +264,7 @@ ASSERT_IPL(SPL0);
/*
* Ensure that reserved parts of the environment are 0.
*/
- bzero((char *)&ifps->fp_save_state, sizeof(struct i386_fp_save));
+ memset(&ifps->fp_save_state, 0, sizeof(struct i386_fp_save));
ifps->fp_save_state.fp_control = user_fp_state->fp_control;
ifps->fp_save_state.fp_status = user_fp_state->fp_status;
@@ -290,13 +292,13 @@ ASSERT_IPL(SPL0);
>> FPS_TOS_SHIFT; /* physical register
for st(0) */
if (i == 0)
- bcopy(src, dst, 8 * 10);
+ memcpy(dst, src, 8 * 10);
else {
- bcopy(src,
- dst + 10 * i,
+ memcpy(dst + 10 * i,
+ src,
10 * (8 - i));
- bcopy(src + 10 * (8 - i),
- dst,
+ memcpy(dst,
+ src + 10 * (8 - i),
10 * i);
}
}
@@ -339,7 +341,7 @@ ASSERT_IPL(SPL0);
* No valid floating-point state.
*/
simple_unlock(&pcb->lock);
- bzero((char *)state, sizeof(struct i386_float_state));
+ memset(state, 0, sizeof(struct i386_float_state));
return KERN_SUCCESS;
}
@@ -372,7 +374,7 @@ ASSERT_IPL(SPL0);
/*
* Ensure that reserved parts of the environment are 0.
*/
- bzero((char *)user_fp_state, sizeof(struct i386_fp_save));
+ memset(user_fp_state, 0, sizeof(struct i386_fp_save));
user_fp_state->fp_control = ifps->fp_save_state.fp_control;
user_fp_state->fp_status = ifps->fp_save_state.fp_status;
@@ -400,13 +402,13 @@ ASSERT_IPL(SPL0);
>> FPS_TOS_SHIFT; /* physical register
for st(0) */
if (i == 0)
- bcopy(src, dst, 8 * 10);
+ memcpy(dst, src, 8 * 10);
else {
- bcopy(src + 10 * i,
- dst,
+ memcpy(dst,
+ src + 10 * i,
10 * (8 - i));
- bcopy(src,
- dst + 10 * (8 - i),
+ memcpy(dst + 10 * (8 - i),
+ src,
10 * i);
}
}
@@ -635,7 +637,7 @@ ASSERT_IPL(SPL0);
ifps = pcb->ims.ifps;
if (ifps == 0) {
ifps = (struct i386_fpsave_state *) zalloc(ifps_zone);
- bzero(ifps, sizeof *ifps);
+ memset(ifps, 0, sizeof *ifps);
pcb->ims.ifps = ifps;
fpinit();
#if 1
@@ -681,7 +683,7 @@ fp_state_alloc()
struct i386_fpsave_state *ifps;
ifps = (struct i386_fpsave_state *)zalloc(ifps_zone);
- bzero(ifps, sizeof *ifps);
+ memset(ifps, 0, sizeof *ifps);
pcb->ims.ifps = ifps;
ifps->fp_valid = TRUE;
diff --git a/i386/i386/iopb.c b/i386/i386/iopb.c
index 97e10c9..f1e859a 100644
--- a/i386/i386/iopb.c
+++ b/i386/i386/iopb.c
@@ -27,6 +27,8 @@
* Code to manipulate IO permission bitmaps.
*/
+#include <string.h>
+
#include <mach/boolean.h>
#include <mach/kern_return.h>
@@ -246,7 +248,7 @@ io_tss_init(
vm_offset_t addr = kvtolin (io_tss);
vm_size_t limit = (char *)&io_tss->barrier - (char *)io_tss;
- bzero(&io_tss->tss, sizeof(struct i386_tss));
+ memset(&io_tss->tss, 0, sizeof(struct i386_tss));
io_tss->tss.io_bit_map_offset
= (char *)&io_tss->bitmap - (char *)io_tss;
io_tss->tss.ss0 = KERNEL_DS;
@@ -560,7 +562,7 @@ i386_io_port_list(thread, list, list_count)
return KERN_RESOURCE_SHORTAGE;
}
- bcopy((void *)addr, (void *)new_addr, size_needed);
+ memcpy((void *)new_addr, (void *)addr, size_needed);
kfree(addr, size);
devices = (mach_device_t *)new_addr;
}
diff --git a/i386/i386/mp_desc.c b/i386/i386/mp_desc.c
index 3a549a8..f5b07ab 100644
--- a/i386/i386/mp_desc.c
+++ b/i386/i386/mp_desc.c
@@ -26,6 +26,8 @@
#if NCPUS > 1
+#include <string.h>
+
#include <kern/cpu_number.h>
#include <mach/machine.h>
#include <vm/vm_kern.h>
@@ -127,16 +129,16 @@ mp_desc_init(mycpu)
/*
* Copy the tables
*/
- bcopy((char *)idt,
- (char *)mpt->idt,
+ memcpy(mpt->idt,
+ idt,
sizeof(idt));
- bcopy((char *)gdt,
- (char *)mpt->gdt,
+ memcpy(mpt->gdt,
+ gdt,
sizeof(gdt));
- bcopy((char *)ldt,
- (char *)mpt->ldt,
+ memcpy(mpt->ldt,
+ ldt,
sizeof(ldt));
- bzero((char *)&mpt->ktss,
+ memset(&mpt->ktss, 0,
sizeof(struct i386_tss));
/*
diff --git a/i386/i386/pcb.c b/i386/i386/pcb.c
index 5187a8b..9665caa 100644
--- a/i386/i386/pcb.c
+++ b/i386/i386/pcb.c
@@ -24,6 +24,8 @@
* the rights to redistribute these changes.
*/
+#include <string.h>
+
#include <mach/std_types.h>
#include <mach/kern_return.h>
#include <mach/thread_status.h>
@@ -324,7 +326,7 @@ void pcb_init(thread)
/*
* We can't let random values leak out to the user.
*/
- bzero((char *) pcb, sizeof *pcb);
+ memset(pcb, 0, sizeof *pcb);
simple_lock_init(&pcb->lock);
/*
@@ -523,9 +525,9 @@ kern_return_t thread_setstatus(thread, flavor, tstate, count)
thread->pcb->ims.io_tss = tss;
}
- bcopy((char *) state->pm,
- (char *) tss->bitmap,
- sizeof state->pm);
+ memcpy(tss->bitmap,
+ state->pm,
+ sizeof state->pm);
#endif
break;
}
@@ -684,9 +686,9 @@ kern_return_t thread_getstatus(thread, flavor, tstate, count)
* The thread has its own ktss.
*/
- bcopy((char *) tss->bitmap,
- (char *) state->pm,
- sizeof state->pm);
+ memcpy(state->pm,
+ tss->bitmap,
+ sizeof state->pm);
}
*count = i386_ISA_PORT_MAP_STATE_COUNT;
diff --git a/i386/i386/phys.c b/i386/i386/phys.c
index 518812d..0b25c68 100644
--- a/i386/i386/phys.c
+++ b/i386/i386/phys.c
@@ -23,7 +23,9 @@
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
-
+
+#include <string.h>
+
#include <mach/boolean.h>
#include <kern/task.h>
#include <kern/thread.h>
@@ -43,7 +45,7 @@ pmap_zero_page(p)
vm_offset_t p;
{
assert(p != vm_page_fictitious_addr);
- bzero(phystokv(p), PAGE_SIZE);
+ memset((void *)phystokv(p), 0, PAGE_SIZE);
}
/*
@@ -55,7 +57,7 @@ pmap_copy_page(src, dst)
assert(src != vm_page_fictitious_addr);
assert(dst != vm_page_fictitious_addr);
- bcopy(phystokv(src), phystokv(dst), PAGE_SIZE);
+ memcpy((void *)phystokv(dst), (void *)phystokv(src), PAGE_SIZE);
}
/*
@@ -68,7 +70,7 @@ copy_to_phys(src_addr_v, dst_addr_p, count)
int count;
{
assert(dst_addr_p != vm_page_fictitious_addr);
- bcopy(src_addr_v, phystokv(dst_addr_p), count);
+ memcpy((void *)phystokv(dst_addr_p), (void *)src_addr_v, count);
}
/*
@@ -82,7 +84,7 @@ copy_from_phys(src_addr_p, dst_addr_v, count)
int count;
{
assert(src_addr_p != vm_page_fictitious_addr);
- bcopy(phystokv(src_addr_p), dst_addr_v, count);
+ memcpy((void *)dst_addr_v, (void *)phystokv(src_addr_p), count);
}
/*
diff --git a/i386/i386/trap.c b/i386/i386/trap.c
index 4c09ee0..d57ce17 100644
--- a/i386/i386/trap.c
+++ b/i386/i386/trap.c
@@ -28,6 +28,8 @@
*/
#include <sys/types.h>
+#include <string.h>
+
#include <mach/machine/eflags.h>
#include <i386/trap.h>
#include <machine/machspl.h> /* for spl_t */
@@ -940,9 +942,9 @@ v86_assist(thread, regs)
#ifdef gcc_1_36_worked
int_vec = ((struct int_vec *)0)[vec];
#else
- bcopy((char *) (sizeof(struct int_vec) * vec),
- (char *)&int_vec,
- sizeof (struct int_vec));
+ memcpy(&int_vec,
+ (void *)(sizeof(struct int_vec) * vec),
+ sizeof (struct int_vec));
#endif
if (copyout((char *)&iret_16,
(char *)Addr8086(regs->ss,sp),
diff --git a/i386/i386/user_ldt.c b/i386/i386/user_ldt.c
index d259ea3..33724ec 100644
--- a/i386/i386/user_ldt.c
+++ b/i386/i386/user_ldt.c
@@ -28,6 +28,8 @@
* Each thread in a task may have its own LDT.
*/
+#include <string.h>
+
#include <kern/kalloc.h>
#include <kern/thread.h>
@@ -221,9 +223,9 @@ i386_set_ldt(thread, first_selector, desc_list, count, desc_list_inline)
* from old to new. Otherwise copy the default ldt.
*/
if (old_ldt) {
- bcopy((char *)&old_ldt->ldt[0],
- (char *)&new_ldt->ldt[0],
- old_ldt->desc.limit_low + 1);
+ memcpy(&new_ldt->ldt[0],
+ &old_ldt->ldt[0],
+ old_ldt->desc.limit_low + 1);
}
else {
struct real_descriptor template = {0, 0, 0, ACC_P, 0, 0 ,0};
@@ -253,9 +255,9 @@ i386_set_ldt(thread, first_selector, desc_list, count, desc_list_inline)
/*
* Install new descriptors.
*/
- bcopy((char *)desc_list,
- (char *)&old_ldt->ldt[first_desc],
- count * sizeof(struct real_descriptor));
+ memcpy(&old_ldt->ldt[first_desc],
+ desc_list,
+ count * sizeof(struct real_descriptor));
simple_unlock(&pcb->lock);
@@ -355,9 +357,9 @@ i386_get_ldt(thread, first_selector, selector_count, desc_list, count)
/*
* copy out the descriptors
*/
- bcopy((char *)&user_ldt->ldt[first_desc],
- (char *)*desc_list,
- ldt_size);
+ memcpy(*desc_list,
+ &user_ldt->ldt[first_desc],
+ ldt_size);
*count = ldt_count;
simple_unlock(&pcb->lock);
@@ -378,7 +380,7 @@ i386_get_ldt(thread, first_selector, selector_count, desc_list, count)
*/
size_left = size_used - ldt_size;
if (size_left > 0)
- bzero((char *)addr + ldt_size, size_left);
+ memset((char *)addr + ldt_size, 0, size_left);
/*
* Make memory into copyin form - this unwires it.
diff --git a/i386/i386at/immc.c b/i386/i386at/immc.c
index a59209e..e457162 100644
--- a/i386/i386at/immc.c
+++ b/i386/i386at/immc.c
@@ -23,6 +23,8 @@
#ifdef ENABLE_IMMEDIATE_CONSOLE
+#include <string.h>
+
/* This is a special "feature" (read: kludge)
intended for use only for kernel debugging.
It enables an extremely simple console output mechanism
@@ -47,8 +49,8 @@ immc_cnputc(unsigned char c)
}
else if (c == '\n')
{
- bcopy(0xb8000+80*2, 0xb8000, 80*2*24);
- bzero(0xb8000+80*2*24, 80*2);
+ memcpy(0xb8000, 0xb8000+80*2, 80*2*24);
+ memset(0xb8000+80*2*24, 0, 80*2);
ofs = 0;
}
else
diff --git a/i386/i386at/kd_event.c b/i386/i386at/kd_event.c
index 961d1b2..dbd1cbd 100644
--- a/i386/i386at/kd_event.c
+++ b/i386/i386at/kd_event.c
@@ -56,6 +56,8 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <mach/boolean.h>
#include <sys/types.h>
+#include <string.h>
+
#ifdef MACH_KERNEL
#include <device/errno.h>
#include <device/io_req.h>
@@ -532,7 +534,7 @@ X_kdb_enter_init(data, count)
if (count * sizeof X_kdb_enter_str[0] > sizeof X_kdb_enter_str)
return D_INVALID_OPERATION;
- bcopy(data, X_kdb_enter_str, count * sizeof X_kdb_enter_str[0]);
+ memcpy(X_kdb_enter_str, data, count * sizeof X_kdb_enter_str[0]);
X_kdb_enter_len = count;
return D_SUCCESS;
}
@@ -545,7 +547,7 @@ X_kdb_exit_init(data, count)
if (count * sizeof X_kdb_exit_str[0] > sizeof X_kdb_exit_str)
return D_INVALID_OPERATION;
- bcopy(data, X_kdb_exit_str, count * sizeof X_kdb_exit_str[0]);
+ memcpy(X_kdb_exit_str, data, count * sizeof X_kdb_exit_str[0]);
X_kdb_exit_len = count;
return D_SUCCESS;
}
diff --git a/i386/intel/pmap.c b/i386/intel/pmap.c
index 688406c..6827519 100644
--- a/i386/intel/pmap.c
+++ b/i386/intel/pmap.c
@@ -55,6 +55,8 @@
* and to when physical maps must be made correct.
*/
+#include <string.h>
+
#include <mach/machine/vm_types.h>
#include <mach/boolean.h>
@@ -715,7 +717,7 @@ void pmap_init()
s = round_page(s);
if (kmem_alloc_wired(kernel_map, &addr, s) != KERN_SUCCESS)
panic("pmap_init");
- bzero((char *) addr, s);
+ memset((char *) addr, 0, s);
/*
* Allocate the structures first to preserve word-alignment.
@@ -829,7 +831,7 @@ pmap_page_table_page_alloc()
/*
* Zero the page.
*/
- bzero(phystokv(pa), PAGE_SIZE);
+ memset((void *)phystokv(pa), 0, PAGE_SIZE);
return pa;
}
@@ -894,7 +896,7 @@ pmap_t pmap_create(size)
!= KERN_SUCCESS)
panic("pmap_create");
- bcopy(kernel_page_dir, p->dirbase, INTEL_PGBYTES);
+ memcpy(p->dirbase, kernel_page_dir, INTEL_PGBYTES);
p->ref_count = 1;
simple_lock_init(&p->lock);