今天想开始一个工程,分析NETBSD,工程比我想像的浩大,希望能在n个月内完成。

NetBSD是一个免费的,具有高度移植性的 UNIX-like 操作系统,是现行可移植平台最多的操作系统,可以在许多平台上执行,从 64bit alpha 服务器到手持设备和嵌入式设备。NetBSD计划的口号是:"Of course it runs NetBSD"。它设计简洁,代码规范,拥有众多先进特性,使得它在业界和学术界广受好评。由于简洁的设计和先进的特征,使得它在生产和研究方面,都有卓越的表现,而且它也有受使用者支持的完整的源代码。许多程序都可以很容易地通过NetBSD Packages Collection获得。

本博客所有内容是原创,如果转载请注明来源

http://blog.csdn.net/myhaspl/

下面开始吧~

src/sys/sys/time.h

/*    $NetBSD: time.h,v 1.65 2011/10/27 16:12:52 christos Exp $    */

/*
 * Copyright (c) 1982, 1986, 1993
 *    The Regents of the University of California.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *    @(#)time.h    8.5 (Berkeley) 5/4/95
 */

定义系统时间的头文件,看来这个time.h是关于时间格式等操作的系统头文件。
#ifndef _SYS_TIME_H_
#define    _SYS_TIME_H_

#include <sys/featuretest.h>
#include <sys/types.h>

/*
 * Structure returned by gettimeofday(2) system call,
 * and used in other calls.
 */
struct timeval {
    time_t        tv_sec;        /* seconds */
    suseconds_t    tv_usec;    /* and microseconds */
};

/*
 * Structure defined by POSIX.1b to be like a timeval.
 */
struct timespec {
    time_t    tv_sec;        /* seconds */
    long    tv_nsec;    /* and nanoseconds */
};

来看看types.h

/*    $NetBSD: types.h,v 1.88 2011/01/14 02:06:34 rmind Exp $    */

/*-
 * Copyright (c) 1982, 1986, 1991, 1993, 1994
 *    The Regents of the University of California.  All rights reserved.
 * (c) UNIX System Laboratories, Inc.
 * All or some portions of this file are derived from material licensed
 * to the University of California by American Telephone and Telegraph
 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
 * the permission of UNIX System Laboratories, Inc.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *    @(#)types.h    8.4 (Berkeley) 1/21/94
 */

#ifndef _SYS_TYPES_H_
#define    _SYS_TYPES_H_

#include <sys/featuretest.h>

/* Machine type dependent parameters. */
#include <machine/types.h>

#include <machine/ansi.h>
#include <machine/int_types.h>

#include <sys/ansi.h>

#ifndef    int8_t
typedef    __int8_t    int8_t;
#define    int8_t        __int8_t
#endif

#ifndef    uint8_t
typedef    __uint8_t    uint8_t;
#define    uint8_t        __uint8_t
#endif

#ifndef    int16_t
typedef    __int16_t    int16_t;
#define    int16_t        __int16_t
#endif

#ifndef    uint16_t
typedef    __uint16_t    uint16_t;
#define    uint16_t    __uint16_t
#endif

#ifndef    int32_t
typedef    __int32_t    int32_t;
#define    int32_t        __int32_t
#endif

#ifndef    uint32_t
typedef    __uint32_t    uint32_t;
#define    uint32_t    __uint32_t
#endif

#ifndef    int64_t
typedef    __int64_t    int64_t;
#define    int64_t        __int64_t
#endif

#ifndef    uint64_t
typedef    __uint64_t    uint64_t;
#define    uint64_t    __uint64_t
#endif

typedef    uint8_t        u_int8_t;
typedef    uint16_t    u_int16_t;
typedef    uint32_t    u_int32_t;
typedef    uint64_t    u_int64_t;
是对变量类型的别名的定义,可能是为了方便移植,有趣的是还定义了bool类型

#if defined(_KERNEL) || defined(_STANDALONE)
/*
 * Boolean type definitions for the kernel environment.  User-space
 * boolean definitions are found in <stdbool.h>.
 */
#define bool    _Bool
#define true    1
#define false    0

/*
 * Deprecated Mach-style boolean_t type.  Should not be used by new code.
 */
typedef int    boolean_t;
#ifndef TRUE
#define    TRUE    1
#endif
#ifndef FALSE
#define    FALSE    0
#endif

对很多内核中的地址以及设备号的C类型以及格式,比如其内存表示,typedef    uint64_t    dev_t;   typedef    int64_t        daddr_t; 
具体如下:

#if !defined(_KERNEL) && !defined(_STANDALONE)
/* We don't and shouldn't use caddr_t in the kernel anymore */
#ifndef    caddr_t
typedef    __caddr_t    caddr_t;    /* core address */
#define    caddr_t        __caddr_t
#endif
#endif

#ifdef __daddr_t
typedef    __daddr_t    daddr_t;    /* disk address */
#undef __daddr_t
#else
typedef    int64_t        daddr_t;    /* disk address */
#endif

typedef    uint64_t    dev_t;        /* device number */
typedef    uint32_t    fixpt_t;    /* fixed point number */

netbsd源码分析(1)相关推荐

  1. aircrack-ng 介绍、功能测试及部分源码分析

    aircrack-ng 介绍.功能测试及部分源码分析 [实验目的] 1.理清aircrack-ng的总体设计框架,包括各模块的功能与联系: 2.核心模块的实现原理(aircrack-ng.airepl ...

  2. 【Golang源码分析】Go Web常用程序包gorilla/mux的使用与源码简析

    目录[阅读时间:约10分钟] 一.概述 二.对比: gorilla/mux与net/http DefaultServeMux 三.简单使用 四.源码简析 1.NewRouter函数 2.HandleF ...

  3. SpringBoot-web开发(四): SpringMVC的拓展、接管(源码分析)

    [SpringBoot-web系列]前文: SpringBoot-web开发(一): 静态资源的导入(源码分析) SpringBoot-web开发(二): 页面和图标定制(源码分析) SpringBo ...

  4. SpringBoot-web开发(二): 页面和图标定制(源码分析)

    [SpringBoot-web系列]前文: SpringBoot-web开发(一): 静态资源的导入(源码分析) 目录 一.首页 1. 源码分析 2. 访问首页测试 二.动态页面 1. 动态资源目录t ...

  5. SpringBoot-web开发(一): 静态资源的导入(源码分析)

    目录 方式一:通过WebJars 1. 什么是webjars? 2. webjars的使用 3. webjars结构 4. 解析源码 5. 测试访问 方式二:放入静态资源目录 1. 源码分析 2. 测 ...

  6. Yolov3Yolov4网络结构与源码分析

    Yolov3&Yolov4网络结构与源码分析 从2018年Yolov3年提出的两年后,在原作者声名放弃更新Yolo算法后,俄罗斯的Alexey大神扛起了Yolov4的大旗. 文章目录 论文汇总 ...

  7. ViewGroup的Touch事件分发(源码分析)

    Android中Touch事件的分发又分为View和ViewGroup的事件分发,View的touch事件分发相对比较简单,可参考 View的Touch事件分发(一.初步了解) View的Touch事 ...

  8. View的Touch事件分发(二.源码分析)

    Android中Touch事件的分发又分为View和ViewGroup的事件分发,先来看简单的View的touch事件分发. 主要分析View的dispatchTouchEvent()方法和onTou ...

  9. MyBatis原理分析之四:一次SQL查询的源码分析

    上回我们讲到Mybatis加载相关的配置文件进行初始化,这回我们讲一下一次SQL查询怎么进行的. 准备工作 Mybatis完成一次SQL查询需要使用的代码如下: Java代码   String res ...

最新文章

  1. java 传入参数_java参数怎么传递参数
  2. python 继承和多态
  3. 屠榜CV还不是这篇论文的终极目标,它更大的目标其实是……
  4. c语言 printf_C语言(4) 屏幕输出指令printf
  5. 无意中发现Markdown,最终解放了我
  6. Spring写第一个程序HelloSpring
  7. BI在企业数字化转型中的价值
  8. python输出被五整除的数_python中给定一系列正整数能被5整除的数字中所有偶数的和?...
  9. Python学习教程(Python学习路线):Python3你还未get到的隐藏技能
  10. CentOS7.5下KVM虚拟机安装
  11. Windows错误“ 0xc0000005”
  12. 编写程序,在屏幕输出“Hello,World!“的字符串
  13. SAP ABAP CDS view Association 引入的缘由
  14. latex 参考文献没有显示_LaTeX 参考文献的处理
  15. 紧急提醒!黑客正利用假 ChatGPT 来推送恶意软件
  16. 计算机怎么格式化硬盘,电脑怎么格式化硬盘
  17. 如何提高条形码识别率
  18. Moran_DeepLPF_Deep_Local_Parametric_Filters_for_Image_Enhancement_CVPR_2020_paper
  19. Day 11. Evidence for a mental health crisis in graduate education
  20. 抖音超级火的评测小程序独立源码内附详细教程文本

热门文章

  1. 网购代下单 省钱新主张
  2. 2021高考河南正阳成绩查询,驻马店教育网2021正阳中考成绩查询系统入口
  3. Failed to get nestedarchive for entry BOOT-INF/lib/jackson
  4. 1、Latex学习笔记之基础入门篇
  5. 【转载】【非常好】MTK 电池流程.c
  6. 2019新版UI设计视频教程(学习路线+课程大纲+学习工具+面试题)
  7. 牛客小白月赛16 J-小雨坐地铁(分层图最短路)
  8. 洛谷 P1873 [COCI 2011/2012 #5] EKO / 砍树 二分
  9. 暴风看电影出现倒影 Vista故意不兼容?
  10. java 多线程开发