libc/winsup/cygwin/wchar.h
Corinna Vinschen d16a56306d Consolidate wctomb/mbtowc calls for POSIX-1.2008
- Remove charset parameter from low level __foo_wctomb/__foo_mbtowc calls.
- Instead, create array of function for ISO and Windows codepages to point
  to function which does not require to evaluate the charset string on
  each call.  Create matching helper functions.  I.e., __iso_wctomb,
  __iso_mbtowc, __cp_wctomb and __cp_mbtowc are functions returning the
  right function pointer now.
- Create __WCTOMB/__MBTOWC macros utilizing per-reent locale and replace
  calls to __wctomb/__mbtowc with calls to __WCTOMB/__MBTOWC.
- Drop global __wctomb/__mbtowc vars.
- Utilize aforementioned changes in Cygwin to get rid of charset in other,
  calling functions and simplify the code.
- In Cygwin restrict global cygheap locale info to the job performed
  by internal_setlocale.  Use UTF-8 instead of ASCII on the fly in
  internal conversion functions.
- In Cygwin dll_entry, make sure to initialize a TLS area with a NULL
  _REENT->_locale pointer.  Add comment to explain why.

Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:57 +02:00

68 lines
1.8 KiB
C

/* wchar.h: Extra wchar defs
This file is part of Cygwin.
This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#ifndef _CYGWIN_WCHAR_H
#define _CYGWIN_WCHAR_H
#include_next <wchar.h>
/* Internal headers from newlib */
#include "../locale/setlocale.h"
#define ENCODING_LEN 31
#ifdef __cplusplus
extern "C" {
#endif
typedef int mbtowc_f (struct _reent *, wchar_t *, const char *, size_t,
mbstate_t *);
typedef mbtowc_f *mbtowc_p;
extern mbtowc_f __ascii_mbtowc;
extern mbtowc_f __utf8_mbtowc;
extern mbtowc_p __iso_mbtowc (int);
extern mbtowc_p __cp_mbtowc (int);
#define __MBTOWC (__get_current_locale ()->mbtowc)
typedef int wctomb_f (struct _reent *, char *, wchar_t, mbstate_t *);
typedef wctomb_f *wctomb_p;
extern wctomb_f __ascii_wctomb;
extern wctomb_f __utf8_wctomb;
#define __WCTOMB (__get_current_locale ()->wctomb)
#ifdef __cplusplus
}
#endif
#ifdef __INSIDE_CYGWIN__
#ifdef __cplusplus
size_t __reg3 sys_wcstombs (char *dst, size_t len, const wchar_t * src,
size_t nwc = (size_t) -1);
size_t __reg3 sys_wcstombs_no_path (char *dst, size_t len,
const wchar_t * src,
size_t nwc = (size_t) -1);
size_t __reg3 sys_wcstombs_alloc (char **, int, const wchar_t *,
size_t = (size_t) -1);
size_t __reg3 sys_wcstombs_alloc_no_path (char **, int, const wchar_t *,
size_t = (size_t) -1);
size_t __reg3 sys_cp_mbstowcs (mbtowc_p, wchar_t *, size_t, const char *,
size_t = (size_t) -1);
size_t __reg3 sys_mbstowcs (wchar_t * dst, size_t dlen, const char *src,
size_t nms = (size_t) -1);
size_t __reg3 sys_mbstowcs_alloc (wchar_t **, int, const char *,
size_t = (size_t) -1);
#endif /* __cplusplus */
#endif /* __INSIDE_CYGWIN__ */
#endif /* _CYGWIN_WCHAR_H */