samples:philosophers:Reformated 80-column width, 80-chars tabs

This patch reformats philosophers sample to fit in 80 columns
with 8-char tabs. It also fixes other coding style issues
reported by chechpatch.pl script with -f option.

Change-Id: Ie7ed59db4e67e279a26000247a1838221ac37cd3
Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
This commit is contained in:
Yannis Damigos 2016-03-08 12:24:05 +02:00 committed by Gerrit Code Review
commit 31100d1a61
3 changed files with 18 additions and 18 deletions

View file

@ -16,9 +16,9 @@
* limitations under the License.
*/
#if defined(CONFIG_STDOUT_CONSOLE)
#include <stdio.h>
#include <stdio.h>
#else
#include <misc/printk.h>
#include <misc/printk.h>
#endif
#define N_PHILOSOPHERS 6
@ -27,7 +27,8 @@
* Therefore use puts() instead of printf().
*/
#if defined(CONFIG_STDOUT_CONSOLE)
#define PRINTF(...) {char output[256]; sprintf(output, __VA_ARGS__); puts(output);}
#define PRINTF(...) { char output[256]; \
sprintf(output, __VA_ARGS__); puts(output); }
#else
#define PRINTF(...) printk(__VA_ARGS__)
#define PRINTF(...) printk(__VA_ARGS__)
#endif

View file

@ -19,25 +19,26 @@
#include "phil.h"
#ifdef CONFIG_NANOKERNEL
#define FORK(x) &forks[x]
#define TAKE(x) nano_fiber_sem_take(x, TICKS_UNLIMITED)
#define GIVE(x) nano_fiber_sem_give(x)
#define FORK(x) (&forks[x])
#define TAKE(x) nano_fiber_sem_take(x, TICKS_UNLIMITED)
#define GIVE(x) nano_fiber_sem_give(x)
#else /* ! CONFIG_NANOKERNEL */
#define FORK(x) forks[x]
#define TAKE(x) task_mutex_lock(x, TICKS_UNLIMITED)
#define GIVE(x) task_mutex_unlock(x)
#define FORK(x) forks[x]
#define TAKE(x) task_mutex_lock(x, TICKS_UNLIMITED)
#define GIVE(x) task_mutex_unlock(x)
#endif /* CONFIG_NANOKERNEL */
#define RANDDELAY(x) myDelay(((sys_tick_get_32() * ((x) + 1)) & 0x1f) + 1)
#define PRINT(x,y) myPrint(x,y)
#define PRINT(x, y) myPrint(x, y)
#ifdef CONFIG_NANOKERNEL
/* externs */
extern struct nano_sem forks[N_PHILOSOPHERS];
#else /* ! CONFIG_NANOKERNEL */
kmutex_t forks[] = {forkMutex0, forkMutex1, forkMutex2, forkMutex3, forkMutex4, forkMutex5};
kmutex_t forks[] = {forkMutex0, forkMutex1, forkMutex2, forkMutex3, forkMutex4,
forkMutex5};
#endif /* CONFIG_NANOKERNEL */
/**

View file

@ -23,13 +23,12 @@
"\x1b[2J\x1b[15;1H" \
"Demo Description\n" \
"----------------\n" \
"An implementation of a solution to the Dining Philosophers problem\n" \
"(a classic multi-thread synchronization problem). This particular\n" \
"implementation demonstrates the usage of multiple (6) %s\n" \
"An implementation of a solution to the Dining Philosophers problem\n" \
"(a classic multi-thread synchronization problem). This particular\n" \
"implementation demonstrates the usage of multiple (6) %s\n" \
"of differing priorities and the %s semaphores and timers."
#ifdef CONFIG_NANOKERNEL
#define STSIZE 1024
/* externs */
@ -62,7 +61,7 @@ int main(void)
/* create philosopher fibers */
for (i = 0; i < N_PHILOSOPHERS; i++) {
task_fiber_start(&philStack[i][0], STSIZE,
(nano_fiber_entry_t) philEntry, 0, 0, 6, 0);
(nano_fiber_entry_t) philEntry, 0, 0, 6, 0);
}
/* wait forever */
@ -71,7 +70,6 @@ int main(void)
nano_cpu_idle();
}
}
#else
/**
*