Check-in [d8083eba5c]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Use PalmOS glue when allocating to allocate more than 64K.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d8083eba5c2b5def0b9283926be646fe469fa5c1
User & Date: stephanie.gawroriski 2019-07-14 12:19:12
Context
2019-07-14
12:54
Add base JVM initialization with error code print. check-in: a531e486b4 user: stephanie.gawroriski tags: trunk
12:19
Use PalmOS glue when allocating to allocate more than 64K. check-in: d8083eba5c user: stephanie.gawroriski tags: trunk
07:02
Backup developer notes. check-in: 32d646c7e1 user: squirreljme tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ratufacoat/makefile.palm.

14
15
16
17
18
19
20
21
22
23
24
			m68k-palmos-obj-res squirreljme-palm.a
			pilrc palm.rcp
			build-prc -o $@ -t appl -c SjME -n "SquirrelJME" \
				--ok-to-install-newer --backup --bundle \
				*.grc *.bin

squirreljme-palm.a:	$(FILES)
			m68k-palmos-gcc -o $@ $^ $(CFLAGS) $(LIBS)

clean:				
			rm -f squirreljme-palm.a *.grc *.bin squirreljme.prc







|



14
15
16
17
18
19
20
21
22
23
24
			m68k-palmos-obj-res squirreljme-palm.a
			pilrc palm.rcp
			build-prc -o $@ -t appl -c SjME -n "SquirrelJME" \
				--ok-to-install-newer --backup --bundle \
				*.grc *.bin

squirreljme-palm.a:	$(FILES)
			m68k-palmos-gcc -o $@ $^ $(CFLAGS) $(LIBS) -lPalmOSGlue

clean:				
			rm -f squirreljme-palm.a *.grc *.bin squirreljme.prc

Changes to ratufacoat/sjmercnm.c.

7
8
9
10
11
12
13






14
15
16
17
18
19
20
..
26
27
28
29
30
31
32




33
34

35
36
37
38





39
40
41
42
43
44
45
..
52
53
54
55
56
57
58




59
60

61
// --------------------------------------------------------------------------*/

/**
 * Native memory functions.
 *
 * @since 2019/06/25
 */







#include "sjmerc.h"

/** Allocates the given number of bytes. */
void* sjme_malloc(sjme_jint size)
{
	void* rv;
................................................................................
	/* Round size and include extra 4-bytes for size storage. */
	size = ((size + SJME_JINT_C(3)) & (~SJME_JINT_C(3))) + SJME_JINT_C(4);
	
	/* Exceeds maximum permitted allocation size? */
	if (sizeof(sjme_jint) > sizeof(size_t) && size > (sjme_jint)SIZE_MAX)
		return NULL;
	




	/* Use standard C function otherwise. */
	rv = calloc(1, size);


	/* Did not allocate? */
	if (rv == NULL)
		return NULL;





	
	/* Store the size into this memory block for later free. */
	*((sjme_jint*)rv) = size;
	
	/* Return the adjusted pointer. */
	return SJME_POINTER_OFFSET_LONG(rv, 4);
}
................................................................................
	/* Ignore null pointers. */
	if (p == NULL)
		return;
	
	/* Base pointer which is size shifted. */
	basep = SJME_POINTER_OFFSET_LONG(p, -4);
	




	/* Use Standard C free. */
	free(basep);

}







>
>
>
>
>
>







 







>
>
>
>


>




>
>
>
>
>







 







>
>
>
>


>

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
..
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
..
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// --------------------------------------------------------------------------*/

/**
 * Native memory functions.
 *
 * @since 2019/06/25
 */

/* Palm OS Functions. */
#if defined(__palmos__)
	#include <MemoryMgr.h>
	#include <MemGlue.h>
#endif

#include "sjmerc.h"

/** Allocates the given number of bytes. */
void* sjme_malloc(sjme_jint size)
{
	void* rv;
................................................................................
	/* Round size and include extra 4-bytes for size storage. */
	size = ((size + SJME_JINT_C(3)) & (~SJME_JINT_C(3))) + SJME_JINT_C(4);
	
	/* Exceeds maximum permitted allocation size? */
	if (sizeof(sjme_jint) > sizeof(size_t) && size > (sjme_jint)SIZE_MAX)
		return NULL;
	
#if defined(__palmos__)
	/* Palm OS, use glue to allow greater than 64K. */
	rv = MemGluePtrNew(size);
#else
	/* Use standard C function otherwise. */
	rv = calloc(1, size);
#endif

	/* Did not allocate? */
	if (rv == NULL)
		return NULL;
		
#if defined(__palmos__)
	/* Clear memory on Palm OS. */
	MemSet(rv, size, 0);
#endif
	
	/* Store the size into this memory block for later free. */
	*((sjme_jint*)rv) = size;
	
	/* Return the adjusted pointer. */
	return SJME_POINTER_OFFSET_LONG(rv, 4);
}
................................................................................
	/* Ignore null pointers. */
	if (p == NULL)
		return;
	
	/* Base pointer which is size shifted. */
	basep = SJME_POINTER_OFFSET_LONG(p, -4);
	
#if defined(__palmos__)
	/* Use Palm OS free. */
	MemPtrFree(basep);
#else
	/* Use Standard C free. */
	free(basep);
#endif
}