XINU
Macros | Functions
fputc.c File Reference

文字をデバイス(ファイル)に書き込む。 More...

Go to the source code of this file.

Macros

#define EOF   (-2)
 End Of Fileを示す値 More...
 
#define SYSERR   (-1)
 システムエラーを示す値 More...
 

Functions

int fputc (int c, int dev)
 文字をデバイス(ファイル)に書き込む。 More...
 
int putc (int, char)
 文字を書き込むputc()のextern宣言 More...
 

Detailed Description

文字をデバイス(ファイル)に書き込む。

Definition in file fputc.c.

Macro Definition Documentation

◆ EOF

#define EOF   (-2)

End Of Fileを示す値

Definition at line 15 of file fputc.c.

Referenced by fputc().

◆ SYSERR

#define SYSERR   (-1)

システムエラーを示す値

Definition at line 11 of file fputc.c.

Referenced by fputc().

Function Documentation

◆ fputc()

int fputc ( int  c,
int  dev 
)

文字をデバイス(ファイル)に書き込む。

Parameters
[in]c書き込む文字
[in]devデバイスディスクリプタ
Returns
成功時は書き込んだ文字、異常時はEOFを返す。

Definition at line 24 of file fputc.c.

References EOF, putc(), and SYSERR.

Referenced by putchar().

25 {
26  if (SYSERR == (int)putc(dev, c))
27  {
28  return EOF;
29  }
30  else
31  {
32  return c;
33  }
34 }
int putc(int, char)
文字を書き込むputc()のextern宣言
Definition: putc.c:18
#define EOF
End Of Fileを示す値
Definition: fputc.c:15
#define SYSERR
システムエラーを示す値
Definition: fputc.c:11
Here is the call graph for this function:
Here is the caller graph for this function:

◆ putc()

int putc ( did32  descrp,
char  ch 
)

文字を書き込むputc()のextern宣言

文字を書き込むputc()のextern宣言

Step1. 割り込みを禁止する。
Step2. デバイスディスクリプタが不正値の場合は、割り込み状態を復元し、処理を終了する。
Step3. デバイスに応じたputc()処理を行う。
Step4. 割り込み状態を復元する。

Parameters
[in]descrpデバイスディスクリプタ
[in]ch送信したい文字
Returns
成功時はデバイスに応じた返り値、デバイスディスクリプタが不正値の場合はSYSERRを返す。

Definition at line 18 of file putc.c.

Referenced by fputc().

19 {
20  intmask mask; /* Saved interrupt mask */
21  struct dentry *devptr; /* Entry in device switch table */
22  int32 retval; /* Value to return to caller */
23 
24  mask = disable();
25  if (isbaddev(descrp))
26  {
27  restore(mask);
28  return SYSERR;
29  }
30  devptr = (struct dentry *)&devtab[descrp];
31  retval = (*devptr->dvputc)(devptr, ch);
32  restore(mask);
33  return retval;
34 }
void restore(intmask)
#define SYSERR
処理が失敗した場合
Definition: kernel.h:79
devcall(* dvputc)(struct dentry *, char)
Definition: conf.h:17
Definition: conf.h:6
struct dentry devtab[]
Definition: conf.c:11
uint32 intmask
保存された割り込みマスク
Definition: kernel.h:38
int int32
符号あり32ビット整数(int)
Definition: kernel.h:11
#define isbaddev(f)
デバイスIDを検証するマクロ。
Definition: device.h:15
intmask disable(void)
割り込み禁止(intr.Sに定義がある)
Here is the caller graph for this function: