Exemple #1
0
static int allocate_transition_tls(int id)
{
    /* Libc function to initialize TLS-based locale info for ctype functions. */
    extern void __ctype_init(void);

    /* We want to free and then reallocate the tls rather than simply
     * reinitializing it because its size may have changed.  TODO: not sure if
     * this is right.  0-ing is one thing, but freeing and reallocating can be
     * expensive, esp if syscalls are involved.  Check out glibc's
     * allocatestack.c for what might work. */
    free_transition_tls(id);

    void *tcb = allocate_tls();
    if (!tcb) {
        errno = ENOMEM;
        return -1;
    }

    /* Setup some intitial TLS data for the newly allocated transition tls. */
    void *temp_tcb = get_tls_desc();
    set_tls_desc(tcb);
    begin_safe_access_tls_vars();
    __vcoreid = id;
    __vcore_context = TRUE;
    __ctype_init();
    end_safe_access_tls_vars();
    set_tls_desc(temp_tcb);

    /* Install the new tls into the vcpd. */
    set_vcpd_tls_desc(id, tcb);
    return 0;
}
Exemple #2
0
void
attribute_hidden
_init (int argc, char **argv, char **envp)
{
#endif
#ifdef USE_NONOPTION_FLAGS
  extern void __getopt_clean_environment (char **);
#endif

  __libc_multiple_libcs = &_dl_starting_up && !_dl_starting_up;

  /* Make sure we don't initialize twice.  */
  if (!__libc_multiple_libcs)
    {
      /* Set the FPU control word to the proper default value if the
	 kernel would use a different value.  (In a static program we
	 don't have this information.)  */
#ifdef SHARED
      if (__fpu_control != GLRO(dl_fpu_control))
#endif
	__setfpucw (__fpu_control);
    }

  /* Save the command-line arguments.  */
  __libc_argc = argc;
  __libc_argv = argv;
  __environ = envp;

#ifndef SHARED
// !BAM
//  __libc_init_secure ();

  /* First the initialization which normally would be done by the
     dynamic linker.  */
// !BAM
//  _dl_non_dynamic_init ();
#endif

#ifdef VDSO_SETUP
  VDSO_SETUP ();
#endif

  __init_misc (argc, argv, envp);

#ifdef USE_NONOPTION_FLAGS
  /* This is a hack to make the special getopt in GNU libc working.  */
  __getopt_clean_environment (envp);
#endif

  /* Initialize ctype data.  */
  __ctype_init ();

#if defined SHARED && !defined NO_CTORS_DTORS_SECTIONS
  __libc_global_ctors ();
#endif
}
Exemple #3
0
void
attribute_hidden
_init (int argc, char **argv, char **envp)
{
#endif

  __libc_multiple_libcs = &_dl_starting_up && !_dl_starting_up;

  /* Make sure we don't initialize twice.  */
  if (!__libc_multiple_libcs)
    {
      /* Set the FPU control word to the proper default value if the
	 kernel would use a different value.  */
      if (__fpu_control != GLRO(dl_fpu_control))
	__setfpucw (__fpu_control);
    }

  /* Save the command-line arguments.  */
  __libc_argc = argc;
  __libc_argv = argv;
  __environ = envp;

#ifndef SHARED
  /* First the initialization which normally would be done by the
     dynamic linker.  */
  _dl_non_dynamic_init ();
#endif

#ifdef VDSO_SETUP
  VDSO_SETUP ();
#endif

  __init_misc (argc, argv, envp);

  /* Initialize ctype data.  */
  __ctype_init ();

#if defined SHARED && !defined NO_CTORS_DTORS_SECTIONS
  __libc_global_ctors ();
#endif
}
Exemple #4
0
char *          _RTL_FUNC _lsetlocale( int __category, const char *__locale )
{
    int start = 1, end = LC_LAST;
    int i;
    char *p;
    char buf2[64];
    LOCALE_HEADER *dat ;
    char *descriptor = __getRtlData()->setlocaledescriptor;
    if (__category != LC_ALL)
        start = end = __category;
    if (__locale && __locale[0] == 0) {
        __locale = getenv(names[LC_ALL]);
        if (!__locale && __category != LC_ALL)
            __locale = getenv(names[__category]);   
        if (!__locale)
            __locale = getenv("LANG");
        if (!__locale)
            return 0;
    }
    p = __locale;
    if (p) {
        if (__category == LC_ALL) {
            if (strchr(p,';')) {
                int done = 0;
                for (i=1; i <= LC_LAST && !done; i++) {
                    int n ;
                    strncpy(buf2,p,63);
                    buf2[63] = 0;
                    n = strcspn(buf2,";");
                    if (buf2[n] == 0)
                        done = 1;
                    else
                        buf2[n] = 0;
                    if (n != 0 && !(dat = lookup(buf2, i)))
                        return 0;
                    p += n + 1;
                }
                done = 0;
                p = __locale;
                for (i=1; i <= LC_LAST && !done; i++) {
                    int n ;
                    strncpy(buf2,p,63);
                    buf2[63] = 0;
                    n = strcspn(buf2,";");
                    if (buf2[n] == 0)
                        done = 1;
                    else
                        buf2[n] = 0;
                    if (n != 0) {
                        if (!(dat = lookup(buf2, i)))
                            return 0;
                        __locale_data[i] = ((void **)dat)[i+1];
                    }                 
                    p += n + 1;
                }
            } else {
                if (!(dat = lookup(p, __category)))
                    return 0;
                for (i=1; i <= LC_LAST; i++) {
                    __locale_data[i] = ((void **)dat)[i+1];
                    
                }
            }
        } else {
            if (strchr(p,';')) {
                for (i=1; *p && i < __category; i++) {
                    p += strcspn(p,";");
                    if (*p)
                        p++;
                }
                if (!*p)
                    return 0;
                strncpy(buf2,p,63);
                buf2[63] = 0;
                i = strcspn(buf2,";");
                buf2[i] = 0;
                p = buf2;
            }
            if (!(dat = lookup(p, __category)))
                return 0;
            __locale_data[__category] = ((void **)dat)[__category + 1];
        }
//        __locale_reinit();
		__ctype_init();
    }
    descriptor[0] = 0;
    for (i=start; i <= end; i++) {
        if (i != start)
            strcat(descriptor,";");
        strcat(descriptor,((COLLATE_DATA *)__locale_data[i])->qualname);
    }
    return descriptor;
}