-
Notifications
You must be signed in to change notification settings - Fork 67
/
sqPlatformSpecific.h
149 lines (119 loc) · 5.35 KB
/
sqPlatformSpecific.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/****************************************************************************
* PROJECT: Platform-specific prototypes and definitions for the iPhone
* FILE: sqPlatformSpecific.h
* CONTENT:
*
* AUTHOR: John McIntosh
* ADDRESS:
* EMAIL: johnmci@smalltalkconsulting.com
* RCSID:
How to use this file:
This file is for general platform-specific macros and declarations.
Function prototypes that are unlikely to introduce name conflicts on
other platforms can be added directly. Macro re-definitions or conflicting
function prototypes can be wrapped in a #ifdefs. Alternatively, a customized
version of this file can be used on that platform. The goal is to keep all
the other header files generic across platforms. To override a definition or
macro from sq.h, you must first #undef it, then provide the new definition.
Define plugin for Netscape Plugin building, needed for CodeWarrior
*/
/*
Copyright (c) 2000-2008 Corporate Smalltalk Consulting Ltd. All rights reserved.
MIT License
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
The end-user documentation included with the redistribution, if any, must include the following acknowledgment:
"This product includes software developed by Corporate Smalltalk Consulting Ltd (http://www.smalltalkconsulting.com)
and its contributors", in the same place and form as other third-party acknowledgments.
Alternately, this acknowledgment may appear in the software itself, in the same form and location as other
such third-party acknowledgments.
*/
//
#include "pharovm/exportDefinition.h"
#ifdef macintoshSqueak
//#define SQUEAK_BUILTIN_PLUGIN
#define ENABLE_URL_FETCH
/* replace the image file manipulation macros with functions */
#undef sqAllocateMemory
//64bit function pointers undef
#undef dispatchFunctionPointer
#undef dispatchFunctionPointerOnin
#include <unistd.h>
#undef sqFTruncate
#define sqFTruncate(f,o) ftruncate(fileno(f), o)
#define ftell ftello
#define fseek fseeko
//int ftruncate(int, off_t);
#undef sqFilenameFromStringOpen
#undef sqFilenameFromString
void sqFilenameFromStringOpen(char *buffer,sqInt fileIndex, long fileLength);
void sqFilenameFromString(char *buffer,sqInt fileIndex, long fileLength);
#undef allocateMemoryMinimumImageFileHeaderSize
extern void* allocateJITMemory(usqInt desiredSize, usqInt desiredPosition);
extern usqInt sqAllocateMemory(usqInt minHeapSize, usqInt desiredHeapSize, usqInt baseAddress);
#define allocateMemoryMinimumImageFileHeaderSizeBaseAddress(heapSize, minimumMemory, fileStream, headerSize, baseAddress) \
sqAllocateMemory(minimumMemory, heapSize, baseAddress)
# define sqMacMemoryFree()
#include <dlfcn.h>
#undef ioMSecs
#define ioUtcWithOffset ioUtcWithOffset
/* undef the memory routines for our logic */
#undef sqMemoryExtraBytesLeft
sqInt sqMemoryExtraBytesLeft(sqInt includingSwap);
sqInt ioSetCursorARGB(sqInt cursorBitsIndex, sqInt extentX, sqInt extentY, sqInt offsetX, sqInt offsetY);
#if COGVM
extern void sqMakeMemoryExecutableFromTo(unsigned long, unsigned long);
extern void sqMakeMemoryNotExecutableFromTo(unsigned long, unsigned long);
extern int isCFramePointerInUse(void);
extern int osCogStackPageHeadroom(void);
extern void reportMinimumUnusedHeadroom(void);
#endif
/* Thread support for thread-safe signalSemaphoreWithIndex and/or the COGMTVM */
#if STACKVM
# define sqLowLevelYield() sched_yield()
# include <pthread.h>
# define sqOSThread pthread_t
/* these are used both in the STACKVM & the COGMTVM */
# define ioOSThreadsEqual(a,b) pthread_equal(a,b)
# define ioCurrentOSThread() pthread_self()
# if COGMTVM
/* Please read the comment for CogThreadManager in the VMMaker package for
* documentation of this API.
*/
typedef struct {
pthread_cond_t cond;
pthread_mutex_t mutex;
int count;
} sqOSSemaphore;
# define ioDestroyOSSemaphore(ptr) 0
# if !ForCOGMTVMImplementation /* this is a read-only export */
extern const pthread_key_t tltiIndex;
# endif
# define ioGetThreadLocalThreadIndex() ((long)pthread_getspecific(tltiIndex))
# define ioSetThreadLocalThreadIndex(v) (pthread_setspecific(tltiIndex,(void*)(v)))
# define ioOSThreadIsAlive(thread) (pthread_kill(thread,0) == 0)
# define ioTransferTimeslice() sched_yield()
# define ioMilliSleep(ms) usleep((ms) * 1000)
# endif /* COGMTVM */
#endif /* STACKVM */
#if !defined(VM_LABEL) || COGVM
# undef VM_LABEL
# define VM_LABEL(foo) ((void)0)
#endif
#endif /* macintoshSqueak */