clock.h revision 93835
193835Stmm/*- 293835Stmm * Copyright (c) 1996 The NetBSD Foundation, Inc. 393835Stmm * All rights reserved. 493835Stmm * 593835Stmm * This code is derived from software contributed to The NetBSD Foundation 693835Stmm * by Gordon W. Ross 793835Stmm * 893835Stmm * Redistribution and use in source and binary forms, with or without 993835Stmm * modification, are permitted provided that the following conditions 1093835Stmm * are met: 1193835Stmm * 1. Redistributions of source code must retain the above copyright 1293835Stmm * notice, this list of conditions and the following disclaimer. 1393835Stmm * 2. Redistributions in binary form must reproduce the above copyright 1493835Stmm * notice, this list of conditions and the following disclaimer in the 1593835Stmm * documentation and/or other materials provided with the distribution. 1693835Stmm * 3. All advertising materials mentioning features or use of this software 1793835Stmm * must display the following acknowledgement: 1893835Stmm * This product includes software developed by the NetBSD 1993835Stmm * Foundation, Inc. and its contributors. 2093835Stmm * 4. Neither the name of The NetBSD Foundation nor the names of its 2193835Stmm * contributors may be used to endorse or promote products derived 2293835Stmm * from this software without specific prior written permission. 2393835Stmm * 2493835Stmm * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 2593835Stmm * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 2693835Stmm * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2793835Stmm * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 2893835Stmm * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2993835Stmm * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 3093835Stmm * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 3193835Stmm * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 3293835Stmm * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 3393835Stmm * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 3493835Stmm * POSSIBILITY OF SUCH DAMAGE. 3593835Stmm * 3693835Stmm * $NetBSD: clock_subr.h,v 1.7 2000/10/03 13:41:07 tsutsui Exp $ 3793835Stmm * 3893835Stmm * $FreeBSD: head/sys/sys/clock.h 93835 2002-04-04 23:39:10Z tmm $ 3993835Stmm */ 4093835Stmm 4193835Stmm#ifndef _SYS_CLOCK_H_ 4293835Stmm#define _SYS_CLOCK_H_ 4393835Stmm 4493835Stmm/* 4593835Stmm * Structure to hold the values typically reported by time-of-day clocks. 4693835Stmm * This can be passed to the generic conversion functions to be converted 4793835Stmm * to a struct timespec. 4893835Stmm */ 4993835Stmmstruct clocktime { 5093835Stmm int year; /* year - 1900 */ 5193835Stmm int mon; /* month (1 - 12) */ 5293835Stmm int day; /* day (1 - 31) */ 5393835Stmm int hour; /* hour (0 - 23) */ 5493835Stmm int min; /* minute (0 - 59) */ 5593835Stmm int sec; /* second (0 - 59) */ 5693835Stmm int dow; /* day of week (0 - 6; 0 = Sunday) */ 5793835Stmm long nsec; /* nano seconds */ 5893835Stmm}; 5993835Stmm 6093835Stmmint clock_ct_to_ts(struct clocktime *, struct timespec *); 6193835Stmmvoid clock_ts_to_ct(struct timespec *, struct clocktime *); 6293835Stmmvoid clock_register(device_t, long); 6393835Stmm 6493835Stmm/* 6593835Stmm * BCD to decimal and decimal to BCD. 6693835Stmm */ 6793835Stmm#define FROMBCD(x) (((x) >> 4) * 10 + ((x) & 0xf)) 6893835Stmm#define TOBCD(x) (((x) / 10 * 16) + ((x) % 10)) 6993835Stmm 7093835Stmm/* Some handy constants. */ 7193835Stmm#define SECDAY (24 * 60 * 60) 7293835Stmm#define SECYR (SECDAY * 365) 7393835Stmm 7493835Stmm/* Traditional POSIX base year */ 7593835Stmm#define POSIX_BASE_YEAR 1970 7693835Stmm 7793835Stmm#endif /* !_SYS_CLOCK_H_ */ 78