• 大小: 10.92MB
    文件类型: .zip
    金币: 2
    下载: 1 次
    发布日期: 2023-10-05
  • 语言: 其他
  • 标签: geekos  project4  

资源简介

geekos项目实现,project0,project1,project2,project3,project4

资源截图

代码片段和文件信息

/*
 * This code was originally part of klibc-0.103.
 * It was adapted by David Hovemeyer 
 * for use in GeekOS (http://geekos.sourceforge.net).
 *
 * For information/source for klibc visit
 *   http://www.kernel.org/pub/linux/libs/klibc/
 *   http://www.zytor.com/mailman/listinfo/klibc/
 *   http://www.zytor.com/cvsweb.cgi/klibc/
 *
 * Modifications are marked with “DHH“.
 * Summary of modifications:
 *
 * 1. Use struct Output_Sink to emit formatted output rather than a
 *    character buffer to allow output polymorphism.
 *
 * 2. Buffer generated numbers so that all output is generated in order.
 *
 * 3. Don‘t use long long types: unsigned long is largest
 *    supported type.  Arithmetic on 64 bit types requires runtime support
 *    (at least on x86).
 *
 * See the file LICENSE-klibc for license information.
 */

/*
 * vsnprintf.c
 *
 * vsnprintf() from which the rest of the printf()
 * family is built
 */

#include 
#include 
#include 
#include 
#include  /* DHH: for struct Output_Sink */

/*
 * DHH: Hack long long arithmetic requires runtime support.
 * Use unsigned long as greatest unsigned integer supported.
 */
typedef long intmax_t;
typedef unsigned long uintmax_t;
typedef unsigned long uintptr_t;

/* DHH */
#define ASSERT(exp) \
do { if (!(exp)) while(1); } while (0)

enum flags {
  FL_ZERO   = 0x01 /* Zero modifier */
  FL_MINUS  = 0x02 /* Minus modifier */
  FL_PLUS   = 0x04 /* Plus modifier */
  FL_TICK   = 0x08 /* ‘ modifier */
  FL_SPACE  = 0x10 /* Space modifier */
  FL_HASH   = 0x20 /* # modifier */
  FL_SIGNED = 0x40 /* Number is signed */
  FL_UPPER  = 0x80 /* Upper case digits */
};

/* These may have to be adjusted on certain implementations */
enum ranks {
  rank_char = -2
  rank_short = -1
  rank_int  = 0
  rank_long = 1
#if 0
  rank_longlong = 2
#endif
};

#define MIN_RANK rank_char
#define MAX_RANK rank_long

#define INTMAX_RANK rank_long
#define SIZE_T_RANK rank_long
#define PTRDIFF_T_RANK rank_long

/* DHH */
#define EMIT(x) do { (q)->Emit((q) (x)); } while (0)

/*
 * DHH - As a hack we buffer this many digits when generating
 * a number.  Because this code originally was an implementation
 * of vnsprintf() it generated some digits backwards in a buffer.
 * Obviously we can‘t do this when emitting output directly
 * to the console or a file.  So we buffer the generated digits
 * and then emit them in order.
 *
 * This value should be adequate to emit values up to 2^32-1 in
 * bases 2 or greater including tick marks.
 */
#define NDIGITS_MAX 43

static size_t
format_int(struct Output_Sink *q uintmax_t val enum flags flags
   int base int width int prec)
{
  char *qq;
  size_t o = 0 oo;
  static const char lcdigits[] = “0123456789abcdef“;
  static const char ucdigits[] = “0123456789ABCDEF“;
  const char *digits;
  uintmax_t tmpval;
  int minus = 0;
  int ndigits = 0 nchars;
  int tickskip b4tick;
  char

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-04-12 23:53  geekos-0.3.0\
     目录           0  2018-04-12 23:53  geekos-0.3.0\doc\
     文件        8371  2005-04-13 00:02  geekos-0.3.0\doc\apiref.html
     文件        6111  2005-04-13 00:02  geekos-0.3.0\doc\elfparsingproject.html
     文件        4909  2005-04-13 00:02  geekos-0.3.0\doc\FAQ.html
     目录           0  2018-04-12 23:53  geekos-0.3.0\doc\figures\
     文件       50626  2005-04-13 00:02  geekos-0.3.0\doc\figures\faultaction2.png
     文件         722  2005-04-13 00:02  geekos-0.3.0\doc\figures\important.png
     文件         490  2005-04-13 00:02  geekos-0.3.0\doc\figures\note.png
     文件        4946  2005-04-13 00:02  geekos-0.3.0\doc\figures\sharedfile.pdf
     文件        2491  2005-04-13 00:02  geekos-0.3.0\doc\figures\sharedfile.png
     文件        6352  2005-04-13 00:02  geekos-0.3.0\doc\figures\vfs.pdf
     文件        4110  2005-04-13 00:02  geekos-0.3.0\doc\figures\vfs.png
     文件       28387  2005-04-13 00:02  geekos-0.3.0\doc\figures\vm2.png
     文件        1241  2005-04-13 00:02  geekos-0.3.0\doc\figures\warning.png
     文件       26462  2005-04-13 00:02  geekos-0.3.0\doc\fsproject.html
     文件         343  2005-04-13 00:02  geekos-0.3.0\doc\hacking-db2latex.xsl.in
     文件        1226  2005-04-13 00:02  geekos-0.3.0\doc\hacking-html.xsl.in
     文件      348501  2005-04-13 00:02  geekos-0.3.0\doc\hacking.pdf
     文件      117259  2005-04-13 00:02  geekos-0.3.0\doc\hacking.xml
     文件       10369  2005-04-13 00:02  geekos-0.3.0\doc\hacking101.html
     文件       13735  2005-04-13 00:02  geekos-0.3.0\doc\index.html
     文件        5085  2005-04-13 00:02  geekos-0.3.0\doc\intro.html
     文件        3559  2005-04-13 00:02  geekos-0.3.0\doc\introproject.html
     文件        2361  2005-04-13 00:02  geekos-0.3.0\doc\ipcproject.html
     文件        1709  2005-04-13 00:02  geekos-0.3.0\doc\Makefile
     文件       27175  2005-04-13 00:02  geekos-0.3.0\doc\overview.html
     文件       18660  2005-04-13 00:02  geekos-0.3.0\doc\projectoverview.html
     文件       11985  2005-04-13 00:02  geekos-0.3.0\doc\schedulingproject.html
     文件       17623  2005-04-13 00:02  geekos-0.3.0\doc\usermodeproject.html
     文件       20515  2005-04-13 00:02  geekos-0.3.0\doc\vmproject.html
............此处省略1388个文件信息

评论

共有 条评论