LC_RESUME() should not resume a NULL lc, added LC_END() macro
diff --git a/contiki-gtk/lib/lc.h b/contiki-gtk/lib/lc.h
index 8e5d155..8415c65 100644
--- a/contiki-gtk/lib/lc.h
+++ b/contiki-gtk/lib/lc.h
@@ -1,25 +1,26 @@
-/* Local continuations: a form of continuation that only works locally
- within a function.
-
- NOTE: this particular implementation only works with GCC!
-*/
-
#ifndef __LC_H__
#define __LC_H__
typedef void * lc_t;
-#define __LC_CONCAT2(s1, s2) s1##s2
-#define __LC_CONCAT(s1, s2) __LC_CONCAT2(s1, s2)
+#define LC_CONCAT2(s1, s2) s1##s2
+#define LC_CONCAT(s1, s2) LC_CONCAT2(s1, s2)
#define LC_SET(s) \
do { \
- __LC_CONCAT(LC_LABEL, __LINE__): \
- (s) = &&__LC_CONCAT(LC_LABEL, __LINE__); \
+ LC_CONCAT(LC_LABEL, __LINE__): \
+ (s) = &&LC_CONCAT(LC_LABEL, __LINE__); \
} while(0)
-#define LC_RESUME(s) goto *s
+#define LC_RESUME(s) \
+ do { \
+ if(s != NULL) { \
+ goto *s; \
+ } \
+ } while(0)
-#define LC_NULL (lc_t)0
+#define LC_END(s)
+
+#define LC_INIT(s) s = NULL
#endif /* __LC_H__ */