test00.c

来自「minix操作系统最新版本(3.1.1)的源代码」· C语言 代码 · 共 59 行

C
59
字号
/* * Test name: test00.c * * Objetive: The purpose of this test is to make sure that the bitmap  * manipulation macros work without problems.   * * Description: This tests first fills a fd_set bit by bit, and shows it, then * it clears the fd_set bit by bit as well.  * * Jose M. Gomez */#include <sys/types.h>#include <fcntl.h>#include <unistd.h>#include <sys/select.h>#include <stdio.h>#include <stdlib.h>#include <limits.h>int main(int argc, char *argv[]) {	fd_set fds;	int i,j;		FD_ZERO(&fds);	for (i=0;i<FD_SETSIZE;i++) {		/* see if SET works */		FD_SET(i, &fds);		if(!FD_ISSET(i, &fds))			return 1;	}	FD_ZERO(&fds);	for (i=0;i<FD_SETSIZE;i++) {		/* see if ZERO works */		if(FD_ISSET(i, &fds))			return 1;	}	for (i=0;i<FD_SETSIZE;i++) {		FD_SET(i, &fds);		for(j = 0; j <= i; j++)			if(!FD_ISSET(j, &fds))				return 1;		for(; j < FD_SETSIZE; j++) 			if(FD_ISSET(j, &fds))				return 1;	}	for (i=0;i<FD_SETSIZE;i++) {		FD_CLR(i, &fds);		for(j = 0; j <= i; j++)			if(FD_ISSET(j, &fds))				return 1;		for(; j < FD_SETSIZE; j++) 			if(!FD_ISSET(j, &fds))				return 1;	}	printf("ok\n");	return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?