Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

minios: switch to C99 integer types

This is a necessary step to make minios build on NetBSD.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
  • Loading branch information...
commit 8a870909c488d1dfecda4ee560cfaf6c463aa1c8 1 parent a233a1e
Christoph Egger authored Keir Fraser committed
View
2  arch/ia64/common.c
@@ -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. */
View
2  arch/ia64/time.c
@@ -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;
View
32 arch/x86/time.c
@@ -46,15 +46,15 @@
/* 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;
View
2  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];
View
4 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);
View
6 hypervisor.c
@@ -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]);
View
18 include/arch/cc.h
@@ -13,17 +13,17 @@
#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
View
6 include/fs.h
@@ -11,13 +11,13 @@
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 */
View
6 include/hypervisor.h
@@ -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;
View
2  include/linux/types.h
@@ -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_ */
View
4 include/sched.h
@@ -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__ */
View
4 include/time.h
@@ -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_ */
View
39 include/types.h
@@ -21,20 +21,6 @@
#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;
View
2  include/x86/os.h
@@ -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__ */
View
4 include/x86/x86_32/hypercall-x86_32.h
@@ -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);
}
View
2  include/x86/x86_64/hypercall-x86_64.h
@@ -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);
}
View
2  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)
{
View
28 lib/math.c
@@ -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));
}
View
2  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;
View
14 lwip-arch.c
@@ -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;
View
2  lwip-net.c
@@ -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 */
View
2  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);
Please sign in to comment.
Something went wrong with that request. Please try again.