Subversion Repositories Kolibri OS

Rev

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

Rev 6084 Rev 6088
Line 5... Line 5...
5
#include "i915_drv.h"
5
#include "i915_drv.h"
6
#include "intel_drv.h"
6
#include "intel_drv.h"
7
#include 
7
#include 
8
#include 
8
#include 
9
#include 
9
#include 
-
 
10
#include "i915_kos32.h"
Line 10... Line 11...
10
 
11
 
11
struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags)
12
struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags)
12
{
13
{
13
    struct file *filep;
14
    struct file *filep;
Line 845... Line 846...
845
    t.tv64 = GetClockNs();
846
    t.tv64 = GetClockNs();
Line 846... Line 847...
846
 
847
 
847
    return t;
848
    return t;
Line -... Line 849...
-
 
849
}
-
 
850
 
-
 
851
char *strdup(const char *str)
-
 
852
{
-
 
853
    size_t len = strlen(str) + 1;
-
 
854
    char *copy = __builtin_malloc(len);
-
 
855
    if (copy)
-
 
856
    {
-
 
857
        memcpy (copy, str, len);
-
 
858
    }
-
 
859
    return copy;
-
 
860
}
-
 
861
 
-
 
862
int split_cmdline(char *cmdline, char **argv)
-
 
863
{
-
 
864
    enum quote_state
-
 
865
    {
-
 
866
        QUOTE_NONE,         /* no " active in current parm       */
-
 
867
        QUOTE_DELIMITER,    /* " was first char and must be last */
-
 
868
        QUOTE_STARTED       /* " was seen, look for a match      */
-
 
869
    };
-
 
870
 
-
 
871
    enum quote_state state;
-
 
872
    unsigned int argc;
-
 
873
    char *p = cmdline;
-
 
874
    char *new_arg, *start;
-
 
875
 
-
 
876
    argc = 0;
-
 
877
 
-
 
878
    for(;;)
-
 
879
    {
-
 
880
        /* skip over spaces and tabs */
-
 
881
        if ( *p )
-
 
882
        {
-
 
883
            while (*p == ' ' || *p == '\t')
-
 
884
                ++p;
-
 
885
        }
-
 
886
 
-
 
887
        if (*p == '\0')
-
 
888
            break;
-
 
889
 
-
 
890
        state = QUOTE_NONE;
-
 
891
        if( *p == '\"' )
-
 
892
        {
-
 
893
            p++;
-
 
894
            state = QUOTE_DELIMITER;
-
 
895
        }
-
 
896
        new_arg = start = p;
-
 
897
        for (;;)
-
 
898
        {
-
 
899
            if( *p == '\"' )
-
 
900
            {
-
 
901
                p++;
-
 
902
                if( state == QUOTE_NONE )
-
 
903
                {
-
 
904
                    state = QUOTE_STARTED;
-
 
905
                }
-
 
906
                else
-
 
907
                {
-
 
908
                    state = QUOTE_NONE;
-
 
909
                }
-
 
910
                continue;
-
 
911
            }
-
 
912
 
-
 
913
            if( *p == ' ' || *p == '\t' )
-
 
914
            {
-
 
915
                if( state == QUOTE_NONE )
-
 
916
                {
-
 
917
                    break;
-
 
918
                }
-
 
919
            }
-
 
920
 
-
 
921
            if( *p == '\0' )
-
 
922
                break;
-
 
923
 
-
 
924
            if( *p == '\\' )
-
 
925
            {
-
 
926
                if( p[1] == '\"' )
-
 
927
                {
-
 
928
                    ++p;
-
 
929
                    if( p[-2] == '\\' )
-
 
930
                    {
-
 
931
                        continue;
-
 
932
                    }
-
 
933
                }
-
 
934
            }
-
 
935
            if( argv )
-
 
936
            {
-
 
937
                *(new_arg++) = *p;
-
 
938
            }
-
 
939
            ++p;
-
 
940
        };
-
 
941
 
-
 
942
        if( argv )
-
 
943
        {
-
 
944
            argv[ argc ] = start;
-
 
945
            ++argc;
-
 
946
 
-
 
947
            /*
-
 
948
              The *new = '\0' is req'd in case there was a \" to "
-
 
949
              translation. It must be after the *p check against
-
 
950
              '\0' because new and p could point to the same char
-
 
951
              in which case the scan would be terminated too soon.
-
 
952
            */
-
 
953
 
-
 
954
            if( *p == '\0' )
-
 
955
            {
-
 
956
                *new_arg = '\0';
-
 
957
                break;
-
 
958
            }
-
 
959
            *new_arg = '\0';
-
 
960
            ++p;
-
 
961
        }
-
 
962
        else
-
 
963
        {
-
 
964
            ++argc;
-
 
965
            if( *p == '\0' )
-
 
966
            {
-
 
967
                break;
-
 
968
            }
-
 
969
            ++p;
-
 
970
        }
-
 
971
    }
-
 
972
 
-
 
973
    return argc;
-
 
974
};
-
 
975
 
-
 
976
char *strstr(const char *cs, const char *ct)
-
 
977
{
-
 
978
int d0, d1;
-
 
979
register char *__res;
-
 
980
__asm__ __volatile__(
-
 
981
    "movl %6,%%edi\n\t"
-
 
982
    "repne\n\t"
-
 
983
    "scasb\n\t"
-
 
984
    "notl %%ecx\n\t"
-
 
985
    "decl %%ecx\n\t"    /* NOTE! This also sets Z if searchstring='' */
-
 
986
    "movl %%ecx,%%edx\n"
-
 
987
    "1:\tmovl %6,%%edi\n\t"
-
 
988
    "movl %%esi,%%eax\n\t"
-
 
989
    "movl %%edx,%%ecx\n\t"
-
 
990
    "repe\n\t"
-
 
991
    "cmpsb\n\t"
-
 
992
    "je 2f\n\t"     /* also works for empty string, see above */
-
 
993
    "xchgl %%eax,%%esi\n\t"
-
 
994
    "incl %%esi\n\t"
-
 
995
    "cmpb $0,-1(%%eax)\n\t"
-
 
996
    "jne 1b\n\t"
-
 
997
    "xorl %%eax,%%eax\n\t"
-
 
998
    "2:"
-
 
999
    : "=a" (__res), "=&c" (d0), "=&S" (d1)
-
 
1000
    : "0" (0), "1" (0xffffffff), "2" (cs), "g" (ct)
-
 
1001
    : "dx", "di");
-
 
1002
return __res;
-
 
1003
}
-
 
1004
 
-
 
1005
fb_get_options(const char *name, char **option)
-
 
1006
{
-
 
1007
    char *opt, *options = NULL;
-
 
1008
    int retval = 1;
-
 
1009
    int name_len;
-
 
1010
 
-
 
1011
    if(i915.cmdline_mode == NULL)
-
 
1012
        return 1;
-
 
1013
 
-
 
1014
    name_len = __builtin_strlen(name);
-
 
1015
 
-
 
1016
    if (name_len )
-
 
1017
    {
-
 
1018
        opt = i915.cmdline_mode;
-
 
1019
        if (!__builtin_strncmp(name, opt, name_len) &&
-
 
1020
             opt[name_len] == ':')
-
 
1021
        {
-
 
1022
             options = opt + name_len + 1;
-
 
1023
             retval = 0;
-
 
1024
        }
-
 
1025
    }
-
 
1026
 
-
 
1027
    if (option)
-
 
1028
        *option = options;
-
 
1029