Changeset 494 for trunk/src/emx/include
- Timestamp:
- Aug 1, 2003, 8:42:12 AM (22 years ago)
- Location:
- trunk/src/emx/include
- Files:
-
- 3 added
- 3 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/include/386/builtin.h
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r493 r494 87 87 } 88 88 89 /* Quick routines similar to div() and friends, but inline */ 90 91 static __inline__ long __ldivmod (long num, long den, long *rem) 92 { 93 long q, r; 94 __asm__ ("cltd; idivl %2" 95 : "=a" (q), "=&d" (r) 96 : "r?m" (den), "a" (num)); 97 *rem = r; 98 return q; 99 } 100 101 static __inline__ unsigned long __uldivmod (unsigned long num, 102 unsigned long den, unsigned long *rem) 103 { 104 unsigned long q, r; 105 __asm__ ("xorl %%edx,%%edx; divl %2" 106 : "=a" (q), "=&d" (r) 107 : "r?m" (den), "a" (num)); 108 *rem = r; 109 return q; 110 } 111 112 /* 113 Divide a 64-bit integer by a 32-bit one: 114 115 A*2^32 + B A B + (A mod 32) 116 ---------- = --- * 2^32 + ---------------- 117 C C C 118 */ 119 static __inline__ long long __lldivmod (long long num, long den, long *rem) 120 { 121 long long q; 122 long r; 123 __asm__ (" movl %%eax,%%esi;" 124 " movl %%edx,%%eax;" 125 " pushl %%edx;" 126 " cltd;" 127 " idivl %2;" 128 " ;" 129 /* Now ensure remainder is smallest of possible two values (negative and 130 positive). For this we compare the remainder with positive and negative 131 denominator/2; if it is smaller than one and bigger than another we 132 consider it optimal, otherwise it can be made smaller by adding or 133 subtracting denominator to it. This is done to ensure no overflow 134 will occur at next division. */ 135 " movl %2,%%ecx;" 136 " sarl $1,%%ecx;" /* ecx = den/2 */ 137 " cmpl %%ecx,%%edx;" 138 " setl %%bl;" 139 " negl %%ecx;" 140 " cmpl %%ecx,%%edx;" 141 " setl %%bh;" 142 " xorb %%bh,%%bl;" 143 " jnz 1f;" /* Remainder is between -den/2...den/2 */ 144 " ;" 145 /* If remainder has same sign as denominator, we have to do r -= den; q++; 146 otherwise we have to do r += den; q--; */ 147 " movl %2,%%ebx;" /* ebx = den */ 148 " xorl %%edx,%%ebx;" /* r ^ den */ 149 " js 0f;" /* Different signs */ 150 " subl %2,%%edx;" /* r -= den */ 151 " addl $1,%%eax;" /* q++ */ 152 " adcl $0,%%edx;" 153 " jmp 1f;" 154 " ;" 155 "0: addl %2,%%edx;" /* r += den */ 156 " subl $1,%%eax;" /* q-- */ 157 " sbbl $0,%%edx;" 158 " ;" 159 "1: xchgl %%eax,%%esi;" 160 " idivl %2;" 161 " ;" 162 " movl %%edx,%1;" 163 " cltd;" 164 " addl %%esi,%%edx;" 165 " ;" 166 /* Check if numerator has the same sign as remainder; if they have different 167 sign we should make the remainder have same sign as numerator to comply 168 with ANSI standard, which says we always should truncate the quotient 169 towards zero. */ 170 " popl %%ebx;" /* ebx = num >> 32 */ 171 " xorl %1,%%ebx;" /* sign(r) ^ sign(num) */ 172 " jns 3f;" /* jump if same sign */ 173 " ;" 174 /* If remainder has same sign as denominator, we have to do r -= den; q++; 175 otherwise we have to do r += den; q--; */ 176 " movl %2,%%ebx;" 177 " xorl %1,%%ebx;" /* r ^ den */ 178 " js 2f;" /* Different signs */ 179 " subl %2,%1;" /* r -= den */ 180 " addl $1,%%eax;" /* q++ */ 181 " adcl $0,%%edx;" 182 " jmp 3f;" 183 " ;" 184 "2: addl %2,%1;" /* r += den */ 185 " subl $1,%%eax;" /* q-- */ 186 " sbbl $0,%%edx;" 187 " ;" 188 "3: ;" 189 : "=A" (q), "=&c" (r) 190 : "r" (den), "A" (num) 191 : "ebx", "esi"); 192 *rem = r; 193 return q; 194 } 195 196 /* 197 Same as __lldivmod except that if A < C, we can do just one division 198 instead of two because the result is always a 32-bit integer. 199 */ 200 static __inline__ unsigned long long __ulldivmod (unsigned long long num, 201 unsigned long den, unsigned long *rem) 202 { 203 unsigned long long q; 204 unsigned long r; 205 __asm__ (" movl %%eax,%1;" 206 " movl %%edx,%%eax;" 207 " xorl %%edx,%%edx;" 208 " divl %2;" 209 " xchgl %%eax,%%ecx;" 210 " divl %2;" 211 " xchgl %%edx,%1;" 212 : "=A" (q), "=c" (r) 213 : "r?m" (den), "A" (num)); 214 *rem = r; 215 return q; 216 } 217 89 218 #if defined (__cplusplus) 90 219 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/ctype.h
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r493 r494 1 /* ctype.h (emx+gcc) */ 1 /* 2 Locale support implementation through OS/2 Unicode API. 3 Copyright (c) 2003 InnoTek Systemberatung GmbH 4 5 For conditions of distribution and use, see the file COPYING. 6 7 Character type querying. 8 */ 2 9 3 10 #ifndef _CTYPE_H … … 8 15 #endif 9 16 10 extern unsigned char _ctype[]; 17 #include <sys/locale.h> 11 18 12 #define _UPPER 0x01 13 #define _LOWER 0x02 14 #define _DIGIT 0x04 15 #define _XDIGIT 0x08 16 #define _CNTRL 0x10 17 #define _SPACE 0x20 18 #define _PUNCT 0x40 19 #define _PRINT 0x80 19 static inline int isalnum (int _c) 20 { return __locale_ctype.cflags [_c & 0xff] & (__UPPER|__LOWER|__DIGIT); } 20 21 21 #if defined (__cplusplus) 22 static inline int isalpha (int _c) 23 { return __locale_ctype.cflags [_c & 0xff] & (__UPPER|__LOWER); } 22 24 23 extern inline int isalnum (int _c) 24 { return (_ctype+1)[(unsigned char)_c] & (_UPPER|_LOWER|_DIGIT); } 25 extern inline int isalpha (int _c) 26 { return (_ctype+1)[(unsigned char)_c] & (_UPPER|_LOWER); } 27 extern inline int iscntrl (int _c) 28 { return (_ctype+1)[(unsigned char)_c] & (_CNTRL); } 29 extern inline int isdigit (int _c) 30 { return (_ctype+1)[(unsigned char)_c] & (_DIGIT); } 31 extern inline int isgraph (int _c) 32 { return (_ctype+1)[(unsigned char)_c] & (_PUNCT|_UPPER|_LOWER|_DIGIT); } 33 extern inline int islower (int _c) 34 { return (_ctype+1)[(unsigned char)_c] & (_LOWER); } 35 extern inline int isprint (int _c) 36 { return (_ctype+1)[(unsigned char)_c] & (_PRINT); } 37 extern inline int ispunct (int _c) 38 { return (_ctype+1)[(unsigned char)_c] & (_PUNCT); } 39 extern inline int isspace (int _c) 40 { return (_ctype+1)[(unsigned char)_c] & (_SPACE); } 41 extern inline int isupper (int _c) 42 { return (_ctype+1)[(unsigned char)_c] & (_UPPER); } 43 extern inline int isxdigit (int _c) 44 { return (_ctype+1)[(unsigned char)_c] & (_XDIGIT); } 25 static inline int iscntrl (int _c) 26 { return __locale_ctype.cflags [_c & 0xff] & (__CNTRL); } 45 27 46 #else 28 static inline int isdigit (int _c) 29 { return __locale_ctype.cflags [_c & 0xff] & (__DIGIT); } 47 30 48 #define isalnum(c) ((_ctype+1)[(unsigned char)c] & (_UPPER|_LOWER|_DIGIT)) 49 #define isalpha(c) ((_ctype+1)[(unsigned char)c] & (_UPPER|_LOWER)) 50 #define iscntrl(c) ((_ctype+1)[(unsigned char)c] & (_CNTRL)) 51 #define isdigit(c) ((_ctype+1)[(unsigned char)c] & (_DIGIT)) 52 #define isgraph(c) ((_ctype+1)[(unsigned char)c] & (_PUNCT|_UPPER|_LOWER|_DIGIT)) 53 #define islower(c) ((_ctype+1)[(unsigned char)c] & (_LOWER)) 54 #define isprint(c) ((_ctype+1)[(unsigned char)c] & (_PRINT)) 55 #define ispunct(c) ((_ctype+1)[(unsigned char)c] & (_PUNCT)) 56 #define isspace(c) ((_ctype+1)[(unsigned char)c] & (_SPACE)) 57 #define isupper(c) ((_ctype+1)[(unsigned char)c] & (_UPPER)) 58 #define isxdigit(c) ((_ctype+1)[(unsigned char)c] & (_XDIGIT)) 31 static inline int isgraph (int _c) 32 { return __locale_ctype.cflags [_c & 0xff] & (__PUNCT|__UPPER|__LOWER|__DIGIT); } 59 33 60 int (isalnum)(int); 61 int (isalpha)(int); 62 int (iscntrl)(int); 63 int (isdigit)(int); 64 int (isgraph)(int); 65 int (islower)(int); 66 int (isprint)(int); 67 int (ispunct)(int); 68 int (isspace)(int); 69 int (isupper)(int); 70 int (isxdigit)(int); 34 static inline int islower (int _c) 35 { return __locale_ctype.cflags [_c & 0xff] & (__LOWER); } 71 36 72 int toupper (int); 73 int tolower (int); 74 int _toupper (int); 75 int _tolower (int); 37 static inline int isprint (int _c) 38 { return __locale_ctype.cflags [_c & 0xff] & (__PRINT); } 76 39 77 #endif 40 static inline int ispunct (int _c) 41 { return __locale_ctype.cflags [_c & 0xff] & (__PUNCT); } 78 42 79 #if !defined (_CTYPE_FUN) 80 extern __inline__ int _toupper (int _c) { return (_c-'a'+'A'); } 81 extern __inline__ int _tolower (int _c) { return (_c-'A'+'a'); } 82 extern __inline__ int toupper(int _c) 83 {return (islower(_c) ? _toupper(_c) : _c);} 84 extern __inline__ int tolower(int _c) 85 {return (isupper(_c) ? _tolower(_c) : _c);} 86 #endif 43 static inline int isspace (int _c) 44 { return __locale_ctype.cflags [_c & 0xff] & (__SPACE); } 45 46 static inline int isupper (int _c) 47 { return __locale_ctype.cflags [_c & 0xff] & (__UPPER); } 48 49 static inline int isxdigit (int _c) 50 { return __locale_ctype.cflags [_c & 0xff] & (__XDIGIT); } 51 52 static inline int toupper (int _c) 53 { return __locale_ctype.upcase [_c & 0xff]; } 54 55 static inline int tolower (int _c) 56 { return __locale_ctype.locase [_c & 0xff]; } 87 57 88 58 #if !defined (__STRICT_ANSI__) && !defined (_POSIX_SOURCE) 89 59 90 int (toascii)(int); 91 int (isascii)(int); 60 static inline int isascii (int _c) 61 { return (unsigned)_c <= 0x7f; } 92 62 93 #define isascii(c) ((unsigned)(c) <= 0x7f)94 #define toascii(c) ((c) & 0x7f) 63 static inline int toascii (int _c) 64 { return _c & 0x7f; } 95 65 96 66 #endif 97 98 67 99 68 #if defined (__cplusplus) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/emx/syscalls.h
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r493 r494 179 179 int __mkdir (__const__ char *name); 180 180 int __newthread (int tid); 181 int __nls_ctype (unsigned char *buf);182 void __nls_memupr (unsigned char *buf, size_t size);183 181 int __open (__const__ char *name, int flags, unsigned long size); 184 182 int __pause (void); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/emx/thread.h
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r493 r494 37 37 unsigned int _th_rand; /* Used by rand() */ 38 38 void * _th_store; /* Pointer to user data */ 39 int _th_mblen_shift; /* Shift state for mblen() */40 int _th_mbtowc_shift; /* Shift state for mbtowc() */41 int _th_wctomb_shift; /* Shift state for wctomb() */42 39 char _th_vollabel[12]; /* Used by _getvol() */ 43 40 char _th_error[28]; /* Used by strerror() */ … … 46 43 char _th_ttyname[32]; /* Used by ttyname() */ 47 44 char _th_inetntoa[16]; /* Used by inetntoa() */ 48 int _th_reserved[97 1]; /* 4096 bytes, total */45 int _th_reserved[974]; /* 4096 bytes, total */ 49 46 }; 50 47 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/locale.h
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r493 r494 1 /* locale.h (emx+gcc) */ 1 /* 2 Locale support implementation through OS/2 Unicode API. 3 Copyright (c) 2003 InnoTek Systemberatung GmbH 4 5 For conditions of distribution and use, see the file COPYING. 6 7 POSIX locale implementation. 8 */ 2 9 3 10 #ifndef _LOCALE_H … … 8 15 #endif 9 16 10 #if !defined (NULL) 11 #if defined (__cplusplus) 12 #define NULL 0 13 #else 14 #define NULL ((void *)0) 15 #endif 16 #endif 17 /* lconv and categories */ 18 #include <sys/locale.h> 17 19 18 #define LC_ALL 0 19 #define LC_COLLATE 1 20 #define LC_CTYPE 2 21 #define LC_MONETARY 3 22 #define LC_NUMERIC 4 23 #define LC_TIME 5 24 25 #define LC_C "C" 26 #define LC_C_FRANCE "FRAN" 27 #define LC_C_GERMANY "GERM" 28 #define LC_C_ITALY "ITAL" 29 #define LC_C_SPAIN "SPAI" 30 #define LC_C_UK "UK" 31 #define LC_C_USA "USA" 32 33 struct lconv 34 { 35 char *decimal_point; 36 char *thousands_sep; 37 char *grouping; 38 char *int_curr_symbol; 39 char *currency_symbol; 40 char *mon_decimal_point; 41 char *mon_thousands_sep; 42 char *mon_grouping; 43 char *positive_sign; 44 char *negative_sign; 45 char int_frac_digits; 46 char frac_digits; 47 char p_cs_precedes; 48 char p_sep_by_space; 49 char n_cs_precedes; 50 char n_sep_by_space; 51 char p_sign_posn; 52 char n_sign_posn; 53 }; 54 55 56 char *setlocale (int, __const__ char *); 57 58 struct lconv *_localeconv (int); 59 struct lconv *localeconv (void); 60 61 #if defined (__CHAR_UNSIGNED__) 62 #define localeconv() _localeconv (255) 63 #else 64 #define localeconv() _localeconv (127) 65 #endif 20 /* Set current locale, if __locale is not NULL. Returns previous locale. */ 21 extern char *setlocale (int category, __const__ char *locale); 22 /* Get information about current locale. */ 23 extern struct lconv *localeconv (void); 66 24 67 25 #if defined (__cplusplus) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/stdlib.h
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r493 r494 79 79 int (*)(__const__ void *, __const__ void *)); 80 80 div_t div (int, int); 81 ldiv_t ldiv (long, long); 81 82 void exit (int) __attribute__ ((__noreturn__)); 82 83 char *getenv (__const__ char *); 83 ldiv_t ldiv (long, long);84 84 int mblen (__const__ char *, size_t); 85 85 size_t mbstowcs (wchar_t *, __const__ char *, size_t); … … 149 149 extern char **environ; 150 150 151 extern __const__ char * __const__ sys_errlist[];152 extern __const__ int sys_nerr;153 154 151 extern __const__ unsigned char _osminor; 155 152 extern __const__ unsigned char _osmajor; … … 159 156 160 157 unsigned alarm (unsigned); 161 int 158 int brk(const void *); 162 159 int chdir (__const__ char *); 163 160 char *gcvt (double, int, char *); … … 169 166 int putenv (__const__ char *); 170 167 int rmdir (__const__ char *); 171 void 168 void *sbrk(intptr_t); 172 169 unsigned sleep (unsigned); 173 170 void swab (__const__ void *, void *, size_t); … … 181 178 void srandom (unsigned); /* BSD */ 182 179 180 char *itoa (int, char *, int); 181 char *ltoa (long, char *, int); 182 char *ultoa (unsigned long, char *, int); 183 char *lltoa (long long, char *, int); 184 char *ulltoa (unsigned long long, char *, int); 185 183 186 #endif 184 187 … … 188 191 189 192 extern char **_environ; 190 extern __const__ char * __const__ _sys_errlist[];191 extern __const__ int _sys_nerr;192 193 193 194 unsigned _alarm (unsigned); 194 int 195 int _brk(const void *); 195 196 int _chdir (__const__ char *); 196 197 char *_gcvt (double, int, char *); … … 201 202 int _putenv (__const__ char *); 202 203 int _rmdir (__const__ char *); 203 void 204 void *_sbrk(intptr_t); 204 205 unsigned _sleep (unsigned); 205 206 void _swab (__const__ void *, void *, size_t); … … 217 218 void _exit (int) __attribute__ ((__noreturn__)); 218 219 int _filesys (__const__ char *, char *, size_t); 219 int _fncmp (__const__ unsigned char *, __const__ unsigned char *);220 220 char **_fnexplode (__const__ char *); 221 221 void _fnexplodefree (char **); … … 239 239 _lldiv_t _lldiv (long long, long long); 240 240 char *_lltoa (long long, char *, int); 241 _uldiv_t _uldiv (unsigned long, unsigned long); 242 _ulldiv_t _ulldiv (unsigned long long, unsigned long long); 243 char *_itoa (int, char *, int); 241 244 char *_ltoa (long, char *, int); 245 char *_ultoa (unsigned long, char *, int); 246 char *_lltoa (long long, char *, int); 247 char *_ulltoa (unsigned long long, char *, int); 242 248 void _makepath (char *, __const__ char *, __const__ char *, 243 249 __const__ char *, __const__ char *); … … 258 264 unsigned long long _strtoull (__const__ char *, char **, int); 259 265 char _swchar (void); 260 _uldiv_t _uldiv (unsigned long, unsigned long);261 _ulldiv_t _ulldiv (unsigned long long, unsigned long long);262 char *_ulltoa (unsigned long long, char *, int);263 char *_ultoa (unsigned long, char *, int);264 266 void _wildcard (int *, char ***); 265 267 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/sys/errno.h
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r493 r494 47 47 #define _SYS_ERRNO_H /* bird: emx */ 48 48 49 #if !defined(_KERNEL) && !defined(__ASSEMBLER__) && !defined(_ERRNO) /* bird: emx */ 50 #include <sys/cdefs.h> 51 __BEGIN_DECLS 52 #define _ERRNO /* bird: emx */ 53 extern int * _errno(void); /* bird: emx */ 54 __END_DECLS 55 #define errno (* _errno()) /* bird: emx */ 49 #if !defined (_ERRNO) && !defined (__ASSEMBLER__) 50 #define _ERRNO 51 extern int *_errno (void); 52 #define errno (*_errno ()) 53 #endif 54 55 #ifndef __ASSEMBLER__ 56 extern __const__ char * __const__ sys_errlist[]; 57 extern __const__ int sys_nerr; 56 58 #endif 57 59 … … 189 191 #endif /* _POSIX_SOURCE */ 190 192 191 #ifdef _KERNEL192 /* pseudo-errors returned inside kernel to modify return to process */193 #define ERESTART (-1) /* restart syscall */194 #define EJUSTRETURN (-2) /* don't modify regs, just return */195 #define ENOIOCTL (-3) /* ioctl not handled by this layer */196 #define EDIRIOCTL (-4) /* do direct ioctl in GEOM */197 193 #endif 198 199 #endif -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/sys/param.h
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r493 r494 180 180 #endif 181 181 182 #if defined (__cplusplus) && (__GNUC__ >= 2) 183 # define MIN(a,b) (((a)<?(b)) 184 #else 185 # define MIN(a,b) (((a)<(b))?(a):(b)) 186 #endif 187 #if defined (__cplusplus) && (__GNUC__ >= 2) 188 # define MAX(a,b) (((a)>?(b)) 189 #else 190 # define MAX(a,b) (((a)>(b))?(a):(b)) 191 #endif 182 192 183 193 #if defined (__cplusplus) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/utils.h
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r493 r494 44 44 #endif 45 45 46 #ifndef MIN 47 #define MIN(a,b) (((a)<(b))?(a):(b)) 48 #define imin(x,y) MIN((x),(y)) 49 #define MAX(a,b) (((a)>(b))?(a):(b)) 50 #endif 51 #ifndef min 52 #define min(a,b) (((a)<(b))?(a):(b)) 53 #endif 46 /* MIN/MAX */ 47 #include <sys/param.h> 54 48 /* timercmp */ 55 49 #include <sys/time.h> -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.