From 744378194dae326fba7b9fdc3ecb0fed3bad498e Mon Sep 17 00:00:00 2001 From: Lionel Sambuc Date: Tue, 16 Apr 2013 11:48:54 +0200 Subject: [PATCH] Alignement on netbsd types, part 1 The following types are modified (old -> new): * _BSD_USECONDS_T_ int -> unsigned int * __socklen_t __int32_t -> __uint32_t * blksize_t uint32_t -> int32_t * rlim_t uint32_t -> uint64_t On ARM: * _BSD_CLOCK_T_ int -> unsigned int On Intel: * _BSD_CLOCK_T_ int -> unsigned long bin/cat is also updated in order to fix warnings. _BSD_TIMER_T_ has still to be aligned. Change-Id: I2b4fda024125a19901120546c4e22e443ba5e9d7 --- bin/cat/cat.1 | 11 +++++--- bin/cat/cat.c | 8 +++--- include/dirent.h | 2 +- include/minix/virtio.h | 24 ++++++++-------- include/stdlib.h | 1 + include/unistd.h | 1 - kernel/clock.c | 7 +++-- kernel/system/do_vtimer.c | 6 ++-- lib/libvirtio/virtio.c | 8 +++--- releasetools/nbsd_ports | 2 +- servers/inet/clock.c | 8 +++--- servers/inet/generic/clock.h | 2 +- servers/inet/generic/tcp_send.c | 23 +++++++-------- servers/is/dmp_kernel.c | 2 +- servers/is/dmp_pm.c | 2 +- servers/is/dmp_rs.c | 2 +- servers/pm/alarm.c | 11 ++++---- servers/rs/exec.c | 2 +- sys/arch/arm/include/ansi.h | 11 +++++--- sys/arch/i386/include/ansi.h | 11 +++++--- sys/arch/i386/include/asm.h | 4 +-- sys/sys/ansi.h | 2 +- sys/sys/disklabel_gpt.h | 9 ++---- sys/sys/fd_set.h | 50 +++++++++++++++++---------------- sys/sys/file.h | 30 ++++++++++++-------- sys/sys/time.h | 3 +- sys/sys/types.h | 15 ++-------- test/test2.c | 6 +--- 28 files changed, 130 insertions(+), 133 deletions(-) diff --git a/bin/cat/cat.1 b/bin/cat/cat.1 index c60063330..d2e07539d 100644 --- a/bin/cat/cat.1 +++ b/bin/cat/cat.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: cat.1,v 1.32 2006/09/23 11:24:44 wiz Exp $ +.\" $NetBSD: cat.1,v 1.34 2012/08/09 07:26:28 dholland Exp $ .\" .\" Copyright (c) 1989, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -32,7 +32,7 @@ .\" .\" @(#)cat.1 8.3 (Berkeley) 5/2/95 .\" -.Dd September 23, 2006 +.Dd April 6, 2012 .Dt CAT 1 .Os .Sh NAME @@ -54,6 +54,9 @@ A single dash represents the standard input, and may appear multiple times in the .Ar file list. +If no +.Ar file +operands are given, standard input is read. .Pp The word .Dq concatenate @@ -65,7 +68,7 @@ The options are as follows: .It Fl b Implies the .Fl n -option but doesn't number blank lines. +option, but doesn't number blank lines. .It Fl e Implies the .Fl v @@ -139,7 +142,7 @@ to the file truncating .Ar file3 if it already exists. -See the manual page for your shell (i.e., +See the manual page for your shell (e.g., .Xr sh 1 ) for more information on redirection. .Pp diff --git a/bin/cat/cat.c b/bin/cat/cat.c index 5d955e56a..176aeb986 100644 --- a/bin/cat/cat.c +++ b/bin/cat/cat.c @@ -1,4 +1,4 @@ -/* $NetBSD: cat.c,v 1.47 2008/07/20 00:52:39 lukem Exp $ */ +/* $NetBSD: cat.c,v 1.48 2012/03/17 23:35:28 christos Exp $ */ /* * Copyright (c) 1989, 1993 @@ -44,7 +44,7 @@ __COPYRIGHT( #if 0 static char sccsid[] = "@(#)cat.c 8.2 (Berkeley) 4/27/95"; #else -__RCSID("$NetBSD: cat.c,v 1.47 2008/07/20 00:52:39 lukem Exp $"); +__RCSID("$NetBSD: cat.c,v 1.48 2012/03/17 23:35:28 christos Exp $"); #endif #endif /* not lint */ @@ -295,8 +295,8 @@ raw_cat(int rfd) if (buf == NULL) { struct stat sbuf; - if (fstat(wfd, &sbuf) == 0 && - sbuf.st_blksize > sizeof(fb_buf)) { + if (fstat(wfd, &sbuf) == 0 && sbuf.st_blksize > 0 && + (size_t)sbuf.st_blksize > sizeof(fb_buf)) { bsize = sbuf.st_blksize; buf = malloc(bsize); } diff --git a/include/dirent.h b/include/dirent.h index c4a70b20b..81a860c4a 100644 --- a/include/dirent.h +++ b/include/dirent.h @@ -113,7 +113,7 @@ DIR *__opendir2(const char *, int) __RENAME(__opendir230); int scandir(const char *, struct dirent ***, int (*)(const struct dirent *), int (*)(const void *, const void *)) __RENAME(__scandir30); -ssize_t getdents(int, char *, size_t) __RENAME(__getdents30); +int getdents(int, char *, size_t) __RENAME(__getdents30); int alphasort(const void *, const void *) __RENAME(__alphasort30); #endif #endif /* defined(_NETBSD_SOURCE) */ diff --git a/include/minix/virtio.h b/include/minix/virtio.h index ee40921a6..aec6d4b89 100644 --- a/include/minix/virtio.h +++ b/include/minix/virtio.h @@ -114,12 +114,12 @@ void virtio_irq_disable(struct virtio_device *dev); int virtio_had_irq(struct virtio_device *dev); -u32_t virtio_read32(struct virtio_device *dev, off_t offset); -u16_t virtio_read16(struct virtio_device *dev, off_t offset); -u8_t virtio_read8(struct virtio_device *dev, off_t offset); -void virtio_write32(struct virtio_device *dev, off_t offset, u32_t val); -void virtio_write16(struct virtio_device *dev, off_t offset, u16_t val); -void virtio_write8(struct virtio_device *dev, off_t offset, u8_t val); +u32_t virtio_read32(struct virtio_device *dev, i32_t offset); +u16_t virtio_read16(struct virtio_device *dev, i32_t offset); +u8_t virtio_read8(struct virtio_device *dev, i32_t offset); +void virtio_write32(struct virtio_device *dev, i32_t offset, u32_t val); +void virtio_write16(struct virtio_device *dev, i32_t offset, u16_t val); +void virtio_write8(struct virtio_device *dev, i32_t offset, u8_t val); /* @@ -129,11 +129,11 @@ void virtio_write8(struct virtio_device *dev, off_t offset, u8_t val); * Something like: * read(off) --> readX(20 + (msi ? 4 : 0) + off) */ -u32_t virtio_sread32(struct virtio_device *dev, off_t offset); -u16_t virtio_sread16(struct virtio_device *dev, off_t offset); -u8_t virtio_sread8(struct virtio_device *dev, off_t offset); -void virtio_swrite32(struct virtio_device *dev, off_t offset, u32_t val); -void virtio_swrite16(struct virtio_device *dev, off_t offset, u16_t val); -void virtio_swrite8(struct virtio_device *dev, off_t offset, u8_t val); +u32_t virtio_sread32(struct virtio_device *dev, i32_t offset); +u16_t virtio_sread16(struct virtio_device *dev, i32_t offset); +u8_t virtio_sread8(struct virtio_device *dev, i32_t offset); +void virtio_swrite32(struct virtio_device *dev, i32_t offset, u32_t val); +void virtio_swrite16(struct virtio_device *dev, i32_t offset, u16_t val); +void virtio_swrite8(struct virtio_device *dev, i32_t offset, u8_t val); #endif /* _MINIX_VIRTIO_H */ diff --git a/include/stdlib.h b/include/stdlib.h index 124be16b7..2a13afddc 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -144,6 +144,7 @@ size_t wcstombs(char * __restrict, const wchar_t * __restrict, size_t); int rand_r(unsigned int *); #endif + /* * X/Open Portability Guide >= Issue 4 */ diff --git a/include/unistd.h b/include/unistd.h index c15848b61..0f7c3f487 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -434,5 +434,4 @@ extern char *suboptarg; /* getsubopt(3) external variable */ #endif __END_DECLS - #endif /* !_UNISTD_H_ */ diff --git a/kernel/clock.c b/kernel/clock.c index c371e4dc8..545198b68 100644 --- a/kernel/clock.c +++ b/kernel/clock.c @@ -131,14 +131,15 @@ int timer_int_handler(void) * well. If any of the timers expire, do_clocktick() will send out * signals. */ - if ((p->p_misc_flags & MF_VIRT_TIMER)){ + if ((p->p_misc_flags & MF_VIRT_TIMER) && (p->p_virt_left > 0)) { p->p_virt_left--; } - if ((p->p_misc_flags & MF_PROF_TIMER)){ + if ((p->p_misc_flags & MF_PROF_TIMER) && (p->p_prof_left > 0)) { p->p_prof_left--; } if (! (priv(p)->s_flags & BILLABLE) && - (billp->p_misc_flags & MF_PROF_TIMER)){ + (billp->p_misc_flags & MF_PROF_TIMER) && + (billp->p_prof_left > 0)) { billp->p_prof_left--; } diff --git a/kernel/system/do_vtimer.c b/kernel/system/do_vtimer.c index 790054bc9..47ec2b139 100644 --- a/kernel/system/do_vtimer.c +++ b/kernel/system/do_vtimer.c @@ -53,8 +53,6 @@ int do_vtimer(struct proc * caller, message * m_ptr) /* Retrieve the old value. */ if (rp->p_misc_flags & pt_flag) { old_value = *pt_left; - - if (old_value < 0) old_value = 0; } else { old_value = 0; } @@ -91,14 +89,14 @@ struct proc *rp; /* pointer to the process */ */ /* Check if the virtual timer expired. If so, send a SIGVTALRM signal. */ - if ((rp->p_misc_flags & MF_VIRT_TIMER) && rp->p_virt_left <= 0) { + if ((rp->p_misc_flags & MF_VIRT_TIMER) && rp->p_virt_left == 0) { rp->p_misc_flags &= ~MF_VIRT_TIMER; rp->p_virt_left = 0; cause_sig(rp->p_nr, SIGVTALRM); } /* Check if the profile timer expired. If so, send a SIGPROF signal. */ - if ((rp->p_misc_flags & MF_PROF_TIMER) && rp->p_prof_left <= 0) { + if ((rp->p_misc_flags & MF_PROF_TIMER) && rp->p_prof_left == 0) { rp->p_misc_flags &= ~MF_PROF_TIMER; rp->p_prof_left = 0; cause_sig(rp->p_nr, SIGPROF); diff --git a/lib/libvirtio/virtio.c b/lib/libvirtio/virtio.c index 787987083..c7ae655f9 100644 --- a/lib/libvirtio/virtio.c +++ b/lib/libvirtio/virtio.c @@ -820,7 +820,7 @@ virtio_guest_supports(struct virtio_device *dev, int bit) /* Just some wrappers around sys_read */ #define VIRTIO_READ_XX(xx, suff) \ u##xx##_t \ -virtio_read##xx(struct virtio_device *dev, off_t off) \ +virtio_read##xx(struct virtio_device *dev, i32_t off) \ { \ int r; \ u32_t ret; \ @@ -840,7 +840,7 @@ VIRTIO_READ_XX(8, b) /* Just some wrappers around sys_write */ #define VIRTIO_WRITE_XX(xx, suff) \ void \ -virtio_write##xx(struct virtio_device *dev, off_t off, u##xx##_t val) \ +virtio_write##xx(struct virtio_device *dev, i32_t off, u##xx##_t val) \ { \ int r; \ if ((r = sys_out##suff(dev->port + off, val)) != OK) \ @@ -857,7 +857,7 @@ VIRTIO_WRITE_XX(8, b) /* Just some wrappers around sys_read */ #define VIRTIO_SREAD_XX(xx, suff) \ u##xx##_t \ -virtio_sread##xx(struct virtio_device *dev, off_t off) \ +virtio_sread##xx(struct virtio_device *dev, i32_t off) \ { \ int r; \ u32_t ret; \ @@ -882,7 +882,7 @@ VIRTIO_SREAD_XX(8, b) /* Just some wrappers around sys_write */ #define VIRTIO_SWRITE_XX(xx, suff) \ void \ -virtio_swrite##xx(struct virtio_device *dev, off_t off, u##xx##_t val) \ +virtio_swrite##xx(struct virtio_device *dev, i32_t off, u##xx##_t val) \ { \ int r; \ off += VIRTIO_DEV_SPECIFIC_OFF; \ diff --git a/releasetools/nbsd_ports b/releasetools/nbsd_ports index 008db1107..ae64d6ce9 100644 --- a/releasetools/nbsd_ports +++ b/releasetools/nbsd_ports @@ -6,7 +6,7 @@ # Timestamp in UTC,minixpath,netbsdpath # minixpath: path in Minix source tree (starting from /usr/src/) # netbsdpath: path in BSD source tree (starting from src/) -2012/01/16 18:47:57,bin/cat +2012/10/17 12:00:00,bin/cat 2011/08/27 12:55:09,bin/date 2012/10/17 12:00:00,bin/echo 2012/01/16 18:47:57,bin/ed diff --git a/servers/inet/clock.c b/servers/inet/clock.c index 42e5f6dfd..7c1b37b45 100644 --- a/servers/inet/clock.c +++ b/servers/inet/clock.c @@ -14,8 +14,8 @@ THIS_FILE int clck_call_expire; -static time_t curr_time; -static time_t prev_time; +static clock_t curr_time; +static clock_t prev_time; static timer_t *timer_chain; static time_t next_timeout; @@ -43,7 +43,7 @@ time_t get_time() } void set_time (tim) -time_t tim; +clock_t tim; { if (!curr_time && tim >= prev_time) { @@ -54,7 +54,7 @@ time_t tim; } else if (!curr_time) { - DBLOCK(0x20, printf("set_time: new time %i < prev_time %i\n", + DBLOCK(0x20, printf("set_time: new time %lu < prev_time %lu\n", tim, prev_time)); } } diff --git a/servers/inet/generic/clock.h b/servers/inet/generic/clock.h index f52a51db5..a0f69a0a5 100644 --- a/servers/inet/generic/clock.h +++ b/servers/inet/generic/clock.h @@ -23,7 +23,7 @@ typedef struct timer extern int clck_call_expire; /* Call clck_expire_timer from the mainloop */ void clck_init ARGS(( void )); -void set_time ARGS(( time_t time )); +void set_time ARGS(( clock_t time )); time_t get_time ARGS(( void )); void reset_time ARGS(( void )); /* set a timer to go off at the time specified by timeout */ diff --git a/servers/inet/generic/tcp_send.c b/servers/inet/generic/tcp_send.c index c03a0d9ce..d437d57a5 100644 --- a/servers/inet/generic/tcp_send.c +++ b/servers/inet/generic/tcp_send.c @@ -576,9 +576,10 @@ void tcp_release_retrans( artt= tcp_conn->tc_artt; artt= ((TCP_RTT_SMOOTH-1)*artt+srtt)/TCP_RTT_SMOOTH; - srtt -= artt; - if (srtt < 0) - srtt= -srtt; + if (srtt < artt) + srtt = artt - srtt; + else + srtt -= artt; drtt= tcp_conn->tc_drtt; drtt= ((TCP_RTT_SMOOTH-1)*drtt+srtt)/TCP_RTT_SMOOTH; @@ -603,13 +604,13 @@ void tcp_release_retrans( rtt= TCP_RTT_MAX; } DBLOCK(0x10, printf( - "tcp_release_retrans, conn[%i]: retrans_time= %i ms, rtt = %i ms\n", + "tcp_release_retrans, conn[%i]: retrans_time= %lu ms, rtt = %lu ms\n", tcp_conn-tcp_conn_table, retrans_time*1000/HZ, rtt*1000/HZ)); DBLOCK(0x10, printf( - "tcp_release_retrans: artt= %i -> %i, drtt= %i -> %i\n", + "tcp_release_retrans: artt= %lu -> %lu, drtt= %lu -> %lu\n", tcp_conn->tc_artt, artt, tcp_conn->tc_drtt, drtt)); @@ -864,7 +865,7 @@ struct timer *timer; tcp_conn->tc_ka_snd= tcp_conn->tc_SND_NXT; tcp_conn->tc_ka_rcv= tcp_conn->tc_RCV_NXT; DBLOCK(0x20, printf( -"tcp_send_timeout: conn[%i] setting keepalive timer (+%i ms)\n", +"tcp_send_timeout: conn[%i] setting keepalive timer (+%lu ms)\n", tcp_conn-tcp_conn_table, tcp_conn->tc_ka_time*1000/HZ)); clck_timer(&tcp_conn->tc_transmit_timer, @@ -919,7 +920,7 @@ struct timer *timer; tcp_conn->tc_0wnd_to= 0; DBLOCK(0x20, printf( - "tcp_send_timeout: conn[%i] setting timer to %i ms (+%i ms)\n", + "tcp_send_timeout: conn[%i] setting timer to %lu ms (+%lu ms)\n", tcp_conn-tcp_conn_table, (curr_time+rtt)*1000/HZ, rtt*1000/HZ)); @@ -954,7 +955,7 @@ struct timer *timer; tcp_conn->tc_rt_seq= 0; DBLOCK(0x10, printf( - "tcp_send_timeout: conn[%i] setting timer to %i ms (+%i ms)\n", + "tcp_send_timeout: conn[%i] setting timer to %lu ms (+%lu ms)\n", tcp_conn-tcp_conn_table, (curr_time+tcp_conn->tc_0wnd_to)*1000/HZ, tcp_conn->tc_0wnd_to*1000/HZ)); @@ -974,7 +975,7 @@ struct timer *timer; * probe, which is almost the same. */ - DBLOCK(0x20, printf("tcp_send_timeout: conn[%i] una= %lu, rtt= %ims\n", + DBLOCK(0x20, printf("tcp_send_timeout: conn[%i] una= %lu, rtt= %lu ms\n", tcp_conn-tcp_conn_table, (unsigned long)tcp_conn->tc_SND_UNA, rtt*1000/HZ)); @@ -1030,7 +1031,7 @@ struct timer *timer; timeout += curr_time; DBLOCK(0x20, printf( - "tcp_send_timeout: conn[%i] setting timer to %i ms (+%i ms)\n", + "tcp_send_timeout: conn[%i] setting timer to %lu ms (+%lu ms)\n", tcp_conn-tcp_conn_table, timeout*1000/HZ, (timeout-curr_time)*1000/HZ)); @@ -1285,7 +1286,7 @@ tcp_conn_t *tcp_conn; rtt= tcp_conn->tc_rtt; DBLOCK(0x20, printf( - "tcp_set_send_timer: conn[%i] setting timer to %i ms (+%i ms)\n", + "tcp_set_send_timer: conn[%i] setting timer to %lu ms (+%lu ms)\n", tcp_conn-tcp_conn_table, (curr_time+rtt)*1000/HZ, rtt*1000/HZ)); diff --git a/servers/is/dmp_kernel.c b/servers/is/dmp_kernel.c index ff9d53b6c..e8ed5b6f1 100644 --- a/servers/is/dmp_kernel.c +++ b/servers/is/dmp_kernel.c @@ -330,7 +330,7 @@ void proctab_dmp(void) PROCLOOP(rp, oldrp) printf(" %5d %10d ", _ENDPOINT_G(rp->p_endpoint), rp->p_endpoint); - printf("%-8.8s %5u %5u %6u %6u ", + printf("%-8.8s %5u %5u %6lu %6lu ", rp->p_name, rp->p_priority, rp->p_quantum_size_ms, diff --git a/servers/is/dmp_pm.c b/servers/is/dmp_pm.c index 9be20a054..7dfe1d3d3 100644 --- a/servers/is/dmp_pm.c +++ b/servers/is/dmp_pm.c @@ -95,7 +95,7 @@ void sigaction_dmp() printf(" %08lx %08lx %08lx ", mp->mp_ignore, mp->mp_catch, mp->mp_sigmask); printf("%08lx ", mp->mp_sigpending); - if (mp->mp_flags & ALARM_ON) printf("%8d", mp->mp_timer.tmr_exp_time-uptime); + if (mp->mp_flags & ALARM_ON) printf("%8lu", mp->mp_timer.tmr_exp_time-uptime); else printf(" -"); printf("\n"); } diff --git a/servers/is/dmp_rs.c b/servers/is/dmp_rs.c index 9fcdbee96..be6652834 100644 --- a/servers/is/dmp_rs.c +++ b/servers/is/dmp_rs.c @@ -42,7 +42,7 @@ void rproc_dmp() rpub = &rprocpub[i]; if (! (rp->r_flags & RS_IN_USE)) continue; if (++n > 22) break; - printf("%13s %9d %5d %6s %3d/%1d %3ld %8d %5dx %s", + printf("%13s %9d %5d %6s %3d/%1d %3ld %8lu %5dx %s", rpub->label, rpub->endpoint, rp->r_pid, s_flags_str(rp->r_flags, rpub->sys_flags), rpub->dev_nr, rpub->dev_style, rp->r_period, rp->r_alive_tm, rp->r_restarts, diff --git a/servers/pm/alarm.c b/servers/pm/alarm.c index c0a5fa0ce..177304401 100644 --- a/servers/pm/alarm.c +++ b/servers/pm/alarm.c @@ -17,7 +17,7 @@ #include "mproc.h" #include "param.h" -#define US 1000000 /* shortcut for microseconds per second */ +#define US 1000000UL /* shortcut for microseconds per second */ static clock_t ticks_from_timeval(struct timeval *tv); static void timeval_from_ticks(struct timeval *tv, clock_t ticks); @@ -53,15 +53,14 @@ struct timeval *tv; /* In any case, the following conversion must always round up. */ - ticks = (clock_t) (system_hz * (unsigned long) tv->tv_sec); - if ( (unsigned long) ticks / system_hz != (unsigned long) tv->tv_sec) { + ticks = system_hz * (unsigned long) tv->tv_sec; + if ( (ticks / system_hz) != (unsigned long)tv->tv_sec) { ticks = LONG_MAX; } else { - ticks += (clock_t) - ((system_hz * (unsigned long) tv->tv_usec + (US-1)) / US); + ticks += ((system_hz * (unsigned long)tv->tv_usec + (US-1)) / US); } - if (ticks < 0) ticks = LONG_MAX; + if (ticks > LONG_MAX) ticks = LONG_MAX; return(ticks); } diff --git a/servers/rs/exec.c b/servers/rs/exec.c index 865b3142c..942b30fe2 100644 --- a/servers/rs/exec.c +++ b/servers/rs/exec.c @@ -206,7 +206,7 @@ size_t seg_bytes /* how much is to be transferred? */ if (off+seg_bytes > execi->hdr_len) return ENOEXEC; if((r= sys_vircopy(SELF, ((vir_bytes)execi->hdr)+off, execi->proc_e, seg_addr, seg_bytes)) != OK) { - printf("RS: exec read_seg: copy 0x%x bytes into %i at 0x%08x failed: %i\n", + printf("RS: exec read_seg: copy 0x%x bytes into %i at 0x%08lx failed: %i\n", seg_bytes, execi->proc_e, seg_addr, r); } return r; diff --git a/sys/arch/arm/include/ansi.h b/sys/arch/arm/include/ansi.h index 3aae6ae64..d76b6a049 100644 --- a/sys/arch/arm/include/ansi.h +++ b/sys/arch/arm/include/ansi.h @@ -49,15 +49,18 @@ * #undef _BSD_SIZE_T_ * #endif */ -#define _BSD_CLOCK_T_ int /* clock() */ -#define _BSD_PTRDIFF_T_ int /* ptr1 - ptr2 */ -#define _BSD_SIZE_T_ unsigned int /* sizeof() */ +#define _BSD_CLOCK_T_ unsigned int /* clock() */ +#define _BSD_PTRDIFF_T_ int /* ptr1 - ptr2 */ +#define _BSD_SIZE_T_ unsigned int /* sizeof() */ #define _BSD_SSIZE_T_ int /* byte count or error */ #define _BSD_TIME_T_ int /* time() */ #define _BSD_CLOCKID_T_ int /* clockid_t */ +#if !defined(__minix) +/* Conflict with minix timer_t struct. */ #define _BSD_TIMER_T_ int /* timer_t */ +#endif /* !defined(__minix) */ #define _BSD_SUSECONDS_T_ int /* suseconds_t */ -#define _BSD_USECONDS_T_ int /* useconds_t */ +#define _BSD_USECONDS_T_ unsigned int /* useconds_t */ #define _BSD_WCHAR_T_ int /* wchar_t */ #define _BSD_WINT_T_ int /* wint_t */ diff --git a/sys/arch/i386/include/ansi.h b/sys/arch/i386/include/ansi.h index cbcaaa186..4f5e2ecc8 100644 --- a/sys/arch/i386/include/ansi.h +++ b/sys/arch/i386/include/ansi.h @@ -49,15 +49,18 @@ * #undef _BSD_SIZE_T_ * #endif */ -#define _BSD_CLOCK_T_ int /* clock() */ -#define _BSD_PTRDIFF_T_ int /* ptr1 - ptr2 */ -#define _BSD_SIZE_T_ unsigned int /* sizeof() */ +#define _BSD_CLOCK_T_ unsigned long /* clock() */ +#define _BSD_PTRDIFF_T_ int /* ptr1 - ptr2 */ +#define _BSD_SIZE_T_ unsigned int /* sizeof() */ #define _BSD_SSIZE_T_ int /* byte count or error */ #define _BSD_TIME_T_ int /* time() */ #define _BSD_CLOCKID_T_ int /* clockid_t */ +#if !defined(__minix) +/* Conflict with minix timer_t struct. */ #define _BSD_TIMER_T_ int /* timer_t */ +#endif /* !defined(__minix) */ #define _BSD_SUSECONDS_T_ int /* suseconds_t */ -#define _BSD_USECONDS_T_ int /* useconds_t */ +#define _BSD_USECONDS_T_ unsigned int /* useconds_t */ #define _BSD_WCHAR_T_ int /* wchar_t */ #define _BSD_WINT_T_ int /* wint_t */ diff --git a/sys/arch/i386/include/asm.h b/sys/arch/i386/include/asm.h index 1b4c91de2..805e20fa8 100644 --- a/sys/arch/i386/include/asm.h +++ b/sys/arch/i386/include/asm.h @@ -1,4 +1,4 @@ -/* $NetBSD: asm.h,v 1.39 2010/12/20 21:11:24 joerg Exp $ */ +/* $NetBSD: asm.h,v 1.40 2011/06/16 13:16:20 joerg Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -85,7 +85,7 @@ /* let kernels and others override entrypoint alignment */ #if !defined(_ALIGN_TEXT) && !defined(_KERNEL) # ifdef _STANDALONE -# define _ALIGN_TEXT .align 4 +# define _ALIGN_TEXT .align 1 # elif defined __ELF__ # define _ALIGN_TEXT .align 16 # else diff --git a/sys/sys/ansi.h b/sys/sys/ansi.h index 50909a83c..ae26ef404 100644 --- a/sys/sys/ansi.h +++ b/sys/sys/ansi.h @@ -42,7 +42,7 @@ typedef __uint32_t __mode_t; /* file permissions */ typedef __int64_t __off_t; /* file offset */ typedef __int32_t __pid_t; /* process id */ typedef __uint8_t __sa_family_t; /* socket address family */ -typedef __int32_t __socklen_t; /* socket-related datum length */ +typedef __uint32_t __socklen_t; /* socket-related datum length */ typedef __uint32_t __uid_t; /* user id */ typedef __uint32_t __fsblkcnt_t; /* fs block count (statvfs) */ typedef __uint32_t __fsfilcnt_t; /* fs file count */ diff --git a/sys/sys/disklabel_gpt.h b/sys/sys/disklabel_gpt.h index d72d457b0..e3aa8c3de 100644 --- a/sys/sys/disklabel_gpt.h +++ b/sys/sys/disklabel_gpt.h @@ -127,13 +127,6 @@ struct gpt_ent { {0x516e7cb6,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}} #define GPT_ENT_TYPE_FREEBSD_VINUM \ {0x516e7cb8,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}} -#ifdef __minix -/* LSC These are not present in NetBSD header */ -#define GPT_ENT_TYPE_FREEBSD_ZFS \ - {0x516e7cba,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}} -#define GPT_ENT_TYPE_FREEBSD_BOOT \ - {0x83bd6b9d,0x7f41,0x11dc,0xbe,0x0b,{0x00,0x15,0x60,0xb8,0x4f,0x0f}} -#endif /* * The following are unused but documented here to avoid reuse. * @@ -163,8 +156,10 @@ struct gpt_ent { #define GPT_ENT_TYPE_APPLE_UFS \ {0x55465300,0x0000,0x11aa,0xaa,0x11,{0x00,0x30,0x65,0x43,0xec,0xac}} +#if defined(__minix) #define GPT_ENT_TYPE_MINIX_MFS \ {0xb7aadf00,0xde27,0x11ca,0xa5,0x74,{0x56,0x72,0x69,0x6a,0x65,0x55}} +#endif /* defined(__minix) */ /* * Used by GRUB 2. diff --git a/sys/sys/fd_set.h b/sys/sys/fd_set.h index 9bfd9c413..0fca18e88 100644 --- a/sys/sys/fd_set.h +++ b/sys/sys/fd_set.h @@ -1,4 +1,4 @@ -/* $NetBSD: fd_set.h,v 1.2 2005/12/11 12:25:20 christos Exp $ */ +/* $NetBSD: fd_set.h,v 1.5 2010/07/08 18:56:17 rmind Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -36,48 +36,53 @@ #include #include -#include #include /* - * Implementation dependent defines, hidden from user space. X/Open does not - * specify them. + * Implementation dependent defines, hidden from user space. + * POSIX does not specify them. */ -#define __NBBY 8 /* number of bits in a byte */ -typedef __int32_t __fd_mask; -/* bits per mask */ -#define __NFDBITS ((unsigned int)sizeof(__fd_mask) * __NBBY) +typedef __uint32_t __fd_mask; -#define __howmany(x, y) (((x) + ((y) - 1)) / (y)) +/* 32 = 2 ^ 5 */ +#define __NFDBITS (32) +#define __NFDSHIFT (5) +#define __NFDMASK (__NFDBITS - 1) /* - * Select uses bit masks of file descriptors in longs. These macros - * manipulate such bit fields (the filesystem macros use chars). - * FD_SETSIZE may be defined by the user, but the default here should - * be enough for most uses. + * Select uses bit fields of file descriptors. These macros manipulate + * such bit fields. Note: FD_SETSIZE may be defined by the user. */ + #ifndef FD_SETSIZE +#ifdef __minix +#include #define FD_SETSIZE __MINIX_OPEN_MAX +#else +#define FD_SETSIZE 256 +#endif #endif +#define __NFD_SIZE (((FD_SETSIZE) + (__NFDBITS - 1)) / __NFDBITS) + typedef struct fd_set { - __fd_mask fds_bits[__howmany(FD_SETSIZE, __NFDBITS)]; + __fd_mask fds_bits[__NFD_SIZE]; } fd_set; #define FD_SET(n, p) \ - ((p)->fds_bits[(n)/__NFDBITS] |= (1 << ((n) % __NFDBITS))) + ((p)->fds_bits[(unsigned)(n) >> __NFDSHIFT] |= (1 << ((n) & __NFDMASK))) #define FD_CLR(n, p) \ - ((p)->fds_bits[(n)/__NFDBITS] &= ~(1 << ((n) % __NFDBITS))) + ((p)->fds_bits[(unsigned)(n) >> __NFDSHIFT] &= ~(1 << ((n) & __NFDMASK))) #define FD_ISSET(n, p) \ - ((p)->fds_bits[(n)/__NFDBITS] & (1 << ((n) % __NFDBITS))) + ((p)->fds_bits[(unsigned)(n) >> __NFDSHIFT] & (1 << ((n) & __NFDMASK))) #if __GNUC_PREREQ__(2, 95) #define FD_ZERO(p) (void)__builtin_memset((p), 0, sizeof(*(p))) #else #define FD_ZERO(p) do { \ fd_set *__fds = (p); \ unsigned int __i; \ - for (__i = 0; __i < __howmany(FD_SETSIZE, __NFDBITS); __i++) \ + for (__i = 0; __i < __NFD_SIZE; __i++) \ __fds->fds_bits[__i] = 0; \ } while (/* CONSTCOND */ 0) #endif /* GCC 2.95 */ @@ -87,11 +92,8 @@ typedef struct fd_set { */ #if defined(_NETBSD_SOURCE) -#define fd_mask __fd_mask -#define NFDBITS __NFDBITS -#ifndef howmany -#define howmany(a, b) __howmany(a, b) -#endif +#define fd_mask __fd_mask +#define NFDBITS __NFDBITS #if __GNUC_PREREQ__(2, 95) #define FD_COPY(f, t) (void)__builtin_memcpy((t), (f), sizeof(*(f))) @@ -99,7 +101,7 @@ typedef struct fd_set { #define FD_COPY(f, t) do { \ fd_set *__f = (f), *__t = (t); \ unsigned int __i; \ - for (__i = 0; __i < __howmany(FD_SETSIZE, __NFDBITS); __i++) \ + for (__i = 0; __i < __NFD_SIZE; __i++) \ __t->fds_bits[__i] = __f->fds_bits[__i]; \ } while (/* CONSTCOND */ 0) #endif /* GCC 2.95 */ diff --git a/sys/sys/file.h b/sys/sys/file.h index 96a0cfac4..44de43222 100644 --- a/sys/sys/file.h +++ b/sys/sys/file.h @@ -1,4 +1,4 @@ -/* $NetBSD: file.h,v 1.71 2009/12/24 19:01:12 elad Exp $ */ +/* $NetBSD: file.h,v 1.74 2011/04/24 18:46:24 rmind Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -67,7 +67,6 @@ #include #ifdef _KERNEL -#include #include #include #include @@ -109,15 +108,6 @@ struct file { kmutex_t f_lock; /* lock on structure */ int f_flag; /* see fcntl.h */ u_int f_marker; /* traversal marker (sysctl) */ -#define DTYPE_VNODE 1 /* file */ -#define DTYPE_SOCKET 2 /* communications endpoint */ -#define DTYPE_PIPE 3 /* pipe */ -#define DTYPE_KQUEUE 4 /* event queue */ -#define DTYPE_MISC 5 /* misc file descriptor type */ -#define DTYPE_CRYPTO 6 /* crypto */ -#define DTYPE_MQUEUE 7 /* message queue */ -#define DTYPE_NAMES \ - "0", "file", "socket", "pipe", "kqueue", "misc", "crypto", "mqueue" u_int f_type; /* descriptor type */ u_int f_advice; /* access pattern hint; UVM_ADV_* */ u_int f_count; /* reference count */ @@ -126,6 +116,23 @@ struct file { SLIST_ENTRY(file) f_unplist; /* deferred close: see uipc_usrreq.c */ }; +/* + * Descriptor types. + */ + +#define DTYPE_VNODE 1 /* file */ +#define DTYPE_SOCKET 2 /* communications endpoint */ +#define DTYPE_PIPE 3 /* pipe */ +#define DTYPE_KQUEUE 4 /* event queue */ +#define DTYPE_MISC 5 /* misc file descriptor type */ +#define DTYPE_CRYPTO 6 /* crypto */ +#define DTYPE_MQUEUE 7 /* message queue */ +#define DTYPE_SEM 8 /* semaphore */ + +#define DTYPE_NAMES \ + "0", "file", "socket", "pipe", "kqueue", "misc", "crypto", "mqueue", \ + "semaphore" + /* * Flags for fo_read and fo_write and do_fileread/write/v */ @@ -135,7 +142,6 @@ struct file { LIST_HEAD(filelist, file); extern struct filelist filehead; /* head of list of open files */ extern u_int maxfiles; /* kernel limit on # of open files */ -extern u_int nfiles; /* actual number of open files */ extern const struct fileops vnops; /* vnode operations for files */ diff --git a/sys/sys/time.h b/sys/sys/time.h index 7bbaf095a..bfb2a89bc 100644 --- a/sys/sys/time.h +++ b/sys/sys/time.h @@ -249,12 +249,11 @@ struct itimerspec { }; #define CLOCK_REALTIME 0 -#define CLOCK_MONOTONIC 3 - #ifndef __minix #define CLOCK_VIRTUAL 1 #define CLOCK_PROF 2 #endif +#define CLOCK_MONOTONIC 3 #if defined(_NETBSD_SOURCE) #define TIMER_RELTIME 0x0 /* relative timer */ diff --git a/sys/sys/types.h b/sys/sys/types.h index b6df6ee85..a62c541d0 100644 --- a/sys/sys/types.h +++ b/sys/sys/types.h @@ -122,16 +122,6 @@ typedef uint32_t bit_t; /* bit number in a bit map */ typedef uint16_t zone1_t; /* zone number for V1 file systems */ typedef uint32_t bitchunk_t; /* collection of bits in a bitmap */ #endif - -/* ANSI C makes writing down the promotion of unsigned types very messy. When - * sizeof(short) == sizeof(int), there is no promotion, so the type stays - * unsigned. When the compiler is not ANSI, there is usually no loss of - * unsignedness, and there are usually no prototypes so the promoted type - * doesn't matter. The use of types like Ino_t is an attempt to use ints - * (which are not promoted) while providing information to the reader. - */ - -typedef unsigned long Ino_t; #endif /* __minix */ #include @@ -166,7 +156,7 @@ typedef int64_t longlong_t; /* for XDR */ typedef uint64_t u_longlong_t; /* for XDR */ typedef int64_t blkcnt_t; /* fs block count */ -typedef uint32_t blksize_t; /* fs optimal block size */ +typedef int32_t blksize_t; /* fs optimal block size */ #ifndef fsblkcnt_t typedef __fsblkcnt_t fsblkcnt_t; /* fs block count (statvfs) */ @@ -223,7 +213,7 @@ typedef __pid_t pid_t; /* process id */ #define pid_t __pid_t #endif typedef int32_t lwpid_t; /* LWP id */ -typedef uint32_t rlim_t; /* resource limit */ +typedef uint64_t rlim_t; /* resource limit */ typedef int32_t segsz_t; /* segment size */ typedef int32_t swblk_t; /* swap offset */ @@ -335,6 +325,7 @@ typedef _BSD_CLOCKID_T_ clockid_t; #endif #ifndef __minix +/* LSC: timer_t is defined as a struct on minix. */ #ifdef _BSD_TIMER_T_ typedef _BSD_TIMER_T_ timer_t; #undef _BSD_TIMER_T_ diff --git a/test/test2.c b/test/test2.c index dd63e4d16..8afbb7eba 100644 --- a/test/test2.c +++ b/test/test2.c @@ -343,12 +343,8 @@ void test2g() /* Now times(). */ t4 = times(&tmsbuf); - if ( t4 == (clock_t) -1) e(6); + if (t4 == (clock_t) -1) e(6); if (t4 - t3 < clocks_per_sec) e(7); - if (tmsbuf.tms_utime < 0) e(8); - if (tmsbuf.tms_stime < 0) e(9); - if (tmsbuf.tms_cutime < 0) e(10); - if (tmsbuf.tms_cstime < 0) e(11); } void sigpip(s)