static void
_log_waitpid(int loglevel, int errnum, pid_t pid)
{
  char fmt[FMT_UINT];
  fmt[fmtuint(&fmt[0], pid)] = '\0';
  _log1(loglevel, "waitpid", errnum, "cannot wait child process ", &fmt[0]);
}
static void
_log_dup2(int loglevel, int errnum, int fd)
{
  char fmt[FMT_UINT];
  fmt[fmtuint(&fmt[0], fd)] = '\0';
  _log1(LOG_FATAL, "dup2", errnum, "cannot duplicated fd ", &fmt[0]);
}
static void
_log_close(int loglevel, int errnum, int fd)
{
  char fmt[FMT_UINT];
  fmt[fmtuint(&fmt[0], fd)] = '\0';
  _log1(loglevel, "close", errnum, "cannot close fd ", &fmt[0]);
}
__attribute__((noreturn)) static void
die_waithang(pid_t pid)
{
  char fmt[FMT_UINT];
  fmt[fmtuint(&fmt[0], pid)] = '\0';
  _log1(LOG_FATAL, "waitpid", ECHILD, "unwaited child process ", &fmt[0]);
  die();
}
__attribute__((noreturn)) static void
die_pollfd(int fd)
{
  char fmt[FMT_UINT];
  fmt[fmtuint(&fmt[0], fd)] = '\0';
  _log1(LOG_FATAL, "poll", 0, "cannot poll fd ", &fmt[0]);
  die();
}
static void
_log_sigaction(int loglevel, int errnum, int signum)
{
  _log1(loglevel,
        "sigaction",
        errnum,
        "cannot set handler for ",
        strsignal(signum));
}
Example #7
0
void calculateResult()
{
	long x,y;
	if(stack_isempty(sd1))
	{
		x=result;
	}
	else
	{
		x=get_value_of_stack(sd1);
	}
	y=get_value_of_stack(sd2);

	//do the operation
	switch (operator)
	{
	case 0:
		result = x + y;
		break;
	case 1:
		result = x-y;
		break;
	case 2:
		result = x*y;
		break;
	case 3:
		result = x/y;
		break;
	}

	//display
//	if(stack_isempty(sd1))
//	{
		LCD_Clear();
		LCD_Gotoxy(0,0);
		char* d=(char*)malloc(digitsLength);
		LCD_SendStr(itoa(result, d, 10));

		_log("operator \0") _log1(ops[operator]) _log("\r\0")
		_log("result \0") _log(d) _log("\r\0")
//	}
//	else
//	{
//		LCD_Clear();
//		LCD_Gotoxy(0,0);
//		char* d1=(char*)malloc(digitsLength);
//		LCD_SendStr(itoa(x, d1, 10));
//		LCD_SendData(ops[operator]); //error send the op as char not int
//		char* d2=(char*)malloc(digitsLength);
//		LCD_SendStr(itoa(y, d2, 10));
//	}

	//clear stacks
	stack_Clear(sd1);
	stack_Clear(sd2);
}
static void
_log_noblock(int loglevel, int errnum, int fd)
{
  char fmt[FMT_UINT];
  fmt[fmtuint(&fmt[0], fd)] = '\0';
  _log1(loglevel,
        "fcntl",
        errnum,
        "cannot set non-blocking mode for fd ",
        &fmt[0]);
}
static void
_log_coe(int loglevel, int errnum, int fd)
{
  char fmt[FMT_UINT];
  fmt[fmtuint(&fmt[0], fd)] = '\0';
  _log1(loglevel,
        "fcntl",
        errnum,
        "cannot set close-on-exec flag for fd ",
        &fmt[0]);
}
__attribute__((noreturn)) static void
die_waitstatus(pid_t pid)
{
  char fmt[FMT_UINT];
  fmt[fmtuint(&fmt[0], pid)] = '\0';
  _log1(LOG_FATAL,
        "waitpid",
        EINVAL,
        "unexpected status from child process ",
        &fmt[0]);
  die();
}
static void
_log_fork(int loglevel, int errnum, const char *file)
{
  _log1(loglevel, "fork", errnum, "cannot fork for child process ", file);
}
static void
_log_execve(int loglevel, int errnum, const char *file)
{
  _log1(loglevel, "execve", errnum, "cannot exec child process ", file);
}
static void
_log0(int loglevel, const char *syscall, int errnum, const char *msg)
{
  _log1(loglevel, syscall, errnum, msg, 0);
}