You.i Engine
YiPredefApple.h
Go to the documentation of this file.
1 // © You i Labs Inc. 2000-2017. All rights reserved.
2 #ifndef _YI_PREDEF_APPLE_H_
3 #define _YI_PREDEF_APPLE_H_
4 
5 #include "CoreFoundation/CoreFoundation.h"
6 
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <ctype.h>
10 #include <string.h>
11 #include <strings.h>
12 #include <wchar.h>
13 #include <time.h> // for nanosleep()
14 #include <unistd.h> // for usleep()
15 
16 #include <string>
17 #include <queue>
18 #include <stack>
19 #include <vector>
20 #include <map>
21 #include <list>
22 #include <iterator>
23 #include <sstream>
24 #include <iostream>
25 #include <algorithm>
26 #include <fstream>
27 
33 // platform-dependant functions
34 // memory
35 #define YI_SYSTEM_FREE(a) free(a)
36 #define YI_SYSTEM_MALLOC(a) malloc(a)
37 #define YI_SYSTEM_REALLOC(a, b) realloc(a, b)
38 #define YI_MEMCMP(a, b, c) memcmp(a, b, c)
39 #define YI_MEMMOVE(a, b, c) memmove(a, b, c)
40 #define YI_MEMCOPY(a, b, c) memcpy(a, b, c)
41 #define YI_MEMSET(a, b, c) memset(a, b, c)
42 
43 // multi-byte string
44 // NOTE: To be used only when absolutely required.
45 // Wide strings are preferred
46 #define YI_STRCAT(a, b) strcat(a, b)
47 #define YI_STRCHR(a, b) strchr(a, b)
48 #define YI_STRCMP(a, b) strcmp(a, b)
49 #define YI_STRCPY(a, b) strcpy(a, b)
50 #define YI_STRLEN(a) strlen(a)
51 #define YI_STRREV(a) STRREV(a)
52 #define YI_STRNCMP(a, b, c) strncmp(a, b, c)
53 #define YI_STRNICMP(a, b, c) strncmp(a, b, c)
54 #define YI_STRNCAT(a, b, c) strncat(a, b, c)
55 #define YI_STRNCPY(a, b, c) strncpy(a, b, c)
56 #define YI_STRRCHR(a, b) strrchr(a, b)
57 #define YI_STRTOUL(a, b, c) strtoul(a, b, c)
58 #define YI_VSNPRINTF(a, b, c, d) vsnprintf(a, b, c, d)
59 #define YI_STRICMP(a, b) strcasecmp(a, b)
60 #define YI_SPRINTF sprintf
61 #define YI_SNPRINTF snprintf
62 #define YI_ATOI(a) atoi(a)
63 #define YI_ATOF(a) atof(a)
64 
65 // wide string
66 #define YI_WCSCPY WCSCPY
67 #define YI_WCSNCPY WCSNCPY
68 #define YI_WCSLEN WCSLEN
69 #define YI_WCSREV WCSREV
70 #define YI_WCSCMP WCSCMP
71 #define YI_WCSNCMP WCSNCMP
72 #define YI_WCSICMP WCSICMP
73 #define YI_WCSNICMP WCSNICMP
74 #define YI_WCSCAT WCSCAT
75 #define YI_WCSNCAT WCSNCAT
76 #define YI_WCSSTR WCSSTR
77 #define YI_WCSCHR WCSCHR
78 #define YI_SWPRINTF swprintf
79 
80 #if _POSIX_C_SOURCE >= 199309L
81 inline void YI_SLEEP(long timeMs)
82 {
83  struct timespec ts;
84  ts.tv_sec = int(timeMs / 1000);
85  ts.tv_nsec = (timeMs % 1000) * 1000000;
86  nanosleep(&ts, NULL);
87 }
88 
89 inline void YI_USLEEP(long timeUs)
90 {
91  struct timespec ts;
92  ts.tv_sec = int(timeUs / 1000000);
93  ts.tv_nsec = (timeUs % 1000000) * 1000;
94  nanosleep(&ts, NULL);
95 }
96 #else
97 // usleep: This C routine is considered obsolete (as opposed to the shell
98 // command by the same name). The interaction of this function with SIGALRM and
99 // other timer functions such as sleep(), alarm(), setitimer(), and nanosleep()
100 // is unspecified (CWE-676). Use nanosleep(2) or setitimer(2) instead.
101 #define YI_SLEEP(x) usleep((x)*1000)
102 #define YI_USLEEP(x) usleep(x)
103 #endif
104 
105 //File handling
106 #define YI_FILE FILE
107 #define YI_FREAD (int32_t) fread
108 #define YI_FWRITE fwrite
109 #define YI_FGETC fgetc
110 #define YI_FPUTC fputc
111 
112 #if defined(YI_IOS)
113 #define YI_HAS_VIRTUAL_KEYBOARD
114 #endif
115 
116 #ifndef _SIZE_T_DEFINED
117 typedef unsigned long size_t;
118 #define _SIZE_T_DEFINED
119 #endif
120 
121 typedef void *HANDLE;
122 
126 #endif // _YI_PREDEF_APPLE_H_
#define YI_SLEEP(x)
Definition: YiPredefApple.h:101
void * HANDLE
Definition: YiPredefApple.h:121
unsigned long size_t
Definition: YiPredefApple.h:117
#define YI_USLEEP(x)
Definition: YiPredefApple.h:102