📄 putk.c
字号:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/mm/putk.c
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19300 /* MM must occasionally print some message. It uses the standard library
19301 * routine printk(). (The name "printf" is really a macro defined as
19302 * "printk"). Printing is done by calling the TTY task directly, not going
19303 * through FS.
19304 */
19305
19306 #include "mm.h"
19307 #include <minix/com.h>
19308
19309 #define BUF_SIZE 100 /* print buffer size */
19310
19311 PRIVATE int buf_count; /* # characters in the buffer */
19312 PRIVATE char print_buf[BUF_SIZE]; /* output is buffered here */
19313 PRIVATE message putch_msg; /* used for message to TTY task */
19314
19315 _PROTOTYPE( FORWARD void flush, (void) );
19316
19317 /*===========================================================================*
19318 * putk *
19319 *===========================================================================*/
19320 PUBLIC void putk(c)
19321 int c;
19322 {
19323 /* Accumulate another character. If 0 or buffer full, print it. */
19324
19325 if (c == 0 || buf_count == BUF_SIZE) flush();
19326 if (c == '\n') putk('\r');
19327 if (c != 0) print_buf[buf_count++] = c;
19328 }
19331 /*===========================================================================*
19332 * flush *
19333 *===========================================================================*/
19334 PRIVATE void flush()
19335 {
19336 /* Flush the print buffer by calling TTY task. */
19337
19338 if (buf_count == 0) return;
19339 putch_msg.m_type = DEV_WRITE;
19340 putch_msg.PROC_NR = 0;
19341 putch_msg.TTY_LINE = 0;
19342 putch_msg.ADDRESS = print_buf;
19343 putch_msg.COUNT = buf_count;
19344 sendrec(TTY, &putch_msg);
19345 buf_count = 0;
19346 }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -