Subversion Repositories Kolibri OS

Rev

Rev 5198 | Rev 6074 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5198 Rev 6068
Line 17... Line 17...
17
#include 
17
#include 
18
#include 
18
#include 
19
#include 
19
#include 
20
#include 
20
#include 
Line -... Line 21...
-
 
21
 
-
 
22
struct app_hdr
-
 
23
{
-
 
24
    char  banner[8];
-
 
25
    int   version;
-
 
26
    int   start;
-
 
27
    int   iend;
-
 
28
    int   memsize;
-
 
29
    int   stacktop;
21
 
30
    char  *cmdline;
-
 
31
    char  *path;
Line -... Line 32...
-
 
32
};
Line 22... Line 33...
22
#include "cpu_features.h"
33
 
23
 
34
extern int main (int, char **, char **);
24
 
35
 
25
/* NOTE: The code for initializing the _argv, _argc, and environ variables
36
/* NOTE: The code for initializing the _argv, _argc, and environ variables
26
 *       has been moved to a separate .c file which is included in both
37
 *       has been moved to a separate .c file which is included in both
Line -... Line 38...
-
 
38
 *       crt1.c and dllcrt1.c. This means changes in the code don't have to
-
 
39
 *       be manually synchronized, but it does lead to this not-generally-
Line 27... Line -...
27
 *       crt1.c and dllcrt1.c. This means changes in the code don't have to
-
 
28
 *       be manually synchronized, but it does lead to this not-generally-
40
 *       a-good-idea use of include. */
29
 *       a-good-idea use of include. */
-
 
30
 
-
 
31
 
-
 
32
extern char __cmdline[];
-
 
33
extern char __pgmname[];
-
 
Line 34... Line 41...
34
 
41
 
-
 
42
char* __appenv;
35
extern int main (int, char **, char **);
43
int   __appenv_size;
-
 
44
 
Line -... Line 45...
-
 
45
extern char _tls_map[128];
-
 
46
 
36
 
47
char * __libc_getenv(const char *name)
-
 
48
{
-
 
49
    return NULL;
-
 
50
}
-
 
51
 
-
 
52
static int split_cmdline(char *cmdline, char **argv)
Line 37... Line 53...
37
int   _errno;
53
{
-
 
54
    enum quote_state
-
 
55
    {
-
 
56
        QUOTE_NONE,         /* no " active in current parm       */
Line -... Line 57...
-
 
57
        QUOTE_DELIMITER,    /* " was first char and must be last */
Line 38... Line 58...
38
int   _fmode;
58
        QUOTE_STARTED       /* " was seen, look for a match      */
39
 
59
    };
-
 
60
 
40
int    _argc;
61
    enum quote_state state;
-
 
62
    unsigned int argc;
-
 
63
    char *p = cmdline;
-
 
64
    char *new_arg, *start;
41
char **_argv;
65
 
Line -... Line 66...
-
 
66
    argc = 0;
42
 
67
 
Line 43... Line 68...
43
static char *arg[2];
68
    for(;;)
-
 
69
    {
44
 
70
        /* skip over spaces and tabs */
45
void   _exit(int __status) __attribute__((noreturn));
71
        if ( *p )
46
 
72
        {
47
 
73
            while (*p == ' ' || *p == '\t')
48
char * __libc_getenv(const char *name)
74
                ++p;
49
{
75
        }
50
    return NULL;
76
 
51
}
77
        if (*p == '\0')
52
 
78
            break;
53
void __main (){};
-
 
54
 
-
 
55
struct app_hdr
79
 
56
{
80
        state = QUOTE_NONE;
57
    char  banner[8];
81
        if( *p == '\"' )
58
    int   version;
82
        {
59
    int   start;
-
 
60
    int   iend;
-
 
61
    int   memsize;
-
 
62
    int   stacktop;
-
 
63
    char  *cmdline;
-
 
64
    char  *path;
-
 
65
};
-
 
66
 
83
            p++;
-
 
84
            state = QUOTE_DELIMITER;
-
 
85
        }
-
 
86
        new_arg = start = p;
-
 
87
        for (;;)
-
 
88
        {
67
typedef void (*ctp)();
89
            if( *p == '\"' )
Line 68... Line 90...
68
static void __do_global_ctors ()
90
            {
69
{
91
                p++;
-
 
92
                if( state == QUOTE_NONE )
70
  extern int __CTOR_LIST__;
93
                {
-
 
94
                    state = QUOTE_STARTED;
71
  int *c = &__CTOR_LIST__;
95
                }
72
  c++;
96
                else
Line -... Line 97...
-
 
97
                {
-
 
98
                    state = QUOTE_NONE;
Line -... Line 99...
-
 
99
                }
-
 
100
                continue;
-
 
101
            }
-
 
102
 
73
  while (*c)
103
            if( *p == ' ' || *p == '\t' )
-
 
104
            {
-
 
105
                if( state == QUOTE_NONE )
-
 
106
                {
-
 
107
                    break;
-
 
108
                }
-
 
109
            }
-
 
110
 
-
 
111
            if( *p == '\0' )
-
 
112
                break;
-
 
113
 
-
 
114
            if( *p == '\\' )
-
 
115
            {
-
 
116
                if( p[1] == '\"' )
-
 
117
                {
-
 
118
                    ++p;
-
 
119
                    if( p[-2] == '\\' )
-
 
120
                    {
Line 74... Line 121...
74
    {
121
                        continue;
-
 
122
                    }
75
      ctp d = (ctp)*c;
123
                }
-
 
124
            }
-
 
125
            if( argv )
76
      (d)();
126
            {
77
      c++;
-
 
78
    }
-
 
Line -... Line 127...
-
 
127
                *(new_arg++) = *p;
-
 
128
            }
-
 
129
            ++p;
79
}
130
        };
-
 
131
 
-
 
132
        if( argv )
-
 
133
        {
-
 
134
            argv[ argc ] = start;
-
 
135
            ++argc;
-
 
136
 
-
 
137
            /*
-
 
138
              The *new = '\0' is req'd in case there was a \" to "
-
 
139
              translation. It must be after the *p check against
-
 
140
              '\0' because new and p could point to the same char
-
 
141
              in which case the scan would be terminated too soon.
-
 
142
            */
-
 
143
 
-
 
144
            if( *p == '\0' )
Line 80... Line 145...
80
 
145
            {
-
 
146
                *new_arg = '\0';
Line 81... Line 147...
81
void  __attribute__((noreturn))
147
                break;
-
 
148
            }
82
__crt_startup (void)
149
            *new_arg = '\0';
83
{
-
 
84
    int nRet;
150
            ++p;
85
    struct   app_hdr *header;
151
        }
Line -... Line 152...
-
 
152
        else
86
 
153
        {
Line 87... Line -...
87
 
-
 
88
    init_global_reent();
154
            ++argc;
89
 
-
 
90
  /*
155
            if( *p == '\0' )
91
   * Initialize floating point unit.
-
 
92
   */
156
            {
93
    __cpu_features_init ();   /* Do we have SSE, etc.*/
157
                break;
Line -... Line 158...
-
 
158
            }
-
 
159
            ++p;
94
//  _fpreset ();              /* Supplied by the runtime library. */
160
        }
-
 
161
    }
-
 
162
 
Line 95... Line -...
95
 
-
 
96
    __do_global_ctors();
163
    return argc;
97
 
-
 
98
    arg[0] = &__pgmname[0];
-
 
99
 
-
 
100
    if( __cmdline[0] != 0)
164
};
-
 
165
 
-
 
166
void  __attribute__((noreturn))
-
 
167
__crt_startup (void)
-
 
168
{
-
 
169
    struct   app_hdr *header = NULL;
-
 
170
    int retval = 0;
-
 
171
 
Line -... Line 172...
-
 
172
    char **argv;
-
 
173
    int    argc;
-
 
174
 
101
    {
175
    memset(_tls_map, 0xFF, 32*4);