Commits

Anonymous committed 45ec6cf

Fixes Issue 217
Made posix64 the default platform for the v10 branch

  • Participants
  • Parent commits 319012a
  • Branches v10

Comments (0)

Files changed (12)

 -----
 
 P14p is built, for most platforms, using a POSIX-like terminal, a Makefile
-(or using SCons) and a GCC [cross] compiler.  The desktop platform is the 
+(or using SCons) and a GCC [cross] compiler.  The posix64 platform is the 
 default target platform and it builds for Mac OS X, Linux or Cygwin.
-See src/platform/desktop/README for one extra step if you have 64-bit hardware.
 
 GNU Make should be installed since other forms of Make aren't 100% compatible.
 The development system should have installed the
 The SCons build system is experimental.
 Please read ``docs/src/BuildSystem.txt`` for more details.
 
-To build p14p for the desktop platform and run the interactive prompt::
+To build p14p for the posix64 platform and run the interactive prompt::
 
-    $ make ipm
+    $ scons
     ...
+    $ src/tools/ipm.py --desktop
     ipm> print "Hello world."
     Hello world.
     ipm> ^D
 Press Control+D when done with the interactive prompt.
 To run the system tests on the desktop::
 
-    $ make check
+    $ scons check
 
-To cross-compile for a different platform, type ``make PLATFORM=<plat>``
+To cross-compile for a different platform, type ``scons PLATFORM=<plat>``
 where ``<plat>`` is the name of a subdirectory in ``src/platform/``.
 For example::
 
-    $ make PLATFORM=avr
+    $ scons PLATFORM=avr
 
 The author uses avr-gcc to compile for Atmel AVR microcontrollers.
 Other platforms use other compilers.  The windows platform uses a MicroSoft IDE.
 
 Platforms in **bold** are new since the previous release:
 
-    - **arduino_mega**: The Atmel ATmega1280 based `Arduino Mega board`_
-    - at91sam7s-ek: The Atmel `evaluation kit for the ARM7 AT91SAM7S64`_ **[Not Recommended]**
-    - avr: Generic `Atmel AVR`_
-    - desktop: Mac OS X, Linux, Cygwin or any other Posix-like desktop OS
-    - **econotag**: The Freescale MC13224 based `Redbee EconoTAG`_ 802.15.4 wireless module
-    - mbed: The NXP LPC1368 based mbed_ microcontroller platform
-    - mmb103: The Atmel ATmega103 based Mega Mini Board **[Not Recommended]**
-    - **mosync**: The MoSync_ cross-platform framework for mobile platforms.
-    - **pic24**: The `Microchip PIC24/dsPIC family`_
-    - **stm32**: The ST Microelectronics STM32F103 `ET-STM32 Stamp Module`_
-    - **teensy**: The Atmel ATmega 1280 based `Teensy++ 2.0`_
-    - **windows**: The MicroSoft Windows desktop OS
-
-.. _`Arduino Mega board`: http://arduino.cc/en/Main/ArduinoBoardMega
-.. _`evaluation kit for the ARM7 AT91SAM7S64`:  http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3784
-.. _`Atmel AVR`: http://www.atmel.com/products/AVR/megaavr.asp?family_id=607&source=avrhomereadmore
-.. _`Redbee EconoTAG`: http://redwirellc.com/store/index.php?route=product/product&product_id=56
-.. _mbed: http://mbed.org/
-.. _MoSync: http://www.mosync.com/
-.. _`Microchip PIC24/dsPIC family`: http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2629&param=en533465
-.. _`ET-STM32 Stamp Module`: http://www.futurlec.com/ET-STM32_Stamp.shtml
-.. _`Teensy++ 2.0`: http://www.pjrc.com/teensy/
+    - posix: Mac OS X, Linux, Cygwin or any other Posix-like desktop OS
+    - **posix64**: Mac OS X, Linux, Cygwin or any other 64-bit Posix-like desktop OS
 
 
 Release Notes
     - JT: Created issues and patches for ipm, mbed and __bi.py.
 
 
-This is release 09
+Older releases:
 
 * Release 09, 2010/09/21
 
 
 import os, string
 
-DEFAULT_PLATFORM = "posix"
+DEFAULT_PLATFORM = "posix64"
 
 valid_platforms = [os.path.split(x)[1] for x in map(str, Glob("src/platform/*"))
                    if x not in ("_unmaintained", "COPYING")]
     Clean("check", build_path)
 
 
-# Default: build a platform; posix is the default platform
+# Build the default platform
 else:
     if len(vars.args) == 0:
         vars.args["PLATFORM"] = DEFAULT_PLATFORM

File src/platform/posix64/README

+====================
+The Posix64 Platform
+====================
+Formerly known as "desktop" or "desktop64"
+==========================================
+
+
+:Author:    Dean Hall
+
+
+Purpose
+-------
+
+This is a sample project that demonstrates running Python-on-a-Chip on a
+64-bit POSIX-compliant terminal.  Any POSIX-compliant OS should work
+(Mac OS X, Linux, Cygwin).
+
+
+Building the Project
+--------------------
+
+Start with a clean source tree.
+
+The posix64 platform is the default platform of the SCons build system,
+so typing ``scons`` in the root directory will build a binary to run on the
+posix64 platform::
+
+    $ scons
+
+The resulting binary is found in ``src/platform/posix64/build/main``.
+Presently, the main.py program runs the interactive prompt (ipm).
+To launch the vm on your posix64 target and connect to it, type this::
+
+    $ src/tools/ipm.py --desktop
+

File src/platform/posix64/SConscript

+# BEGIN PLATFORM BUILD CONFIGURATION
+platform_c_sources = ["main.c", "plat.c"]
+platform_py_sources = ["main.py"]
+pmlib_py_sources = [
+    "#src/lib/__bi.py",
+    "#src/lib/sys.py",
+    "#src/lib/ipm.py",
+    "#src/lib/string.py",
+    "#src/lib/list.py",
+    "#src/lib/dict.py",
+    "#src/lib/pmMarshal.py",
+    ]
+HAVE_FLOAT = "little endien"
+HAVE_DEBUG_INFO = True
+# END PLATFORM BUILD CONFIGURATION
+
+
+# Initialize Scons' construction environment
+import sys
+cflags = "-Wall -Wstrict-prototypes -Werror "
+cflags_dbg = "-ggdb -D__DEBUG__=1 "
+cflags_opt = "-Os "
+Import("vars")
+env_dbg = Environment(variables = vars,
+    CPPPATH = ["#src/vm", "#src/platform/posix64/build"],
+    CCFLAGS = cflags + cflags_dbg,
+    LINKFLAGS = "-Wl,-map $mapfile")
+env = env_dbg
+if not sys.platform.startswith("win"):
+    env['ARFLAGS'] = "rcs"
+
+# Generate pmfeatures.h
+pmfeatures_py = File("#src/platform/posix64/pmfeatures.py")
+pmfeatures_h = env.Command("pmfeatures.h", pmfeatures_py,
+    "src/tools/pmGenPmFeatures.py $SOURCE > $TARGET")
+
+# Generate code objs and types
+generated_objs = [File("#src/platform/posix64/build/pm_generated_objs.c"),
+                  File("#src/platform/posix64/build/pm_generated_types.h")]
+pm_generated_codeobjs = env.Command(generated_objs,
+    platform_py_sources + pmlib_py_sources,
+    "src/tools/pmCoCreator.py src/platform/posix64/build $SOURCES")
+Depends(pm_generated_codeobjs, pmfeatures_py)
+
+# Build pmvm library, a linker map and the executable
+mapfile = env.Command("#src/platform/posix64/build/main.map", "", Touch("$TARGET"))
+pmvm_lib = env.SConscript("#src/vm/SConscript", "env", variant_dir = "vm")
+main = env.Program("main", [mapfile, platform_c_sources + pmvm_lib,
+                           "#src/platform/posix64/build/pm_generated_objs.c"])
+Return("main")
+
+#:mode=python:

File src/platform/posix64/main.c

+/*
+# This file is Copyright 2007, 2009 Dean Hall.
+#
+# This file is part of the Python-on-a-Chip program.
+# Python-on-a-Chip is free software: you can redistribute it and/or modify
+# it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1.
+#
+# Python-on-a-Chip is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1
+# is seen in the file COPYING up one directory from this.
+*/
+
+
+#include "pm.h"
+
+#define HEAP_SIZE 0x4000
+
+
+int main(void)
+{
+    uint8_t heap[HEAP_SIZE];
+    PmReturn_t retval;
+
+    retval = plat_init();
+    PM_RETURN_IF_ERROR(retval);
+
+    retval = pm_init(heap, HEAP_SIZE);
+    PM_RETURN_IF_ERROR(retval);
+
+    retval = pm_run((uint8_t *)"main");
+
+    plat_deinit();
+
+    return (int)retval;
+}

File src/platform/posix64/main.py

+# This file is Copyright 2007, 2009 Dean Hall.
+#
+# This file is part of the Python-on-a-Chip program.
+# Python-on-a-Chip is free software: you can redistribute it and/or modify
+# it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1.
+# 
+# Python-on-a-Chip is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1
+# is seen in the file COPYING up one directory from this.
+
+#
+# Runs the interactive interpreter
+#
+
+import ipm
+ipm.ipm()

File src/platform/posix64/plat.c

+/*
+# This file is Copyright 2006, 2007, 2009 Dean Hall.
+#
+# This file is part of the Python-on-a-Chip program.
+# Python-on-a-Chip is free software: you can redistribute it and/or modify
+# it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1.
+#
+# Python-on-a-Chip is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1
+# is seen in the file COPYING up one directory from this.
+*/
+
+
+#undef __FILE_ID__
+#define __FILE_ID__ 0x70
+
+
+/** PyMite platform-specific routines for Desktop target */
+
+
+#include <stdio.h>
+#include <unistd.h>
+#include <signal.h>
+#include <string.h>
+
+#include "pm.h"
+
+
+void
+_sigalrm_handler(int signal)
+{
+    PmReturn_t retval;
+    retval = pm_vmPeriodic(1000);
+    PM_REPORT_IF_ERROR(retval);
+}
+
+
+/* Desktop target shall use stdio for I/O routines. */
+PmReturn_t
+plat_init(void)
+{
+    /* Let POSIX' SIGALRM fire every full millisecond. */
+    /*
+     * #67 Using sigaction complicates the use of getchar (below),
+     * so signal() is used instead.
+     */
+/*#ifndef __DEBUG__*/
+/* This block was ifndef'd because of a verbal warning that signals cause trouble when debugging */
+    signal(SIGALRM, _sigalrm_handler);
+    ualarm(1000, 1000);
+/*#endif*/
+
+    return PM_RET_OK;
+}
+
+
+/* Disables the peripherals and interrupts */
+PmReturn_t
+plat_deinit(void)
+{
+    /* Cancel alarm and set the alarm handler to the default */
+    ualarm(0, 0);
+    signal(SIGALRM, SIG_DFL);
+
+    return PM_RET_OK;
+}
+
+
+/* Desktop target shall use stdio for I/O routines */
+PmReturn_t
+plat_getByte(uint8_t *b)
+{
+    int c;
+    PmReturn_t retval = PM_RET_OK;
+
+    c = getchar();
+    *b = c & 0xFF;
+
+    if (c == EOF)
+    {
+        PM_RAISE(retval, PM_RET_EX_IO);
+    }
+
+    return retval;
+}
+
+
+/* Desktop target shall use stdio for I/O routines */
+PmReturn_t
+plat_putByte(uint8_t b)
+{
+    int i;
+    PmReturn_t retval = PM_RET_OK;
+
+    i = putchar(b);
+    fflush(stdout);
+
+    if ((i != b) || (i == EOF))
+    {
+        PM_RAISE(retval, PM_RET_EX_IO);
+    }
+
+    return retval;
+}
+
+
+PmReturn_t
+plat_getMsTicks(uint32_t *r_ticks)
+{
+    *r_ticks = pm_timerMsTicks;
+
+    return PM_RET_OK;
+}
+
+
+void
+plat_reportError(PmReturn_t result)
+{
+
+#ifdef HAVE_DEBUG_INFO
+#define LEN_FNLOOKUP 26
+#define LEN_EXNLOOKUP 18
+
+    uint8_t res;
+    pPmFrame_t pframe;
+    pPmObj_t pstr;
+    pPmObj_t pfnstr;
+    PmReturn_t retval;
+    uint16_t bcaddr;
+    uint16_t lineno;
+    uint16_t len_lnotab;
+    uint16_t lnotab_index;
+    uint8_t b1, b2;
+    uint16_t i;
+
+    /* This table should match src/vm/fileid.txt */
+    char const * const fnlookup[LEN_FNLOOKUP] = {
+        "<no file>",
+        "codeobj.c",
+        "dict.c",
+        "frame.c",
+        "func.c",
+        "global.c",
+        "heap.c",
+        "img.c",
+        "int.c",
+        "interp.c",
+        "pm_generated_objs.c",
+        "list.c",
+        "main.c",
+        "mem.c",
+        "module.c",
+        "obj.c",
+        "seglist.c",
+        "sli.c",
+        "strobj.c",
+        "tuple.c",
+        "seq.c",
+        "pm.c",
+        "thread.c",
+        "float.c",
+        "class.c",
+        "bytearray.c",
+    };
+
+    /* This table should match src/vm/pm.h PmReturn_t */
+    char const * const exnlookup[LEN_EXNLOOKUP] = {
+        "Exception",
+        "SystemExit",
+        "IoError",
+        "ZeroDivisionError",
+        "AssertionError",
+        "AttributeError",
+        "ImportError",
+        "IndexError",
+        "KeyError",
+        "MemoryError",
+        "NameError",
+        "SyntaxError",
+        "SystemError",
+        "TypeError",
+        "ValueError",
+        "StopIteration",
+        "Warning",
+        "OverflowError",
+    };
+
+    /* Print traceback */
+    printf("Traceback (most recent call first):\n");
+
+    /* Get the top frame */
+    pframe = gVmGlobal.pthread->pframe;
+
+    /* If it's the native frame, print the native function name */
+    if (pframe == (pPmFrame_t)&(gVmGlobal.nativeframe))
+    {
+        /* Get the native func's name */
+        retval = co_getName((pPmObj_t)gVmGlobal.nativeframe.nf_func->f_co, &pstr);
+        if ((retval) != PM_RET_OK)
+        {
+            printf("  Unable to get native func name.\n");
+            return;
+        }
+        else
+        {
+            printf("  %s() __NATIVE__\n", ((pPmString_t)pstr)->val);
+        }
+
+        /* Get the frame that called the native frame */
+        pframe = (pPmFrame_t)gVmGlobal.nativeframe.nf_back;
+    }
+
+    /* Print the remaining frame stack */
+    for (; pframe != C_NULL; pframe = pframe->fo_back)
+    {
+        /* The last name in the names tuple of the code obj is the name */
+        retval = co_getName((pPmObj_t)pframe->fo_func->f_co, &pstr);
+        if ((retval) != PM_RET_OK) break;
+
+        /*
+         * Get the line number of the current bytecode. Algorithm comes from:
+         * http://svn.python.org/view/python/trunk/Objects/lnotab_notes.txt?view=markup
+         */
+        lnotab_index = 0;
+        bcaddr = 0;
+        co_getLnotabLen((pPmObj_t)pframe->fo_func->f_co, &len_lnotab);
+        co_getFirstlineno((pPmObj_t)pframe->fo_func->f_co, &lineno);
+        for (i = 0; i < len_lnotab; i += 2)
+        {
+            co_getLnotabAtOffset((pPmObj_t)pframe->fo_func->f_co,
+                                 lnotab_index++, &b1);
+            bcaddr += b1;
+            if (bcaddr > pframe->fo_ip) break;
+
+            co_getLnotabAtOffset((pPmObj_t)pframe->fo_func->f_co,
+                                 lnotab_index++, &b2);
+            lineno += b2;
+        }
+
+        co_getFileName((pPmObj_t)((pPmFrame_t)pframe)->fo_func->f_co, &pfnstr);
+        printf("  File \"%s\", line %d, in %s\n",
+               ((pPmString_t)pfnstr)->val,
+               lineno,
+               ((pPmString_t)pstr)->val);
+    }
+
+    /* Print error */
+    if ((gVmGlobal.errFileId > 0) && (gVmGlobal.errFileId < LEN_FNLOOKUP))
+    {
+        printf("%s:", fnlookup[gVmGlobal.errFileId]);
+    }
+    else
+    {
+        printf("FileId 0x%02X line ", gVmGlobal.errFileId);
+    }
+    printf("%d detects a ", gVmGlobal.errLineNum);
+
+    res = (uint8_t)result;
+    if ((res > 0) && ((res - PM_RET_EX) < LEN_EXNLOOKUP))
+    {
+        printf("%s\n", exnlookup[res - PM_RET_EX]);
+    }
+    else
+    {
+        printf("Error code 0x%02X\n", result);
+    }
+
+
+#else /* HAVE_DEBUG_INFO */
+
+    /* Print error */
+    printf("Error:     0x%02X\n", result);
+    printf("  Release: 0x%02X\n", gVmGlobal.errVmRelease);
+    printf("  FileId:  0x%02X\n", gVmGlobal.errFileId);
+    printf("  LineNum: %d\n", gVmGlobal.errLineNum);
+
+    /* Print traceback */
+    {
+        pPmObj_t pframe;
+        pPmObj_t pstr;
+        PmReturn_t retval;
+
+        printf("Traceback (top first):\n");
+
+        /* Get the top frame */
+        pframe = (pPmObj_t)gVmGlobal.pthread->pframe;
+
+        /* If it's the native frame, print the native function name */
+        if (pframe == (pPmObj_t)&(gVmGlobal.nativeframe))
+        {
+
+            /* The last name in the names tuple of the code obj is the name */
+            retval = tuple_getItem((pPmObj_t)gVmGlobal.nativeframe.nf_func->
+                                   f_co->co_names, -1, &pstr);
+            if ((retval) != PM_RET_OK)
+            {
+                printf("  Unable to get native func name.\n");
+                return;
+            }
+            else
+            {
+                printf("  %s() __NATIVE__\n", ((pPmString_t)pstr)->val);
+            }
+
+            /* Get the frame that called the native frame */
+            pframe = (pPmObj_t)gVmGlobal.nativeframe.nf_back;
+        }
+
+        /* Print the remaining frame stack */
+        for (;
+             pframe != C_NULL;
+             pframe = (pPmObj_t)((pPmFrame_t)pframe)->fo_back)
+        {
+            /* Get the func's name */
+            retval = co_getName((pPmObj_t)((pPmFrame_t)pframe)->fo_func->f_co, &pstr);
+            PM_BREAK_IF_ERROR(retval);
+
+            printf("  %s()\n", ((pPmString_t)pstr)->val);
+        }
+        printf("  <module>.\n");
+    }
+#endif /* HAVE_DEBUG_INFO */
+}
+

File src/platform/posix64/plat.h

+/*
+# This file is Copyright 2010 Dean Hall.
+#
+# This file is part of the Python-on-a-Chip program.
+# Python-on-a-Chip is free software: you can redistribute it and/or modify
+# it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1.
+#
+# Python-on-a-Chip is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1
+# is seen in the file COPYING up one directory from this.
+*/
+
+#ifndef _PLAT_H_
+#define _PLAT_H_
+
+#define PM_FLOAT_LITTLE_ENDIAN
+#define PM_PLAT_POINTER_SIZE 8
+#define PM_PLAT_HEAP_ATTR __attribute__((aligned (4)))
+#define PM_PLAT_PROGMEM const
+
+#endif /* _PLAT_H_ */

File src/platform/posix64/pmfeatures.py

+# This file is Copyright 2010 Dean Hall.
+#
+# This file is part of the Python-on-a-Chip program.
+# Python-on-a-Chip is free software: you can redistribute it and/or modify
+# it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1.
+#
+# Python-on-a-Chip is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1
+# is seen in the file COPYING up one directory from this.
+
+PM_FEATURES = {
+    "HAVE_FLOAT": True,
+    "HAVE_DEBUG_INFO": True,
+}

File src/tools/ipm.py

 PLATFORM_DIR = os.path.join(TOOLS_DIR, '..', 'platform')
 
 NEED_PYSERIAL = "Install the pySerial module from http://pyserial.sourceforge.net/"
-if not sys.platform.lower().startswith("win"):
-    PMVM_EXE = os.path.join(PLATFORM_DIR, "posix/build/main")
+if sys.platform.lower().startswith("win"):
+    PMVM_EXE = os.path.join(PLATFORM_DIR, "windows/main.exe")
 else:
-    PMVM_EXE = os.path.join(PLATFORM_DIR, "windows/main.exe")
+    PMVM_EXE = os.path.join(PLATFORM_DIR, "posix64/build/main")
+    if not os.path.exists(PMVM_EXE):
+        PMVM_EXE = os.path.join(PLATFORM_DIR, "posix/build/main")
 IPM_PROMPT = "ipm> "
 IPM_PROMPT2 = ".... "
 COMPILE_FN = "<ipm>"
         print NEED_PYSERIAL
         raise e
 
-    pic = pmImgCreator.PmImgCreator(os.path.join(PLATFORM_DIR, "desktop/pmfeatures.py"))
+    pic = pmImgCreator.PmImgCreator(os.path.join(PLATFORM_DIR, "posix64/pmfeatures.py"))
     serconn = serial.Serial("/dev/cu.SLAB_USBtoUART", 19200)
     serconn.setTimeout(2)
 

File src/vm/fileid.txt

 0x1A  marshal.c
 ----- ---------------------------------------
 0x70  RESERVED FOR PLATFORM-SPECIFIC FILES
+0x70  plat.c
 0x7F
 ----- ---------------------------------------
 0x90  utest.c

File src/vm/heap.c

  * The live chunk size is determined by the size field in the *object*
  * descriptor.  That field is nine bits with two assumed lsbs (zeros):
  * (0x1FF << 2) == 2044
+ * For 64-bit platforms, the value is 4 bytes less
  */
+#if defined(PM_PLAT_POINTER_SIZE) && (PM_PLAT_POINTER_SIZE == 8)
+#define HEAP_MAX_LIVE_CHUNK_SIZE 2040
+#else
 #define HEAP_MAX_LIVE_CHUNK_SIZE 2044
+#endif
 
 /**
  * The maximum size a free chunk can be (a free chunk is one that is not in use).
  * The free chunk size is limited by the size field in the *heap* descriptor.
  * That field is fourteen bits with two assumed least significant bits (zeros):
  * (0x3FFF << 2) == 65532
+ * For 64-bit platforms, the value is 4 bytes less
  */
+#if defined(PM_PLAT_POINTER_SIZE) && (PM_PLAT_POINTER_SIZE == 8)
+#define HEAP_MAX_FREE_CHUNK_SIZE 65528
+#else
 #define HEAP_MAX_FREE_CHUNK_SIZE 65532
+#endif
 
-/** The minimum size a chunk can be (rounded up to a multiple of 4) */
+/**
+ * The minimum size a chunk can be
+ * (rounded up to a multiple of platform-pointer-size)
+ */
+#if defined(PM_PLAT_POINTER_SIZE) && (PM_PLAT_POINTER_SIZE == 8)
+#define HEAP_MIN_CHUNK_SIZE ((sizeof(PmHeapDesc_t) + 7) & ~7)
+#else
 #define HEAP_MIN_CHUNK_SIZE ((sizeof(PmHeapDesc_t) + 3) & ~3)
-
+#endif
 
 /**
  * Gets the GC's mark bit for the object.
         requestedsize = HEAP_MIN_CHUNK_SIZE;
     }
 
-    /*
-     * Round up the size to a multiple of 4 bytes.
-     * This maintains alignment on 32-bit platforms (required).
-     */
+    /* Round up the size to a multiple of platform pointer size. */
+#if defined(PM_PLAT_POINTER_SIZE) && (PM_PLAT_POINTER_SIZE == 8)
+    adjustedsize = ((requestedsize + 7) & ~7);
+#else
     adjustedsize = ((requestedsize + 3) & ~3);
+#endif
 
     /* Attempt to get a chunk */
     retval = heap_getChunkImpl(adjustedsize, r_pchunk);
     /* Ensure that the pointer is 4-byte aligned */
     if (retval == PM_RET_OK)
     {
+#if defined(PM_PLAT_POINTER_SIZE) && (PM_PLAT_POINTER_SIZE == 8)
+        C_ASSERT(((intptr_t)*r_pchunk & 7) == 0);
+#else
         C_ASSERT(((intptr_t)*r_pchunk & 3) == 0);
+#endif
     }
 
     return retval;