Changeset 270bf4f in mainline


Ignore:
Timestamp:
2015-03-15T00:05:49Z (9 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a420203
Parents:
7f9d97f3
Message:

use intrinsic 128-bit integer type if available

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/typedefs.h

    r7f9d97f3 r270bf4f  
    4747
    4848typedef struct {
    49         uint64_t lo;
    50         int64_t hi;
    51 } __attribute__ ((aligned(16))) int128_t;
    52 
    53 typedef struct {
    54         uint64_t lo;
    55         uint64_t hi;
    56 } __attribute__ ((aligned(16))) uint128_t;
    57 
    58 typedef struct {
    5949        volatile atomic_count_t count;
    6050} atomic_t;
  • tools/autotool.py

    r7f9d97f3 r270bf4f  
    9999
    100100PROBE_TAIL = """}
     101"""
     102
     103PROBE_INT128_HEAD = """#define AUTOTOOL_DECLARE(category, subcategory, tag, name, strc, conc, value) \\
     104        asm volatile ( \\
     105                "AUTOTOOL_DECLARE\\t" category "\\t" subcategory "\\t" tag "\\t" name "\\t" strc "\\t" conc "\\t%[val]\\n" \\
     106                : \\
     107                : [val] "n" (value) \\
     108        )
     109
     110#define DECLARE_INTSIZE(tag, type) \\
     111        AUTOTOOL_DECLARE("intsize", "unsigned", tag, #type, "", "", sizeof(unsigned type)); \\
     112        AUTOTOOL_DECLARE("intsize", "signed", tag, #type, "", "", sizeof(signed type));
     113
     114int main(int argc, char *argv[])
     115{
     116"""
     117
     118PROBE_INT128_TAIL = """}
    101119"""
    102120
     
    510528        return {'unsigned_sizes': unsigned_sizes, 'signed_sizes': signed_sizes, 'unsigned_tags': unsigned_tags, 'signed_tags': signed_tags, 'unsigned_strcs': unsigned_strcs, 'signed_strcs': signed_strcs, 'unsigned_concs': unsigned_concs, 'signed_concs': signed_concs, 'float_tags': float_tags, 'builtin_sizes': builtin_sizes, 'builtin_signs': builtin_signs}
    511529
     530def probe_int128(common):
     531        "Generate, compile and parse probing source for 128-bit integers"
     532       
     533        check_common(common, "CC")
     534       
     535        outf = open(PROBE_SOURCE, 'w')
     536        outf.write(PROBE_INT128_HEAD)
     537        outf.write("\tDECLARE_INTSIZE(\"INT128\", int __attribute((mode(TI))));\n")
     538        outf.write(PROBE_INT128_TAIL)
     539        outf.close()
     540       
     541        args = [common['CC']]
     542        args.extend(common['CC_ARGS'])
     543        args.extend(["-S", "-o", PROBE_OUTPUT, PROBE_SOURCE])
     544       
     545        try:
     546                sys.stderr.write("Checking whether the compiler has intrinsic support for 128-bit integers ... ")
     547                output = subprocess.Popen(args, stdout = subprocess.PIPE, stderr = subprocess.PIPE).communicate()
     548        except:
     549                sys.stderr.write("no\n")
     550                return False
     551       
     552        if (not os.path.isfile(PROBE_OUTPUT)):
     553                sys.stderr.write("no\n")
     554                return False
     555       
     556        inf = open(PROBE_OUTPUT, 'r')
     557        lines = inf.readlines()
     558        inf.close()
     559       
     560        for j in range(len(lines)):
     561                tokens = lines[j].strip().split("\t")
     562               
     563                if (len(tokens) > 0):
     564                        if (tokens[0] == "AUTOTOOL_DECLARE"):
     565                                if (len(tokens) < 7):
     566                                        print_error(["Malformed declaration in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL])
     567                               
     568                                category = tokens[1]
     569                                subcategory = tokens[2]
     570                                tag = tokens[3]
     571                                name = tokens[4]
     572                                strc = tokens[5]
     573                                conc = tokens[6]
     574                                value = tokens[7]
     575                               
     576                                if (category == "intsize"):
     577                                        try:
     578                                                value_int = decode_value(value)
     579                                        except:
     580                                                print_error(["Integer value expected in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL])
     581                                       
     582                                        if (subcategory == "unsigned"):
     583                                                if (value_int != 16):
     584                                                        sys.stderr.write("no\n")
     585                                                        return False
     586                                        elif (subcategory == "signed"):
     587                                                if (value_int != 16):
     588                                                        sys.stderr.write("no\n")
     589                                                        return False
     590                                        else:
     591                                                print_error(["Unexpected keyword \"%s\" in \"%s\" on line %s." % (subcategory, PROBE_OUTPUT, j), COMPILER_FAIL])
     592       
     593        sys.stderr.write("yes\n")
     594        return True
     595
    512596def detect_sizes(probe, bytes, inttags, floattags):
    513597        "Detect correct types for fixed-size types"
     
    683767        outmk.close()
    684768
    685 def create_header(hdname, maps):
     769def create_header(hdname, maps, int128):
    686770        "Create header output"
    687771       
     
    703787        for typedef in maps['typedefs']:
    704788                outhd.write('typedef %s %s;\n' % (typedef['oldtype'], typedef['newtype']))
     789       
     790        if (int128):
     791                outhd.write('typedef unsigned int __attribute((mode(TI))) uint128_t;\n')
     792                outhd.write('typedef signed int __attribute((mode(TI))) int128_t;\n')
    705793       
    706794        outhd.write('\n#endif\n')
     
    845933                )
    846934               
     935                int128 = probe_int128(common)
     936               
    847937                maps = detect_sizes(probe, [1, 2, 4, 8], ['CHAR', 'SHORT', 'INT', 'LONG', 'LLONG'], ['LONG_DOUBLE', 'DOUBLE', 'FLOAT'])
    848938               
     
    851941       
    852942        common['AUTOGEN'] = "%s/autogen.py" % os.path.dirname(os.path.abspath(sys.argv[0]))
    853 
     943       
    854944        create_makefile(MAKEFILE, common)
    855         create_header(HEADER, maps)
     945        create_header(HEADER, maps, int128)
    856946       
    857947        return 0
  • uspace/lib/c/arch/ia64/include/libarch/types.h

    r7f9d97f3 r270bf4f  
    4646#define SSIZE_MAX  INT64_MAX
    4747
    48 typedef struct {
    49         uint64_t lo;
    50         int64_t hi;
    51 } __attribute__((aligned(16))) int128_t;
    52 
    53 typedef struct {
    54         uint64_t lo;
    55         uint64_t hi;
    56 } __attribute__((aligned(16))) uint128_t;
    57 
    5848typedef uint64_t sysarg_t;
    5949typedef int64_t native_t;
Note: See TracChangeset for help on using the changeset viewer.