/* * consoledemo.c * * Part of librfn (a general utility library from redfelineninja.org.uk) * * Copyright (C) 2014 Daniel Thompson * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. */ #include #include #include #include "librfn.h" /* * console_add is not protothreaded. It can simply return PT_EXITED. */ static pt_state_t console_add(console_t *c) { if (c->argc != 3) fprintf(c->out, "Usage: add \n"); else fprintf(c->out, "%ld\n", strtol(c->argv[1], NULL, 0) + strtol(c->argv[2], NULL, 0)); return PT_EXITED; } static const console_cmd_t cmd_add = CONSOLE_CMD_VAR_INIT("add", console_add); /* * console_udelay is a busy-wait (scheduler cannot go idle) that yields to other * protothreads of fibres. */ static pt_state_t console_udelay(console_t *c) { PT_BEGIN(&c->pt); if (c->argc != 2) { fprintf(c->out, "Usage: udelay