util.cpp

来自「EM8511s中使用的avi播放器」· C++ 代码 · 共 48 行

CPP
48
字号
#include <sys/time.h>#include <sys/ipc.h>#include <sys/msg.h>#include <sys/wait.h>#include "util.h"int loadmodule (char *module){	pid_t pid;	char *my_argv[4] = {INSMOD_PROG, module, NULL};	char *my_envp[1] = {NULL};	int status;	if ((pid = vfork()) == 0) 	{                       		//this is the child do the execve		execve (INSMOD_PATH""INSMOD_PROG, my_argv, my_envp);		_exit (1);	} 	else 	{		// this is the parent.		pid = waitpid (pid, &status, 0);		if (WIFEXITED (status) && (WEXITSTATUS (status) != 0))		{			return 1;		} 		else if (WIFEXITED (status) && (WEXITSTATUS (status) == 0))		{			return 0;		} 		else 		{			printf ("Seems that an error happened during module loading\n");			return 1;		}	}	return 0;}int gettime_ms (void){	struct timeval tv1;	struct timezone tz;	gettimeofday (&tv1, &tz);	return tv1.tv_sec * 1000 + tv1.tv_usec/1000;}

⌨️ 快捷键说明

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