Subversion Repositories HelenOS-historic

Rev

Rev 857 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 857 Rev 1031
Line 27... Line 27...
27
 */
27
 */
28
 
28
 
29
#ifndef __SFTYPES_H__
29
#ifndef __SFTYPES_H__
30
#define __SFTYPES_H__
30
#define __SFTYPES_H__
31
 
31
 
32
#include <types.h>
32
#include <endian.h>
33
#include <arch.h>
33
#include <stdint.h>
34
 
34
 
35
typedef union {
35
typedef union {
36
    float f;
36
    float f;
37
    __u32 binary;
37
    uint32_t binary;
38
 
38
 
39
    struct  {
39
    struct  {
40
        #ifdef __BIG_ENDIAN__
40
        #if __BYTE_ORDER == __BIG_ENDIAN
41
        __u32 sign:1;
41
        uint32_t sign:1;
42
        __u32 exp:8;
42
        uint32_t exp:8;
43
        __u32 fraction:23;
43
        uint32_t fraction:23;
44
        #elif defined __LITTLE_ENDIAN__
44
        #elif __BYTE_ORDER == __LITTLE_ENDIAN
45
        __u32 fraction:23;
45
        uint32_t fraction:23;
46
        __u32 exp:8;
46
        uint32_t exp:8;
47
        __u32 sign:1;
47
        uint32_t sign:1;
48
        #else 
48
        #else 
49
        #error "Unknown endians."
49
            #error "Unknown endians."
50
        #endif
50
        #endif
51
        } parts __attribute__ ((packed));
51
        } parts __attribute__ ((packed));
52
    } float32;
52
    } float32;
53
   
53
   
54
typedef union {
54
typedef union {
55
    double d;
55
    double d;
56
    __u64 binary;
56
    uint64_t binary;
57
   
57
   
58
    struct  {
58
    struct  {
59
        #ifdef __BIG_ENDIAN__
59
        #if __BYTE_ORDER == __BIG_ENDIAN
60
        __u64 sign:1;
60
        uint64_t sign:1;
61
        __u64 exp:11;
61
        uint64_t exp:11;
62
        __u64 fraction:52;
62
        uint64_t fraction:52;
63
        #elif defined __LITTLE_ENDIAN__
63
        #elif __BYTE_ORDER == __LITTLE_ENDIAN
64
        __u64 fraction:52;
64
        uint64_t fraction:52;
65
        __u64 exp:11;
65
        uint64_t exp:11;
66
        __u64 sign:1;
66
        uint64_t sign:1;
67
        #else 
67
        #else 
68
        #error "Unknown endians."
68
            #error "Unknown endians."
69
        #endif
69
        #endif
70
        } parts __attribute__ ((packed));
70
        } parts __attribute__ ((packed));
71
    } float64;
71
    } float64;
72
 
72
 
73
#define FLOAT32_MAX 0x7f800000
73
#define FLOAT32_MAX 0x7f800000