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
This commit is contained in:
Lionel Sambuc 2013-04-16 11:48:54 +02:00
parent e8e506f2a0
commit 744378194d
28 changed files with 130 additions and 133 deletions

View file

@ -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

View file

@ -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);
}

View file

@ -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) */

View file

@ -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 */

View file

@ -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
*/

View file

@ -434,5 +434,4 @@ extern char *suboptarg; /* getsubopt(3) external variable */
#endif
__END_DECLS
#endif /* !_UNISTD_H_ */

View file

@ -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--;
}

View file

@ -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);

View file

@ -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; \

View file

@ -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

View file

@ -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));
}
}

View file

@ -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 */

View file

@ -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));

View file

@ -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,

View file

@ -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");
}

View file

@ -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,

View file

@ -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);
}

View file

@ -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;

View file

@ -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 */

View file

@ -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 */

View file

@ -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

View file

@ -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 */

View file

@ -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.

View file

@ -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 <sys/cdefs.h>
#include <sys/featuretest.h>
#include <sys/syslimits.h>
#include <machine/int_types.h>
/*
* 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 <sys/syslimits.h>
#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 */

View file

@ -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 <sys/unistd.h>
#ifdef _KERNEL
#include <sys/mallocvar.h>
#include <sys/queue.h>
#include <sys/mutex.h>
#include <sys/condvar.h>
@ -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 */

View file

@ -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 */

View file

@ -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 <machine/endian.h>
@ -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_

View file

@ -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)