Changeset 1454
- Timestamp:
- Sep 4, 2004, 8:22:38 AM (21 years ago)
- Location:
- trunk/src/emx
- Files:
-
- 32 added
- 4 deleted
- 211 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/Makefile
-
Property cvs2svn:cvs-rev
changed from
1.47
to1.48
r1453 r1454 91 91 92 92 # The C compiler 93 CC = gcc -c -Zmt -fmessage-length= 15093 CC = gcc -c -Zmt -fmessage-length=0 94 94 # The C compiler flags 95 95 ifndef NO_LOCAL_HEADERS … … 118 118 # Linker flags 119 119 LDFLAGS = $(LDFLAGS.$(MODE)) $(LDFLAGS.KIND) -Zmap -Zstack 1024 -Zhigh-mem $(LIBS) 120 LDFLAGS.DLL = $(LDFLAGS) -Zdll 120 LDFLAGS.DLL = $(LDFLAGS) -Zdll -Zfork 121 121 # Linker flags for different build modes 122 122 LDFLAGS.opt = -g -Zcrtdll=c_dll … … 329 329 330 330 dep depend: 331 @$(MAKE) - -no-print-directory BUILD_DEPS=1 depdone331 @$(MAKE) -f $(MAKEFILE) --no-print-directory BUILD_DEPS=1 depdone 332 332 333 333 depdone: -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/386/builtin.h
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r1453 r1454 7 7 #define _I386_BUILTIN_H 8 8 9 #if defined (__cplusplus) 10 extern "C" { 11 #endif 9 #include <sys/cdefs.h> 10 #include <stdint.h> 11 12 __BEGIN_DECLS 13 12 14 13 15 static __inline__ signed char __cxchg (__volatile__ signed char *p, … … 40 42 } 41 43 44 45 /** 46 * Performs an atomical xchg on an unsigned int. 47 * @returns old value. 48 * @param pu Pointer to the value to update. 49 * @param u The new value. 50 */ 51 static __inline__ unsigned __atomic_xchg(__volatile__ unsigned *pu, unsigned u) 52 { 53 __asm__ __volatile__ ("xchgl %0, %1" : "=m" (*pu), "=r" (u) : "1" (u)); 54 return u; 55 } 56 57 /** 58 * Performs an atomical xchg on an 16-bit unsigned integer. 59 * 60 * @returns old value. 61 * @param pu16 Pointer to the value to update. 62 * @param u16 The new value. 63 */ 64 static inline uint16_t __atomic_xchg_word(volatile uint16_t *pu16, uint16_t u16) 65 { 66 __asm__ __volatile__ ("xchgw %0, %1" : "=m" (*pu16), "=r" (u16) : "1" (u16)); 67 return u16; 68 } 69 42 70 /** 43 71 * Atomically sets a bit and return the old one. 44 72 * 45 * @returns 1 if the b it was set, 0 if it was clear.73 * @returns 1 if the bwit was set, 0 if it was clear. 46 74 * @param pv Pointer to base of bitmap. 47 75 * @param uBit Bit in question. … … 89 117 "0" (uBit)); 90 118 return uBit; 119 } 120 121 122 /** 123 * Atomically add a 32-bit unsigned value to another. 124 * 125 * @param pu Pointer to the value to add to. 126 * @param uAdd The value to add to *pu. 127 */ 128 static __inline__ void __atomic_add(__volatile__ unsigned *pu, unsigned uAdd) 129 { 130 __asm__ __volatile__("lock addl %1, %0" 131 : "=m" (*pu) 132 : "r" (uAdd)); 133 } 134 135 /** 136 * Atomically subtract a 32-bit unsigned value from another. 137 * 138 * @param pu Pointer to the value to subtract from. 139 * @param uAdd The value to subtract from *pu. 140 */ 141 static __inline__ void __atomic_sub(__volatile__ unsigned *pu, unsigned uSub) 142 { 143 __asm__ __volatile__("lock subl %1, %0" 144 : "=m" (*pu) 145 : "r" (uSub)); 91 146 } 92 147 … … 148 203 149 204 /** 205 * Atomically increments a 16-bit unsigned value if less than max. 206 * 207 * @returns New value. 208 * @returns Current value | 0xffff0000 if current value is less or equal to u16Min. 209 * @param pu16 Pointer to the value to increment. 210 * @param u16Max *pu16 must not be above this value after the incrementation. 211 */ 212 static inline unsigned __atomic_increment_word_max(volatile uint16_t *pu16, uint16_t u16Max) 213 { 214 unsigned rc; 215 __asm__ __volatile__("movw (%1), %%ax\n\t" 216 "1:\n\t" 217 "movw %%ax, %%bx\n\t" 218 "cmpw %%dx, %%ax\n\t" 219 "jb 2f\n\t" 220 "orl $0xffff0000, %%ebx\n\t" 221 "jmp 3f\n" 222 "2:\n\t" 223 "incw %%bx\n\t" 224 "lock cmpxchgw %%bx, (%1)\n\t" 225 "jz 3f\n\t" 226 "jmp 1b\n\t" 227 "3:" 228 : "=b" (rc) 229 : "r" (pu16), 230 "d" (u16Max) 231 : "%eax"); 232 return rc; 233 } 234 235 236 /** 150 237 * Atomically decrements a 32-bit unsigned value if greater than a min. 151 238 * … … 180 267 181 268 269 /** 270 * Atomically decrements a 16-bit unsigned value if greater than a min. 271 * 272 * @returns New value. 273 * @returns Current value | 0xffff0000 if current value is less or equal to u16Min. 274 * @param pu16 Pointer to the value to decrement. 275 * @param u16Min *pu16 must not be below this value after the decrementation. 276 */ 277 static inline unsigned __atomic_decrement_word_min(volatile uint16_t *pu16, uint16_t u16Min) 278 { 279 unsigned rc; 280 __asm__ __volatile__("movw (%1), %%ax\n" 281 "1:\n\t" 282 "movw %%ax, %%bx\n\t" 283 "cmpw %%dx, %%ax\n\t" 284 "ja 2f\n\t" 285 "orl $0xffff0000, %%ebx\n\t" 286 "jmp 3f\n" 287 "2:\n\t" 288 "decw %%bx\n\t" 289 "lock cmpxchgw %%bx, (%1)\n\t" 290 "jz 3f\n\t" 291 "jmp 1b\n" 292 "3:" 293 : "=b" (rc) 294 : "r" (pu16), 295 "d" (u16Min) 296 : "%eax"); 297 return rc; 298 } 299 300 182 301 #define __ROTATE_FUN(F,I,T) \ 183 302 static __inline__ T F (T value, int shift) \ … … 356 475 } 357 476 358 #if defined (__cplusplus) 359 } 360 #endif 361 477 __END_DECLS 362 478 #endif /* not _I386_BUILTIN_H */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/InnoTekLIBC/logstrict.h
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1453 r1454 179 179 #define __LIBC_LOG_GRP_ENV 15 180 180 181 /** Shared Process Database and LIBC Shared Memory APIs. */ 182 #define __LIBC_LOG_GRP_SPM 24 183 /** Fork APIs. */ 184 #define __LIBC_LOG_GRP_FORK 25 181 185 /** Backend IO APIs. */ 182 186 #define __LIBC_LOG_GRP_BACK_IO 26 183 184 187 /** Init/Term APIs and Events. */ 185 188 #define __LIBC_LOG_GRP_INITTERM 27 … … 204 207 /** Posix thread APIs. */ 205 208 #define __LIBC_LOG_GRP_PTHREAD 36 209 /** Posix thread APIs. */ 210 #define __LIBC_LOG_GRP_DOSEX 37 206 211 207 212 /** @todo complete this */ 208 #define __LIBC_LOG_GRP_MAX 3 6213 #define __LIBC_LOG_GRP_MAX 37 209 214 /** @} */ 210 215 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/ctype.h
-
Property cvs2svn:cvs-rev
changed from
1.13
to1.14
r1453 r1454 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 */ 1 /* ctype.h,v 1.14 2004/09/04 06:22:16 bird Exp */ 2 /** @file 3 * 4 * InnoTek LIBC - Character type querying. 5 * 6 * Copyright (c) 2004 knut st. osmundsen <bird@innotek.de> 7 * 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with This program; if not, write to the Free Software 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * 23 */ 9 24 10 25 #ifndef _CTYPE_H_ … … 12 27 13 28 #include <sys/cdefs.h> 14 #include <sys/locale.h> 29 30 #if !defined(__InnoTekLIBC_locale_h__) 31 __BEGIN_DECLS 32 /** 33 * Simplified Ctype structure for inline functions. 34 */ 35 extern struct 36 { 37 /** All uppercased characters. */ 38 unsigned char auchUpper[256]; 39 /** All lowercased characters. */ 40 unsigned char auchLower[256]; 41 /** Bit flags for every character (for isXXX() function series). */ 42 unsigned short ausfType[256]; 43 } __libc_GLocaleCtype; 44 45 /** 46 * Simplified Default Ctype structure for inline functions. 47 */ 48 extern const struct 49 { 50 /** Bit flags for every character (for isXXX() function series). */ 51 unsigned short ausfType[256]; 52 } __libc_GLocaleCtypeDefault; 53 __END_DECLS 54 #endif /* !__InnoTekLIBC_locale_h__ */ 55 56 57 /** Bit masks for the ausfType member of __libc_GLocaleCtype 58 * and __libc_GLocaleCtypeDefault 59 * 60 * @remark These have identical values to the CT_* to speed up setlocale(). 61 * @{ 62 */ 63 #define __UPPER 0x0001 /** Upper case alphabetic character. */ 64 #define __LOWER 0x0002 /** Lower case alphabetic character. */ 65 #define __DIGIT 0x0004 /** Digits 0-9. */ 66 #define __SPACE 0x0008 /** White space and line ends. */ 67 #define __PUNCT 0x0010 /** Punctuation marks. */ 68 #define __CNTRL 0x0020 /** Control and format characters. */ 69 #define __BLANK 0x0040 /** Space and tab. */ 70 #define __XDIGIT 0x0080 /** Hex digits. */ 71 #define __ALPHA 0x0100 /** Letters and linguistic marks. */ 72 #define __ALNUM 0x0200 /** Alphanumeric. */ 73 #define __GRAPH 0x0400 /** All except controls and space. */ 74 #define __PRINT 0x0800 /** Everything except controls. */ 75 #define __NUMBER 0x1000 /** Integral number. */ 76 #define __SYMBOL 0x2000 /** Symbol. */ 77 #define __ASCII 0x8000 /** In standard ASCII set. */ 78 /** @} */ 79 15 80 16 81 __BEGIN_DECLS … … 51 116 #define isalpha(c) __istype((c), (__UPPER)|(__LOWER)) 52 117 #define iscntrl(c) __istype((c), (__CNTRL)) 53 #define isdigit(c) __istype((c), (__DIGIT))54 118 #define isgraph(c) __istype((c), (__PUNCT)|(__UPPER)|(__LOWER)|(__DIGIT)) 55 119 #define islower(c) __istype((c), (__LOWER)) … … 58 122 #define isspace(c) __istype((c), (__SPACE)) 59 123 #define isupper(c) __istype((c), (__UPPER)) 60 #define isxdigit(c) __istype((c), (__XDIGIT)) 124 #ifdef __UNIX_CHAR_CLASS__ 125 /* BSD and some other UNIXes have non-standard definitions of these two at least. */ 126 #define isdigit(c) __isctype((c),(__DIGIT)) 127 #define isxdigit(c) __isctype((c),(__XDIGIT)) 128 #else 129 #define isdigit(c) __istype((c),(__DIGIT)) 130 #define isxdigit(c) __istype((c),(__XDIGIT)) 131 #endif 132 #define tolower(c) __tolower(c) 61 133 #define toupper(c) __toupper(c) 62 #define tolower(c) __tolower(c)63 134 64 135 #if __XSI_VISIBLE … … 81 152 __BEGIN_DECLS 82 153 static inline int __istype(int _c, unsigned _f) 83 { return __locale_ctype.cflags [_c & 0xff] & (_f); } 154 { return (__libc_GLocaleCtype.ausfType[_c & 0xff] & (_f)) != 0; } 155 static inline int __isctype(int _c, unsigned _f) 156 { return (__libc_GLocaleCtypeDefault.ausfType[_c & 0xff] & (_f)) != 0; } 84 157 static inline int __toupper(int _c) 85 { return __l ocale_ctype.upcase[_c & 0xff]; }158 { return __libc_GLocaleCtype.auchUpper[_c & 0xff]; } 86 159 static inline int __tolower(int _c) 87 { return __l ocale_ctype.locase[_c & 0xff]; }160 { return __libc_GLocaleCtype.auchLower[_c & 0xff]; } 88 161 __END_DECLS 89 162 … … 92 165 __BEGIN_DECLS 93 166 int __istype(int, unsigned); 167 int __isctype(int, unsigned); 94 168 int __toupper(int); 95 169 int __tolower(int); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/emx/asm386.h
-
Property cvs2svn:cvs-rev
changed from
1.8
to1.9
r1453 r1454 39 39 #define LABEL(name) LABEL0(name) 40 40 41 #define ALIGN .align 2, 0x9041 #define ALIGN .align 4, 0x90 42 42 43 43 #define SET_ERRNO_CONST(x) \ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/emx/io.h
-
Property cvs2svn:cvs-rev
changed from
1.8
to1.9
r1453 r1454 4 4 #define _EMX_IO_H 5 5 6 #if defined (__cplusplus) 7 extern "C" { 8 #endif 9 6 #include <sys/cdefs.h> 10 7 #include <sys/types.h> 8 #include <InnoTekLIBC/fork.h> 9 10 __BEGIN_DECLS 11 11 12 12 #if !defined (NULL) … … 19 19 20 20 /** @defgroup libc_ioflags Low Level I/O Flags 21 * 21 22 * These low level I/O flags are kept in the fFlags member of the LIBCFH 22 23 * structure. The O_* flags are defined in sys/fcntl.h, the F_* flags are 23 * internal to LIBC and defined in emx/io.h. 24 * internal to LIBC and defined in emx/io.h (they should've been decorated 25 * with the usual prefix but it's already EMX legacy), and the FD_* flag(s) 26 * is(/are) defined 27 * 24 28 * @{ 25 29 */ … … 43 47 /* free 0x00004000 */ 44 48 /* O_NOCTTY 0x00008000 */ 45 #define F_EOF 0x01000000 46 #define F_TERMIO 0x02000000 47 #define F_WRCRPEND 0x04000000 48 #define F_CRLF 0x08000000 49 /** Filetype mask. */ 50 #define F_TYPEMASK 0xf0000000 49 #define F_EOF 0x00100000 50 #define F_TERMIO 0x00200000 51 #define F_WRCRPEND 0x00400000 52 #define F_CRLF 0x00800000 51 53 /** Type - Regular file. */ 52 #define F_FILE 0x 1000000054 #define F_FILE 0x01000000 53 55 /** Type - Characater device. */ 54 #define F_DEV 0x 2000000056 #define F_DEV 0x02000000 55 57 /** Type - Pipe. */ 56 #define F_PIPE 0x 3000000058 #define F_PIPE 0x03000000 57 59 /** Type - Socket. */ 58 #define F_SOCKET 0x40000000 60 #define F_SOCKET 0x04000000 61 /* FD_CLOEXEC 0x10000000 (when shifted) */ 62 /** The shift for the file descriptor part of __LIBC_FH::fFlags. */ 63 #define __LIBC_FH_FDFLAGS_SHIFT 28 64 65 /** File status/open flag mask. */ 66 #define __LIBC_FH_OFLAGS_MASK 0x00ffffff 67 /** File handle type mask. */ 68 #define __LIBC_FH_TYPEMASK 0x0f000000 69 /** File descriptor flags mask. */ 70 #define __LIBC_FH_FDFLAGS_MASK 0xf0000000 71 59 72 /** @} */ 60 73 … … 179 192 extern struct fdvec _fdvec_head; 180 193 181 #if defined (_SYS_ RMUTEX_H)194 #if defined (_SYS_FMUTEX_H) 182 195 183 196 /* This semaphore (defined in app/stdio.c) protects _streamv[]. Only … … 188 201 _newstream(), _setmore(), and freopen(). */ 189 202 190 extern _ rmutex _streamv_rmutex;191 192 #define STREAMV_LOCK _ rmutex_checked_request (&_streamv_rmutex, _FMR_IGNINT)193 #define STREAMV_UNLOCK _ rmutex_checked_release (&_streamv_rmutex)203 extern _fmutex _streamv_fmutex; 204 205 #define STREAMV_LOCK _fmutex_checked_request(&_streamv_fmutex, _FMR_IGNINT) 206 #define STREAMV_UNLOCK _fmutex_checked_release(&_streamv_fmutex) 194 207 195 208 #define STREAM_LOCK(f) \ 196 (_ rmutex_request (&(f)->__u.__rsem, _FMR_IGNINT) != 0 \209 (_fmutex_request(&(f)->__u.__fsem, _FMR_IGNINT) != 0 \ 197 210 ? abort () : (void)0) 198 211 199 212 #define STREAM_UNLOCK(f) \ 200 (_ rmutex_release (&(f)->__u.__rsem) != 0 ? abort() : (void)0)213 (_fmutex_release(&(f)->__u.__fsem) != 0 ? abort() : (void)0) 201 214 202 215 #define STREAM_LOCK_NOWAIT(f) \ 203 (_ rmutex_request (&(f)->__u.__rsem, _FMR_NOWAIT) == 0)204 205 #define STREAM_UNLOCKED(f) _ rmutex_available (&(f)->__u.__rsem)206 207 #endif /* defined (_SYS_ RMUTEX_H) */216 (_fmutex_request(&(f)->__u.__fsem, _FMR_NOWAIT) == 0) 217 218 #define STREAM_UNLOCKED(f) _fmutex_available(&(f)->__u.__fsem) 219 220 #endif /* defined (_SYS_FMUTEX_H) */ 208 221 209 222 struct __libc_FileHandle; 223 224 /** 225 * Filehandle type. 226 */ 227 typedef enum __libc_FileHandleType 228 { 229 /** Anything which is supported by the OS/2 file API. 230 * (not used at present as those handles doesn't need special ops). */ 231 enmFH_File, 232 /** Socket handle (BSD 4.3 stack). */ 233 enmFH_Socket43, 234 /** Socket handle (BSD 4.4 stack). */ 235 enmFH_Socket44 236 } __LIBC_FHTYPE; 210 237 211 238 /** … … 216 243 { 217 244 /** Handle type. */ 218 enum 219 { 220 /** Anything which is supported by the OS/2 file API. 221 * (not used at present as those handles doesn't need special ops). */ 222 enmFH_File, 223 /** Socket handle. */ 224 enmFH_Socket 225 } enmType; 226 245 __LIBC_FHTYPE enmType; 227 246 /** Close operation. 228 247 * @returns 0 on success. … … 269 288 * @param pFH Pointer to the handle structure to operate on. 270 289 * @param fh It's associated filehandle. 271 * @param i IOControl Which file file control operationto perform.290 * @param iRequest Which file file descriptior request to perform. 272 291 * @param iArg Argument which content is specific to each 273 * i IOControloperation.292 * iRequest operation. 274 293 * @param prc Where to store the value which upon success is 275 294 * returned to the caller. 276 295 */ 277 int (*pfnFileControl)(struct __libc_FileHandle *pFH, int fh, int i IOControl, int iArg, int *prc);296 int (*pfnFileControl)(struct __libc_FileHandle *pFH, int fh, int iRequest, int iArg, int *prc); 278 297 /** I/O Control operation. 279 298 * @returns 0 on success. … … 303 322 */ 304 323 int (*pfnSelect)(int cFHs, struct fd_set *pRead, struct fd_set *pWrite, struct fd_set *pExcept, struct timeval *tv, int *prc); 305 306 } LIBCFHOPS, *PLIBCFHOPS/*, const * PCLIBCFHOPS*/; 307 324 /** Fork notification - parent context. 325 * If NULL it's assumed that no notifiction is needed. 326 * 327 * @returns 0 on success. 328 * @returns OS/2 error code or negated errno on failure. 329 * @param pFH Pointer to the handle structure to operate on. 330 * @param fh It's associated filehandle. 331 * @param pForkHandle The fork handle. 332 * @param enmOperation The fork operation. 333 */ 334 int (*pfnForkParent)(struct __libc_FileHandle *pFH, int fh, __LIBC_PFORKHANDLE pForkHandle, __LIBC_FORKOP enmOperation); 335 /** Fork notification - child context. 336 * Only the __LIBC_FORK_OP_FORK_CHILD operation is forwarded atm. 337 * If NULL it's assumed that no notifiction is needed. 338 * 339 * @returns 0 on success. 340 * @returns OS/2 error code or negated errno on failure. 341 * @param pFH Pointer to the handle structure to operate on. 342 * @param fh It's associated filehandle. 343 * @param pForkHandle The fork handle. 344 * @param enmOperation The fork operation. 345 */ 346 int (*pfnForkChild)(struct __libc_FileHandle *pFH, int fh, __LIBC_PFORKHANDLE pForkHandle, __LIBC_FORKOP enmOperation); 347 348 } __LIBC_FHOPS; 349 /** Pointer to file handle operations. */ 350 typedef __LIBC_FHOPS *__LIBC_PFHOPS; 351 /** Pointer to const file handle operations. */ 352 typedef const __LIBC_FHOPS *__LIBC_PCFHOPS; 308 353 309 354 /** … … 313 358 { 314 359 /** Handle flags. 315 * Previously represented by _files / *fd_vec->flags.360 * See group @ref libc_ioflags in include/emx.h. 316 361 * @remark For thread safety update this atomically. */ 317 unsigned intfFlags;362 volatile unsigned int fFlags; 318 363 319 364 /** Lookahead. (whoever uses that?) 320 365 * Previously represented by _files / *fd_vec->flags. 321 366 * @remark For thread safety update this atomically. */ 322 intiLookAhead;367 volatile int iLookAhead; 323 368 324 369 /** Pointer to the operations one can perform on the handle. 325 370 * Only for special handles not supported by the OS/2 file API. */ 326 PLIBCFHOPS pOps; 327 328 } LIBCFH, *PLIBCFH; 371 __LIBC_PCFHOPS pOps; 372 373 } __LIBC_FH; 374 /** Pointer to filehandle. */ 375 typedef __LIBC_FH *__LIBC_PFH; 376 /* fixme!! */ 377 #define LIBCFH __LIBC_FH 378 #define PLIBCFH __LIBC_PFH 379 329 380 330 381 int __libc_FHEnsureHandles(int fh); 331 382 int __libc_FHMoreHandles(void); 332 int __libc_FHAllocate(int fh, unsigned fFlags, int cb, PLIBCFHOPS pOps, PLIBCFH *ppFH, int *pfh);383 int __libc_FHAllocate(int fh, unsigned fFlags, int cb, __LIBC_PCFHOPS pOps, PLIBCFH *ppFH, int *pfh); 333 384 int __libc_FHClose(int fh); 334 385 PLIBCFH __libc_FH(int fh); … … 359 410 360 411 361 #if defined (__cplusplus) 362 } 363 #endif 412 __END_DECLS 364 413 365 414 #endif /* not _EMX_IO_H */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/emx/locale.h
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 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 Internal header file. 8 */ 9 10 #ifndef _local_private_h_ 11 #define _local_private_h_ 12 13 #include <sys/types.h> 14 #include <uconv.h> 15 16 int __to_ucs (UconvObject uconv_obj, const unsigned char *sbcs, size_t len, 17 UniChar *ucs); 18 int __from_ucs (UconvObject uconv_obj, UniChar c, unsigned char *sbcs, 19 size_t len); 20 void __convert_codepage (const char *cp, UniChar *ucp); 21 void __do_Unicode (UconvObject *uconv, char *s, void *arg, 22 int (*xform) (UniChar *, void *)); 23 24 #endif 25 1 /* dead */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/emx/umalloc.h
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r1453 r1454 13 13 #include <sys/builtin.h> 14 14 #include <sys/fmutex.h> 15 #include <sys/rmutex.h>16 15 #include <sys/uflags.h> 17 16 … … 688 687 because the heap is probably not in a consistent state. */ 689 688 690 _ rmutex rsem;689 _fmutex fsem; 691 690 692 691 /* This member is used for various purposes by _uheapchk(): … … 756 755 void * __libc_HimemDefaultAlloc(Heap_t Heap, size_t *pcb, int *pfClean); 757 756 void __libc_HimemDefaultRelease(Heap_t Heap, void *pv, size_t cb); 757 #if 0 758 int __libc_HimemDefaultExpand(Heap_t Heap, void *pvBase, size_t cbOld, size_t *pcbNew, int *pfClean); 759 void __libc_HimemDefaultShrink(Heap_t Heap, void *pvBase, size_t cbOld, size_t *pcbNew); 760 #endif 758 761 int __libc_HasHighMem(void); 759 762 /** @} */ … … 773 776 static __inline__ void _um_heap_lock (Heap_t h) 774 777 { 775 _ rmutex_checked_request (&h->rsem, _FMR_IGNINT);778 _fmutex_checked_request (&h->fsem, _FMR_IGNINT); 776 779 } 777 780 … … 779 782 static __inline__ void _um_heap_unlock (Heap_t h) 780 783 { 781 _ rmutex_checked_release (&h->rsem);784 _fmutex_checked_release (&h->fsem); 782 785 } 783 786 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/locale.h
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 1 1 /* 2 Locale support implementation through OS/2 Unicode API. 3 Copyright (c) 2003 InnoTek Systemberatung GmbH 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. All advertising materials mentioning features or use of this software 14 * must display the following acknowledgement: 15 * This product includes software developed by the University of 16 * California, Berkeley and its contributors. 17 * 4. Neither the name of the University nor the names of its contributors 18 * may be used to endorse or promote products derived from this software 19 * without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)locale.h 8.1 (Berkeley) 6/2/93 34 * $FreeBSD: src/include/locale.h,v 1.7 2002/10/09 09:19:27 tjr Exp $ 35 */ 4 36 5 For conditions of distribution and use, see the file COPYING. 37 /** @file 38 * FreeBSD 5.1 39 * @changed bird: removed unsupported values and added comments to lconv. 40 * @changed bird: Changed the LC_* values to match those unidef.h sets. 41 */ 6 42 7 POSIX locale implementation. 8 */ 43 #ifndef _LOCALE_H_ 44 #define _LOCALE_H_ 9 45 10 #ifndef _LOCALE_H 11 #define _LOCALE_H 46 struct lconv { 47 char *decimal_point; /** non-monetary decimal point */ 48 char *thousands_sep; /** non-monetary thousands separator */ 49 char *grouping; /** non-monetary size of grouping */ 50 char *int_curr_symbol; /** international currency symbol and separator */ 51 char *currency_symbol; /** local currency symbol */ 52 char *mon_decimal_point; /** monetary decimal point */ 53 char *mon_thousands_sep; /** monetary thousands separator */ 54 char *mon_grouping; /** monetary size of grouping */ 55 char *positive_sign; /** non-negative values sign */ 56 char *negative_sign; /** negative values sign */ 57 char int_frac_digits; /** number of fractional digits - int currency */ 58 char frac_digits; /** number of fractional digits - local currency */ 59 char p_cs_precedes; /** (non-neg curr sym) 1-precedes, 0-succeeds */ 60 char p_sep_by_space; /** (non-neg curr sym) 1-space, 0-no space */ 61 char n_cs_precedes; /** (neg curr sym) 1-precedes, 0-succeeds */ 62 char n_sep_by_space; /** (neg curr sym) 1-space, 0-no space */ 63 char p_sign_posn; /** positioning of non-negative monetary sign */ 64 char n_sign_posn; /** positioning of negative monetary sign */ 65 #if 0 /* bird: we don't have this information (it's C99 stuff btw). */ 66 char int_p_cs_precedes; 67 char int_n_cs_precedes; 68 char int_p_sep_by_space; 69 char int_n_sep_by_space; 70 char int_p_sign_posn; 71 char int_n_sign_posn; 72 #endif 73 }; 12 74 13 #if defined (__cplusplus)14 extern "C" { 75 #ifndef NULL 76 #define NULL 0 15 77 #endif 16 78 17 /* lconv and categories */ 18 #include <sys/locale.h> 79 #define LC_ALL (-1) /* bird: was 0 */ 80 #define LC_COLLATE 0 /* bird: was 1 */ 81 #define LC_CTYPE 1 /* bird: was 2 */ 82 #define LC_MONETARY 2 /* bird: was 3 */ 83 #define LC_NUMERIC 3 /* bird: was 4 */ 84 #define LC_TIME 4 /* bird: was 5 */ 85 #define LC_MESSAGES 5 /* bird: was 6 */ 19 86 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); 87 #define _LC_LAST 6 /* bird: was 7 */ /* marks end */ 24 88 25 #if defined (__cplusplus) 26 } 27 #endif 89 #include <sys/cdefs.h> 28 90 29 #endif /* not _LOCALE_H */ 91 __BEGIN_DECLS 92 struct lconv *localeconv(void); 93 char *setlocale(int, const char *); 94 __END_DECLS 95 96 #endif /* _LOCALE_H_ */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/os2emx.h
-
Property cvs2svn:cvs-rev
changed from
1.17
to1.18
r1453 r1454 1416 1416 1417 1417 1418 #if 0 /* -pedantic generates annoying warnings here */ 1418 1419 typedef struct _FTIME 1419 1420 { … … 1422 1423 USHORT hours : 5; 1423 1424 } FTIME; 1425 #else 1426 typedef struct _FTIME 1427 { 1428 unsigned twosecs : 5; 1429 unsigned minutes : 6; 1430 unsigned hours : 5; 1431 } FTIME; 1432 #endif 1424 1433 typedef FTIME *PFTIME; 1425 1434 1435 #if 0 /* -pedantic generates annoying warnings here */ 1426 1436 typedef struct _FDATE 1427 1437 { … … 1430 1440 USHORT year : 7; 1431 1441 } FDATE; 1442 #else 1443 typedef struct _FDATE 1444 { 1445 unsigned day : 5; 1446 unsigned month : 4; 1447 unsigned year : 7; 1448 } FDATE; 1449 #endif 1432 1450 typedef FDATE *PFDATE; 1433 1451 … … 8068 8086 #define MLE_RGB 1 8069 8087 8088 #define MLE_INDEX 0 8089 #define MLE_RGB 1 8090 8070 8091 #define MLS_WORDWRAP 0x0001 8071 8092 #define MLS_BORDER 0x0002 … … 13315 13336 13316 13337 13338 #ifdef INCL_EXAPIS 13339 13340 /** Allocate memory at given location. */ 13341 #define OBJ_LOCATION 0x01000000 13342 /** The allocated memory object should be duplicated/opened in forked process. */ 13343 #define OBJ_FORK 0x02000000 13344 13345 /** 13346 * Extended DosAllocMem(). 13347 * 13348 * @returns See DosAllocMem(). 13349 * @param ppv Where to store the address of the allocated memory. 13350 * If OBJ_LOCATION is specified in the flFlags *ppv will be the 13351 * address the object must be allocated at. 13352 * @param cb Number of bytes to allocate. 13353 * @param flFlags Allocation flags. This API supports the same flags as DosAllocMem() 13354 * but adds OBJ_FORK and OBJ_LOCATION. 13355 * If OBJ_FORK is specified the object will be automatically 13356 * duplicated in the new process. 13357 * If OBJ_LOCATION is specified the object will be allocated 13358 * at the address specified by *ppv. 13359 * @remark The memory must be freed with DosFreeMemEx()! 13360 */ 13361 APIRET APIENTRY DosAllocMemEx(PPVOID ppv, ULONG cb, ULONG flFlags); 13362 13363 /** 13364 * Extended DosAllocSharedMem(). 13365 * 13366 * @returns See DosAllocSharedMem(). 13367 * @param ppv Where to store the address of the allocated memory. 13368 * @param pszName Name of the shared memory. (optional) 13369 * @param cb Number of bytes to allocate. 13370 * @param flFlags Allocation flags. This API supports the same flags as DosAllocSharedMem() 13371 * but adds OBJ_FORK. 13372 * If OBJ_FORK is specified the object will be automatically 13373 * be opened in a forked() process. 13374 * @remark The memory must be freed with DosFreeMemEx()! 13375 */ 13376 APIRET APIENTRY DosAllocSharedMemEx(PPVOID ppv, PCSZ pszName, ULONG cb, ULONG flFlags); 13377 13378 /** 13379 * Extended DosGetSharedMem(). 13380 * 13381 * @returns See DosGetSharedMem(). 13382 * @param pv The address of the shared memory. 13383 * @param flFlags Allocation flags. This API supports the same flags as DosGetSharedMem() 13384 * but adds OBJ_FORK. If OBJ_FORK is specified the object will 13385 * be automatically be opened in a forked() process. 13386 * @remark The memory must be freed with DosFreeMemEx()! 13387 */ 13388 APIRET APIENTRY DosGetSharedMemEx(PVOID pv, ULONG flFlags); 13389 13390 /** 13391 * Extended DosGetNamedSharedMem(). 13392 * 13393 * @returns See DosGetNamedSharedMem(). 13394 * @param pv The address of the shared memory. 13395 * @param flFlags Allocation flags. This API supports the same flags as DosGetNamedSharedMem() 13396 * but adds OBJ_FORK. If OBJ_FORK is specified the object will 13397 * be automatically be opened in a forked() process. 13398 * @remark The memory must be freed with DosFreeMemEx()! 13399 */ 13400 APIRET APIENTRY DosGetNamedSharedMemEx(PPVOID ppv, PCSZ pszName, ULONG flFlags); 13401 13402 /** 13403 * Free memory allocated by DosAllocMemEx. 13404 * 13405 * @returns See DosFreeMem(). 13406 * @param pv Address of the memory to free. 13407 */ 13408 APIRET APIENTRY DosFreeMemEx(PVOID pv); 13409 13410 /** 13411 * Extended DosCreateEventSem() which will make sure the created semaphore is 13412 * opened in a forked process with the same handle. 13413 */ 13414 APIRET APIENTRY DosCreateEventSemEx(PSZ pszName, PHEV phev, ULONG flAttr, BOOL32 fState); 13415 /** 13416 * Extended DosCreateMutexSem() which will make sure the created semaphore is 13417 * opened in a forked process with the same handle. 13418 */ 13419 APIRET APIENTRY DosCreateMutexSemEx(PSZ pszName, PHMTX phmtx, ULONG flAttr, BOOL32 fState); 13420 /** 13421 * Extended DosOpenEventSem() which will make sure the opened semaphore is 13422 * opened in a forked process with the same handle. 13423 */ 13424 APIRET APIENTRY DosOpenEventSemEx(PSZ pszName, PHEV phev); 13425 /** 13426 * Extended DosOpenMutexSem() which will make sure the opened semaphore is 13427 * opened in a forked process with the same handle. 13428 */ 13429 APIRET APIENTRY DosOpenMutexSemEx(PSZ pszName, PHMTX phmtx); 13430 /** 13431 * Close semaphore opened or created using the extended APIs. 13432 * @returns see DosCloseMutexSem(). 13433 * @param hmtx Handle to the mutex semaphore which is to be closed. 13434 */ 13435 APIRET APIENTRY DosCloseMutexSemEx(HMTX hmtx); 13436 /** 13437 * Close semaphore opened or created using the extended APIs. 13438 * @returns see DosCloseEventSem(). 13439 * @param hev Handle to the event semaphore which is to be closed. 13440 */ 13441 APIRET APIENTRY DosCloseEventSemEx(HEV hev); 13442 13443 #ifdef INCL_EXAPIS_MAPPINGS 13444 13445 #define DosAllocMem(a, b, c) DosAllocMemEx((a),(b),(c) | OBJ_FORK) 13446 #define DosAllocSharedMem(a,b,c,d) DosAllocSharedMemEx((a),(b),(c),(d) | OBJ_FORK) 13447 #define DosFreeMem(a) DosFreeMemEx((a)) 13448 13449 #define DosCreateMutexSem(a,b,c,d) DosCreateMutexSemEx((a),(b),(c),(d)) 13450 #define DosCreateEventSem(a,b,c,d) DosCreateEventSemEx((a),(b),(c),(d)) 13451 #define DosOpenMutexSem(a,b) DosOpenMutexSemEx((a),(b)) 13452 #define DosOpenEventSem(a,b) DosOpenEventSemEx((a),(b)) 13453 #define DosCloseMutexSem(a) DosCloseMutexSemEx((a)) 13454 #define DosCloseEventSem(a) DosCloseEventSemEx((a)) 13455 13456 #endif /* INCL_EXAPIS_MAPPINGS */ 13457 13458 13459 #endif /* INCL_EXAPIS */ 13460 13461 13317 13462 /* ------------------------------ THE END --------------------------------- */ 13318 13463 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/stdio.h
-
Property cvs2svn:cvs-rev
changed from
1.11
to1.12
r1453 r1454 197 197 union 198 198 { 199 #if defined (_SYS_ RMUTEX_H)200 _ rmutex __rsem;201 #endif 202 char __rsem_ersatz[ 16];199 #if defined (_SYS_FMUTEX_H) 200 _fmutex __fsem; 201 #endif 202 char __rsem_ersatz[8]; 203 203 } __u; 204 204 /** Pointer to the stream vector which thie FILE belongs to. -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/sys/fcntl.h
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1453 r1454 274 274 /* Open flags. 275 275 As stated in the FreeBSD part, there is supposidly a limited number of bits 276 available. We'll try keep in suitable for 16bit just in case (don't care to 277 check what we use right now). 276 available. We'll try keep it suitable for 16bit just in case (don't care to 277 check what we use right now) because that'll enable us to share a 32-bit flag 278 variable per handle to both status (O_*) flags and descriptor (FD_*) flags. 279 278 280 When we've disabled a few BSD flags and leave out KERNEL stuff the following 279 281 bits are available: -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/sys/locale.h
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1453 r1454 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 Private header file for locale support. 8 */ 9 10 #ifndef __SYS_LOCALE_H__ 11 #define __SYS_LOCALE_H__ 12 13 /* To avoid conflicts with unidef.h we should use same values as there. */ 14 #define LC_ALL (-1) 15 #define LC_COLLATE 0 16 #define LC_CTYPE 1 17 #define LC_NUMERIC 2 18 #define LC_MONETARY 3 19 #define LC_TIME 4 20 #define LC_MESSAGES 5 21 #define __LC_COUNT 6 22 23 /* Bit masks for __locale_global.ctype - 24 !NOTE! - these have identical values to the CT_* to speed up setlocale(). */ 25 #define __UPPER 0x0001 /* Upper case alphabetic character. */ 26 #define __LOWER 0x0002 /* Lower case alphabetic character. */ 27 #define __DIGIT 0x0004 /* Digits 0-9. */ 28 #define __SPACE 0x0008 /* White space and line ends. */ 29 #define __PUNCT 0x0010 /* Punctuation marks. */ 30 #define __CNTRL 0x0020 /* Control and format characters. */ 31 #define __BLANK 0x0040 /* Space and tab. */ 32 #define __XDIGIT 0x0080 /* Hex digits. */ 33 #define __ALPHA 0x0100 /* Letters and linguistic marks. */ 34 #define __ALNUM 0x0200 /* Alphanumeric. */ 35 #define __GRAPH 0x0400 /* All except controls and space. */ 36 #define __PRINT 0x0800 /* Everything except controls. */ 37 #define __NUMBER 0x1000 /* Integral number. */ 38 #define __SYMBOL 0x2000 /* Symbol. */ 39 #define __ASCII 0x8000 /* In standard ASCII set. */ 40 41 /* Locale information structure. */ 42 struct lconv 43 { 44 char *decimal_point; /* non-monetary decimal point */ 45 char *thousands_sep; /* non-monetary thousands separator */ 46 char *grouping; /* non-monetary size of grouping */ 47 char *int_curr_symbol; /* international currency symbol and separator */ 48 char *currency_symbol; /* local currency symbol */ 49 char *mon_decimal_point; /* monetary decimal point */ 50 char *mon_thousands_sep; /* monetary thousands separator */ 51 char *mon_grouping; /* monetary size of grouping */ 52 char *positive_sign; /* non-negative values sign */ 53 char *negative_sign; /* negative values sign */ 54 char int_frac_digits; /* number of fractional digits - int currency */ 55 char frac_digits; /* number of fractional digits - local currency */ 56 char p_cs_precedes; /* (non-neg curr sym) 1-precedes, 0-succeeds */ 57 char p_sep_by_space; /* (non-neg curr sym) 1-space, 0-no space */ 58 char n_cs_precedes; /* (neg curr sym) 1-precedes, 0-succeeds */ 59 char n_sep_by_space; /* (neg curr sym) 1-space, 0-no space */ 60 char p_sign_posn; /* positioning of non-negative monetary sign */ 61 char n_sign_posn; /* positioning of negative monetary sign */ 62 /** @todo C99 63 char int_n_cs_precedes 64 char int_n_sep_by_space 65 char int_n_sign_posn 66 char int_p_cs_precedes 67 char int_p_sep_by_space 68 char int_p_sign_posn 69 */ 70 }; 71 72 73 #ifdef __INTERNAL_DEFS 74 75 #include <uconv.h> 76 77 /* This structure keeps the time formatting rules. */ 78 struct __locale_time 79 { 80 char *smonths [12]; /* Short month names */ 81 char *lmonths [12]; /* Long month names */ 82 char *swdays [7]; /* Short weekday names */ 83 char *lwdays [7]; /* Long weekday names */ 84 char *date_time_fmt; /* Date and time format */ 85 char *date_fmt; /* Date format */ 86 char *time_fmt; /* Time format */ 87 char *am, *pm; /* AM and PM strings */ 88 }; 89 90 /* There is one global object of this type that contains integral 91 information about last selected (with setlocale()) locale. 92 The locale information itself is split into parts to avoid linking 93 unused data into programs that use just the "C" locale and just 94 a few functions that use locale data (such as strdate()). */ 95 struct __locale_global 96 { 97 /* Lock for multi-threaded operations. */ 98 signed char /* _smutex */ lock; /* Avoid including builtin.h & smutex.h */ 99 /* Category names. */ 100 char *name [__LC_COUNT + 1]; 101 }; 102 103 /* This structure contains the uppercase/lowercase tables. */ 104 struct __locale_ctype 105 { 106 /* Bit flags for every character (for isXXX() function series) */ 107 unsigned short cflags [256]; 108 /* All uppercased characters */ 109 unsigned char upcase [256]; 110 /* All lowercased characters */ 111 unsigned char locase [256]; 112 /* MBCS prefixes. Two bits per character. */ 113 unsigned char mbcsprefix [256/4]; 114 /* The converter object to convert to and from selected codepage 115 (used with MBCS codepages only) */ 116 UconvObject uconv; 117 /* The locale object. */ 118 LocaleObject locale; 119 /* Non-zero if there are any MBCS prefix characters in codepage */ 120 char mbcs; 121 }; 122 123 struct __locale_collate 124 { 125 /* Character weight for SBCS codepages */ 126 unsigned char weight [256]; 127 /* MBCS prefixes. Two bits per character. */ 128 unsigned char mbcsprefix [256/4]; 129 /* The converter object to convert to and from selected codepage 130 (used with MBCS codepages only) */ 131 UconvObject uconv; 132 /* The locale object. */ 133 LocaleObject locale; 134 /* Non-zero if there are any MBCS prefix characters in codepage */ 135 char mbcs; 136 }; 137 138 /* Handy macros for working with (__locale_ctype|__locale_collate).mbcsprefix */ 139 #define SET_MBCS_PREFIX(s,c,v) \ 140 s [((unsigned char)c) >> 2] |= (v) << (2 * ((c) & 3)) 141 #define LEN_MBCS_PREFIX(s,c) \ 142 ((s [((unsigned char)c) >> 2] >> (2 * ((c & 3) ^ 3))) & 3) 143 #define IS_MBCS_PREFIX(s,c) \ 144 (LEN_MBCS_PREFIX(s.mbcsprefix,c) != 1) 145 #define CHK_MBCS_PREFIX(s,c,v) \ 146 ((v = LEN_MBCS_PREFIX(s.mbcsprefix,c)) > 1) 147 148 /* A static constant string denoting the "C" locale. */ 149 extern const char __locale_C[2]; 150 151 /* Global locale information. */ 152 extern struct __locale_global __locale; 153 /* String collation information. */ 154 extern struct __locale_collate __locale_collate; 155 /* Character case conversion tables. */ 156 extern struct __locale_ctype __locale_ctype; 157 /* Locale information structure. */ 158 extern struct lconv __locale_lconv; 159 /* Date / time formatting rules. */ 160 extern struct __locale_time __locale_time; 161 162 /* Convert a string to Unicode, apply some transform and convert back. */ 163 extern void __do_Unicode (UconvObject *uconv, char *s, void *arg, 164 int (*xform) (UniChar *, void *)); 165 /* Convert a MBCS character to Unicode; returns number of bytes in MBCS char. */ 166 extern int __to_ucs (UconvObject, const unsigned char *, size_t, UniChar *); 167 /* Convert a Unicode character to MBCS */ 168 extern int __from_ucs (UconvObject, UniChar, unsigned char *, size_t); 169 170 #else 171 172 /* Simplified extern definitions for inline functions usage */ 173 174 /* Character case conversion tables. */ 175 extern struct 176 { 177 unsigned short cflags [256]; 178 unsigned char upcase [256]; 179 unsigned char locase [256]; 180 } __locale_ctype; 181 182 #endif /* __INTERNAL_DEFS */ 183 184 #endif /* __SYS_LOCALE_H__ */ 1 /* dead */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/sys/resource.h
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r1453 r1454 1 /* sys/resource.h (emx+gcc) */ 1 /* 2 * Copyright (c) 1982, 1986, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. All advertising materials mentioning features or use of this software 14 * must display the following acknowledgement: 15 * This product includes software developed by the University of 16 * California, Berkeley and its contributors. 17 * 4. Neither the name of the University nor the names of its contributors 18 * may be used to endorse or promote products derived from this software 19 * without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)resource.h 8.4 (Berkeley) 1/9/95 34 * $FreeBSD: src/sys/sys/resource.h,v 1.19 2003/02/16 13:30:29 phk Exp $ 35 */ 36 37 /** @file 38 * FreeBSD 5.1 39 */ 40 41 #ifndef _SYS_RESOURCE_H_ 42 #define _SYS_RESOURCE_H_ 43 44 /* 45 * Process priority specifications to get/setpriority. 46 */ 47 #define PRIO_MIN -20 48 #define PRIO_MAX 20 49 #ifdef _KERNEL 50 #define PRIO_TOTAL (PRIO_MAX - PRIO_MIN) 51 #endif /* _KERNEL */ 52 53 #define PRIO_PROCESS 0 54 #define PRIO_PGRP 1 55 #define PRIO_USER 2 56 57 /* 58 * Resource utilization information. 59 */ 60 61 #define RUSAGE_SELF 0 62 #define RUSAGE_CHILDREN -1 63 64 struct rusage { 65 struct timeval ru_utime; /* user time used */ 66 struct timeval ru_stime; /* system time used */ 67 long ru_maxrss; /* max resident set size */ 68 #define ru_first ru_ixrss 69 long ru_ixrss; /* integral shared memory size */ 70 long ru_idrss; /* integral unshared data " */ 71 long ru_isrss; /* integral unshared stack " */ 72 long ru_minflt; /* page reclaims */ 73 long ru_majflt; /* page faults */ 74 long ru_nswap; /* swaps */ 75 long ru_inblock; /* block input operations */ 76 long ru_oublock; /* block output operations */ 77 long ru_msgsnd; /* messages sent */ 78 long ru_msgrcv; /* messages received */ 79 long ru_nsignals; /* signals received */ 80 long ru_nvcsw; /* voluntary context switches */ 81 long ru_nivcsw; /* involuntary " */ 82 #define ru_last ru_nivcsw 83 }; 84 85 /* 86 * Resource limits 87 */ 88 #define RLIMIT_CPU 0 /* cpu time in milliseconds */ 89 #define RLIMIT_FSIZE 1 /* maximum file size */ 90 #define RLIMIT_DATA 2 /* data size */ 91 #define RLIMIT_STACK 3 /* stack size */ 92 #define RLIMIT_CORE 4 /* core file size */ 93 #define RLIMIT_RSS 5 /* resident set size */ 94 #define RLIMIT_MEMLOCK 6 /* locked-in-memory address space */ 95 #define RLIMIT_NPROC 7 /* number of processes */ 96 #define RLIMIT_NOFILE 8 /* number of open files */ 97 #define RLIMIT_SBSIZE 9 /* maximum size of all socket buffers */ 98 #define RLIMIT_VMEM 10 /* virtual process size (inclusive of mmap) */ 99 100 #define RLIM_NLIMITS 11 /* number of resource limits */ 101 102 #define RLIM_INFINITY ((rlim_t)(((u_quad_t)1 << 63) - 1)) 103 104 105 /* 106 * Resource limit string identifiers 107 */ 108 109 #ifdef _RLIMIT_IDENT 110 static char *rlimit_ident[] = { 111 "cpu", 112 "fsize", 113 "data", 114 "stack", 115 "core", 116 "rss", 117 "memlock", 118 "nproc", 119 "nofile", 120 "sbsize", 121 "vmem", 122 }; 123 #endif 124 125 struct orlimit { 126 int32_t rlim_cur; /* current (soft) limit */ 127 int32_t rlim_max; /* maximum value for rlim_cur */ 128 }; 129 130 struct rlimit { 131 rlim_t rlim_cur; /* current (soft) limit */ 132 rlim_t rlim_max; /* maximum value for rlim_cur */ 133 }; 134 135 /* Load average structure. */ 136 struct loadavg { 137 fixpt_t ldavg[3]; 138 long fscale; 139 }; 140 141 #define CP_USER 0 142 #define CP_NICE 1 143 #define CP_SYS 2 144 #define CP_INTR 3 145 #define CP_IDLE 4 146 #define CPUSTATES 5 147 148 #ifdef _KERNEL 149 extern struct loadavg averunnable; 150 extern long cp_time[CPUSTATES]; 151 152 int dosetrlimit(struct thread *, u_int, struct rlimit *); 153 154 #else 155 #include <sys/cdefs.h> 156 157 __BEGIN_DECLS 158 int getpriority(int, int); 159 int getrlimit(int, struct rlimit *); 160 int getrusage(int, struct rusage *); 161 int setpriority(int, int, int); 162 int setrlimit(int, const struct rlimit *); 163 __END_DECLS 164 165 #endif /* _KERNEL */ 166 #endif /* !_SYS_RESOURCE_H_ */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/sys/rmutex.h
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r1453 r1454 1 1 /* sys/rmutex.h (emx+gcc) */ 2 3 /* _rmutex semaphores are registered _fmutex semaphores. They are a4 bit bigger than _fmutex metaphores but they are inherited by child5 processes created with fork(). Shared _rmutex semaphores behave6 like _fmutex semaphores, ie, they are not registered and therefore7 not inherited by child processes created with fork(). (As malloc()8 uses _rmutex semaphores, we have to support shared semaphores9 anyway.) */10 2 11 3 /* This header requires <sys/builtin.h> and <sys/fmutex.h>. */ … … 14 6 #define _SYS_RMUTEX_H 15 7 16 #if defined (__cplusplus) 17 extern "C" { 18 #endif 8 #warning "_rmutex is obsoleted. use _fmutex!" 19 9 20 /* See also <emx/io.h> and /emx/test/internal.c. */ 21 typedef struct __rmutex 22 { 23 struct __rmutex *next; 24 struct __rmutex *prev; 25 _fmutex fm; 26 unsigned char flags; 27 unsigned short count; 28 } _rmutex; 10 #define _rmutex _fmutex 11 #define _rmutex_request _fmutex_request 12 #define _rmutex_release _fmutex_release 13 #define _rmutex_close _fmutex_close 14 #define _rmutex_create _fmutex_create 15 #define _rmutex_open _fmutex_open 16 #define _rmutex_available _fmutex_available 17 #define _rmutex_dummy _fmutex_dummy 18 #define _rmutex_checked_request _fmutex_checked_request 19 #define _rmutex_checked_release _fmutex_checked_release 20 #define _rmutex_checked_close _fmutex_checked_close 21 #define _rmutex_checked_create _fmutex_checked_create 22 #define _rmutex_checked_open _fmutex_checked_open 29 23 30 24 31 static __inline__ unsigned _rmutex_request (_rmutex *sem, unsigned flags)32 {33 return _fmutex_request (&sem->fm, flags);34 }35 36 37 static __inline__ unsigned _rmutex_release (_rmutex *sem)38 {39 return _fmutex_release (&sem->fm);40 }41 42 43 static __inline__ int _rmutex_available (_rmutex *sem)44 {45 return _fmutex_available (&sem->fm);46 }47 48 49 unsigned _rmutex_close (_rmutex *);50 unsigned _rmutex_create (_rmutex *, unsigned);51 unsigned _rmutex_open (_rmutex *);52 void _rmutex_dummy (_rmutex *);53 54 55 static __inline__ void _rmutex_checked_release (_rmutex *sem)56 {57 _fmutex_checked_release (&sem->fm);58 }59 60 61 static __inline__ void _rmutex_checked_request (_rmutex *sem, unsigned flags)62 {63 _fmutex_checked_request (&sem->fm, flags);64 }65 66 67 void _rmutex_checked_close (_rmutex *);68 void _rmutex_checked_create (_rmutex *, unsigned);69 void _rmutex_checked_open (_rmutex *);70 71 #if defined (__cplusplus)72 }73 #endif74 75 25 #endif /* not _SYS_RMUTEX_H */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/unistd.h
-
Property cvs2svn:cvs-rev
changed from
1.15
to1.16
r1453 r1454 183 183 int dup(int); 184 184 int dup2(int, int); 185 /** @todo int eaccess(const char *, int); */ 185 int eaccess(const char *, int); 186 186 int execl(const char *, const char *, ...); 187 187 int execle(const char *, const char *, ...); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/libonly.gmk
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1453 r1454 3 3 MAKEFILE := libonly.gmk 4 4 GENRULES = $.genrules-libonly.smak 5 SUBMAK := version.smak $(wildcard src/lib*/*.smak) include/include.smak \ 6 $(wildcard bsd/*/*.smak) $(wildcard gnu/*/*.smak) 5 SUBMAK := version.smak $(wildcard src/lib*/*.smak) include/include.smak 7 6 8 7 include Makefile -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/emxload/emxload.c
-
Property cvs2svn:cvs-rev
changed from
1.7
to1.8
r1453 r1454 19 19 Boston, MA 02111-1307, USA. */ 20 20 21 21 #define NO_EXAPIS 22 22 #include <stdio.h> 23 23 #include <stdlib.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/emxomf/emxomf.c
-
Property cvs2svn:cvs-rev
changed from
1.38
to1.39
r1453 r1454 90 90 int seg_name[3]; /* Name indices of the three segments */ 91 91 int seg_index[3]; /* Segment indices of the three segments */ 92 int group_name; /* Name index of the group */93 int group_index; /* Group index of the group */94 92 int def; /* Non-zero if head element encountered */ 95 93 int count; /* Number of non-head non-tail elements */ … … 245 243 static struct set *sets; 246 244 static struct set **set_add; 247 248 /* For compatibility with emxomf 0.8h and older, generation of GRPDEF249 records for sets can be enabled by using the -g option. That250 option sets this variable to TRUE. By default, GRPDEF records are251 not generated. */252 static int do_set_groups = FALSE;253 245 254 246 /* If this variable is TRUE, an a.out archive is split into several … … 2249 2241 set_ptr->seg_index[j] = -1; 2250 2242 } 2251 set_ptr->group_name = -1;2252 2243 set_ptr->count = 0; 2253 2244 set_ptr->data = NULL; … … 2294 2285 2295 2286 2296 /* Create the group name with group name index for each set. */2297 2298 static void define_set_groups (void)2299 {2300 struct set *set_ptr;2301 char tmp[512];2302 2303 for (set_ptr = sets; set_ptr != NULL; set_ptr = set_ptr->next)2304 {2305 strcpy (tmp, "GROUP");2306 strcat (tmp, set_ptr->name);2307 set_ptr->group_name = find_lname (tmp);2308 }2309 }2310 2311 2312 2287 /* Define three segments for each set. The segment names have already 2313 2288 been defined, now write the SEGDEF records. */ … … 2321 2296 for (j = 0; j < 3; ++j) 2322 2297 set_ptr->seg_index[j] = 2323 seg_def (set_ptr->seg_name[j], code_class_name,2298 seg_def (set_ptr->seg_name[j], data_class_name, 2324 2299 4 * (j == 1 ? set_ptr->count : set_ptr->def), FALSE, TRUE); 2325 }2326 2327 2328 /* Write the GRPDEF records for all the sets. One group consisting of2329 three segments is defined for each set.2330 2331 GRPDEF record:2332 1/2 Group name index2333 Ú2334 ³1 0xff (use segment index)2335 ³1/2 Segment index2336 À2337 2338 Group indices are assigned sequentially. */2339 2340 static void write_set_groups (void)2341 {2342 int j;2343 struct set *set_ptr;2344 2345 for (set_ptr = sets; set_ptr != NULL; set_ptr = set_ptr->next)2346 {2347 set_ptr->group_index = group_index++;2348 init_rec (GRPDEF);2349 put_idx (set_ptr->group_name);2350 for (j = 0; j < 3; ++j)2351 {2352 put_8 (0xff); put_idx (set_ptr->seg_index[j]);2353 }2354 write_rec ();2355 }2356 2300 } 2357 2301 … … 3478 3422 byte *t; 3479 3423 const struct nlist *entry_symbol; 3424 struct set *set_ptr; 3425 int j; 3480 3426 3481 3427 /* Simplify things by reading the complete a.out module into … … 3588 3534 flat_group_name = find_lname ("FLAT"); 3589 3535 dgroup_group_name = find_lname ("DGROUP"); 3590 if (do_set_groups)3591 define_set_groups ();3592 3536 3593 3537 /* Write the THREADR record. */ … … 3624 3568 text_index = seg_def (text_seg_name, code_class_name, text_size, 3625 3569 FALSE, FALSE); 3626 write_set_segs ();3627 3628 3570 if (udat_seg_string != NULL) 3629 3571 udat_index = seg_def (udat_seg_name, data_class_name, data_size, … … 3635 3577 udat_index = data_index; 3636 3578 3579 write_set_segs (); 3580 3637 3581 bss_index = seg_def (bss_seg_name, bss_class_name, a_out_h->a_bss, 3638 3582 FALSE, FALSE); … … 3651 3595 3652 3596 /* Define groups (GRPDEF records). This must be done after defining 3653 segments. */ 3597 segments. 3598 We lazily assumes that the number of sets will not make the GRPDEF 3599 record too big. Rather safe unless a hundred setvectors are used... */ 3654 3600 3655 3601 flat_index = group_index++; … … 3663 3609 put_8 (0xff); put_idx (bss_index); 3664 3610 put_8 (0xff); put_idx (data_index); 3611 for (set_ptr = sets; set_ptr != NULL; set_ptr = set_ptr->next) 3612 for (j = 0; j < 3; ++j) 3613 { 3614 put_8 (0xff); put_idx (set_ptr->seg_index[j]); 3615 } 3665 3616 write_rec (); 3666 3667 if (do_set_groups)3668 write_set_groups ();3669 3617 3670 3618 /* Process weak symbols */ … … 3754 3702 puts ("\nOptions:"); 3755 3703 puts (" -d Delete input files except for archives"); 3756 puts (" -g Create groups for sets");3757 3704 puts (" -i <default_lib> Add default library request"); 3758 3705 puts (" -l[<symbol>] Convert library modules, with optional entrypoint"); … … 4190 4137 /* Parse the command line options. */ 4191 4138 4192 while ((c = getopt (argc, argv, "bdD: gh:i:jI:m:l::o:P:p:qO:r:R:tsuxwz")) != EOF)4139 while ((c = getopt (argc, argv, "bdD:h:i:jI:m:l::o:P:p:qO:r:R:tsuxwz")) != EOF) 4193 4140 switch (c) 4194 4141 { … … 4201 4148 case 'D': 4202 4149 udat_seg_string = optarg; 4203 break;4204 case 'g':4205 do_set_groups = TRUE;4206 4150 break; 4207 4151 case 'h': -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/app/stdio.c
-
Property cvs2svn:cvs-rev
changed from
1.9
to1.10
r1453 r1454 4 4 #include "libc-alias.h" 5 5 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 6 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 7 #include <sys/rmutex.h> 6 #include <sys/fmutex.h> 8 7 #include <stdio.h> 9 8 #include <stdlib.h> … … 28 27 29 28 /** Mutex protecting the stream vector. */ 30 _ rmutex _streamv_rmutex; /* See io/_newstre.c */29 _fmutex _streamv_fmutex; /* See io/_newstre.c */ 31 30 32 31 /* … … 69 68 70 69 /* 71 * Init the _more and _owner pointers.70 * Init the stream vector back pointer. 72 71 */ 73 72 pFile = &gaPreFiles[0]; … … 81 80 _streamvec_head = &gPreStreamVec; 82 81 _streamvec_tail = &gPreStreamVec; 83 _ rmutex_checked_create(&_streamv_rmutex, 0);82 _fmutex_checked_create(&_streamv_fmutex, 0); 84 83 85 84 /* … … 100 99 gaPreFiles[i]._handle = i; 101 100 gaPreFiles[i]._flush = _flushstream; 102 if (_ rmutex_create (&gaPreFiles[i].__u.__rsem, 0) != 0)101 if (_fmutex_create(&gaPreFiles[i].__u.__fsem, 0) != 0) 103 102 { 104 103 LIBC_ASSERTM_FAILED("_setmore failed for i=%d\n", i); … … 117 116 gaPreFiles[0]._buffer = gachStdIn; 118 117 gaPreFiles[0]._buf_size = BUFSIZ; 119 LIBCLOG_MSG("__stdinp=%p\n", __stdinp);118 LIBCLOG_MSG("__stdinp=%p\n", (void *)__stdinp); 120 119 break; 121 120 … … 123 122 /* stdout is buffered unless it's connected to a device. */ 124 123 gaPreFiles[1]._flags |= _IOWRT | _IOBUFNONE 125 | ((pFH->fFlags & F_TYPEMASK) == F_DEV ? _IONBF : _IOFBF);126 LIBCLOG_MSG("__stdoutp=%p flags=%#x (%s)\n", __stdoutp, gaPreFiles[1]._flags,127 (pFH->fFlags & F_TYPEMASK) == F_DEV ? "dev" : "none-dev");124 | ((pFH->fFlags & __LIBC_FH_TYPEMASK) == F_DEV ? _IONBF : _IOFBF); 125 LIBCLOG_MSG("__stdoutp=%p flags=%#x (%s)\n", (void *)__stdoutp, gaPreFiles[1]._flags, 126 (pFH->fFlags & __LIBC_FH_TYPEMASK) == F_DEV ? "dev" : "none-dev"); 128 127 break; 129 128 … … 131 130 /* stderr is always unbuffered. */ 132 131 gaPreFiles[2]._flags |= _IOWRT | _IOBUFNONE | _IONBF; 133 LIBCLOG_MSG("__stderrp=%p\n", __stderrp);132 LIBCLOG_MSG("__stderrp=%p\n", (void *)__stderrp); 134 133 break; 135 134 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/conv/atod.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 1 1 /* atod.c (emx+gcc) -- Copyright (c) 1996-1998 by Eberhard Mattes */ 2 2 3 #define __INTERNAL_DEFS4 3 #include "libc-alias.h" 5 4 #include <stdlib.h> 6 #include <ctype.h>7 5 #include <math.h> 8 6 #include <float.h> … … 12 10 #include <emx/bigint.h> 13 11 #include <emx/float.h> 14 #include <sys/locale.h> 12 #include <InnoTekLIBC/locale.h> 13 #include <ctype.h> 14 15 15 16 16 #define BBITS (LDBL_MAX_EXP + LDBL_MANT_DIG - LDBL_MAX_10_EXP \ … … 22 22 #define MAX2 (_BI_WORDMAX - 10 * MAX1) 23 23 24 #define DOT (unsigned char)__l ocale_lconv.decimal_point[0]24 #define DOT (unsigned char)__libc_gLocaleLconv.s.decimal_point[0] 25 25 26 26 const char * __atod (long double *p_result, const char *string, -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/conv/conv.smak
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1453 r1454 34 34 .TCF.src/lib/conv/bipow5.c := -I$. 35 35 $(call .MVER,conv/bipow5.o): $.bipow5.tab 36 src/lib/conv/bipow5.c: $.bipow5.tab 36 37 $.bipow5.tab: $.makepow5.exe 37 38 $< -o $@ -s -m325 4951 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/conv/gcvt.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 1 1 /* gcvt.c (emx+gcc) -- Copyright (c) 1994-1996 by Eberhard Mattes */ 2 2 3 #define __INTERNAL_DEFS4 3 #include "libc-alias.h" 5 4 #include <stdlib.h> … … 9 8 #include <locale.h> 10 9 #include <emx/float.h> 11 #include < sys/locale.h>10 #include <InnoTekLIBC/locale.h> 12 11 13 12 char *_STD(gcvt) (double x, int digits, char *buffer) … … 82 81 *dst++ = str[0]; 83 82 if (str[1] != 0) 84 *dst++ = __l ocale_lconv.decimal_point[0];83 *dst++ = __libc_gLocaleLconv.s.decimal_point[0]; 85 84 for (src = str+1; *src != 0; ++src) 86 85 *dst++ = *src; … … 112 111 { 113 112 if (i == xp + 1) 114 *dst++ = __l ocale_lconv.decimal_point[0];113 *dst++ = __libc_gLocaleLconv.s.decimal_point[0]; 115 114 *dst++ = str[i]; 116 115 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/conv/smalatod.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1453 r1454 1 1 /* smalatod.c (emx+gcc) -- Copyright (c) 1990-1996 by Eberhard Mattes */ 2 2 3 #define __INTERNAL_DEFS4 3 #include "libc-alias.h" 5 4 #include <stdlib.h> … … 7 6 #include <float.h> 8 7 #include <locale.h> 9 #include <ctype.h>10 8 #include <errno.h> 11 9 #define __atod __small_atod /* bird: let's get a prototype. */ 12 10 #include <emx/float.h> 13 #include <sys/locale.h> 11 #include <InnoTekLIBC/locale.h> 12 #include <ctype.h> 14 13 15 14 … … 34 33 } z; 35 34 36 s = end = string;35 s = end = (unsigned char *)string; 37 36 38 37 switch (mant_dig) … … 49 48 default: 50 49 *p_result = NAN; 51 return string;50 return (const char *)string; 52 51 } 53 52 … … 74 73 s += 5; 75 74 *p_result = neg ? -INFINITY : INFINITY; 76 return s;75 return (const char *)s; 77 76 } 78 77 else if ((s[0] == 'n' || s[0] == 'N') … … 95 94 } 96 95 *p_result = NAN; 97 return end;96 return (const char *)end; 98 97 } 99 98 … … 104 103 for (;;) 105 104 { 106 if (*s == (unsigned char)__l ocale_lconv.decimal_point[0] && !dot)105 if (*s == (unsigned char)__libc_gLocaleLconv.s.decimal_point[0] && !dot) 107 106 { 108 107 dot = 1; … … 127 126 { 128 127 *p_result = 0.0; 129 return string;128 return (const char *)string; 130 129 } 131 130 … … 151 150 152 151 saved_errno = errno; errno = 0; 153 exp = strtol ( s, (char **)&q, 10);152 exp = strtol ((const char *)s, (char **)&q, 10); 154 153 if (errno == ERANGE) 155 154 { … … 215 214 216 215 *p_result = neg ? -z.ld : z.ld; 217 return end;216 return (const char *)end; 218 217 219 218 overflow: 220 219 *p_result = neg ? -HUGE_VALL : HUGE_VALL; 221 220 errno = ERANGE; 222 return end;221 return (const char *)end; 223 222 224 223 underflow: 225 224 *p_result = neg ? -0.0 : 0.0; 226 225 errno = ERANGE; 227 return end;226 return (const char *)end; 228 227 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/_fbuf.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 17 17 { 18 18 PLIBCFH pFH = __libc_FH(stream->_handle); 19 if (pFH && ( (pFH->fFlags & F_TYPEMASK) == F_DEV20 || (pFH->fFlags & F_TYPEMASK) == F_SOCKET))19 if (pFH && ( (pFH->fFlags & __LIBC_FH_TYPEMASK) == F_DEV 20 || (pFH->fFlags & __LIBC_FH_TYPEMASK) == F_SOCKET)) 21 21 stream->_buffer = _lmalloc(BUFSIZ); 22 22 else -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/_fdinit.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1453 r1454 6 6 #include <emx/io.h> 7 7 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 8 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 9 #include <sys/rmutex.h> 8 #include <sys/fmutex.h> 10 9 #include <emx/startup.h> 11 10 … … 18 17 /* This semaphore protects a critical region in _fd_init(). */ 19 18 20 static _ rmutex _fdinit_rmutex;19 static _fmutex _fdinit_fmutex; 21 20 22 21 … … 27 26 void _init1_fdinit (void) 28 27 { 29 _ rmutex_checked_create (&_fdinit_rmutex, 0);28 _fmutex_checked_create (&_fdinit_fmutex, 0); 30 29 } 31 30 … … 82 81 /* Prevent other threads from updating last->next. */ 83 82 84 _ rmutex_checked_request (&_fdinit_rmutex, _FMR_IGNINT);83 _fmutex_checked_request (&_fdinit_fmutex, _FMR_IGNINT); 85 84 86 85 /* Now that we have locked other threads out of this critical … … 94 93 and therefore won't be changed by other threads. */ 95 94 96 _ rmutex_checked_release (&_fdinit_rmutex);95 _fmutex_checked_release (&_fdinit_fmutex); 97 96 98 97 /* If another thread updated last->next, back out and retry, -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/_fopen.c
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1453 r1454 6 6 #include <errno.h> 7 7 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 8 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 9 #include <sys/rmutex.h> 8 #include <sys/fmutex.h> 10 9 #include <stdio.h> 11 10 #include <emx/io.h> … … 80 79 dst->_flags |= _IOOPEN | _IOBUFNONE; 81 80 dst->_flush = _flushstream; 82 if (_ rmutex_create (&dst->__u.__rsem, 0) != 0)81 if (_fmutex_create (&dst->__u.__fsem, 0) != 0) 83 82 { 84 83 _closestream (dst); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/_input.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1453 r1454 1 1 /* _input.c (emx+gcc) -- Copyright (c) 1990-2000 by Eberhard Mattes */ 2 2 3 #define __INTERNAL_DEFS4 3 #include "libc-alias.h" 5 4 #include <stdio.h> … … 7 6 #include <stdarg.h> 8 7 #include <string.h> 9 #include <ctype.h>10 8 #include <limits.h> 11 9 #include <locale.h> 12 #include <sys/locale.h>13 10 #include <emx/io.h> 11 #include <InnoTekLIBC/locale.h> 12 #include <ctype.h> 14 13 #include "getputc.h" 15 14 … … 477 476 c = get (v); 478 477 } 479 if (c == (unsigned char)__l ocale_lconv.decimal_point[0])478 if (c == (unsigned char)__libc_gLocaleLconv.s.decimal_point[0]) 480 479 { 481 480 COLLECT (c); … … 597 596 unread." */ 598 597 599 if (!CHK_MBCS_PREFIX ( __locale_ctype, f, mbn))598 if (!CHK_MBCS_PREFIX (&__libc_GLocaleCtype, f, mbn)) 600 599 mbn = 1; 601 600 for (mbi = 0; mbi < mbn; ++mbi) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/_isterm.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1453 r1454 31 31 * (Hope that's correct interpretation of the __ioctl1() call...) 32 32 */ 33 return (pFH->fFlags & F_TYPEMASK) == F_DEV;33 return (pFH->fFlags & __LIBC_FH_TYPEMASK) == F_DEV; 34 34 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/_mfopen.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 5 5 #include <errno.h> 6 6 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 7 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 8 #include <sys/rmutex.h> 7 #include <sys/fmutex.h> 9 8 #include <stdio.h> 10 9 #include <emx/io.h> … … 89 88 stream->_tmpidx = inc; 90 89 stream->_ungetc_count = 0; 91 if (_ rmutex_create (&stream->__u.__rsem, 0) != 0)90 if (_fmutex_create (&stream->__u.__fsem, 0) != 0) 92 91 { 93 92 if (abuf != NULL) free (abuf); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/_newstre.c
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1453 r1454 5 5 #include <stdlib.h> 6 6 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 7 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 8 #include <sys/rmutex.h> 7 #include <sys/fmutex.h> 9 8 #include <stdio.h> 10 9 #include <emx/io.h> … … 105 104 stream->_flags = 0; 106 105 /* Assumption hare made about how the dummy stuff is made. */ 107 if (stream->__u.__ rsem.fm.hev)108 _ rmutex_close(&stream->__u.__rsem);106 if (stream->__u.__fsem.hev) 107 _fmutex_close(&stream->__u.__fsem); 109 108 110 109 if (stream->__pSV) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/_output.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1453 r1454 1 1 /* _output.c (emx+gcc) -- Copyright (c) 1990-2000 by Eberhard Mattes */ 2 2 3 #define __INTERNAL_DEFS4 3 #include "libc-alias.h" 5 4 #include <stdio.h> … … 13 12 #include <emx/io.h> 14 13 #include <emx/float.h> 15 #include < sys/locale.h>14 #include <InnoTekLIBC/locale.h> 16 15 #include "getputc.h" 17 16 … … 704 703 v.stream = stream; 705 704 v.count = 0; 706 zdot[1] = __l ocale_lconv.decimal_point[0];705 zdot[1] = __libc_gLocaleLconv.s.decimal_point[0]; 707 706 708 707 /* ANSI X3.159-1989, 4.9.6.1: "The format shall be a multibyte … … 723 722 Avoid the overhead of calling mblen(). */ 724 723 725 if (!CHK_MBCS_PREFIX ( __locale_ctype, c, mbn))724 if (!CHK_MBCS_PREFIX (&__libc_GLocaleCtype, c, mbn)) 726 725 mbn = 1; 727 726 while (mbn > 0) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/_rmtmp.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1453 r1454 3 3 #include "libc-alias.h" 4 4 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 5 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 6 #include <sys/rmutex.h> 5 #include <sys/fmutex.h> 7 6 #include <stdio.h> 8 7 #include <emx/io.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/_tempnam.c
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1453 r1454 3 3 4 4 #include "libc-alias.h" 5 #define __USE_GNU6 5 #include <stdio.h> 7 6 #include <stdlib.h> 7 #ifndef __USE_GNU /* __strnlen */ 8 # define __USE_GNU 9 #endif 8 10 #include <string.h> 9 11 #include <io.h> … … 75 77 _itoa (_tmpidx, p, 10); 76 78 strcat (p, ".tmp"); 77 memmove (p, prefix, strnlen (prefix, 5));79 memmove (p, prefix, __strnlen (prefix, 5)); 78 80 errno = 0; 79 81 if (access (tmpname, 0) != 0) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/_tmp.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 3 3 #include "libc-alias.h" 4 4 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 5 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 6 #include <sys/rmutex.h> 5 #include <sys/fmutex.h> 7 6 #include <emx/startup.h> 8 7 #include "_tmp.h" 9 8 9 10 /******************************************************************************* 11 * Global Variables * 12 *******************************************************************************/ 10 13 int _tmpidx = IDX_LO; 11 14 15 /** This semaphore protects _tmpidx. */ 16 static _fmutex _tmpidx_fmutex; 12 17 13 /* This semaphore protects _tmpidx. */ 14 15 static _rmutex _tmpidx_rmutex; 18 /******************************************************************************* 19 * Internal Functions * 20 *******************************************************************************/ 21 static void _init1_tmp(void); 16 22 17 23 18 /* Initialize the semaphore -- this function will be called by 24 _CRT_INIT1(_init1_tmp) 25 26 /** Initialize the semaphore -- this function will be called by 19 27 _CRT_init() via the __crtinit1__ set vector. */ 20 21 void _init1_tmp (void); 22 void _init1_tmp (void) 28 static void _init1_tmp(void) 23 29 { 24 _rmutex_checked_create (&_tmpidx_rmutex, 0); 30 static void *hack = (void *)_init1_tmp; 31 hack = hack; 32 _fmutex_checked_create(&_tmpidx_fmutex, 0); 25 33 } 26 34 27 _CRT_INIT1 (_init1_tmp)28 35 29 30 void _tmpidx_lock (void) 36 void _tmpidx_lock(void) 31 37 { 32 _rmutex_checked_request (&_tmpidx_rmutex, _FMR_IGNINT);38 _fmutex_checked_request(&_tmpidx_fmutex, _FMR_IGNINT); 33 39 } 34 40 35 void _tmpidx_unlock 41 void _tmpidx_unlock(void) 36 42 { 37 _rmutex_checked_release (&_tmpidx_rmutex);43 _fmutex_checked_release(&_tmpidx_fmutex); 38 44 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/_trslash.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 1 1 /* _trslash.c (emx+gcc) -- Copyright (c) 1996 by Eberhard Mattes */ 2 2 3 #define __INTERNAL_DEFS4 3 #include "libc-alias.h" 5 4 #include <emx/io.h> 6 #include < sys/locale.h>5 #include <InnoTekLIBC/locale.h> 7 6 8 7 /* Detect trailing slash or backslash for stat(), access(), and … … 60 59 for (;;) 61 60 { 62 if (CHK_MBCS_PREFIX ( __locale_ctype, name[i], mbcl))61 if (CHK_MBCS_PREFIX (&__libc_GLocaleCtype, name[i], mbcl)) 63 62 { 64 63 if (i == len - 1 - mbcl) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/_vsopen.c
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1453 r1454 126 126 * Check what we got a handle to. 127 127 */ 128 if ((fLibc & F_TYPEMASK) == F_DEV)128 if ((fLibc & __LIBC_FH_TYPEMASK) == F_DEV) 129 129 fOpen &= ~O_APPEND; 130 130 … … 132 132 * For text files we shall remove eventual ending Ctrl-Z. 133 133 */ 134 if ( (fLibc & F_TYPEMASK) != F_DEV134 if ( (fLibc & __LIBC_FH_TYPEMASK) != F_DEV 135 135 && (fLibc & O_TEXT)) 136 136 { … … 159 159 fFlags = (fFlags & ~O_ACCMODE) | (fOpen & O_ACCMODE); 160 160 fFlags &= ~_SO_EXCL; /* Ignore O_EXCL */ 161 hFile = __open(pszName, fFlags, cbInitial, fLibc & ~ F_TYPEMASK, &pFH);161 hFile = __open(pszName, fFlags, cbInitial, fLibc & ~__LIBC_FH_TYPEMASK, &pFH); 162 162 if (hFile < 0) 163 163 return -1; … … 168 168 * This is required for passing the file to a child process. 169 169 */ 170 if ( (fLibc & F_TYPEMASK) == F_FILE170 if ( (fLibc & __LIBC_FH_TYPEMASK) == F_FILE 171 171 && (fLibc & O_APPEND)) 172 172 __lseek(hFile, 0L, SEEK_END); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/fdopen.c
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r1453 r1454 6 6 #include <errno.h> 7 7 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 8 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 9 #include <sys/rmutex.h> 8 #include <sys/fmutex.h> 10 9 #include <stdio.h> 11 10 #include <stdio.h> … … 31 30 if (!dst) 32 31 return NULL; 33 if (_ rmutex_create (&dst->__u.__rsem, 0) != 0)32 if (_fmutex_create (&dst->__u.__fsem, 0) != 0) 34 33 { 35 34 _closestream (dst); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/fflush.c
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1453 r1454 3 3 #include "libc-alias.h" 4 4 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 5 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 6 #include <sys/rmutex.h> 5 #include <sys/fmutex.h> 7 6 #include <stdio.h> 8 7 #include <stdlib.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/fgetc.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 3 3 #include "libc-alias.h" 4 4 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 5 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 6 #include <sys/rmutex.h> 5 #include <sys/fmutex.h> 7 6 #include <stdio.h> 8 7 #include <stdlib.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/fgets.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 3 3 #include "libc-alias.h" 4 4 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 5 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 6 #include <sys/rmutex.h> 5 #include <sys/fmutex.h> 7 6 #include <stdio.h> 8 7 #include <stdlib.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/flushall.c
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1453 r1454 3 3 #include "libc-alias.h" 4 4 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 5 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 6 #include <sys/rmutex.h> 5 #include <sys/fmutex.h> 7 6 #include <stdio.h> 8 7 #include <stdlib.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/fprintf.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 3 3 #include "libc-alias.h" 4 4 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 5 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 6 #include <sys/rmutex.h> 5 #include <sys/fmutex.h> 7 6 #include <stdio.h> 8 7 #include <stdlib.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/fputc.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 3 3 #include "libc-alias.h" 4 4 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 5 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 6 #include <sys/rmutex.h> 5 #include <sys/fmutex.h> 7 6 #include <stdio.h> 8 7 #include <stdlib.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/fread.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 3 3 #include "libc-alias.h" 4 4 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 5 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 6 #include <sys/rmutex.h> 5 #include <sys/fmutex.h> 7 6 #include <sys/param.h> 8 7 #include <stdio.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/freopen.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 5 5 #include <share.h> 6 6 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 7 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 8 #include <sys/rmutex.h> 7 #include <sys/fmutex.h> 9 8 #include <emx/io.h> 10 9 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/fscanf.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 3 3 #include "libc-alias.h" 4 4 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 5 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 6 #include <sys/rmutex.h> 5 #include <sys/fmutex.h> 7 6 #include <stdio.h> 8 7 #include <stdlib.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/fseek.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1453 r1454 3 3 #include "libc-alias.h" 4 4 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 5 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 6 #include <sys/rmutex.h> 5 #include <sys/fmutex.h> 7 6 #include <stdio.h> 8 7 #include <stdlib.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/ftell.c
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r1453 r1454 3 3 #include "libc-alias.h" 4 4 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 5 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 6 #include <sys/rmutex.h> 5 #include <sys/fmutex.h> 7 6 #include <stdio.h> 8 7 #include <stdlib.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/ftruncat.c
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1453 r1454 22 22 } 23 23 /** @todo check this api with latest specs - there is a zero fill extension now IIRC. */ 24 if ((pFH->fFlags & F_TYPEMASK) != F_FILE)24 if ((pFH->fFlags & __LIBC_FH_TYPEMASK) != F_FILE) 25 25 { 26 26 errno = EBADF; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/fwrite.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 3 3 #include "libc-alias.h" 4 4 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 5 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 6 #include <sys/rmutex.h> 5 #include <sys/fmutex.h> 7 6 #include <stdio.h> 8 7 #include <stdlib.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/gets.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 3 3 #include "libc-alias.h" 4 4 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 5 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 6 #include <sys/rmutex.h> 5 #include <sys/fmutex.h> 7 6 #include <stdio.h> 8 7 #include <stdlib.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/isatty.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1453 r1454 21 21 } 22 22 23 return (pFH->fFlags & F_TYPEMASK) == F_DEV;23 return (pFH->fFlags & __LIBC_FH_TYPEMASK) == F_DEV; 24 24 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/printf.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 3 3 #include "libc-alias.h" 4 4 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 5 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 6 #include <sys/rmutex.h> 5 #include <sys/fmutex.h> 7 6 #include <stdio.h> 8 7 #include <stdlib.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/puts.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 3 3 #include "libc-alias.h" 4 4 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 5 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 6 #include <sys/rmutex.h> 5 #include <sys/fmutex.h> 7 6 #include <stdio.h> 8 7 #include <stdlib.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/read.c
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1453 r1454 65 65 { 66 66 /* special processing for text mode */ 67 if ( (pFH->fFlags & F_TYPEMASK) == F_FILE67 if ( (pFH->fFlags & __LIBC_FH_TYPEMASK) == F_FILE 68 68 && dst[n-1] == 0x1a 69 69 && eof (handle)) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/rewind.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 3 3 #include "libc-alias.h" 4 4 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 5 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 6 #include <sys/rmutex.h> 5 #include <sys/fmutex.h> 7 6 #include <stdio.h> 8 7 #include <stdlib.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/scanf.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 3 3 #include "libc-alias.h" 4 4 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 5 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 6 #include <sys/rmutex.h> 5 #include <sys/fmutex.h> 7 6 #include <stdio.h> 8 7 #include <stdlib.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/setvbuf.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 3 3 #include "libc-alias.h" 4 4 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 5 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 6 #include <sys/rmutex.h> 5 #include <sys/fmutex.h> 7 6 #include <stdio.h> 8 7 #include <stdlib.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/snprintf.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1453 r1454 3 3 #include "libc-alias.h" 4 4 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 5 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 6 #include <sys/rmutex.h> 5 #include <sys/fmutex.h> 7 6 #include <stdio.h> 8 7 #include <stdio.h> … … 30 29 trick._ungetc_count = 0; 31 30 trick._mbstate = 0; 32 _ rmutex_dummy(&trick.__u.__rsem);31 _fmutex_dummy(&trick.__u.__fsem); 33 32 result = _output (&trick, format, arg_ptr); 34 33 if (n != 0) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/sprintf.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 3 3 #include "libc-alias.h" 4 4 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 5 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 6 #include <sys/rmutex.h> 5 #include <sys/fmutex.h> 7 6 #include <stdio.h> 8 7 #include <stdio.h> … … 28 27 trick._ungetc_count = 0; 29 28 trick._mbstate = 0; 30 _ rmutex_dummy(&trick.__u.__rsem);29 _fmutex_dummy(&trick.__u.__fsem); 31 30 result = _output (&trick, format, arg_ptr); 32 31 putc (0, &trick); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/sscanf.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1453 r1454 3 3 #include "libc-alias.h" 4 4 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 5 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 6 #include <sys/rmutex.h> 5 #include <sys/fmutex.h> 7 6 #include <stdio.h> 8 7 #include <stdio.h> … … 29 28 trick._ungetc_count = 0; 30 29 trick._mbstate = 0; 31 _ rmutex_dummy(&trick.__u.__rsem);30 _fmutex_dummy(&trick.__u.__fsem); 32 31 result = _input (&trick, format, arg_ptr); 33 32 va_end (arg_ptr); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/ungetc.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 3 3 #include "libc-alias.h" 4 4 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 5 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 6 #include <sys/rmutex.h> 5 #include <sys/fmutex.h> 7 6 #include <stdio.h> 8 7 #include <stdlib.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/vfprintf.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 3 3 #include "libc-alias.h" 4 4 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 5 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 6 #include <sys/rmutex.h> 5 #include <sys/fmutex.h> 7 6 #include <stdio.h> 8 7 #include <stdlib.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/vfscanf.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 3 3 #include "libc-alias.h" 4 4 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 5 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 6 #include <sys/rmutex.h> 5 #include <sys/fmutex.h> 7 6 #include <stdio.h> 8 7 #include <stdlib.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/vprintf.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 3 3 #include "libc-alias.h" 4 4 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 5 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 6 #include <sys/rmutex.h> 5 #include <sys/fmutex.h> 7 6 #include <stdio.h> 8 7 #include <stdlib.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/vscanf.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 3 3 #include "libc-alias.h" 4 4 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 5 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 6 #include <sys/rmutex.h> 5 #include <sys/fmutex.h> 7 6 #include <stdio.h> 8 7 #include <stdlib.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/vsnprint.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1453 r1454 3 3 #include "libc-alias.h" 4 4 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 5 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 6 #include <sys/rmutex.h> 5 #include <sys/fmutex.h> 7 6 #include <stdio.h> 8 7 #include <stdio.h> … … 27 26 trick._ungetc_count = 0; 28 27 trick._mbstate = 0; 29 _ rmutex_dummy(&trick.__u.__rsem);28 _fmutex_dummy(&trick.__u.__fsem); 30 29 result = _output (&trick, format, arg_ptr); 31 30 if (n != 0) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/vsprintf.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 3 3 #include "libc-alias.h" 4 4 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 5 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 6 #include <sys/rmutex.h> 5 #include <sys/fmutex.h> 7 6 #include <stdio.h> 8 7 #include <stdio.h> … … 25 24 trick._ungetc_count = 0; 26 25 trick._mbstate = 0; 27 _ rmutex_dummy(&trick.__u.__rsem);26 _fmutex_dummy(&trick.__u.__fsem); 28 27 result = _output (&trick, format, arg_ptr); 29 28 putc (0, &trick); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/vsscanf.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1453 r1454 3 3 #include "libc-alias.h" 4 4 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 5 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 6 #include <sys/rmutex.h> 5 #include <sys/fmutex.h> 7 6 #include <stdio.h> 8 7 #include <stdio.h> … … 27 26 trick._ungetc_count = 0; 28 27 trick._mbstate = 0; 29 _ rmutex_dummy(&trick.__u.__rsem);28 _fmutex_dummy(&trick.__u.__fsem); 30 29 result = _input (&trick, format, arg_ptr); 31 30 return result; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/write.c
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1453 r1454 118 118 if (splitp) 119 119 { 120 if ((pFH->fFlags & F_TYPEMASK) != F_FILE)120 if ((pFH->fFlags & __LIBC_FH_TYPEMASK) != F_FILE) 121 121 pFH->fFlags |= F_WRCRPEND; 122 122 else … … 154 154 } 155 155 156 if ((pFH->fFlags & ( F_TYPEMASK | O_APPEND)) == (O_APPEND | F_FILE))156 if ((pFH->fFlags & (__LIBC_FH_TYPEMASK | O_APPEND)) == (O_APPEND | F_FILE)) 157 157 __lseek (handle, 0, SEEK_END); 158 158 if (nbyte == 0) /* Avoid truncation of file */ … … 182 182 data to be written. */ 183 183 184 if ( (pFH->fFlags & F_TYPEMASK) == F_DEV184 if ( (pFH->fFlags & __LIBC_FH_TYPEMASK) == F_DEV 185 185 && *src == CTRL_Z) 186 186 return 0; … … 190 190 191 191 if ( (pFH->fFlags & O_NONBLOCK) 192 && ( (pFH->fFlags & F_TYPEMASK) == F_DEV193 || (pFH->fFlags & F_TYPEMASK) == F_SOCKET /* ???? */194 || (pFH->fFlags & F_TYPEMASK) == F_PIPE) )192 && ( (pFH->fFlags & __LIBC_FH_TYPEMASK) == F_DEV 193 || (pFH->fFlags & __LIBC_FH_TYPEMASK) == F_SOCKET /* ???? */ 194 || (pFH->fFlags & __LIBC_FH_TYPEMASK) == F_PIPE) ) 195 195 { 196 196 errno = EAGAIN; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/libc.def
-
Property cvs2svn:cvs-rev
changed from
1.58
to1.59
r1453 r1454 23 23 "___default_hash" @1 24 24 "___digits" @2 25 "___locale" @3 26 "___locale_collate" @4 27 "___locale_ctype" @5 28 "___locale_lconv" @6 29 "___locale_time" @7 25 "___libc_GLocaleCtype" @3 26 "___libc_GLocaleCtypeDefault" @4 27 ;fixme "___locale_collate" @4 28 ;fixme "___locale_ctype" @5 29 ;fixme "___locale_lconv" @6 30 ;fixme "___locale_time" @7 30 31 "___progname" @8 31 32 "___stderrp" @9 … … 53 54 "__std_timezone" @31 54 55 "__std_tzname" @32 55 "__streamv_ rmutex" @3356 "__streamv_fmutex" @33 56 57 "__streamvec_head" @34 57 58 "__tmpidx" @35 … … 138 139 "__alloca" @161 139 140 ; LIBGCCEND 140 141 141 142 ; LIBC code - and const 142 143 "__CRT_init" @162 … … 195 196 "___close" @215 196 197 "___collate_range_cmp" @216 197 "___convert_codepage" @217198 ;fixme "___convert_codepage" @217 198 199 "___ctordtorInit1" @218 199 200 "___ctordtorTerm1" @219 200 201 "___dbpanic" @220 201 202 "___delpair" @221 202 "___do_Unicode" @222203 ;fixme "___do_Unicode" @222 203 204 "___dtoa" @223 204 205 "___dup" @224 … … 220 221 "___fpclassifyl" @240 221 222 "___free_ovflpage" @241 222 "___from_ucs" @242223 ;fixme "___from_ucs" @242 223 224 "___fstat" @243 224 225 "___ftime" @244 … … 274 275 "___libc_TLSGet" @294 275 276 "___libc_TLSSet" @295 276 "___locale_C" @296277 ;fixme "___locale_C" @296 277 278 "___log2" @297 278 279 "___lseek" @298 … … 323 324 "___swchar" @343 324 325 "___threadid" @344 325 "___to_ucs" @345326 ;fixme "___to_ucs" @345 326 327 "___tolower" @346 327 328 "___toupper" @347 … … 488 489 "__hrealloc" @508 489 490 "__imphandle" @509 490 "__init1_tmp" @510491 ; fixme!! "__init1_tmp" @510 491 492 "__init_streams" @511 492 493 "__input" @512 … … 523 524 "__rfnlwr" @543 524 525 "__rmtmp" @544 525 "__rmutex_checked_close" @545526 "__rmutex_checked_create" @546527 "__rmutex_checked_open" @547528 "__rmutex_close" @548529 "__rmutex_create" @549530 "__rmutex_dummy" @550531 "__rmutex_fork" @551532 "__rmutex_open" @552526 ; fixme!! "__rmutex_checked_close" @545 527 ; fixme!! "__rmutex_checked_create" @546 528 ; fixme!! "__rmutex_checked_open" @547 529 ; fixme!! "__rmutex_close" @548 530 ; fixme!! "__rmutex_create" @549 531 ; fixme!! "__rmutex_dummy" @550 532 ; fixme!! "__rmutex_fork" @551 533 ; fixme!! "__rmutex_open" @552 533 534 "__scrsize" @553 534 535 "__searchenv" @554 … … 1100 1101 "___libc_ThreadRegisterTermCallback" @1120 1101 1102 "___libc_TLSGetDestructor" @1121 1102 1103 1103 1104 ; LIBGCCSTART 1104 1105 ; GCC333.DLL - move this!!! … … 1109 1110 "___gcc_personality_v0" @1126 ; (this is a bug in the gcc 3.2.2 config, it should've been there too.) 1110 1111 ; LIBGCCEND 1111 1112 1112 1113 "__std_strtok_r" @1127 1114 "___libc_LogDumpHex" @1128 1115 "DosAllocMemEx" @1129 1116 "DosAllocSharedMemEx" @1130 1117 "DosCloseEventSemEx" @1131 1118 "DosCloseMutexSemEx" @1132 1119 "DosCreateEventSemEx" @1133 1120 "DosCreateMutexSemEx" @1134 1121 "DosFreeMemEx" @1135 1122 "DosGetNamedSharedMemEx" @1136 1123 "DosGetSharedMemEx" @1137 1124 "DosOpenEventSemEx" @1138 1125 "DosOpenMutexSemEx" @1139 1126 "__atfork_callback" @1140 1127 "__std_getrlimit" @1141 1128 "__std_setrlimit" @1142 1129 "___libc_ForkDefaultModuleCallback" @1143 1130 "___libc_ForkRegisterModule" @1144 1131 "___isctype" @1145 1132 "___libc_TranslateCodepage" @1146 1133 "__std_eaccess" @1147 1134 "___libc_TcpipAllocFH43" @1148 1135 "___libc_TcpipAllocFH44" @1149 1136 "___libc_TcpipAllocFHEx43" @1150 1137 "___libc_TcpipAllocFHEx44" @1151 1138 "___libc_Tcpipbsdselect43" @1152 1139 "___libc_Tcpipbsdselect44" @1153 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/libc.smak
-
Property cvs2svn:cvs-rev
changed from
1.41
to1.42
r1453 r1454 29 29 .TSRC := $(libc.TSRC.$(CPU)) $(libc.TSRC) 30 30 .TDEP := $(libc.TDEP.$(CPU)) $(libc.TDEP) 31 .TCF := -I$. -D __DBINTERFACE_PRIVATE -D__NETBSD_SYSCALLS -DPOSIX_MISTAKE -DHAVE_CONFIG_H -Isrc/lib/bsd/locale -Isrc/lib/lgpl/include31 .TCF := -I$. -DIN_INNOTEK_LIBC -D__DBINTERFACE_PRIVATE -D__NETBSD_SYSCALLS -DPOSIX_MISTAKE -DHAVE_CONFIG_H -Isrc/lib/bsd/locale -Isrc/lib/lgpl/include 32 32 .INSDIR = lib/ 33 33 .TKEEP := 1 34 34 include mklib.smak 35 35 36 .TARGET := libc_l_s.a 36 37 .TARGET := libc_l_s.a 37 38 .TKIND := aout log 38 39 .TKEEP := 1 … … 56 57 LIBC.IMPLIB := $.omf/libc_dll.lib $.aout/libc_dll.a 57 58 LIBC.DEF := $.omf/libc.def 58 LIBC.OBJS := $.omf/src/lib/startup/dll0hi .obj $.omf/src/lib/startup/dllinit.obj59 LIBC.OBJS := $.omf/src/lib/startup/dll0hifork.obj $.omf/src/lib/startup/dllinit.obj 59 60 LIBC.LIBS := $.omf/libc_s.lib $.omf/libc_app.lib 60 61 LIBC.DEPS := $(LIBC.STUB) $.omf/libc_alias.lib … … 64 65 LIBC.PRF.DLL := $(LIBC.DLL:.dll=.prf) 65 66 LIBC.PRF.DEF := $.omf/libc.prf.def 66 LIBC.PRF.OBJS := $.omf/src/lib/startup/dll0hi .obj $.omf-prof/src/lib/startup/dllinit.obj67 LIBC.PRF.OBJS := $.omf/src/lib/startup/dll0hifork.obj $.omf-prof/src/lib/startup/dllinit.obj 67 68 LIBC.PRF.LIBS := $.omf-prof/libc_p_s.lib $.omf-prof/libc_app_p.lib 68 69 LIBC.PRF.DEPS := $(LIBC.DEPS) … … 78 79 LIBC.LOG.DLL := $(LIBC.DLL:.dll=.logchk) 79 80 LIBC.LOG.DEF := $(LIBC.DEF) 80 LIBC.LOG.OBJS := $.omf/src/lib/startup/dll0hi .obj $.omf/src/lib/startup/dllinit.obj81 LIBC.LOG.OBJS := $.omf/src/lib/startup/dll0hifork.obj $.omf/src/lib/startup/dllinit.obj 81 82 LIBC.LOG.LIBS := $.omf-log/libc_l_s.lib $.omf-log/libc_app_l.lib 82 83 LIBC.LOG.DEPS := $(LIBC.DEPS) … … 248 249 $(addprefix $(INS)lib/,$(notdir $(LIBC.IMPLIB))) \ 249 250 $(INS)lib/$(notdir $(LIBC.LOG.DLL)) \ 251 $(INS)lib/$(notdir $(LIBC.LOG.DLL).map) \ 250 252 $(INS)lib/$(notdir $(LIBC.PRF.DLL)) \ 251 $(INS)lib/$(notdir $(LIBC.ELH.DLL)) 253 $(INS)lib/$(notdir $(LIBC.PRF.DLL).map) \ 254 $(INS)lib/$(notdir $(LIBC.ELH.DLL)) \ 255 $(INS)lib/$(notdir $(LIBC.ELH.DLL).map) 252 256 253 257 $(INS)lib/$(notdir $(LIBC.DLL)): $(LIBC.DLL) … … 258 262 $(INS)lib/$(notdir $(LIBC.LOG.DLL)): $(LIBC.LOG.DLL) 259 263 $(call CP,$<,$@) 264 $(INS)lib/$(notdir $(LIBC.LOG.DLL).map): $(LIBC.LOG.DLL).map 265 $(call CP,$<,$@) 260 266 261 267 $(INS)lib/$(notdir $(LIBC.PRF.DLL)): $(LIBC.PRF.DLL) 262 268 $(call CP,$<,$@) 269 $(INS)lib/$(notdir $(LIBC.PRF.DLL).map): $(LIBC.PRF.DLL).map 270 $(call CP,$<,$@) 263 271 264 272 $(INS)lib/$(notdir $(LIBC.ELH.DLL)): $(LIBC.ELH.DLL) 273 $(call CP,$<,$@) 274 $(INS)lib/$(notdir $(LIBC.ELH.DLL).map): $(LIBC.ELH.DLL).map 265 275 $(call CP,$<,$@) 266 276 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/locale/__convcp.c
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1453 r1454 1 /* 2 Locale support implementation through OS/2 Unicode API. 3 Copyright (c) 2003 InnoTek Systemberatung GmbH 1 /* $Id$ */ 2 /** @file 3 * 4 * Locale - code page translation. 5 * 6 * Copyright (c) 2003 InnoTek Systemberatung GmbH 7 * 8 * 9 * This file is part of InnoTek LIBC. 10 * 11 * InnoTek LIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * InnoTek LIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with InnoTek LIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 4 26 5 For conditions of distribution and use, see the file COPYING. 27 #include <InnotekLIBC/locale.h> 28 #include <string.h> 6 29 7 Convert an ASCIIZ codepage to UCS-2 form and convert POSIX codepage 8 names to names understood by OS/2 Unicode API. 9 */ 30 /** 31 * Convert an ASCIIZ codepage to UCS-2 form and convert POSIX codepage 32 * names to names understood by OS/2 Unicode API. 33 */ 34 extern void __libc_TranslateCodepage(const char *cp, UniChar *ucp) 35 { 36 static const struct _cp_aliases 37 { 38 const char *pszAlias; 39 const char *pszIBM; 40 } aAliases[] = 41 { /* pszAlias -> pszIBM */ 42 { "SYSTEM", ""}, 43 { "ASCII", "IBM-367"}, 44 { "UTF-8", "IBM-1208"}, 45 { "UCS-2", "IBM-1200"}, 46 { "UCS-2BE", "IBM-1200@endian=big"}, 47 { "UCS-2LE", "IBM-1200@endian=little"}, 48 { "EUC-JP", "IBM-954"}, 49 { "EUC-KR", "IBM-970"}, 50 { "EUC-TW", "IBM-964"}, 51 { "EUC-CN", "IBM-1383"}, 52 { "BIG5", "IBM-950"}, 53 }; 54 unsigned i; 55 size_t sl; 10 56 11 #include <string.h> 12 #include <uconv.h> 13 #include <emx/locale.h> 14 15 /* Convert an encoding name to te form understood by UniCreateUconvObject. */ 16 void __convert_codepage (const char *cp, UniChar *ucp) 17 { 18 static const struct _cp_aliases 19 { 20 const char *pszAlias; 21 const char *pszIBM; 22 } aAliases[] = 23 { /* pszAlias -> pszIBM */ 24 { "SYSTEM", "" }, 25 { "ASCII", "IBM-367" }, 26 { "UTF-8", "IBM-1208" }, 27 { "UCS-2", "IBM-1200" }, 28 { "UCS-2BE", "IBM-1200@endian=big" }, 29 { "UCS-2LE", "IBM-1200@endian=little" }, 30 { "EUC-JP", "IBM-954" }, 31 { "EUC-KR", "IBM-970" }, 32 { "EUC-TW", "IBM-964" }, 33 { "EUC-CN", "IBM-1383" }, 34 { "BIG5", "IBM-950" }, 35 }; 36 int i; 37 size_t sl; 38 39 /* 40 * Try aliases. 41 */ 42 for (i = 0; i < sizeof(aAliases) / sizeof(aAliases[0]); i++ ) 57 /* 58 * Try aliases. 59 */ 60 for (i = 0; i < sizeof(aAliases) / sizeof(aAliases[0]); i++) 43 61 { 44 if (!strcmp(cp, aAliases[i].pszAlias))62 if (!strcmp(cp, aAliases[i].pszAlias)) 45 63 { 46 cp = aAliases[i].pszIBM;47 while ((*ucp++ = *cp++) != 0)48 /* nada */;49 return;64 cp = aAliases[i].pszIBM; 65 while ((*ucp++ = *cp++) != '\0') 66 /* nada */; 67 return; 50 68 } 51 69 } 52 70 53 /*54 * Generic transformations:55 * CPxxxx -> IBM-xxxx56 * ISO-xxxx-x -> ISOxxxx-x57 */58 sl = 0;59 /* Transform CPXXX naming style to IBM-XXX style */60 if ((cp[0] == 'C' || cp[0] == 'c')61 && (cp[1] == 'P' || cp[1] == 'p'))71 /* 72 * Generic transformations: 73 * CPxxxx -> IBM-xxxx 74 * ISO-xxxx-x -> ISOxxxx-x 75 */ 76 sl = 0; 77 /* Transform CPXXX naming style to IBM-XXX style */ 78 if ( (cp[0] == 'C' || cp[0] == 'c') 79 && (cp[1] == 'P' || cp[1] == 'p')) 62 80 { 63 ucp[sl++] = 'I';64 ucp[sl++] = 'B';65 ucp[sl++] = 'M';66 ucp[sl++] = '-';67 cp += 2;81 ucp[sl++] = 'I'; 82 ucp[sl++] = 'B'; 83 ucp[sl++] = 'M'; 84 ucp[sl++] = '-'; 85 cp += 2; 68 86 } 69 /* Transform ISO-XXXX-X naming style to ISOXXXX-X style */70 else if ((cp[0] == 'I' || cp[0] == 'i')71 && (cp[1] == 'S' || cp[1] == 's')72 && (cp[2] == 'O' || cp[2] == 'o')73 && (cp[3] == '-'))74 {75 ucp[sl++] = 'I';76 ucp[sl++] = 'S';77 ucp[sl++] = 'O';78 cp += 4;79 }87 /* Transform ISO-XXXX-X naming style to ISOXXXX-X style */ 88 else if ( (cp[0] == 'I' || cp[0] == 'i') 89 && (cp[1] == 'S' || cp[1] == 's') 90 && (cp[2] == 'O' || cp[2] == 'o') 91 && (cp[3] == '-')) 92 { 93 ucp[sl++] = 'I'; 94 ucp[sl++] = 'S'; 95 ucp[sl++] = 'O'; 96 cp += 4; 97 } 80 98 81 /* copy the rest of the string. */82 while (*cp != '\0')83 ucp[sl++] = *cp++;84 ucp[sl] = 0;99 /* copy the rest of the string. */ 100 while (*cp != '\0') 101 ucp[sl++] = *cp++; 102 ucp[sl] = '\0'; 85 103 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/locale/__do_uni.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 1 /* 2 Locale support implementation through OS/2 Unicode API. 3 Copyright (c) 2003 InnoTek Systemberatung GmbH 1 /* $Id$ */ 2 /** @file 3 * 4 * Locale - String processor. 5 * 6 * Copyright (c) 2003 InnoTek Systemberatung GmbH 7 * 8 * 9 * This file is part of InnoTek LIBC. 10 * 11 * InnoTek LIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * InnoTek LIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with InnoTek LIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 4 26 5 For conditions of distribution and use, see the file COPYING.6 27 7 Utility routine that converts a string to Unicode, calls some 8 function and then converts the string back. Used to handle 9 MBCS encodings. 10 */ 11 12 #define INCL_FSMACROS 13 #include <os2emx.h> 14 #include <uconv.h> 28 #include <InnoTekLIBC/locale.h> 15 29 #include <alloca.h> 16 30 #include <malloc.h> 17 31 #include <string.h> 18 #include <emx/locale.h> 32 #define INCL_FSMACROS 33 #include <os2emx.h> 19 34 20 void __do_Unicode (UconvObject *uconv, char *s, void *arg, 21 int (*xform) (UniChar *, void *)) 35 /** 36 * Utility routine that converts a string to Unicode, calls some 37 * function and then converts the string back. 38 * Used to handle MBCS encodings 39 */ 40 extern void __libc_ucs2Do(UconvObject *uconv, char *s, void *arg, int (*xform)(UniChar *, void *)) 22 41 { 23 /* We'll get maximum that much UniChar's */24 size_t sl = strlen(s) + 1;25 char free_ucs = 0;26 UniChar *ucs;27 void *mbcsbuf;28 UniChar *ucsbuf;29 size_t in_left, out_left, nonid;30 FS_VAR();31 FS_SAVE_LOAD();42 /* We'll get maximum that much UniChar's */ 43 size_t sl = strlen(s) + 1; 44 char free_ucs = 0; 45 UniChar *ucs; 46 void *mbcsbuf; 47 UniChar *ucsbuf; 48 size_t in_left, out_left, nonid; 49 FS_VAR(); 50 FS_SAVE_LOAD(); 32 51 33 /* Allocate strings up to 2000 characters on the stack */34 if (sl < 4096 / sizeof(UniChar))35 ucs = alloca (sl * sizeof(UniChar));36 else37 {38 free_ucs = 1;39 ucs = malloc (sl * sizeof(UniChar));40 }52 /* Allocate strings up to 2000 characters on the stack */ 53 if (sl < 4096 / sizeof(UniChar)) 54 ucs = alloca(sl * sizeof(UniChar)); 55 else 56 { 57 free_ucs = 1; 58 ucs = malloc(sl * sizeof(UniChar)); 59 } 41 60 42 /* Translate the string to Unicode */43 mbcsbuf = s; in_left = sl;44 ucsbuf = ucs; out_left = sl;45 if (UniUconvToUcs(uconv, &mbcsbuf, &in_left, &ucsbuf, &out_left, &nonid))46 goto out;61 /* Translate the string to Unicode */ 62 mbcsbuf = s; in_left = sl; 63 ucsbuf = ucs; out_left = sl; 64 if (UniUconvToUcs(uconv, &mbcsbuf, &in_left, &ucsbuf, &out_left, &nonid)) 65 goto out; 47 66 48 /* Apply the transform function */49 if (xform(ucs, arg))50 {51 /* Now convert back to MBCS */52 ucsbuf = ucs; in_left = sl - out_left;53 mbcsbuf = s; out_left = sl;54 UniUconvFromUcs(uconv, &ucsbuf, &in_left, &mbcsbuf, &out_left, &nonid);55 }67 /* Apply the transform function */ 68 if (xform(ucs, arg)) 69 { 70 /* Now convert back to MBCS */ 71 ucsbuf = ucs; in_left = sl - out_left; 72 mbcsbuf = s; out_left = sl; 73 UniUconvFromUcs(uconv, &ucsbuf, &in_left, &mbcsbuf, &out_left, &nonid); 74 } 56 75 57 76 out: 58 if (free_ucs)59 free(ucs);60 FS_RESTORE();77 if (free_ucs) 78 free(ucs); 79 FS_RESTORE(); 61 80 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/locale/__from_ucs.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 1 /* 2 Locale support implementation through OS/2 Unicode API. 3 Copyright (c) 2003 InnoTek Systemberatung GmbH 1 /* $Id$ */ 2 /** @file 3 * 4 * Locale - Convert a char from unicode to mbcs. 5 * 6 * Copyright (c) 2003 InnoTek Systemberatung GmbH 7 * 8 * 9 * This file is part of InnoTek LIBC. 10 * 11 * InnoTek LIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * InnoTek LIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with InnoTek LIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 4 26 5 For conditions of distribution and use, see the file COPYING. 6 7 Helper function: Convert a character from Unicode. 8 Returns number of bytes in the MBCS character. 9 */ 10 27 #include <InnoTekLIBC/locale.h> 11 28 #define INCL_FSMACROS 12 29 #include <os2emx.h> 13 #include <uconv.h>14 #include <emx/locale.h>15 30 16 int __from_ucs (UconvObject uconv_obj, UniChar c, unsigned char *sbcs, 17 31 /** Convert a Unicode character to MBCS. */ 32 extern int __libc_ucs2From(UconvObject uobj, UniChar c, unsigned char *sbcs, size_t len) 18 33 { 19 UniChar *inbuf = &c;20 void *outbuf = sbcs;21 size_t nonid, in_left = 1, out_left = len;22 int rc;23 FS_VAR();34 UniChar *inbuf = &c; 35 void *outbuf = sbcs; 36 size_t nonid, in_left = 1, out_left = len; 37 int rc; 38 FS_VAR(); 24 39 25 FS_SAVE_LOAD();26 rc = UniUconvFromUcs (uconv_obj, &inbuf, &in_left, &outbuf, &out_left, &nonid);27 FS_RESTORE();28 if (rc || nonid || in_left)29 return 0;40 FS_SAVE_LOAD(); 41 rc = UniUconvFromUcs(uobj, &inbuf, &in_left, &outbuf, &out_left, &nonid); 42 FS_RESTORE(); 43 if (rc || nonid || in_left) 44 return 0; 30 45 31 return len - out_left;46 return len - out_left; 32 47 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/locale/__to_ucs.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 1 /* 2 Locale support implementation through OS/2 Unicode API. 3 Copyright (c) 2003 InnoTek Systemberatung GmbH 1 /* $Id$ */ 2 /** @file 3 * 4 * Locale - Confer from MBCS to Unicode. 5 * 6 * Copyright (c) 2003 InnoTek Systemberatung GmbH 7 * 8 * 9 * This file is part of InnoTek LIBC. 10 * 11 * InnoTek LIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * InnoTek LIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with InnoTek LIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 4 26 5 For conditions of distribution and use, see the file COPYING. 6 7 Helper function: convert a MBCS character to a Unicode character. 8 Returns 0 or the length of the MBCS character in bytes. 9 */ 10 27 #include <InnoTekLIBC/locale.h> 11 28 #define INCL_FSMACROS 12 29 #include <os2emx.h> 13 #include <uconv.h>14 #include <emx/locale.h>15 30 16 int __to_ucs (UconvObject uconv_obj, const unsigned char *sbcs, size_t len, 17 UniChar *ucs) 31 32 /** Convert a MBCS character to Unicode; returns number of bytes in MBCS char. */ 33 int __libc_ucs2To(UconvObject uobj, const unsigned char *sbcs, size_t len, UniChar *ucs) 18 34 { 19 void *inbuf = (void *)sbcs;20 UniChar *outbuf = ucs;21 size_t nonid, in_left = len, out_left = 1;22 int ret;23 FS_VAR();35 void *inbuf = (void *)sbcs; 36 UniChar *outbuf = ucs; 37 size_t nonid, in_left = len, out_left = 1; 38 int ret; 39 FS_VAR(); 24 40 25 FS_SAVE_LOAD(); 26 ret = UniUconvToUcs (uconv_obj, &inbuf, &in_left, &outbuf, &out_left, 27 &nonid); 28 FS_RESTORE(); 41 FS_SAVE_LOAD(); 42 ret = UniUconvToUcs(uobj, &inbuf, &in_left, &outbuf, &out_left, &nonid); 43 FS_RESTORE(); 29 44 30 if ((ret && (ret != ULS_BUFFERFULL)) || nonid || out_left)31 return 0;45 if ((ret && (ret != ULS_BUFFERFULL)) || nonid || out_left) 46 return 0; 32 47 33 return len - in_left;48 return len - in_left; 34 49 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/locale/isxxx.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 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 Usually these routines are not needed (they are inline), but 8 for cases when a program instead of including ctype.h blindly 9 declares them with "extern", they will be linked in. 10 */ 1 /* $Id$ */ 2 /** @file 3 * 4 * ctype functions. 5 * 6 * Usually these routines are not needed (they are inline), but 7 * for cases when a program instead of including ctype.h blindly 8 * declares them with "extern", they will be linked in. 9 * 10 * Copyright (c) 2003 InnoTek Systemberatung GmbH 11 * Copyright (c) 2003-2004 knut st. osmundsen <bird-srcspam@anduin.net> 12 * 13 * 14 * This file is part of InnoTek LIBC. 15 * 16 * InnoTek LIBC is free software; you can redistribute it and/or modify 17 * it under the terms of the GNU General Public License as published by 18 * the Free Software Foundation; either version 2 of the License, or 19 * (at your option) any later version. 20 * 21 * InnoTek LIBC is distributed in the hope that it will be useful, 22 * but WITHOUT ANY WARRANTY; without even the implied warranty of 23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 * GNU General Public License for more details. 25 * 26 * You should have received a copy of the GNU General Public License 27 * along with InnoTek LIBC; if not, write to the Free Software 28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 29 * 30 */ 11 31 12 32 #define _DONT_USE_CTYPE_INLINE_ 13 33 #include "libc-alias.h" 14 #include <sys/locale.h>15 34 #include <ctype.h> 16 35 17 36 #undef isalnum 18 37 int isalnum(int _c) 19 { return __l ocale_ctype.cflags[_c & 0xff] & (__UPPER|__LOWER|__DIGIT); }38 { return __libc_GLocaleCtype.ausfType[_c & 0xff] & (__UPPER|__LOWER|__DIGIT); } 20 39 21 40 #undef isalpha 22 41 int isalpha(int _c) 23 { return __l ocale_ctype.cflags[_c & 0xff] & (__UPPER|__LOWER); }42 { return __libc_GLocaleCtype.ausfType[_c & 0xff] & (__UPPER|__LOWER); } 24 43 25 44 #undef iscntrl 26 45 int iscntrl(int _c) 27 { return __l ocale_ctype.cflags[_c & 0xff] & (__CNTRL); }46 { return __libc_GLocaleCtype.ausfType[_c & 0xff] & (__CNTRL); } 28 47 29 48 #undef isdigit 30 49 int isdigit(int _c) 31 { return __l ocale_ctype.cflags[_c & 0xff] & (__DIGIT); }50 { return __libc_GLocaleCtype.ausfType[_c & 0xff] & (__DIGIT); } 32 51 33 52 #undef isgraph 34 53 int isgraph(int _c) 35 { return __l ocale_ctype.cflags[_c & 0xff] & (__PUNCT|__UPPER|__LOWER|__DIGIT); }54 { return __libc_GLocaleCtype.ausfType[_c & 0xff] & (__PUNCT|__UPPER|__LOWER|__DIGIT); } 36 55 37 56 #undef islower 38 57 int islower(int _c) 39 { return __l ocale_ctype.cflags[_c & 0xff] & (__LOWER); }58 { return __libc_GLocaleCtype.ausfType[_c & 0xff] & (__LOWER); } 40 59 41 60 #undef isprint 42 61 int isprint(int _c) 43 { return __l ocale_ctype.cflags[_c & 0xff] & (__PRINT); }62 { return __libc_GLocaleCtype.ausfType[_c & 0xff] & (__PRINT); } 44 63 45 64 #undef ispunct 46 65 int ispunct(int _c) 47 { return __l ocale_ctype.cflags[_c & 0xff] & (__PUNCT); }66 { return __libc_GLocaleCtype.ausfType[_c & 0xff] & (__PUNCT); } 48 67 49 68 #undef isspace 50 69 int isspace(int _c) 51 { return __l ocale_ctype.cflags[_c & 0xff] & (__SPACE); }70 { return __libc_GLocaleCtype.ausfType[_c & 0xff] & (__SPACE); } 52 71 53 72 #undef isupper 54 73 int isupper(int _c) 55 { return __l ocale_ctype.cflags[_c & 0xff] & (__UPPER); }74 { return __libc_GLocaleCtype.ausfType[_c & 0xff] & (__UPPER); } 56 75 57 76 #undef isxdigit 58 77 int isxdigit(int _c) 59 { return __l ocale_ctype.cflags[_c & 0xff] & (__XDIGIT); }78 { return __libc_GLocaleCtype.ausfType[_c & 0xff] & (__XDIGIT); } 60 79 61 80 #undef isblank 62 81 int isblank(int _c) 63 { return __l ocale_ctype.cflags[_c & 0xff] & (__BLANK); }82 { return __libc_GLocaleCtype.ausfType[_c & 0xff] & (__BLANK); } 64 83 65 84 #undef ishexnumber 66 85 int ishexnumber(int _c) 67 { return __l ocale_ctype.cflags[_c & 0xff] & (__XDIGIT); }86 { return __libc_GLocaleCtype.ausfType[_c & 0xff] & (__XDIGIT); } 68 87 69 88 #undef isnumber 70 89 int isnumber(int _c) 71 { return __l ocale_ctype.cflags[_c & 0xff] & (__DIGIT); }90 { return __libc_GLocaleCtype.ausfType[_c & 0xff] & (__DIGIT); } 72 91 73 92 #undef toascii … … 79 98 { return (_c & 0x80) != 0; } 80 99 81 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/locale/locale_collate.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 1 /* 2 Locale support implementation through OS/2 Unicode API. 3 Copyright (c) 2003 InnoTek Systemberatung GmbH 1 /* $Id$ */ 2 /** @file 3 * 4 * Locale - String collation information array. 5 * 6 * Copyright (c) 2003 InnoTek Systemberatung GmbH 7 * 8 * 9 * This file is part of InnoTek LIBC. 10 * 11 * InnoTek LIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * InnoTek LIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with InnoTek LIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 4 26 5 For conditions of distribution and use, see the file COPYING. 27 #include <InnoTekLIBC/locale.h> 6 28 7 String collation information array. 8 */ 9 10 #define __INTERNAL_DEFS 11 #include <sys/locale.h> 12 #include <string.h> 13 14 struct __locale_collate __locale_collate = 29 /** String collation information. */ 30 __LIBC_LOCALECOLLATE __libc_gLocaleCollate = 15 31 { 16 weight:17 {18 0, 1, 2, 3, 4, 5, 6, 7, 8,9,19 10, 11, 13, 12, 14, 15, 16, 17, 18,19,20 20, 21, 23, 22, 24, 25, 26, 27, 28,29,21 30, 31, 33, 32, 34, 35, 36, 37, 38,39,22 40, 41, 43, 42, 44, 45, 46, 47, 48,49,23 50, 51, 53, 52, 54, 55, 56, 57, 58,59,24 60, 61, 63, 62, 64, 65, 66, 67, 68,69,25 70, 71, 73, 72, 74, 75, 76, 77, 78,79,26 80, 81, 83, 82, 84, 85, 86, 87, 88,89,27 90, 91, 93, 92, 94, 95, 96, 97, 98,99,28 100, 101, 103, 102, 104, 105, 106, 107, 108, 109,29 110, 111, 113, 112, 114, 115, 116, 117, 118, 119,30 120, 121, 123, 122, 124, 125, 126, 127, 128, 129,31 130, 131, 133, 132, 134, 135, 136, 137, 138, 139,32 140, 141, 143, 142, 144, 145, 146, 147, 148, 149,33 150, 151, 153, 152, 154, 155, 156, 157, 158, 159,34 160, 161, 163, 162, 164, 165, 166, 167, 168, 169,35 170, 171, 173, 172, 174, 175, 176, 177, 178, 179,36 180, 181, 183, 182, 184, 185, 186, 187, 188, 189,37 190, 191, 193, 192, 194, 195, 196, 197, 198, 199,38 200, 201, 203, 202, 204, 205, 206, 207, 208, 209,39 210, 211, 213, 212, 214, 215, 216, 217, 218, 219,40 220, 221, 223, 222, 224, 225, 226, 227, 228, 229,41 230, 231, 233, 232, 234, 235, 236, 237, 238, 239,42 240, 241, 243, 242, 244, 245, 246, 247, 248, 249,43 250, 251, 253, 252, 254, 25544 },45 mbcsprefix:46 {47 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,48 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,49 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,50 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,51 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,52 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,53 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,54 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,55 },56 uconv:0,57 locale:0,58 mbcs:032 .auchWeight = 33 { 34 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 35 10, 11, 13, 12, 14, 15, 16, 17, 18, 19, 36 20, 21, 23, 22, 24, 25, 26, 27, 28, 29, 37 30, 31, 33, 32, 34, 35, 36, 37, 38, 39, 38 40, 41, 43, 42, 44, 45, 46, 47, 48, 49, 39 50, 51, 53, 52, 54, 55, 56, 57, 58, 59, 40 60, 61, 63, 62, 64, 65, 66, 67, 68, 69, 41 70, 71, 73, 72, 74, 75, 76, 77, 78, 79, 42 80, 81, 83, 82, 84, 85, 86, 87, 88, 89, 43 90, 91, 93, 92, 94, 95, 96, 97, 98, 99, 44 100, 101, 103, 102, 104, 105, 106, 107, 108, 109, 45 110, 111, 113, 112, 114, 115, 116, 117, 118, 119, 46 120, 121, 123, 122, 124, 125, 126, 127, 128, 129, 47 130, 131, 133, 132, 134, 135, 136, 137, 138, 139, 48 140, 141, 143, 142, 144, 145, 146, 147, 148, 149, 49 150, 151, 153, 152, 154, 155, 156, 157, 158, 159, 50 160, 161, 163, 162, 164, 165, 166, 167, 168, 169, 51 170, 171, 173, 172, 174, 175, 176, 177, 178, 179, 52 180, 181, 183, 182, 184, 185, 186, 187, 188, 189, 53 190, 191, 193, 192, 194, 195, 196, 197, 198, 199, 54 200, 201, 203, 202, 204, 205, 206, 207, 208, 209, 55 210, 211, 213, 212, 214, 215, 216, 217, 218, 219, 56 220, 221, 223, 222, 224, 225, 226, 227, 228, 229, 57 230, 231, 233, 232, 234, 235, 236, 237, 238, 239, 58 240, 241, 243, 242, 244, 245, 246, 247, 248, 249, 59 250, 251, 253, 252, 254, 255 60 }, 61 .au2MBCSPrefixs = 62 { /* 01 */ 63 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 64 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 65 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 66 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 67 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 68 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 69 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 70 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 71 }, 72 .uobj = 0, 73 .lobj = 0, 74 .mbcs = 0 59 75 }; 60 76 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/locale/locale_ctype.c
-
Property cvs2svn:cvs-rev
changed from
1.7
to1.8
r1453 r1454 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 Default character type bits for "C" locale. 8 */ 9 10 #define __INTERNAL_DEFS 1 /* $Id$ */ 2 /** @file 3 * 4 * Locale - ctype data. 5 * 6 * Copyright (c) 2003 InnoTek Systemberatung GmbH 7 * Copyright (c) 2003-2004 knut st. osmundsen <bird-srcspam@anduin.net> 8 * 9 * 10 * This file is part of InnoTek LIBC. 11 * 12 * InnoTek LIBC is free software; you can redistribute it and/or modify 13 * it under the terms of the GNU General Public License as published by 14 * the Free Software Foundation; either version 2 of the License, or 15 * (at your option) any later version. 16 * 17 * InnoTek LIBC is distributed in the hope that it will be useful, 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * GNU General Public License for more details. 21 * 22 * You should have received a copy of the GNU General Public License 23 * along with InnoTek LIBC; if not, write to the Free Software 24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 25 * 26 */ 27 11 28 #define _DONT_USE_CTYPE_INLINE_ 12 29 #include "libc-alias.h" 13 #include < sys/locale.h>30 #include <InnoTekLIBC/locale.h> 14 31 #include <ctype.h> 15 32 16 33 17 struct __locale_ctype __locale_ctype = 18 { 19 cflags: 20 { 21 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 22 0x8020, 0x8068, 0x8028, 0x8028, 0x8028, 0x8028, 0x8020, 0x8020, 23 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 24 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 25 0x8848, 0x8c10, 0x8c10, 0x8c10, 0xac10, 0x8c10, 0x8c10, 0x8c10, 26 0x8c10, 0x8c10, 0x8c10, 0xac10, 0x8c10, 0x8c10, 0x8c10, 0x8c10, 27 0x9e84, 0x9e84, 0x9e84, 0x9e84, 0x9e84, 0x9e84, 0x9e84, 0x9e84, 28 0x9e84, 0x9e84, 0x8c10, 0x8c10, 0xac10, 0xac10, 0xac10, 0x8c10, 29 0x8c10, 0x8f81, 0x8f81, 0x8f81, 0x8f81, 0x8f81, 0x8f81, 0x8f01, 30 0x8f01, 0x8f01, 0x8f01, 0x8f01, 0x8f01, 0x8f01, 0x8f01, 0x8f01, 31 0x8f01, 0x8f01, 0x8f01, 0x8f01, 0x8f01, 0x8f01, 0x8f01, 0x8f01, 32 0x8f01, 0x8f01, 0x8f01, 0x8c10, 0x8c10, 0x8c10, 0xac10, 0x8c10, 33 0xac10, 0x8f82, 0x8f82, 0x8f82, 0x8f82, 0x8f82, 0x8f82, 0x8f02, 34 0x8f02, 0x8f02, 0x8f02, 0x8f02, 0x8f02, 0x8f02, 0x8f02, 0x8f02, 35 0x8f02, 0x8f02, 0x8f02, 0x8f02, 0x8f02, 0x8f02, 0x8f02, 0x8f02, 36 0x8f02, 0x8f02, 0x8f02, 0x8c10, 0xac10, 0x8c10, 0xac10, 0x8020, 37 }, 38 upcase: 39 { 40 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 41 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 42 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 43 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 44 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 45 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 46 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 47 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 48 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 49 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 50 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 51 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 52 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 53 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 54 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 55 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, 56 }, 57 locase: 58 { 59 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 60 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 61 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 62 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 63 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 64 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 65 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 66 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 67 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 68 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 69 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 70 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 71 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 72 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 73 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 74 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, 75 }, 76 mbcsprefix: 77 { 78 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 79 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 80 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 81 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 82 }, 83 uconv: 0, 84 locale: 0, 85 mbcs: 0x0 34 /* Character case conversion tables. */ 35 __LIBC_LOCALECTYPE __libc_GLocaleCtype = 36 { 37 .auchUpper = 38 { 39 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 40 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 41 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 42 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 43 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 44 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 45 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 46 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 47 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 48 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 49 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 50 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 51 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 52 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 53 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 54 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, 55 }, 56 .auchLower = 57 { 58 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 59 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 60 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 61 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 62 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 63 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 64 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 65 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 66 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 67 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 68 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 69 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 70 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 71 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 72 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 73 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, 74 }, 75 .ausfType = 76 { 77 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 78 0x8020, 0x8068, 0x8028, 0x8028, 0x8028, 0x8028, 0x8020, 0x8020, 79 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 80 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 0x8020, 81 0x8848, 0x8c10, 0x8c10, 0x8c10, 0xac10, 0x8c10, 0x8c10, 0x8c10, 82 0x8c10, 0x8c10, 0x8c10, 0xac10, 0x8c10, 0x8c10, 0x8c10, 0x8c10, 83 0x9e84, 0x9e84, 0x9e84, 0x9e84, 0x9e84, 0x9e84, 0x9e84, 0x9e84, 84 0x9e84, 0x9e84, 0x8c10, 0x8c10, 0xac10, 0xac10, 0xac10, 0x8c10, 85 0x8c10, 0x8f81, 0x8f81, 0x8f81, 0x8f81, 0x8f81, 0x8f81, 0x8f01, 86 0x8f01, 0x8f01, 0x8f01, 0x8f01, 0x8f01, 0x8f01, 0x8f01, 0x8f01, 87 0x8f01, 0x8f01, 0x8f01, 0x8f01, 0x8f01, 0x8f01, 0x8f01, 0x8f01, 88 0x8f01, 0x8f01, 0x8f01, 0x8c10, 0x8c10, 0x8c10, 0xac10, 0x8c10, 89 0xac10, 0x8f82, 0x8f82, 0x8f82, 0x8f82, 0x8f82, 0x8f82, 0x8f02, 90 0x8f02, 0x8f02, 0x8f02, 0x8f02, 0x8f02, 0x8f02, 0x8f02, 0x8f02, 91 0x8f02, 0x8f02, 0x8f02, 0x8f02, 0x8f02, 0x8f02, 0x8f02, 0x8f02, 92 0x8f02, 0x8f02, 0x8f02, 0x8c10, 0xac10, 0x8c10, 0xac10, 0x8020, 93 }, 94 .au2MBCSPrefixs = 95 { 96 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 97 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 98 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 99 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 100 }, 101 .uobj = 0, 102 .lobj = 0, 103 .mbcs = 0 86 104 }; 105 87 106 88 107 89 108 #undef tolower 90 109 int tolower(int _c) 91 { return __locale_ctype.locase [_c & 0xff]; } 110 { 111 return __libc_GLocaleCtype.auchLower[_c & 0xff]; 112 } 113 #undef __tolower 92 114 int __tolower(int _c) 93 { return __locale_ctype.locase [_c & 0xff]; } 115 { 116 return __libc_GLocaleCtype.auchLower[_c & 0xff]; 117 } 94 118 95 119 #undef toupper 96 120 int toupper(int _c) 97 { return __locale_ctype.upcase [_c & 0xff]; } 121 { 122 return __libc_GLocaleCtype.auchUpper[_c & 0xff]; 123 } 124 #undef __toupper 98 125 int __toupper(int _c) 99 { return __locale_ctype.upcase [_c & 0xff]; } 100 126 { 127 return __libc_GLocaleCtype.auchUpper[_c & 0xff]; 128 } 129 130 #undef __istype 101 131 int __istype(int _c, unsigned _f) 102 { return __locale_ctype.cflags [_c & 0xff] & (_f); } 103 104 105 106 107 #if 0 /* code for regenerating that table. */ 108 109 #define __INTERNAL_DEFS 110 #include <locale.h> 111 #include <ctype.h> 132 { 133 return (__libc_GLocaleCtype.ausfType[_c & 0xff] & (_f)) != 0; 134 } 135 136 137 138 139 140 #if 0 /* code for regenerating that table - link staticly! */ 141 142 #include <InnoTekLIBC/locale.h> 112 143 #include <stdio.h> 113 144 … … 117 148 setlocale(LC_CTYPE, "en_US"); 118 149 setlocale(LC_CTYPE, "C"); 119 printf("/*\n" 120 " Locale support implementation through OS/2 Unicode API.\n" 121 " Copyright (c) 2003 InnoTek Systemberatung GmbH\n" 122 "\n" 123 " For conditions of distribution and use, see the file COPYING.\n" 124 "\n" 125 " Default character type bits for \"C\" locale.\n" 126 "*/\n" 127 "\n" 128 "#define __INTERNAL_DEFS\n" 129 "#define _DONT_USE_CTYPE_INLINE_\n" 130 "#include \"libc-alias.h\"\n" 131 "#include <sys/locale.h>\n" 132 "#include <ctype.h>\n" 133 "\n" 134 "\n" 135 "struct __locale_ctype __locale_ctype =\n" 136 "{\n" 137 " cflags:\n" 138 " {"); 139 for (i = 0; i < /*sizeof(__locale_ctype.cflags) / sizeof(__locale_ctype.cflags[0])*/ 128; i++) 150 printf("{\n" 151 " .auchUpper =\n" 152 " {"); 153 for (i = 0; i < sizeof(__libc_GLocaleCtype.auchUpper) / sizeof(__libc_GLocaleCtype.auchUpper[0]); i++) 154 { 155 if (i % 16) 156 printf("0x%02x, ", (int)__libc_GLocaleCtype.auchUpper[i]); 157 else 158 printf("\n 0x%02x, ", (int)__libc_GLocaleCtype.auchUpper[i]); 159 } 160 printf("\n" 161 " },\n" 162 " .auchLower =\n" 163 " {"); 164 for (i = 0; i < sizeof(__libc_GLocaleCtype.auchLower) / sizeof(__libc_GLocaleCtype.auchLower[0]); i++) 165 { 166 if (i % 16) 167 printf("0x%02x, ", (int)__libc_GLocaleCtype.auchLower[i]); 168 else 169 printf("\n 0x%02x, ", (int)__libc_GLocaleCtype.auchLower[i]); 170 } 171 printf("\n" 172 " },\n" 173 " .ausfType = \n" 174 " {"); 175 for (i = 0; i < 128; i++) 140 176 { 141 177 if (i % 8) 142 printf("0x%04x, ", (int)__locale_ctype.cflags[i]); 143 else 144 printf("\n 0x%04x, ", (int)__locale_ctype.cflags[i]); 145 } 146 printf("\n },\n" 147 " upcase:\n" 148 " {"); 149 for (i = 0; i < sizeof(__locale_ctype.upcase) / sizeof(__locale_ctype.upcase[0]); i++) 178 printf("0x%04x, ", (int)__libc_GLocaleCtype.ausfType[i]); 179 else 180 printf("\n 0x%04x, ", (int)__libc_GLocaleCtype.ausfType[i]); 181 } 182 printf("\n" 183 " },\n" 184 " .au2MBCSPrefixs =\n" 185 " {"); 186 for (i = 0; i < sizeof(__libc_GLocaleCtype.au2MBCSPrefixs) / sizeof(__libc_GLocaleCtype.au2MBCSPrefixs[0]); i++) 150 187 { 151 188 if (i % 16) 152 printf("0x%02x, ", (int)__locale_ctype.upcase[i]); 153 else 154 printf("\n 0x%02x, ", (int)__locale_ctype.upcase[i]); 155 } 156 printf("\n },\n" 157 " locase:\n" 158 " {"); 159 for (i = 0; i < sizeof(__locale_ctype.locase) / sizeof(__locale_ctype.locase[0]); i++) 160 { 161 if (i % 16) 162 printf("0x%02x, ", (int)__locale_ctype.locase[i]); 163 else 164 printf("\n 0x%02x, ", (int)__locale_ctype.locase[i]); 165 } 166 printf("\n },\n" 167 " mbcsprefix:\n" 168 " {"); 169 for (i = 0; i < sizeof(__locale_ctype.mbcsprefix) / sizeof(__locale_ctype.mbcsprefix[0]); i++) 170 { 171 if (i % 16) 172 printf("0x%02x, ", (int)__locale_ctype.mbcsprefix[i]); 173 else 174 printf("\n 0x%02x, ", (int)__locale_ctype.mbcsprefix[i]); 175 } 176 printf("\n },\n" 177 " uconv: 0,\n" 178 " locale: 0,\n" 179 " mbcs: 0x%x\n" 189 printf("0x%02x, ", (int)__libc_GLocaleCtype.au2MBCSPrefixs[i]); 190 else 191 printf("\n 0x%02x, ", (int)__libc_GLocaleCtype.au2MBCSPrefixs[i]); 192 } 193 printf("\n" 194 " },\n" 195 " .uobj = 0,\n" 196 " .lobj = 0,\n" 197 " .mbcs = %d\n" 180 198 "};\n", 181 (int)__l ocale_ctype.mbcs);199 (int)__libc_GLocaleCtype.mbcs); 182 200 183 201 return 0; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/locale/locale_lconv.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r1453 r1454 1 /* 2 Locale support implementation through OS/2 Unicode API. 3 Copyright (c) 2003 InnoTek Systemberatung GmbH 1 /* $Id$ */ 2 /** @file 3 * 4 * Locale - lconv data. 5 * 6 * Copyright (c) 2003 InnoTek Systemberatung GmbH 7 * 8 * 9 * This file is part of InnoTek LIBC. 10 * 11 * InnoTek LIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * InnoTek LIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with InnoTek LIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 4 26 5 For conditions of distribution and use, see the file COPYING. 6 7 Global locale information structure. 8 */ 9 10 #define __INTERNAL_DEFS 11 #include <sys/locale.h> 27 #include <InnoTekLIBC/locale.h> 12 28 #include <limits.h> 13 29 14 struct lconv __locale_lconv = 30 /* Locale information structure. */ 31 __LIBC_LOCALELCONV __libc_gLocaleLconv = 15 32 { 16 ".", "", "", 17 "", "", "", "", "", "", "-", 18 CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX, 19 CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX 33 .s = 34 { 35 ".", //*decimal_point; /** non-monetary decimal point */ 36 "", //*thousands_sep; /** non-monetary thousands separator */ 37 "", //*grouping; /** non-monetary size of grouping */ 38 "", //*int_curr_symbol; /** international currency symbol and separator */ 39 "", //*currency_symbol; /** local currency symbol */ 40 "", //*mon_decimal_point; /** monetary decimal point */ 41 "", //*mon_thousands_sep; /** monetary thousands separator */ 42 "", //*mon_grouping; /** monetary size of grouping */ 43 "", //*positive_sign; /** non-negative values sign */ 44 "-", //*negative_sign; /** negative values sign */ 45 CHAR_MAX, //int_frac_digits; /** number of fractional digits - int currency */ 46 CHAR_MAX, //frac_digits; /** number of fractional digits - local currency */ 47 CHAR_MAX, //p_cs_precedes; /** (non-neg curr sym) 1-precedes, 0-succeeds */ 48 CHAR_MAX, //p_sep_by_space; /** (non-neg curr sym) 1-space, 0-no space */ 49 CHAR_MAX, //n_cs_precedes; /** (neg curr sym) 1-precedes, 0-succeeds */ 50 CHAR_MAX, //n_sep_by_space; /** (neg curr sym) 1-space, 0-no space */ 51 CHAR_MAX, //p_sign_posn; /** positioning of non-negative monetary sign */ 52 CHAR_MAX //n_sign_posn; /** positioning of negative monetary sign */ 53 }, 54 55 .fNumericConsts = 1, 56 .fMonetaryConsts = 1 20 57 }; 58 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/locale/locale_time.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 1 /* 2 Locale support implementation through OS/2 Unicode API. 3 Copyright (c) 2003 InnoTek Systemberatung GmbH 1 /* $Id$ */ 2 /** @file 3 * 4 * Locale - time data. 5 * 6 * Copyright (c) 2003 InnoTek Systemberatung GmbH 7 * 8 * 9 * This file is part of InnoTek LIBC. 10 * 11 * InnoTek LIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * InnoTek LIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with InnoTek LIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 4 26 5 For conditions of distribution and use, see the file COPYING. 27 #include <InnoTekLIBC/locale.h> 6 28 7 Locale-dependent time formatting strings. 8 */ 9 10 #define __INTERNAL_DEFS 11 #include <sys/locale.h> 12 13 struct __locale_time __locale_time = 29 /** Date / time formatting rules. */ 30 __LIBC_LOCALETIME __libc_gLocaleTime = 14 31 { 15 smonths: { "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"}, 16 lmonths: { "January","February","March","April","May","June","July","August","September","October","November","December" }, 17 swdays: { "Sun","Mon","Tue","Wed","Thu","Fri","Sat" }, 18 lwdays: { "Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday" }, 19 date_time_fmt: "%a %b %d %H:%M:%S %Y", 20 date_fmt: "%m/%d/%y", 21 time_fmt: "%H:%M:%S", 22 am: "AM", 23 pm: "PM" 32 .smonths = { "Jan", "Feb", "Mar", "Apr", "May","Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, 33 .lmonths = { "January","February","March","April","May","June","July","August","September","October","November","December" }, 34 .swdays = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }, 35 .lwdays = { "Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday" }, 36 .date_time_fmt = "%a %b %d %H:%M:%S %Y", 37 .date_fmt = "%m/%d/%y", 38 .time_fmt = "%H:%M:%S", 39 .am = "AM", 40 .pm = "PM", 41 .fConsts = 1 24 42 }; 25 43 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/locale/localeconv.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r1453 r1454 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 Return the address of the (static) locale information structure. 8 */ 1 /* $Id$ */ 2 /** @file 3 * 4 * localeconv(). 5 * 6 * Copyright (c) 2003 InnoTek Systemberatung GmbH 7 * 8 * 9 * This file is part of InnoTek LIBC. 10 * 11 * InnoTek LIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * InnoTek LIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with InnoTek LIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 9 26 10 27 #define __INTERNAL_DEFS 11 28 #include "libc-alias.h" 12 29 #include <locale.h> 13 #include < sys/locale.h>30 #include <InnoTekLIBC/locale.h> 14 31 15 struct lconv *_STD(localeconv) (void) 32 /** 33 * Return the address of the (static) locale information structure. 34 */ 35 struct lconv *_STD(localeconv)(void) 16 36 { 17 return &__locale_lconv;37 return &__libc_gLocaleLconv.s; 18 38 } 39 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/locale/setlocale.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1453 r1454 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 Implementation of the setlocale() function. 8 */ 9 10 #define __INTERNAL_DEFS 1 /* $Id$ */ 2 /** @file 3 * 4 * Locale support implementation through OS/2 Unicode API. 5 * 6 * Implementation of the setlocale() function. 7 * 8 * 9 * Copyright (c) 2003 InnoTek Systemberatung GmbH 10 * Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net> 11 * 12 * 13 * This file is part of InnoTek LIBC. 14 * 15 * InnoTek LIBC is free software; you can redistribute it and/or modify 16 * it under the terms of the GNU General Public License as published by 17 * the Free Software Foundation; either version 2 of the License, or 18 * (at your option) any later version. 19 * 20 * InnoTek LIBC is distributed in the hope that it will be useful, 21 * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 * GNU General Public License for more details. 24 * 25 * You should have received a copy of the GNU General Public License 26 * along with InnoTek LIBC; if not, write to the Free Software 27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 28 * 29 */ 30 31 32 /******************************************************************************* 33 * Header Files * 34 *******************************************************************************/ 11 35 #include "libc-alias.h" 12 #include <locale.h> 13 #include <sys/locale.h> 36 #include <InnoTekLIBC/locale.h> /* must be included before ctype. */ 37 #include <ctype.h> 38 14 39 #include <stdlib.h> 40 15 41 #include <alloca.h> 16 42 #include <string.h> 17 43 #include <errno.h> 18 #include <ctype.h>19 44 #include <386/builtin.h> 20 45 #include <sys/param.h> 21 46 #include <sys/smutex.h> 47 #include <InnoTekLIBC/errno.h> 48 #include <InnoTekLIBC/fork.h> 22 49 23 50 #define INCL_DOS … … 27 54 #include <uconv.h> 28 55 29 /* Instead of strcmp since it's faster */ 30 #define IS_C_LOCALE(s) (((s) [0] == 'C') && (!(s) [1])) 31 32 /* The order of locale categories must equal those in <locale.h> */ 33 static char *locale_cat = 34 "LC_COLLATE\0LC_CTYPE\0LC_MONETARY\0LC_NUMERIC\0LC_TIME\0LC_MESSAGES\0"; 35 36 extern void __convert_codepage (const char *cp, UniChar *ucp); 37 38 /* Structure used while sorting codepage characters by their weights. */ 56 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_LOCALE 57 #include <InnoTekLIBC/logstrict.h> 58 59 60 /******************************************************************************* 61 * Defined Constants And Macros * 62 *******************************************************************************/ 63 /** Instead of strcmp since it's faster. */ 64 #define IS_C_LOCALE(s) (((s)[0] == 'C') && (!(s)[1])) 65 /** For simplisity. */ 66 #define IS_POSIX_LOCALE(s) ( (s)[0] == 'P' \ 67 && (s)[1] == 'O' \ 68 && (s)[2] == 'S' \ 69 && (s)[3] == 'I' \ 70 && (s)[4] == 'X' \ 71 && (s)[5] == '\0' ) 72 /** Max lenght we anticipate of a codepage name. */ 73 #define CODEPAGE_MAX_LENGTH 64 74 75 /******************************************************************************* 76 * Structures and Typedefs * 77 *******************************************************************************/ 78 /** Structure used while sorting codepage characters by their weights. */ 39 79 struct __collate_weight 40 80 { 41 /* Character code. */42 unsigned char code;43 /* Actual weight length. */44 unsigned char len;45 /* The weight itself. */46 UniChar weight[7];81 /* Character code. */ 82 unsigned char code; 83 /* Actual weight length. */ 84 unsigned char len; 85 /* The weight itself. */ 86 UniChar ucsWeight[7]; 47 87 }; 48 88 49 static int convert_ucs (UconvObject uconv_obj, UniChar *in, char **out) 50 { 51 size_t usl = UniStrlen (in) + 1; 52 /* Allocate twice as much as we need - just in case every character is DBCS 53 or desired encoding is UCS-2. */ 54 size_t osl = usl * 2; 55 size_t in_left = usl; 56 size_t nonid, out_left = osl; 57 char *tmp = malloc (osl); 58 UniChar *inbuf = in; 59 void *outbuf = tmp; 60 int try_count = 0; 61 FS_VAR(); 62 63 FS_SAVE_LOAD(); 64 try_again: 65 66 if (try_count > 10) 67 { 68 /* Well... nobody will say we gave it no chance ... */ 69 free(tmp); 70 FS_RESTORE(); 71 return -1; 72 } 73 74 switch (UniUconvFromUcs (uconv_obj, &inbuf, &in_left, &outbuf, &out_left, &nonid)) 75 { 76 case 0: 77 break; 78 79 case UCONV_E2BIG: 80 /* Out buffer too small, make one larger */ 81 inbuf = in; in_left = usl; 82 out_left = (osl *= 2); 83 outbuf = tmp = realloc (tmp, osl); 84 try_count++; 85 goto try_again; 86 87 default: 88 /* Unexpected error. */ 89 free (tmp); 90 FS_RESTORE(); 91 return -1; 92 } 93 94 usl = (char *)outbuf - (char *)tmp; 95 (*out) = (char *)malloc (usl); 96 memcpy (*out, tmp, usl); 97 free (tmp); 98 FS_RESTORE(); 99 100 return 0; 101 } 102 103 static void setname (int category, const char *value, int noalloc) 104 { 105 /* LC_ALL is -1. */ 106 category++; 107 if (__locale.name [category] && (__locale.name [category] != __locale_C)) 108 free (__locale.name [category]); 109 __locale.name [category] = noalloc ? (char *)value : strdup (value); 110 } 111 112 static int query_array (LocaleObject locale_obj, UconvObject uconv_obj, 113 int count, LocaleItem first, char **out) 114 { 115 UniChar *item; 116 int idx; 117 118 for (idx = 0; idx < count; idx++) 119 if (UniQueryLocaleItem (locale_obj, first + idx, &item) 120 || convert_ucs (uconv_obj, item, &out [idx])) 121 return -1; 122 123 return 0; 124 } 125 126 #define FREE(x) { if (x) free (x); } 127 128 static void free_time (struct __locale_time *loc_time) 129 { 130 int i; 131 132 for (i = 0; i < 12; i++) 133 { 134 FREE (__locale_time.smonths [i]); 135 FREE (__locale_time.lmonths [i]); 136 } 137 138 for (i = 0; i < 7; i++) 139 { 140 FREE (__locale_time.swdays [i]); 141 FREE (__locale_time.lwdays [i]); 142 } 143 144 FREE (__locale_time.date_time_fmt); 145 FREE (__locale_time.date_fmt); 146 FREE (__locale_time.time_fmt); 147 FREE (__locale_time.am); 148 FREE (__locale_time.pm); 149 } 150 151 static void free_numeric (struct lconv *lconv) 152 { 153 FREE (lconv->decimal_point); 154 FREE (lconv->thousands_sep); 155 FREE (lconv->grouping); 156 } 157 158 static void free_monetary (struct lconv *lconv) 159 { 160 FREE (lconv->int_curr_symbol); 161 FREE (lconv->currency_symbol); 162 FREE (lconv->mon_decimal_point); 163 FREE (lconv->mon_thousands_sep); 164 FREE (lconv->mon_grouping); 165 FREE (lconv->positive_sign); 166 FREE (lconv->negative_sign); 167 } 168 169 static unsigned char Transform (LocaleObject locale_obj, UconvObject uconv_obj, 170 UniChar (*TransFunc) (LocaleObject, UniChar), UniChar c, unsigned char fallback) 171 { 172 unsigned char sbcs; 173 int nb = __from_ucs (uconv_obj, TransFunc (locale_obj, c), &sbcs, 1); 174 return (nb == 1) ? sbcs : fallback; 175 } 176 177 static int cw_cmp (struct __collate_weight *w1, struct __collate_weight *w2) 178 { 179 return UniStrncmp (w1->weight, w2->weight, MIN (w1->len, w2->len)); 180 } 181 182 static void Ucs2Sb (UniChar *ucs, char *sbs, size_t sl) 183 { 184 while (sl--) 185 *sbs++ = *ucs++; 186 } 187 188 static int query_mbcs (UconvObject uconv_obj, char *mbcs, 189 unsigned char *mbcsprefix, int *mb_cur_max) 190 { 191 unsigned i; 192 uconv_attribute_t uconv_attr; 193 unsigned char seqlen [256]; 194 195 if (UniQueryUconvObject (uconv_obj, &uconv_attr, sizeof (uconv_attr), 196 seqlen, NULL, NULL)) 197 return -1; 198 199 if (mb_cur_max) 200 *mb_cur_max = uconv_attr.mb_max_len; 201 *mbcs = (uconv_attr.mb_max_len > 1); 202 203 memset (mbcsprefix, 0, 256/4); 204 for (i = 0; i < 256; i++) 205 if (seqlen [i] != 255) 206 SET_MBCS_PREFIX (mbcsprefix, i, seqlen [i]); 207 208 return 0; 209 } 210 211 #define ERROR(code) { errno = code; ret = NULL; goto normal_exit; } 212 #define ERROR2(code) { _smutex_release (&__locale.lock); ERROR (code); } 213 214 char *_STD(setlocale) (int category, const char *locale) 215 { 216 LocaleObject locale_obj = 0; 217 UconvObject uconv_obj = 0; 218 UniChar cpbuff [16]; 219 struct UniLconv *Lconv; 220 char *x, *l, *m; 221 size_t sl; 222 char *ret = NULL; 223 int i,def_val; 224 225 /* Sanity check. */ 226 if (category >= __LC_COUNT) 227 { 228 errno = EINVAL; 229 return NULL; 230 } 231 232 /* Check if user just queries current locale. */ 233 if (!locale) 234 return __locale.name [category + 1]; 235 236 /* Check if user wants we to do the same job twice. */ 237 if (strcmp (locale, __locale.name [category + 1]) == 0) 238 /* We have to return the value of LC_ALL */ 239 return __locale.name [0]; 240 241 /* We'll use OS/2 Unicode API to query all interesting information. 242 But it works only with Unicode strings, so we have to convert all 243 input information to UCS-2 and all output information from UCS-2. */ 244 245 /* Copy locale to a local storage since we'll modify it during parsing. 246 If locale value is a empty string, user wants the defaults fetched from 247 environment. */ 248 def_val = (locale [0] == 0); 249 if (def_val) 250 { 251 char *env_val, *cur_cat = locale_cat; 252 int cat; 253 254 if (category == LC_ALL) 255 /* Not in list */ 256 cur_cat = "LC_ALL"; 89 90 /** 91 * There is one global object of this type that contains integral 92 * information about last selected (with setlocale()) locale. 93 * The locale information itself is split into parts to avoid linking 94 * unused data into programs that use just the "C" locale and just 95 * a few functions that use locale data (such as strdate()). 96 */ 97 typedef struct __libc_LocaleGlobal 98 { 99 /** Category names. */ 100 char *apszNames[_LC_LAST + 1]; 101 /* Lock for multi-threaded operations. */ 102 _smutex lock; 103 } __LIBC_LOCALEGLOBAL, *__LIBC_PLOCALEGLOBAL; 104 105 106 /** 107 * Internal working structure which we modify while 108 * performing the setlocale() operation. 109 */ 110 struct temp_locale 111 { 112 /** Which we have processed.*/ 113 int afProcessed[_LC_LAST + 1]; 114 /** The global data. */ 115 __LIBC_LOCALEGLOBAL Global; 116 /** Collate data. */ 117 __LIBC_LOCALECOLLATE Collate; 118 /** Ctype data. */ 119 __LIBC_LOCALECTYPE Ctype; 120 /** Time data. */ 121 __LIBC_LOCALETIME Time; 122 /** Numeric and monetary data. */ 123 __LIBC_LOCALELCONV Lconv; 124 }; 125 126 127 /******************************************************************************* 128 * Global Variables * 129 *******************************************************************************/ 130 /** Array of local categories. Use their defined value + 1 as index (LC_ALL is -1). */ 131 static const char gaszCategories[_LC_LAST + 1][16] = 132 { 133 "LC_ALL", /* -1 */ 134 "LC_COLLATE", /* 0 */ 135 "LC_CTYPE", 136 "LC_MONETARY", 137 "LC_NUMERIC", 138 "LC_TIME", 139 "LC_MESSAGES" 140 }; 141 /** Array of the lengths corresponding to the entries in the above array. */ 142 static const unsigned char gacchCategories[_LC_LAST + 1] = 143 { 144 sizeof("LC_ALL") - 1, 145 sizeof("LC_COLLATE") - 1, 146 sizeof("LC_CTYPE") - 1, 147 sizeof("LC_MONETARY") - 1, 148 sizeof("LC_NUMERIC") - 1, 149 sizeof("LC_TIME") - 1, 150 sizeof("LC_MESSAGES") - 1 151 }; 152 153 /** "C" string. */ 154 static const char gszC[] = "C"; 155 156 /** "POSIX" string. */ 157 static const char gszPOSIX[] = "POSIX"; 158 159 /** The currnet locale specifications. */ 160 static __LIBC_LOCALEGLOBAL gLocale = 161 { 162 .apszNames = 163 { 164 (char *)gszC, /* LC_ALL */ 165 (char *)gszC, /* LC_COLLATE */ 166 (char *)gszC, /* LC_CTYPE */ 167 (char *)gszC, /* LC_NUMERIC */ 168 (char *)gszC, /* LC_MONETARY */ 169 (char *)gszC, /* LC_TIME */ 170 (char *)gszC /* LC_MESSAGES */ 171 }, 172 .lock = 0 173 }; 174 175 /** "ISO8859-1" UniChar string. */ 176 static const UniChar gucsISO8859_1[] = {'I', 'S', 'O', '8', '8', '5', '9', '-', '1', '\0' }; 177 178 /** @page pg_env 179 * @subsection pg_env_sub1_LIBC_SETLOCALE_OLDSTYLE LIBC_SETLOCALE_OLDSTYLE 180 * 181 * When the LIBC_SETLOCALE_OLDSTYLE environment variable is present in the 182 * environemnt LIBC will ask OS/2 about the country and codepage so the right 183 * default locale can be found when none of the POSIX variables are present. 184 * 185 * The default behaviour (i.e. when LIBC_SETLOCALE_OLDSTYLE is not present) is 186 * to use the 'C' locale if none of the LANG or LC_* variables can be found. 187 */ 188 189 /** Whether or not to use the old style where we query extra stuff from OS/2. 190 * The new style is more conforming to POSIX and with VAC. 191 * The presense of LIBC_SETLOCALE_OLDSTYLE forces the old style. 192 * 193 * If the value is negative Then init is required. 194 */ 195 static int gfOldStyle = -1; 196 197 198 /******************************************************************************* 199 * Internal Functions * 200 *******************************************************************************/ 201 static int unierr2errno(int rc); 202 static int convert_ucs(UconvObject uobj, UniChar *in, char **out); 203 static void Ucs2Sb(UniChar *ucs, char *sbs, size_t cch); 204 static const char *getDefaultLocale(const char *pszCategory, char *pszBuffer, int *pfDefault); 205 static int getCodepage(const char *pszCodepage, const char *pszLocale, LocaleObject lobj, UniChar *pucsCodepage, unsigned cucCodepage); 206 static int query_mbcs(UconvObject uobj, char *mbcs, unsigned char *au2MBCSPrefixs, int *pmb_cur_max); 207 208 static int localeCollateDo(__LIBC_PLOCALECOLLATE pCollate, UconvObject uobj, LocaleObject lobj); 209 static void localeCollateFree(__LIBC_PLOCALECOLLATE pCollate); 210 static inline unsigned char Transform(LocaleObject lobj, UconvObject uobj, 211 UniChar (*pfnTransFunc) (LocaleObject, UniChar), 212 UniChar uc, unsigned char uchFallback); 213 static int localeCtypeDo(__LIBC_PLOCALECTYPE pCtype, UconvObject uobj, LocaleObject lobj, const char *pszLocale); 214 static void localeCtypeFree(__LIBC_PLOCALECTYPE pCtype); 215 static int query_item(LocaleObject lobj, UconvObject uobj, LocaleItem iItem, char **ppszOut); 216 static int query_array(LocaleObject lobj, UconvObject uobj, int cElements, LocaleItem iFirst, char **papszOut); 217 static int localeTimeDo(__LIBC_PLOCALETIME pTime, UconvObject uobj, LocaleObject lobj); 218 static void localeTimeFree(__LIBC_PLOCALETIME pTime); 219 static void localeNumericFree(__LIBC_PLOCALELCONV pLconv); 220 static void localeMonetaryFree(__LIBC_PLOCALELCONV pLconv); 221 static int localeNumericDo(__LIBC_PLOCALELCONV pLconv, UconvObject uobj, struct UniLconv *pULconv); 222 static int localeMonetaryDo(__LIBC_PLOCALELCONV pLconv, UconvObject uobj, struct UniLconv *pULconv); 223 static void localeGlobalFree(__LIBC_PLOCALEGLOBAL pGlobal, int iCategory); 224 static int localeCreateObjects(const char *pszLocale, const char *pszCodepage, char *pszCodepageActual, LocaleObject *plobj, UconvObject *puobj); 225 static int localeParseLocale(char *pszLocale, const char **ppszCodepage); 226 static int localeDoOne(struct temp_locale *pTemp, int iCategory, const char *pszLocale, const char *pszCodepage); 227 static int localeDo(struct temp_locale *pTemp, int iCategory, char *pszLocale, int fDefaultValue); 228 static char *localeCommit(struct temp_locale *pTemp, int iCategory); 229 static void localeFree(struct temp_locale *pTemp); 230 231 static int setlocalForkChild1(__LIBC_PFORKHANDLE pForkHandle, __LIBC_FORKOP enmOperation); 232 233 234 235 236 237 238 /** 239 * Converts from Uni api error code to errno. 240 * 241 * @returns errno 242 * @param rc Uni api error code. 243 */ 244 static int unierr2errno(int rc) 245 { 246 switch (rc) 247 { 248 case ULS_SUCCESS: return 0; 249 case ULS_MAXFILESPERPROC: return -EMFILE; 250 case ULS_MAXFILES: return -ENFILE; 251 case ULS_BADOBJECT: return -EBADF; 252 case ULS_BADHANDLE: return -EBADF; 253 case ULS_NOTIMPLEMENTED: return -ENOSYS; 254 case ULS_RANGE: return -ERANGE; 255 case ULS_NOMEMORY: return -ENOMEM; 256 case ULS_OTHER: 257 case ULS_ILLEGALSEQUENCE: 258 case ULS_NOOP: 259 case ULS_TOOMANYKBD: 260 case ULS_KBDNOTFOUND: 261 case ULS_NODEAD: 262 case ULS_NOSCAN: 263 case ULS_INVALIDSCAN: 264 case ULS_INVALID: 265 case ULS_NOTOKEN: 266 case ULS_NOMATCH: 267 case ULS_BUFFERFULL: 268 case ULS_UNSUPPORTED: 269 case ULS_BADATTR: 270 case ULS_VERSION: 271 default: 272 return -EINVAL; 273 } 274 } 275 276 static int convert_ucs(UconvObject uobj, UniChar *in, char **out) 277 { 278 size_t usl = UniStrlen (in) + 1; 279 /* Allocate twice as much as we need - just in case every character is DBCS 280 or desired encoding is UCS-2. */ 281 size_t osl = usl * 2; 282 size_t in_left = usl; 283 size_t nonid, out_left = osl; 284 char *tmp = malloc (osl); 285 UniChar *inbuf = in; 286 void *outbuf = tmp; 287 int try_count = 0; 288 FS_VAR(); 289 290 FS_SAVE_LOAD(); 291 try_again: 292 293 if (try_count > 10) 294 { 295 /* Well... nobody will say we gave it no chance ... */ 296 free(tmp); 297 FS_RESTORE(); 298 return -1; 299 } 300 301 switch (UniUconvFromUcs (uobj, &inbuf, &in_left, &outbuf, &out_left, &nonid)) 302 { 303 case 0: 304 break; 305 306 case UCONV_E2BIG: 307 /* Out buffer too small, make one larger */ 308 inbuf = in; in_left = usl; 309 out_left = (osl *= 2); 310 outbuf = tmp = realloc (tmp, osl); 311 try_count++; 312 goto try_again; 313 314 default: 315 /* Unexpected error. */ 316 free (tmp); 317 FS_RESTORE(); 318 return -1; 319 } 320 321 usl = (char *)outbuf - (char *)tmp; 322 (*out) = (char *)malloc (usl); 323 memcpy (*out, tmp, usl); 324 free (tmp); 325 FS_RESTORE(); 326 327 return 0; 328 } 329 330 static void Ucs2Sb(UniChar *ucs, char *sbs, size_t cch) 331 { 332 while (cch--) 333 *sbs++ = *ucs++; 334 } 335 336 337 static int query_mbcs(UconvObject uobj, char *mbcs, unsigned char *au2MBCSPrefixs, int *pmb_cur_max) 338 { 339 unsigned i; 340 uconv_attribute_t uconv_attr; 341 unsigned char uchSeqlen[256]; 342 int rc; 343 344 /* 345 * Query data. 346 */ 347 rc = UniQueryUconvObject(uobj, &uconv_attr, sizeof(uconv_attr), (char *)&uchSeqlen[0], NULL, NULL); 348 if (rc) 349 return -unierr2errno(rc); 350 351 /* 352 * Create the return values. 353 */ 354 if (pmb_cur_max) 355 *pmb_cur_max = uconv_attr.mb_max_len; 356 *mbcs = (uconv_attr.mb_max_len > 1); 357 358 memset(au2MBCSPrefixs, 0, 256/4); 359 for (i = 0; i < 256; i++) 360 if (uchSeqlen[i] != 255) 361 SET_MBCS_PREFIX(au2MBCSPrefixs, i, uchSeqlen[i]); 362 363 return 0; 364 } 365 366 /** 367 * Sets the LC_COLLATE part of the locale. 368 * 369 * @returns 0 on success. 370 * @returns negated errno on failure. 371 * @param pCollate The collate structure to operate on. 372 * @param uobj The UconvObject to use. Collate is responsible for freeing it. 373 * @param lobj The LocaleObject to use. Collate is responsible for freeing it. 374 */ 375 static int localeCollateDo(__LIBC_PLOCALECOLLATE pCollate, UconvObject uobj, LocaleObject lobj) 376 { 377 int rc; 378 379 /* Cleanup in case of some special LC_ALL call. */ 380 localeCollateFree(pCollate); 381 382 /* 383 * Query multi-byte related stuff. 384 */ 385 rc = query_mbcs(uobj, &pCollate->mbcs, &pCollate->au2MBCSPrefixs[0], NULL); 386 if (rc) 387 return rc; 388 389 if (&pCollate->mbcs) 390 { 391 /* 392 * In MBCS mode we just borrow the conversion and locale objects 393 * and leave the real work to the Unicode subsystem. 394 */ 395 pCollate->lobj = lobj; 396 pCollate->uobj = uobj; 397 } 257 398 else 258 for (cat = 0; cat != category; cat++) 259 cur_cat = strchr (cur_cat, 0) + 1; 260 261 env_val = getenv (cur_cat); 262 if (env_val) 263 locale = env_val; 399 { 400 /* 401 * In SBCS we query the weight of every character and use the 402 * weights directly, without the need to invoke the Unicode API. 403 */ 404 struct __collate_weight aCW[256]; 405 int i, j; 406 407 /* Initialize character weights. */ 408 for (i = 0; i < 256; i++) 409 { 410 UniChar ucs[2]; 411 if (!__libc_ucs2To(uobj, (unsigned char *)&i, 1, &ucs[0])) 412 { 413 LIBC_ASSERTM_FAILED("__libc_ucs2To failed for char %d\n", i); 414 ucs[0] = (UniChar)i; 415 } 416 ucs[1] = '\0'; 417 418 aCW[i].code = i; 419 aCW[i].len = UniStrxfrm(lobj, aCW[i].ucsWeight, &ucs[0], sizeof(aCW[i].ucsWeight) / sizeof(aCW[i].ucsWeight[0])); 420 if (aCW[i].len >= sizeof(aCW[i].ucsWeight) / sizeof(aCW[i].ucsWeight[0])) 421 { 422 LIBC_ASSERTM_FAILED("This cannot happen... :-) i=%d len=%d \n", i, aCW[i].len); 423 aCW[i].len = sizeof(aCW[i].ucsWeight) / sizeof(aCW[i].ucsWeight[0]); 424 } 425 } 426 427 /* 428 * Do bubble sorting since qsort() doesn't guarantee that the order 429 * of equal elements stays the same. 430 */ 431 for (i = 0; i < 256; i++) 432 for (j = i; j < 256; j++) 433 if (UniStrncmp(aCW[j].ucsWeight, aCW[j + 1].ucsWeight, MIN(aCW[j].len, aCW[j + 1].len)) > 0) 434 _memswap(&aCW[j], &aCW[j + 1], sizeof(aCW[j])); 435 436 /* 437 * Store the result. 438 */ 439 for (i = 0; i < 256; i++) 440 pCollate->auchWeight[aCW[i].code] = i; 441 442 /* cleanup */ 443 UniFreeUconvObject(uobj); 444 UniFreeLocaleObject(lobj); 445 } 446 447 return 0; 448 } 449 450 /** 451 * Frees system and CRT resources assocated with a collate structure. 452 * @param pCollate The collate structure. 453 */ 454 static void localeCollateFree(__LIBC_PLOCALECOLLATE pCollate) 455 { 456 /* Free old pszLocale objects, if any */ 457 if (pCollate->uobj) 458 { 459 UniFreeUconvObject(pCollate->uobj); 460 pCollate->uobj = NULL; 461 } 462 if (pCollate->lobj) 463 { 464 UniFreeLocaleObject(pCollate->lobj); 465 pCollate->lobj = NULL; 466 } 467 } 468 469 470 static inline unsigned char Transform(LocaleObject lobj, UconvObject uobj, 471 UniChar (* APIENTRY pfnTransFunc) (LocaleObject, UniChar), 472 UniChar uc, unsigned char uchFallback) 473 { 474 unsigned char sbcs; 475 int nb = __libc_ucs2From(uobj, pfnTransFunc(lobj, uc), &sbcs, 1); 476 return (nb == 1) ? sbcs : uchFallback; 477 } 478 479 480 /** 481 * Sets the LC_TYPE part of the locale. 482 * 483 * @returns 0 on success. 484 * @returns negated errno on failure. 485 * @param pCtype The Ctype structure to operate on. 486 * @param uobj The UconvObject to use. Ctype is responsible for freeing it. 487 * @param lobj The LocaleObject to use. Ctype is responsible for freeing it. 488 */ 489 static int localeCtypeDo(__LIBC_PLOCALECTYPE pCtype, UconvObject uobj, LocaleObject lobj, const char *pszLocale) 490 { 491 int rc; 492 unsigned i; 493 494 /* Cleanup in case of some special LC_ALL call. */ 495 localeCtypeFree(pCtype); 496 497 /* 498 * Query multi-byte related stuff. 499 */ 500 rc = query_mbcs(uobj, &pCtype->mbcs, &pCtype->au2MBCSPrefixs[0], NULL); 501 if (rc) 502 return rc; 503 504 /* 505 * For speeding up isXXX() and lower/upper case mapping functions 506 * we'll cache the type of every character into a variable. 507 * 508 * Do every character separately to avoid errors that could result 509 * when some character in the middle cannot be conerted from or to 510 * Unicode - this would lead in a shift of the entire string. 511 */ 512 for (i = 0; i < 256; i++) 513 { 514 unsigned short usfType = 0; 515 unsigned char uchUpper; 516 unsigned char uchLower; 517 UniChar ucs; 518 519 if (!__libc_ucs2To(uobj, (unsigned char *)&i, 1, &ucs)) 520 ucs = i; 521 522 /* isxxx() do not support DBCS characters at all */ 523 if (!IS_MBCS_PREFIX(pCtype, i)) 524 { 525 /* ASSUMES CT_* == __* ! */ 526 UNICTYPE *pCtype = UniQueryCharType(ucs); 527 if (pCtype) 528 usfType = (pCtype->itype) & (__UPPER | __LOWER | __DIGIT | __SPACE | 529 __PUNCT | __CNTRL | __BLANK | __XDIGIT | 530 __ALPHA | __ALNUM | __GRAPH | __PRINT | 531 __NUMBER | __SYMBOL | __ASCII); 532 uchUpper = Transform(lobj, uobj, UniTransUpper, ucs, i); 533 uchLower = Transform(lobj, uobj, UniTransLower, ucs, i); 534 /** @todo isn't there apis for getting all this at once? */ 535 } 536 else 537 uchUpper = uchLower = i; 538 539 pCtype->ausfType[i] = usfType; 540 pCtype->auchUpper[i] = uchUpper; 541 pCtype->auchLower[i] = uchLower; 542 } 543 544 /* 545 * In the "C" pszLocale second half of the cflags table should be empty. 546 */ 547 if ( IS_C_LOCALE(pszLocale) 548 || IS_POSIX_LOCALE(pszLocale)) 549 { 550 memset(&pCtype->ausfType[128], 0, 128 * sizeof(pCtype->ausfType[0])); 551 for (i = 128; i < 255; i++) 552 { 553 pCtype->auchUpper[i] = i; 554 pCtype->auchLower[i] = i; 555 } 556 } 557 558 /* 559 * Store the objects. 560 */ 561 pCtype->uobj = uobj; 562 if (pCtype->mbcs) 563 { 564 /* 565 * In MBCS mode we just borrow the local object and leave the 566 * real work to the Unicode subsystem. 567 */ 568 pCtype->lobj = lobj; 569 } 264 570 else 265 { 266 env_val = getenv ("LANG"); 267 if (env_val) 268 locale = env_val; 269 else 270 { 271 /* Not specified nor in environment, ask country info */ 272 COUNTRYCODE cc; 273 COUNTRYINFO ci; 274 ULONG il; 275 memset (&cc, 0, sizeof (cc)); 276 memset (&ci, 0, sizeof (ci)); 277 if (DosQueryCtryInfo (sizeof (ci), &cc, &ci, &il)) 571 UniFreeLocaleObject(lobj); 572 573 return 0; 574 } 575 576 577 /** 578 * Frees system and CRT resources assocated with a ctype structure. 579 * @param pCtype The collate structure. 580 */ 581 static void localeCtypeFree(__LIBC_PLOCALECTYPE pCtype) 582 { 583 if (pCtype->uobj) 584 { 585 UniFreeUconvObject(pCtype->uobj); 586 pCtype->uobj = NULL; 587 } 588 if (pCtype->lobj) 589 { 590 UniFreeLocaleObject(pCtype->lobj); 591 pCtype->lobj = NULL; 592 } 593 } 594 595 /** 596 * Query one item from a locale object. 597 */ 598 static int query_item(LocaleObject lobj, UconvObject uobj, LocaleItem iItem, char **ppszOut) 599 { 600 /* 601 * Query item. 602 */ 603 UniChar *pucsItem; 604 int rc = UniQueryLocaleItem(lobj, iItem, &pucsItem); 605 if (rc) 606 { 607 LIBC_ASSERTM_FAILED("UniQueryLocaleItem(,%d,) -> rc=%d\n", iItem, rc); 608 return -unierr2errno(rc); 609 } 610 611 /* 612 * Convert from Ucs2. 613 */ 614 rc = convert_ucs(uobj, pucsItem, ppszOut); 615 616 UniFreeMem(pucsItem); 617 return rc; 618 } 619 620 /** 621 * Query an array of locale string items. 622 */ 623 static int query_array(LocaleObject lobj, UconvObject uobj, int cElements, LocaleItem iFirst, char **papszOut) 624 { 625 int i; 626 for (i = 0; i < cElements; i++) 627 { 628 int rc = query_item(lobj, uobj, iFirst + i, &papszOut[i]); 629 if (rc) 630 return rc; 631 } 632 return 0; 633 } 634 635 /** 636 * Sets the LC_TIME part of the locale. 637 * 638 * @returns 0 on success. 639 * @returns negated errno on failure. 640 * @param pTime The time structure to operate on. 641 * @param uobj The UconvObject to use. 642 * @param lobj The LocaleObject to use. 643 */ 644 static int localeTimeDo(__LIBC_PLOCALETIME pTime, UconvObject uobj, LocaleObject lobj) 645 { 646 int rc; 647 648 /* free old stuff. */ 649 localeTimeFree(pTime); 650 651 /* query the items. */ 652 if ( (rc = query_item( lobj, uobj, D_T_FMT, &pTime->date_time_fmt)) 653 || (rc = query_item( lobj, uobj, D_FMT, &pTime->date_fmt)) 654 || (rc = query_item( lobj, uobj, T_FMT, &pTime->time_fmt)) 655 || (rc = query_item( lobj, uobj, AM_STR, &pTime->am)) 656 || (rc = query_item( lobj, uobj, PM_STR, &pTime->pm)) 657 || (rc = query_array(lobj, uobj, 7, DAY_1, &pTime->lwdays[0])) 658 || (rc = query_array(lobj, uobj, 7, ABDAY_1, &pTime->swdays[0])) 659 || (rc = query_array(lobj, uobj, 12, MON_1, &pTime->lmonths[0])) 660 || (rc = query_array(lobj, uobj, 12, ABMON_1, &pTime->smonths[0])) 661 ) 662 { 663 return rc; 664 } 665 666 return 0; 667 } 668 669 /** 670 * Frees the CRT resources held up by a time structure. 671 * @param pTime The time structure. 672 */ 673 static void localeTimeFree(__LIBC_PLOCALETIME pTime) 674 { 675 if (!pTime->fConsts) 676 { 677 /* 678 * Everything is pointers to heap here! 679 */ 680 char **ppsz = (char **)pTime; 681 char **ppszEnd = (char **)pTime->fConsts; 682 while (ppsz < ppszEnd) 278 683 { 279 ctry_error: 280 locale = "C"; 684 void *pv = *ppsz; 685 if (pv) 686 { 687 free(pv); 688 *ppsz = NULL; 689 } 690 } 691 } 692 pTime->fConsts = 0; 693 } 694 695 696 /** 697 * Frees all heap strings in the monetary part of the lconv structure. 698 * @param pLconv What to work on. 699 */ 700 static void localeNumericFree(__LIBC_PLOCALELCONV pLconv) 701 { 702 #define FREE(x) do { if (pLconv->s.x && !pLconv->fNumericConsts) free(pLconv->s.x); pLconv->s.x = NULL; } while (0) 703 FREE(decimal_point); 704 FREE(thousands_sep); 705 FREE(grouping); 706 pLconv->fNumericConsts = 0; 707 #undef FREE 708 } 709 710 /** 711 * Frees all heap strings in the monetary part of the lconv structure. 712 * @param pLconv What to work on. 713 */ 714 static void localeMonetaryFree(__LIBC_PLOCALELCONV pLconv) 715 { 716 #define FREE(x) do { if (pLconv->s.x && !pLconv->fMonetaryConsts) free(pLconv->s.x); pLconv->s.x = NULL; } while (0) 717 FREE(int_curr_symbol); 718 FREE(currency_symbol); 719 FREE(mon_decimal_point); 720 FREE(mon_thousands_sep); 721 FREE(mon_grouping); 722 FREE(positive_sign); 723 FREE(negative_sign); 724 pLconv->fMonetaryConsts = 0; 725 #undef FREE 726 } 727 728 /** 729 * Converts a grouping array. 730 */ 731 static int localeConvertGrouping(short *pasGrouping, char **pachRet) 732 { 733 short *ps; 734 char *pch; 735 int cch; 736 737 for (cch = 1, ps = pasGrouping; *ps && *ps != -1; ps++) 738 cch++; 739 *pachRet = pch = malloc(cch); 740 if (!pch) 741 return -ENOMEM; 742 for (ps = pasGrouping; cch > 0; cch--) 743 *pch++ = (char)*ps++; 744 745 return 0; 746 } 747 748 /** 749 * Sets the LC_NUMERIC part of the locale. 750 * 751 * @returns 0 on success. 752 * @returns negated errno on failure. 753 * @param pLconv The lconv structure to operate on. 754 * @param uobj The UconvObject to use. 755 * @param pULconv Pointer to the pULconv structure to get the data from. 756 */ 757 static int localeNumericDo(__LIBC_PLOCALELCONV pLconv, UconvObject uobj, struct UniLconv *pULconv) 758 { 759 int rc; 760 /* free any old stuff. */ 761 localeNumericFree(pLconv); 762 763 /* 764 * Convert the stuff. 765 */ 766 #define CONVERT_UCS(field) \ 767 do { rc = convert_ucs(uobj, pULconv->field, &pLconv->s.field); if (rc) return rc; } while (0) 768 CONVERT_UCS(decimal_point); 769 CONVERT_UCS(thousands_sep); 770 #undef CONVERT_UCS 771 772 return localeConvertGrouping(pULconv->grouping, &pLconv->s.grouping); 773 } 774 775 776 /** 777 * Sets the LC_MONETARY part of the locale. 778 * 779 * @returns 0 on success. 780 * @returns negated errno on failure. 781 * @param pLconv The lconv structure to operate on. 782 * @param uobj The UconvObject to use. 783 * @param pULconv Pointer to the pULconv structure to get the data from. 784 */ 785 static int localeMonetaryDo(__LIBC_PLOCALELCONV pLconv, UconvObject uobj, struct UniLconv *pULconv) 786 { 787 int rc; 788 /* free any old stuff. */ 789 localeMonetaryFree(pLconv); 790 791 /* 792 * Convert the stuff. 793 */ 794 #define CONVERT_UCS(field) \ 795 do { rc = convert_ucs(uobj, pULconv->field, &pLconv->s.field); if (rc) return rc; } while (0) 796 CONVERT_UCS(int_curr_symbol); 797 CONVERT_UCS(currency_symbol); 798 CONVERT_UCS(mon_decimal_point); 799 CONVERT_UCS(mon_thousands_sep); 800 CONVERT_UCS(positive_sign); 801 CONVERT_UCS(negative_sign); 802 pLconv->s.int_frac_digits = pULconv->int_frac_digits; 803 pLconv->s.frac_digits = pULconv->frac_digits; 804 pLconv->s.p_cs_precedes = pULconv->p_cs_precedes; 805 pLconv->s.p_sep_by_space = pULconv->p_sep_by_space; 806 pLconv->s.n_cs_precedes = pULconv->n_cs_precedes; 807 pLconv->s.n_sep_by_space = pULconv->n_sep_by_space; 808 pLconv->s.p_sign_posn = pULconv->p_sign_posn; 809 pLconv->s.n_sign_posn = pULconv->n_sign_posn; 810 #undef CONVERT_UCS 811 return localeConvertGrouping(pULconv->mon_grouping, &pLconv->s.mon_grouping); 812 } 813 814 /** 815 * Free an entry in the global locale data array. 816 */ 817 static void localeGlobalFree(__LIBC_PLOCALEGLOBAL pGlobal, int iCategory) 818 { 819 if (pGlobal->apszNames[iCategory + 1]) 820 { 821 if ( pGlobal->apszNames[iCategory + 1] != gszC 822 && pGlobal->apszNames[iCategory + 1] != gszPOSIX) 823 free(pGlobal->apszNames[iCategory + 1]); 824 pGlobal->apszNames[iCategory + 1] = NULL; 825 } 826 } 827 828 /** 829 * Parses out the locale spec and the code page spec. 830 */ 831 static int localeParseLocale(char *pszLocale, const char **ppszCodepage) 832 { 833 /* 834 * Strip of modifier. 835 */ 836 char *psz = strchr(pszLocale, '@'); 837 if (psz) 838 { 839 LIBCLOG_MSG2("Ignoring locale modifier '%s'\n", psz); 840 *psz = '\0'; 841 } 842 843 /* 844 * Codepage. 845 */ 846 psz = strchr(pszLocale, '.'); 847 if (psz) 848 *psz++ = '\0'; 849 *ppszCodepage = psz; 850 851 return 0; 852 } 853 854 /** 855 * Get the default local specification. 856 * @returns Pointer to default local (can be environment or it could be pszBuffer). 857 * @param pszBuffer Where to store the default local. 858 */ 859 static const char *getDefaultLocale(const char *pszCategory, char *pszBuffer, int *pfDefault) 860 { 861 /* Copy pszLocale to a local storage since we'll modify it during parsing. 862 If pszLocale value is a empty string, user wants the defaults fetched from 863 environment. */ 864 const char *pszRet = getenv("LC_ALL"); 865 if (pszRet && *pszRet) 866 *pfDefault = 0; /* LC_ALL is not default, it's an override of everything else. */ 867 else 868 { 869 *pfDefault = 1; 870 pszRet = getenv(pszCategory); 871 if (!pszRet) 872 { 873 pszRet = getenv("LANG"); 874 if (!pszRet) 875 { 876 /* 877 * The default is 'C' or 'POSIX'. 878 * 879 * But if old style is enabled we'll be using the country 880 * info to get a locale. 881 */ 882 pszRet = gszC; 883 if (gfOldStyle < 0) 884 gfOldStyle = getenv("LIBC_SETLOCALE_OLDSTYLE") != NULL; 885 if (gfOldStyle) 886 { 887 /* 888 * Not specified nor in environment, use country info. 889 * This is actually wrong in POSIX sense, but it makes "OS/2 sense". :) 890 */ 891 COUNTRYCODE ctryc = {0,0}; 892 COUNTRYINFO ctryi = {0}; 893 ULONG cb; 894 int rc; 895 FS_VAR() 896 897 FS_SAVE_LOAD(); 898 rc = DosQueryCtryInfo(sizeof(ctryi), &ctryc, &ctryi, &cb); 899 if (!rc /*|| rc == ERROR_COU*/) 900 { 901 UniChar ucs[50]; 902 rc = UniMapCtryToLocale(ctryi.country, ucs, sizeof(ucs)); 903 if (!rc) 904 { 905 Ucs2Sb(ucs, pszBuffer, UniStrlen(ucs) + 1); 906 pszRet = pszBuffer; 907 } 908 else 909 LIBC_ASSERTM_FAILED("UniMapCtryToLocale(%ld) failed rc=%d\n", ctryi.country, rc); 910 } 911 else 912 LIBC_ASSERTM_FAILED("DosQueryCtryInfo failed rc=%d\n", rc); 913 FS_RESTORE(); 914 } 915 } 916 } 917 } 918 return pszRet; 919 } 920 921 /** 922 * Extracts the code page from the locale spec or gets the default 923 * code page. 924 * @returns 0 on success. 925 * @returns negated errno on failure. 926 * @param pszCodepage Pointer to where the codepage specifier starts. 927 * @param pucsCodepage Where to store the code page. 928 * @param cucCodepage Number of UniChar's in the buffer. 929 */ 930 static int getCodepage(const char *pszCodepage, const char *pszLocale, LocaleObject lobj, UniChar *pucsCodepage, unsigned cucCodepage) 931 { 932 /* 933 * Look at what the user provides. 934 */ 935 if (pszCodepage && *pszCodepage) 936 __libc_TranslateCodepage(pszCodepage, pucsCodepage); 937 else 938 { 939 int rc = -1; 940 if (gfOldStyle < 0) 941 gfOldStyle = getenv("LIBC_SETLOCALE_OLDSTYLE") != NULL; 942 943 /* 944 * The locale object contains codepage information. 945 * We'll use that unless someone want's the old style. 946 */ 947 if (!gfOldStyle) 948 { 949 UniChar *pucsItem; 950 rc = UniQueryLocaleItem(lobj, LOCI_sISOCodepage, &pucsItem); 951 if (!rc) 952 { 953 UniChar *pucs = pucsItem; 954 while ( (*pucsCodepage++ = *pucs++) != '\0') 955 /* nada */; 956 UniFreeMem(pucsItem); 957 return 0; 958 } 959 } 960 961 /* 962 * Old style / fallback. 963 */ 964 if (IS_C_LOCALE(pszLocale) || IS_POSIX_LOCALE(pszLocale)) 965 /* 966 * The "C" character encoding maps to ISO8859-1 which is not quite true, 967 * but Unicode API doesn't have a codepage that matches the POSIX "C" 968 * pszCodepage, so that's what we presume when user requests the "C" pszCodepage. 969 */ 970 memcpy(pucsCodepage, gucsISO8859_1, sizeof(gucsISO8859_1)); 971 else 972 { 973 /* 974 * Consider current process codepage as default for specified language. 975 */ 976 ULONG aulCPs[5]; 977 ULONG cb; 978 int rc; 979 FS_VAR() 980 981 FS_SAVE_LOAD(); 982 rc = DosQueryCp(sizeof(aulCPs), &aulCPs[0], &cb); 983 if (rc) 984 { 985 FS_RESTORE(); 986 LIBC_ASSERTM_FAILED("DosQueryCp failed with rc=%d\n", rc); 987 return -__libc_native2errno(rc); 988 } 989 LIBC_ASSERT(cb >= sizeof(ULONG)); 990 LIBCLOG_MSG2("locale: using process codepage %ld\n", aulCPs[0]); 991 rc = UniMapCpToUcsCp(aulCPs[0], pucsCodepage, cucCodepage); 992 FS_RESTORE(); 993 if (rc) 994 { 995 LIBC_ASSERTM_FAILED("UniMapCpToUcsCp(%ld,,) -> %d\n", aulCPs[0], rc); 996 return -unierr2errno(rc); 997 } 998 } 999 } 1000 return 0; 1001 } 1002 1003 1004 /** 1005 * Creates the libuni objects we need. 1006 */ 1007 static int localeCreateObjects(const char *pszLocale, const char *pszCodepage, char *pszCodepageActual, LocaleObject *plobj, UconvObject *puobj) 1008 { 1009 LIBCLOG_ENTER("pszLocale=%p:{%s} pszCodepage=%p:{%s} pszCodepageActual=%p plobj=%p puobj=%p\n", 1010 pszLocale, pszLocale, pszCodepage, pszCodepage, pszCodepageActual, (void *)plobj, (void *)puobj); 1011 UniChar ucsCodepage[CODEPAGE_MAX_LENGTH]; 1012 int rc; 1013 1014 /* 1015 * Create locale object. 1016 */ 1017 if (IS_POSIX_LOCALE(pszLocale)) 1018 rc = UniCreateLocaleObject(UNI_MBS_STRING_POINTER, gszC, plobj); 1019 else 1020 rc = UniCreateLocaleObject(UNI_MBS_STRING_POINTER, pszLocale, plobj); 1021 if (rc) 1022 { 1023 LIBC_ASSERTM_FAILED("UniCreateLocaleObject(,%p:{%s},) -> rc=%d\n", pszLocale, pszLocale, rc); 1024 rc = -unierr2errno(rc); 1025 LIBCLOG_RETURN_INT(rc); 1026 } 1027 1028 /* 1029 * Calc code page and create object. 1030 */ 1031 rc = getCodepage(pszCodepage, pszLocale, *plobj, &ucsCodepage[0], sizeof(ucsCodepage) / sizeof(ucsCodepage[0])); 1032 if (!rc) 1033 { 1034 rc = UniCreateUconvObject(ucsCodepage, puobj); 1035 if (!rc) 1036 { 1037 if (pszCodepageActual) 1038 Ucs2Sb(ucsCodepage, pszCodepageActual, UniStrlen(ucsCodepage) + 1); 1039 LIBCLOG_RETURN_MSG(rc, "ret 0 *plobj=%08x *puobj=%08x pszCodepageActual=%p:{%s}\n", 1040 (unsigned)*plobj, (unsigned)*puobj, pszCodepageActual, pszCodepageActual); 1041 } 1042 1043 LIBC_ASSERTM_FAILED("UniCreateUconvObject(%ls,) -> rc=%d\n", (wchar_t *)ucsCodepage, rc); 1044 rc = -unierr2errno(rc); 1045 } 1046 1047 UniFreeUconvObject(*puobj); 1048 LIBCLOG_RETURN_INT(rc); 1049 } 1050 1051 1052 1053 /** 1054 * Performe the locale operation on one category. 1055 */ 1056 static int localeDoOne(struct temp_locale *pTemp, int iCategory, const char *pszLocale, const char *pszCodepage) 1057 { 1058 LIBCLOG_ENTER("pTemp=%p iCategory=%d (%s) pszLocale=%p:{%s} pszCodepage=%p:{%s}\n", 1059 (void *)pTemp, iCategory, gaszCategories[iCategory + 1], pszLocale, pszLocale, pszCodepage, pszCodepage); 1060 char szCodepageActual[CODEPAGE_MAX_LENGTH]; 1061 UconvObject uobj; 1062 LocaleObject lobj; 1063 int rc; 1064 int fFree; 1065 1066 1067 /* 1068 * Create the objects. 1069 */ 1070 rc = localeCreateObjects(pszLocale, pszCodepage, &szCodepageActual[0], &lobj, &uobj); 1071 if (rc) 1072 return rc; 1073 1074 /* 1075 * Call the worker for the locale category. 1076 */ 1077 fFree = 1; 1078 pTemp->afProcessed[iCategory + 1] = 1; 1079 switch (iCategory) 1080 { 1081 case LC_COLLATE: 1082 rc = localeCollateDo(&pTemp->Collate, uobj, lobj); 1083 fFree = rc != 0; 1084 break; 1085 1086 case LC_CTYPE: 1087 rc = localeCtypeDo(&pTemp->Ctype, uobj, lobj, pszLocale); 1088 fFree = rc != 0; 1089 break; 1090 1091 case LC_TIME: 1092 rc = localeTimeDo(&pTemp->Time, uobj, lobj); 1093 break; 1094 1095 case LC_NUMERIC: 1096 case LC_MONETARY: 1097 { 1098 /* 1099 * Query the unicode data.. 1100 */ 1101 struct UniLconv *pULconv; 1102 rc = UniQueryLocaleInfo(lobj, &pULconv); 1103 if (!rc) 1104 { 1105 if (iCategory == LC_NUMERIC) 1106 rc = localeNumericDo(&pTemp->Lconv, uobj, pULconv); 1107 else 1108 rc = localeMonetaryDo(&pTemp->Lconv, uobj, pULconv); 1109 UniFreeLocaleInfo(pULconv); 1110 } 1111 else 1112 { 1113 LIBC_ASSERTM_FAILED("UniQueryLocaleInfo -> %d\n", rc); 1114 rc = -unierr2errno(rc); 1115 } 1116 break; 1117 } 1118 1119 case LC_MESSAGES: 1120 /* Nothing to do for now */ 1121 default: 1122 rc = 0; 1123 break; 1124 } 1125 1126 1127 /* 1128 * Cleanup. 1129 */ 1130 if (fFree) 1131 { 1132 UniFreeLocaleObject(lobj); 1133 UniFreeUconvObject(uobj); 1134 } 1135 1136 if (!rc) 1137 { 1138 /* 1139 * Build and set catagory value. 1140 * The 'pszLocale' variable already contains language and country. 1141 */ 1142 localeGlobalFree(&pTemp->Global, iCategory); 1143 if (!pszCodepage || !*pszCodepage) 1144 { 1145 /* (no codepage specified) */ 1146 if (IS_C_LOCALE(pszLocale)) 1147 pTemp->Global.apszNames[iCategory + 1] = (char *)gszC; 1148 else if (IS_POSIX_LOCALE(pszLocale)) 1149 pTemp->Global.apszNames[iCategory + 1] = (char *)gszPOSIX; 1150 else 1151 { 1152 pTemp->Global.apszNames[iCategory + 1] = strdup(pszLocale); 1153 if (!pTemp->Global.apszNames[iCategory + 1]) 1154 return -ENOMEM; 1155 } 281 1156 } 282 1157 else 283 1158 { 284 UniChar cobuff [50]; 285 if (UniMapCtryToLocale (ci.country, cobuff, sizeof (cobuff))) 286 goto ctry_error; 287 locale = (char *)cpbuff; 288 Ucs2Sb (cobuff, (char *)locale, UniStrlen (cobuff) + 1); 1159 /* pszLocale + "." + szCodepageActual. */ 1160 int cch1 = strlen(pszLocale); 1161 int cch2 = strlen(szCodepageActual); 1162 char *psz = malloc(cch1 + cch2 + 2); 1163 if (!psz) 1164 return -ENOMEM; 1165 1166 memcpy(psz, pszLocale, cch1); 1167 psz[cch1] = '.'; 1168 memcpy(psz + cch1 + 1, szCodepageActual, cch2); 1169 psz[cch1 + 1 + cch2] = '\0'; 1170 1171 pTemp->Global.apszNames[iCategory + 1] = psz; 289 1172 } 290 } 291 } 292 } 293 sl = strlen (locale) + 1; 294 l = (char *)alloca (sl); 295 memcpy (l, locale, sl); 296 297 /* Parse the locale string user passed to us. This is either a string 298 in the XPG format (see below) or a list of values of the 299 form "CATEGORY1=value1;CATEGORY2=value2[;...]", where values are 300 also in XPG format: "language[_territory[.codeset]][@modifier]". 301 Currently we're ignoring the modifier. */ 302 303 if (category == LC_ALL) 304 { 305 /* User supplied a list of category=value statements separated with ';'. */ 306 if ((m = strchr (l, ';'))) 307 { 308 x = l; 309 while (m) 310 { 311 int cat; 312 char *cur_cat = locale_cat; 313 314 /* Remove the ';' at the end of assignment. */ 315 *m = 0; 316 for (cat = 0; *cur_cat; cat++, cur_cat = strchr (cur_cat, 0) + 1) 1173 } 1174 1175 LIBCLOG_RETURN_INT(rc); 1176 } 1177 1178 1179 1180 /** 1181 * Perform the more complex setlocale() operations which requires that 1182 * failure doesn't change anything. It will use an auto variable for 1183 * the temporary locale structure comitting it if all goes fine. 1184 * 1185 * @returns 0 on success. 1186 * @returns Negative errno on failure. 1187 */ 1188 static int localeDo(struct temp_locale *pTemp, int iCategory, char *pszLocale, int fDefaultValue) 1189 { 1190 LIBCLOG_ENTER("pTemp=%p iCategory=%d (%s) pszLocale=%p:{%s} fDefaultValue=%d\n", 1191 (void *)pTemp, iCategory, gaszCategories[iCategory + 1], pszLocale, pszLocale, fDefaultValue); 1192 const char *pszCodepage; 1193 char *pszNext; 1194 int rc; 1195 1196 /* 1197 * Process it. 1198 */ 1199 if (iCategory != LC_ALL) 1200 { 1201 rc = localeParseLocale(pszLocale, &pszCodepage); 1202 if (!rc) 1203 rc = localeDoOne(pTemp, iCategory, pszLocale, pszCodepage); 1204 } 1205 else 1206 { 1207 /* 1208 * Parse the pszLocale string user passed to us. This is either a string 1209 * in the XPG format (see below) or a list of values of the 1210 * form "CATEGORY1=value1;CATEGORY2=value2[;...]", where values are 1211 * also in XPG format: "language[_territory[.codeset]][@modifier]". 1212 * Currently we're ignoring the modifier. 1213 */ 1214 pszNext = strchr(pszLocale, ';'); 1215 if (pszNext) 317 1216 { 318 int sl = strlen (cur_cat); 319 if (strncmp (x, cur_cat, sl) == 0 320 && (x [sl] == '=')) 321 { 322 setlocale (cat, x + sl + 1); 323 break; 324 } 325 } 326 327 m = strchr (x = m + 1, ';'); 328 if (!m && *x) 329 m = strchr (x, 0); 330 } 331 } 332 else 333 { 334 int cat; 335 char *env_val, *cur_cat = locale_cat; 336 337 /* Set all locale categories to given value */ 338 for (cat = 0; *cur_cat; cat++, cur_cat = strchr (cur_cat, 0) + 1) 339 /* If user wants default values, check environment first. */ 340 if (def_val && (env_val = getenv (cur_cat))) 341 setlocale (cat, env_val); 342 else 343 setlocale (cat, l); 344 } 345 } 346 else 347 { 348 /* Look if the modifier is present and strip it off. */ 349 m = strchr (l, '@'); 350 if (m) *m = 0; 351 352 /* Look which codepage the user provides. */ 353 x = strchr (l, '.'); 354 if (x) 355 { 356 *x++ = 0; 357 __convert_codepage (x, cpbuff); 358 } 359 else if (IS_C_LOCALE (l)) 360 /* The "C" character encoding maps to ISO8859-1 which is not quite true, 361 but Unicode API doesn't have a codepage that matches the POSIX "C" 362 locale, so that's what we presume when user requests the "C" locale. */ 363 memcpy (cpbuff, L"ISO8859-1", 10 * sizeof (wchar_t)); 364 else 365 { 366 ULONG cp [3], cplen; 367 368 /* Consider current process codepage as default for specified language */ 369 if (DosQueryCp (sizeof (cp), cp, &cplen)) 370 ERROR (EINVAL); 371 372 if (UniMapCpToUcsCp (cp [0], cpbuff, sizeof (cpbuff) / sizeof (UniChar))) 373 ERROR (EINVAL); 374 } 375 376 if (UniCreateUconvObject (cpbuff, &uconv_obj)) 377 ERROR (EINVAL); 378 379 if (UniCreateLocaleObject (UNI_MBS_STRING_POINTER, l, &locale_obj)) 380 ERROR (EINVAL); 381 382 _smutex_request (&__locale.lock); 383 384 switch (category) 385 { 386 case LC_COLLATE: 387 { 388 int j; 389 struct __collate_weight cw [256]; 390 if (query_mbcs (uconv_obj, &__locale_collate.mbcs, 391 __locale_collate.mbcsprefix, NULL)) 392 ERROR2 (EINVAL); 393 394 /* Free old locale objects, if any */ 395 if (__locale_collate.uconv) 396 UniFreeUconvObject (__locale_collate.uconv); 397 __locale_collate.uconv = NULL; 398 if (__locale_collate.locale) 399 UniFreeLocaleObject (__locale_collate.locale); 400 __locale_collate.locale = NULL; 401 402 if (__locale_collate.mbcs) 403 { 404 /* In MBCS mode we just borrow the conversion and locale objects 405 and leave the real work to the Unicode subsystem. */ 406 __locale_collate.locale = locale_obj; 407 locale_obj = NULL; 408 __locale_collate.uconv = uconv_obj; 409 uconv_obj = NULL; 1217 /* 1218 * User supplied a list of iCategory=value statements separated with ';'. 1219 */ 1220 char *pszCur = pszLocale; 1221 *pszNext++ = '\0'; /* remove the ';'. */ 1222 for (;;) 1223 { 1224 int iCat; 1225 /* Search for the variable, ignoring those we cannot find.s */ 1226 for (rc = 0, iCat = LC_ALL; iCat < _LC_LAST; iCat++) 1227 { 1228 unsigned cch = gacchCategories[iCat + 1]; 1229 if ( strncmp(pszCur, gaszCategories[iCat + 1], cch) == 0 1230 && pszCur[cch] == '=') 1231 { 1232 char *pszVal = &pszCur[cch + 1]; 1233 const char *pszValCp; 1234 /* parse the locale value. */ 1235 rc = localeParseLocale(pszVal, &pszValCp); 1236 if (!rc) 1237 { 1238 if (iCat != LC_ALL) 1239 rc = localeDoOne(pTemp, iCat, pszVal, pszValCp); 1240 else /* Iterate all categories except LC_ALL. */ 1241 for (iCat = LC_ALL + 1; !rc && iCat < _LC_LAST; iCat++) 1242 rc = localeDoOne(pTemp, iCat, pszVal, pszValCp); 1243 } 1244 break; 1245 } 1246 } 1247 1248 /* next */ 1249 if (!pszNext || rc < 0) 1250 break; 1251 pszCur = pszNext; 1252 pszNext = strchr(pszCur, ';'); 1253 if (pszNext) 1254 *pszNext++ = '\0'; 1255 } 410 1256 } 411 1257 else 412 1258 { 413 /* In SBCS we query the weight of every character and use the 414 weights directly, without the need to invoke the Unicode API. */ 415 416 /* Initialize character weights. */ 417 for (i = 0; i < 256; i++) 418 { 419 UniChar ucs; 420 UniChar us [2]; 421 422 if (!__to_ucs (uconv_obj, (unsigned char *)&i, 1, &ucs)) 423 ucs = i; 424 425 us [0] = ucs; us [1] = 0; 426 427 cw [i].code = i; 428 cw [i].len = UniStrxfrm (locale_obj, cw [i].weight, us, 429 sizeof (cw [i].weight) / sizeof (UniChar)); 430 if (cw [i].len >= sizeof (cw [i].weight) / sizeof (UniChar)) 431 /* This should never happen. */ 432 cw [i].len = sizeof (cw [i].weight) / sizeof (UniChar); 433 } 434 435 /* Do bubble sorting since qsort() doesn't guarantee that the order 436 of equal elements stays the same. */ 437 for (i = 0; i < 256; i++) 438 for (j = i; j < 256; j++) 439 if (cw_cmp (&cw [j], &cw [j + 1]) > 0) 440 _memswap (&cw [j], &cw [j + 1], sizeof (struct __collate_weight)); 441 442 for (i = 0; i < 256; i++) 443 __locale_collate.weight [cw [i].code] = i; 1259 /* 1260 * Set all pszLocale categories to given value. 1261 * Parse it first to save time. 1262 */ 1263 rc = localeParseLocale(pszLocale, &pszCodepage); 1264 if (!rc) 1265 { 1266 int iCat; 1267 for (iCat = LC_ALL + 1; !rc && iCat < _LC_LAST; iCat++) 1268 { 1269 const char *pszEnv; 1270 /* 1271 * If user wants default values, we must check environment first. 1272 */ 1273 if (fDefaultValue && (pszEnv = getenv(gaszCategories[iCat + 1])) != NULL) 1274 { 1275 const char *pszCodepageEnv; 1276 char *pszCopy = alloca(strlen(pszEnv) + 1); 1277 if (!pszCopy) 1278 LIBCLOG_RETURN_INT(-ENOMEM); 1279 rc = localeParseLocale(strcpy(pszCopy, pszEnv), &pszCodepageEnv); 1280 if (!rc) 1281 rc = localeDoOne(pTemp, iCat, pszCopy, pszCodepageEnv); 1282 } 1283 else 1284 rc = localeDoOne(pTemp, iCat, pszLocale, pszCodepage); 1285 } 1286 } 444 1287 } 445 446 break; 447 } 448 449 case LC_CTYPE: 450 { 451 if (query_mbcs (uconv_obj, &__locale_ctype.mbcs, 452 __locale_ctype.mbcsprefix, &MB_CUR_MAX)) 453 ERROR2 (EINVAL); 454 455 /* For speeding up isXXX() and lower/upper case mapping functions 456 we'll cache the type of every character into a variable. 457 458 Do every character separately to avoid errors that could result 459 when some character in the middle cannot be conerted from or to 460 Unicode - this would lead in a shift of the entire string. */ 461 for (i = 0; i < 256; i++) 1288 } 1289 LIBCLOG_RETURN_INT(rc); 1290 } 1291 1292 1293 /** 1294 * Commits a temporary local and updates the global locale strings. 1295 */ 1296 static char *localeCommit(struct temp_locale *pTemp, int iCategory) 1297 { 1298 char *pszRet; 1299 char *pszAll; 1300 int cch; 1301 int iCat; 1302 1303 /* 1304 * Lock the structure. 1305 */ 1306 _smutex_request(&gLocale.lock); 1307 1308 /* 1309 * Copy all the data. 1310 */ 1311 if (pTemp->afProcessed[LC_COLLATE + 1]) 1312 { 1313 localeCollateFree(&__libc_gLocaleCollate); 1314 memcpy(&__libc_gLocaleCollate, &pTemp->Collate, sizeof(__libc_gLocaleCollate)); 1315 pTemp->afProcessed[LC_COLLATE + 1] = 0; 1316 gLocale.apszNames[LC_COLLATE + 1] = pTemp->Global.apszNames[LC_COLLATE + 1]; 1317 } 1318 1319 if (pTemp->afProcessed[LC_CTYPE + 1]) 1320 { 1321 localeCtypeFree(&__libc_GLocaleCtype); 1322 memcpy(&__libc_GLocaleCtype, &pTemp->Ctype, sizeof(__libc_GLocaleCtype)); 1323 pTemp->afProcessed[LC_CTYPE + 1] = 0; 1324 gLocale.apszNames[LC_CTYPE + 1] = pTemp->Global.apszNames[LC_CTYPE + 1]; 1325 } 1326 1327 if (pTemp->afProcessed[LC_TIME + 1]) 1328 { 1329 localeTimeFree(&__libc_gLocaleTime); 1330 memcpy(&__libc_gLocaleTime, &pTemp->Time, sizeof(__libc_gLocaleTime)); 1331 pTemp->afProcessed[LC_TIME + 1] = 0; 1332 gLocale.apszNames[LC_TIME + 1] = pTemp->Global.apszNames[LC_TIME + 1]; 1333 } 1334 1335 if (pTemp->afProcessed[LC_NUMERIC + 1]) 1336 { 1337 localeNumericFree(&__libc_gLocaleLconv); 1338 __libc_gLocaleLconv.fNumericConsts = pTemp->Lconv.fNumericConsts; 1339 __libc_gLocaleLconv.s.decimal_point = pTemp->Lconv.s.decimal_point; 1340 __libc_gLocaleLconv.s.thousands_sep = pTemp->Lconv.s.thousands_sep; 1341 __libc_gLocaleLconv.s.grouping = pTemp->Lconv.s.grouping; 1342 pTemp->afProcessed[LC_NUMERIC + 1] = 0; 1343 gLocale.apszNames[LC_NUMERIC + 1] = pTemp->Global.apszNames[LC_NUMERIC + 1]; 1344 } 1345 1346 if (pTemp->afProcessed[LC_MONETARY + 1]) 1347 { 1348 localeMonetaryFree(&__libc_gLocaleLconv); 1349 __libc_gLocaleLconv.fMonetaryConsts = pTemp->Lconv.fMonetaryConsts; 1350 __libc_gLocaleLconv.s.int_curr_symbol = pTemp->Lconv.s.int_curr_symbol; 1351 __libc_gLocaleLconv.s.currency_symbol = pTemp->Lconv.s.currency_symbol; 1352 __libc_gLocaleLconv.s.mon_decimal_point = pTemp->Lconv.s.mon_decimal_point; 1353 __libc_gLocaleLconv.s.mon_thousands_sep = pTemp->Lconv.s.mon_thousands_sep; 1354 __libc_gLocaleLconv.s.mon_grouping = pTemp->Lconv.s.mon_grouping; 1355 __libc_gLocaleLconv.s.positive_sign = pTemp->Lconv.s.positive_sign; 1356 __libc_gLocaleLconv.s.negative_sign = pTemp->Lconv.s.negative_sign; 1357 __libc_gLocaleLconv.s.int_frac_digits = pTemp->Lconv.s.int_frac_digits; 1358 __libc_gLocaleLconv.s.frac_digits = pTemp->Lconv.s.frac_digits; 1359 __libc_gLocaleLconv.s.p_cs_precedes = pTemp->Lconv.s.p_cs_precedes; 1360 __libc_gLocaleLconv.s.p_sep_by_space = pTemp->Lconv.s.p_sep_by_space; 1361 __libc_gLocaleLconv.s.n_cs_precedes = pTemp->Lconv.s.n_cs_precedes; 1362 __libc_gLocaleLconv.s.n_sep_by_space = pTemp->Lconv.s.n_sep_by_space; 1363 __libc_gLocaleLconv.s.p_sign_posn = pTemp->Lconv.s.p_sign_posn; 1364 __libc_gLocaleLconv.s.n_sign_posn = pTemp->Lconv.s.n_sign_posn; 1365 pTemp->afProcessed[LC_MONETARY + 1] = 0; 1366 gLocale.apszNames[LC_MONETARY + 1] = pTemp->Global.apszNames[LC_MONETARY + 1]; 1367 } 1368 if (pTemp->afProcessed[LC_MESSAGES + 1]) 1369 { 1370 pTemp->afProcessed[LC_MONETARY + 1] = 0; 1371 gLocale.apszNames[LC_MESSAGES + 1] = pTemp->Global.apszNames[LC_MESSAGES + 1]; 1372 } 1373 1374 1375 /* 1376 * Now we must build the LC_ALL string. 1377 * 1378 * If all the entries are not identical we must make a "category=value" 1379 * string for LC_ALL. Else we can just duplicate one of the others. 1380 */ 1381 pszAll = gLocale.apszNames[1]; 1382 cch = gacchCategories[1] + 1 + strlen(pszAll) + 1 + 1; 1383 for (iCat = 2; iCat <= _LC_LAST; iCat++) 1384 { 1385 int cchCat = strlen(gLocale.apszNames[iCat]); 1386 cch += gacchCategories[iCat] + 1 + cchCat + 1; 1387 if (pszAll && strcmp(pszAll, gLocale.apszNames[iCat])) 1388 pszAll = NULL; 1389 } 1390 1391 if (!pszAll) 1392 { 1393 /* 1394 * Not identical. Generate composite value. 1395 */ 1396 char *psz = pszAll = malloc(cch); /* If we're out of memory here, then it's just too bad :-/ */ 1397 for (iCat = 1; iCat <= _LC_LAST; iCat++) /* (iCat is array index not lc idx this time) */ 462 1398 { 463 UniChar ucs; 464 unsigned short ct = 0; 465 unsigned char uc, lc; 466 467 if (!__to_ucs (uconv_obj, (unsigned char *)&i, 1, &ucs)) 468 ucs = i; 469 470 /* isxxx() do not support DBCS characters at all */ 471 if (!IS_MBCS_PREFIX (__locale_ctype,i)) 472 { /* isn't there apis for getting all this at once? */ 473 #if 0 474 if (UniQueryUpper (locale_obj, ucs)) 475 ct |= __UPPER; 476 if (UniQueryLower (locale_obj, ucs)) 477 ct |= __LOWER; 478 if (UniQueryDigit (locale_obj, ucs)) 479 ct |= __DIGIT; 480 if (UniQueryXdigit (locale_obj, ucs)) 481 ct |= __XDIGIT; 482 if (UniQueryCntrl (locale_obj, ucs)) 483 ct |= __CNTRL; 484 if (UniQuerySpace (locale_obj, ucs)) 485 ct |= __SPACE; 486 if (UniQueryPunct (locale_obj, ucs)) 487 ct |= __PUNCT; 488 if (UniQueryPrint (locale_obj, ucs)) 489 ct |= __PRINT; 490 if (UniQueryBlank (locale_obj, ucs)) 491 ct |= __BLANK; 492 #else 493 UNICTYPE * pctype = UniQueryCharType (ucs); 494 if (pctype) 495 /* ASSUMES CT_* == __* */ 496 ct = (pctype->itype) & (__UPPER | __LOWER | __DIGIT | __SPACE | 497 __PUNCT | __CNTRL | __BLANK | __XDIGIT | 498 __ALPHA | __ALNUM | __GRAPH | __PRINT | 499 __NUMBER | __SYMBOL | __ASCII); 500 501 #endif 502 503 uc = Transform (locale_obj, uconv_obj, UniTransUpper, ucs, i); 504 lc = Transform (locale_obj, uconv_obj, UniTransLower, ucs, i); 505 } 506 else 507 uc = lc = i; 508 509 __locale_ctype.cflags [i] = ct; 510 511 __locale_ctype.upcase [i] = uc; 512 __locale_ctype.locase [i] = lc; 1399 int cchCat = gacchCategories[iCat]; 1400 memcpy(psz, gaszCategories[iCat], cchCat); 1401 psz += cchCat; 1402 *psz++ = '='; 1403 cchCat = strlen(gLocale.apszNames[iCat]); 1404 memcpy(psz, gLocale.apszNames[iCat], cchCat); 1405 psz += cchCat; 1406 *psz++ = ';'; 513 1407 } 514 515 /* In the "C" locale second half of the cflags table should be empty */ 516 if (IS_C_LOCALE (l)) 1408 *psz = '\0'; 1409 localeGlobalFree(&gLocale, LC_ALL); 1410 gLocale.apszNames[LC_ALL + 1] = pszAll; 1411 } 1412 else if (strcmp(gLocale.apszNames[LC_ALL + 1], pszAll)) 1413 { 1414 localeGlobalFree(&gLocale, LC_ALL); 1415 gLocale.apszNames[LC_ALL + 1] = strdup(pszAll); 1416 } 1417 1418 /* 1419 * Unlock and returns. 1420 */ 1421 pszRet = gLocale.apszNames[iCategory + 1]; 1422 _smutex_release(&gLocale.lock); 1423 1424 return pszRet; 1425 } 1426 1427 1428 /** 1429 * Clean up the temporary locale instance structure. 1430 * @param pTemp Stuff to cleanup. 1431 */ 1432 static void localeFree(struct temp_locale *pTemp) 1433 { 1434 int iCat; 1435 if (pTemp->afProcessed[LC_COLLATE + 1]) 1436 localeCollateFree(&pTemp->Collate); 1437 if (pTemp->afProcessed[LC_CTYPE + 1]) 1438 localeCtypeFree(&pTemp->Ctype); 1439 if (pTemp->afProcessed[LC_TIME + 1]) 1440 localeTimeFree(&pTemp->Time); 1441 if (pTemp->afProcessed[LC_NUMERIC + 1]) 1442 localeNumericFree(&pTemp->Lconv); 1443 if (pTemp->afProcessed[LC_MONETARY + 1]) 1444 localeMonetaryFree(&pTemp->Lconv); 1445 for (iCat = 0; iCat < _LC_LAST; iCat++) 1446 if (pTemp->afProcessed[iCat + 1]) 1447 localeGlobalFree(&pTemp->Global, iCat); 1448 } 1449 1450 1451 /** 1452 * This setlocale() implementation differs from the specs in that any 1453 * options specified by '@...' is ignored. 1454 */ 1455 char *_STD(setlocale)(int iCategory, const char *pszLocale) 1456 { 1457 LIBCLOG_ENTER("iCategory=%d pszLocale=%p:{%s}\n", iCategory, pszLocale, pszLocale); 1458 char szTmpBuf[64]; 1459 int fDefaultValue; 1460 size_t cch; 1461 char *pszLocaleCopy; 1462 char *pszRet; 1463 int rc; 1464 1465 /* 1466 * Validate input. 1467 */ 1468 if (iCategory < LC_ALL || iCategory >= _LC_LAST) 1469 { 1470 LIBC_ASSERTM_FAILED("iCategory=%d is invalid!\n", iCategory); 1471 errno = EINVAL; 1472 LIBCLOG_RETURN_P(NULL); 1473 } 1474 1475 /* 1476 * Check if user just queries current pszLocale. 1477 */ 1478 if (!pszLocale) 1479 { 1480 pszRet = gLocale.apszNames[iCategory + 1]; 1481 LIBCLOG_RETURN_MSG(pszRet, "ret %p:{%s}\n", pszRet, pszRet); 1482 } 1483 1484 /* 1485 * Check if user wants we to do the same job twice. 1486 */ 1487 if (strcmp(pszLocale, gLocale.apszNames[iCategory + 1]) == 0) 1488 { 1489 /* We have to return the value of LC_ALL */ 1490 pszRet = gLocale.apszNames[iCategory + 1]; 1491 LIBCLOG_RETURN_MSG(pszRet, "ret %p:{%s} (already set)\n", pszRet, pszRet); 1492 } 1493 1494 1495 /* 1496 * If pszLocale value is a empty string, user wants the defaults fetched from 1497 * environment. 1498 */ 1499 fDefaultValue = *pszLocale == '\0'; 1500 if (fDefaultValue) 1501 pszLocale = getDefaultLocale(gaszCategories[iCategory + 1], szTmpBuf, &fDefaultValue); 1502 1503 /* 1504 * Copy pszLocale to a local storage since we'll modify it during parsing. 1505 */ 1506 cch = strlen(pszLocale) + 1; 1507 pszLocaleCopy = (char *)alloca(cch); 1508 if (!pszLocaleCopy) 1509 { 1510 errno = ENOMEM; 1511 LIBCLOG_RETURN_P(NULL); 1512 } 1513 memcpy(pszLocaleCopy, pszLocale, cch); 1514 1515 1516 /* 1517 * Allocate a temporary locale state and perform 1518 * the locale operation on that. 1519 */ 1520 struct temp_locale *pTemp = alloca(sizeof(struct temp_locale)); 1521 memset(pTemp, 0, sizeof(struct temp_locale)); 1522 1523 rc = localeDo(pTemp, iCategory, pszLocaleCopy, fDefaultValue); 1524 1525 /* 1526 * If successful commit the temporary locale. 1527 */ 1528 if (!rc) 1529 pszRet = localeCommit(pTemp, iCategory); 1530 else 1531 { 1532 errno = -rc; 1533 pszRet = NULL; 1534 } 1535 1536 /* 1537 * Cleanup and exit. 1538 */ 1539 localeFree(pTemp); 1540 1541 LIBCLOG_RETURN_MSG(pszRet, "ret %p:{%s}\n", pszRet, pszRet); 1542 } 1543 1544 #undef ERROR 1545 1546 #undef __LIBC_LOG_GROUP 1547 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_FORK 1548 1549 1550 _FORK_CHILD1(0xffffff00, setlocalForkChild1) 1551 1552 /** 1553 * Create any unicode objects used by the locale stuff. 1554 * 1555 * !describe me! 1556 */ 1557 static int setlocalForkChild1(__LIBC_PFORKHANDLE pForkHandle, __LIBC_FORKOP enmOperation) 1558 { 1559 LIBCLOG_ENTER("pForkHandle=%p enmOperation=%d\n", (void *)pForkHandle, enmOperation); 1560 int rc; 1561 switch (enmOperation) 1562 { 1563 case __LIBC_FORK_OP_FORK_CHILD: 517 1564 { 518 memset (__locale_ctype.cflags + 128, 0, 128); 519 for (i = 128; i < 255; i++) 520 { 521 __locale_ctype.upcase [i] = i; 522 __locale_ctype.locase [i] = i; 523 } 1565 gLocale.lock = 0; 1566 1567 rc = 0; 1568 if ( __libc_GLocaleCtype.lobj 1569 || __libc_GLocaleCtype.uobj 1570 || __libc_gLocaleCollate.lobj 1571 || __libc_gLocaleCollate.uobj 1572 ) 1573 { 1574 LocaleObject lobj; 1575 UconvObject uobj; 1576 const char *pszCodepage; 1577 int cch1 = strlen(gLocale.apszNames[LC_CTYPE + 1]); 1578 int cch2 = strlen(gLocale.apszNames[LC_COLLATE + 1]); 1579 int cch = cch1 > cch2 ? cch1 + 1 : cch2 + 1; 1580 char *psz = alloca(cch); 1581 if (!psz) 1582 LIBCLOG_RETURN_INT(-ENOMEM); 1583 1584 if ( __libc_GLocaleCtype.lobj 1585 || __libc_GLocaleCtype.uobj) 1586 { 1587 memcpy(psz, gLocale.apszNames[LC_CTYPE + 1], cch); 1588 localeParseLocale(psz, &pszCodepage); 1589 rc = localeCreateObjects(psz, pszCodepage, NULL, &lobj, &uobj); 1590 if (!rc) 1591 LIBCLOG_RETURN_INT(rc); 1592 1593 if (__libc_GLocaleCtype.lobj) 1594 __libc_GLocaleCtype.lobj = lobj; 1595 else 1596 UniFreeLocaleObject(lobj); 1597 1598 if (__libc_GLocaleCtype.uobj) 1599 __libc_GLocaleCtype.uobj = uobj; 1600 else 1601 UniFreeUconvObject(uobj); 1602 } 1603 1604 if ( __libc_gLocaleCollate.lobj 1605 || __libc_gLocaleCollate.uobj) 1606 { 1607 memcpy(psz, gLocale.apszNames[LC_COLLATE + 1], cch); 1608 localeParseLocale(psz, &pszCodepage); 1609 rc = localeCreateObjects(psz, pszCodepage, NULL, &lobj, &uobj); 1610 if (!rc) 1611 LIBCLOG_RETURN_INT(rc); 1612 1613 if (__libc_gLocaleCollate.lobj) 1614 __libc_gLocaleCollate.lobj = lobj; 1615 else 1616 UniFreeLocaleObject(lobj); 1617 1618 if (__libc_gLocaleCollate.uobj) 1619 __libc_gLocaleCollate.uobj = uobj; 1620 else 1621 UniFreeUconvObject(uobj); 1622 } 1623 } 1624 break; 524 1625 } 525 526 if (__locale_ctype.uconv) 527 UniFreeUconvObject (__locale_ctype.uconv); 528 __locale_ctype.uconv = NULL; 529 if (__locale_ctype.locale) 530 UniFreeLocaleObject (__locale_ctype.locale); 531 __locale_ctype.locale = NULL; 532 533 __locale_ctype.uconv = uconv_obj; 534 uconv_obj = NULL; 535 536 if (__locale_ctype.mbcs) 537 { 538 /* In MBCS mode we just borrow the locale object 539 and leave the real work to the Unicode subsystem. */ 540 __locale_ctype.locale = locale_obj; 541 locale_obj = NULL; 542 } 543 544 break; 545 } 546 547 case LC_TIME: 548 { 549 struct __locale_time loc_time; 550 UniChar *item; 551 552 memset (&loc_time, 0, sizeof (loc_time)); 553 554 if (UniQueryLocaleItem (locale_obj, D_T_FMT, &item) 555 || convert_ucs (uconv_obj, item, &loc_time.date_time_fmt) 556 || UniQueryLocaleItem (locale_obj, D_FMT, &item) 557 || convert_ucs (uconv_obj, item, &loc_time.date_fmt) 558 || UniQueryLocaleItem (locale_obj, T_FMT, &item) 559 || convert_ucs (uconv_obj, item, &loc_time.time_fmt) 560 || UniQueryLocaleItem (locale_obj, AM_STR, &item) 561 || convert_ucs (uconv_obj, item, &loc_time.am) 562 || UniQueryLocaleItem (locale_obj, PM_STR, &item) 563 || convert_ucs (uconv_obj, item, &loc_time.pm) 564 || query_array (locale_obj, uconv_obj, 7, DAY_1, loc_time.lwdays) 565 || query_array (locale_obj, uconv_obj, 7, ABDAY_1, loc_time.swdays) 566 || query_array (locale_obj, uconv_obj, 12, MON_1, loc_time.lmonths) 567 || query_array (locale_obj, uconv_obj, 12, ABMON_1, loc_time.smonths)) 568 { 569 free_time (&loc_time); 570 ERROR2 (EINVAL); 571 } 572 573 /* Free the old time formatting info if needed. */ 574 if (__locale.name [LC_TIME + 1] != __locale_C) 575 free_time (&__locale_time); 576 577 /* Assign value to static variable. */ 578 __locale_time = loc_time; 579 break; 580 } 581 582 case LC_MESSAGES: 583 /* Nothing to do for now */ 584 break; 585 586 case LC_NUMERIC: 587 case LC_MONETARY: 588 { 589 struct lconv lconv; 590 591 if (UniQueryLocaleInfo (locale_obj, &Lconv)) 592 ERROR2 (EINVAL); 593 594 lconv = __locale_lconv; 595 596 #define CONVERT_UCS(field) \ 597 if (convert_ucs (uconv_obj, Lconv->field, &lconv.field)) \ 598 ERROR3 (EINVAL); 599 600 if (category == LC_NUMERIC) 601 { 602 #define ERROR3(code) \ 603 { free_numeric (&lconv); UniFreeLocaleInfo (Lconv); ERROR2 (code); } 604 605 /* Initialize fields with NULLs (for the case we will fail) */ 606 lconv.decimal_point = lconv.thousands_sep = lconv.grouping = NULL; 607 608 CONVERT_UCS (decimal_point); 609 CONVERT_UCS (thousands_sep); 610 CONVERT_UCS (grouping); 611 612 if (__locale.name [LC_NUMERIC + 1] != __locale_C) 613 free_numeric (&__locale_lconv); 614 #undef ERROR3 615 } 616 617 if (category == LC_MONETARY) 618 { 619 #define ERROR3(code) { free_monetary (&lconv); ERROR2 (code); } 620 621 /* Initialize fields with NULLs (for the case we will fail) */ 622 lconv.int_curr_symbol = lconv.currency_symbol = 623 lconv.mon_decimal_point = lconv.mon_thousands_sep = 624 lconv.mon_grouping = lconv.positive_sign = 625 lconv.negative_sign = NULL; 626 627 CONVERT_UCS (int_curr_symbol); 628 CONVERT_UCS (currency_symbol); 629 CONVERT_UCS (mon_decimal_point); 630 CONVERT_UCS (mon_thousands_sep); 631 CONVERT_UCS (mon_grouping); 632 CONVERT_UCS (positive_sign); 633 CONVERT_UCS (negative_sign); 634 lconv.int_frac_digits = Lconv->int_frac_digits; 635 lconv.frac_digits = Lconv->frac_digits; 636 lconv.p_cs_precedes = Lconv->p_cs_precedes; 637 lconv.p_sep_by_space = Lconv->p_sep_by_space; 638 lconv.n_cs_precedes = Lconv->n_cs_precedes; 639 lconv.n_sep_by_space = Lconv->n_sep_by_space; 640 lconv.p_sign_posn = Lconv->p_sign_posn; 641 lconv.n_sign_posn = Lconv->n_sign_posn; 642 643 if (__locale.name [LC_MONETARY + 1] != __locale_C) 644 free_monetary (&__locale_lconv); 645 #undef ERROR3 646 } 647 #undef CONVERT_UCS 648 649 UniFreeLocaleInfo (Lconv); 650 651 /* Okay, since we got no errors, copy to its final location. */ 652 __locale_lconv = lconv; 653 break; 654 } 655 } /* endcase */ 656 657 /* Build and set category value. 658 'l' already contains language and country. */ 659 if (IS_C_LOCALE (l)) 660 setname (category, l, 0); 661 else 662 { 663 char *loc; 664 int j = 0; 665 i = strlen (l); 666 sl = i + UniStrlen (cpbuff) + 2; 667 loc = malloc (sl); 668 memcpy (loc, l, i); 669 loc [i++] = '.'; 670 /* Suppose codepage names always use 7-bit characters (which is true) */ 671 while (i < sl) 672 loc [i++] = (char)cpbuff [j++]; 673 setname (category, loc, 1); 674 } /* endif */ 675 676 _smutex_release (&__locale.lock); 677 } 678 679 /* Check if all locale categories are equal. If not, return a list in 680 the "category=value" format, otherwise just return the value itself. */ 681 ret = __locale.name [1]; 682 sl = 0; 683 x = locale_cat; 684 for (i = 0; i < __LC_COUNT; i++) 685 { 686 if (ret && strcmp (ret, __locale.name [i + 1]) != 0) 687 /* We have to return a list value. */ 688 ret = NULL; 689 sl += strlen (x) + strlen (__locale.name [i + 1]) + 2; 690 x = strchr (x, 0) + 1; 691 } 692 693 i = 0; 694 if (!ret) 695 { 696 /* Generate a list value. */ 697 ret = malloc (sl); 698 x = locale_cat; 699 sl = 0; 700 for (/*i = 0*/; i < __LC_COUNT; i++) 701 { 702 strcpy (ret + sl, x); 703 sl += strlen (ret + sl); 704 ret [sl++] = '='; 705 strcpy (ret + sl, __locale.name [i + 1]); 706 sl += strlen (ret + sl); 707 if (i < __LC_COUNT - 1) 708 ret [sl++] = ';'; 709 x = strchr (x, 0) + 1; 710 } 711 } /* endif */ 712 713 /* If all values (except LC_ALL) are equal, ret is set to that value. 714 In this case we must set LC_ALL to that value as well. 715 If values are partially different, ret points to a composite value. 716 In this case we also must set LC_ALL to this composite value. 717 If i is not zero, then we have a composite value which is already 718 allocated from heap (so avoid setname() allocating it again). */ 719 setname (LC_ALL, ret, i); 720 721 /* But in any case, the returned value is the one actually set for 722 the category in question. */ 723 ret = __locale.name [category + 1]; 724 725 normal_exit: 726 if (locale_obj) 727 UniFreeLocaleObject (locale_obj); 728 if (uconv_obj) 729 UniFreeUconvObject (uconv_obj); 730 731 return ret; 732 } 733 734 #undef ERROR 1626 default: 1627 rc = 0; 1628 break; 1629 } 1630 LIBCLOG_RETURN_INT(rc); 1631 } 1632 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/_hinitheap.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r1453 r1454 84 84 * Allocate the initial heap block. 85 85 */ 86 cbInitial = 4*1024*1024;86 cbInitial = _INITIAL_DEFAULT_HEAP_SIZE; 87 87 fClean = _BLOCK_CLEAN; 88 88 pvInitial = __libc_HimemDefaultAlloc(NULL, &cbInitial, &fClean); … … 98 98 Heap = _ucreate2(pvInitial, cbInitial, fClean, 99 99 _HEAP_REGULAR | _HEAP_HIGHMEM, 100 __libc_HimemDefaultAlloc, __libc_HimemDefaultRelease,100 __libc_HimemDefaultAlloc, __libc_HimemDefaultRelease, 101 101 NULL, NULL); 102 102 if (Heap == NULL) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/calloc.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1453 r1454 6 6 #include <umalloc.h> 7 7 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 8 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 9 #include <sys/rmutex.h> 8 #include <sys/fmutex.h> 10 9 #include <emx/umalloc.h> 11 10 #include <InnoTekLIBC/thread.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/defalloc.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 7 7 #include <umalloc.h> 8 8 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 9 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 10 #include <sys/rmutex.h> 9 #include <sys/fmutex.h> 11 10 #include <emx/umalloc.h> 12 11 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/defexpan.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 6 6 #include <umalloc.h> 7 7 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 8 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 9 #include <sys/rmutex.h> 8 #include <sys/fmutex.h> 10 9 #include <emx/umalloc.h> 11 10 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/defrelea.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 6 6 #include <umalloc.h> 7 7 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 8 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 9 #include <sys/rmutex.h> 8 #include <sys/fmutex.h> 10 9 #include <emx/umalloc.h> 11 10 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/defshrin.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 6 6 #include <umalloc.h> 7 7 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 8 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 9 #include <sys/rmutex.h> 8 #include <sys/fmutex.h> 10 9 #include <emx/umalloc.h> 11 10 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/expand.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 6 6 #include <umalloc.h> 7 7 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 8 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 9 #include <sys/rmutex.h> 8 #include <sys/fmutex.h> 10 9 #include <emx/umalloc.h> 11 10 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/free.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 6 6 #include <umalloc.h> 7 7 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 8 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 9 #include <sys/rmutex.h> 8 #include <sys/fmutex.h> 10 9 #include <emx/umalloc.h> 11 10 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/heapchk.c
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1453 r1454 6 6 #include <umalloc.h> 7 7 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 8 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 9 #include <sys/rmutex.h> 8 #include <sys/fmutex.h> 10 9 #include <emx/umalloc.h> 11 10 #include <InnoTekLIBC/thread.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/heapmin.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1453 r1454 6 6 #include <umalloc.h> 7 7 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 8 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 9 #include <sys/rmutex.h> 8 #include <sys/fmutex.h> 10 9 #include <emx/umalloc.h> 11 10 #include <InnoTekLIBC/thread.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/heapset.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1453 r1454 6 6 #include <umalloc.h> 7 7 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 8 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 9 #include <sys/rmutex.h> 8 #include <sys/fmutex.h> 10 9 #include <emx/umalloc.h> 11 10 #include <InnoTekLIBC/thread.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/iaddmem.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 7 7 #include <umalloc.h> 8 8 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 9 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 10 #include <sys/rmutex.h> 9 #include <sys/fmutex.h> 11 10 #include <emx/umalloc.h> 12 11 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/ialloc.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 8 8 #include <umalloc.h> 9 9 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 10 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 11 #include <sys/rmutex.h> 10 #include <sys/fmutex.h> 12 11 #include <emx/umalloc.h> 13 12 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/ifree.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 7 7 #include <umalloc.h> 8 8 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 9 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 10 #include <sys/rmutex.h> 9 #include <sys/fmutex.h> 11 10 #include <emx/umalloc.h> 12 11 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/imisc.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 7 7 #include <umalloc.h> 8 8 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 9 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 10 #include <sys/rmutex.h> 9 #include <sys/fmutex.h> 11 10 #include <emx/umalloc.h> 12 11 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/initr.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1453 r1454 1 1 /* initr.c (emx+gcc) -- Copyright (c) 1996 by Eberhard Mattes */ 2 2 3 4 /******************************************************************************* 5 * Header Files * 6 *******************************************************************************/ 3 7 #include "libc-alias.h" 4 8 #include <umalloc.h> … … 6 10 #include <sys/smutex.h> 7 11 #include <InnoTekLIBC/thread.h> 12 #include <InnoTekLIBC/fork.h> 13 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_HEAP 14 #include <InnoTekLIBC/logstrict.h> 8 15 16 17 /******************************************************************************* 18 * Global Variables * 19 *******************************************************************************/ 9 20 /** This is the default regular heap. */ 10 Heap_t _um_regular_heap; 21 Heap_t _um_regular_heap; 22 23 /** Fork cleanup indicator. */ 24 static int gfForkCleanupDone; 25 26 27 /******************************************************************************* 28 * Internal Functions * 29 *******************************************************************************/ 30 static int umForkParent1(__LIBC_PFORKHANDLE pForkHandle, __LIBC_FORKOP enmOperation); 31 static void umForkCompletion(void *pvArg, int rc, __LIBC_FORKCTX enmCtx); 32 33 11 34 12 35 /** … … 78 101 } 79 102 103 104 #undef __LIBC_LOG_GROUP 105 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_FORK 106 107 _FORK_PARENT1(0xffffff01, umForkParent1) 108 109 /** 110 * Parent fork callback. 111 * 112 * The purpose of this is to lock the three heaps we knows about while 113 * we're doing the fork() operation. 114 * 115 * @returns 0 on success. 116 * @returns -errno on failure. 117 * @param pForkHandle Pointer to fork handle. 118 * @param enmOperation Fork operation. 119 */ 120 static int umForkParent1(__LIBC_PFORKHANDLE pForkHandle, __LIBC_FORKOP enmOperation) 121 { 122 LIBCLOG_ENTER("pForkHandle=%p enmOperation=%d\n", (void *)pForkHandle, enmOperation); 123 int rc; 124 125 switch (enmOperation) 126 { 127 /* 128 * Lock the heaps before fork() scheduling an unlocking 129 * completion callback after fork() is done. 130 */ 131 case __LIBC_FORK_OP_EXEC_PARENT: 132 gfForkCleanupDone = 0; 133 rc = pForkHandle->pfnCompletionCallback(pForkHandle, umForkCompletion, NULL, __LIBC_FORK_CTX_BOTH); 134 if (rc >= 0) 135 { 136 LIBCLOG_MSG("Locking the heaps.\n"); 137 if (_um_tiled_heap) 138 _um_heap_lock(_um_tiled_heap); 139 if (_um_high_heap) 140 _um_heap_lock(_um_high_heap); 141 if (_um_low_heap) 142 _um_heap_lock(_um_low_heap); 143 } 144 break; 145 146 default: 147 rc = 0; 148 break; 149 } 150 LIBCLOG_RETURN_INT(rc); 151 } 152 153 154 /** 155 * Fork completion callback used to release the locks on the default heaps. 156 * 157 * @param pvArg NULL. 158 * @param rc The fork() result. Negative on failure. 159 * @param enmCtx The calling context. 160 */ 161 static void umForkCompletion(void *pvArg, int rc, __LIBC_FORKCTX enmCtx) 162 { 163 LIBCLOG_ENTER("pvArg=%p rc=%d enmCtx=%d - gfForkCleanupDone=%d\n", pvArg, rc, enmCtx, gfForkCleanupDone); 164 165 if (!gfForkCleanupDone) 166 { 167 LIBCLOG_MSG("Unlocking the heaps.\n"); 168 if (_um_tiled_heap) 169 _um_heap_unlock(_um_tiled_heap); 170 if (_um_high_heap) 171 _um_heap_unlock(_um_high_heap); 172 if (_um_low_heap) 173 _um_heap_unlock(_um_low_heap); 174 gfForkCleanupDone = 1; 175 } 176 LIBCLOG_RETURN_VOID(); 177 } 178 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/irealloc.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 8 8 #include <umalloc.h> 9 9 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 10 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 11 #include <sys/rmutex.h> 10 #include <sys/fmutex.h> 12 11 #include <emx/umalloc.h> 13 12 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/iwalk.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 6 6 #include <umalloc.h> 7 7 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 8 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 9 #include <sys/rmutex.h> 8 #include <sys/fmutex.h> 10 9 #include <emx/umalloc.h> 11 10 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/malloc.c
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r1453 r1454 6 6 #include <umalloc.h> 7 7 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 8 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 9 #include <sys/rmutex.h> 8 #include <sys/fmutex.h> 10 9 #include <emx/umalloc.h> 11 10 #include <InnoTekLIBC/thread.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/mheap.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 6 6 #include <umalloc.h> 7 7 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 8 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 9 #include <sys/rmutex.h> 8 #include <sys/fmutex.h> 10 9 #include <emx/umalloc.h> 11 10 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/msize.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 6 6 #include <umalloc.h> 7 7 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 8 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 9 #include <sys/rmutex.h> 8 #include <sys/fmutex.h> 10 9 #include <emx/umalloc.h> 11 10 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/realloc.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1453 r1454 6 6 #include <umalloc.h> 7 7 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 8 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 9 #include <sys/rmutex.h> 8 #include <sys/fmutex.h> 10 9 #include <emx/umalloc.h> 11 10 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/tcalloc.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 6 6 #include <umalloc.h> 7 7 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 8 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 9 #include <sys/rmutex.h> 8 #include <sys/fmutex.h> 10 9 #include <emx/umalloc.h> 11 10 #include <InnoTekLIBC/thread.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/tfree.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 6 6 #include <umalloc.h> 7 7 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 8 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 9 #include <sys/rmutex.h> 8 #include <sys/fmutex.h> 10 9 #include <emx/umalloc.h> 11 10 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/theapmin.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 6 6 #include <umalloc.h> 7 7 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 8 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 9 #include <sys/rmutex.h> 8 #include <sys/fmutex.h> 10 9 #include <emx/umalloc.h> 11 10 #include <InnoTekLIBC/thread.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/tmalloc.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 6 6 #include <umalloc.h> 7 7 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 8 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 9 #include <sys/rmutex.h> 8 #include <sys/fmutex.h> 10 9 #include <emx/umalloc.h> 11 10 #include <InnoTekLIBC/thread.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/trealloc.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 6 6 #include <umalloc.h> 7 7 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 8 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 9 #include <sys/rmutex.h> 8 #include <sys/fmutex.h> 10 9 #include <emx/umalloc.h> 11 10 #include <InnoTekLIBC/thread.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/uaddmem.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 6 6 #include <umalloc.h> 7 7 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 8 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 9 #include <sys/rmutex.h> 8 #include <sys/fmutex.h> 10 9 #include <emx/umalloc.h> 11 10 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/ucalloc.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 7 7 #include <umalloc.h> 8 8 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 9 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 10 #include <sys/rmutex.h> 9 #include <sys/fmutex.h> 11 10 #include <emx/umalloc.h> 12 11 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/uclose.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 6 6 #include <umalloc.h> 7 7 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 8 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 9 #include <sys/rmutex.h> 8 #include <sys/fmutex.h> 10 9 #include <emx/umalloc.h> 11 10 … … 15 14 || h == _um_regular_heap || h == _um_tiled_heap) 16 15 return -1; 17 _ rmutex_close (&h->rsem);16 _fmutex_close (&h->fsem); 18 17 return 0; 19 18 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/ucreate.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 6 6 #include <umalloc.h> 7 7 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 8 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 9 #include <sys/rmutex.h> 8 #include <sys/fmutex.h> 10 9 #include <emx/umalloc.h> 11 10 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/ucreate2.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 6 6 #include <umalloc.h> 7 7 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 8 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 9 #include <sys/rmutex.h> 8 #include <sys/fmutex.h> 10 9 #include <emx/umalloc.h> 11 10 … … 81 80 82 81 /* Initialize the mutex semaphore. */ 83 if (_ rmutex_create (&h->rsem, (type & _HEAP_SHARED) ? _FMC_SHARED : 0) != 0)82 if (_fmutex_create (&h->fsem, (type & _HEAP_SHARED) ? _FMC_SHARED : 0) != 0) 84 83 return NULL; 85 84 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/udefault.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 6 6 #include <umalloc.h> 7 7 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 8 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 9 #include <sys/rmutex.h> 8 #include <sys/fmutex.h> 10 9 #include <emx/umalloc.h> 11 10 #include <InnoTekLIBC/thread.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/udestroy.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 7 7 #include <umalloc.h> 8 8 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 9 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 10 #include <sys/rmutex.h> 9 #include <sys/fmutex.h> 11 10 #include <emx/umalloc.h> 12 11 … … 89 88 decrements the open count to 0, destroying the semaphore. */ 90 89 91 _ rmutex_close (&h->rsem);90 _fmutex_close (&h->fsem); 92 91 return 0; 93 92 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/uheapchk.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 6 6 #include <umalloc.h> 7 7 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 8 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 9 #include <sys/rmutex.h> 8 #include <sys/fmutex.h> 10 9 #include <emx/umalloc.h> 11 10 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/uheapmin.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 8 8 #include <umalloc.h> 9 9 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 10 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 11 #include <sys/rmutex.h> 10 #include <sys/fmutex.h> 12 11 #include <emx/umalloc.h> 13 12 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/uheapset.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 7 7 #include <umalloc.h> 8 8 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 9 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 10 #include <sys/rmutex.h> 9 #include <sys/fmutex.h> 11 10 #include <emx/umalloc.h> 12 11 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/umalloc.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 7 7 #include <umalloc.h> 8 8 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 9 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 10 #include <sys/rmutex.h> 9 #include <sys/fmutex.h> 11 10 #include <emx/umalloc.h> 12 11 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/uopen.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 6 6 #include <umalloc.h> 7 7 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 8 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 9 #include <sys/rmutex.h> 8 #include <sys/fmutex.h> 10 9 #include <emx/umalloc.h> 11 10 … … 15 14 || h == _um_regular_heap || h == _um_tiled_heap) 16 15 return -1; 17 if (_ rmutex_open (&h->rsem) != 0)16 if (_fmutex_open (&h->fsem) != 0) 18 17 return -1; 19 18 return 0; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/ustats.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 6 6 #include <umalloc.h> 7 7 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 8 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 9 #include <sys/rmutex.h> 8 #include <sys/fmutex.h> 10 9 #include <emx/umalloc.h> 11 10 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/utcalloc.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 7 7 #include <umalloc.h> 8 8 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 9 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 10 #include <sys/rmutex.h> 9 #include <sys/fmutex.h> 11 10 #include <emx/umalloc.h> 12 11 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/utdefaul.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 6 6 #include <umalloc.h> 7 7 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 8 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 9 #include <sys/rmutex.h> 8 #include <sys/fmutex.h> 10 9 #include <emx/umalloc.h> 11 10 #include <InnoTekLIBC/thread.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/utmalloc.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 7 7 #include <umalloc.h> 8 8 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 9 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 10 #include <sys/rmutex.h> 9 #include <sys/fmutex.h> 11 10 #include <emx/umalloc.h> 12 11 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/utype.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 6 6 #include <umalloc.h> 7 7 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 8 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 9 #include <sys/rmutex.h> 8 #include <sys/fmutex.h> 10 9 #include <emx/umalloc.h> 11 10 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/uwalk.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 6 6 #include <umalloc.h> 7 7 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 8 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 9 #include <sys/rmutex.h> 8 #include <sys/fmutex.h> 10 9 #include <emx/umalloc.h> 11 10 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/uwalk2.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 6 6 #include <umalloc.h> 7 7 #include <sys/builtin.h> /* For <sys/fmutex.h> */ 8 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 9 #include <sys/rmutex.h> 8 #include <sys/fmutex.h> 10 9 #include <emx/umalloc.h> 11 10 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/mbyte/mblen.c
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r1453 r1454 23 23 */ 24 24 25 #define __INTERNAL_DEFS26 25 #include "libc-alias.h" 27 26 #include <stdlib.h> 28 #include < sys/locale.h>27 #include <InnoTekLIBC/locale.h> 29 28 30 29 int _STD(mblen) (const char *s, size_t n) … … 33 32 if (!n) 34 33 return -1; 35 CHK_MBCS_PREFIX ( __locale_ctype, *s, pl);34 CHK_MBCS_PREFIX (&__libc_GLocaleCtype, *s, pl); 36 35 return pl ? pl : -1; 37 36 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/mbyte/mbstowcs.c
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r1453 r1454 25 25 #define INCL_FSMACROS 26 26 #include <os2emx.h> 27 #define __INTERNAL_DEFS28 27 #include "libc-alias.h" 29 #include < sys/locale.h>28 #include <InnoTekLIBC/locale.h> 30 29 #include <stdlib.h> 31 30 #include <string.h> … … 38 37 39 38 FS_SAVE_LOAD(); 40 rc = UniUconvToUcs (__l ocale_ctype.uconv, (void *)&s, &sl, &pwcs, &nw, &nonid);39 rc = UniUconvToUcs (__libc_GLocaleCtype.uobj, (void *)&s, &sl, &pwcs, &nw, &nonid); 41 40 FS_RESTORE(); 42 41 if (rc) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/mbyte/mbtowc.c
-
Property cvs2svn:cvs-rev
changed from
1.7
to1.8
r1453 r1454 27 27 #define INCL_FSMACROS 28 28 #include <os2emx.h> 29 #define __INTERNAL_DEFS30 29 #include "libc-alias.h" 31 #include < sys/locale.h>30 #include <InnoTekLIBC/locale.h> 32 31 #include <string.h> 33 32 #include <stdlib.h> … … 43 42 44 43 FS_SAVE_LOAD(); 45 rc = UniUconvToUcs (__l ocale_ctype.uconv, (void *)&s, &ni, &pwc, &no, &nonid);44 rc = UniUconvToUcs (__libc_GLocaleCtype.uobj, (void *)&s, &ni, &pwc, &no, &nonid); 46 45 FS_RESTORE(); 47 46 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/mbyte/wcstombs.c
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r1453 r1454 24 24 #define INCL_FSMACROS 25 25 #include <os2emx.h> 26 #define __INTERNAL_DEFS27 26 #include "libc-alias.h" 28 #include < sys/locale.h>27 #include <InnoTekLIBC/locale.h> 29 28 #include <string.h> 30 29 #include <stdlib.h> … … 37 36 38 37 FS_SAVE_LOAD(); 39 rc = UniUconvFromUcs (__l ocale_ctype.uconv, (UniChar **)&pwcs, &sl, (void *)&s, &nw, &nonid);38 rc = UniUconvFromUcs (__libc_GLocaleCtype.uobj, (UniChar **)&pwcs, &sl, (void *)&s, &nw, &nonid); 40 39 FS_RESTORE(); 41 40 if (rc) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/mbyte/wctomb.c
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r1453 r1454 19 19 #define INCL_FSMACROS 20 20 #include <os2emx.h> 21 #define __INTERNAL_DEFS22 21 #include "libc-alias.h" 23 #include < sys/locale.h>22 #include <InnoTekLIBC/locale.h> 24 23 #include <stdlib.h> 25 24 … … 35 34 36 35 FS_SAVE_LOAD(); 37 rc = UniUconvFromUcs (__l ocale_ctype.uconv, &ucs, &ni, (void **)&s, &no, &nonid);36 rc = UniUconvFromUcs (__libc_GLocaleCtype.uobj, &ucs, &ni, (void **)&s, &no, &nonid); 38 37 FS_RESTORE(); 39 38 if (rc) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/misc/abspath.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 1 1 /* abspath.c (emx+gcc) -- Copyright (c) 1992-1998 by Eberhard Mattes */ 2 2 3 #define __INTERNAL_DEFS4 3 #include "libc-alias.h" 5 4 #include <stdlib.h> … … 9 8 #include <sys/param.h> 10 9 #include <emx/syscalls.h> 11 #include < sys/locale.h>10 #include <InnoTekLIBC/locale.h> 12 11 13 12 #define FALSE 0 … … 72 71 while (*s != 0) 73 72 { 74 if (CHK_MBCS_PREFIX ( __locale_ctype, *s, mbcl) && s[1] != 0)73 if (CHK_MBCS_PREFIX (&__libc_GLocaleCtype, *s, mbcl) && s[1] != 0) 75 74 { 76 75 if (i < sizeof (dir) - mbcl) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/misc/defext.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 1 1 /* defext.c (emx+gcc) -- Copyright (c) 1990-1996 by Eberhard Mattes */ 2 2 3 #define __INTERNAL_DEFS4 3 #include "libc-alias.h" 5 4 #include <stdlib.h> 6 5 #include <string.h> 7 #include < sys/locale.h>6 #include <InnoTekLIBC/locale.h> 8 7 9 8 #define FALSE 0 … … 16 15 dot = FALSE; sep = TRUE; 17 16 while (*dst != 0) 18 if (CHK_MBCS_PREFIX ( __locale_ctype, *dst, mbcl))17 if (CHK_MBCS_PREFIX (&__libc_GLocaleCtype, *dst, mbcl)) 19 18 { 20 19 if (dst[1] == 0) /* Invalid DBCS character */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/misc/fnmatch.c
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1453 r1454 1 1 /* fnmatch.c (emx+gcc) -- Copyright (c) 1994-1998 by Eberhard Mattes */ 2 2 3 #define __INTERNAL_DEFS4 3 #include "libc-alias.h" 5 4 #include <string.h> 5 #include <emx/fnmatch.h> 6 #include <InnoTekLIBC/locale.h> 6 7 #include <ctype.h> 7 #include <emx/fnmatch.h>8 #include <sys/locale.h>9 8 10 9 /* In OS/2 and DOS styles, both / and \ separate components of a path. … … 32 31 33 32 while (!IS_OS2_COMP_END (*src)) 34 if (CHK_MBCS_PREFIX ( __locale_ctype, *src, mbcl) && src[1] != 0)33 if (CHK_MBCS_PREFIX (&__libc_GLocaleCtype, *src, mbcl) && src[1] != 0) 35 34 src += mbcl; 36 35 else … … 54 53 if (*p == ':') 55 54 return 1; 56 else if (CHK_MBCS_PREFIX ( __locale_ctype, p[0], mbcl) && p[1] != 0)55 else if (CHK_MBCS_PREFIX (&__libc_GLocaleCtype, p[0], mbcl) && p[1] != 0) 57 56 p += mbcl; 58 57 else … … 78 77 79 78 for (;;) 80 if (CHK_MBCS_PREFIX ( __locale_ctype, *mask, mbcl) && mask[1] != 0)79 if (CHK_MBCS_PREFIX (&__libc_GLocaleCtype, *mask, mbcl) && mask[1] != 0) 81 80 { 82 81 if (memicmp (mask, name, mbcl)) … … 125 124 if (*name != '.' && !IS_OS2_COMP_END (*name)) 126 125 { 127 if (CHK_MBCS_PREFIX ( __locale_ctype, name[0], mbcl) && name[1] != 0)126 if (CHK_MBCS_PREFIX (&__libc_GLocaleCtype, name[0], mbcl) && name[1] != 0) 128 127 name += mbcl; 129 128 else … … 151 150 if (*name == '.' && (flags & _FNM_STYLE_MASK) == _FNM_DOS) 152 151 return FNM_NOMATCH; 153 if (CHK_MBCS_PREFIX ( __locale_ctype, name[0], mbcl) && name[1] != 0)152 if (CHK_MBCS_PREFIX (&__libc_GLocaleCtype, name[0], mbcl) && name[1] != 0) 154 153 name += mbcl; 155 154 else … … 212 211 s = name; 213 212 while (!IS_OS2_COMP_END (*s) && *s != '.') 214 if (CHK_MBCS_PREFIX ( __locale_ctype, s[0], mbcl) && s[1] != 0)213 if (CHK_MBCS_PREFIX (&__libc_GLocaleCtype, s[0], mbcl) && s[1] != 0) 215 214 s += mbcl; 216 215 else … … 252 251 253 252 for (;;) 254 if (CHK_MBCS_PREFIX ( __locale_ctype, *mask, mbcl))253 if (CHK_MBCS_PREFIX (&__libc_GLocaleCtype, *mask, mbcl)) 255 254 { 256 255 if (memicmp (mask, name, mbcl)) … … 287 286 return FNM_NOMATCH; 288 287 ++mask; 289 if (CHK_MBCS_PREFIX ( __locale_ctype, name[0], mbcl) && name[1] != 0)288 if (CHK_MBCS_PREFIX (&__libc_GLocaleCtype, name[0], mbcl) && name[1] != 0) 290 289 name += mbcl; 291 290 else … … 315 314 if ((flags & FNM_PATHNAME) && IS_UNIX_COMP_SEP (*name)) 316 315 return FNM_NOMATCH; 317 if (CHK_MBCS_PREFIX ( __locale_ctype, name[0], mbcl) && name[1] != 0)316 if (CHK_MBCS_PREFIX (&__libc_GLocaleCtype, name[0], mbcl) && name[1] != 0) 318 317 name += mbcl; 319 318 else … … 365 364 ++mask; invert = 1; 366 365 } 367 else if (IS_MBCS_PREFIX ( __locale_ctype, *name))366 else if (IS_MBCS_PREFIX (&__libc_GLocaleCtype, *name)) 368 367 { 369 368 /* DBCS characters can only match inverted sets. */ … … 384 383 385 384 c1 = *mask++; 386 if (IS_MBCS_PREFIX ( __locale_ctype, c1))385 if (IS_MBCS_PREFIX (&__libc_GLocaleCtype, c1)) 387 386 return _FNM_ERR; /* DBCS characters not supported in sets */ 388 387 if (!(flags & FNM_NOESCAPE) && c1 == '\\') … … 406 405 break; 407 406 c2 = *mask++; 408 if (IS_MBCS_PREFIX ( __locale_ctype, c2))407 if (IS_MBCS_PREFIX (&__libc_GLocaleCtype, c2)) 409 408 return _FNM_ERR; /* DBCS chars not supported in sets */ 410 409 } … … 439 438 if (*name != 0) 440 439 { 441 if (CHK_MBCS_PREFIX ( __locale_ctype, name[0], mbcl) && name[1] != 0)440 if (CHK_MBCS_PREFIX (&__libc_GLocaleCtype, name[0], mbcl) && name[1] != 0) 442 441 name += mbcl; 443 442 else … … 597 596 int _STD(fnmatch) (const char *mask, const char *name, int flags) 598 597 { 599 return _fnmatch_unsigned ( mask,name, flags);600 } 598 return _fnmatch_unsigned ((const unsigned char *)mask, (const unsigned char *)name, flags); 599 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/misc/fnslashi.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 1 1 /* fnslashi.c (emx+gcc) -- Copyright (c) 1996 by Eberhard Mattes */ 2 2 3 #define __INTERNAL_DEFS4 3 #include "libc-alias.h" 5 4 #include <stdlib.h> 6 #include < sys/locale.h>5 #include <InnoTekLIBC/locale.h> 7 6 8 7 char *_fnslashify (char *name) … … 13 12 p = name; 14 13 while (*p != 0) 15 if (CHK_MBCS_PREFIX ( __locale_ctype, *p, mbcl) && p[1] != 0)14 if (CHK_MBCS_PREFIX (&__libc_GLocaleCtype, *p, mbcl) && p[1] != 0) 16 15 p += mbcl; 17 16 else if (*p == '\\') -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/misc/getext.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 1 1 /* getext.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */ 2 2 3 #define __INTERNAL_DEFS4 3 #include "libc-alias.h" 5 4 #include <stdlib.h> 6 5 #include <string.h> 7 #include < sys/locale.h>6 #include <InnoTekLIBC/locale.h> 8 7 9 8 #define FALSE 0 … … 17 16 sep = TRUE; dotp = NULL; 18 17 while (*path != 0) 19 if (CHK_MBCS_PREFIX ( __locale_ctype, *path, mbcl))18 if (CHK_MBCS_PREFIX (&__libc_GLocaleCtype, *path, mbcl)) 20 19 { 21 20 if (path[1] == 0) /* Invalid DBCS character */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/misc/getname.c
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1453 r1454 5 5 #include <stdlib.h> 6 6 #include <string.h> 7 #include < sys/locale.h>7 #include <InnoTekLIBC/locale.h> 8 8 9 9 char *_getname (const char *path) … … 14 14 p = path; 15 15 while (*path != 0) 16 if (CHK_MBCS_PREFIX ( __locale_ctype, *path, mbcl))16 if (CHK_MBCS_PREFIX (&__libc_GLocaleCtype, *path, mbcl)) 17 17 { 18 18 if (path[1] == 0) /* Invalid DBCS character */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/misc/makepath.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 1 1 /* makepath.c (emx+gcc) -- Copyright (c) 1993-1996 by Eberhard Mattes */ 2 2 3 #define __INTERNAL_DEFS4 3 #include "libc-alias.h" 5 4 #include <stdlib.h> 6 #include < sys/locale.h>5 #include <InnoTekLIBC/locale.h> 7 6 #include <string.h> 8 7 … … 24 23 while (n < _MAX_PATH - 1 && *dir != 0) 25 24 { 26 if (CHK_MBCS_PREFIX ( __locale_ctype, *dir, mbcl))25 if (CHK_MBCS_PREFIX (&__libc_GLocaleCtype, *dir, mbcl)) 27 26 { 28 27 if (dir[1] == 0) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/misc/remext.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 5 5 #include <stdlib.h> 6 6 #include <string.h> 7 #include < sys/locale.h>7 #include <InnoTekLIBC/locale.h> 8 8 9 9 #define FALSE 0 … … 17 17 dot = FALSE; sep = TRUE; dotp = NULL; 18 18 while (*path != 0) 19 if (CHK_MBCS_PREFIX ( __locale_ctype, *path, mbcl))19 if (CHK_MBCS_PREFIX (&__libc_GLocaleCtype, *path, mbcl)) 20 20 { 21 21 if (path[1] == 0) /* Invalid DBCS character */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/misc/splitpat.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 6 6 #include <string.h> 7 7 #include <sys/param.h> 8 #include < sys/locale.h>8 #include <InnoTekLIBC/locale.h> 9 9 10 10 void _splitpath (const char *src, char *drive, char *dir, char *fname, … … 15 15 i = 0; 16 16 while (src[i] != 0) 17 if (CHK_MBCS_PREFIX ( __locale_ctype, src[i], mbcl))17 if (CHK_MBCS_PREFIX (&__libc_GLocaleCtype, src[i], mbcl)) 18 18 { 19 19 if (src[i+1] == 0) /* Invalid DBCS character */ … … 34 34 else if (drive != NULL) 35 35 *drive = 0; 36 36 37 37 i = 0; j = 0; 38 38 while (src[j] != 0) 39 if (CHK_MBCS_PREFIX ( __locale_ctype, src[j], mbcl))39 if (CHK_MBCS_PREFIX (&__libc_GLocaleCtype, src[j], mbcl)) 40 40 { 41 41 if (src[j+1] == 0) /* Invalid DBCS character */ … … 51 51 _strncpy (dir, src, MIN (_MAX_DIR, i + 1)); 52 52 src += i; 53 53 54 54 i = 0; j = 0; 55 55 while (src[j] != 0) 56 if (CHK_MBCS_PREFIX ( __locale_ctype, src[j], mbcl))56 if (CHK_MBCS_PREFIX (&__libc_GLocaleCtype, src[j], mbcl)) 57 57 { 58 58 if (src[j+1] == 0) /* Invalid DBCS character */ … … 70 70 _strncpy (fname, src, MIN (_MAX_FNAME, i + 1)); 71 71 src += i; 72 72 73 73 if (ext != NULL) 74 74 _strncpy (ext, src, _MAX_EXT); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/misc/syserr.c
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1453 r1454 42 42 /* 35 EAGAIN */ "Resource temporarily unavailable", 43 43 /* 36 EINPROGRESS */ "Operation now in progress", 44 /* 37 EALREADY */ "Operation already in progress" 44 /* 37 EALREADY */ "Operation already in progress", 45 45 /* 38 ENOTSOCK */ "Socket operation on non-socket", 46 46 /* 39 EDESTADDRREQ */ "Destination address required", -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/process/386/_errno.s
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1453 r1454 6 6 .globl __errno_fun 7 7 8 .data 9 initterm_errno: 10 .long 0 11 8 12 .text 9 10 13 ALIGN 11 14 … … 13 16 __errno_fun: 14 17 movl ___libc_gpTLS, %eax 18 orl %eax, %eax 19 jnz ok 20 21 /* ignore calls before TLS inits. (fork registration failure) */ 22 movl $initterm_errno, %eax 23 jmp done 24 ALIGN 25 ok: 15 26 movl (%eax), %eax 16 27 orl %eax, %eax 17 28 jnz done 18 29 call ___libc_threadCurrentSlow 30 jmp done 31 32 ALIGN 19 33 done: 20 34 EPILOGUE(_errno) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/process/fmutex.c
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r1453 r1454 6 6 #define INCL_DOSERRORS 7 7 #define INCL_FSMACROS 8 #define INCL_EXAPIS 8 9 #include <os2.h> 9 10 #include <stdlib.h> … … 14 15 #include <InnoTekLIBC/logstrict.h> 15 16 17 16 18 /* These functions are available even in single-thread libraries. */ 17 19 … … 19 21 unsigned _fmutex_create(_fmutex *sem, unsigned flags) 20 22 { 21 LIBCLOG_ENTER("sem=%p flags=%#x\n", sem, flags);23 LIBCLOG_ENTER("sem=%p flags=%#x\n", (void *)sem, flags); 22 24 unsigned rc; 23 FS_VAR(); 25 24 26 sem->fs = _FMS_AVAILABLE; 25 27 sem->flags = flags; 26 28 sem->padding[0] = 'f'; 27 29 sem->padding[1] = 'm'; 28 FS_SAVE_LOAD(); 29 rc = DosCreateEventSem(NULL, (PHEV)&sem->hev, 30 (flags & _FMC_SHARED) ? DC_SEM_SHARED : 0, 31 FALSE); 32 FS_RESTORE(); 30 rc = DosCreateEventSemEx(NULL, (PHEV)&sem->hev, 31 (flags & _FMC_SHARED) ? DC_SEM_SHARED : 0, 32 FALSE); 33 33 34 LIBCLOG_RETURN_UINT(rc); 34 35 } … … 37 38 unsigned _fmutex_open(_fmutex *sem) 38 39 { 39 LIBCLOG_ENTER("sem=%p\n", sem); 40 unsigned rc; 41 FS_VAR(); 42 FS_SAVE_LOAD(); 43 rc = DosOpenEventSem(NULL, (PHEV)&sem->hev); 44 FS_RESTORE(); 40 LIBCLOG_ENTER("sem=%p\n", (void *)sem); 41 unsigned rc = DosOpenEventSemEx(NULL, (PHEV)&sem->hev); 45 42 LIBCLOG_RETURN_UINT(rc); 46 43 } … … 49 46 unsigned _fmutex_close(_fmutex *sem) 50 47 { 51 LIBCLOG_ENTER("sem=%p\n", sem); 52 unsigned rc; 53 FS_VAR(); 54 FS_SAVE_LOAD(); 55 rc = DosCloseEventSem(sem->hev); 56 FS_RESTORE(); 48 LIBCLOG_ENTER("sem=%p\n", (void *)sem); 49 unsigned rc = DosCloseEventSemEx(sem->hev); 57 50 LIBCLOG_RETURN_UINT(rc); 58 51 } … … 61 54 unsigned __fmutex_request_internal(_fmutex *sem, unsigned flags, signed char fs) 62 55 { 63 LIBCLOG_ENTER("sem=%p flags=%#x fs=%#x\n", sem, flags, (int)fs);64 ULONG rc, count;65 PTIB pTib;66 PPIB pPib;56 LIBCLOG_ENTER("sem=%p flags=%#x fs=%#x\n", (void *)sem, flags, (int)fs); 57 int rc; 58 PTIB pTib; 59 PPIB pPib; 67 60 68 61 if (fs == _FMS_UNINIT) … … 84 77 for (;;) 85 78 { 79 ULONG ulCount; 86 80 FS_VAR(); 87 81 FS_SAVE_LOAD(); 88 rc = DosResetEventSem(sem->hev, & count);82 rc = DosResetEventSem(sem->hev, &ulCount); 89 83 FS_RESTORE(); 90 84 if (rc != 0 && rc != ERROR_ALREADY_RESET) … … 96 90 do 97 91 { 98 rc = DosWaitEventSem 92 rc = DosWaitEventSem(sem->hev, sem->flags & _FMC_SHARED ? SEM_INDEFINITE_WAIT : 3000); 99 93 if (rc == ERROR_INTERRUPT) 100 94 { … … 146 140 unsigned __fmutex_release_internal(_fmutex *sem) 147 141 { 148 LIBCLOG_ENTER("sem=%p\n", sem);149 ULONGrc;142 LIBCLOG_ENTER("sem=%p\n", (void *)sem); 143 unsigned rc; 150 144 FS_VAR(); 151 145 … … 209 203 void _fmutex_dummy(_fmutex *sem) 210 204 { 211 LIBCLOG_ENTER("sem=%p\n", sem);205 LIBCLOG_ENTER("sem=%p\n", (void *)sem); 212 206 sem->fs = _FMS_AVAILABLE; 213 207 sem->hev = 0; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/process/fork.c
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r1453 r1454 4 4 #include <process.h> 5 5 #include <emx/syscalls.h> 6 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_ PROCESS6 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_FORK 7 7 #include <InnoTekLIBC/logstrict.h> 8 9 extern void _rmutex_fork(void);10 8 11 9 int _STD(fork)(void) … … 13 11 LIBCLOG_ENTER("\n"); 14 12 int pid = __fork(); 15 if (pid == 0)16 _rmutex_fork();17 13 LIBCLOG_RETURN_INT(pid); 18 14 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/startup/386/crt0.s
-
Property cvs2svn:cvs-rev
changed from
1.7
to1.8
r1453 r1454 32 32 #include <emx/asm386.h> 33 33 34 35 34 .globl __text 35 .globl __data 36 36 37 37 .text 38 38 39 39 __text: 40 41 #if defined (FORK) 42 /* Registering the fork module. If we're forking this call will not return. */ 43 pushl $1 44 pushl $ForkModule 45 call ___libc_ForkRegisterModule 46 addl $8, %esp 47 #endif 40 48 #if defined (HIGHMEM) 41 49 pushl $1 /* vote for high mem for default stack */ … … 43 51 pushl $0 /* veto agains high mem for default stack */ 44 52 #endif 45 53 call ___init_app 46 54 /* esp points to main() call frame. */ 47 55 cld 48 56 #if defined (MCRT0) 49 50 51 52 53 54 57 pushl $__mcleanup 58 call _atexit 59 pushl $__etext 60 pushl $__text 61 call _monstartup 62 addl $3*4, %esp 55 63 #endif 56 call __CRT_init 57 call _main 58 addl $3*4, %esp 59 pushl %eax 60 call _exit 61 1: jmp 1b /* Just in case exit() returns :-) */ 64 call __CRT_init 65 call _main 66 addl $3*4, %esp 67 do_exit: 68 pushl %eax 69 call _exit 70 1: jmp 1b /* Just in case exit() returns :-) */ 62 71 63 72 64 73 .data 65 74 66 75 __data: 67 .long 0xba0bab// Magic number (error detection)68 .long __os2dll// list of OS/2 DLL references76 .long 0xba0bab // Magic number (error detection) 77 .long __os2dll // list of OS/2 DLL references 69 78 70 71 72 73 74 75 76 77 79 .stabs "__os2dll", 21, 0, 0, 0xffffffff 80 .stabs "___CTOR_LIST__", 21, 0, 0, 0xffffffff 81 .stabs "___DTOR_LIST__", 21, 0, 0, 0xffffffff 82 .stabs "___crtinit1__", 21, 0, 0, 0xffffffff 83 .stabs "___crtexit1__", 21, 0, 0, 0xffffffff 84 .stabs "___eh_frame__", 21, 0, 0, 0xffffffff 85 .stabs "___eh_init__", 21, 0, 0, 0xffffffff 86 .stabs "___eh_term__", 21, 0, 0, 0xffffffff 78 87 88 #if defined (FORK) 89 .stabs "___fork_parent1__", 21, 0, 0, 0xffffffff 90 .stabs "___fork_child1__", 21, 0, 0, 0xffffffff 91 92 ForkModule: 93 .long 0x00010000 // uVersion 94 .long __atfork_callback // pfnAtFork 95 .long ___fork_parent1__ // papParent1 96 .long ___fork_child1__ // papChild1 97 .long __data // pvDataSegBase 98 .long _end // pvDataSegEnd 99 .long 0x00000001 // fFlags - __LIBC_FORKMODULE_FLAGS_EXECUTABLE 100 .long 0 // pNext 101 .long 0 // uReserved[8] 102 .long 0 // uReserved[8] 103 .long 0 // uReserved[8] 104 .long 0 // uReserved[8] 105 .long 0 // uReserved[8] 106 .long 0 // uReserved[8] 107 .long 0 // uReserved[8] 108 .long 0 // uReserved[8] 109 #endif 110 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/startup/386/dll0.s
-
Property cvs2svn:cvs-rev
changed from
1.9
to1.10
r1453 r1454 30 30 #include <emx/asm386.h> 31 31 32 33 32 .globl __text 33 .globl __data 34 34 35 35 .text 36 36 37 37 __text: … … 44 44 */ 45 45 do_common_init: 46 #if defined(FORK) 47 pushl $0 48 pushl $ForkModule 49 call ___libc_ForkRegisterModule 50 addl $8, %esp 51 cmpl $0, %eax 52 je do_init 53 jg do_fork 54 55 /* return failure (eax < 0). */ 56 xorl %eax, %eax 57 ret 58 59 /* return success - we're forking; no init. */ 60 do_fork: 61 xorl %eax, %eax 62 inc %al 63 ret 64 65 /* normal dll init. */ 66 do_init: 67 #endif 46 68 #if defined (HIGHMEM) 47 69 pushl $1 /* vote for high mem for default stack */ … … 49 71 pushl $0 /* veto against high mem for default stack */ 50 72 #endif 51 73 call ___init_dll 52 74 add $4, %esp 53 75 orl %eax, %eax … … 63 85 */ 64 86 do_initterm: 65 87 cld 66 88 jmp _DLL_InitTerm 67 89 68 90 69 91 .data 70 92 __data: 71 .long 0xba0bab// Magic number (error detection)72 .long __os2dll// list of OS/2 DLL references93 .long 0xba0bab // Magic number (error detection) 94 .long __os2dll // list of OS/2 DLL references 73 95 74 .stabs "__os2dll", 21, 0, 0, 0xffffffff 75 .stabs "___CTOR_LIST__", 21, 0, 0, 0xffffffff 76 .stabs "___DTOR_LIST__", 21, 0, 0, 0xffffffff 77 .stabs "___crtinit1__", 21, 0, 0, 0xffffffff 78 .stabs "___crtexit1__", 21, 0, 0, 0xffffffff 79 .stabs "___eh_frame__", 21, 0, 0, 0xffffffff 80 .stabs "___eh_init__", 21, 0, 0, 0xffffffff 81 .stabs "___eh_term__", 21, 0, 0, 0xffffffff 96 .stabs "__os2dll", 21, 0, 0, 0xffffffff 97 .stabs "___CTOR_LIST__", 21, 0, 0, 0xffffffff 98 .stabs "___DTOR_LIST__", 21, 0, 0, 0xffffffff 99 .stabs "___crtinit1__", 21, 0, 0, 0xffffffff 100 .stabs "___crtexit1__", 21, 0, 0, 0xffffffff 101 .stabs "___eh_frame__", 21, 0, 0, 0xffffffff 102 .stabs "___eh_init__", 21, 0, 0, 0xffffffff 103 .stabs "___eh_term__", 21, 0, 0, 0xffffffff 104 #if defined (FORK) 105 .stabs "___fork_parent1__", 21, 0, 0, 0xffffffff 106 .stabs "___fork_child1__", 21, 0, 0, 0xffffffff 82 107 108 ForkModule: 109 .long 0x00010000 // uVersion 110 .long __atfork_callback // pfnAtFork 111 .long ___fork_parent1__ // papParent1 112 .long ___fork_child1__ // papChild1 113 .long __data // pvDataSegBase 114 .long _end // pvDataSegEnd 115 .long 0 // fFlags 116 .long 0 // pNext 117 .long 0 // uReserved[8] 118 .long 0 // uReserved[8] 119 .long 0 // uReserved[8] 120 .long 0 // uReserved[8] 121 .long 0 // uReserved[8] 122 .long 0 // uReserved[8] 123 .long 0 // uReserved[8] 124 .long 0 // uReserved[8] 125 #endif 126 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/startup/_exit.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 5 5 6 6 /* mkstd.awk: NOUNDERSCORE(exit) */ 7 void _exit 7 void _exit(int ret) 8 8 { 9 if (ret < 0 || ret > 255) 10 ret = 255; 11 for (;;) 12 __exit (ret); 9 for (;;) 10 __exit(ret); 13 11 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/startup/startup.smak
-
Property cvs2svn:cvs-rev
changed from
1.12
to1.13
r1453 r1454 9 9 include common.smak 10 10 11 .OBJS += $(addprefix $.$(.TKIND.DIR)src/lib/startup/,mcrt0.o gcrt0.o crt0 hi.o dll0hi.o) \11 .OBJS += $(addprefix $.$(.TKIND.DIR)src/lib/startup/,mcrt0.o gcrt0.o crt0fork.o dll0fork.o crt0hi.o dll0hi.o crt0hifork.o dll0hifork.o) \ 12 12 $(addprefix $.omf/src/lib/startup/,mcrt0.obj gcrt0.obj \ 13 $(CPU)/crt0.obj $(CPU)/dll0.obj crt0 hi.obj dll0hi.obj)13 $(CPU)/crt0.obj $(CPU)/dll0.obj crt0fork.obj dll0fork.obj crt0hi.obj dll0hi.obj crt0hifork.obj dll0hifork.obj) 14 14 .DIRS := $(sort $(dir $(.OBJS))) 15 15 TARGDIRS += $(.DIRS) … … 21 21 $(call CP,$^,$(dir $@)) 22 22 23 $.aout/src/lib/startup/crt0fork.o: src/lib/startup/386/crt0.s 24 $(call DO.COMPILE.s, -DFORK) 25 26 $.aout/src/lib/startup/dll0fork.o: src/lib/startup/386/dll0.s 27 $(call DO.COMPILE.s, -DFORK) 28 23 29 $.aout/src/lib/startup/crt0hi.o: src/lib/startup/386/crt0.s 24 30 $(call DO.COMPILE.s, -DHIGHMEM) … … 26 32 $.aout/src/lib/startup/dll0hi.o: src/lib/startup/386/dll0.s 27 33 $(call DO.COMPILE.s, -DHIGHMEM) 34 35 $.aout/src/lib/startup/crt0hifork.o: src/lib/startup/386/crt0.s 36 $(call DO.COMPILE.s, -DHIGHMEM -DFORK) 37 38 $.aout/src/lib/startup/dll0hifork.o: src/lib/startup/386/dll0.s 39 $(call DO.COMPILE.s, -DHIGHMEM -DFORK) 40 28 41 29 42 $.aout/src/lib/startup/mcrt0.o: src/lib/startup/386/crt0.s … … 46 59 $.omf/src/lib/startup/gcrt0.obj: $.aout/src/lib/startup/gcrt0.o 47 60 $(call DO.EMXOMF,-m__text) 61 $.omf/src/lib/startup/dll0fork.obj: $.aout/src/lib/startup/dll0fork.o 62 $(call DO.EMXOMF,-l__text) 63 $.omf/src/lib/startup/crt0fork.obj: $.aout/src/lib/startup/crt0fork.o 64 $(call DO.EMXOMF,-m__text) 48 65 $.omf/src/lib/startup/dll0hi.obj: $.aout/src/lib/startup/dll0hi.o 49 66 $(call DO.EMXOMF,-l__text) 50 67 $.omf/src/lib/startup/crt0hi.obj: $.aout/src/lib/startup/crt0hi.o 68 $(call DO.EMXOMF,-m__text) 69 $.omf/src/lib/startup/dll0hifork.obj: $.aout/src/lib/startup/dll0hifork.o 70 $(call DO.EMXOMF,-l__text) 71 $.omf/src/lib/startup/crt0hifork.obj: $.aout/src/lib/startup/crt0hifork.o 51 72 $(call DO.EMXOMF,-m__text) 52 73 $.omf/src/lib/startup/386/dll0.obj: $.aout/src/lib/startup/386/dll0.o -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/str/memicmp.c
-
Property cvs2svn:cvs-rev
changed from
1.7
to1.8
r1453 r1454 10 10 #define INCL_FSMACROS 11 11 #include <os2emx.h> 12 #define __INTERNAL_DEFS13 12 #include "libc-alias.h" 14 #include < sys/locale.h>13 #include <InnoTekLIBC/locale.h> 15 14 #include <stddef.h> 16 15 #include <string.h> … … 28 27 c1 = *s1; c2 = *s2; 29 28 30 if (__l ocale_ctype.mbcs)29 if (__libc_GLocaleCtype.mbcs) 31 30 { 32 31 FS_VAR(); … … 37 36 int d; 38 37 39 if (IS_MBCS_PREFIX ( __locale_ctype, c1)40 || IS_MBCS_PREFIX ( __locale_ctype, c2))38 if (IS_MBCS_PREFIX (&__libc_GLocaleCtype, c1) 39 || IS_MBCS_PREFIX (&__libc_GLocaleCtype, c2)) 41 40 { 42 41 /* Translate unknown characters to Unicode, and compare them... … … 45 44 UniChar uc1, uc2; 46 45 int c1l, c2l; 47 if (!(c1l = __ to_ucs (__locale_ctype.uconv, s1, len, &uc1)))46 if (!(c1l = __libc_ucs2To (__libc_GLocaleCtype.uobj, s1, len, &uc1))) 48 47 uc1 = c1, c1l = 1; 49 48 else 50 uc1 = UniTransLower (__l ocale_ctype.locale, uc1);51 if (!(c2l = __ to_ucs (__locale_ctype.uconv, s2, len, &uc2)))49 uc1 = UniTransLower (__libc_GLocaleCtype.lobj, uc1); 50 if (!(c2l = __libc_ucs2To (__libc_GLocaleCtype.uobj, s2, len, &uc2))) 52 51 uc2 = c2, c2l = 1; 53 52 else 54 uc2 = UniTransLower (__l ocale_ctype.locale, uc2);53 uc2 = UniTransLower (__libc_GLocaleCtype.lobj, uc2); 55 54 d = uc1 - uc2; 56 55 c1l--; c2l--; … … 59 58 } 60 59 else 61 d = __l ocale_ctype.locase [c1] - __locale_ctype.locase[c2];60 d = __libc_GLocaleCtype.auchLower [c1] - __libc_GLocaleCtype.auchLower [c2]; 62 61 if (d) 63 62 { … … 79 78 for (;;) 80 79 { 81 int d = __l ocale_ctype.locase [c1] - __locale_ctype.locase[c2];80 int d = __libc_GLocaleCtype.auchLower [c1] - __libc_GLocaleCtype.auchLower [c2]; 82 81 if (d) 83 82 return d; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/str/strcoll.c
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1453 r1454 12 12 #define INCL_FSMACROS 13 13 #include <os2emx.h> 14 #define __INTERNAL_DEFS15 14 #include "libc-alias.h" 16 #include < sys/locale.h>15 #include <InnoTekLIBC/locale.h> 17 16 #include <alloca.h> 18 17 #include <string.h> … … 24 23 unsigned char c2 = *s2; 25 24 26 if (__l ocale_collate.mbcs)25 if (__libc_gLocaleCollate.mbcs) 27 26 { 28 27 FS_VAR(); … … 33 32 for (;;) 34 33 { 35 if (IS_MBCS_PREFIX ( __locale_collate, c1)36 || IS_MBCS_PREFIX ( __locale_collate, c2))34 if (IS_MBCS_PREFIX (&__libc_gLocaleCollate, c1) 35 || IS_MBCS_PREFIX (&__libc_gLocaleCollate, c2)) 37 36 { 38 37 /* Allright, we found a MBCS character. */ … … 49 48 UniChar *outbuf = ucs [i] = alloca (sl * sizeof (UniChar)); 50 49 51 if (UniUconvToUcs (__l ocale_collate.uconv, &inbuf, &in_left, &outbuf,50 if (UniUconvToUcs (__libc_gLocaleCollate.uobj, &inbuf, &in_left, &outbuf, 52 51 &out_left, &nonid)) 53 52 { … … 60 59 61 60 /* Okay, now we have two Unicode strings. Compare them. */ 62 d = UniStrcoll (__l ocale_collate.locale, ucs [0], ucs [1]);61 d = UniStrcoll (__libc_gLocaleCollate.lobj, ucs [0], ucs [1]); 63 62 FS_RESTORE(); 64 63 return d; 65 64 } 66 65 67 d = __l ocale_collate.weight [c1] - __locale_collate.weight [c2];66 d = __libc_gLocaleCollate.auchWeight [c1] - __libc_gLocaleCollate.auchWeight [c2]; 68 67 if (d || !c1 || !c2) 69 68 { … … 80 79 for (;;) 81 80 { 82 d = __l ocale_collate.weight [c1] - __locale_collate.weight [c2];81 d = __libc_gLocaleCollate.auchWeight [c1] - __libc_gLocaleCollate.auchWeight [c2]; 83 82 if (d || !c1 || !c2) 84 83 return d; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/str/stricmp.c
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r1453 r1454 10 10 #define INCL_FSMACROS 11 11 #include <os2emx.h> 12 #define __INTERNAL_DEFS13 12 #include "libc-alias.h" 14 #include < sys/locale.h>13 #include <InnoTekLIBC/locale.h> 15 14 #include <alloca.h> 15 #ifndef __USE_GNU /* __strnlen */ 16 # define __USE_GNU 17 #endif 16 18 #include <string.h> 17 18 static int __strnlen (const char *s, int maxlen)19 {20 int sl = 0;21 while (*s++ && maxlen--)22 sl++;23 return sl;24 }25 19 26 20 int _STD(stricmp) (__const__ char *s1, __const__ char *s2) … … 29 23 unsigned char c2 = *s2; 30 24 31 if (__l ocale_ctype.mbcs)25 if (__libc_GLocaleCtype.mbcs) 32 26 { 33 27 FS_VAR(); … … 38 32 int d; 39 33 40 if (IS_MBCS_PREFIX ( __locale_ctype, c1)41 || IS_MBCS_PREFIX ( __locale_ctype, c2))34 if (IS_MBCS_PREFIX (&__libc_GLocaleCtype, c1) 35 || IS_MBCS_PREFIX (&__libc_GLocaleCtype, c2)) 42 36 { 43 37 /* Translate unknown characters to Unicode, and compare them... … … 46 40 UniChar uc1, uc2; 47 41 int c1l, c2l; 48 if (!(c1l = __ to_ucs (__locale_ctype.uconv,s1, __strnlen (s1, 3), &uc1)))42 if (!(c1l = __libc_ucs2To (__libc_GLocaleCtype.uobj, (const unsigned char *)s1, __strnlen (s1, 3), &uc1))) 49 43 uc1 = c1, c1l = 1; 50 44 else 51 uc1 = UniTransLower (__l ocale_ctype.locale, uc1);52 if (!(c2l = __ to_ucs (__locale_ctype.uconv,s2, __strnlen (s2, 3), &uc2)))45 uc1 = UniTransLower (__libc_GLocaleCtype.lobj, uc1); 46 if (!(c2l = __libc_ucs2To (__libc_GLocaleCtype.uobj, (const unsigned char *)s2, __strnlen (s2, 3), &uc2))) 53 47 uc2 = c2, c2l = 1; 54 48 else 55 uc2 = UniTransLower (__l ocale_ctype.locale, uc2);49 uc2 = UniTransLower (__libc_GLocaleCtype.lobj, uc2); 56 50 d = uc1 - uc2; 57 51 s1 += c1l - 1; … … 59 53 } 60 54 else 61 d = __l ocale_ctype.locase [c1] - __locale_ctype.locase[c2];55 d = __libc_GLocaleCtype.auchLower [c1] - __libc_GLocaleCtype.auchLower [c2]; 62 56 63 57 if (d || !c1 || !c2) … … 75 69 for (;;) 76 70 { 77 int d = __l ocale_ctype.locase [c1] - __locale_ctype.locase[c2];71 int d = __libc_GLocaleCtype.auchLower [c1] - __libc_GLocaleCtype.auchLower [c2]; 78 72 if (d || !c1 || !c2) 79 73 return d; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/str/strlwr.c
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r1453 r1454 10 10 #define INCL_FSMACROS 11 11 #include <os2emx.h> 12 #define __INTERNAL_DEFS13 12 #include "libc-alias.h" 14 #include < sys/locale.h>13 #include <InnoTekLIBC/locale.h> 15 14 #include <string.h> 16 15 … … 20 19 (void)arg; 21 20 for (c = ucs; *c; c++) 22 *c = UniTransLower (__l ocale_ctype.locale, *c);21 *c = UniTransLower (__libc_GLocaleCtype.lobj, *c); 23 22 return 1; 24 23 } … … 29 28 unsigned char *s = (unsigned char *)string; 30 29 31 if (__l ocale_ctype.mbcs)30 if (__libc_GLocaleCtype.mbcs) 32 31 { 33 32 while ((c = *s)) 34 33 { 35 if (IS_MBCS_PREFIX ( __locale_ctype, c))34 if (IS_MBCS_PREFIX (&__libc_GLocaleCtype, c)) 36 35 { 37 /* Al lright, we encountered a MBCS character. Convert everything36 /* Alright, we encountered a MBCS character. Convert everything 38 37 until the end to Unicode, do the work in Unicode and then 39 38 convert back to MBCS. */ 40 39 FS_VAR(); 41 40 FS_SAVE_LOAD(); 42 __ do_Unicode (__locale_ctype.uconv,s, s, __uni_strlwr);41 __libc_ucs2Do (__libc_GLocaleCtype.uobj, (char *)s, s, __uni_strlwr); 43 42 FS_RESTORE(); 44 43 break; 45 44 } 46 *s++ = __l ocale_ctype.locase[c];45 *s++ = __libc_GLocaleCtype.auchLower [c]; 47 46 } 48 47 } 49 48 else 50 49 while ((c = *s)) 51 *s++ = __l ocale_ctype.locase[c];50 *s++ = __libc_GLocaleCtype.auchLower [c]; 52 51 53 52 return string; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/str/strnicmp.c
-
Property cvs2svn:cvs-rev
changed from
1.7
to1.8
r1453 r1454 11 11 #define INCL_FSMACROS 12 12 #include <os2emx.h> 13 #define __INTERNAL_DEFS14 13 #include "libc-alias.h" 15 14 #include <stddef.h> 16 #include <sys/locale.h>17 15 #include <string.h> 16 #include <InnoTekLIBC/locale.h> 17 18 18 19 19 int _STD(strnicmp) (__const__ char *s1, __const__ char *s2, size_t len) … … 27 27 c1 = *s1; c2 = *s2; 28 28 29 if (__l ocale_ctype.mbcs)29 if (__libc_GLocaleCtype.mbcs) 30 30 { 31 31 FS_VAR(); … … 36 36 int d; 37 37 38 if (IS_MBCS_PREFIX ( __locale_ctype, c1)39 || IS_MBCS_PREFIX ( __locale_ctype, c2))38 if (IS_MBCS_PREFIX (&__libc_GLocaleCtype, c1) 39 || IS_MBCS_PREFIX (&__libc_GLocaleCtype, c2)) 40 40 { 41 41 /* Translate unknown characters to Unicode, and compare them... … … 44 44 UniChar uc1, uc2; 45 45 int c1l, c2l; 46 if (!(c1l = __ to_ucs (__locale_ctype.uconv,s1, len, &uc1)))46 if (!(c1l = __libc_ucs2To (__libc_GLocaleCtype.uobj, (const unsigned char *)s1, len, &uc1))) 47 47 uc1 = c1, c1l = 1; 48 48 else 49 uc1 = UniTransLower (__l ocale_ctype.locale, uc1);50 if (!(c2l = __ to_ucs (__locale_ctype.uconv,s2, len, &uc2)))49 uc1 = UniTransLower (__libc_GLocaleCtype.lobj, uc1); 50 if (!(c2l = __libc_ucs2To (__libc_GLocaleCtype.uobj, (const unsigned char *)s2, len, &uc2))) 51 51 uc2 = c2, c2l = 1; 52 52 else 53 uc2 = UniTransLower (__l ocale_ctype.locale, uc2);53 uc2 = UniTransLower (__libc_GLocaleCtype.lobj, uc2); 54 54 d = uc1 - uc2; 55 55 c1l--; c2l--; … … 58 58 } 59 59 else 60 d = __l ocale_ctype.locase [c1] - __locale_ctype.locase[c2];60 d = __libc_GLocaleCtype.auchLower [c1] - __libc_GLocaleCtype.auchLower [c2]; 61 61 if (d || !c1 || !c2) 62 62 { … … 78 78 for (;;) 79 79 { 80 int d = __l ocale_ctype.locase [c1] - __locale_ctype.locase[c2];80 int d = __libc_GLocaleCtype.auchLower [c1] - __libc_GLocaleCtype.auchLower [c2]; 81 81 if (d || !c1 || !c2) 82 82 return d; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/str/strupr.c
-
Property cvs2svn:cvs-rev
changed from
1.7
to1.8
r1453 r1454 10 10 #define INCL_FSMACROS 11 11 #include <os2emx.h> 12 #define __INTERNAL_DEFS13 12 #include "libc-alias.h" 14 #include < sys/locale.h>13 #include <InnoTekLIBC/locale.h> 15 14 #include <string.h> 16 15 … … 20 19 (void)arg; 21 20 for (c = ucs; *c; c++) 22 *c = UniTransUpper (__l ocale_ctype.locale, *c);21 *c = UniTransUpper (__libc_GLocaleCtype.lobj, *c); 23 22 return 1; 24 23 } … … 29 28 unsigned char *s = (unsigned char *)string; 30 29 31 if (__l ocale_ctype.mbcs)30 if (__libc_GLocaleCtype.mbcs) 32 31 { 33 32 while ((c = *s)) 34 33 { 35 if (IS_MBCS_PREFIX ( __locale_ctype, c))34 if (IS_MBCS_PREFIX (&__libc_GLocaleCtype, c)) 36 35 { 37 36 /* Allright, we encountered a MBCS character. Convert everything … … 40 39 FS_VAR(); 41 40 FS_SAVE_LOAD(); 42 __ do_Unicode (__locale_ctype.uconv,s, s, __uni_strupr);41 __libc_ucs2Do (__libc_GLocaleCtype.uobj, (char *)s, s, __uni_strupr); 43 42 FS_RESTORE(); 44 43 break; 45 44 } 46 *s++ = __l ocale_ctype.upcase[c];45 *s++ = __libc_GLocaleCtype.auchUpper [c]; 47 46 } 48 47 } 49 48 else 50 49 while ((c = *s)) 51 *s++ = __l ocale_ctype.upcase[c];50 *s++ = __libc_GLocaleCtype.auchUpper [c]; 52 51 53 52 return string; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/str/strxfrm.c
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r1453 r1454 12 12 #define INCL_FSMACROS 13 13 #include <os2emx.h> 14 #define __INTERNAL_DEFS15 14 #include "libc-alias.h" 16 #include < sys/locale.h>15 #include <InnoTekLIBC/locale.h> 17 16 #include <stddef.h> 18 17 #include <string.h> … … 40 39 */ 41 40 42 size_t rs = UniStrxfrm (__l ocale_collate.locale, (UniChar *)x->out,41 size_t rs = UniStrxfrm (__libc_gLocaleCollate.lobj, (UniChar *)x->out, 43 42 ucs, x->size); 44 43 /* rs is in UniChar's without trailing zero */ … … 69 68 size_t ret = 1; /* We need at least space for trailing zero */ 70 69 71 if (__l ocale_collate.mbcs)70 if (__libc_gLocaleCollate.mbcs) 72 71 { 73 72 /* When using MBCS codepaes, we will convert the entire string to … … 81 80 x.out = s1; 82 81 x.size = size / sizeof (UniChar); 83 __ do_Unicode (__locale_collate.uconv, (char *)s2, &x, __uni_strxfrm);82 __libc_ucs2Do (__libc_gLocaleCollate.uobj, (char *)s2, &x, __uni_strxfrm); 84 83 FS_RESTORE(); 85 84 return x.size; … … 90 89 if (size) 91 90 { 92 *s1++ = __l ocale_collate.weight [c];91 *s1++ = __libc_gLocaleCollate.auchWeight [c]; 93 92 size--; 94 93 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__dup.c
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1453 r1454 71 71 * Done. 72 72 */ 73 if (rc != 0)73 if (rc) 74 74 { 75 _sys_set_errno(rc); 75 if (rc > 0) 76 _sys_set_errno(rc); 77 else 78 errno = -rc; 76 79 return -1; 77 80 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__dup2.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1453 r1454 104 104 if (rc) 105 105 { 106 _sys_set_errno(rc); 106 if (rc > 0) 107 _sys_set_errno(rc); 108 else 109 errno = -rc; 107 110 return -1; 108 111 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__exit.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1453 r1454 1 /* sys/exit.c (emx+gcc) -- Copyright (c) 1992-1993 by Eberhard Mattes */ 1 /* sys/exit.c (emx+gcc) -- Copyright (c) 1992-1993 by Eberhard Mattes 2 Copyright (c) 2004 knut st. osmundsen */ 2 3 3 4 #include "libc-alias.h" 4 5 #define INCL_FSMACROS 5 6 #include <os2emx.h> 6 void __exit (int rc); 7 #include <emx/syscalls.h> 8 #include <InnoTekLIBC/sharedpm.h> 7 9 8 void __exit 10 void __exit(int rc) 9 11 { 10 FS_VAR(); 11 FS_SAVE_LOAD(); 12 while (1) 13 DosExit (EXIT_PROCESS, rc); 12 FS_VAR(); 13 14 /* 15 * Update the SPM data base with the right exit reason and code. 16 */ 17 __libc_spmTerm(__LIBC_EXIT_REASON_EXIT, rc); 18 19 /* 20 * Actually exit the process. 21 */ 22 FS_SAVE_LOAD(); 23 for (;;) 24 DosExit(EXIT_PROCESS, rc < 0 || rc > 255 ? 255 : rc); 14 25 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__fcntl.c
-
Property cvs2svn:cvs-rev
changed from
1.7
to1.8
r1453 r1454 10 10 #define INCL_FSMACROS 11 11 #include <os2emx.h> 12 #include <386/builtin.h> 12 13 #include <emx/io.h> 13 14 #include <emx/syscalls.h> 14 15 #include "syscalls.h" 15 16 static int __fcntl_locking(int handle, int request, struct flock *pflock); 17 18 int __fcntl(int handle, int request, int arg) 16 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_IO 17 #include <InnoTekLIBC/logstrict.h> 18 19 20 /******************************************************************************* 21 * Internal Functions * 22 *******************************************************************************/ 23 static int __fcntl_getfd(__LIBC_PFH pFH, int hFile); 24 static int __fcntl_setfd(__LIBC_PFH pFH, int hFile, int arg); 25 static int __fcntl_locking(int hFile, int iRequest, struct flock *pFlock); 26 27 28 int __fcntl(int hFile, int iRequest, int arg) 19 29 { 20 ULONG rc; 21 ULONG fulState; 22 PLIBCFH pFH; 23 FS_VAR(); 30 LIBCLOG_ENTER("hFile=%d iRequest=%#x arg=%#x\n", hFile, iRequest, arg); 31 int rc; 32 __LIBC_PFH pFH; 24 33 25 34 /* 26 * Get the file h andle data.35 * Get the file hFile data. 27 36 */ 28 pFH = __libc_FH(h andle);37 pFH = __libc_FH(hFile); 29 38 if (!pFH) 30 39 { 31 40 errno = EBADF; 32 return -1;41 LIBCLOG_RETURN_INT(-1); 33 42 } 34 43 … … 36 45 { 37 46 /* 38 * Standard OS/2 File h andle.47 * Standard OS/2 File hFile. 39 48 */ 40 switch ( request)49 switch (iRequest) 41 50 { 42 51 /* … … 44 53 */ 45 54 case F_GETFL: 46 return pFH->fFlags & (O_ACCMODE | O_APPEND | O_NONBLOCK | O_SYNC /*| O_*SYNC*/); 55 { 56 unsigned fFlags = pFH->fFlags & (O_ACCMODE | O_APPEND | O_NONBLOCK | O_SYNC /*| O_*SYNC*/); 57 LIBCLOG_RETURN_INT(fFlags); 58 } 47 59 48 60 /* … … 50 62 */ 51 63 case F_SETFL: 64 { 52 65 /** @todo implement this properly. See FCNTLFLAGS. */ 53 return 0; 66 LIBC_ASSERTM_FAILED("F_SETFL isn't implemented but returns success. arg=%#x\n", arg); 67 LIBCLOG_RETURN_INT(0); 68 } 54 69 55 70 /* 56 71 * Get file descriptor flags. 57 * (At the moment FD_CLOEXEC is the only flag.)58 72 */ 59 73 case F_GETFD: 60 FS_SAVE_LOAD(); 61 rc = DosQueryFHState(handle, &fulState); 62 FS_RESTORE(); 63 if (rc != 0) 64 { 65 _sys_set_errno(rc); 66 return -1; 67 } 68 return ((fulState & OPEN_FLAGS_NOINHERIT) ? FD_CLOEXEC : 0); 74 rc = __fcntl_getfd(pFH, hFile); 75 LIBCLOG_RETURN_INT(rc); 69 76 70 77 /* 71 78 * Set file descriptor flags. 72 * (At the moment FD_CLOEXEC is the only flag.)73 79 */ 74 80 case F_SETFD: 75 FS_SAVE_LOAD(); 76 rc = DosQueryFHState(handle, &fulState); 77 if (!rc) 78 { 79 ULONG fulNewState; 80 if (arg & FD_CLOEXEC) 81 fulNewState = fulState | OPEN_FLAGS_NOINHERIT; 82 else 83 fulNewState = fulState & ~OPEN_FLAGS_NOINHERIT; 84 if (fulNewState != fulState) 85 { 86 fulNewState &= 0x7f88; /* Mask the flags accepted the API. */ 87 rc = DosSetFHState(handle, fulNewState); 88 } 89 } 90 FS_RESTORE(); 91 if (rc) 92 { 93 _sys_set_errno (rc); 94 return -1; 95 } 96 return 0; 81 rc = __fcntl_setfd(pFH, hFile, arg); 82 LIBCLOG_RETURN_INT(rc); 97 83 98 84 /* … … 102 88 case F_SETLK: /* set record locking information */ 103 89 case F_SETLKW: /* F_SETLK; wait if blocked */ 104 return __fcntl_locking(handle, request, (struct flock*)arg); 90 { 91 int rc = __fcntl_locking(hFile, iRequest, (struct flock*)arg); 92 LIBCLOG_RETURN_INT(rc); 93 } 105 94 106 95 default: 96 LIBC_ASSERTM_FAILED("Invalid iRequest %#x\n", iRequest); 107 97 errno = EINVAL; 108 return -1;98 LIBCLOG_RETURN_INT(-1); 109 99 } 110 100 } … … 112 102 { 113 103 /* 114 * Non-standard h andle - call registered method.104 * Non-standard hFile - call registered method. 115 105 */ 116 106 int rcRet = 0; 117 rc = pFH->pOps->pfnFileControl(pFH, h andle, request, arg, &rcRet);107 rc = pFH->pOps->pfnFileControl(pFH, hFile, iRequest, arg, &rcRet); 118 108 if (rc) 119 109 { 120 _sys_set_errno(rc); 121 return -1; 122 } 123 return rcRet; 110 if (rc > 0) 111 _sys_set_errno(rc); 112 else 113 errno = -rc; 114 LIBCLOG_RETURN_INT(-1); 115 } 116 117 /* 118 * Post process to keep the OS/2 fake hFile up to date (on success). 119 */ 120 switch (iRequest) 121 { 122 case F_SETFD: 123 rc = __fcntl_setfd(pFH, hFile, arg); 124 if (rc == -1) 125 LIBCLOG_RETURN_INT(-1); 126 break; 127 } 128 LIBCLOG_RETURN_INT(rcRet); 124 129 } 125 130 } 126 131 127 132 128 /* Handle locking requests. 129 130 Please excuse the Hungarian and indenting used in this code, 131 it's take from elsewhere. */ 132 133 static int __fcntl_locking(int hFile, int request, struct flock *pflock) 133 134 /** 135 * F_GETFD operation on standard OS/2 hFile. 136 * Gets file descriptor flags, which at the moment is limited to FD_CLOEXEC. 137 * 138 * @returns 0 on success. 139 * @returns -1 an errno on failure. 140 * @param pFH File handler structure. 141 * @param hFile File hFile. 142 */ 143 static int __fcntl_getfd(__LIBC_PFH pFH, int hFile) 144 { 145 LIBCLOG_ENTER("pFH=%p hFile=%d\n", (void *)pFH, hFile); 146 int rc; 147 ULONG fulState; 148 FS_VAR(); 149 150 FS_SAVE_LOAD(); 151 rc = DosQueryFHState(hFile, &fulState); 152 FS_RESTORE(); 153 if (!rc) 154 { 155 unsigned fFlags = pFH->fFlags; 156 /* flags out of sync? */ 157 if ( ( (fulState & OPEN_FLAGS_NOINHERIT) != 0 ) 158 != ( (fFlags & (O_NOINHERIT | (FD_CLOEXEC << __LIBC_FH_FDFLAGS_SHIFT))) 159 == (O_NOINHERIT | (FD_CLOEXEC << __LIBC_FH_FDFLAGS_SHIFT)) ) ) 160 { 161 LIBC_ASSERTM_FAILED("Inherit flags are out of sync for file hFile %d (%#x)! fulState=%08lx fFlags=%08x\n", 162 hFile, hFile, fulState, fFlags); 163 if (fulState & OPEN_FLAGS_NOINHERIT) 164 fFlags |= O_NOINHERIT | FD_CLOEXEC; 165 else 166 fFlags &= ~(O_NOINHERIT | FD_CLOEXEC); 167 __atomic_xchg(&pFH->fFlags, fFlags); 168 } 169 170 fFlags >>= __LIBC_FH_FDFLAGS_SHIFT; 171 LIBCLOG_RETURN_INT(fFlags); 172 } 173 174 /* failure. */ 175 _sys_set_errno(rc); 176 LIBCLOG_RETURN_INT(-1); 177 } 178 179 180 /** 181 * F_SETFD operation on standard OS/2 hFile. 182 * Sets file descriptor flags, which at the moment is limited to FD_CLOEXEC. 183 * 184 * @returns 0 on success. 185 * @returns -1 an errno on failure. 186 * @param pFH File handler structure. 187 * @param hFile File hFile. 188 * @param arg New file descriptor flags. 189 */ 190 static int __fcntl_setfd(__LIBC_PFH pFH, int hFile, int arg) 191 { 192 LIBCLOG_ENTER("pFH=%p hFile=%d arg=%#x\n", (void *)pFH, hFile, arg); 193 int rc; 194 ULONG fulState; 195 FS_VAR(); 196 197 FS_SAVE_LOAD(); 198 rc = DosQueryFHState(hFile, &fulState); 199 if (!rc) 200 { 201 ULONG fulNewState; 202 LIBC_ASSERTM( ( (fulState & OPEN_FLAGS_NOINHERIT) != 0 ) 203 == ( (pFH->fFlags & (O_NOINHERIT | (FD_CLOEXEC << __LIBC_FH_FDFLAGS_SHIFT))) 204 == (O_NOINHERIT | (FD_CLOEXEC << __LIBC_FH_FDFLAGS_SHIFT)) ), 205 "Inherit flags are out of sync for file hFile %d (%#x)! fulState=%08lx fFlags=%08x\n", 206 hFile, hFile, fulState, pFH->fFlags); 207 if (arg & FD_CLOEXEC) 208 fulNewState = fulState | OPEN_FLAGS_NOINHERIT; 209 else 210 fulNewState = fulState & ~OPEN_FLAGS_NOINHERIT; 211 if (fulNewState != fulState) 212 { 213 fulNewState &= 0x7f88; /* Mask the flags accepted the API. */ 214 rc = DosSetFHState(hFile, fulNewState); 215 } 216 } 217 FS_RESTORE(); 218 219 if (!rc) 220 { 221 unsigned fFlags = pFH->fFlags; 222 fFlags = (fFlags & ~__LIBC_FH_FDFLAGS_MASK) | (arg << __LIBC_FH_FDFLAGS_SHIFT); 223 if (arg & FD_CLOEXEC) 224 fFlags |= O_NOINHERIT; 225 else 226 fFlags &= ~O_NOINHERIT; 227 __atomic_xchg(&pFH->fFlags, fFlags); 228 LIBCLOG_RETURN_INT(0); 229 } 230 231 /* error! */ 232 _sys_set_errno(rc); 233 LIBCLOG_RETURN_INT(-1); 234 } 235 236 237 /** 238 * Handle locking requests. 239 * @returns 240 * @param hFile File hFile. 241 * @param iRequest Lock iRequest. 242 * @param pFlock Pointer to flock structure. 243 */ 244 static int __fcntl_locking(int hFile, int iRequest, struct flock *pFlock) 134 245 { 135 246 APIRET rc; … … 146 257 /* check input */ 147 258 /** @todo: Implement F_GETLK */ 148 if (!p flock || request == F_GETLK)259 if (!pFlock || iRequest == F_GETLK) 149 260 { 150 261 errno = EINVAL; … … 180 291 181 292 /* range */ 182 cbRange = p flock->l_len ? pflock->l_len : OFF_MAX;293 cbRange = pFlock->l_len ? pFlock->l_len : OFF_MAX; 183 294 184 295 /* offset */ 185 switch (p flock->l_whence)186 { 187 case SEEK_SET: offStart = p flock->l_start; break;188 case SEEK_CUR: offStart = tell(hFile) + p flock->l_start; break;189 case SEEK_END: offStart = cbFile - p flock->l_start; break;296 switch (pFlock->l_whence) 297 { 298 case SEEK_SET: offStart = pFlock->l_start; break; 299 case SEEK_CUR: offStart = tell(hFile) + pFlock->l_start; break; 300 case SEEK_END: offStart = cbFile - pFlock->l_start; break; 190 301 default: 191 302 errno = EINVAL; … … 201 312 /* flags and order */ 202 313 fAccess = 0; /* exclusive */ 203 switch (p flock->l_type)314 switch (pFlock->l_type) 204 315 { 205 316 case F_UNLCK: … … 219 330 220 331 /* timeout */ 221 if ( request == F_SETLKW)332 if (iRequest == F_SETLKW) 222 333 ulTimeout = SEM_INDEFINITE_WAIT; 223 334 else -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__fstat.c
-
Property cvs2svn:cvs-rev
changed from
1.8
to1.9
r1453 r1454 52 52 LIBCLOG_RETURN_INT(-1); 53 53 } 54 switch (pFH->fFlags & F_TYPEMASK)54 switch (pFH->fFlags & __LIBC_FH_TYPEMASK) 55 55 { 56 56 case F_DEV: pStat->st_mode = S_IFCHR; break; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__init.c
-
Property cvs2svn:cvs-rev
changed from
1.12
to1.13
r1453 r1454 26 26 #include <alloca.h> 27 27 #include <InnoTekLIBC/thread.h> 28 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_INITTERM 29 #include <InnoTekLIBC/logstrict.h> 28 30 29 31 … … 440 442 { 441 443 __asm__ ("cld"); /* Don't trust */ 444 LIBCLOG_MSG2("!!! num %08lx flags %08lx nested %p whatever %p\n", report->ExceptionNum, report->fHandlerFlags, report->NestedExceptionReportRecord, whatever); 442 445 if (report->fHandlerFlags & (EH_UNWINDING | EH_EXIT_UNWIND)) 443 446 return XCPT_CONTINUE_SEARCH; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__initdll.c
-
Property cvs2svn:cvs-rev
changed from
1.10
to1.11
r1453 r1454 24 24 #undef _osminor 25 25 #include <string.h> 26 #include <errno.h> 26 27 #include <sys/builtin.h> 27 28 #include <sys/fmutex.h> … … 30 31 #include <emx/umalloc.h> 31 32 #include <alloca.h> 33 #include <InnoTekLIBC/fork.h> 32 34 #include "syscalls.h" 33 35 #include <InnoTekLIBC/thread.h> 36 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_INITTERM 37 #include <InnoTekLIBC/logstrict.h> 34 38 35 39 /* Make this function an weak external. */ 36 40 #pragma weak __init_largefileio 41 42 /******************************************************************************* 43 * Structures and Typedefs * 44 *******************************************************************************/ 45 /** 46 * Argument to initdllForkTLM(). 47 */ 48 typedef struct TLMARGS_s 49 { 50 /** Pointer to the TLM entry. */ 51 PULONG pTLM; 52 /** Pointer to the current thread. */ 53 __LIBC_PTHREAD pCurThread; 54 } TLMARGS, *PTLMARGS; 37 55 38 56 … … 46 64 47 65 66 /******************************************************************************* 67 * Internal Functions * 68 *******************************************************************************/ 69 static int initdllForkParent1(__LIBC_PFORKHANDLE pForkHandle, __LIBC_FORKOP enmOperation); 70 static int initdllForkChild1(__LIBC_PFORKHANDLE pForkHandle, __LIBC_FORKOP enmOperation); 71 static int initdllForkTLM(__LIBC_PFORKHANDLE pForkHandle, void *pvArg, size_t cbArg); 72 73 48 74 /** 49 75 * Common init code for crt0 and dll0. … … 52 78 int __init_dll(int fDefaultHeapInHighMem) 53 79 { 54 ULONG aul[2]; 55 ULONG rc; 56 PTIB ptib; 57 PPIB ppib; 58 static int initialized = 0; 80 ULONG aul[2]; 81 int rc; 82 PTIB ptib; 83 PPIB ppib; 84 __LIBC_PSPMPROCESS pSelf; 85 static int fInitialized = 0; 59 86 60 87 /* … … 66 93 * The rest must only be executed once. 67 94 */ 68 if ( initialized)95 if (fInitialized) 69 96 return 0; 70 initialized = 1;97 fInitialized = 1; 71 98 72 99 /* … … 106 133 if (_fmutex_create(&_sys_gmtxHimem, 0) != 0) 107 134 return -1; 135 if (_fmutex_create(&__libc_gmtxExec, 0) != 0) 136 return -1; 108 137 109 138 /* 110 139 * Initialize TLS. 111 140 */ 112 if (!__libc_gpTLS) /* !paranoia! */113 {114 rc = DosAllocThreadLocalMemory(1, (PULONG*)&__libc_gpTLS);115 if (rc)116 141 rc = DosAllocThreadLocalMemory(1, (PULONG*)(void*)&__libc_gpTLS); 142 if (rc) 143 { 144 LIBC_ASSERTM_FAILED("DosAllocThreadLocalMemory() failed. rc=%d\n", rc); 145 return -1; 117 146 } 118 147 … … 122 151 rc = _sys_init_environ(ppib->pib_pchenv); 123 152 if (rc) 124 return -1; 153 { 154 LIBC_ASSERTM_FAILED("_sys_init_environ() failed\n"); 155 return -1; 156 } 157 158 /* 159 * Get the current process. 160 */ 161 pSelf = __libc_spmSelf(); 162 if (!pSelf) 163 { 164 LIBC_ASSERTM_FAILED("__libc_spmSelf() failed\n"); 165 return -1; 166 } 125 167 126 168 /* … … 135 177 * Init file handles. 136 178 */ 137 rc = _ sys_init_filehandles();179 rc = __libc_fhInit(pSelf->pInherit ? pSelf->pInherit->pFHBundles : NULL); 138 180 if (rc) 139 return -1; 181 { 182 LIBC_ASSERTM_FAILED("__libc_fhInit(%p) failed\n", pSelf->pInherit ? (void *)pSelf->pInherit->pFHBundles : NULL); 183 return -1; 184 } 140 185 141 186 /* … … 146 191 } 147 192 193 194 #undef __LIBC_LOG_GROUP 195 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_FORK 196 197 _FORK_PARENT1(0xffffffff, initdllForkParent1) 198 199 /** 200 * Fork callback which transfere the TLM to the child. 201 * 202 * @returns 0 on success. 203 * @returns -errno on failure. 204 * @param pForkHandle Pointer to fork handle. 205 * @param enmOperation Fork operation. 206 */ 207 int initdllForkParent1(__LIBC_PFORKHANDLE pForkHandle, __LIBC_FORKOP enmOperation) 208 { 209 LIBCLOG_ENTER("pForkHandle=%p enmOperation=%d\n", (void *)pForkHandle, enmOperation); 210 int rc; 211 switch (enmOperation) 212 { 213 case __LIBC_FORK_OP_EXEC_PARENT: 214 { 215 TLMARGS Args; 216 Args.pTLM = (PULONG)__libc_gpTLS; 217 Args.pCurThread = *__libc_gpTLS; 218 rc = pForkHandle->pfnInvoke(pForkHandle, initdllForkTLM, &Args, sizeof(Args)); 219 break; 220 } 221 222 default: 223 rc = 0; 224 break; 225 } 226 227 LIBCLOG_RETURN_INT(rc); 228 } 229 230 231 _FORK_CHILD1(0xffffffff, initdllForkChild1) 232 233 /** 234 * Fork callback which updates the thread structure in the child. 235 * 236 * @returns 0 on success. 237 * @returns -errno on failure. 238 * @param pForkHandle Pointer to fork handle. 239 * @param enmOperation Fork operation. 240 */ 241 static int initdllForkChild1(__LIBC_PFORKHANDLE pForkHandle, __LIBC_FORKOP enmOperation) 242 { 243 LIBCLOG_ENTER("pForkHandle=%p enmOperation=%d\n", (void *)pForkHandle, enmOperation); 244 int rc; 245 switch (enmOperation) 246 { 247 case __LIBC_FORK_OP_FORK_CHILD: 248 { 249 LIBCLOG_MSG("Adjusts thread nesting level. from %d to %d\n", (*__libc_gpTLS)->cDefLoggerDepth, 250 (*__libc_gpTLS)->cDefLoggerDepth - 2); 251 (*__libc_gpTLS)->cDefLoggerDepth -= 2; 252 rc = 0; 253 break; 254 } 255 256 default: 257 rc = 0; 258 break; 259 } 260 261 LIBCLOG_RETURN_INT(rc); 262 } 263 264 265 /** 266 * Callback which allocates the TLM entry which the parent is using. 267 * and initializes it with the pointer to the thread used by the 268 * parent. The global variable is not set, we must wait on the 269 * data segment and heap duplication there. 270 * 271 * @returns 0 on success. 272 * @returns -errno on failure. 273 * @param pForkHandle Pointer to fork handle. 274 * @param pvArg Pointer to a TLMARGS structure. 275 * @param cbArg Size of argument pointed to by pvArg. 276 */ 277 static int initdllForkTLM(__LIBC_PFORKHANDLE pForkHandle, void *pvArg, size_t cbArg) 278 { 279 LIBCLOG_ENTER("pForkHandle=%p pvArg=%p cbArg=%d\n", (void *)pForkHandle, pvArg, cbArg); 280 PTLMARGS pArgs = (PTLMARGS)pvArg; 281 int rc = 0; 282 PULONG apulTLM[64]; 283 int iTLM; 284 LIBC_ASSERT(cbArg == sizeof(TLMARGS)); 285 286 for (iTLM = 0; iTLM < sizeof(apulTLM) / sizeof(apulTLM[0]); iTLM++) 287 { 288 /* 289 * Allocate. 290 */ 291 rc = DosAllocThreadLocalMemory(1, &apulTLM[iTLM]); 292 if (rc) 293 break; 294 295 /* 296 * The right one? 297 */ 298 if (apulTLM[iTLM] == pArgs->pTLM) 299 { 300 *apulTLM[iTLM] = (ULONG)pArgs->pCurThread; 301 break; 302 } 303 } 304 305 /* 306 * Cleanup. 307 */ 308 while (iTLM-- > 0) 309 DosFreeThreadLocalMemory(apulTLM[iTLM]); 310 311 if (!rc) 312 LIBCLOG_RETURN_INT(0); 313 LIBCLOG_RETURN_INT(-ENOMEM); 314 } 315 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__ioctl2.c
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r1453 r1454 114 114 if (rc) 115 115 { 116 _sys_set_errno(rc); 116 if (rc > 0) 117 _sys_set_errno(rc); 118 else 119 errno = -rc; 117 120 return -1; 118 121 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__read.c
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r1453 r1454 45 45 * Allocate a buffer in the low heap. 46 46 */ 47 if ( (pFH->fFlags & F_TYPEMASK) == F_DEV47 if ( (pFH->fFlags & __LIBC_FH_TYPEMASK) == F_DEV 48 48 && (unsigned)buf >= 512*1024*1024) 49 49 { … … 78 78 if (rc) 79 79 { 80 _sys_set_errno(rc); 80 if (rc > 0) 81 rc = -__libc_native2errno(rc); 82 81 83 /* If we don't have read access, EBADF should be returned, not EACCES. */ 82 if ( errno ==EACCES84 if ( rc == -EACCES 83 85 && (pFH->fFlags & O_ACCMODE) != O_RDONLY 84 86 && (pFH->fFlags & O_ACCMODE) != O_RDWR) 85 errno = EBADF; 87 rc = -EBADF; 88 errno = -rc; 86 89 return -1; 87 90 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__spawnve.c
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r1453 r1454 11 11 #include <os2emx.h> 12 12 #include <emx/syscalls.h> 13 #include <InnoTekLIBC/sharedpm.h> 13 14 #include "syscalls.h" 15 16 17 /** 18 * Collects and creates the inherit stuff we send down to a LIBC child. 19 * @returns Pointer to inherit structure on success. 20 * @returns NULL and errno on failure. 21 */ 22 static __LIBC_PSPMINHERIT doInherit(void) 23 { 24 size_t cbFH; 25 __LIBC_PSPMINHFHBHDR pFH; 26 __LIBC_PSPMINHERIT pRet = NULL; 27 28 /* 29 * Get FH stuff. 30 */ 31 pFH = __libc_fhInheritPack(&cbFH); 32 if (pFH) 33 { 34 /* 35 * Allocate shared memory. 36 */ 37 size_t cb = sizeof(__LIBC_SPMINHERIT) + ((cbFH + 3) & ~3); 38 pRet = __libc_spmAlloc(cb); 39 if (pRet) 40 { 41 pRet->cb = sizeof(*pRet); 42 pRet->pFHBundles = (__LIBC_PSPMINHFHBHDR)(pRet + 1); 43 memcpy(pRet->pFHBundles, pFH, cbFH); 44 free(pFH); 45 return pRet; 46 } 47 /* cleanup on failure */ 48 __libc_fhInheritDone(); 49 free(pFH); 50 } 51 52 return pRet; 53 } 54 55 56 /** 57 * Cleans up any globale inherit stuff. 58 */ 59 static void doInheritDone(void) 60 { 61 __libc_fhInheritDone(); 62 } 14 63 15 64 /* Note: We are allowed to call _trealloc() as this module is not used … … 41 90 size_t arg_size, arg_alloc, len; 42 91 int i, quote, bs, method; 92 __LIBC_PSPMPROCESS pEmbryo; 43 93 FS_VAR(); 44 94 … … 142 192 *arg_ptr++ = '\0'; 143 193 *arg_ptr++ = '\0'; 144 FS_SAVE_LOAD(); 145 rc = DosExecPgm (obj, sizeof (obj), exec_flag, arg_buf, 146 (const char *)np->env_off, &res, pgm_name); 147 FS_RESTORE(); 194 195 /* 196 * Now create an embryo process. 197 */ 198 pEmbryo = __libc_spmCreateEmbryo(getpid()); 199 if (pEmbryo) 200 { 201 /* 202 * Do inheritance stuff. 203 */ 204 pEmbryo->pInherit = doInherit(); 205 if (pEmbryo->pInherit) 206 { 207 /* 208 * Create the process. 209 */ 210 FS_SAVE_LOAD(); 211 rc = DosExecPgm (obj, sizeof (obj), exec_flag, (PCSZ)arg_buf, (PCSZ)np->env_off, &res, (PCSZ)pgm_name); 212 FS_RESTORE(); 213 if (!rc) 214 { 215 /* cleanup embryo and other stuff. */ 216 __libc_spmRelease(pEmbryo); 217 doInheritDone(); 218 if (arg_buf != NULL) 219 _tfree (arg_buf); 220 221 /* exit depends on the mode. */ 222 switch (mode & 0xff) 223 { 224 case P_WAIT: 225 return res.codeResult; 226 case P_NOWAIT: 227 return res.codeTerminate; 228 case P_OVERLAY: 229 FS_SAVE_LOAD(); 230 while (1) 231 DosExit (EXIT_PROCESS, 0); 232 default: 233 errno = EINVAL; 234 return -1; 235 } 236 /* won't ever get here! */ 237 } 238 else 239 _sys_set_errno (rc); 240 doInheritDone(); 241 } 242 /* cleanup embryo */ 243 __libc_spmRelease(pEmbryo); 244 } 245 148 246 if (arg_buf != NULL) 149 247 _tfree (arg_buf); 150 if (rc != 0) 151 { 152 _sys_set_errno (rc); 153 return -1; 154 } 155 switch (mode & 0xff) 156 { 157 case P_WAIT: 158 return res.codeResult; 159 case P_NOWAIT: 160 return res.codeTerminate; 161 case P_OVERLAY: 162 FS_SAVE_LOAD(); 163 while (1) 164 DosExit (EXIT_PROCESS, 0); 165 default: 166 errno = EINVAL; 167 return -1; 168 } 248 return -1; 169 249 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__write.c
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r1453 r1454 45 45 * Devices doesn't like getting high addresses. 46 46 */ 47 if ( (pFH->fFlags & F_TYPEMASK) == F_DEV47 if ( (pFH->fFlags & __LIBC_FH_TYPEMASK) == F_DEV 48 48 && (unsigned)buf >= 512*1024*1024) 49 49 { … … 87 87 if (rc) 88 88 { 89 _sys_set_errno(rc); 89 if (rc > 0) 90 rc = -__libc_native2errno(rc); 91 90 92 /* If we don't have write access, EBADF should be returned, not EACCES. */ 91 if ( errno ==EACCES93 if ( rc == -EACCES 92 94 && (pFH->fFlags & O_ACCMODE) != O_WRONLY 93 95 && (pFH->fFlags & O_ACCMODE) != O_RDWR) 94 errno = EBADF; 96 rc = -EBADF; 97 errno = -rc; 95 98 return -1; 96 99 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/filehandles.c
-
Property cvs2svn:cvs-rev
changed from
1.8
to1.9
r1453 r1454 4 4 * LIBC File Handles. 5 5 * 6 * Copyright (c) 2003 knut st. osmundsen <bird-srcspam@anduin.net>6 * Copyright (c) 2003-2004 knut st. osmundsen <bird-srcspam@anduin.net> 7 7 * 8 8 * … … 27 27 *******************************************************************************/ 28 28 /** Maximum number of file handles. */ 29 #define __LIBC_MAX_FHS 1000029 #define __LIBC_MAX_FHS 10000 30 30 /** Number of file handles to increase the max value with. */ 31 #define __LIBC_INC_FHS 64 31 #define __LIBC_INC_FHS 64 32 32 33 33 34 /******************************************************************************* … … 42 43 #include <sys/fcntl.h> 43 44 #include <errno.h> 45 #include <InnoTekLIBC/fork.h> 46 #include <InnoTekLIBC/sharedpm.h> 47 #include <InnoTekLIBC/tcpip.h> 44 48 #include <emx/io.h> 45 49 #include <emx/umalloc.h> 46 50 #include "syscalls.h" 51 52 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_INITTERM 53 #include <InnoTekLIBC/logstrict.h> 47 54 48 55 … … 55 62 static _fmutex gmtx; 56 63 /** Array of file handle pointers. */ 57 static PLIBCFH*gpapFHs;64 static __LIBC_PFH *gpapFHs; 58 65 /** Number of entires in the file handle table. */ 59 66 static unsigned gcFHs; … … 64 71 static unsigned gcPreAllocatedAvail; 65 72 73 /** Indicator whether or not inherit flags and other stuff have been cleaned 74 * up after fork. */ 75 static int gfForkCleanupDone; 76 66 77 extern int _fmode_bin; 67 78 … … 70 81 * Internal Functions * 71 82 *******************************************************************************/ 72 static int __libc_fhMoreHandles(unsigned cMin); 73 static int __libc_fhAllocate(int fh, unsigned fFlags, int cb, PLIBCFHOPS pOps, PLIBCFH *ppFH, int *pfh, int fOwnSem); 74 static PLIBCFH __libc_fh(int fh); 83 static int fhMoreHandles(unsigned cMin); 84 static int fhAllocate(int fh, unsigned fFlags, int cb, __LIBC_PCFHOPS pOps, __LIBC_PFH *ppFH, int *pfh, int fOwnSem); 85 static void fhFreeHandle(__LIBC_PFH pFH); 86 static __LIBC_PFH fhGet(int fh); 87 static int fhForkParent1(__LIBC_PFORKHANDLE pForkHandle, __LIBC_FORKOP enmOperation); 88 static int fhForkChild1(__LIBC_PFORKHANDLE pForkHandle, __LIBC_FORKOP enmOperation); 89 static void fhForkCompletion(void *pvArg, int rc, __LIBC_FORKCTX enmCtx); 75 90 76 91 … … 80 95 * @returns 0 on success. 81 96 * @returns -1 on failure. 82 */ 83 int _sys_init_filehandles(void) 97 * @param pInherit Pointer to inherited filehandle data. 98 */ 99 int __libc_fhInit(__LIBC_PSPMINHFHBHDR pInherit) 84 100 { 85 101 ULONG cMaxFHs = 0; … … 93 109 if (gcFHs) 94 110 { 95 #ifdef DEBUG 96 __asm__("int $3"); 97 #endif 111 LIBC_ASSERTM_FAILED("already initialized!\n"); 98 112 return 0; 99 113 } … … 112 126 if (rc) 113 127 { 114 #ifdef DEBUG 115 __asm__("int $3"); 116 #endif 128 LIBC_ASSERTM_FAILED("DosSetRelMaxFH failed with rc=%d when querying current values\n", rc); 117 129 cMaxFHs = 20; 118 130 } … … 125 137 126 138 127 /* 128 * Work thru the handles checking if they are in use. 129 * Was previously done in init_files() in startup.c. 130 * We need to allocate the handles and initialize them accordingly. 131 * Bird Feb 12 2004 9:12pm: We do not have to do more than the first 3 handles. 132 * Other open files will be automatically added when __libc_FH() is called 133 * for usage validation in any of LIBC apis. 134 */ 135 if (cMaxFHs > 3) 136 cMaxFHs = 3; 137 for (i = 0; i < cMaxFHs; i++) 138 __libc_fh(i); 139 if (!pInherit) 140 { 141 /* 142 * Work thru the handles checking if they are in use. 143 * Was previously done in init_files() in startup.c. 144 * We need to allocate the handles and initialize them accordingly. 145 * Bird Feb 12 2004 9:12pm: We do not have to do more than the first 3 handles. 146 * Other open files will be automatically added when __libc_FH() is called 147 * for usage validation in any of LIBC apis. 148 */ 149 if (cMaxFHs > 3) 150 cMaxFHs = 3; 151 for (i = 0; i < cMaxFHs; i++) 152 fhGet(i); 153 } 154 else 155 { 156 /* 157 * Process the inherit data passed to us. 158 */ 159 union 160 { 161 __LIBC_PSPMINHFHBHDR pHdr; 162 __LIBC_PSPMINHFHBSTD pStds; 163 __LIBC_PSPMINHFHBSOCK pSockets; 164 uintptr_t u; 165 void *pv; 166 } u; 167 u.pHdr = pInherit; 168 while (u.pHdr->uchType != __LIBC_SPM_INH_FHB_TYPE_END) 169 { 170 unsigned i = 0; 171 unsigned c = u.pHdr->cHandles; 172 unsigned iFH = u.pHdr->fhStart; 173 switch (u.pHdr->uchType) 174 { 175 case __LIBC_SPM_INH_FHB_TYPE_STANDARD: 176 for (i = 0; i < c; i++) 177 { 178 if (fhAllocate(iFH, u.pStds->afFlags[i], sizeof(__LIBC_FH), NULL, NULL, NULL, 0)) 179 { 180 LIBC_ASSERTM_FAILED("Failed to allocated inherited file handle! iFH=%d\n", iFH); 181 return -1; 182 } 183 } 184 u.pv = &u.pStds->afFlags[c]; 185 break; 186 187 case __LIBC_SPM_INH_FHB_TYPE_SOCKET_44: 188 for (i = 0; i < c; i++) 189 { 190 if (TCPNAMEG44(AllocFHEx)(iFH, u.pSockets->aHandles[i].usSocket, u.pSockets->aHandles[i].fFlags, 0, NULL)) 191 { 192 LIBC_ASSERTM_FAILED("Failed to allocated inherited socket (4.4) handle! iFH=%d iSocket=%d\n", 193 iFH, u.pSockets->aHandles[i].usSocket); 194 return -1; 195 } 196 } 197 u.pv = &u.pSockets->aHandles[c]; 198 break; 199 200 case __LIBC_SPM_INH_FHB_TYPE_SOCKET_43: 201 for (i = 0; i < c; i++) 202 { 203 if (TCPNAMEG43(AllocFHEx)(iFH, u.pSockets->aHandles[i].usSocket, u.pSockets->aHandles[i].fFlags, 0, NULL)) 204 { 205 LIBC_ASSERTM_FAILED("Failed to allocated inherited socket (4.3) handle! iFH=%d iSocket=%d\n", 206 iFH, u.pSockets->aHandles[i].usSocket); 207 return -1; 208 } 209 } 210 u.pv = &u.pSockets->aHandles[c]; 211 break; 212 213 /* 214 * Unknown - skip it. 215 */ 216 default: 217 { 218 size_t cb = __LIBC_SPM_INH_FHB_SIZE(u.pHdr->uchType); 219 cb *= u.pHdr->cHandles; 220 u.u += cb + sizeof(*u.pHdr); 221 break; 222 } 223 224 } 225 } 226 } 139 227 140 228 return 0; 141 229 } 142 230 143 231 #if 0 // not used 144 232 /** 145 233 * Terminate the file handles. … … 152 240 if (!gcFHs) 153 241 { 154 #ifdef DEBUG 155 __asm__("int $3"); 156 #endif 242 LIBC_ASSERTM_FAILED("gcFHs is zero - we've already been terminated!\n"); 157 243 return 0; 158 244 } … … 171 257 return 0; 172 258 } 259 #endif 260 261 262 /** 263 * Pack down file handles for exec. 264 * 265 * @returns Pointer to a high heap buffer of the size indicated in *pch containing 266 * the bundles for all the current file handles. The filehandle semaphore 267 * is also owned. Called __libc_fhInheritDone() to release the semaphore. 268 * @returns NULL and errno on failure. 269 * @param pcb Where to store the size of the returned data. 270 */ 271 __LIBC_PSPMINHFHBHDR __libc_fhInheritPack(size_t *pcb) 272 { 273 LIBCLOG_ENTER("pcb=%p\n", (void *)pcb); 274 size_t cb = 0x1000; 275 unsigned iFH; 276 unsigned cFHs; 277 int rc; 278 __LIBC_PSPMINHFHBHDR pRet; 279 union 280 { 281 __LIBC_PSPMINHFHBHDR pHdr; 282 __LIBC_PSPMINHFHBSTD pStds; 283 __LIBC_PSPMINHFHBSOCK pSockets; 284 uintptr_t u; 285 void *pv; 286 } u; 287 288 /* 289 * Allocate buffer. 290 */ 291 pRet = _hmalloc(cb); 292 if (!pRet) 293 LIBCLOG_RETURN_P(NULL); 294 295 /* 296 * Lock the filehandle array. 297 */ 298 rc = _fmutex_request(&gmtx, 0); 299 if (rc) 300 { 301 _sys_set_errno(rc); 302 free(pRet); 303 LIBCLOG_RETURN_P(NULL); 304 } 305 306 /* 307 * Enumerate the handles. 308 * UGLY!!!!! 309 */ 310 for (cFHs = gcFHs, iFH = 0, u.pHdr = pRet; iFH < cFHs;) 311 { 312 __LIBC_FHTYPE enmType; 313 unsigned i; 314 315 /* 316 * Skip unused ones. 317 */ 318 while ( iFH < cFHs 319 && ( !gpapFHs[iFH] 320 || (gpapFHs[iFH]->fFlags & ((FD_CLOEXEC << __LIBC_FH_FDFLAGS_SHIFT) | O_NOINHERIT)) ) ) 321 iFH++; 322 if (iFH >= cFHs) 323 break; 324 325 /* 326 * Create new bundle. 327 */ 328 /* Ensure space for max sized bundle and termination record. */ 329 if ( ((uintptr_t)&u.pSockets->aHandles[256] + sizeof(__LIBC_SPMINHFHBHDR) - (uintptr_t)pRet) > cb) 330 { 331 void *pv = realloc(pRet, cb + 0x1000); 332 if (!pv) 333 { 334 _fmutex_release(&gmtx); 335 free(pRet); 336 LIBCLOG_RETURN_P(NULL); 337 } 338 u.u += (uintptr_t)pv - (uintptr_t)pv; 339 pRet = pv; 340 cb += 0x1000; 341 } 342 /* init the bundle. */ 343 enmType = gpapFHs[iFH]->pOps ? gpapFHs[iFH]->pOps->enmType : enmFH_File; 344 switch (enmType) 345 { 346 case enmFH_File: 347 { 348 u.pStds->Hdr.uchType = __LIBC_SPM_INH_FHB_TYPE_STANDARD; 349 u.pStds->Hdr.fhStart = iFH; 350 /* walk file handles. */ 351 for (i = 0; ; ) 352 { 353 u.pStds->afFlags[i] = gpapFHs[iFH]->fFlags; 354 /* next */ 355 i++; iFH++; 356 if ( i >= 255 357 || iFH >= cFHs 358 || !gpapFHs[iFH] 359 || gpapFHs[iFH]->pOps 360 || (gpapFHs[iFH]->fFlags & ((FD_CLOEXEC << __LIBC_FH_FDFLAGS_SHIFT) | O_NOINHERIT)) ) 361 break; 362 } 363 /* commit the bundle. */ 364 u.pStds->Hdr.cHandles = i; 365 u.pv = &u.pStds->afFlags[i]; 366 break; 367 } 368 369 case enmFH_Socket43: 370 case enmFH_Socket44: 371 { 372 u.pSockets->Hdr.uchType = enmType == enmFH_Socket44 373 ? __LIBC_SPM_INH_FHB_TYPE_SOCKET_44 : __LIBC_SPM_INH_FHB_TYPE_SOCKET_43; 374 u.pSockets->Hdr.fhStart = iFH; 375 /* walk file handles. */ 376 for (i = 0; ; ) 377 { 378 u.pSockets->aHandles[i].fFlags = gpapFHs[iFH]->fFlags; 379 u.pSockets->aHandles[i].usSocket = ((PLIBCSOCKETFH)gpapFHs[iFH])->iSocket; 380 /* next */ 381 i++; iFH++; 382 if ( i >= 255 383 || iFH >= cFHs 384 || !gpapFHs[iFH] 385 || !gpapFHs[iFH]->pOps 386 || (gpapFHs[iFH]->pOps->enmType != enmType) 387 || (gpapFHs[iFH]->fFlags & ((FD_CLOEXEC << __LIBC_FH_FDFLAGS_SHIFT) | O_NOINHERIT)) ) 388 break; 389 } 390 /* commit the bundle. */ 391 u.pSockets->Hdr.cHandles = i; 392 u.pv = &u.pSockets->aHandles[i]; 393 break; 394 } 395 396 default: 397 { /* skip */ 398 for (;;) 399 { 400 /* next */ 401 iFH++; 402 if ( iFH >= cFHs 403 || !gpapFHs[iFH] 404 || !gpapFHs[iFH]->pOps 405 || (gpapFHs[iFH]->pOps->enmType != enmType)) 406 break; 407 } 408 break; 409 } 410 411 } /* switch handle type. */ 412 413 } /* outer loop */ 414 415 /* 416 * Done. Let's add a termination bundle and calc the actual size. 417 */ 418 u.pHdr->uchType = __LIBC_SPM_INH_FHB_TYPE_END; 419 u.pHdr->cHandles = 0; 420 u.pHdr->fhStart = ~0; 421 cb = (uintptr_t)(u.pHdr + 1) - (uintptr_t)pRet; 422 *pcb = (cb + 3) & ~3; /* (This is safe.) */ 423 LIBCLOG_RETURN_MSG(pRet, "ret %p *pcb=%d\n", (void *)pRet, *pcb); 424 } 425 426 427 /** 428 * Called as a response to a successful __libc_fhInheritPack() to 429 * release the file handle mutex. 430 */ 431 void __libc_fhInheritDone(void) 432 { 433 _fmutex_release(&gmtx); 434 } 435 436 437 438 #undef __LIBC_LOG_GROUP 439 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO 173 440 174 441 … … 190 457 191 458 FS_SAVE_LOAD(); 192 rc = DosOpen( "\\DEV\\NUL", &hFile, &ulAction, 0, FILE_NORMAL,459 rc = DosOpen((PCSZ)"\\DEV\\NUL", &hFile, &ulAction, 0, FILE_NORMAL, 193 460 OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS, 194 461 OPEN_SHARE_DENYNONE | OPEN_ACCESS_WRITEONLY, … … 211 478 } 212 479 480 213 481 /** 214 482 * Frees handle data. … … 219 487 * @remark Must own the mutex upon entry! 220 488 */ 221 static void __libc_fhFreeHandle(PLIBCFH pFH)489 static void fhFreeHandle(__LIBC_PFH pFH) 222 490 { 223 491 /* … … 245 513 * @remark Lock must be owned upon entry! 246 514 */ 247 static int __libc_fhMoreHandles(unsigned cMin)515 static int fhMoreHandles(unsigned cMin) 248 516 { 249 517 int rc; … … 297 565 * Reallocate the array of handle pointers. 298 566 */ 299 PLIBCFH *papNewFHs = _hrealloc(gpapFHs, cNewMaxFHs * sizeof(gpapFHs[0]));567 __LIBC_PFH *papNewFHs = _hrealloc(gpapFHs, cNewMaxFHs * sizeof(gpapFHs[0])); 300 568 if (papNewFHs) 301 569 { … … 333 601 return -1; 334 602 335 rc = __libc_fhMoreHandles(fh + 1);603 rc = fhMoreHandles(fh + 1); 336 604 337 605 _fmutex_release(&gmtx); … … 352 620 return -1; 353 621 354 rc = __libc_fhMoreHandles(0);622 rc = fhMoreHandles(0); 355 623 356 624 _fmutex_release(&gmtx); … … 378 646 * @remark The preallocated handles make this function somewhat big and messy. 379 647 */ 380 static int __libc_fhAllocate(int fh, unsigned fFlags, int cb, PLIBCFHOPS pOps, PLIBCFH *ppFH, int *pfh, int fOwnSem)381 { 382 PLIBCFHpFH;648 static int fhAllocate(int fh, unsigned fFlags, int cb, __LIBC_PCFHOPS pOps, __LIBC_PFH *ppFH, int *pfh, int fOwnSem) 649 { 650 __LIBC_PFH pFH; 383 651 int rc; 384 652 FS_VAR(); … … 409 677 if (cb == sizeof(LIBCFH) && gcPreAllocatedAvail) 410 678 { 411 PLIBCFH pFHSearch;679 __LIBC_PFH pFHSearch; 412 680 for (pFHSearch = &gaPreAllocated[0]; 413 681 pFH < &gaPreAllocated[sizeof(gaPreAllocated) / sizeof(gaPreAllocated[0])]; … … 419 687 break; 420 688 } 421 #ifdef DEBUG 422 if (!pFH) __asm__("int $3"); 423 #endif 689 LIBC_ASSERT(pFH); 424 690 } 425 691 … … 438 704 */ 439 705 pFH->fFlags = fFlags; 706 if (fFlags & O_NOINHERIT) 707 fFlags |= FD_CLOEXEC << __LIBC_FH_FDFLAGS_SHIFT; 440 708 pFH->iLookAhead = -1; 441 709 pFH->pOps = pOps; … … 450 718 * Open dummy device to find a handle number. 451 719 */ 452 #ifdef DEBUG 453 if (!pOps) 454 __asm__("int $3"); 455 #endif 720 LIBC_ASSERTM(pOps, "cannot open a non-standard handle without giving pOps!\n"); 456 721 rc = __libc_fhOpenDummy(-1, &fh); 457 722 if (!rc) … … 461 726 */ 462 727 if (fh >= gcFHs) 463 rc = __libc_fhMoreHandles(fh + 1);728 rc = fhMoreHandles(fh + 1); 464 729 if (!rc) 465 730 { … … 469 734 */ 470 735 if (gpapFHs[fh]) 471 __libc_fhFreeHandle(gpapFHs[fh]);736 fhFreeHandle(gpapFHs[fh]); 472 737 gpapFHs[fh] = pFH; 473 738 } … … 490 755 rc = 0; 491 756 if (fh >= gcFHs) 492 rc = __libc_fhMoreHandles(fh + 1);757 rc = fhMoreHandles(fh + 1); 493 758 494 759 if (!rc) … … 507 772 */ 508 773 if (gpapFHs[fh]) 509 __libc_fhFreeHandle(gpapFHs[fh]);774 fhFreeHandle(gpapFHs[fh]); 510 775 gpapFHs[fh] = pFH; 511 776 } … … 523 788 _sys_set_errno(rc); 524 789 if (pFH) 525 __libc_fhFreeHandle(pFH);790 fhFreeHandle(pFH); 526 791 pFH = NULL; 527 792 fh = -1; … … 557 822 * @remark The preallocated handles make this function somewhat big and messy. 558 823 */ 559 int __libc_FHAllocate(int fh, unsigned fFlags, int cb, PLIBCFHOPS pOps, PLIBCFH *ppFH, int *pfh)560 { 561 return __libc_fhAllocate(fh, fFlags, cb, pOps, ppFH, pfh, 0);824 int __libc_FHAllocate(int fh, unsigned fFlags, int cb, __LIBC_PCFHOPS pOps, __LIBC_PFH *ppFH, int *pfh) 825 { 826 return fhAllocate(fh, fFlags, cb, pOps, ppFH, pfh, 0); 562 827 } 563 828 … … 572 837 int __libc_FHClose(int fh) 573 838 { 574 PLIBCFHpFH;575 ULONGrc;839 __LIBC_PFH pFH; 840 int rc; 576 841 FS_VAR(); 577 842 … … 582 847 * Validate input. 583 848 */ 584 if (!__libc_fh(fh)) 585 { 586 /*#ifdef DEBUG 587 __asm__("int $3"); 588 #endif*/ 849 if (!fhGet(fh)) 850 { 851 LIBC_ASSERTM_FAILED("fh=%d is not opened according to our table!\n", fh); 589 852 _fmutex_release(&gmtx); 590 853 errno = EBADF; … … 617 880 rc2 = DosClose(fh); 618 881 FS_RESTORE(); 882 LIBC_ASSERTM(!rc2, "DosClose(%d) -> rc2=%d (rc=%d)\n", fh, rc2, rc); 619 883 if (!pFH->pOps) 620 884 rc = rc2; 621 #ifdef DEBUG622 else if (rc2) __asm__("int $3");623 #endif624 885 625 886 /* … … 630 891 { 631 892 gpapFHs[fh] = NULL; 632 __libc_fhFreeHandle(pFH);893 fhFreeHandle(pFH); 633 894 } 634 895 } … … 641 902 _sys_set_errno(rc); 642 903 else 643 errno = rc;904 errno = -rc; 644 905 } 645 906 … … 657 918 * @internal 658 919 */ 659 static PLIBCFH __libc_fh(int fh)660 { 661 PLIBCFH pFH = NULL;920 static __LIBC_PFH fhGet(int fh) 921 { 922 __LIBC_PFH pFH = NULL; 662 923 663 924 /* … … 672 933 cCur = gcFHs; 673 934 if (gcFHs != cCur) 674 __libc_fhMoreHandles(cCur);935 fhMoreHandles(cCur); 675 936 } 676 937 … … 732 993 733 994 /* 995 * Inherit flags. 996 */ 997 if (fulMode & OPEN_FLAGS_NOINHERIT) 998 fLibc |= O_NOINHERIT | (FD_CLOEXEC << __LIBC_FH_FDFLAGS_SHIFT); 999 1000 /* 734 1001 * Textflag. 735 1002 */ … … 741 1008 * Allocate a new handle for this filehandle. 742 1009 */ 743 rc = __libc_fhAllocate(fh, fLibc, sizeof(LIBCFH), NULL, &pFH, NULL, 1);1010 rc = fhAllocate(fh, fLibc, sizeof(LIBCFH), NULL, &pFH, NULL, 1); 744 1011 if (rc) 745 1012 pFH = NULL; … … 759 1026 * @param fh Handle to lookup. 760 1027 */ 761 PLIBCFH __libc_FH(int fh)762 { 763 PLIBCFH pFH;1028 __LIBC_PFH __libc_FH(int fh) 1029 { 1030 __LIBC_PFH pFH; 764 1031 765 1032 /** @todo shared access */ … … 767 1034 return NULL; 768 1035 769 pFH = __libc_fh(fh);1036 pFH = fhGet(fh); 770 1037 771 1038 _fmutex_release(&gmtx); … … 773 1040 } 774 1041 1042 1043 1044 #undef __LIBC_LOG_GROUP 1045 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_FORK 1046 1047 _FORK_PARENT1(0xfffff000, fhForkParent1) 1048 1049 /** 1050 * Parent fork callback. 1051 * 1052 * There are two purposes for this function. First, lock the filehandle 1053 * array while forking. Second, force all handles to tempoarily be inherited 1054 * by child process. 1055 * 1056 * @returns 0 on success. 1057 * @returns -errno on failure. 1058 * @param pForkHandle Pointer to fork handle. 1059 * @param enmOperation Fork operation. 1060 */ 1061 static int fhForkParent1(__LIBC_PFORKHANDLE pForkHandle, __LIBC_FORKOP enmOperation) 1062 { 1063 LIBCLOG_ENTER("pForkHandle=%p enmOperation=%d\n", (void *)pForkHandle, enmOperation); 1064 int rc; 1065 1066 switch (enmOperation) 1067 { 1068 /* 1069 * Take file handle semaphore. 1070 * Mark all handles temporarily for inheritance. 1071 */ 1072 case __LIBC_FORK_OP_EXEC_PARENT: 1073 { 1074 /* 1075 * Acquire Semaphore and register completion handler for cleaning up. 1076 */ 1077 rc = _fmutex_request(&gmtx, 0); 1078 if (!rc) 1079 { 1080 gfForkCleanupDone = 0; 1081 rc = pForkHandle->pfnCompletionCallback(pForkHandle, fhForkCompletion, NULL, __LIBC_FORK_CTX_BOTH); 1082 if (rc < 0) 1083 _fmutex_release(&gmtx); 1084 else 1085 { 1086 /* 1087 * Iterate all file handles and do pre exec processing, i.e. mark as inherit. 1088 */ 1089 unsigned iFH; 1090 unsigned cFHs = gcFHs; 1091 for (iFH = 0; iFH < cFHs; iFH++) 1092 { 1093 __LIBC_PFH pFH; 1094 if ((pFH = gpapFHs[iFH]) != NULL) 1095 { 1096 if (pFH->pOps && pFH->pOps->pfnForkParent) 1097 { 1098 rc = pFH->pOps->pfnForkParent(pFH, iFH, pForkHandle, __LIBC_FORK_OP_EXEC_PARENT); 1099 if (rc) 1100 { 1101 LIBC_ASSERTM_FAILED("pfnForkParent(=%p) for handle %d failed with rc=%d\n", 1102 (void *)pFH->pOps->pfnForkParent, iFH, rc); 1103 if (rc > 0) 1104 rc = -__libc_native2errno(rc); 1105 break; 1106 } 1107 } 1108 1109 /* mark as inherit. */ 1110 if (pFH->fFlags & (O_NOINHERIT | (FD_CLOEXEC << __LIBC_FH_FDFLAGS_SHIFT))) 1111 { 1112 ULONG fulState; 1113 1114 rc = DosQueryFHState(iFH, &fulState); 1115 if (!rc) 1116 { 1117 fulState = fulState & ~OPEN_FLAGS_NOINHERIT; 1118 fulState &= 0x7f88; /* Mask the flags accepted by the API. */ 1119 rc = DosSetFHState(iFH, fulState); 1120 } 1121 if (rc) 1122 { 1123 LIBC_ASSERTM_FAILED("DosSetFHState or DosQueryFHState failed with rc=%d for handle %d\n", rc, iFH); 1124 rc = -__libc_native2errno(rc); 1125 break; 1126 } 1127 } 1128 } 1129 } /* for */ 1130 /* No need to clean up on failure. the completion callback will do that. */ 1131 } 1132 } 1133 else 1134 { 1135 LIBC_ASSERTM_FAILED("failed to get the filehandle mutex. rc=%d\n", rc); 1136 rc = -__libc_native2errno(rc); 1137 } 1138 break; 1139 } 1140 1141 1142 /* 1143 * Iterate all file handles and do fork exec processing. 1144 * This is only done for non standard file handles. 1145 */ 1146 case __LIBC_FORK_OP_FORK_PARENT: 1147 { 1148 unsigned iFH; 1149 unsigned cFHs = gcFHs; 1150 for (iFH = 0, rc = 0; iFH < cFHs; iFH++) 1151 { 1152 __LIBC_PFH pFH; 1153 if ((pFH = gpapFHs[iFH]) != NULL) 1154 { 1155 if (pFH->pOps && pFH->pOps->pfnForkParent) 1156 { 1157 rc = pFH->pOps->pfnForkParent(pFH, iFH, pForkHandle, __LIBC_FORK_OP_FORK_PARENT); 1158 if (rc) 1159 { 1160 LIBC_ASSERTM_FAILED("pfnForkParent(=%p) for handle %d failed with rc=%d\n", 1161 (void *)pFH->pOps->pfnForkParent, iFH, rc); 1162 if (rc > 0) 1163 rc = -__libc_native2errno(rc); 1164 break; 1165 } 1166 } 1167 } 1168 } 1169 break; 1170 } 1171 1172 default: 1173 rc = 0; 1174 break; 1175 } 1176 1177 LIBCLOG_RETURN_INT(rc); 1178 } 1179 1180 1181 1182 _FORK_CHILD1(0xffffff00, fhForkChild1) 1183 1184 /** 1185 * Child fork callback. 1186 * 1187 * There are two purposes for this function. First, restore no-inherit handles 1188 * and call pfnForkChild(). Second, to release the file handle mutex. 1189 * 1190 * Note that only __LIBC_FORK_OP_FORK_CHILD is propagated to pfnForkChild(). 1191 * 1192 * @returns 0 on success. 1193 * @returns -errno on failure. 1194 * @param pForkHandle Pointer to fork handle. 1195 * @param enmOperation Fork operation. 1196 */ 1197 static int fhForkChild1(__LIBC_PFORKHANDLE pForkHandle, __LIBC_FORKOP enmOperation) 1198 { 1199 LIBCLOG_ENTER("pForkHandle=%p enmOperation=%d\n", (void *)pForkHandle, enmOperation); 1200 int rc; 1201 1202 switch (enmOperation) 1203 { 1204 /* 1205 * Clear all handles which was temporarily marked for inheritance. 1206 * Release the file handle semaphore. 1207 */ 1208 case __LIBC_FORK_OP_FORK_CHILD: 1209 { 1210 int rc2; 1211 unsigned iFH; 1212 unsigned cFHs = gcFHs; 1213 for (iFH = 0, rc = 0; iFH < cFHs; iFH++) 1214 { 1215 __LIBC_PFH pFH; 1216 if ((pFH = gpapFHs[iFH]) != NULL) 1217 { 1218 /* call pfnForkChild(). */ 1219 if (pFH->pOps && pFH->pOps->pfnForkChild) 1220 { 1221 rc = pFH->pOps->pfnForkChild(pFH, iFH, pForkHandle, __LIBC_FORK_OP_FORK_PARENT); 1222 if (rc) 1223 { 1224 LIBC_ASSERTM_FAILED("pfnForkChild(=%p) for handle %d failed with rc=%d\n", 1225 (void *)pFH->pOps->pfnForkChild, iFH, rc); 1226 if (rc > 0) 1227 rc = -__libc_native2errno(rc); 1228 break; 1229 } 1230 } 1231 1232 /* clear flag. */ 1233 if (pFH->fFlags & (O_NOINHERIT | (FD_CLOEXEC << __LIBC_FH_FDFLAGS_SHIFT))) 1234 { 1235 ULONG fulState; 1236 rc = DosQueryFHState(iFH, &fulState); 1237 if (!rc) 1238 { 1239 fulState |= OPEN_FLAGS_NOINHERIT; 1240 fulState &= 0x7f88; /* Mask the flags accepted by the API. */ 1241 rc = DosSetFHState(iFH, fulState); 1242 } 1243 LIBC_ASSERTM(!rc, "DosSetFHState or DosQueryFHState failed with rc=%d for handle %d\n", rc, iFH); 1244 } 1245 } 1246 } 1247 1248 /* release semaphore. */ 1249 rc2 = _fmutex_release(&gmtx); 1250 if (rc2) 1251 { 1252 LIBC_ASSERTM_FAILED("_fmutex_release failed rc=%d\n", rc2); 1253 if (rc >= 0) 1254 rc = -__libc_native2errno(rc2); 1255 } 1256 gfForkCleanupDone = 1; 1257 break; 1258 } 1259 1260 default: 1261 rc = 0; 1262 break; 1263 } 1264 1265 LIBCLOG_RETURN_INT(rc); 1266 } 1267 1268 1269 /** 1270 * Fork completion callback used to release the file handle semaphore 1271 * and set the noinherit flags. 1272 * 1273 * @param pvArg NULL. 1274 * @param rc The fork() result. Negative on failure. 1275 * @param enmCtx The calling context. 1276 */ 1277 static void fhForkCompletion(void *pvArg, int rc, __LIBC_FORKCTX enmCtx) 1278 { 1279 LIBCLOG_ENTER("pvArg=%p rc=%d enmCtx=%d\n", pvArg, rc, enmCtx); 1280 rc = rc; 1281 pvArg = pvArg; 1282 1283 if ( !gfForkCleanupDone 1284 && ( !rc 1285 || enmCtx == __LIBC_FORK_CTX_PARENT)) 1286 { 1287 /* 1288 * Iterate handles and set no-inherit flags. 1289 * 1290 * We assume that the non standard handles will do any necessary 1291 * cleanup themselves. If they register completion callbacks they 1292 * have all be executed by now since we registered our before them 1293 * the the order is LIFO. 1294 */ 1295 unsigned iFH; 1296 unsigned cFHs = gcFHs; 1297 for (iFH = 0, rc = 0; iFH < cFHs; iFH++) 1298 { 1299 __LIBC_PFH pFH; 1300 if ((pFH = gpapFHs[iFH]) != NULL) 1301 { 1302 if (pFH->fFlags & (O_NOINHERIT | (FD_CLOEXEC << __LIBC_FH_FDFLAGS_SHIFT))) 1303 { 1304 ULONG fulState; 1305 rc = DosQueryFHState(iFH, &fulState); 1306 if (!rc) 1307 { 1308 fulState |= OPEN_FLAGS_NOINHERIT; 1309 fulState &= 0x7f88; /* Mask the flags accepted by the API. */ 1310 rc = DosSetFHState(iFH, fulState); 1311 } 1312 LIBC_ASSERTM(!rc, "DosSetFHState or DosQueryFHState failed with rc=%d for handle %d\n", rc, iFH); 1313 } 1314 } 1315 } 1316 } 1317 1318 /* 1319 * Release the mutex. 1320 */ 1321 if (!gfForkCleanupDone) 1322 { 1323 gfForkCleanupDone = 1; 1324 _fmutex_release(&gmtx); 1325 } 1326 1327 LIBCLOG_RETURN_VOID(); 1328 } 1329 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/heap.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 4 4 #define INCL_DOSERRORS 5 5 #define INCL_FSMACROS 6 #define INCL_EXAPIS 6 7 #include <os2emx.h> 7 8 #include <errno.h> … … 9 10 #include <emx/syscalls.h> 10 11 #include "syscalls.h" 12 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_HEAP 13 #include <InnoTekLIBC/logstrict.h> 11 14 12 15 … … 22 25 23 26 FS_SAVE_LOAD(); 24 if (DosAllocMem (&p, size, PAG_READ | PAG_WRITE) != 0)27 if (DosAllocMemEx (&p, size, PAG_READ | PAG_WRITE | OBJ_FORK) != 0) 25 28 { 26 29 FS_RESTORE(); … … 40 43 /* We got a suitable object. Free the bad one. */ 41 44 42 DosFreeMem (p);45 DosFreeMemEx (p); 43 46 FS_RESTORE(); 44 47 return ret; … … 51 54 ULONG _sys_expand_heap_obj_by (ULONG incr) 52 55 { 56 LIBCLOG_ENTER("incr=%ld\n", incr); 53 57 ULONG rc, old_brk, new_brk, addr, size, rest; 54 58 … … 57 61 58 62 if (new_brk < _sys_top_heap_obj->base || new_brk > _sys_top_heap_obj->end) 59 return 0;63 LIBCLOG_RETURN_ULONG(0UL); 60 64 61 65 addr = old_brk; … … 79 83 FS_RESTORE(); 80 84 if (rc != 0) 81 return 0;85 LIBCLOG_RETURN_ULONG(0UL); 82 86 } 83 87 _sys_top_heap_obj->brk = new_brk; 84 return old_brk;88 LIBCLOG_RETURN_ULONG(old_brk); 85 89 } 86 90 … … 91 95 ULONG _sys_shrink_heap_obj_by (ULONG decr) 92 96 { 97 LIBCLOG_ENTER("decr=%ld\n", decr); 93 98 ULONG rc, old_brk, new_brk, addr, high; 94 99 … … 97 102 98 103 if (new_brk < _sys_top_heap_obj->base || new_brk > _sys_top_heap_obj->end) 99 return 0;104 LIBCLOG_RETURN_ULONG(0UL); 100 105 101 106 addr = (new_brk + 0xfff) & ~0xfff; … … 108 113 FS_RESTORE(); 109 114 if (rc != 0) 110 return 0;115 LIBCLOG_RETURN_ULONG(0UL); 111 116 } 112 117 _sys_top_heap_obj->brk = new_brk; 113 return old_brk;118 LIBCLOG_RETURN_ULONG(old_brk); 114 119 } 115 120 … … 120 125 ULONG _sys_expand_heap_by (ULONG incr, ULONG sbrk_model) 121 126 { 127 LIBCLOG_ENTER("incr=%ld sbrk_model=%ld\n", incr, sbrk_model); 122 128 unsigned old_obj_count; 123 129 ULONG base, size; … … 155 161 FS_VAR(); 156 162 FS_SAVE_LOAD(); 157 DosFreeMem ((void *)_sys_heap_objs[0].base);163 DosFreeMemEx ((void *)_sys_heap_objs[0].base); 158 164 FS_RESTORE(); 159 165 _sys_heap_obj_count = 0; 160 166 _sys_top_heap_obj = NULL; 161 167 } 162 return 0;/* Failure */168 LIBCLOG_RETURN_ULONG(0UL); /* Failure */ 163 169 } 164 170 … … 175 181 if (sbrk_model == _UF_SBRK_CONTIGUOUS 176 182 || _sys_heap_obj_count >= MAX_HEAP_OBJS) 177 return 0;183 LIBCLOG_RETURN_ULONG(0UL); 178 184 179 185 /* Allocate at least _sys_heap_size bytes. The new object must … … 199 205 size /= 2; 200 206 if (size < incr) 201 return 0;207 LIBCLOG_RETURN_ULONG(0UL); 202 208 } 203 209 … … 213 219 expansion as an object might have been added. */ 214 220 215 return _sys_expand_heap_obj_by (incr); 221 base = _sys_expand_heap_obj_by (incr); 222 LIBCLOG_RETURN_ULONG(base); 216 223 } 217 224 … … 222 229 ULONG _sys_shrink_heap_to (ULONG new_brk) 223 230 { 231 LIBCLOG_ENTER("new_brk=%ld\n", new_brk); 224 232 unsigned obj; 225 233 ULONG old_brk; … … 250 258 { 251 259 if ((_sys_uflags & _UF_SBRK_MODEL) == _UF_SBRK_CONTIGUOUS) 252 return 0;260 LIBCLOG_RETURN_ULONG(0UL); 253 261 while (_sys_heap_obj_count - 1 > obj) 254 262 { … … 256 264 _sys_heap_obj_count -= 1; 257 265 FS_SAVE_LOAD(); 258 DosFreeMem ((void *)_sys_heap_objs[_sys_heap_obj_count].base);266 DosFreeMemEx ((void *)_sys_heap_objs[_sys_heap_obj_count].base); 259 267 FS_RESTORE(); 260 268 _sys_heap_objs[_sys_heap_obj_count].base = 0; … … 293 301 _sys_heap_obj_count -= 1; 294 302 FS_SAVE_LOAD(); 295 DosFreeMem ((void *)_sys_heap_objs[_sys_heap_obj_count].base);303 DosFreeMemEx ((void *)_sys_heap_objs[_sys_heap_obj_count].base); 296 304 FS_RESTORE(); 297 305 _sys_heap_objs[_sys_heap_obj_count].base = 0; … … 312 320 if (_sys_heap_obj_count > 0 313 321 && _sys_shrink_heap_obj_by (_sys_top_heap_obj->brk - new_brk) == 0) 314 return 0;315 return old_brk;322 LIBCLOG_RETURN_ULONG(0UL); 323 LIBCLOG_RETURN_ULONG(old_brk); 316 324 } 317 325 … … 322 330 ULONG _sys_shrink_heap_by (ULONG decr, ULONG sbrk_model) 323 331 { 332 LIBCLOG_ENTER("decr=%ld sbrk_model=%ld\n", decr, sbrk_model); 333 ULONG ulRet; 324 334 if (_sys_heap_obj_count == 0) 325 return 0;335 LIBCLOG_RETURN_ULONG(0UL); 326 336 if (_sys_top_heap_obj->brk - decr < _sys_top_heap_obj->base) 327 return 0; 328 return _sys_shrink_heap_to (_sys_top_heap_obj->brk - decr); 329 } 337 LIBCLOG_RETURN_ULONG(0UL); 338 ulRet = _sys_shrink_heap_to (_sys_top_heap_obj->brk - decr); 339 LIBCLOG_RETURN_ULONG(ulRet); 340 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/heaphigh.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 23 23 * 24 24 */ 25 26 27 /******************************************************************************* 28 * Defined Constants And Macros * 29 *******************************************************************************/ 30 /** The size of a chunk descriptor pool (64KB). */ 31 #define HIMEM_POOL_SIZE (64*1024) 32 /** Default chunk size (16MB). */ 33 #define HIMEM_CHUNK_SIZE (16*1024*1024) 34 /** Minimum chunk size (64KB). */ 35 #define HIMEM_CHUNK_SIZE_MIN (64*1024) 36 /** Default commit size (256KB). */ 37 #define HIMEM_COMMIT_SIZE HIMEM_CHUNK_SIZE_MIN 38 39 /** Round chunk size. */ 40 #define HIMEM_ROUND_SIZE(cb, align) ( ((cb) + (align) - 1) & ~((align) - 1) ) 41 25 42 26 43 … … 30 47 #include "libc-alias.h" 31 48 #define INCL_DOSMEMMGR 49 #define INCL_EXAPIS 32 50 #define INCL_ERRORS 33 51 #include <os2emx.h> … … 35 53 #include <emx/umalloc.h> 36 54 #include "syscalls.h" 55 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_HEAP 56 #include <InnoTekLIBC/logstrict.h> 37 57 38 58 … … 40 60 * Structures and Typedefs * 41 61 *******************************************************************************/ 42 /** One chunk of memory43 * This structure is located at the very start of thechunk.62 /** 63 * Descriptor for a high memory chunk. 44 64 */ 45 65 typedef struct _HighChunk 46 66 { 47 /** Magic / padding the struct to 16 bytes. */48 char szMagic[8];49 67 /** Pointer to the next one. */ 50 68 struct _HighChunk *pNext; 69 /** Pointer to the chunk. */ 70 void *pv; 51 71 /** Size of the chunk. */ 52 72 size_t cb; 53 } HIGHCHUNK, *PHIGHCHUNK; 73 /** Size of the un committed memory. */ 74 size_t cbUncommitted; 75 } HIGHCHUNK; 76 /** Pointer to a descriptor for a high memory chunk. */ 77 typedef HIGHCHUNK *PHIGHCHUNK; 78 79 /** 80 * A pool of chunk descriptors. 81 */ 82 typedef struct _HighChunkPool 83 { 84 /** Pointer to the next pool in the list.*/ 85 struct _HighChunkPool *pNext; 86 /** List of free chunks. */ 87 PHIGHCHUNK pFreeHead; 88 /** Index to the next uninitialized chunk. 89 * ~0 if all are initialized. */ 90 unsigned iUnitialized; 91 /** Size of the pool. */ 92 unsigned cChunks; 93 /** Array of cChunks entires. */ 94 HIGHCHUNK aChunks[1]; 95 } HIGHCHUNKPOOL; 96 /** Pointer to a pool of chunk descriptors. */ 97 typedef HIGHCHUNKPOOL *PHIGHCHUNKPOOL; 54 98 55 99 … … 57 101 * Global Variables * 58 102 *******************************************************************************/ 59 /** List of chuncks. Protected by _sys_gmtxHimem. */ 60 static PHIGHCHUNK pHimemHead; 61 103 /** List of chuncks. 104 * Protected by _sys_gmtxHimem. */ 105 static PHIGHCHUNK gpHimemHead; 106 /** Search hint containing NULL or the last used chunk. 107 * Protected by _sys_gmtxHimem. */ 108 static PHIGHCHUNK gpHimemHint; 109 /** List of chunk pools. 110 * Protected by _sys_gmtxHimem. */ 111 static PHIGHCHUNKPOOL gpHimemPoolHead; 112 113 114 115 /******************************************************************************* 116 * Internal Functions * 117 *******************************************************************************/ 118 static PHIGHCHUNK himemAllocChunk(void); 119 static void himemFreeChunk(PHIGHCHUNK pChunk); 120 121 122 /** 123 * Allocates a chunk descriptor. 124 * Caller must not own semaphore. 125 * 126 * @returns Pointer to chunk descriptor. 127 * Owner of the semaphore. Caller must free it. 128 * @returns NULL on failure. 129 */ 130 static PHIGHCHUNK himemAllocChunk(void) 131 { 132 LIBCLOG_ENTER("\n"); 133 PHIGHCHUNK pChunk; 134 PHIGHCHUNKPOOL pPool; 135 PVOID pv; 136 int rc; 137 138 /* 139 * Take semaphore. 140 */ 141 if (_fmutex_request(&_sys_gmtxHimem, _FMR_IGNINT)) 142 LIBCLOG_RETURN_P(NULL); 143 144 /* 145 * Walk the pool list and look for free chunks. 146 */ 147 pChunk = NULL; 148 for (pPool = gpHimemPoolHead; pPool; pPool = pPool->pNext) 149 { 150 if (pPool->pFreeHead) 151 { 152 /* Unlink free chunk. */ 153 pChunk = pPool->pFreeHead; 154 pPool->pFreeHead = pChunk->pNext; 155 pChunk->pNext = NULL; 156 LIBCLOG_RETURN_P(pChunk); 157 } 158 if (pPool->iUnitialized != ~0) 159 { 160 /* We commit page by page to make fork() as fast as possible. */ 161 if ((((uintptr_t)&pPool->aChunks[pPool->iUnitialized]) & 0xfff) == 0) 162 { 163 rc = DosSetMem(&pPool->aChunks[pPool->iUnitialized], 0x1000, PAG_DEFAULT | PAG_COMMIT); 164 LIBC_ASSERTM(rc, "DosSetMem(%p, 0x1000,) -> rc=%d\n", (void *)&pPool->aChunks[pPool->iUnitialized], rc); 165 if (rc) 166 continue; 167 } 168 /* initialize a new chunk and return it. */ 169 pChunk = &pPool->aChunks[pPool->iUnitialized++]; 170 if (pPool->iUnitialized >= pPool->cChunks) 171 pPool->iUnitialized = ~0; 172 LIBCLOG_RETURN_P(pChunk); 173 } 174 } 175 176 /* 177 * We're out of chunk descriptors. 178 * Allocate another pool. 179 */ 180 rc = DosAllocMemEx(&pv, HIMEM_POOL_SIZE, PAG_WRITE | PAG_READ | OBJ_ANY | OBJ_FORK); 181 if (rc) 182 { 183 LIBC_ASSERTM_FAILED("Failed to allocate more chunks. rc=%d\n", rc); 184 _fmutex_release(&_sys_gmtxHimem); 185 LIBCLOG_RETURN_P(NULL); 186 } 187 /* Commit the first page. */ 188 rc = DosSetMem(pv, 0x1000, PAG_DEFAULT | PAG_COMMIT); 189 if (rc) 190 { 191 LIBC_ASSERTM_FAILED("DosSetMem(%p, 0x1000,) -> rc=%d\n", pv, rc); 192 DosFreeMemEx(pv); 193 _fmutex_release(&_sys_gmtxHimem); 194 LIBCLOG_RETURN_P(NULL); 195 } 196 197 /* 198 * Initialize the pool, allocate the first chunk and put the pool into the lifo. 199 */ 200 pPool = (PHIGHCHUNKPOOL)pv; 201 pPool->cChunks = (HIMEM_POOL_SIZE - sizeof(HIGHCHUNKPOOL)) / sizeof(HIGHCHUNK); 202 203 pPool->iUnitialized = 1; 204 pChunk = &pPool->aChunks[0]; 205 206 pPool->pNext = gpHimemPoolHead; 207 gpHimemPoolHead = pPool; 208 209 LIBCLOG_RETURN_P(pChunk); 210 } 211 212 213 /** 214 * Frees a chunk. 215 * The caller must own the semaphore. 216 * 217 * @param pChunk The chunk to free. 218 */ 219 static void himemFreeChunk(PHIGHCHUNK pChunk) 220 { 221 LIBCLOG_ENTER("pChunk=%p:{pv=%p cb=%#x}\n", (void *)pChunk, pChunk->pv, pChunk->cb); 222 PHIGHCHUNKPOOL pPool; 223 224 /* 225 * Walk the pool list and look for free chunks. 226 */ 227 for (pPool = gpHimemPoolHead; pPool; pPool = pPool->pNext) 228 { 229 if ( pChunk >= &pPool->aChunks[0] 230 && pChunk < &pPool->aChunks[pPool->cChunks]) 231 { 232 pChunk->pv = NULL; 233 pChunk->cb = 0; 234 pChunk->cbUncommitted = 0; 235 236 pChunk->pNext = pPool->pFreeHead; 237 pPool->pFreeHead = pChunk; 238 LIBCLOG_RETURN_VOID(); 239 } 240 } 241 242 LIBC_ASSERTM_FAILED("couldn't find pool which chunk %p belongs in!\n", (void *)pChunk); 243 LIBCLOG_RETURN_VOID(); 244 } 62 245 63 246 64 247 /** 65 248 * Heap callback function for allocating high memory. 249 * We allocate a good deal of memory, but only commits the requested size. 66 250 * 67 251 * @returns Pointer to the allocated memory on success. … … 73 257 * pointed to by the returned address is clean 74 258 * (i.e zeroed) or not. 259 * 260 * @remark Assumes it serves one heap only ATM! 75 261 */ 76 262 void *__libc_HimemDefaultAlloc(Heap_t Heap, size_t *pcb, int *pfClean) 77 263 { 264 LIBCLOG_ENTER("Heap=%p pcb=%p:{%#x} pfClean=%p\n", (void *)Heap, (void *)pcb, *pcb, (void *)pfClean); 78 265 size_t cbAlloc; 266 size_t cbCommit; 267 PVOID pv; 79 268 int rc; 80 269 PHIGHCHUNK pChunk; 81 270 271 272 if (!gpHimemPoolHead) 273 { 274 /* 275 * The first time we force the allocation of the chunk decriptor 276 * pool before we allocate the actual chunk to optimize the address space. 277 */ 278 pChunk = himemAllocChunk(); 279 if (pChunk) 280 { 281 himemFreeChunk(pChunk); 282 _fmutex_release(&_sys_gmtxHimem); 283 } 284 } 285 else 286 { 287 /* 288 * Check if we have a chunk we can expand to satisfy the request. 289 */ 290 if (_fmutex_request(&_sys_gmtxHimem, _FMR_IGNINT)) 291 LIBCLOG_RETURN_P(NULL); 292 cbCommit = *pcb; 293 cbCommit = HIMEM_ROUND_SIZE(cbCommit, HIMEM_COMMIT_SIZE); 294 pChunk = gpHimemHint; 295 if (!pChunk) 296 pChunk = gpHimemHead; 297 for (; pChunk; pChunk = pChunk->pNext) 298 { 299 if (pChunk->cbUncommitted >= cbCommit) 300 { 301 /* commit the rest if it's less than the minimum commit size. */ 302 if (pChunk->cbUncommitted - cbCommit < HIMEM_COMMIT_SIZE) 303 cbCommit = pChunk->cbUncommitted; 304 305 /* 306 * commit the lump. 307 */ 308 pv = (char *)pChunk->pv + pChunk->cb - pChunk->cbUncommitted; 309 rc = DosSetMem(pv, cbCommit, PAG_DEFAULT | PAG_COMMIT); 310 if (rc) 311 { /* page by page */ 312 void *pvCom = pv; 313 int cbCom = (int)cbCommit; 314 for (rc = 0; cbCom > 0; cbCom -= 0x1000, pv = (char *)pv + 0x1000) 315 { 316 int rc2 = DosSetMem(pvCom, 0x1000, PAG_DEFAULT | PAG_COMMIT); 317 LIBC_ASSERTM(!rc2, "DosSetMem(%p, 0x1000, commit) -> %d\n", pvCom, rc2); 318 if (rc2) 319 rc = rc2; 320 } 321 } 322 323 if (!rc) 324 { 325 pChunk->cbUncommitted -= cbCommit; 326 gpHimemHint = pChunk->cbUncommitted ? pChunk : gpHimemHead; 327 _fmutex_release(&_sys_gmtxHimem); 328 329 /* return pv and commit size. The heap takes care of joining 330 * it with the earlier part of the block. ASSUMES ONE HEAP!!! */ 331 *pcb = cbCommit; 332 LIBCLOG_RETURN_MSG(pv, "ret %p *pcb=%#x\n", pv, *pcb); 333 } 334 LIBC_ASSERTM_FAILED("DosSetMem(%p, %#x, commit) -> %d\n", pv, cbCommit, rc); 335 continue; 336 } 337 } 338 339 /* Out of luck, allocate a new chunk. */ 340 _fmutex_release(&_sys_gmtxHimem); 341 } 342 343 82 344 /* 83 345 * Allocate a (rather big) memory block, there is generally speaking 84 * more than enough high memory to allocate from. So, we'll align the 85 * chunks on a rather high limit, 4MB to save kernel calls and list 86 * elements. 87 */ 88 cbAlloc = *pcb + sizeof(HIGHCHUNK); 89 cbAlloc = (cbAlloc + (4*1024*1024 - 1)) & ~(4*1024*1024 - 1); 90 91 rc = DosAllocMem((PPVOID)&pChunk, cbAlloc, PAG_READ | PAG_WRITE | PAG_COMMIT | OBJ_ANY); 346 * more than enough high memory to allocate from. So, we'll round the 347 * chunks sizes up quite a bit to keep the object count low and the 348 * heap as flexible as possible. 349 */ 350 cbAlloc = *pcb; 351 cbAlloc = HIMEM_ROUND_SIZE(cbAlloc, HIMEM_CHUNK_SIZE); 352 rc = DosAllocMemEx(&pv, cbAlloc, PAG_READ | PAG_WRITE | OBJ_ANY | OBJ_FORK); 92 353 if (rc == ERROR_NOT_ENOUGH_MEMORY) 93 { /* 94 * Retry with page alignment instead of 4MB. 354 { 355 /* 356 * That's odd, we're out of address space or something. 357 * Try again with the minimum rounding. 95 358 */ 96 359 cbAlloc = *pcb + sizeof(HIGHCHUNK); 97 cbAlloc = (cbAlloc + (0x1000 - 1)) & ~(0x1000 - 1); 98 rc = DosAllocMem((PPVOID)&pChunk, cbAlloc, PAG_READ | PAG_WRITE | PAG_COMMIT | OBJ_ANY); 99 } 100 360 cbAlloc = HIMEM_ROUND_SIZE(cbAlloc, HIMEM_CHUNK_SIZE_MIN); 361 rc = DosAllocMemEx(pv, cbAlloc, PAG_READ | PAG_WRITE | OBJ_ANY | OBJ_FORK); 362 } 101 363 if (rc) 102 return NULL; 103 104 /* 105 * We've got a block. Now it's gotta go into the list. 106 */ 107 memcpy(pChunk->szMagic, "HiChunk", sizeof(pChunk->szMagic)); 108 pChunk->cb = cbAlloc; 109 if (_fmutex_request(&_sys_gmtxHimem, _FMR_IGNINT) != 0) 110 { 111 DosFreeMem(pChunk); 112 return NULL; 113 } 114 pChunk->pNext = pHimemHead; 115 pHimemHead = pChunk; 116 _fmutex_release(&_sys_gmtxHimem); 117 118 119 /* 120 * Set the output values and return. 121 */ 122 *pfClean = _BLOCK_CLEAN; 123 *pcb = cbAlloc - sizeof(HIGHCHUNK); 124 return &pChunk[1]; 364 { 365 LIBC_ASSERTM_FAILED("Failed to allocate chunk! rc=%d cbAlloc=%d *pcb=%d\n", rc, cbAlloc, *pcb); 366 LIBCLOG_RETURN_P(NULL); 367 } 368 369 /* 370 * Commit the requested memory size. 371 */ 372 cbCommit = *pcb; 373 cbCommit = HIMEM_ROUND_SIZE(cbCommit, HIMEM_COMMIT_SIZE); 374 rc = DosSetMem(pv, cbCommit, PAG_DEFAULT | PAG_COMMIT); 375 if (!rc) 376 { 377 /* 378 * Allocate a chunk descriptor taking in the heap semaphore in the same run. 379 */ 380 pChunk = himemAllocChunk(); 381 if (pChunk) 382 { 383 /* init */ 384 pChunk->pv = pv; 385 pChunk->cb = cbAlloc; 386 pChunk->cbUncommitted = cbAlloc - cbCommit; 387 /* link in to the list. */ 388 pChunk->pNext = gpHimemHead; 389 gpHimemHead = pChunk; 390 gpHimemHint = pChunk; 391 392 /* release and return. */ 393 _fmutex_release(&_sys_gmtxHimem); 394 *pcb = cbCommit; 395 *pfClean = _BLOCK_CLEAN; 396 LIBCLOG_RETURN_MSG(pv, "ret %p *pcb=%#x\n", pv, *pcb); 397 } 398 } 399 else 400 LIBC_ASSERTM_FAILED("DosSetMem(%p, %#x, PAG_DEFAULT | PAG_COMMIT) -> %d\n", pv, cbCommit, rc); 401 402 DosFreeMemEx(pv); 403 LIBCLOG_RETURN_P(NULL); 125 404 } 126 405 … … 135 414 void __libc_HimemDefaultRelease(Heap_t Heap, void *pv, size_t cb) 136 415 { 416 LIBCLOG_ENTER("Heap=%p pv=%p cb=%#x\n", (void *)Heap, pv, cb); 137 417 int rc; 138 418 PHIGHCHUNK pChunk; 139 419 PHIGHCHUNK pPrevChunk; 140 420 141 /* 142 * Find and unlink the chunk. 421 LIBC_ASSERT(cb); 422 LIBC_ASSERT(!(cb & 0xfff)); 423 LIBC_ASSERT(pv); 424 LIBC_ASSERT(!((uintptr_t)pv & 0xfff)); 425 426 427 /* 428 * Take semaphore. 143 429 */ 144 430 if (_fmutex_request(&_sys_gmtxHimem, _FMR_IGNINT) != 0) 145 431 return; 146 for (pChunk = pHimemHead, pPrevChunk = NULL; pChunk; pPrevChunk = pChunk, pChunk = pChunk->pNext) 147 if (&pChunk[1] == pv) 148 { 149 if (pPrevChunk) 150 pPrevChunk->pNext = pChunk->pNext; 151 else 152 pHimemHead = pChunk->pNext; 153 break; 154 } 432 433 /* 434 * Remove from top to bottom of the described block. 435 * 436 * We must (?) handle cases where the pv+cb describes a memory area 437 * which covers several chunks. This is easier when done from the end. 438 * 439 * We ASSUME that the heap will not request areas which is not at the 440 * end of the committed memory in a chunk. 441 */ 442 do 443 { 444 void *pvEnd = (char *)pv + cb; 445 for (pChunk = gpHimemHead, pPrevChunk = NULL; pChunk; pPrevChunk = pChunk, pChunk = pChunk->pNext) 446 { 447 size_t offEnd = (uintptr_t)pvEnd - (uintptr_t)pChunk->pv; 448 if (offEnd <= pChunk->cb) 449 { 450 void *pvFree; 451 size_t off = (uintptr_t)pv - (uintptr_t)pChunk->pv; 452 if (off > pChunk->cb) 453 off = 0; 454 455 /* check that it's at the end of the committed area. */ 456 if (offEnd != pChunk->cb - pChunk->cbUncommitted) 457 { 458 LIBC_ASSERTM_FAILED("Bad high heap release!! pv=%p cb=%#x off=%#x offEnd=%#x; chunk pv=%p cb=%#x cbUncomitted=%#x\n", 459 pv, cb, off, offEnd, pChunk->pv, pChunk->cb, pChunk->cbUncommitted); 460 _fmutex_release(&_sys_gmtxHimem); 461 LIBCLOG_RETURN_VOID(); 462 } 463 464 /* 465 * Decommit part of the chunk. 466 */ 467 if (off > 0) 468 { 469 size_t cbDecommit = offEnd - off; 470 rc = DosSetMem(pv, cbDecommit, PAG_DECOMMIT); 471 if (rc) 472 { 473 LIBC_ASSERTM_FAILED("DosSetMem(%p, %#x, decommit) -> %d\n", pv, cbDecommit, rc); 474 /* page by page */ 475 for (; cbDecommit; cbDecommit -= 0x1000) 476 DosSetMem(pv, 0x1000, PAG_DECOMMIT); 477 } 478 pChunk->cbUncommitted += cbDecommit; 479 480 /* we're done. */ 481 _fmutex_release(&_sys_gmtxHimem); 482 LIBCLOG_RETURN_VOID(); 483 } 484 485 /* 486 * Free the chunk. 487 */ 488 pvFree = pChunk->pv; 489 /* unlink and free the chunk descriptor */ 490 if (pPrevChunk) 491 pPrevChunk->pNext = pChunk->pNext; 492 else 493 gpHimemHead = pChunk->pNext; 494 if (gpHimemHint == pChunk) 495 gpHimemHint = gpHimemHead; 496 himemFreeChunk(pChunk); 497 498 /* free */ 499 rc = DosFreeMemEx(pvFree); 500 LIBC_ASSERTM(!rc, "DosFreeMem(%p) -> %d\n", pvFree, rc); 501 502 /* Update size and restart loop. */ 503 cb -= offEnd - off; 504 break; 505 } 506 } 507 508 LIBC_ASSERTM(pChunk, "Couldn't find any chunk containing the area pv=%p cb=%#x!\n", pv, cb); 509 } while (cb && pChunk); 510 155 511 _fmutex_release(&_sys_gmtxHimem); 156 157 /* 158 * Precautions and assertions. 159 */ 160 if (!pChunk || cb + sizeof(HIGHCHUNK) != pChunk->cb) 161 { 162 #ifdef DEBUG 163 __asm__("int $3"); 164 #endif 165 return; 166 } 167 168 /* 169 * Free it. 170 */ 171 rc = DosFreeMem(pChunk); 172 if (rc) 173 { 174 #ifdef DEBUG 175 __asm__("int $3"); 176 #endif 177 } 178 } 512 LIBCLOG_RETURN_VOID(); 513 } 514 515 516 #if 0 517 int __libc_HimemDefaultExpand(Heap_t Heap, void *pvBase, size_t cbOld, size_t *pcbNew, int *pfClean) 518 { 519 LIBCLOG_ENTER("Heap=%p pvBase=%p cbOld=%#x pcbNew=%p:{%#x} pfClean=%p\n", 520 (void *)Heap, pvBase, cbOld, (void *)pcbNew, *pcbNew, (void *)pfClean); 521 522 523 LIBCLOG_RETURN_INT(0); 524 } 525 526 void __libc_HimemDefaultShrink(Heap_t Heap, void *pvBase, size_t cbOld, size_t *pcbNew) 527 { 528 LIBCLOG_ENTER("Heap=%p pvBase=%p cbOld=%#x pcbNew=%p:{%#x} pfClean=%p\n", 529 (void *)Heap, pvBase, cbOld, (void *)pcbNew, *pcbNew, (void *)pfClean); 530 531 LIBCLOG_RETURN_VOID(0); 532 } 533 #endif 179 534 180 535 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/logstrict.c
-
Property cvs2svn:cvs-rev
changed from
1.9
to1.10
r1453 r1454 112 112 static inline unsigned getTimestamp(void); 113 113 static inline unsigned getTid(void); 114 static inline unsigned getPid(void); 114 115 static ULONG _System __libc_logXcptHandler(PEXCEPTIONREPORTRECORD pRepRec, struct _EXCEPTIONREGISTRATIONRECORD * pRegRec, PCONTEXTRECORD pCtxRec, PVOID pv); 115 116 static int __libc_logVSNPrintf(char *pszBuffer, size_t cchBuffer, const char *pszFormat, va_list args); 116 117 static int __libc_logSNPrintf(char *pszBuffer, size_t cchBuffer, const char *pszFormat, ...) __printflike(3, 4); 118 117 119 118 120 … … 282 284 " | | | | | errno in hex (0xface if not available).\n" 283 285 " | | | | | | Function Name.\n" 284 " | | | | | | | 285 " v v v v v v v 286 "xxxxxxxx tt nn gggg dddd eeee function [( 286 " | | | | | | | Millisconds In function (Optional).\n" 287 " v v v v v v v v\n" 288 "xxxxxxxx tt nn gggg dddd eeee function [(ms)]: message\n"); 287 289 DosWrite(pInst->hFile, pszMsg, cch, &cb); 288 290 } … … 438 440 { 1, "future" }, /* 22 */ 439 441 { 1, "future" }, /* 23 */ 440 { 1, " future" },/* 24 */441 { 1, " future" },/* 25 */442 { 1, "SPM" }, /* 24 */ 443 { 1, "FORK" }, /* 25 */ 442 444 { 1, "BACK_IO" }, /* 26 */ 443 445 { 1, "INITTERM" }, /* 27 */ … … 450 452 { 1, "ICONV" }, /* 34 */ 451 453 { 1, "DLFCN" }, /* 35 */ 452 { 1, "PTHREAD" } /* 36 */ 454 { 1, "PTHREAD" }, /* 36 */ 455 { 1, "DOSEX" } /* 37 */ 453 456 }; 454 457 static __LIBC_LOGGROUPS DefGrps = … … 464 467 * Create the log instance. 465 468 */ 466 __libc_logSNPrintf(szFilename, sizeof(szFilename), "libc_%04x.log", get pid());469 __libc_logSNPrintf(szFilename, sizeof(szFilename), "libc_%04x.log", getPid()); 467 470 if (__libc_logInit(&DefInst, 0, &DefGrps, szFilename)) 468 471 pDefault = &DefInst; … … 640 643 641 644 /** 645 * Gets the current process id. 646 */ 647 inline static unsigned getPid(void) 648 { 649 PTIB pTib; 650 PPIB pPib; 651 FS_VAR(); 652 FS_SAVE_LOAD(); 653 DosGetInfoBlocks(&pTib, &pPib); 654 FS_RESTORE(); 655 return pPib->pib_ulpid; 656 } 657 658 659 /** 642 660 * Output an enter function log message. 643 661 * An enter message is considered to be one line and is appended a newline if … … 790 808 791 809 va_start(args, pszFormat); 792 cch = __libc_logBuildMsg(pszMsg, pszFormat, args, "%08x %02x %02x %04x Leav %04x %s (% 2d ms): ",810 cch = __libc_logBuildMsg(pszMsg, pszFormat, args, "%08x %02x %02x %04x Leav %04x %s (%d ms): ", 793 811 uTS, getTid(), cDepth, __LIBC_LOG_GETGROUP(fGroupAndFlags), 794 812 pThread ? pThread->iErrNo : 0xface, pszFunction, uTS - uEnterTS); … … 859 877 va_start(args, pszFormat); 860 878 if (uEnterTS != ~0) 861 cch = __libc_logBuildMsg(pszMsg, pszFormat, args, "%08x %02x %02x %04x Mesg %04x %s (% 2d ms): ",879 cch = __libc_logBuildMsg(pszMsg, pszFormat, args, "%08x %02x %02x %04x Mesg %04x %s (%d ms): ", 862 880 uTS, getTid(), cDepth, __LIBC_LOG_GETGROUP(fGroupAndFlags), 863 881 pThread ? pThread->iErrNo : 0xface, pszFunction, uTS - uEnterTS); … … 987 1005 va_start(args, pszFormat); 988 1006 if (uEnterTS != ~0) 989 cch = __libc_logBuildMsg(pszMsg, pszFormat, args, "%08x %02x %02x %04x Dump %04x %s (% 2d ms): ",1007 cch = __libc_logBuildMsg(pszMsg, pszFormat, args, "%08x %02x %02x %04x Dump %04x %s (%d ms): ", 990 1008 uTS, getTid(), cDepth, __LIBC_LOG_GETGROUP(fGroupAndFlags), 991 1009 pThread ? pThread->iErrNo : 0xface, pszFunction, uTS - uEnterTS); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/seterrno.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 86 86 errno = errno_tab[rc]; 87 87 } 88 89 int __libc_native2errno (unsigned long rc) 90 { 91 if (rc >= sizeof (errno_tab)) 92 return EINVAL; 93 return errno_tab[rc]; 94 } 95 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/syscalls.h
-
Property cvs2svn:cvs-rev
changed from
1.10
to1.11
r1453 r1454 6 6 #include "libc-alias.h" 7 7 #include <sys/signal.h> 8 #include <InnoTekLIBC/sharedpm.h> 8 9 9 10 #ifndef __LIBC_THREAD_DECLARED … … 140 141 #endif /* _OS2EMX_H */ 141 142 142 void _sys_set_errno (unsigned long rc);143 143 void _sys_get_clock (unsigned long *ms); 144 144 … … 150 150 ULONG _sys_shrink_heap_by (ULONG decr, ULONG sbrk_model); 151 151 ULONG _sys_shrink_heap_obj_by (ULONG decr); 152 #ifdef _ FMC_SHARED152 #ifdef _SYS_FMUTEX_H 153 153 /** This mutex semaphore protects the heap. */ 154 154 EXTERN _fmutex _sys_heap_fmutex; … … 163 163 extern void __init(int fDefaultHeapInHighMem); 164 164 extern int __init_dll(int fDefaultHeapInHighMem); 165 extern void volatile _sys_init_ret(void *stack);165 extern void /*volatile*/_sys_init_ret(void *stack) __attribute__((__noreturn__)); 166 166 extern int _sys_init_environ(const char *pszEnv); 167 167 extern void _sys_init_largefileio(void); 168 extern int _sys_init_filehandles(void); 168 extern int __libc_fhInit(__LIBC_PSPMINHFHBHDR pInherit); 169 /** @} */ 170 171 /** @defgroup grp_sys_inherit Inherit Function 172 * @{ */ 173 __LIBC_PSPMINHFHBHDR __libc_fhInheritPack(size_t *pcb); 174 void __libc_fhInheritDone(void); 169 175 /** @} */ 170 176 … … 174 180 /** @} */ 175 181 182 183 /** @group Error code and errno Functions. 184 * @{ */ 185 extern void _sys_set_errno(unsigned long rc); 186 extern int __libc_native2errno(unsigned long rc); 187 /** @} */ 188 189 /** @group Exec, Spawn and Fork stuff. 190 * @{ */ 191 #ifdef _SYS_FMUTEX_H 192 EXTERN _fmutex __libc_gmtxExec INIT({0}); 193 #endif 194 /** @} */ 195 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/time/strftime.c
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1453 r1454 23 23 #include <time.h> 24 24 #include <limits.h> 25 #include < sys/locale.h>25 #include <InnoTekLIBC/locale.h> 26 26 #include <emx/time.h> 27 27 #include <sys/builtin.h> … … 160 160 161 161 case 'a': 162 INS (__l ocale_time.swdays [t->tm_wday]);162 INS (__libc_gLocaleTime.swdays [t->tm_wday]); 163 163 break; 164 164 case 'A': 165 INS (__l ocale_time.lwdays [t->tm_wday]);165 INS (__libc_gLocaleTime.lwdays [t->tm_wday]); 166 166 break; 167 167 case 'b': 168 168 case 'h': 169 INS (__l ocale_time.smonths [t->tm_mon]);169 INS (__libc_gLocaleTime.smonths [t->tm_mon]); 170 170 break; 171 171 case 'B': 172 INS (__l ocale_time.lmonths [t->tm_mon]);172 INS (__libc_gLocaleTime.lmonths [t->tm_mon]); 173 173 break; 174 174 case 'c': 175 FMT (__l ocale_time.date_time_fmt);175 FMT (__libc_gLocaleTime.date_time_fmt); 176 176 break; 177 177 case 'C': … … 209 209 break; 210 210 case 'p': 211 INS (t->tm_hour >= 12 ? __l ocale_time.pm : __locale_time.am);211 INS (t->tm_hour >= 12 ? __libc_gLocaleTime.pm : __libc_gLocaleTime.am); 212 212 break; 213 213 case 'r': … … 233 233 break; 234 234 case 'x': 235 FMT (__l ocale_time.date_fmt);235 FMT (__libc_gLocaleTime.date_fmt); 236 236 break; 237 237 case 'X': 238 FMT (__l ocale_time.time_fmt);238 FMT (__libc_gLocaleTime.time_fmt); 239 239 break; 240 240 case 'y': … … 253 253 } 254 254 } 255 else if (!CHK_MBCS_PREFIX ( __locale_ctype, c, i))255 else if (!CHK_MBCS_PREFIX (&__libc_GLocaleCtype, c, i)) 256 256 CHR (c); 257 257 else -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/time/strptime.c
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r1453 r1454 31 31 #include <string.h> 32 32 #include <time.h> 33 #include <InnoTekLIBC/locale.h> 33 34 #include <ctype.h> 34 #include <sys/locale.h>35 35 #include <emx/time.h> 36 36 … … 48 48 return NULL; 49 49 50 static const unsigned char *parse_number (const unsignedchar *s, int *dst,50 static const char *parse_number (const char *s, int *dst, 51 51 int min, int max, int add) 52 52 { … … 66 66 } 67 67 68 static const unsigned char *parse_string (const unsignedchar *s,68 static const char *parse_string (const char *s, 69 69 const char *str) 70 70 { … … 79 79 } 80 80 81 static const unsigned char *parse_table (const unsignedchar *s, int *dst,81 static const char *parse_table (const char *s, int *dst, 82 82 char **tab, int n) 83 83 { … … 99 99 } 100 100 101 static const unsigned char *parse_fmt (const unsignedchar *s,102 const unsignedchar *f, struct tm *tm, unsigned *retmask)101 static const char *parse_fmt (const char *s, 102 const char *f, struct tm *tm, unsigned *retmask) 103 103 { 104 const unsignedchar *t;104 const char *t; 105 105 int week = -1; 106 106 int century = -1; … … 165 165 166 166 case 'a': /* Short weekday name */ 167 TABLE (&tm->tm_wday, __l ocale_time.swdays, 7);167 TABLE (&tm->tm_wday, __libc_gLocaleTime.swdays, 7); 168 168 mask |= MASK_WEEKDAY; 169 169 break; 170 170 171 171 case 'A': /* Long weekday name */ 172 TABLE (&tm->tm_wday, __l ocale_time.lwdays, 7);172 TABLE (&tm->tm_wday, __libc_gLocaleTime.lwdays, 7); 173 173 mask |= MASK_WEEKDAY; 174 174 break; … … 176 176 case 'b': /* Short month name */ 177 177 case 'h': 178 TABLE (&tm->tm_mon, __l ocale_time.smonths, 12);178 TABLE (&tm->tm_mon, __libc_gLocaleTime.smonths, 12); 179 179 mask |= MASK_MONTH; 180 180 break; 181 181 182 182 case 'B': /* Long month name */ 183 TABLE (&tm->tm_mon, __l ocale_time.lmonths, 12);183 TABLE (&tm->tm_mon, __libc_gLocaleTime.lmonths, 12); 184 184 mask |= MASK_MONTH; 185 185 break; 186 186 187 187 case 'c': /* Locale's defined time and date format */ 188 RECURSE (__l ocale_time.date_time_fmt);188 RECURSE (__libc_gLocaleTime.date_time_fmt); 189 189 break; 190 190 … … 242 242 || (tm->tm_hour > 12)) 243 243 return NULL; 244 if ((t = parse_string (s, __l ocale_time.am)) != NULL)244 if ((t = parse_string (s, __libc_gLocaleTime.am)) != NULL) 245 245 { 246 246 if (tm->tm_hour == 12) 247 247 tm->tm_hour = 0; 248 248 } 249 else if ((t = parse_string (s, __l ocale_time.pm)) != NULL)249 else if ((t = parse_string (s, __libc_gLocaleTime.pm)) != NULL) 250 250 { 251 251 if (tm->tm_hour != 12) … … 296 296 297 297 case 'x': 298 RECURSE (__l ocale_time.date_fmt);298 RECURSE (__libc_gLocaleTime.date_fmt); 299 299 break; 300 300 301 301 case 'X': 302 RECURSE (__l ocale_time.time_fmt);302 RECURSE (__libc_gLocaleTime.time_fmt); 303 303 break; 304 304 … … 410 410 char *_STD(strptime) (const char *buf, const char *format, struct tm *tm) 411 411 { 412 return (char *)parse_fmt ((const unsignedchar *)buf,413 (const unsignedchar *)format, tm, NULL);412 return (char *)parse_fmt ((const char *)buf, 413 (const char *)format, tm, NULL); 414 414 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libiconv/iconv.c
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1453 r1454 1 /* iconv wrapper based on OS/2 Unicode API. */ 2 1 /* $Id$ */ 2 /** @file 3 * 4 * iconv wrapper based on OS/2 Unicode API. 5 * 6 * Copyright (c) 2003 InnoTek Systemberatung GmbH 7 * 8 * 9 * This file is part of InnoTek LIBC. 10 * 11 * InnoTek LIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * InnoTek LIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with InnoTek LIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 26 27 28 29 /******************************************************************************* 30 * Header Files * 31 *******************************************************************************/ 32 #include <InnoTekLIBC/locale.h> 3 33 #define INCL_FSMACROS 4 34 #include <os2emx.h> 5 35 #include <uconv.h> 6 36 7 typedef struct _iconv_t 8 { 9 UconvObject from; /* "From" conversion handle */ 10 UconvObject to; /* "To" conversion handle */ 11 } *iconv_t; 12 13 /* Tell "iconv.h" to not define iconv_t by itself. */ 14 #define _ICONV_T 15 #include "iconv.h" 16 37 #include <386/builtin.h> 38 #include <sys/smutex.h> 17 39 #include <string.h> 18 40 #include <malloc.h> 19 41 #include <errno.h> 20 42 #include <alloca.h> 21 #include <emx/locale.h> 43 #include <InnoTekLIBC/fork.h> 44 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_ICONV 45 #include <InnoTekLIBC/logstrict.h> 46 47 typedef struct __libc_iconv_s 48 { 49 UconvObject from; /* "From" conversion handle */ 50 UconvObject to; /* "To" conversion handle */ 51 UniChar * ucp_to; 52 UniChar * ucp_from; 53 struct __libc_iconv_s *pNext; 54 struct __libc_iconv_s *pPrev; 55 } *iconv_t; 56 57 /* Tell "iconv.h" to not define iconv_t by itself. */ 58 #define _ICONV_T 59 #include "iconv.h" 60 61 62 /******************************************************************************* 63 * Global Variables * 64 *******************************************************************************/ 65 /** List of open Iconv structures. 66 * The purpose is to enable fork() to recreate the conversion objects. */ 67 static iconv_t gIconvHead = NULL; 68 /** Mutex protecting the list. */ 69 static _smutex gsmtxIconv = {0}; 70 71 /******************************************************************************* 72 * Internal Functions * 73 *******************************************************************************/ 74 static int iconvForkChild1(__LIBC_PFORKHANDLE pForkHandle, __LIBC_FORKOP enmOperation); 75 22 76 23 77 iconv_t 24 78 iconv_open (const char *cp_to, const char *cp_from) 25 79 { 26 UniChar *ucp;27 80 iconv_t conv; 28 81 uconv_attribute_t attr; 29 82 FS_VAR(); 30 83 31 conv = (iconv_t) malloc (sizeof (struct _iconv_t));84 conv = (iconv_t) calloc (sizeof (struct __libc_iconv_s), 1); 32 85 if (conv == NULL) 33 86 { … … 37 90 38 91 FS_SAVE_LOAD(); 39 ucp = (UniChar *) alloca ((strlen (cp_from) + 2 + 1) * sizeof (UniChar)); 40 __convert_codepage (cp_from, ucp); 41 if (UniCreateUconvObject (ucp, &conv->from)) 42 { 92 conv->ucp_from = (UniChar *) malloc ((strlen (cp_from) + 2 + 1) * sizeof (UniChar)); 93 if (conv->ucp_from == NULL) 94 { 95 free (conv); 96 errno = ENOMEM; 97 FS_RESTORE(); 98 return (iconv_t)(-1); 99 } 100 __libc_TranslateCodepage (cp_from, conv->ucp_from); 101 if (UniCreateUconvObject (conv->ucp_from, &conv->from)) 102 { 103 free (conv->ucp_from); 43 104 free (conv); 44 105 errno = EINVAL; … … 47 108 } 48 109 49 ucp = (UniChar *) alloca ((strlen (cp_to) + 2 + 1) * sizeof (UniChar)); 50 __convert_codepage (cp_to, ucp); 51 if (UniCreateUconvObject (ucp, &conv->to)) 110 conv->ucp_to = (UniChar *) malloc ((strlen (cp_to) + 2 + 1) * sizeof (UniChar)); 111 if (conv->ucp_to == NULL) 52 112 { 53 113 UniFreeUconvObject (conv->from); 114 free (conv->ucp_from); 115 free (conv); 116 errno = ENOMEM; 117 FS_RESTORE(); 118 return (iconv_t)(-1); 119 } 120 __libc_TranslateCodepage (cp_to, conv->ucp_to); 121 if (UniCreateUconvObject (conv->ucp_to, &conv->to)) 122 { 123 UniFreeUconvObject (conv->from); 124 free (conv->ucp_from); 125 free (conv->ucp_to); 54 126 free (conv); 55 127 errno = EINVAL; … … 67 139 attr.converttype &= ~(CVTTYPE_CTRL7F | CVTTYPE_PATH); 68 140 UniSetUconvObject (conv->from, &attr); 141 142 _smutex_request(&gsmtxIconv); 143 conv->pPrev = NULL; 144 conv->pNext = gIconvHead; 145 if (conv->pNext) 146 conv->pNext->pPrev = conv; 147 gIconvHead = conv; 148 _smutex_release(&gsmtxIconv); 69 149 70 150 FS_RESTORE(); … … 170 250 iconv_close (iconv_t conv) 171 251 { 172 if ( !conv && conv != (iconv_t)(-1))252 if (conv && conv != (iconv_t)(-1)) 173 253 { 174 254 FS_VAR(); 255 256 _smutex_request(&gsmtxIconv); 257 if (conv->pNext) 258 conv->pNext->pPrev = conv->pPrev; 259 if (conv->pPrev) 260 conv->pPrev->pNext = conv->pNext; 261 else 262 gIconvHead = conv->pNext; 263 _smutex_release(&gsmtxIconv); 264 265 free (conv->ucp_to); 266 free (conv->ucp_from); 175 267 FS_SAVE_LOAD(); 176 UniFreeUconvObject (conv->to);177 UniFreeUconvObject (conv->from);268 if (conv->to) UniFreeUconvObject (conv->to); 269 if (conv->from) UniFreeUconvObject (conv->from); 178 270 FS_RESTORE(); 179 271 free (conv); … … 181 273 return 0; 182 274 } 275 276 277 #undef __LIBC_LOG_GROUP 278 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_FORK 279 _FORK_CHILD1(0xffff0000, iconvForkChild1) 280 281 /** 282 * Walks the chain of iconv_t structures. 283 * 284 * @returns 0 on success. 285 * @returns positive errno on warning. 286 * @returns negative errno on failure. Fork will be aborted. 287 * @param pForkHandle Pointer to fork handle. 288 * @param enmOperation Callback operation. 289 */ 290 static int iconvForkChild1(__LIBC_PFORKHANDLE pForkHandle, __LIBC_FORKOP enmOperation) 291 { 292 LIBCLOG_ENTER("pForkHandle=%p enmOperation=%d\n", (void *)pForkHandle, enmOperation); 293 int rc = 0; 294 295 switch (enmOperation) 296 { 297 case __LIBC_FORK_OP_FORK_CHILD: 298 { 299 struct __libc_iconv_s *pCur; 300 for (rc = 0, pCur = gIconvHead; !rc && pCur; pCur = pCur->pNext) 301 { 302 pCur->from = NULL; 303 pCur->to = NULL; 304 305 rc = UniCreateUconvObject(pCur->ucp_from, &pCur->from); 306 if (!rc) 307 { 308 rc = UniCreateUconvObject(pCur->ucp_to, &pCur->to); 309 if (!rc) 310 { 311 uconv_attribute_t Attr; 312 UniQueryUconvObject(pCur->from, &Attr, sizeof(Attr), NULL, NULL, NULL); 313 Attr.converttype &= ~(CVTTYPE_CTRL7F | CVTTYPE_PATH); 314 UniSetUconvObject(pCur->from, &Attr); 315 } 316 else 317 LIBC_ASSERTM_FAILED("Failed to create the 'to' object. rc=%d spec=%ls\n", rc, pCur->ucp_to); 318 } 319 else 320 LIBC_ASSERTM_FAILED("Failed to create the 'from' object. rc=%d spec=%ls\n", rc, pCur->ucp_from); 321 } 322 if (rc) 323 rc = -EACCES; /* bad, fixme */ 324 break; 325 } 326 327 default: 328 rc = 0; 329 break; 330 } 331 LIBCLOG_RETURN_INT(rc); 332 } 333 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libiconv/iconv.smak
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1453 r1454 2 2 include comend.smak 3 3 4 .MODULE := iconv4 .MODULE := libiconv 5 5 .MDESC := POSIX iconv API library 6 7 .TARGET := libiconv_p.a 8 .TKIND := aout prof 9 .TSRC := $(wildcard src/libiconv/*.c) 10 .INSDIR = lib/ 11 include mklib.smak 6 12 7 13 .TARGET := libiconv.a … … 11 17 include mklib.smak 12 18 19 .TARGET := libiconv_l.a 20 .TKIND := aout log 21 .TSRC := $(wildcard src/libiconv/*.c) 22 .INSDIR = lib/ 23 include mklib.smak 24 13 25 # Forget temporary variables 14 26 include comend.smak -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/_getsockhandle.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 48 48 { 49 49 LIBCLOG_ENTER("socket=%d\n", socket); 50 PLIBCSOCKETFH pFHSocket = __lib socket_FH(socket);50 PLIBCSOCKETFH pFHSocket = __libc_TcpipFH(socket); 51 51 if (pFHSocket) 52 52 LIBCLOG_RETURN_INT(pFHSocket->iSocket); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/_impsockhandle.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 54 54 int cb; 55 55 int fh; 56 int rc;57 56 58 57 /* … … 62 61 if (__libsocket_getsockopt(os2socket, SOL_SOCKET, SO_TYPE, (char*)&iType, &cb) < 0) 63 62 { 64 __lib socket_setErrno(EBADF);63 __libc_TcpipSetErrno(EBADF); 65 64 LIBCLOG_RETURN_INT(-1); 66 65 } … … 69 68 * Allocate LIBC handle. 70 69 */ 71 rc = __libc_FHAllocate(-1, O_RDWR | F_SOCKET, sizeof(LIBCSOCKETFH), &__libsocket_gSocketOps, (PLIBCFH*)&pFH, &fh);72 if ( rc)70 pFH = TCPNAMEG(AllocFH)(os2socket, &fh); 71 if (!pFH) 73 72 LIBCLOG_RETURN_INT(-1); 74 pFH->iSocket = os2socket;75 73 LIBCLOG_RETURN_INT(fh); 76 74 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/accept.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1453 r1454 33 33 #include <sys/fcntl.h> 34 34 #include <emx/io.h> 35 #include <os2emx.h> 36 #include <InnoTekLIBC/sharedpm.h> 35 37 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_SOCKET 36 38 #include <InnoTekLIBC/logstrict.h> … … 39 41 int accept(int socket, struct sockaddr *addr, int *addrlen) 40 42 { 41 LIBCLOG_ENTER("socket=%d socketaddr=%p addrlen=%p \n",42 socket, addr, addrlen);43 PLIBCSOCKETFH pFHSocket = __lib socket_FH(socket);43 LIBCLOG_ENTER("socket=%d socketaddr=%p addrlen=%p:{%d}\n", 44 socket, (void *)addr, (void *)addrlen, addrlen ? *addrlen : -1); 45 PLIBCSOCKETFH pFHSocket = __libc_TcpipFH(socket); 44 46 int s; 45 47 if (pFHSocket) … … 48 50 if (s >= 0) 49 51 { 50 int rc;51 52 int fh; 52 PLIBCSOCKETFH pFH; 53 rc = __libc_FHAllocate(-1, O_RDWR | F_SOCKET, sizeof(LIBCSOCKETFH), &__libsocket_gSocketOps, (PLIBCFH*)&pFH, &fh); 54 if (!rc) 55 { 56 pFH->iSocket = s; 53 PLIBCSOCKETFH pFH = TCPNAMEG(AllocFH)(s, &fh); 54 if (pFH) 57 55 LIBCLOG_RETURN_INT(fh); 58 }59 56 else 60 57 __libsocket_soclose(s); 61 __lib socket_setSocketErrno();58 __libc_TcpipSetSocketErrno(); 62 59 } 63 60 else 64 __lib socket_setLibcErrno();61 __libc_TcpipUpdateErrno(); 65 62 } 66 63 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/bind.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1453 r1454 40 40 { 41 41 LIBCLOG_ENTER("socket=%d addr=%p addrlen=%d\n", socket, addr, addrlen); 42 PLIBCSOCKETFH pFHSocket = __lib socket_FH(socket);42 PLIBCSOCKETFH pFHSocket = __libc_TcpipFH(socket); 43 43 if (pFHSocket) 44 44 { … … 47 47 if (rc >= 0) 48 48 LIBCLOG_RETURN_INT(rc); 49 __lib socket_setLibcErrno();49 __libc_TcpipUpdateErrno(); 50 50 } 51 51 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/bsdselect.c
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1453 r1454 38 38 #include "socket.h" 39 39 40 41 /*******************************************************************************42 * Defined Constants And Macros *43 *******************************************************************************/44 #ifdef TCPV40HDRS45 46 #define MY_FD_SET(fd, set) FD_SET(fd, set)47 #define MY_FD_ISSET(fd, set) FD_ISSET(fd, set)48 #define MY_FD_ZERO(set, cb) memset(set, 0, cb);49 #define my_fd_set fd_set50 51 #else52 53 #define MY_FD_SET(fd, set) V5_FD_SET(fd, set)54 #define MY_FD_ISSET(fd, set) V5_FD_ISSET(fd, set)55 #define MY_FD_ZERO(set, cb) memset(set, 0, cb);56 #define my_fd_set v5_fd_set57 58 #endif59 60 61 /**62 * Calculate the size required for the converted set structure.63 * @returns number of bytes.64 * @param c Number of file descriptors specified in the call.65 * @param pFrom The select input fd_set structure.66 * @parm pcFDs Store the new number of file descriptors (socket handles) to examin.67 */68 static inline int calcsize(int c, const struct fd_set *pFrom, int *pcFDs)69 {70 int cbRet;71 int i;72 #ifdef TCPV40HDRS73 /* here we need to figure out the max real socket handle */74 int iMax;75 for (iMax = *pcFDs - 1, i = 0; i < c; i++)76 if (FD_ISSET(i, pFrom))77 {78 PLIBCSOCKETFH pFHSocket = __libsocket_FH(i);79 if (pFHSocket && iMax < pFHSocket->iSocket)80 iMax = pFHSocket->iSocket;81 }82 cbRet = (iMax + 8) / 8; /* iMax is index not count, thus +8 not +7. */83 *pcFDs = iMax + 1;84 #else85 for (cbRet = sizeof(u_short), i = 0; i < c; i++)86 if (FD_ISSET(i, pFrom))87 cbRet++;88 *pcFDs = c;89 #endif90 if (cbRet < sizeof(struct my_fd_set))91 return sizeof(struct my_fd_set);92 return cbRet;93 }94 95 /** Converts the LIBC fd_set strcture pointed to by pFrom with it's LIBC socket handles,96 * to the fd_set strcuture used by the OS/2 tcpip and the OS/2 socket handles.97 * @returns 0 on success.98 * @returns -1 on failure, both errnos set.99 * @param c Number of file descriptors specified in the call.100 * @param cb Size of pTo. (used for zeroing it)101 * @param pFrom The select input fd_set structure.102 * @param pTo The structure we present to OS/2 TCPIP.103 * This will be initialized.104 * @param pszType Typestring to use in the log.105 */106 static inline int convert(int c, int cb, const struct fd_set *pFrom, struct my_fd_set *pTo, const char *pszType)107 {108 int i;109 MY_FD_ZERO(pTo, cb)110 for (i = 0; i < c; i++)111 {112 if (FD_ISSET(i, pFrom))113 {114 PLIBCSOCKETFH pFHSocket = __libsocket_FH(i);115 if (!pFHSocket)116 {117 LIBCLOG_MSG2("Invalid handle %d specified (%s).\n", i, pszType);118 return -1;119 }120 MY_FD_SET(pFHSocket->iSocket, pTo);121 LIBCLOG_MSG2("%s: %02d -> %03d\n", pszType, i, pFHSocket->iSocket);122 }123 }124 pszType = pszType;125 return 0;126 }127 128 /**129 * Updates the pTo structure with the fds marked ready in pFrom.130 *131 * @param c Number of file descriptors specified in the call.132 * @param pFrom The structure returned from OS/2 TCPIP select.133 * @param pTo The structure passed in to select which have to134 * be updated for the return.135 * @param pszType Typestring to use in the log.136 */137 static inline void update(int c, const struct my_fd_set *pFrom, struct fd_set *pTo, const char *pszType)138 {139 int i;140 for (i = 0; i < c; i++)141 {142 if (FD_ISSET(i, pTo))143 {144 PLIBCSOCKETFH pFHSocket = __libsocket_FH(i);145 if (pFHSocket)146 {147 if (!MY_FD_ISSET(pFHSocket->iSocket, pFrom))148 {149 FD_CLR(i, pTo);150 LIBCLOG_MSG2("%s: %02d -> %03d set\n", pszType, i, pFHSocket->iSocket);151 }152 else153 LIBCLOG_MSG2("%s: %02d -> %03d clear\n", pszType, i, pFHSocket->iSocket);154 }155 }156 }157 pszType = pszType;158 }159 160 161 162 40 int bsdselect(int nfds, struct fd_set *readfds, struct fd_set *writefds, struct fd_set *exceptfds, struct timeval *tv) 163 41 { 164 LIBCLOG_ENTER("nfds=%d readfds=%p writefds=%p exceptfds=%d tv=%p={tv_sec=%d, rv_usec=%d}\n", 165 nfds, readfds, writefds, exceptfds, tv, tv ? tv->tv_sec : -1, tv ? tv->tv_usec : -1); 166 #ifdef TCPV40HDRS 167 struct fd_set *pRead; 168 struct fd_set *pWrite; 169 struct fd_set *pExcept; 170 #else 171 struct v5_fd_set *pRead; 172 struct v5_fd_set *pWrite; 173 struct v5_fd_set *pExcept; 174 #endif 175 int rc; 176 int cb = 0; 177 int cFDs = 0; 178 179 /* 180 * Calculate bitmapsize. 181 */ 182 if (readfds) 183 cb = calcsize(nfds, readfds, &cFDs); 184 if (writefds) 185 { 186 int cbT = calcsize(nfds, writefds, &cFDs); 187 if (cbT > cb) 188 cb = cbT; 189 } 190 if (exceptfds) 191 { 192 int cbT = calcsize(nfds, exceptfds, &cFDs); 193 if (cbT > cb) 194 cb = cbT; 195 } 196 197 /* 198 * Allocate new bitmaps. 199 */ 200 pRead = NULL; 201 if (readfds) 202 { 203 pRead = alloca(cb); 204 if (!pRead) 205 { 206 __libsocket_setErrno(ENOMEM); 207 LIBCLOG_RETURN_INT(-1); 208 } 209 } 210 211 pWrite = NULL; 212 if (writefds) 213 { 214 pWrite = alloca(cb); 215 if (!pWrite) 216 { 217 __libsocket_setErrno(ENOMEM); 218 LIBCLOG_RETURN_INT(-1); 219 } 220 } 221 222 pExcept = NULL; 223 if (exceptfds) 224 { 225 pExcept = alloca(cb); 226 if (!pExcept) 227 { 228 __libsocket_setErrno(ENOMEM); 229 LIBCLOG_RETURN_INT(-1); 230 } 231 } 232 233 /* 234 * Convert the bitmaps. 235 */ 236 if (readfds) 237 { 238 if (convert(nfds, cb, readfds, pRead, "read ")) 239 LIBCLOG_RETURN_INT(-1); 240 } 241 242 if (writefds) 243 { 244 if (convert(nfds, cb, writefds, pWrite, "write")) 245 LIBCLOG_RETURN_INT(-1); 246 } 247 248 if (exceptfds) 249 { 250 if (convert(nfds, cb, exceptfds, pExcept, "excpt")) 251 LIBCLOG_RETURN_INT(-1); 252 } 253 254 /* 255 * Do the call. 256 */ 257 LIBCLOG_MSG("calling native: cFDs=%d pRead=%p pWrite=%p, pExcept=%p tv=%p\n", 258 cFDs, pRead, pWrite, pExcept, tv); 259 rc = __libsocket_bsdselect(cFDs, pRead, pWrite, pExcept, tv); 260 if (rc < 0) 261 { 262 __libsocket_setLibcErrno(); 263 LIBCLOG_RETURN_INT(rc); 264 } 265 266 /* 267 * Timeout? 268 * Just clear the bitmaps and return. 269 */ 270 if (rc == 0) 271 { 272 cb = (nfds + 7) / 8; 273 if (readfds) 274 memset(readfds, 0, cb); 275 if (writefds) 276 memset(writefds, 0, cb); 277 if (exceptfds) 278 memset(exceptfds, 0, cb); 279 LIBCLOG_RETURN_INT(0); 280 } 281 282 /* 283 * Convert the bitmaps. 284 */ 285 if (readfds) 286 update(nfds, pRead, readfds, "read "); 287 if (writefds) 288 update(nfds, pWrite, writefds, "write"); 289 if (exceptfds) 290 update(nfds, pExcept, exceptfds, "excpt"); 291 42 LIBCLOG_ENTER("nfds=%d readfds=%p writefds=%p exceptfds=%p tv=%p={tv_sec=%ld, rv_usec=%ld}\n", 43 nfds, (void *)readfds, (void *)writefds, (void *)exceptfds, (void *)tv, 44 tv ? tv->tv_sec : -1, tv ? tv->tv_usec : -1); 45 int rc = TCPNAMEG(bsdselect)(nfds, readfds, writefds, exceptfds, tv); 292 46 LIBCLOG_RETURN_INT(rc); 293 47 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/connect.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1453 r1454 40 40 { 41 41 LIBCLOG_ENTER("socket=%d addr=%p addrlen=%d\n", socket, addr, addrlen); 42 PLIBCSOCKETFH pFHSocket = __lib socket_FH(socket);42 PLIBCSOCKETFH pFHSocket = __libc_TcpipFH(socket); 43 43 if (pFHSocket) 44 44 { … … 47 47 if (rc >= 0) 48 48 LIBCLOG_RETURN_INT(rc); 49 __lib socket_setLibcErrno();49 __libc_TcpipUpdateErrno(); 50 50 } 51 51 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/getpeername.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 40 40 { 41 41 LIBCLOG_ENTER("socket=%d addr=%p addrlen=%d\n", socket, addr, addrlen); 42 PLIBCSOCKETFH pFHSocket = __lib socket_FH(socket);42 PLIBCSOCKETFH pFHSocket = __libc_TcpipFH(socket); 43 43 if (pFHSocket) 44 44 { … … 47 47 if (rc >= 0) 48 48 LIBCLOG_RETURN_INT(rc); 49 __lib socket_setLibcErrno();49 __libc_TcpipUpdateErrno(); 50 50 } 51 51 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/getsockname.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 40 40 { 41 41 LIBCLOG_ENTER("socket=%d addr=%p addrlen=%d\n", socket, addr, addrlen); 42 PLIBCSOCKETFH pFHSocket = __lib socket_FH(socket);42 PLIBCSOCKETFH pFHSocket = __libc_TcpipFH(socket); 43 43 if (pFHSocket) 44 44 { … … 47 47 if (rc >= 0) 48 48 LIBCLOG_RETURN_INT(rc); 49 __lib socket_setLibcErrno();49 __libc_TcpipUpdateErrno(); 50 50 } 51 51 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/getsockopt.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1453 r1454 41 41 LIBCLOG_ENTER("socket=%d level=%#x optname=%#x optval=%p optlen=%d\n", 42 42 socket, level, optname, optval, optlen); 43 PLIBCSOCKETFH pFHSocket = __lib socket_FH(socket);43 PLIBCSOCKETFH pFHSocket = __libc_TcpipFH(socket); 44 44 if (pFHSocket) 45 45 { … … 69 69 LIBCLOG_RETURN_INT(rc); 70 70 } 71 __lib socket_setLibcErrno();71 __libc_TcpipUpdateErrno(); 72 72 } 73 73 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/listen.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1453 r1454 40 40 { 41 41 LIBCLOG_ENTER("socket=%d backlog=%d\n", socket, backlog); 42 PLIBCSOCKETFH pFHSocket = __lib socket_FH(socket);42 PLIBCSOCKETFH pFHSocket = __libc_TcpipFH(socket); 43 43 if (pFHSocket) 44 44 { … … 47 47 if (rc >= 0) 48 48 LIBCLOG_RETURN_INT(rc); 49 __lib socket_setLibcErrno();49 __libc_TcpipUpdateErrno(); 50 50 } 51 51 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/os2_ioctl.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 45 45 { 46 46 LIBCLOG_ENTER("socket=%d request=%#x arg=%p len_arg=%d\n", socket, (int)request, arg, len_arg); 47 PLIBCSOCKETFH pFHSocket = __lib socket_FH(socket);47 PLIBCSOCKETFH pFHSocket = __libc_TcpipFH(socket); 48 48 if (pFHSocket) 49 49 { … … 56 56 if (rc >= 0) 57 57 LIBCLOG_RETURN_INT(rc); 58 __lib socket_setLibcErrno();58 __libc_TcpipUpdateErrno(); 59 59 } 60 60 LIBCLOG_RETURN_INT(-1); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/os2_select.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 52 52 if (aSockets) 53 53 { 54 __lib socket_setErrno(ENOMEM);54 __libc_TcpipSetErrno(ENOMEM); 55 55 LIBCLOG_RETURN_INT(-1); 56 56 } 57 57 for (i = 0; i < cSockets; i++) 58 58 { 59 PLIBCSOCKETFH pFHSocket = __lib socket_FH(s[i]);59 PLIBCSOCKETFH pFHSocket = __libc_TcpipFH(s[i]); 60 60 if (!pFHSocket) 61 61 { 62 __lib socket_setErrno(EBADF);62 __libc_TcpipSetErrno(EBADF); 63 63 LIBCLOG_RETURN_INT(-1); 64 64 } … … 72 72 if (rc >= 0) 73 73 LIBCLOG_RETURN_INT(rc); 74 __lib socket_setLibcErrno();74 __libc_TcpipUpdateErrno(); 75 75 LIBCLOG_RETURN_INT(-1); 76 76 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/recv.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1453 r1454 40 40 { 41 41 LIBCLOG_ENTER("socket=%d buf=%p len=%d flags=%#x\n", socket, buf, len, flags); 42 PLIBCSOCKETFH pFHSocket = __lib socket_FH(socket);42 PLIBCSOCKETFH pFHSocket = __libc_TcpipFH(socket); 43 43 if (pFHSocket) 44 44 { … … 47 47 if (rc >= 0) 48 48 LIBCLOG_RETURN_INT(rc); 49 __lib socket_setLibcErrno();49 __libc_TcpipUpdateErrno(); 50 50 } 51 51 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/recvfrom.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1453 r1454 41 41 LIBCLOG_ENTER("socket=%d buf=%p len=%d flags=%#x from=%p from=%d\n", 42 42 socket, buf, len, flags, from, fromlen); 43 PLIBCSOCKETFH pFHSocket = __lib socket_FH(socket);43 PLIBCSOCKETFH pFHSocket = __libc_TcpipFH(socket); 44 44 if (pFHSocket) 45 45 { … … 48 48 if (rc >= 0) 49 49 LIBCLOG_RETURN_INT(rc); 50 __lib socket_setLibcErrno();50 __libc_TcpipUpdateErrno(); 51 51 } 52 52 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/recvmsg.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 40 40 { 41 41 LIBCLOG_ENTER("socket=%d msg=%p flags=%d\n", socket, msg, flags); 42 PLIBCSOCKETFH pFHSocket = __lib socket_FH(socket);42 PLIBCSOCKETFH pFHSocket = __libc_TcpipFH(socket); 43 43 if (pFHSocket) 44 44 { … … 47 47 if (rc >= 0) 48 48 LIBCLOG_RETURN_INT(rc); 49 __lib socket_setLibcErrno();49 __libc_TcpipUpdateErrno(); 50 50 } 51 51 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/send.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1453 r1454 40 40 { 41 41 LIBCLOG_ENTER("socket=%d buf=%p len=%d flags=%#x\n", socket, buf, len, flags); 42 PLIBCSOCKETFH pFHSocket = __lib socket_FH(socket);42 PLIBCSOCKETFH pFHSocket = __libc_TcpipFH(socket); 43 43 if (pFHSocket) 44 44 { … … 47 47 if (rc >= 0) 48 48 LIBCLOG_RETURN_INT(rc); 49 __lib socket_setLibcErrno();49 __libc_TcpipUpdateErrno(); 50 50 } 51 51 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/sendmsg.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 40 40 { 41 41 LIBCLOG_ENTER("socket=%d msg=%p flags=%#x\n", socket, msg, flags); 42 PLIBCSOCKETFH pFHSocket = __lib socket_FH(socket);42 PLIBCSOCKETFH pFHSocket = __libc_TcpipFH(socket); 43 43 if (pFHSocket) 44 44 { … … 47 47 if (rc >= 0) 48 48 LIBCLOG_RETURN_INT(rc); 49 __lib socket_setLibcErrno();49 __libc_TcpipUpdateErrno(); 50 50 } 51 51 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/sendto.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1453 r1454 41 41 LIBCLOG_ENTER("socket=%d buf=%p len=%d flags=%#x to=%p tolen=%p\n", 42 42 socket, buf, len, flags, to, tolen); 43 PLIBCSOCKETFH pFHSocket = __lib socket_FH(socket);43 PLIBCSOCKETFH pFHSocket = __libc_TcpipFH(socket); 44 44 if (pFHSocket) 45 45 { … … 48 48 if (rc >= 0) 49 49 LIBCLOG_RETURN_INT(rc); 50 __lib socket_setLibcErrno();50 __libc_TcpipUpdateErrno(); 51 51 } 52 52 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/setsockopt.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1453 r1454 41 41 LIBCLOG_ENTER("socket=%d level=%#x optname=%#x optval=%p optlen=%d\n", 42 42 socket, level, optname, optval, optlen); 43 PLIBCSOCKETFH pFHSocket = __lib socket_FH(socket);43 PLIBCSOCKETFH pFHSocket = __libc_TcpipFH(socket); 44 44 if (pFHSocket) 45 45 { … … 60 60 if (rc >= 0) 61 61 LIBCLOG_RETURN_INT(rc); 62 __lib socket_setLibcErrno();62 __libc_TcpipUpdateErrno(); 63 63 } 64 64 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/shutdown.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1453 r1454 40 40 { 41 41 LIBCLOG_ENTER("socket=%d how=%d\n", socket, how); 42 PLIBCSOCKETFH pFHSocket = __lib socket_FH(socket);42 PLIBCSOCKETFH pFHSocket = __libc_TcpipFH(socket); 43 43 if (pFHSocket) 44 44 { … … 47 47 if (rc >= 0) 48 48 LIBCLOG_RETURN_INT(rc); 49 __lib socket_setLibcErrno();49 __libc_TcpipUpdateErrno(); 50 50 } 51 51 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/so_cancel.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 40 40 { 41 41 LIBCLOG_ENTER("socket=%d\n", socket); 42 PLIBCSOCKETFH pFHSocket = __lib socket_FH(socket);42 PLIBCSOCKETFH pFHSocket = __libc_TcpipFH(socket); 43 43 if (pFHSocket) 44 44 { … … 47 47 if (rc >= 0) 48 48 LIBCLOG_RETURN_INT(rc); 49 __lib socket_setLibcErrno();49 __libc_TcpipUpdateErrno(); 50 50 } 51 51 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/so_ioctl.c
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1453 r1454 42 42 { 43 43 LIBCLOG_ENTER("socket=%d request=%#lx arg=%#lx\n", socket, request, (&request)[1]); 44 PLIBCSOCKETFH pFHSocket = __lib socket_FH(socket);44 PLIBCSOCKETFH pFHSocket = __libc_TcpipFH(socket); 45 45 if (pFHSocket) 46 46 { -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/so_readv.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 40 40 { 41 41 LIBCLOG_ENTER("socket=%d iov=%p iovcnt=%d\n", socket, iov, iovcnt); 42 PLIBCSOCKETFH pFHSocket = __lib socket_FH(socket);42 PLIBCSOCKETFH pFHSocket = __libc_TcpipFH(socket); 43 43 if (pFHSocket) 44 44 { … … 47 47 if (rc >= 0) 48 48 LIBCLOG_RETURN_INT(rc); 49 __lib socket_setLibcErrno();49 __libc_TcpipUpdateErrno(); 50 50 } 51 51 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/so_writev.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 40 40 { 41 41 LIBCLOG_ENTER("socket=%d iov=%p iovcnt=%d\n", socket, iov, iovcnt); 42 PLIBCSOCKETFH pFHSocket = __lib socket_FH(socket);42 PLIBCSOCKETFH pFHSocket = __libc_TcpipFH(socket); 43 43 if (pFHSocket) 44 44 { … … 47 47 if (rc >= 0) 48 48 LIBCLOG_RETURN_INT(rc); 49 __lib socket_setLibcErrno();49 __libc_TcpipUpdateErrno(); 50 50 } 51 51 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/soabort.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 43 43 { 44 44 LIBCLOG_ENTER("socket=%d\n", socket); 45 PLIBCSOCKETFH pFHSocket = __lib socket_FH(socket);45 PLIBCSOCKETFH pFHSocket = __libc_TcpipFH(socket); 46 46 if (pFHSocket) 47 47 { … … 50 50 if (rc >= 0) 51 51 LIBCLOG_RETURN_INT(rc); 52 __lib socket_setLibcErrno();52 __libc_TcpipUpdateErrno(); 53 53 } 54 54 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/socket.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1453 r1454 33 33 #include <sys/fcntl.h> 34 34 #include <emx/io.h> 35 #include <os2emx.h> 36 #include <InnoTekLIBC/sharedpm.h> 35 37 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_SOCKET 36 38 #include <InnoTekLIBC/logstrict.h> … … 46 48 if (s >= 0) 47 49 { 48 int rc;49 50 int fh; 50 PLIBCSOCKETFH pFH; 51 rc = __libc_FHAllocate(-1, O_RDWR | F_SOCKET, sizeof(LIBCSOCKETFH), &__libsocket_gSocketOps, (PLIBCFH*)&pFH, &fh); 52 if (!rc) 53 { 54 pFH->iSocket = s; 51 PLIBCSOCKETFH pFH = TCPNAMEG(AllocFH)(s, &fh); 52 if (pFH) 55 53 LIBCLOG_RETURN_INT(fh); 56 }57 54 else 58 55 __libsocket_soclose(s); 59 __lib socket_setSocketErrno();56 __libc_TcpipSetSocketErrno(); 60 57 } 61 58 else 62 __lib socket_setLibcErrno();59 __libc_TcpipUpdateErrno(); 63 60 64 61 LIBCLOG_RETURN_INT(-1); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/socket.h
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 4 4 * Interal libsocket stuff. 5 5 * 6 * Copyright (c) 2003 knut st. osmundsen <bird-srcspam@anduin.net>6 * Copyright (c) 2003-2004 knut st. osmundsen <bird-srcspam@anduin.net> 7 7 * 8 8 * … … 28 28 #define __socket_h__ 29 29 30 31 /** @group libsocket libsocket 32 * @{ 33 */ 34 35 /******************************************************************************* 36 * Defined Constants And Macros * 37 *******************************************************************************/ 38 /** The offset the OS/2 TCP/IP errno values are skewed compared to the 39 * LIBC errno values. */ 40 #define EOS2_TCPIP_OFFSET 10000 41 42 /** Get the low word of the ioctl request number. 43 * Used to support ioctl request numbers from old and new _IOC macros. 44 */ 45 #define __IOCLW(a) ((unsigned short)(a)) 46 47 #ifndef TCPV40HDRS 48 49 #define V5_FD_SETSIZE 64 50 #define V5_FD_SET(fd, set) do { \ 51 /* if (((v5_fd_set *)(set))->fd_count < V5_FD_SETSIZE) - calcsize fixes this */ \ 52 ((v5_fd_set *)(set))->fd_array[((v5_fd_set *)(set))->fd_count++]=fd;\ 53 } while(0) 54 #define V5_FD_ISSET(fd, set) v5_isset(fd, set) 30 #include <InnoTekLIBC/tcpip.h> 31 #if 0 32 /* force all objects using socket.h to link in the init routine. */ 33 asm(".stabs \"___libsocket_init\",1,0,0,0"); 34 #endif 55 35 56 36 #endif 57 58 59 /*******************************************************************************60 * Structures and Typedefs *61 *******************************************************************************/62 /** Socket handle.*/63 typedef struct __libc_SocketHandle64 {65 /** the common fh core. */66 LIBCFH core;67 68 /** OS/2 socket number. */69 int iSocket;70 } LIBCSOCKETFH, *PLIBCSOCKETFH;71 72 73 #ifndef TCPV40HDRS74 75 #pragma pack(4)76 /** OS/2 oddities from the BSD 4.4 stack. */77 typedef struct v5_fd_set {78 u_short fd_count; /* how many are SET? */79 int fd_array[V5_FD_SETSIZE];/* an array of SOCKETs */80 } v5_fd_set;81 #pragma pack()82 83 /** internal helper */84 static inline int v5_isset(int fd, const struct v5_fd_set *set)85 {86 const int *pfd = &set->fd_array[0];87 int c = set->fd_count;88 while (c > 0)89 {90 if (*pfd == fd)91 return 1;92 pfd++;93 c--;94 }95 return 0;96 }97 98 #endif99 100 101 /*******************************************************************************102 * Global Variables *103 *******************************************************************************/104 extern LIBCFHOPS __libsocket_gSocketOps;105 106 107 /*******************************************************************************108 * Internal Functions *109 *******************************************************************************/110 /** @defgroup libsocket_renamed Renamed Imports.111 * @{ */112 int TCPCALL __libsocket_accept(int, struct sockaddr *, int *);113 int TCPCALL __libsocket_bind(int, __const__ struct sockaddr *, int);114 int TCPCALL __libsocket_connect(int, __const__ struct sockaddr *, int);115 int TCPCALL __libsocket_getpeername(int, struct sockaddr *, int *);116 int TCPCALL __libsocket_getsockname(int, struct sockaddr *, int *);117 int TCPCALL __libsocket_getsockopt(int, int, int, void *, int *);118 int TCPCALL __libsocket_ioctl(int, int, char *);119 int TCPCALL __libsocket_listen(int, int);120 int TCPCALL __libsocket_os2_ioctl(int, unsigned long, char *, int);121 int TCPCALL __libsocket_os2_select(int *, int, int, int, long);122 int TCPCALL __libsocket_recv(int, void *, int, int);123 int TCPCALL __libsocket_recv(int, void *, int, int);124 int TCPCALL __libsocket_recvfrom(int, void *, int, int, struct sockaddr *, int *);125 int TCPCALL __libsocket_recvmsg(int, struct msghdr *, int);126 int TCPCALL __libsocket_send(int, __const__ void *, int, int);127 int TCPCALL __libsocket_send(int, const void *, int, int);128 int TCPCALL __libsocket_sendmsg(int, __const__ struct msghdr *, int);129 int TCPCALL __libsocket_sendto(int, __const__ void *, int, int, __const__ struct sockaddr *, int);130 int TCPCALL __libsocket_setsockopt(int, int, int, __const__ void *, int);131 int TCPCALL __libsocket_shutdown(int, int);132 int TCPCALL __libsocket_sock_errno(void);133 int TCPCALL __libsocket_socket(int, int, int);134 int TCPCALL __libsocket_socket(int, int, int);135 int TCPCALL __libsocket_socketpair(int, int, int, int *);136 int TCPCALL __libsocket_soclose(int);137 int TCPCALL __libsocket_accept_and_recv(long, long*, struct sockaddr *, long*, struct sockaddr*, long*, caddr_t, size_t);138 void TCPCALL __libsocket_addsockettolist(int);139 int TCPCALL __libsocket_removesocketfromlist(int);140 ssize_t TCPCALL __libsocket_so_readv(int, struct iovec *, int);141 ssize_t TCPCALL __libsocket_so_writev(int, struct iovec *, int);142 int TCPCALL __libsocket_so_cancel(int);143 int TCPCALL __libsocket_soabort(int);144 int TCPCALL __libsocket_Raccept(int, struct sockaddr *, int *);145 struct sockaddr_in;146 int TCPCALL __libsocket_tcpip4_Rbind(int, struct sockaddr_in *, int, struct sockaddr_in *);147 int TCPCALL __libsocket_Rbind(int, struct sockaddr *, int, struct sockaddr *);148 int TCPCALL __libsocket_Rconnect(int, const struct sockaddr *, int);149 int TCPCALL __libsocket_Rgetsockname(int, struct sockaddr *, int *);150 int TCPCALL __libsocket_Rlisten(int, int);151 #ifndef TCPV40HDRS152 ssize_t TCPCALL __libsocket_send_file(int *, struct sf_parms *, int );153 int TCPCALL __libsocket_socketpair(int af, int type, int flags, int *osfd);154 #endif155 char * TCPCALL __libsocket_sock_strerror(int);156 #ifdef TCPV40HDRS157 int TCPCALL __libsocket_bsdselect(int, fd_set *, fd_set *, fd_set *, struct timeval *);158 #else159 int TCPCALL __libsocket_bsdselect(int, v5_fd_set *, v5_fd_set *, v5_fd_set *, struct timeval *);160 #endif161 void TCPCALL __libsocket_set_errno(int);162 /** @} */163 164 165 /** @defgroup libsocket_internal Internal helpers.166 * @{ */167 /**168 * Sets the LIBC and socket errno variables to a given error number.169 */170 static inline void __libsocket_setErrno(int err)171 {172 errno = err;173 __libsocket_set_errno(err + EOS2_TCPIP_OFFSET);174 }175 176 /**177 * Updates the LIBC errno with the latest socket error.178 */179 static inline void __libsocket_setLibcErrno(void)180 {181 int err = __libsocket_sock_errno();182 if (err >= EOS2_TCPIP_OFFSET && err < EOS2_TCPIP_OFFSET + 1000)183 errno = err - EOS2_TCPIP_OFFSET;184 }185 186 /**187 * Updates the socket errno with the latest LIBC error.188 */189 static inline void __libsocket_setSocketErrno(void)190 {191 __libsocket_set_errno(errno + EOS2_TCPIP_OFFSET);192 }193 194 /**195 * Gets the socket errno translating it to a LIBC errno.196 */197 static inline int __libsocket_getSocketErrno(void)198 {199 int err = __libsocket_sock_errno();200 if (err >= EOS2_TCPIP_OFFSET && err < EOS2_TCPIP_OFFSET + 1000)201 return err - EOS2_TCPIP_OFFSET;202 return EDOOFUS;203 }204 205 206 /**207 * Retrieve the socket handle structure for a given handle.208 * @returns Pointer to socket handle structure on success.209 * @returns NULL on failure with errno set to the appropriate value.210 * @param socket Socket handle number.211 */212 static inline PLIBCSOCKETFH __libsocket_FH(int socket)213 {214 PLIBCSOCKETFH pFHSocket = (PLIBCSOCKETFH)__libc_FH(socket);215 if (pFHSocket)216 {217 if ((pFHSocket->core.fFlags & F_TYPEMASK) == F_SOCKET)218 return pFHSocket;219 __libsocket_setErrno(ENOSYS);220 }221 else222 __libsocket_setErrno(EBADF);223 return NULL;224 }225 226 /** @} */227 228 229 /** @} */230 231 #endif -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/socketpair.c
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1453 r1454 28 28 #include <sys/fcntl.h> 29 29 #include <emx/io.h> 30 #include <os2emx.h> 31 #include <InnoTekLIBC/sharedpm.h> 30 32 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_SOCKET 31 33 #include <InnoTekLIBC/logstrict.h> … … 46 48 int TCPCALL socketpair(int af, int type, int flags, int *osfd) 47 49 { 48 LIBCLOG_ENTER("af=%d type=% p flags=%#x osfd=%p\n", af, type, flags,osfd);50 LIBCLOG_ENTER("af=%d type=%d flags=%#x osfd=%p\n", af, type, flags, (void *)osfd); 49 51 #ifdef TCPV40HDRS 50 52 int rc; … … 109 111 osfd[0] = sock1accept; 110 112 osfd[1] = sock2; 111 LIBCLOG_RETURN_ INT(0);113 LIBCLOG_RETURN_MSG(0, "ret 0 osfd[0]=%d osfd[1]=%d\n", osfd[0], osfd[1]); 112 114 113 115 failure: … … 124 126 int fh1; 125 127 int fh2; 126 PLIBCSOCKETFH pFH ;128 PLIBCSOCKETFH pFH1; 127 129 128 130 rc = __libsocket_socketpair(af, type, flags, osfd); 129 131 if (rc < 0) 130 132 { 131 __lib socket_setLibcErrno();133 __libc_TcpipUpdateErrno(); 132 134 LIBCLOG_RETURN_INT(-1); 133 135 } … … 136 138 * Allocate LIBC sockets. 137 139 */ 138 rc = __libc_FHAllocate(-1, O_RDWR | F_SOCKET, sizeof(LIBCSOCKETFH), &__libsocket_gSocketOps, (PLIBCFH*)&pFH, &fh1);139 if ( !rc)140 pFH1 = TCPNAMEG(AllocFH)(osfd[0], &fh1); 141 if (pFH1) 140 142 { 141 pFH->iSocket = osfd[0]; 142 rc = __libc_FHAllocate(-1, O_RDWR | F_SOCKET, sizeof(LIBCSOCKETFH), &__libsocket_gSocketOps, (PLIBCFH*)&pFH, &fh2); 143 if (!rc) 143 PLIBCSOCKETFH pFH2 = TCPNAMEG(AllocFH)(osfd[1], &fh2); 144 if (pFH2) 144 145 { 145 pFH->iSocket = osfd[1];146 146 osfd[0] = fh1; 147 147 osfd[1] = fh2; 148 LIBCLOG_RETURN_INT(0); 148 149 LIBCLOG_RETURN_MSG(0, "ret 0 osfd[0]=%d osfd[1]=%d\n", osfd[0], osfd[1]); 149 150 } 151 __libsocket_soclose(osfd[1]); 150 152 __libc_FHClose(fh1); 151 153 } 154 else 155 { 156 __libsocket_soclose(osfd[1]); 157 __libsocket_soclose(osfd[0]); 158 } 152 159 153 __libsocket_soclose(osfd[0]);154 __libsocket_soclose(osfd[1]);155 160 LIBCLOG_RETURN_INT(-1); 156 161 #endif -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/soclose.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1453 r1454 40 40 { 41 41 LIBCLOG_ENTER("socket=%d\n", socket); 42 PLIBCSOCKETFH pFHSocket = __lib socket_FH(socket);42 PLIBCSOCKETFH pFHSocket = __libc_TcpipFH(socket); 43 43 if (pFHSocket) 44 44 { 45 45 if (!__libc_FHClose(socket)) 46 46 LIBCLOG_RETURN_INT(0); 47 __lib socket_setSocketErrno();47 __libc_TcpipSetSocketErrno(); 48 48 } 49 49 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/os2/memory.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r1453 r1454 29 29 #include <sys/builtin.h> 30 30 #include <sys/fmutex.h> 31 #include <sys/rmutex.h> 31 32 #include <sys/uflags.h> 32 33 #include "emxdll.h" … … 64 65 /* Mutex semaphore for protecting the heap. */ 65 66 66 static _ fmutex heap_fmutex;67 static _rmutex heap_rmutex; 67 68 68 69 /* Number of memory objects registered with register_obj(). */ … … 254 255 void init_heap (void) 255 256 { 256 _ fmutex_create (&heap_fmutex, 0);257 _rmutex_create (&heap_rmutex, 0); 257 258 } 258 259 … … 545 546 ULONG base; 546 547 547 if (_ fmutex_request (&heap_fmutex, _FMR_IGNINT) != 0)548 if (_rmutex_request (&heap_rmutex, _FMR_IGNINT) != 0) 548 549 return -1; 549 550 … … 553 554 base = shrink_heap_by (-incr, uflags & _UF_SBRK_MODEL); 554 555 555 if (_ fmutex_release (&heap_fmutex) != 0)556 if (_rmutex_release (&heap_rmutex) != 0) 556 557 return -1; 557 558 return base != 0 ? (long)base : -1; … … 565 566 ULONG base; 566 567 567 if (_ fmutex_request (&heap_fmutex, _FMR_IGNINT) != 0)568 if (_rmutex_request (&heap_rmutex, _FMR_IGNINT) != 0) 568 569 return -1; 569 570 … … 577 578 base = shrink_heap_to (brkp); 578 579 579 if (_ fmutex_release (&heap_fmutex) != 0)580 if (_rmutex_release (&heap_rmutex) != 0) 580 581 return -1; 581 582 return base != 0 ? 0 : -1; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/version.smak
-
Property cvs2svn:cvs-rev
changed from
1.14
to1.15
r1453 r1454 4 4 VH = 0 5 5 # Middle part of version number 6 VM = 6 6 VM = 6a2 7 7 # Low part of version number 8 8 VL = 0 … … 24 24 25 25 # Copyright 26 COPYRIGHT = Copyright (c) 2003 InnoTek Systemberatung GmbH26 COPYRIGHT = Copyright (c) 2003-2004 InnoTek Systemberatung GmbH -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.