Skip to content

Commit

Permalink
Merge pull request #113 from oliverschmidt/master
Browse files Browse the repository at this point in the history
Allow to reduce functionality if non-standard alloca() isn't available.
  • Loading branch information
oliverschmidt committed Feb 3, 2013
2 parents b504601 + b493395 commit 1324fa6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions apps/shell/shell-crc.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@
#include <stdlib.h>
#include <string.h>

#ifdef __CC65__
#define HAVE_ALLOCA 0
#else
#define HAVE_ALLOCA 1
#endif

#define DEBUG 0
#if DEBUG
#include <stdio.h>
Expand All @@ -55,6 +61,7 @@
#endif

/*---------------------------------------------------------------------------*/
#if HAVE_ALLOCA
PROCESS(shell_bin2hex_process, "bin2hex");
SHELL_COMMAND(bin2hex_command,
"bin2hex",
Expand All @@ -70,12 +77,14 @@ SHELL_COMMAND(crc_command,
"crc",
"crc: append per-block crc",
&shell_crc_process);
#endif /* HAVE_ALLOCA */
PROCESS(shell_crcvalidate_process, "crc-v");
SHELL_COMMAND(crcvalidate_command,
"crc-v",
"crc-v: verify crc and output if valid",
&shell_crcvalidate_process);
/*---------------------------------------------------------------------------*/
#if HAVE_ALLOCA
static unsigned char
fromhexchar(unsigned char c)
{
Expand Down Expand Up @@ -221,6 +230,7 @@ PROCESS_THREAD(shell_crc_process, ev, data)

PROCESS_END();
}
#endif /* HAVE_ALLOCA */
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_crcvalidate_process, ev, data)
{
Expand Down Expand Up @@ -289,9 +299,11 @@ PROCESS_THREAD(shell_crcvalidate_process, ev, data)
void
shell_crc_init(void)
{
#if HAVE_ALLOCA
shell_register_command(&bin2hex_command);
shell_register_command(&hex2bin_command);
shell_register_command(&crc_command);
#endif /* HAVE_ALLOCA */
shell_register_command(&crcvalidate_command);
}
/*---------------------------------------------------------------------------*/

0 comments on commit 1324fa6

Please sign in to comment.