3 * @brief Include O/S headers and smooth out per-O/S differences
6 * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved.
8 * This software is distributed under commercial and open source licenses.
9 * You may use the GPL open source license described below or you may acquire
10 * a commercial license from Mbedthis Software. You agree to be fully bound
11 * by the terms of either license. Consult the LICENSE.TXT distributed with
12 * this software for full details.
14 * This software is open source; you can redistribute it and/or modify it
15 * under the terms of the GNU General Public License as published by the
16 * Free Software Foundation; either version 2 of the License, or (at your
17 * option) any later version. See the GNU General Public License for more
18 * details at: http://www.mbedthis.com/downloads/gplLicense.html
20 * This program is distributed WITHOUT ANY WARRANTY; without even the
21 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23 * This GPL license does NOT permit incorporating this software into
24 * proprietary programs. If you are unable to comply with the GPL, you must
25 * acquire a commercial license to use this software. Commercial licenses
26 * for this software and support services are available from Mbedthis
27 * Software at http://www.mbedthis.com
32 /******************************* Documentation ********************************/
35 * This header is part of the Mbedthis Portable Runtime and aims to include
36 * all necessary O/S headers and to unify the constants and declarations
37 * required by Mbedthis products. It can be included by C or C++ programs.
40 /******************************************************************************/
42 #ifndef _h_MPR_OS_HDRS
43 #define _h_MPR_OS_HDRS 1
45 #include "buildConfig.h"
47 /********************************* CPU Families *******************************/
49 * Porters, add your CPU families here and update configure code.
51 #define MPR_CPU_UNKNOWN 0
52 #define MPR_CPU_IX86 1
54 #define MPR_CPU_SPARC 3
55 #define MPR_CPU_XSCALE 4
57 #define MPR_CPU_MIPS 6
59 #define MPR_CPU_SIMNT 8 /* VxWorks NT simulator */
60 #define MPR_CPU_SIMSPARC 9 /* VxWorks sparc simulator */
62 /********************************* O/S Includes *******************************/
65 #include <sys/types.h>
67 #include <arpa/inet.h>
78 #include <netinet/in.h>
79 #include <netinet/tcp.h>
80 #include <netinet/ip.h>
90 #include <sys/ioctl.h>
92 #include <sys/param.h>
93 #include <sys/resource.h>
96 #include <sys/socket.h>
97 #include <sys/select.h>
99 #include <sys/times.h>
100 #include <sys/utsname.h>
101 #include <sys/wait.h>
109 #include <netinet/in_systm.h>
112 #if BLD_FEATURE_FLOATING_POINT
113 #define __USE_ISOC99 1
118 #endif /* LINUX || SOLARIS */
123 #include <sys/types.h>
125 #include <arpa/inet.h>
134 #include <netinet/tcp.h>
135 #include <netinet/in.h>
136 #include <netinet/ip.h>
142 #include <sysSymTbl.h>
143 #include <sys/fcntlcom.h>
144 #include <sys/ioctl.h>
145 #include <sys/stat.h>
146 #include <sys/socket.h>
147 #include <sys/times.h>
148 #include <sys/wait.h>
152 #if BLD_FEATURE_FLOATING_POINT
154 #define __USE_ISOC99 1
165 #include <taskHookLib.h>
171 #include <arpa/inet.h>
178 #include <mach-o/dyld.h>
181 #include <netinet/in_systm.h>
182 #include <netinet/in.h>
183 #include <netinet/tcp.h>
184 #include <netinet/ip.h>
195 #include <sys/ioctl.h>
196 #include <sys/types.h>
197 #include <sys/stat.h>
198 #include <sys/param.h>
199 #include <sys/resource.h>
202 #include <sys/socket.h>
203 #include <sys/select.h>
204 #include <sys/time.h>
205 #include <sys/times.h>
206 #include <sys/types.h>
207 #include <sys/utsname.h>
208 #include <sys/wait.h>
214 * We replace insecure functions with Mbedthis replacements
216 #define _CRT_SECURE_NO_DEPRECATE 1
227 #include <sys/stat.h>
228 #include <sys/types.h>
235 #define WIN32_LEAN_AND_MEAN
236 #include <winsock2.h>
239 #if BLD_FEATURE_FLOATING_POINT
243 #include <shellapi.h>
244 #include <wincrypt.h>
253 #if BLD_FEATURE_FLOATING_POINT
254 #warning "Floating point is not supported on Brew"
256 #if BLD_FEATURE_MULTITHREAD
257 #warning "Multithreading is not supported on Brew"
260 #include "AEEModGen.h"
261 #include "AEEAppGen.h"
262 #include "BREWVersion.h"
264 #if BREW_MAJ_VER == 2
269 #define __inline extern __inline__
276 #include "AEEBitmap.h"
280 #include "AEEImageCtl.h"
281 #include "AEEMedia.h"
282 #include "AEEMediaUtil.h"
283 #include "AEEMimeTypes.h"
284 #include "AEEStdLib.h"
285 #include "AEEShell.h"
286 #include "AEESoundPlayer.h"
288 #include "AEETransform.h"
290 #if BREW_MAJ_VER >= 3
296 #include "AEESound.h"
303 /******************************************************************************/
304 /******************************* General Defines ******************************/
305 /******************************************************************************/
309 #define MAXINT INT_MAX
311 #define MAXINT 0x7fffffff
316 #define BITSPERBYTE (8 * sizeof(char))
319 #define BITS(type) (BITSPERBYTE * (int) sizeof(type))
322 #define max(a,b) (((a) > (b)) ? (a) : (b))
326 #define min(a,b) (((a) < (b)) ? (a) : (b))
329 #define MPR_ARRAY_SIZE(type) (sizeof(type) / sizeof(type[0]))
331 #ifndef PRINTF_ATTRIBUTE
332 #if (__GNUC__ >= 3) && !DOXYGEN && BLD_FEATURE_ALLOC_LEAK_TRACK
333 /** Use gcc attribute to check printf fns. a1 is the 1-based index of
334 * the parameter containing the format, and a2 the index of the first
335 * argument. Note that some gcc 2.x versions don't handle this
337 #define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2)))
339 #define PRINTF_ATTRIBUTE(a1, a2)
343 typedef char *MprStr; /* Used for dynamic strings */
351 /******************************************************************************/
352 /******************************** Linux Defines *******************************/
353 /******************************************************************************/
356 typedef unsigned char uchar;
358 #if BLD_FEATURE_INT64
359 __extension__ typedef long long int int64;
360 __extension__ typedef unsigned long long int uint64;
361 #define INT64(x) (x##LL)
362 #define UINT64(x) (x##ULL)
365 #define closesocket(x) close(x)
366 #define MPR_BINARY ""
370 #define SOCKET_ERROR -1
371 #define MPR_DLL_EXT ".so"
373 #if BLD_FEATURE_FLOATING_POINT
374 #define MAX_FLOAT MAXFLOAT
378 * For some reason it is removed from fedora pthreads.h and only
379 * comes in for UNIX96
381 extern int pthread_mutexattr_gettype (__const pthread_mutexattr_t *__restrict
382 __attr, int *__restrict __kind) __THROW;
383 /* Set the mutex kind attribute in *ATTR to KIND (either PTHREAD_MUTEX_NORMAL,
384 PTHREAD_MUTEX_RECURSIVE, PTHREAD_MUTEX_ERRORCHECK, or
385 PTHREAD_MUTEX_DEFAULT). */
386 extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind)
391 /******************************************************************************/
392 /******************************* VxWorks Defines ******************************/
393 /******************************************************************************/
397 typedef unsigned char uchar;
398 typedef unsigned int uint;
399 typedef unsigned long ulong;
401 #define HAVE_SOCKLEN_T
402 typedef int socklen_t;
404 #if BLD_FEATURE_INT64
405 typedef long long int int64;
406 typedef unsigned long long int uint64;
407 #define INT64(x) (x##LL)
408 #define UINT64(x) (x##ULL)
411 #define closesocket(x) close(x)
412 #define getpid() taskIdSelf()
413 #define MPR_BINARY ""
417 #define SOCKET_ERROR -1
418 #define MPR_DLL_EXT ".so"
420 #if BLD_FEATURE_FLOATING_POINT
421 #define MAX_FLOAT FLT_MAX
433 #define MSG_NOSIGNAL 0
435 extern int access(char *path, int mode);
436 extern int sysClkRateGet();
440 /******************************************************************************/
441 /******************************** MacOsx Defines ******************************/
442 /******************************************************************************/
444 typedef unsigned long ulong;
445 typedef unsigned char uchar;
447 #if BLD_FEATURE_INT64
448 __extension__ typedef long long int int64;
449 __extension__ typedef unsigned long long int uint64;
450 #define INT64(x) (x##LL)
451 #define UINT64(x) (x##ULL)
454 #define closesocket(x) close(x)
455 #define MPR_BINARY ""
459 #define SOCKET_ERROR -1
460 #define MPR_DLL_EXT ".dylib"
461 #define MSG_NOSIGNAL 0
462 #define __WALL 0x40000000
463 #define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
465 #if BLD_FEATURE_FLOATING_POINT
466 #define MAX_FLOAT MAXFLOAT
471 /******************************************************************************/
472 /******************************* Windows Defines ******************************/
473 /******************************************************************************/
476 typedef unsigned char uchar;
477 typedef unsigned int uint;
478 typedef unsigned long ulong;
479 typedef unsigned short ushort;
482 * We always define INT64 types on windows
484 #if BLD_FEATURE_INT64 || 1
485 typedef __int64 int64;
486 typedef unsigned __int64 uint64;
487 #define INT64(x) (x##i64)
488 #define UINT64(x) (x##Ui64)
492 typedef void *handle;
493 typedef char *caddr_t;
496 typedef ushort mode_t;
497 typedef void *siginfo_t;
499 #define HAVE_SOCKLEN_T
500 typedef int socklen_t;
508 * On windows map X_OK to R_OK
516 #define EADDRINUSE 46
519 #define EWOULDBLOCK EAGAIN
525 #define ECONNRESET 44
528 #define ECONNREFUSED 45
531 #define MSG_NOSIGNAL 0
532 #define MPR_BINARY "b"
535 #if BLD_FEATURE_FLOATING_POINT
536 #define MAX_FLOAT DBL_MAX
539 #ifndef FILE_FLAG_FIRST_PIPE_INSTANCE
540 #define FILE_FLAG_FIRST_PIPE_INSTANCE 0x00080000
543 #define MPR_DLL_EXT ".dll"
546 /******************************************************************************/
547 /****************************** Solaris Defines *******************************/
548 /******************************************************************************/
551 typedef unsigned char uchar;
553 #if BLD_FEATURE_INT64
554 typedef long long int int64;
555 typedef unsigned long long int uint64;
556 #define INT64(x) (x##LL)
557 #define UINT64(x) (x##ULL)
560 #define closesocket(x) close(x)
561 #define MPR_BINARY ""
565 #define SOCKET_ERROR -1
566 #define MPR_DLL_EXT ".so"
567 #define MSG_NOSIGNAL 0
568 #define INADDR_NONE ((in_addr_t) 0xffffffff)
570 #define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
572 #if BLD_FEATURE_FLOATING_POINT
573 #define MAX_FLOAT MAXFLOAT
578 /******************************************************************************/
579 /********************************* BREW Defines *******************************/
580 /******************************************************************************/
583 typedef unsigned char uchar;
584 typedef unsigned int uint;
585 typedef unsigned long ulong;
586 typedef unsigned short ushort;
593 typedef void *handle;
594 typedef char *caddr_t;
596 typedef ushort mode_t;
597 typedef void *siginfo_t;
599 #define HAVE_SOCKLEN_T
600 typedef int socklen_t;
603 #define EADDRINUSE 46
606 #define EWOULDBLOCK EAGAIN
612 #define ECONNRESET 44
615 #define ECONNREFUSED 45
618 #define MSG_NOSIGNAL 0
619 #define MPR_BINARY "b"
622 #define MPR_DLL_EXT ".dll"
628 #define O_CREAT 0x200
629 #define O_TRUNC 0x400
631 #define O_TEXT 0x20000
632 #define O_EXCL 0x40000
633 #define O_APPEND 0x80000
651 extern int isalnum(int c);
652 extern int isalpha(int c);
653 extern int isdigit(int c);
654 extern int islower(int c);
655 extern int isupper(int c);
656 extern int isspace(int c);
657 extern int isxdigit(int c);
659 extern uint strlen(const char *str);
660 extern char *strstr(const char *string, const char *strSet);
661 extern void *memset(const void *dest, int c, uint count);
662 extern void exit(int status);
663 extern char *strpbrk(const char *str, const char *set);
664 extern uint strspn(const char *str, const char *set);
665 extern int tolower(int c);
666 extern int toupper(int c);
667 extern void *memcpy(void *dest, const void *src, uint count);
668 extern void *memmove(void *dest, const void *src, uint count);
670 extern int atoi(const char *str);
671 extern void free(void *ptr);
672 extern void *malloc(uint size);
673 extern void *realloc(void *ptr, uint size);
674 extern char *strcat(char *dest, const char *src);
675 extern char *strchr(const char *str, int c);
676 extern int strcmp(const char *s1, const char *s2);
677 extern int strncmp(const char *s1, const char *s2, uint count);
678 extern char *strcpy(char *dest, const char *src);
679 extern char *strncpy(char *dest, const char *src, uint count);
680 extern char *strrchr(const char *str, int c);
683 #define printf DBGPRINTF
685 #if BREW_SIMULATOR && BLD_DEBUG
686 extern _CRTIMP int __cdecl _CrtCheckMemory(void);
687 extern _CRTIMP int __cdecl _CrtSetReportHook();
692 /******************************************************************************/
697 #endif /* _h_MPR_OS_HDRS */
705 * vim600: sw=4 ts=4 fdm=marker