[svn:parrot] r47866 - in branches/cfunctionsdocs: . config/gen config/gen/platform/ansi config/gen/platform/darwin
jkeenan at svn.parrot.org
jkeenan at svn.parrot.org
Sat Jun 26 13:10:22 UTC 2010
Author: jkeenan
Date: Sat Jun 26 13:10:22 2010
New Revision: 47866
URL: https://trac.parrot.org/parrot/changeset/47866
Log:
Correct two codingstd errors. Delete darwin/memalign.c; not needed, as pointed out by doughera++.
Deleted:
branches/cfunctionsdocs/config/gen/platform/darwin/memalign.c
Modified:
branches/cfunctionsdocs/MANIFEST
branches/cfunctionsdocs/config/gen/platform.pm
branches/cfunctionsdocs/config/gen/platform/ansi/dl.c
branches/cfunctionsdocs/config/gen/platform/ansi/time.c
Modified: branches/cfunctionsdocs/MANIFEST
==============================================================================
--- branches/cfunctionsdocs/MANIFEST Sat Jun 26 12:52:00 2010 (r47865)
+++ branches/cfunctionsdocs/MANIFEST Sat Jun 26 13:10:22 2010 (r47866)
@@ -1,7 +1,7 @@
# ex: set ro:
# $Id$
#
-# generated by tools/dev/mk_manifest_and_skip.pl Wed Jun 9 14:23:50 2010 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Sat Jun 26 00:20:03 2010 UT
#
# See below for documentation on the format of this file.
#
@@ -278,7 +278,6 @@
config/gen/platform/cygwin/math.c []
config/gen/platform/darwin/begin.c []
config/gen/platform/darwin/hires_timer.c []
-config/gen/platform/darwin/memalign.c []
config/gen/platform/generic/dl.c []
config/gen/platform/generic/dl.h []
config/gen/platform/generic/env.c []
Modified: branches/cfunctionsdocs/config/gen/platform.pm
==============================================================================
--- branches/cfunctionsdocs/config/gen/platform.pm Sat Jun 26 12:52:00 2010 (r47865)
+++ branches/cfunctionsdocs/config/gen/platform.pm Sat Jun 26 13:10:22 2010 (r47866)
@@ -191,7 +191,6 @@
dl.c
stat.c
math.c
- memalign.c
signal.c
itimer.c
memexec.c
Modified: branches/cfunctionsdocs/config/gen/platform/ansi/dl.c
==============================================================================
--- branches/cfunctionsdocs/config/gen/platform/ansi/dl.c Sat Jun 26 12:52:00 2010 (r47865)
+++ branches/cfunctionsdocs/config/gen/platform/ansi/dl.c Sat Jun 26 13:10:22 2010 (r47866)
@@ -11,7 +11,8 @@
=head1 DESCRIPTION
-Parrot functions -- B<none yet implemented> -- which wrap around standard library functions for handling dynamic libraries.
+Parrot functions -- B<none yet implemented> -- which wrap around standard
+library functions for handling dynamic libraries.
=head2 Functions
Modified: branches/cfunctionsdocs/config/gen/platform/ansi/time.c
==============================================================================
--- branches/cfunctionsdocs/config/gen/platform/ansi/time.c Sat Jun 26 12:52:00 2010 (r47865)
+++ branches/cfunctionsdocs/config/gen/platform/ansi/time.c Sat Jun 26 13:10:22 2010 (r47866)
@@ -44,7 +44,7 @@
=item C<FLOATVAL Parrot_floatval_time(void)>
-Note: We are unable to provide this level of precision under ANSI-C, so we
+Note: We are unable to provide this level of precision under ANSI-C, so we
just fall back to intval time for this.
=cut
Deleted: branches/cfunctionsdocs/config/gen/platform/darwin/memalign.c
==============================================================================
--- branches/cfunctionsdocs/config/gen/platform/darwin/memalign.c Sat Jun 26 13:10:22 2010 (r47865)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,201 +0,0 @@
-/*
- * $Id$
- * Copyright (C) 2007-2008, Parrot Foundation.
- */
-
-/*
-
-=head1 NAME
-
-memalign.c
-
-=head1 DESCRIPTION
-
-memalign related stuff
-
-=head2 Functions
-
-=over 4
-
-=cut
-
-*/
-
-#include <mach/vm_map.h>
-#include <mach/mach_init.h>
-
-/*
-
-=item C<static unsigned long log2int(unsigned long x)>
-
-=cut
-
-*/
-
-static unsigned long log2int(unsigned long x) {
- return (x < 2) ? 0 : log2int(x >> 1) + 1;
-}
-
-/*
-
-=item C<static unsigned long roundDownPowerOf2(unsigned long x)>
-
-=cut
-
-*/
-
-static unsigned long roundDownPowerOf2(unsigned long x) {
- return (1 << log2int(x));
-}
-
-/*
-
-=item C<static unsigned long roundUpPowerOf2(unsigned long x)>
-
-=cut
-
-*/
-
-static unsigned long roundUpPowerOf2(unsigned long x)
-{
- static unsigned long one = 1;
- unsigned long log2Int = log2int(x);
-
- return ((one << log2Int) == x) ? x : (one << (log2Int + 1));
-}
-
-/*
-
-=item C<static unsigned long roundUpToPageBoundary(unsigned long x)>
-
-=cut
-
-*/
-
-static unsigned long roundUpToPageBoundary(unsigned long x)
-{
- unsigned long roundedDown = trunc_page(x);
-
- return (roundedDown == x) ? x : (roundedDown + vm_page_size);
-}
-
-typedef struct _memalign_marker_t {
- vm_address_t start;
- vm_size_t size;
-} memalign_marker_t;
-
-/*
-
-=item C<void * Parrot_memalign(size_t align, size_t size)>
-
-=cut
-
-*/
-
-void *
-Parrot_memalign(size_t align, size_t size)
-{
- size_t effectiveAlign = align;
- size_t padding = 0;
- size_t amountToAllocate = 0;
-
- if (effectiveAlign < sizeof (void *))
- effectiveAlign = roundUpPowerOf2(sizeof (void *));
- else
- effectiveAlign = roundUpPowerOf2(effectiveAlign);
-
- if (effectiveAlign < sizeof (memalign_marker_t))
- padding = sizeof (memalign_marker_t);
- else
- padding = effectiveAlign;
-
- amountToAllocate = roundUpToPageBoundary(size + padding);
-
- {
- vm_address_t p = (vm_address_t)NULL;
- kern_return_t status = vm_allocate(mach_task_self(), &p,
- amountToAllocate, 1);
-
- if (status != KERN_SUCCESS)
- return NULL;
- else {
- vm_size_t logEffectiveAlign = log2int(effectiveAlign);
- vm_address_t lowestAvaliableAddress =
- p + sizeof (memalign_marker_t);
- vm_address_t roundedDownAddress =
- ((lowestAvaliableAddress >> logEffectiveAlign)
- << logEffectiveAlign);
- vm_address_t returnAddress =
- (roundedDownAddress == lowestAvaliableAddress)
- ? lowestAvaliableAddress
- : (roundedDownAddress + effectiveAlign);
- vm_address_t firstUnneededPage = 0;
-
- memalign_marker_t *marker =
- (memalign_marker_t *)returnAddress - 1;
-
- /* lowest address used, then round down to vm_page boundary */
- vm_address_t usedPageBase = trunc_page((vm_address_t)marker);
- marker->start = usedPageBase;
- marker->size = returnAddress + size - usedPageBase;
-
- if (usedPageBase > p) {
- status = vm_deallocate(mach_task_self(), p, usedPageBase - p);
-
- if (status != KERN_SUCCESS)
- fprintf(stderr, "Parrot_memalign(%zx, %zx) failed "
- "to deallocate extra header space.\n",
- align, size);
- }
-
- firstUnneededPage = roundUpToPageBoundary(returnAddress + size);
-
- if (firstUnneededPage < p + amountToAllocate) {
- status = vm_deallocate(mach_task_self(), firstUnneededPage,
- p + amountToAllocate - firstUnneededPage);
-
- if (status != KERN_SUCCESS) {
- fprintf(stderr, "Parrot_memalign(%zx, %zx) failed "
- "to deallocate extra footer space.\n",
- align, size);
- }
- }
-
- return (void *)returnAddress;
- }
- }
-}
-
-/*
-
-=item C<void Parrot_free_memalign(void *p)>
-
-=cut
-
-*/
-
-void
-Parrot_free_memalign(void *p)
-{
- memalign_marker_t *marker = (memalign_marker_t *)p - 1;
- kern_return_t status = vm_deallocate(mach_task_self(),
- marker->start, marker->size);
-
- if (status != KERN_SUCCESS)
- fprintf(stderr, "Parrot_free_memalign(%p) failed!\n", p);
-}
-
-/*
-
-=back
-
-=cut
-
-*/
-
-/*
- * Local variables:
- * c-file-style: "parrot"
- * End:
- * vim: expandtab shiftwidth=4:
- */
More information about the parrot-commits
mailing list