]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/mini-os.git/commitdiff
minios: switch to C99 integer types
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 15 Jul 2009 08:09:48 +0000 (09:09 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 15 Jul 2009 08:09:48 +0000 (09:09 +0100)
This is a necessary step to make minios build on NetBSD.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
22 files changed:
arch/ia64/common.c
arch/ia64/time.c
arch/x86/time.c
events.c
gnttab.c
hypervisor.c
include/arch/cc.h
include/fs.h
include/hypervisor.h
include/linux/types.h
include/sched.h
include/time.h
include/types.h
include/x86/os.h
include/x86/x86_32/hypercall-x86_32.h
include/x86/x86_64/hypercall-x86_64.h
kernel.c
lib/math.c
lib/sys.c
lwip-arch.c
lwip-net.c
sched.c

index 45b770326c2137b72229fef2f06a2157ab3fa318..c82e604bacedfb8e8a7513561ed453d3ad9deac7 100644 (file)
@@ -68,7 +68,7 @@ char boot_cmd_line[COMMAND_LINE_SIZE+1];
 
 
 void
-ia64_write_itr_i(ia64_pte_t* pteP, u32 reg, uint64_t vAddr,
+ia64_write_itr_i(ia64_pte_t* pteP, uint32_t reg, uint64_t vAddr,
                  uint64_t ps, uint64_t pk)
 {
        /* The virtual address. */
index d358730c2756d12c3ac25137573c1c8529cdd67b..4a3a558dc36263613701af892b8791f804b95912 100644 (file)
@@ -178,7 +178,7 @@ timer_interrupt(evtchn_port_t port, struct pt_regs* regsP, void *data)
 /*
  * monotonic_clock(): returns # of nanoseconds passed since time_init()
  */
-u64
+uint64_t
 monotonic_clock(void)
 {
        uint64_t delta;
index 4af0b89b941bee4a7d6a9daca5d28bb7b5c3b7bd..a55bf59ee60d03e963953d837dceca26311285f0 100644 (file)
 
 /* These are peridically updated in shared_info, and then copied here. */
 struct shadow_time_info {
-       u64 tsc_timestamp;     /* TSC at last update of time vals.  */
-       u64 system_timestamp;  /* Time, in nanosecs, since boot.    */
-       u32 tsc_to_nsec_mul;
-       u32 tsc_to_usec_mul;
+       uint64_t tsc_timestamp;     /* TSC at last update of time vals.  */
+       uint64_t system_timestamp;  /* Time, in nanosecs, since boot.    */
+       uint32_t tsc_to_nsec_mul;
+       uint32_t tsc_to_usec_mul;
        int tsc_shift;
-       u32 version;
+       uint32_t version;
 };
 static struct timespec shadow_ts;
-static u32 shadow_ts_version;
+static uint32_t shadow_ts_version;
 
 static struct shadow_time_info shadow;
 
@@ -84,11 +84,11 @@ static inline int time_values_up_to_date(void)
  * Scale a 64-bit delta by scaling and multiplying by a 32-bit fraction,
  * yielding a 64-bit result.
  */
-static inline u64 scale_delta(u64 delta, u32 mul_frac, int shift)
+static inline uint64_t scale_delta(uint64_t delta, uint32_t mul_frac, int shift)
 {
-       u64 product;
+       uint64_t product;
 #ifdef __i386__
-       u32 tmp1, tmp2;
+       uint32_t tmp1, tmp2;
 #endif
 
        if ( shift < 0 )
@@ -106,11 +106,11 @@ static inline u64 scale_delta(u64 delta, u32 mul_frac, int shift)
                "xor  %5,%5    ; "
                "adc  %5,%%edx ; "
                : "=A" (product), "=r" (tmp1), "=r" (tmp2)
-               : "a" ((u32)delta), "1" ((u32)(delta >> 32)), "2" (mul_frac) );
+               : "a" ((uint32_t)delta), "1" ((uint32_t)(delta >> 32)), "2" (mul_frac) );
 #else
        __asm__ (
                "mul %%rdx ; shrd $32,%%rdx,%%rax"
-               : "=a" (product) : "0" (delta), "d" ((u64)mul_frac) );
+               : "=a" (product) : "0" (delta), "d" ((uint64_t)mul_frac) );
 #endif
 
        return product;
@@ -119,7 +119,7 @@ static inline u64 scale_delta(u64 delta, u32 mul_frac, int shift)
 
 static unsigned long get_nsec_offset(void)
 {
-       u64 now, delta;
+       uint64_t now, delta;
        rdtscll(now);
        delta = now - shadow.tsc_timestamp;
        return scale_delta(delta, shadow.tsc_to_nsec_mul, shadow.tsc_shift);
@@ -151,10 +151,10 @@ static void get_time_values_from_xen(void)
  *             Note: This function is required to return accurate
  *             time even in the absence of multiple timer ticks.
  */
-u64 monotonic_clock(void)
+uint64_t monotonic_clock(void)
 {
-       u64 time;
-       u32 local_time_version;
+       uint64_t time;
+       uint32_t local_time_version;
 
        do {
                local_time_version = shadow.version;
@@ -185,7 +185,7 @@ static void update_wallclock(void)
 
 int gettimeofday(struct timeval *tv, void *tz)
 {
-    u64 nsec = monotonic_clock();
+    uint64_t nsec = monotonic_clock();
     nsec += shadow_ts.tv_nsec;
     
     
index 9ca78d0016dadb6c327c5b3a509fdd49b5f5dd27..c907e652b9625544c1fc3acdcfef199159546f0c 100644 (file)
--- a/events.c
+++ b/events.c
@@ -28,7 +28,7 @@
 typedef struct _ev_action_t {
        evtchn_handler_t handler;
        void *data;
-    u32 count;
+    uint32_t count;
 } ev_action_t;
 
 static ev_action_t ev_actions[NR_EVS];
index 18fd87e29cb2adadde71c893232a8f4476decc30..9b350523d59c036c000e471fa46128791495c3af 100644 (file)
--- a/gnttab.c
+++ b/gnttab.c
@@ -102,7 +102,7 @@ gnttab_grant_transfer(domid_t domid, unsigned long pfn)
 int
 gnttab_end_access(grant_ref_t ref)
 {
-    u16 flags, nflags;
+    uint16_t flags, nflags;
 
     BUG_ON(ref >= NR_GRANT_ENTRIES || ref < NR_RESERVED_ENTRIES);
 
@@ -123,7 +123,7 @@ unsigned long
 gnttab_end_transfer(grant_ref_t ref)
 {
     unsigned long frame;
-    u16 flags;
+    uint16_t flags;
 
     BUG_ON(ref >= NR_GRANT_ENTRIES || ref < NR_RESERVED_ENTRIES);
 
index 936a17b6a9adb5a161d488930da100acd1eed86f..dad8b59609c6ed34515ad5edbb7c57533220db53 100644 (file)
@@ -87,13 +87,13 @@ void force_evtchn_callback(void)
     };
 }
 
-inline void mask_evtchn(u32 port)
+inline void mask_evtchn(uint32_t port)
 {
     shared_info_t *s = HYPERVISOR_shared_info;
     synch_set_bit(port, &s->evtchn_mask[0]);
 }
 
-inline void unmask_evtchn(u32 port)
+inline void unmask_evtchn(uint32_t port)
 {
     shared_info_t *s = HYPERVISOR_shared_info;
     vcpu_info_t *vcpu_info = &s->vcpu_info[smp_processor_id()];
@@ -114,7 +114,7 @@ inline void unmask_evtchn(u32 port)
     }
 }
 
-inline void clear_evtchn(u32 port)
+inline void clear_evtchn(uint32_t port)
 {
     shared_info_t *s = HYPERVISOR_shared_info;
     synch_clear_bit(port, &s->evtchn_pending[0]);
index 02aeb2f4bd53bc7970ff040dafb43c6a50c93354..85cfbdba8f3decac2d9b558ebe87dd7e0cb97810 100644 (file)
 #include <mini-os/os.h>
 #include <mini-os/types.h>
 #include <time.h>
-typedef  u8  u8_t;
-typedef  s8  s8_t;
-typedef u16 u16_t;
-typedef s16 s16_t;
-typedef u32 u32_t;
-typedef s32 s32_t;
-typedef u64 u64_t;
-typedef s64 s64_t;
+typedef uint8_t  u8_t;
+typedef int8_t   s8_t;
+typedef uint16_t u16_t;
+typedef int16_t  s16_t;
+typedef uint32_t u32_t;
+typedef int32_t  s32_t;
+typedef uint64_t u64_t;
+typedef int64_t  s64_t;
 typedef uintptr_t mem_ptr_t;
 
-typedef u16 u_short;
+typedef uint16_t u_short;
 
 /*   Compiler hints for packing lwip's structures - */
 #define PACK_STRUCT_FIELD(_x)  _x
index aa191358223a672e5909d1a73f779765eb2fe522..2f91f8d264a0ccd50b22ffce27fb7d08b3ef989a 100644 (file)
 struct fs_import 
 {
     domid_t dom_id;                 /* dom id of the exporting domain       */ 
-    u16 export_id;                  /* export id (exporting dom specific)   */
-    u16 import_id;                  /* import id (specific to this domain)  */ 
+    uint16_t export_id;             /* export id (exporting dom specific)   */
+    uint16_t import_id;             /* import id (specific to this domain)  */ 
     struct minios_list_head list;   /* list of all imports                  */
     unsigned int nr_entries;        /* Number of entries in rings & request
                                        array                                */
     struct fsif_front_ring ring;    /* frontend ring (contains shared ring) */
-    u32 gnt_refs[FSIF_RING_SIZE_PAGES];  /* grant references to the shared ring  */
+    uint32_t gnt_refs[FSIF_RING_SIZE_PAGES];  /* grant references to the shared ring  */
     evtchn_port_t local_port;       /* local event channel port             */
     char *backend;                  /* XenBus location of the backend       */
     struct fs_request *requests;    /* Table of requests                    */
index b4c7292a47660ec3e449708584c45424ef61ca7d..e299df1f73a381d7e8e31dcf1edf891987651f64 100644 (file)
@@ -40,9 +40,9 @@ extern union start_info_union start_info_union;
 /* hypervisor.c */
 void force_evtchn_callback(void);
 void do_hypervisor_callback(struct pt_regs *regs);
-void mask_evtchn(u32 port);
-void unmask_evtchn(u32 port);
-void clear_evtchn(u32 port);
+void mask_evtchn(uint32_t port);
+void unmask_evtchn(uint32_t port);
+void clear_evtchn(uint32_t port);
 
 extern int in_callback;
 
index 978f29e2cb5d9d4b84d2ab6210f407dd63ab4c3f..ac596a7e2fa58bc9d06dd523dd3d47a63f3d83e7 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef _LINUX_TYPES_H_
 #define _LINUX_TYPES_H_
 #include <mini-os/types.h>
-typedef u64 __u64;
+typedef uint64_t __u64;
 #endif /* _LINUX_TYPES_H_ */
index c60e61e94ae2c6510e23a464cada3eddfc750939..538bed5b8d543b4e0c9cf2238102bbf96de86249 100644 (file)
@@ -20,7 +20,7 @@ struct thread
     thread_regs_t regs;
 #endif /* !defined(__ia64__) */
     struct minios_list_head thread_list;
-    u32 flags;
+    uint32_t flags;
     s_time_t wakeup_time;
 #ifdef HAVE_LIBC
     struct _reent reent;
@@ -54,6 +54,6 @@ void schedule(void);
 
 void wake(struct thread *thread);
 void block(struct thread *thread);
-void msleep(u32 millisecs);
+void msleep(uint32_t millisecs);
 
 #endif /* __SCHED_H__ */
index ac83df855b3bc481a6d0d2d8fb50ea58909fbd0e..5d6ed672d1a738ce831da461a15031ea70a4e724 100644 (file)
@@ -29,7 +29,7 @@
  * The other macros are for convenience to approximate short intervals
  * of real time into system time 
  */
-typedef s64 s_time_t;
+typedef int64_t s_time_t;
 #define NOW()                   ((s_time_t)monotonic_clock())
 #define SECONDS(_s)             (((s_time_t)(_s))  * 1000000000UL )
 #define TENTHS(_ts)             (((s_time_t)(_ts)) * 100000000UL )
@@ -57,7 +57,7 @@ void     init_time(void);
 void     fini_time(void);
 s_time_t get_s_time(void);
 s_time_t get_v_time(void);
-u64      monotonic_clock(void);
+uint64_t monotonic_clock(void);
 void     block_domain(s_time_t until);
 
 #endif /* _MINIOS_TIME_H_ */
index 19b730280d3892bf059caa69f6da6c00f1117aac..456e21ac0687ae33d7b937e20ed69663e471ee8f 100644 (file)
 #define _TYPES_H_
 #include <stddef.h>
 
-typedef signed char         s8;
-typedef unsigned char       u8;
-typedef signed short        s16;
-typedef unsigned short      u16;
-typedef signed int          s32;
-typedef unsigned int        u32;
-#ifdef __i386__
-typedef signed long long    s64;
-typedef unsigned long long  u64;
-#elif defined(__x86_64__) || defined(__ia64__)
-typedef signed long         s64;
-typedef unsigned long       u64;
-#endif
-
 /* FreeBSD compat types */
 #ifndef HAVE_LIBC
 typedef unsigned char       u_char;
@@ -72,15 +58,22 @@ typedef int                 intptr_t;
 typedef unsigned long       uintptr_t;
 typedef long                intptr_t;
 #endif /* __i386__ || __x86_64__ */
-typedef  u8 uint8_t;
-typedef  s8 int8_t;
-typedef u16 uint16_t;
-typedef s16 int16_t;
-typedef u32 uint32_t;
-typedef s32 int32_t;
-typedef u64 uint64_t, uintmax_t;
-typedef s64 int64_t, intmax_t;
-typedef u64 off_t;
+typedef unsigned char uint8_t;
+typedef   signed char int8_t;
+typedef unsigned short uint16_t;
+typedef   signed short int16_t;
+typedef unsigned int uint32_t;
+typedef   signed int int32_t;
+#ifdef __i386__
+typedef   signed long long int64_t;
+typedef unsigned long long uint64_t;
+#elif defined(__x86_64__) || defined(__ia64__)
+typedef   signed long int64_t;
+typedef unsigned long uint64_t;
+#endif
+typedef uint64_t uintmax_t;
+typedef  int64_t intmax_t;
+typedef uint64_t off_t;
 #endif
 
 typedef intptr_t            ptrdiff_t;
index 7fc3a83b53885a379d77afbfd8ccce249c48e6c2..6bd0ebee99ad35279c4ef3e11d560df493762c9f 100644 (file)
@@ -445,7 +445,7 @@ static __inline__ unsigned long __ffs(unsigned long word)
                            : /* no outputs */ \
                            : "c" (msr), "a" (val1), "d" (val2))
 
-#define wrmsrl(msr,val) wrmsr(msr,(u32)((u64)(val)),((u64)(val))>>32)
+#define wrmsrl(msr,val) wrmsr(msr,(uint32_t)((uint64_t)(val)),((uint64_t)(val))>>32)
 
 
 #else /* ifdef __x86_64__ */
index d5f5b1e713c651f44484a0f5a07ec754b858ad95..43028eea0ab671fe499058c8fc016231b1376473 100644 (file)
@@ -174,7 +174,7 @@ HYPERVISOR_sched_op(
 
 static inline long
 HYPERVISOR_set_timer_op(
-       u64 timeout)
+       uint64_t timeout)
 {
        unsigned long timeout_hi = (unsigned long)(timeout>>32);
        unsigned long timeout_lo = (unsigned long)timeout;
@@ -197,7 +197,7 @@ HYPERVISOR_get_debugreg(
 
 static inline int
 HYPERVISOR_update_descriptor(
-       u64 ma, u64 desc)
+       uint64_t ma, uint64_t desc)
 {
        return _hypercall4(int, update_descriptor, ma, ma>>32, desc, desc>>32);
 }
index 32ea5bd611abb8d35a29f46f3106ea46c175a317..b874f039fe3217ff5ea9f5b5827c109bbd09dc8b 100644 (file)
@@ -178,7 +178,7 @@ HYPERVISOR_sched_op(
 
 static inline long
 HYPERVISOR_set_timer_op(
-       u64 timeout)
+       uint64_t timeout)
 {
        return _hypercall1(long, set_timer_op, timeout);
 }
index f2bd01f8ebf0a7835c4658ac8a2d3ae1b65e47f1..33c91b59ff96d355f8492604e27534aea7df1a12 100644 (file)
--- a/kernel.c
+++ b/kernel.c
@@ -49,7 +49,7 @@
 
 static struct netfront_dev *net_dev;
 
-u8 xen_features[XENFEAT_NR_SUBMAPS * 32];
+uint8_t xen_features[XENFEAT_NR_SUBMAPS * 32];
 
 void setup_xen_features(void)
 {
index f1f7826080fa6d361c841bf78747430e9411c867..55ece1ed510efe94a612b6a0f40042aedc4ab721 100644 (file)
@@ -68,8 +68,8 @@
  * one or more of the following formats.
  */
 union uu {
-        s64            q;              /* as a (signed) quad */
-        s64            uq;             /* as an unsigned quad */
+        int64_t           q;              /* as a (signed) quad */
+        int64_t          uq;             /* as an unsigned quad */
         long           sl[2];          /* as two signed longs */
         unsigned long  ul[2];          /* as two unsigned longs */
 };
@@ -90,7 +90,7 @@ union uu {
 #ifndef HAVE_LIBC
 #define CHAR_BIT        8               /* number of bits in a char */
 #endif
-#define QUAD_BITS       (sizeof(s64) * CHAR_BIT)
+#define QUAD_BITS       (sizeof(int64_t) * CHAR_BIT)
 #define LONG_BITS       (sizeof(long) * CHAR_BIT)
 #define HALF_BITS       (sizeof(long) * CHAR_BIT / 2)
 
@@ -147,8 +147,8 @@ shl(register digit *p, register int len, register int sh)
  * divisor are 4 `digits' in this base (they are shorter if they have
  * leading zeros).
  */
-u64
-__qdivrem(u64 uq, u64 vq, u64 *arq)
+uint64_t
+__qdivrem(uint64_t uq, uint64_t vq, uint64_t *arq)
 {
        union uu tmp;
        digit *u, *v, *q;
@@ -348,31 +348,31 @@ __qdivrem(u64 uq, u64 vq, u64 *arq)
  * Divide two signed quads.
  * ??? if -1/2 should produce -1 on this machine, this code is wrong
  */
-s64
-__divdi3(s64 a, s64 b)
+int64_t
+__divdi3(int64_t a, int64_t b)
 {
-       u64 ua, ub, uq;
+       uint64_t ua, ub, uq;
        int neg;
 
        if (a < 0)
-               ua = -(u64)a, neg = 1;
+               ua = -(uint64_t)a, neg = 1;
        else
                ua = a, neg = 0;
        if (b < 0)
-               ub = -(u64)b, neg ^= 1;
+               ub = -(uint64_t)b, neg ^= 1;
        else
                ub = b;
-       uq = __qdivrem(ua, ub, (u64 *)0);
+       uq = __qdivrem(ua, ub, (uint64_t *)0);
        return (neg ? -uq : uq);
 }
 
 /*
  * Divide two unsigned quads.
  */
-u64
-__udivdi3(u64 a, u64 b)
+uint64_t
+__udivdi3(uint64_t a, uint64_t b)
 {
-        return (__qdivrem(a, b, (u64 *)0));
+        return (__qdivrem(a, b, (uint64_t *)0));
 }
 
 
index 166ecc9c0996bd9ecaac80fff07b76794c1d6a4c..8cb5d28479633237146bbb0611ff776e3696dcb1 100644 (file)
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -1189,7 +1189,7 @@ int clock_gettime(clockid_t clk_id, struct timespec *tp)
        }
        case CLOCK_REALTIME:
        {
-           u64 nsec = monotonic_clock();
+           uint64_t nsec = monotonic_clock();
 
            tp->tv_sec = nsec / 1000000000ULL;
            tp->tv_nsec = nsec % 1000000000ULL;
index cdd4fa66cc7220d864a0800e8fca5aa44fe25180..e634ef466ec1eaaab5637ef18f5d40f2e8393705 100644 (file)
@@ -20,7 +20,7 @@ void sys_init(void)
 
 /* Creates and returns a new semaphore. The "count" argument specifies
  * the initial state of the semaphore. */
-sys_sem_t sys_sem_new(u8_t count)
+sys_sem_t sys_sem_new(uint8_t count)
 {
     struct semaphore *sem = xmalloc(struct semaphore);
     sem->count = count;
@@ -50,13 +50,13 @@ void sys_sem_signal(sys_sem_t sem)
  * semaphore wasn't signaled within the specified time, the return value is
  * SYS_ARCH_TIMEOUT. If the thread didn't have to wait for the semaphore
  * (i.e., it was already signaled), the function may return zero. */
-u32_t sys_arch_sem_wait(sys_sem_t sem, u32_t timeout)
+uint32_t sys_arch_sem_wait(sys_sem_t sem, uint32_t timeout)
 {
     /* Slightly more complicated than the normal minios semaphore:
      * need to wake on timeout *or* signal */
     sys_prot_t prot;
-    s64_t then = NOW();
-    s64_t deadline;
+    int64_t then = NOW();
+    int64_t deadline;
 
     if (timeout == 0)
        deadline = 0;
@@ -174,9 +174,9 @@ static void do_mbox_fetch(sys_mbox_t mbox, void **msg)
  * The return values are the same as for the sys_arch_sem_wait() function:
  * Number of milliseconds spent waiting or SYS_ARCH_TIMEOUT if there was a
  * timeout. */
-u32_t sys_arch_mbox_fetch(sys_mbox_t mbox, void **msg, u32_t timeout)
+uint32_t sys_arch_mbox_fetch(sys_mbox_t mbox, void **msg, uint32_t timeout)
 {
-    u32 rv;
+    uint32_t rv;
     if (mbox == SYS_MBOX_NULL)
         return SYS_ARCH_TIMEOUT;
 
@@ -199,7 +199,7 @@ u32_t sys_arch_mbox_fetch(sys_mbox_t mbox, void **msg, u32_t timeout)
  *     sys_arch_mbox_fetch(mbox,msg,1)
  * although this would introduce unnecessary delays. */
 
-u32_t sys_arch_mbox_tryfetch(sys_mbox_t mbox, void **msg) {
+uint32_t sys_arch_mbox_tryfetch(sys_mbox_t mbox, void **msg) {
     if (mbox == SYS_MBOX_NULL)
         return SYS_ARCH_TIMEOUT;
 
index 194ae2711e657eca8fa3949efd9db008eba3ce40..9fded114c824abe1966a81c199e959e43d0292ab 100644 (file)
@@ -207,7 +207,7 @@ netfront_input(struct netif *netif, unsigned char* data, int len)
     etharp_ip_input(netif, p);
 #endif
     /* skip Ethernet header */
-    pbuf_header(p, -(s16)sizeof(struct eth_hdr));
+    pbuf_header(p, -(int16_t)sizeof(struct eth_hdr));
     /* pass to network layer */
     if (tcpip_input(p, netif) == ERR_MEM)
       /* Could not store it, drop */
diff --git a/sched.c b/sched.c
index ab454cd83a6c4480a5c28b4f00811a29daaae5af..b1e1d288b80e7815553174fec5931e724e543cee 100644 (file)
--- a/sched.c
+++ b/sched.c
@@ -227,7 +227,7 @@ void block(struct thread *thread)
     clear_runnable(thread);
 }
 
-void msleep(u32 millisecs)
+void msleep(uint32_t millisecs)
 {
     struct thread *thread = get_current();
     thread->wakeup_time = NOW()  + MILLISECS(millisecs);