[r120]: interpreter-3.x / trunk / kernel / platform / unix / PlatformDefinitions.h  Maximize  Restore  History

Download this file

623 lines (515 with data), 28.9 kB

  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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
/*----------------------------------------------------------------------------*/
/* */
/* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */
/* Copyright (c) 2005-2006 Rexx Language Association. All rights reserved. */
/* */
/* This program and the accompanying materials are made available under */
/* the terms of the Common Public License v1.0 which accompanies this */
/* distribution. A copy is also available at the following address: */
/* http://www.oorexx.org/license.html */
/* */
/* Redistribution and use in source and binary forms, with or */
/* without modification, are permitted provided that the following */
/* conditions are met: */
/* */
/* Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in */
/* the documentation and/or other materials provided with the distribution. */
/* */
/* Neither the name of Rexx Language Association nor the names */
/* of its contributors may be used to endorse or promote products */
/* derived from this software without specific prior written permission. */
/* */
/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */
/* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
/* */
/*----------------------------------------------------------------------------*/
/******************************************************************************/
/* REXX AIX/Linux Support aixrexx.h */
/* */
/* AIX/Linux master definition file */
/* */
/******************************************************************************/
/******************************************************************************/
/* Template for system specific declarations for Object REXX. The following */
/* sections are a series of required and optional sections where system */
/* specific information is provided to the rest of the interpreter code. */
/* Wherever possible, reasonable defaults are provided for these settings. */
/******************************************************************************/
#ifndef AIXREXX_H /* provide a define here to protect */
#define AIXREXX_H /* against multiple includes */
/******************************************************************************/
/* REQUIRED: The implemenation must decide on the C_STACK_SIZE defining */
/* constants that are compiler/linker dependent. */
/******************************************************************************/
#define MIN_C_STACK 1024*16
#define TOTAL_STACK_SIZE 1024*512
#define C_STACK_SIZE TOTAL_STACK_SIZE
/******************************************************************************/
/* REQUIRED: The following type definitions are used throughout the REXX */
/* kernel code, so definitions are required for all of these. If the system */
/* in questions (e.g., OS/2) provides definitions for these via other include */
/* files, any of these items can be deleted from the system specific file and */
/* and replaced by any replacement #includes at this point. */
/******************************************************************************/
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#define HQUEUE unsigned long
#define ULONG unsigned long
#define PULONG ULONG *
#define PVOID void *
#ifdef LINUX
#define PPVOID void **
#endif
#define SHORT short
#define LONG long
#define PLONG LONG *
#define USHORT unsigned short
#define PSHORT SHORT *
#define PUSHORT USHORT *
#define UCHAR unsigned char
#define PUCHAR UCHAR *
#define CHAR char
#define PCHAR CHAR *
#define INT int
#define UINT unsigned int
#define PINT int *
#define PCH PCHAR
#define PSZ PCHAR
#define APIENTRY
#define APIRET ULONG
#define CONST const
#define LPCTSTR LPCSTR
#define BYTE unsigned char
#define BOOL unsigned long
#define UBYTE unsigned char
#ifndef TID
#ifndef LINUX
#define TID tid_t
#else
#define TID pthread_t
#endif
#endif
#ifndef PID
#define PID pid_t
#endif
#define VOID void
#define near
#define far
#define _loadds
#define PFN void *
#if defined(LINUX) && defined(PPC)
#define VAPVOID void *
#define VACHAR int
#define VAINT int
#define VASHORT int
#define VAULONG long long
#define VAUSHORT int
#define VALONG long long
#define VAOREF void *
#else
#define VAPVOID PVOID
#define VACHAR CHAR
#define VAINT INT
#define VASHORT SHORT
#define VAULONG ULONG
#define VAUSHORT USHORT
#define VALONG LONG
#define VAOREF OREF
#endif
#ifdef LINUX
#define FNONBLOCK O_NONBLOCK
#endif
#define SysCall
#define SysCallV
//#define PATH_MAX POSIX_PATH_MAX
/******************************************************************************/
/* OPTIONAL: If the implementation is going to support a cross-process */
/* shared memory model, then include a define for SHARED */
/******************************************************************************/
//#define SHARED
#define RXTRACE_SUPPORT
/******************************************************************************/
/* OPTIONAL: If the implementation is going to support SOM, include a define */
/* for SOM. */
/******************************************************************************/
//#define SOM
//#define SOMV2 /* both these are required yet */
/******************************************************************************/
/* OPTIONAL: If the implementation is going to support multiple threads, */
/* include a define for THREADS. */
// If the implementation is going to use the OREXX thread package do NOT
// define THREADS.
/******************************************************************************/
#define THREADS
/******************************************************************************/
/* OPTIONAL: Perform stack checking on new message invocations. If this type*/
/* of information is not available, then do not include this define */
/******************************************************************************/
#define STACKCHECK
/******************************************************************************/
/* OPTIONAL: Need support for non-ansi string routines strdup, strupr, */
/* strlwr, stricmp, and memicmp. */
/******************************************************************************/
//#define NEED_NON_ANSI
/******************************************************************************/
/* OPTIONAL: No time slicing support for REXX activation yields is available.*/
/* Code will yield after a given count of instructions. */
/* This option is mutually exclusive with TIMESLICE. */
/******************************************************************************/
#define NOTIMER
/******************************************************************************/
/* OPTIONAL: Enable concurrency timeslice dispatching support. Default is */
/* only yield at specific event points. */
/******************************************************************************/
/* #define TIMESLICE */
/******************************************************************************/
/* OPTIONAL: If the implementation enables external scripting support, then */
/* additional hand-shaking with an the exernal environment is enabled for */
/* providing default values for uninitialized variables. */
/******************************************************************************/
//#define SCRIPTING
/******************************************************************************/
/* REQUIRED: Define the REXX type for semaphores. These can be system */
/* specific semaphore types or the REXX define OSEM. */
/******************************************************************************/
#define _POSIX_THREADS_
#ifdef OLD_THREADING_PACKAGE
#include "oryxthrd.h" // Need this here for OSEM structs
#define SMTX OSEM /* semaphore data types */
#define HMTX HOSEM
#define SEV OSEM
#define HEV HOSEM
// semaphore definitions and init
//
// If you use the OREXX Thread Package, the semaphores are structs. This
// macro must be changed such that each semaphore is assigned = {0,0,0}
//
#define SysSharedSemaphoreDefn SMTX rexx_kernel_semaphore = {0,0,0}; \
SMTX rexx_resource_semaphore = {0,0,0}; \
SMTX rexx_start_semaphore = {0,0,0}; \
SMTX rexx_wait_queue_semaphore = {0,0,0};
SEV rexxTimeSliceSemaphore = {0,0,0}; \
ULONG rexxTimeSliceTimerOwner;
#else
#ifdef OPSYS_AIX41
#define SysThreadYield() pthread_yield()
#else
#define SysThreadYield() sched_yield()
#endif
#include "ThreadSupport.hpp"
#include "SystemSemaphores.h"
#define KMTX INT /* kernel semaphore ID */
#define SMTX RexxMutex * /* semaphore data types */
#define HMTX SMTX
#define SEV RexxSemaphore *
#define HEV SEV
// semaphore definitions and init
//#ifdef AIX
extern SMTX initialize_sem;
extern int SecureFlag;
//#endif
#define SysSharedSemaphoreDefn SMTX rexx_kernel_semaphore = 0; \
SMTX rexx_resource_semaphore = 0; \
SMTX rexx_start_semaphore = 0; \
SMTX rexx_wait_queue_semaphore = 0; \
SEV rexxTimeSliceSemaphore = 0; \
ULONG rexxTimeSliceTimerOwner;
#endif
/******************************************************************************/
/* REQUIRED: Define the REXX type for exceptions. These can be system */
/* specific exception registration info or any place holder type if this */
/* doesn't apply. */
/******************************************************************************/
#define SYSEXCEPTIONBLOCK LONG
/******************************************************************************/
/* REQUIRED: Define the REXX type for a "thread function" that starts off */
/* a new thread. */
/******************************************************************************/
typedef void *(* PTHREADFN)(void *); /* define a thread function */
/******************************************************************************/
/* REQUIRED: Define any special requirements for external entry calls back */
/* into the interpreter. The default is no special requirements. */
/******************************************************************************/
#define REXXENTRY APIENTRY
/******************************************************************************/
/* REQUIRED: This was needed for Windows. Any entry points containing */
/* variable length arguments need to use __cdecl calling convention. */
/******************************************************************************/
#define VLAREXXENTRY APIENTRY /* external entry points */
#define VLAENTRY /* internal entry points */
/******************************************************************************/
/* REQUIRED: Definitions for REXX semaphore functions. These default to */
/* the REXX library semaphore package, but can be redefined to map directly */
/* to system specific functions too. */
// If you are using the OREXX Thread package, look at winrexx.h for correct
// setup of these macros.
/******************************************************************************/
#ifdef OLD_THREADING_PACKAGE
// Check these changes in oryxthrd.h
#define MTXCR(s) new ((void *)s) RexxMutex// create a mutex semaphore
// request wait on a semaphore
#define MTXRQ(s) OryxSemRequest(&s, SEM_INDEFINITE_WAIT)
#define MTXRL(s) OryxSemClear(&s) // clear a semaphore
#define MTXCL(s) // no need to close in thread package
// no wait, return if can't get it
#define MTXRI(s) OryxSemRequest(&s,SEM_IMMEDIATE_RETURN)
#define MTXNOPEN(s,n) // only used for shared stuff
#define MTXNCR(s,n) MTXCR(s)
#define EVCR(s) OryxSemInit(&s)
#define EVPOST(s) OryxSemClear(&s)
#define EVSET(s) OryxSemSet(&s)
#define EVWAIT(s) OryxSemWait(&s)
#define EVCL(s) // no need to close in thread package
#define EVCLOSE(s)
#define EVOPEN(s)
#define EVCLEAR(s) OryxSemInit(&s) // clear an OSEM
#define EVEXIST(s) s.use_count
#else
#define MTXCR(s) s = new RexxMutex// create a mutex semaphore
#define MTXCROPEN(s,n) s = new RexxMutex // dummy for Windows
// request wait on a semaphore
#define MTXRQ(s) s->request()
#define MTXRL(s) s->release() // clear a semaphore
/* Mutex semaphores are in AIX defined as C++ Object pointers and */
/* therefore must be deleted after use */
#define MTXCL(s) delete s
//#define MTXCL(s) // no need to close in thread package
// no wait, return if can't get it
#define MTXRI(s) s->requestImmediate()
#define MTXNOPEN(s,n) // only used for shared stuff
#define MTXNCR(s,n) MTXCR(s)
#define EVCR(s) s = new RexxSemaphore
#define EVCROPEN(s,n) s = new RexxSemaphore // dummy for Windows
#define EVPOST(s) s->post()
#define EVSET(s) s->reset()
#define EVWAIT(s) s->wait()
#define EVCL(s)
//#define EVCLOSE(s)
/* Event semaphores are in AIX defined as C++ Object pointers and */
/* therefore must be deleted after use */
#define EVCLOSE(s) delete s
#define EVOPEN(s)
//#define EVCLEAR(s) s->reset() // commented out by weigold
#define EVCLEAR(s) s=0 // and inserted new line
#define EVEXIST(s)
#endif
/******************************************************************************/
/* REQUIRED: Definitions for entering and exiting code sections that */
/* manipulate globally defined resources. */
/******************************************************************************/
#if defined(AIX) || defined(LINUX)
#define SysEnterResourceSection() MTXRQ(resource_semaphore);
#define SysExitResourceSection() MTXRL(resource_semaphore);
#else
#define SysEnterResourceSection() {\
MTXRQ(resource_semaphore); \
SysEnterCriticalSection(); }
#define SysExitResourceSection() {\
SysExitCriticalSection(); \
MTXRL(resource_semaphore); }
#endif
/******************************************************************************/
/* REQUIRED: Definitions for entering and exiting critical code sections. */
/* These can be defined out to nothing if these have no meaning. */
/******************************************************************************/
#define SysEnterCriticalSection() MTXRQ(initialize_sem);
#define SysExitCriticalSection() MTXRL(initialize_sem);
/******************************************************************************/
/* REQUIRED: Define a routine to determine if an activation needs to yield. */
/* Use whatever mechanism is approcpriate for given System. */
/* OS/2 uses the DosStartTimer, continious Asynch Timer. */
/******************************************************************************/
BOOL SysTimeSliceElapsed( void );
/******************************************************************************/
/* REQUIRED: Routine to start a new TimeSlice period. */
/******************************************************************************/
void SysStartTimeSlice( void );
/******************************************************************************/
/* REQUIRED: Routine to alloc memory passed to external environments */
/******************************************************************************/
#define SysAllocateExternalMemory(s) malloc((s))
#define SysFreeExternalMemory(p) free((p))
/******************************************************************************/
/* REQUIRED: Define the string used for the default initial address setting. */
/******************************************************************************/
#if defined(AIX)
#define SYSINITIALADDRESS "ksh"
#elif defined(OPSYS_SUN)
#define SYSINITIALADDRESS "sh"
#else
#define SYSINITIALADDRESS "bash"
#endif
/******************************************************************************/
/* REQUIRED: Define the macro to call the line_write_function */
/******************************************************************************/
#define line_write(b,c) fwrite(b,1,c,stream_info->stream_file)
/******************************************************************************/
/* REQUIRED: Define the name of the image file that is saved and restored. */
/******************************************************************************/
#define BASEIMAGE "rexx.img"
/******************************************************************************/
/* REQUIRED: Define the name of the program called to load create the saved */
/* image file. */
/******************************************************************************/
#define BASEIMAGELOAD "CoreClasses.orx" /* MHES 29122004 */
/******************************************************************************/
/* REQUIRED: Define a name for the initialization semaphore. If not required*/
/* for your system, just make this any string. */
/******************************************************************************/
#define INIT_SEM_NAME "INIT_SEM"
//******************************************************************************
// REQUIRED: Define name of rexxsaa.h toolkit header file for your platform
//******************************************************************************
#define SYSREXXSAA "rexx.h"
/******************************************************************************/
/* REQUIRED: Define the REXX type to hold information for a WIndow Environmen*/
/* These can be system specifc handles/etc for messageQueuue/Windows/etc */
/* or any place holder type if this doesn't apply */
/******************************************************************************/
typedef PVOID SYSWINDOWINFO;
/******************************************************************************/
/* Priority values used for adjusting thead priorities */
/******************************************************************************/
#ifdef AIX
#define HIGH_PRIORITY 127
#endif
/******************************************************************************/
/* REQUIRED: Name of the file used to store the external message repository */
/******************************************************************************/
#define REXXMESSAGEFILE ((PSZ)"rexx.cat")
/******************************************************************************/
/* REQUIRED: Define any additional native methods that are to be accessed as */
/* external REXX methods. */
/******************************************************************************/
#define SYSTEM_INTERNAL_METHODS() \
INTERNAL_METHOD(sysRxfuncadd) \
INTERNAL_METHOD(sysRxfuncdrop) \
INTERNAL_METHOD(sysRxfuncquery) \
INTERNAL_METHOD(sysBeep) \
INTERNAL_METHOD(sysFilespec) \
INTERNAL_METHOD(sysDirectory) \
INTERNAL_METHOD(sysSetLocal) \
INTERNAL_METHOD(sysEndLocal) \
INTERNAL_METHOD(server_init_local) \
INTERNAL_METHOD(function_queueExit)
/******************************************************************************/
/* REQUIRED: Definitions for stream I/O. Each should be tailored to the */
/* needs/quirks of the platform file systems. */
/* The following lines are examples from the OS/2 code. */
/******************************************************************************/
#ifdef INCL_REXX_STREAM /* asking for file system stuff? */
/******************************************************************************/
/* REQUIRED: include whatever library system specific include files are */
/* needed. If it is necessary to override any standard routines, do this */
/* here. */
/******************************************************************************/
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#if defined(AIX)
#include <usersec.h>
#else
#include <pwd.h>
#endif
/******************************************************************************/
/* REQUIRED: define the path delimiter and end of line information */
/* appropriate for this file system. */
/******************************************************************************/
#define delimiter '/'
#define line_end "\n"
#define line_end_size 1
/* adjust scan pointer */
//#define adjust_scan_at_line_end()
#endif
#if defined(AIX) || defined(LINUX)
#define OLDMETAVERSION 22 /* highest meta version number: */
#else
#define OLDMETAVERSION 30 // each platform should have it's own old meta version
#endif
#define OPT_CHAR '-' /* Option char for UNIX */
/******************************************************************************/
/* REQUIRED: Define the REXX type for a native method function */
/******************************************************************************/
/* pointer to native method function */
typedef char *(far *REXXENTRY PNMF)(void **);
/******************************************************************************/
/* OPTIONAL: Overrides for any functions defined in sysdef.h. These */
/* can map the calls directly to inline code or comment them out all together.*/
/* The following lines are examples from the OS/2 code. */
/******************************************************************************/
#define SysRelinquish()
#if defined(AIX)
#define SysName() new_string("AIX", 3)
#define SysINTName() new_string("AIX",3)
#elif defined(OPSYS_SUN)
#define SysName() new_string("SUNOS", 5)
#define SysINTName() new_string("SUNOS",5)
#else
#define SysName() new_string("LINUX", 5)
#define SysINTName() new_string("LINUX",5)
// Thread yielding functions in
// threading package
//#define SysThreadYield() sched_yield()
#endif
//#define SysQueryThreadID() LinThreadQueryID()
//#define SysGetThreadStackBase(INT) NULL
//#define SysTerminateThread(t) { pthread_detach((t)); }
#ifdef AIX
#define SysIsThreadEqual(pth1, pth2) (pthread_equal(pth1, pth2))
#endif
#define SysThreadArg(a) a->args
//#define SysCreateThread(PTHREADFN, INT, PVOID) LinThreadCreate(PTHREADFN, INT, PVOID)
#define SysInitialAddressName() OREF_INITIALADDRESS
#define SysRegisterExceptions(SYSEXCEPTIONBLOCK)
#define SysDeregisterExceptions(SYSEXCEPTIONBLOCK)
#define SysGetTempFileName() tmpnam(NULL)
/******************************************************************************/
/* REQUIRED: Define the macro for pointer subtraction */
/******************************************************************************/
#define PTRSUB(f,s) ((char *)(f)-(char *)(s))
/******************************************************************************/
/* OPTIONAL: Finally, any other global defined constants for system specific */
/* code usage. */
/******************************************************************************/
#define DEFRXSTRING 256 /* Default RXSTRING return size */
extern ULONG ProcessMustCompleteNest; /* The must complete nest */
#ifdef __cplusplus
extern "C" {
#endif
PSZ APIENTRY RexxGetVersionInformation(void);
//void SysResetEventSem (SEV *psem); /* reset an event semaphore */
//void SysCreateMutexSem (SMTX *psem); /* create/open a mutex semaphore */
#ifdef SEMAPHORE_DEBUG
void SysRequestMutexSem (SMTX psem); /* request a mutex semaphore */
/* request a mutex (immediate return)*/
LONG SysRequestImmediateMutexSem (SMTX psem);
#define REXXTIMESLICE 100 /* 100 milliseconds (1/10 second) */
#endif
/* moved from olcrtmis.h */
#define stricmp(s1, s2) strcasecmp(s1, s2)
#define memicmp(s1, s2, l) strncasecmp((char *)s1, (char *)s2, l)
/* both functions can only be used */
/* without a return value & radix=10 */
#define _ltoa(val, str, radix) sprintf(str, "%d", val)
#define _ultoa(val, str, radix) sprintf(str, "%u", val)
//#include "olcrtmis.h"
#ifdef __cplusplus
}
#endif
#endif

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks