diff --git a/.gitignore b/.gitignore index b9f01083408a3ddca4aa5e1b5bf86b0c850d37e7..f1056e8de37f250473364d6b56a30d8bb2ce03e4 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,7 @@ lib/c/liblabcomm.a compiler/AST/ compiler/labComm.jar +examples/twoway/gen/ +lib/csharp/labcomm.dll +lib/java/gen/ +lib/java/labcomm.jar diff --git a/lib/c/Makefile b/lib/c/Makefile index 886d8185ff764ffb188bee9544f9bbb90334e0a9..c5af86b5d5b8e42d646bc3305de47ca9da3e558a 100644 --- a/lib/c/Makefile +++ b/lib/c/Makefile @@ -1,8 +1,19 @@ ## Macros UNAME_S=$(shell uname -s) +ALL_DEPS=liblabcomm.a liblabcomm.so.1 + ifeq ($(UNAME_S),Linux) - CC=gcc - CFLAGS=-std=c99 -g -Wall -Werror -O3 -I. -Itest + CFLAGS=-std=c99 -g -Wall -Werror -O3 -I. -Itest + ifndef TARGET + CC=gcc + else ifeq ($(TARGET),vx) + CC=i586-wrs-vxworks-gcc + LD=i586-wrs-vxworks-ld + ALL_DEPS:=$(filter-out %.so.1, $(ALL_DEPS)) + CFLAGS:=$(CFLAGS) -DLABCOMM_COMPAT=\"labcomm_compat_vxworks.h\" + else + @echo 'Invalid target.' + endif LDFLAGS=-L. LDLIBS=-llabcomm -lrt MAKESHARED=gcc -o $1 -shared -Wl,-soname,$2 $3 -lc -lrt @@ -57,7 +68,7 @@ endif .PHONY: all run-test clean distclean -all: liblabcomm.a liblabcomm.so.1 +all: $(ALL_DEPS) liblabcomm.a: $(OBJS) ar -r $@ $^ diff --git a/lib/c/labcomm.h b/lib/c/labcomm.h index b83cdf85faa6dc4890d489ec915b5329090993a9..0c264bcb956ceb73bcddcd6027318c6763340838 100644 --- a/lib/c/labcomm.h +++ b/lib/c/labcomm.h @@ -24,8 +24,14 @@ #define _LABCOMM_H_ #include <stdarg.h> -#include <stdint.h> -#include <unistd.h> + +#ifdef LABCOMM_COMPAT + #include LABCOMM_COMPAT +#else + #include <stdint.h> + #include <unistd.h> +#endif + #include "labcomm_error.h" #include "labcomm_scheduler.h" diff --git a/lib/c/labcomm_compat_vxworks.h b/lib/c/labcomm_compat_vxworks.h index f05ee787d334e27dd32ef03bd0ff84b3c2cea086..00a2b5acf931475e22533ab52502dd8fe5a6a8ac 100644 --- a/lib/c/labcomm_compat_vxworks.h +++ b/lib/c/labcomm_compat_vxworks.h @@ -1,7 +1,13 @@ +#ifndef _LABCOMM_COMPAT_VXWORKS_H_ +#define _LABCOMM_COMPAT_VXWORKS_H_ + #ifndef __VXWORKS__ #error "__VXWORKS__" not defined #endif +#include <types/vxTypes.h> +#include <stdio.h> + #if (CPU == PPC603) #undef _LITTLE_ENDIAN #endif @@ -10,3 +16,5 @@ #undef _BIG_ENDIAN #endif +#endif + diff --git a/lib/c/labcomm_decoder.c b/lib/c/labcomm_decoder.c index d6ecd5e5103e82faf39d8edf8c7f24228736bb5c..0606e6fd18a424963830a5e3eb59a12adfdcd065 100644 --- a/lib/c/labcomm_decoder.c +++ b/lib/c/labcomm_decoder.c @@ -199,7 +199,9 @@ static int decode_typedef_or_sample(struct labcomm_decoder *d, int kind) LABCOMM_IOCTL_WRITER_GET_BYTES_WRITTEN, &signature.size); if (err < 0) { - fprintf(stderr, "Failed to get size: %s\n", strerror(-err)); + /* fprintf(stderr, "Failed to get size: %s\n", strerror(-err)); */ + labcomm_error_warning(d->error, LABCOMM_ERROR_BAD_WRITER, + "Failed to get size: %s\n", strerror(-err)); result = -ENOENT; goto free_signature_name; } @@ -207,7 +209,9 @@ static int decode_typedef_or_sample(struct labcomm_decoder *d, int kind) LABCOMM_IOCTL_WRITER_GET_BYTE_POINTER, &signature.signature); if (err < 0) { - fprintf(stderr, "Failed to get pointer: %s\n", strerror(-err)); + /* fprintf(stderr, "Failed to get pointer: %s\n", strerror(-err)); */ + labcomm_error_warning(d->error, LABCOMM_ERROR_BAD_WRITER, + "Failed to get pointer: %s\n", strerror(-err)); result = -ENOENT; goto free_signature_name; } diff --git a/lib/c/labcomm_error.h b/lib/c/labcomm_error.h index dd124c96fe80b4bec7c95d8e087fa89d052424be..80e4805d96c071967d3be7b964c2d549e304f6ef 100644 --- a/lib/c/labcomm_error.h +++ b/lib/c/labcomm_error.h @@ -64,5 +64,7 @@ LABCOMM_ERROR(LABCOMM_ERROR_MEMORY, "Could not allocate memory") LABCOMM_ERROR(LABCOMM_ERROR_USER_DEF, "User defined error") +LABCOMM_ERROR(LABCOMM_ERROR_BAD_WRITER, + "Decoder: writer_ioctl() failed") #endif diff --git a/lib/c/labcomm_fd_reader.c b/lib/c/labcomm_fd_reader.c index e397c84401a27a59aec74da39e37cedbf111e7f5..65a9fbbc20f3ed7526677fa3feeb6ef13465bf74 100644 --- a/lib/c/labcomm_fd_reader.c +++ b/lib/c/labcomm_fd_reader.c @@ -98,7 +98,7 @@ static int fd_fill(struct labcomm_reader *r, int err; r->pos = 0; - err = read(fd_reader->fd, r->data, r->data_size); + err = read(fd_reader->fd, (char *)r->data, r->data_size); if (err <= 0) { r->count = 0; r->error = -EPIPE; diff --git a/lib/c/labcomm_fd_writer.c b/lib/c/labcomm_fd_writer.c index acf6934ad7c50eec43dba087b8d863e045ac4703..9ea707fdae04c8e4dece32fa63a342d7b86687eb 100644 --- a/lib/c/labcomm_fd_writer.c +++ b/lib/c/labcomm_fd_writer.c @@ -101,7 +101,7 @@ static int fd_flush(struct labcomm_writer *w, start = 0; err = 0; while (start < w->pos) { - err = write(fd_context->fd, &w->data[start], w->pos - start); + err = write(fd_context->fd, (char *)&w->data[start], w->pos - start); if (err <= 0) { break; } diff --git a/lib/c/labcomm_private.h b/lib/c/labcomm_private.h index ab4e315d0b28f89fb5e8bbaa607e0848dbe37084..c74c4a7b7d9a02bfe1e0c4dea169212cfebeecf3 100644 --- a/lib/c/labcomm_private.h +++ b/lib/c/labcomm_private.h @@ -28,12 +28,12 @@ #else #include <endian.h> #include <stdio.h> + #include <stdint.h> + #include <unistd.h> #endif -#include <stdint.h> //#include <stdlib.h> #include <string.h> -#include <unistd.h> #include "labcomm.h" /* diff --git a/lib/c/labcomm_scheduler.h b/lib/c/labcomm_scheduler.h index 4aef48daf6c734cafdb25780a43954d0340beb71..07f74c281ab7fff57ec8edf86e6f04219f2e3427 100644 --- a/lib/c/labcomm_scheduler.h +++ b/lib/c/labcomm_scheduler.h @@ -22,8 +22,12 @@ #ifndef _LABCOMM_SCHEDULER_H_ #define _LABCOMM_SCHEDULER_H_ -#include <unistd.h> -#include <stdint.h> +#ifdef LABCOMM_COMPAT + #include LABCOMM_COMPAT +#else + #include <unistd.h> + #include <stdint.h> +#endif struct labcomm_time; diff --git a/lib/c/labcomm_scheduler_private.h b/lib/c/labcomm_scheduler_private.h index cc4d50e40c518eb7c43b928918e1f568a8301065..398552e0e434f17b4f332364ce09256dcb4d682c 100644 --- a/lib/c/labcomm_scheduler_private.h +++ b/lib/c/labcomm_scheduler_private.h @@ -22,7 +22,12 @@ #ifndef _LABCOMM_SCHEDULER_PRIVATE_H_ #define _LABCOMM_SCHEDULER_PRIVATE_H_ -#include <unistd.h> +#ifdef LABCOMM_COMPAT + #include LABCOMM_COMPAT +#else + #include <unistd.h> +#endif + #include "labcomm_scheduler.h" struct labcomm_time {