Print this page
2964 need POSIX 2008 locale object support (more C++ fixes)


  38  * which keeps a point to the opaque per-category data, along with a reference
  39  * count to it.  To be threadsafe, we will use atomics when holding it or
  40  * freeing it.  (This only occurs when locale objects are created or destroyed,
  41  * so there should be no performance impact on hot code paths.  If your code
  42  * uses locale_t creation/destruction on a hot code path, its broken.  But
  43  * even so, the atomic and reference counting will probably *greatly* improve
  44  * your life as bootstrapping locale data from files is quite expensive.
  45  */
  46 
  47 #define NLOCDATA        4
  48 struct locdata {
  49         char            l_lname[ENCODING_LEN+1];        /* locale name */
  50         void            *l_data[NLOCDATA];              /* storage area */
  51         void            *l_map;                         /* mapped file */
  52         size_t          l_map_len;
  53         struct locdata  *l_next;                        /* link cached list */
  54         int             l_cached;                       /* nonzero if cached */
  55 };
  56 
  57 
  58 struct locale {
  59         struct locdata  *locdata[LC_ALL];
  60         struct locale   *next;
  61         int             on_list;        /* on linked list */
  62         char            locname[(ENCODING_LEN+1)*NLOCDATA + 1];
  63 
  64         /*
  65          * Convenience pointers.
  66          */
  67         const struct lc_ctype           *ctype;
  68         const struct lc_collate         *collate;
  69         const struct lc_messages        *messages;
  70         const struct lc_monetary        *monetary;
  71         const struct lc_numeric         *numeric;
  72         const struct lc_time            *time;
  73         const _RuneLocale               *runelocale;
  74 
  75         /*
  76          * The loaded value is used for localeconv.  In paticular, when
  77          * when we change the value of one of the above categories, we will
  78          * also need to update the lconv structure.  The loaded bit indicates
  79          * that the lconv structure is "current" for that category.  It's
  80          * sort of an "inverse dirty" bit.




  38  * which keeps a point to the opaque per-category data, along with a reference
  39  * count to it.  To be threadsafe, we will use atomics when holding it or
  40  * freeing it.  (This only occurs when locale objects are created or destroyed,
  41  * so there should be no performance impact on hot code paths.  If your code
  42  * uses locale_t creation/destruction on a hot code path, its broken.  But
  43  * even so, the atomic and reference counting will probably *greatly* improve
  44  * your life as bootstrapping locale data from files is quite expensive.
  45  */
  46 
  47 #define NLOCDATA        4
  48 struct locdata {
  49         char            l_lname[ENCODING_LEN+1];        /* locale name */
  50         void            *l_data[NLOCDATA];              /* storage area */
  51         void            *l_map;                         /* mapped file */
  52         size_t          l_map_len;
  53         struct locdata  *l_next;                        /* link cached list */
  54         int             l_cached;                       /* nonzero if cached */
  55 };
  56 
  57 
  58 struct _locale {
  59         struct locdata  *locdata[LC_ALL];
  60         struct _locale  *next;
  61         int             on_list;        /* on linked list */
  62         char            locname[(ENCODING_LEN+1)*NLOCDATA + 1];
  63 
  64         /*
  65          * Convenience pointers.
  66          */
  67         const struct lc_ctype           *ctype;
  68         const struct lc_collate         *collate;
  69         const struct lc_messages        *messages;
  70         const struct lc_monetary        *monetary;
  71         const struct lc_numeric         *numeric;
  72         const struct lc_time            *time;
  73         const _RuneLocale               *runelocale;
  74 
  75         /*
  76          * The loaded value is used for localeconv.  In paticular, when
  77          * when we change the value of one of the above categories, we will
  78          * also need to update the lconv structure.  The loaded bit indicates
  79          * that the lconv structure is "current" for that category.  It's
  80          * sort of an "inverse dirty" bit.